I have an application, where I'm requesting user to Authenticate in my app via KeyguardManager
using PIN.
The important thing is that I have android:showOnLockScreen="true"
to my activity in manifest, so when device is locked, and my activity is showing, I'm tapping on "Sign in" button, which calls showAuthenticationScreen()
, I'm receiving RESULT_CANCELED
in my onActivityResult()
.
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void showAuthenticationScreen() {
KeyguardManager keyguardManager = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);
if (keyguardManager == null) {
return;
}
Intent kgIntent = keyguardManager.createConfirmDeviceCredentialIntent(getString(R.string.nnl_kg_title), getKgPrompt());
if (kgIntent != null) {
startActivityForResult(kgIntent, KG_REQUEST_ID);
}
}
I took a look to system logs, and found out that I'm getting this error back from BiometricService
with message "Canceling from CDC". Here is some part of system logs.
936 936 I ActivityTaskManager: START u0 {act=android.app.action.CONFIRM_DEVICE_CREDENTIAL_WITH_USER flg=0x8080000 pkg=com.android.settings cmp=com.android.settings/.password.ConfirmDeviceCredentialActivity$InternalActivity (has extras)} from
uid 1000
11-11 10:54:53.076 936 972 D ActivityTaskManager: Top Process State changed to PROCESS_STATE_TOP_SLEEPING
11-11 10:54:53.092 936 1032 W ProcessStats: Tracking association SourceState{2c15fa1 com.android.settings/1000 Top #565108} whose proc state 1 is better than process ProcessState{54a9784 com.google.android.gms.persistent/10029 pkg=com.google.android.gms} proc st
ate 2 (9 skipped)
11-11 10:54:53.126 936 936 D BiometricService: Creating auth session. Modality: 1, cookie: 1632337634
11-11 10:54:53.127 936 936 V FingerprintService: startAuthentication(com.android.settings)
11-11 10:54:53.128 936 936 V FingerprintService: Returning cookie: 1632337634
11-11 10:54:53.128 936 936 D BiometricService: Matched cookie: 1632337634, 0 remaining
11-11 10:54:53.128 936 936 V FingerprintService: starting client AuthenticationClientImpl(com.android.settings) cookie: 1632337634/1632337634
11-11 10:54:53.135 936 936 W FingerprintService: client com.android.settings is authenticating...
11-11 10:54:53.161 936 936 D BiometricService: Cancelling from CDC
11-11 10:54:53.162 936 936 V FingerprintService: Stopping client com.android.settings, fromClient: false
11-11 10:54:53.173 936 936 W FingerprintService: client com.android.settings is no longer authenticating
11-11 10:54:53.177 936 3056 D ActivityTaskManager: Top Process State changed to PROCESS_STATE_TOP
11-11 10:54:53.195 936 936 V FingerprintService: handleError(client=com.android.settings, error = 5)
11-11 10:54:53.195 936 936 V FingerprintService: Done with client: com.android.settings
11-11 10:54:53.196 936 936 D BiometricService: Error: 5 cookie: 1632337634
11-11 10:54:53.285 936 3041 I ActivityTaskManager: Activity reported stop, but no longer stopping: ActivityRecord{9b6d8b u0 com.natigbabayev.biometricprompt/.MainActivity t1936}
So is there any solution to this? Can I still ask users to authenticate with PIN even when device is locked? Thank you guys in advance.