Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a05b33b6 authored by josephpv's avatar josephpv
Browse files

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
parent 55fc6463
Loading
Loading
Loading
Loading
+11 −8
Original line number Diff line number Diff line
@@ -26,7 +26,6 @@ import static com.android.settings.privatespace.PrivateSpaceSetupActivity.ACCOUN
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.activity.result.contract.ActivityResultContracts;
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 @@ public class PrivateProfileContextHelperActivity extends FragmentActivity {
    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 @@ public class PrivateProfileContextHelperActivity extends FragmentActivity {
        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 @@ public class PrivateProfileContextHelperActivity extends FragmentActivity {
        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 {