Thursday, 6 May 2021

Calling requestDismissKeyguard() twice with a delayed result

I'm working an app that has call capabilities so I need the device to wake up. If the device is locked, I use the following code to unlock:

keyguardManager.requestDismissKeyguard(this, new KeyguardManager.KeyguardDismissCallback() {

    @Override
    public void onDismissError() {
        super.onDismissError();
        AppLog.d(TAG, "Inside onDismissError()");
    }

    @Override
    public void onDismissSucceeded() {
        super.onDismissSucceeded();
        AppLog.d(TAG, "Inside onDismissSucceeded()");
    }

    @Override
    public void onDismissCancelled() {
        super.onDismissCancelled();
        AppLog.d(TAG, "Inside onDismissCancelled()");
    }
});

On an initial call the device is unlocking without any issues, but on a second call, there is a delay from when requestDismissKeyguard is called and when the callback is called, so my device stays on with the lock screen open, causing a weird state because the user is expecting an incoming call screen.

See my logs here:

2021-04-21 16:25:39.885: Invoking requestDismissKeyguard()
2021-04-21 16:25:39.994: Inside onDismissCancelled()

2021-04-21 16:25:51.835: Invoking requestDismissKeyguard()
2021-04-21 16:25:55.311: Inside onDismissCancelled()

Notice the difference between the first call (gets cancelled within 100ms) and the second call (gets cancelled within 4s!!!)

Any ideas? Suggestions?



from Calling requestDismissKeyguard() twice with a delayed result

No comments:

Post a Comment