import android.content.pm.PackageManager;
import android.hardware.fingerprint.FingerprintManager;
import android.os.Bundle;
+import android.util.Log;
import android.view.View;
import androidx.annotation.VisibleForTesting;
*/
public class FingerprintEnrollFinish extends BiometricEnrollBase {
+ private static final String TAG = "FingerprintEnrollFinish";
@VisibleForTesting
static final int REQUEST_ADD_ANOTHER = 1;
@VisibleForTesting
}
@Override
+ public void onBackPressed() {
+ super.onBackPressed();
+
+ updateFingerprintSuggestionEnableState();
+ }
+
+ @Override
protected void onResume() {
super.onResume();
@Override
protected void onNextButtonClick(View view) {
- setFingerprintSuggestionEnabled();
+ updateFingerprintSuggestionEnableState();
setResult(RESULT_FINISHED);
finish();
}
- private void setFingerprintSuggestionEnabled() {
+ private void updateFingerprintSuggestionEnableState() {
final FingerprintManager fpm = Utils.getFingerprintManagerOrNull(this);
if (fpm != null) {
int enrolled = fpm.getEnrolledFingerprints(mUserId).size();
FINGERPRINT_SUGGESTION_ACTIVITY);
getPackageManager().setComponentEnabledSetting(
componentName, flag, PackageManager.DONT_KILL_APP);
+ Log.d(TAG, FINGERPRINT_SUGGESTION_ACTIVITY + " enabled state = " + (enrolled == 1));
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
- setFingerprintSuggestionEnabled();
+ updateFingerprintSuggestionEnableState();
if (requestCode == REQUEST_ADD_ANOTHER && resultCode != RESULT_CANCELED) {
setResult(resultCode, data);
finish();
assertThat(application.getPackageManager().getComponentEnabledSetting(
mComponentName)).isEqualTo(PackageManager.COMPONENT_ENABLED_STATE_ENABLED);
}
+
+ @Test
+ public void onBackPressed_fingerprintCountIsNotOne_fingerprintSuggestionActivityDisabled() {
+ Shadows.shadowOf((FingerprintManager) mFingerprintManager).setDefaultFingerprints(2);
+
+ mActivity.onBackPressed();
+
+ assertThat(application.getPackageManager().getComponentEnabledSetting(
+ mComponentName)).isEqualTo(PackageManager.COMPONENT_ENABLED_STATE_DISABLED);
+ }
+
+ @Test
+ public void onBackPressed_fingerprintCountIsOne_fngerprintSuggestionActivityEnabled() {
+ Shadows.shadowOf((FingerprintManager) mFingerprintManager).setDefaultFingerprints(1);
+
+ mActivity.onBackPressed();
+
+ assertThat(application.getPackageManager().getComponentEnabledSetting(
+ mComponentName)).isEqualTo(PackageManager.COMPONENT_ENABLED_STATE_ENABLED);
+ }
}
\ No newline at end of file