Add check to verify if separate lock is setup for private space.
With this change on selecting new lock option for private space it is
taken care to handle back/swipe left action to show the lock setup
screen again if a separate lock is not setup for private profile.
Bug: 307281644
Bug: 313142822
Test: Manual
Change-Id: I8f31b7f69307c0c6947cb0f6c52cb3560e69a156
diff --git a/src/com/android/settings/privatespace/PrivateProfileContextHelperActivity.java b/src/com/android/settings/privatespace/PrivateProfileContextHelperActivity.java
index 9601819..12a7440 100644
--- a/src/com/android/settings/privatespace/PrivateProfileContextHelperActivity.java
+++ b/src/com/android/settings/privatespace/PrivateProfileContextHelperActivity.java
@@ -26,7 +26,6 @@
import static com.android.settings.privatespace.PrivateSpaceSetupActivity.EXTRA_ACTION_TYPE;
import static com.android.settings.privatespace.PrivateSpaceSetupActivity.SET_LOCK_ACTION;
-import android.app.KeyguardManager;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
@@ -37,6 +36,7 @@
import androidx.annotation.Nullable;
import androidx.fragment.app.FragmentActivity;
+import com.android.internal.widget.LockPatternUtils;
import com.android.settings.R;
import com.android.settings.SetupWizardUtils;
import com.android.settings.overlay.FeatureFactory;
@@ -52,9 +52,10 @@
private final ActivityResultLauncher<Intent> mAddAccountToPrivateProfile =
registerForActivityResult(
new ActivityResultContracts.StartActivityForResult(), this::onAccountAdded);
- private final ActivityResultLauncher<Intent> mVerifyDeviceLock =
+ private final ActivityResultLauncher<Intent> mSetNewPrivateProfileLock =
registerForActivityResult(
- new ActivityResultContracts.StartActivityForResult(), this::onSetDeviceNewLock);
+ new ActivityResultContracts.StartActivityForResult(),
+ this::onSetNewProfileLockActionCompleted);
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -88,7 +89,7 @@
intent.putExtra(
EXTRA_KEY_CHOOSE_LOCK_SCREEN_DESCRIPTION,
R.string.private_space_lock_setup_description);
- mVerifyDeviceLock.launch(intent);
+ mSetNewPrivateProfileLock.launch(intent);
}
private void onAccountAdded(@Nullable ActivityResult result) {
@@ -102,10 +103,12 @@
finish();
}
- private void onSetDeviceNewLock(@Nullable ActivityResult result) {
- // TODO(b/307281644) : Verify this for biometrics and check result code after new
- // Authentication changes are merged.
- if (result != null && getSystemService(KeyguardManager.class).isDeviceSecure()) {
+ private void onSetNewProfileLockActionCompleted(@Nullable ActivityResult result) {
+ LockPatternUtils lockPatternUtils =
+ FeatureFactory.getFeatureFactory()
+ .getSecurityFeatureProvider()
+ .getLockPatternUtils(this);
+ if (result != null && lockPatternUtils.isSeparateProfileChallengeEnabled(getUserId())) {
Log.i(TAG, "separate private space lock setup success");
setResult(RESULT_OK);
} else {