For private space lock setup as part of both PS setup and separate lock form private space settings we need to show only traditional unlock factors and Fingerprint but not show Face enrolment even on devices where Face unlock is supported by hardware. Once LSKF is enrolled it should be followed by Fingerprint enrollment flow and after that Face enrollment should not be shown and exit lock setup flow. Currently for separate profile lock setup ACTION_SET_NEW_PASSWORD intent is used in private space setup. With this intent the options of LSKF+fingerprint+Face is shown in devices supporting both fingerprint and face hardware. After the LSKF ennrollment BiometricEnrollActivity is started which continues with fingerprint and Face enrollment. With this change we are passing an extra along with the intent to enroll fingerprint only. Based on the intent extra value if set even if hardware support exists the lock enrollment for the profile will support only LSKF and fingerprint enrollment but not start Face enrollment. User will still have the option to enroll Face from the dedicated settings entrypoint in private space settings. Recording link : b/323839067#comment4 Bug: 323839067 Test: Manual, verified option for face enrollment is shown or not shown based on the intent extra. When extra is not passed the behaviour will be default. Change-Id: Idf92084052e02df9ca89f288c618796750e563e6
124 lines
5.4 KiB
Java
124 lines
5.4 KiB
Java
/*
|
|
* Copyright (C) 2023 The Android Open Source Project
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
package com.android.settings.privatespace;
|
|
|
|
import static android.app.admin.DevicePolicyManager.ACTION_SET_NEW_PASSWORD;
|
|
import static android.app.admin.DevicePolicyManager.EXTRA_PASSWORD_COMPLEXITY;
|
|
import static android.app.admin.DevicePolicyManager.PASSWORD_COMPLEXITY_LOW;
|
|
|
|
import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_CHOOSE_LOCK_SCREEN_DESCRIPTION;
|
|
import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_CHOOSE_LOCK_SCREEN_TITLE;
|
|
import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_FINGERPRINT_ENROLLMENT_ONLY;
|
|
import static com.android.settings.privatespace.PrivateSpaceSetupActivity.ACCOUNT_LOGIN_ACTION;
|
|
import static com.android.settings.privatespace.PrivateSpaceSetupActivity.EXTRA_ACTION_TYPE;
|
|
import static com.android.settings.privatespace.PrivateSpaceSetupActivity.SET_LOCK_ACTION;
|
|
|
|
import android.content.Intent;
|
|
import android.os.Bundle;
|
|
import android.util.Log;
|
|
|
|
import androidx.activity.result.ActivityResult;
|
|
import androidx.activity.result.ActivityResultLauncher;
|
|
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;
|
|
|
|
import com.google.android.setupdesign.util.ThemeHelper;
|
|
|
|
/**
|
|
* Activity that is started as private profile user that helps to set private profile lock or add an
|
|
* account on the private profile.
|
|
*/
|
|
public class PrivateProfileContextHelperActivity extends FragmentActivity {
|
|
private static final String TAG = "PrivateSpaceHelperAct";
|
|
private final ActivityResultLauncher<Intent> mAddAccountToPrivateProfile =
|
|
registerForActivityResult(
|
|
new ActivityResultContracts.StartActivityForResult(), this::onAccountAdded);
|
|
private final ActivityResultLauncher<Intent> mSetNewPrivateProfileLock =
|
|
registerForActivityResult(
|
|
new ActivityResultContracts.StartActivityForResult(),
|
|
this::onSetNewProfileLockActionCompleted);
|
|
|
|
@Override
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
if (!android.os.Flags.allowPrivateProfile()
|
|
|| !android.multiuser.Flags.enablePrivateSpaceFeatures()) {
|
|
return;
|
|
}
|
|
setTheme(SetupWizardUtils.getTheme(this, getIntent()));
|
|
ThemeHelper.trySetDynamicColor(this);
|
|
super.onCreate(savedInstanceState);
|
|
if (savedInstanceState == null) {
|
|
int action = getIntent().getIntExtra(EXTRA_ACTION_TYPE, -1);
|
|
if (action == ACCOUNT_LOGIN_ACTION) {
|
|
PrivateSpaceLoginFeatureProvider privateSpaceLoginFeatureProvider =
|
|
FeatureFactory.getFeatureFactory().getPrivateSpaceLoginFeatureProvider();
|
|
if (!privateSpaceLoginFeatureProvider.initiateAccountLogin(
|
|
this, mAddAccountToPrivateProfile)) {
|
|
setResult(RESULT_OK);
|
|
finish();
|
|
}
|
|
} else if (action == SET_LOCK_ACTION) {
|
|
createPrivateSpaceLock();
|
|
}
|
|
}
|
|
}
|
|
|
|
private void createPrivateSpaceLock() {
|
|
final Intent intent = new Intent(ACTION_SET_NEW_PASSWORD);
|
|
intent.putExtra(EXTRA_PASSWORD_COMPLEXITY, PASSWORD_COMPLEXITY_LOW);
|
|
intent.putExtra(EXTRA_KEY_FINGERPRINT_ENROLLMENT_ONLY, true);
|
|
intent.putExtra(
|
|
EXTRA_KEY_CHOOSE_LOCK_SCREEN_TITLE, R.string.private_space_lock_setup_title);
|
|
intent.putExtra(
|
|
EXTRA_KEY_CHOOSE_LOCK_SCREEN_DESCRIPTION,
|
|
R.string.private_space_lock_setup_description);
|
|
mSetNewPrivateProfileLock.launch(intent);
|
|
}
|
|
|
|
private void onAccountAdded(@Nullable ActivityResult result) {
|
|
if (result != null && result.getResultCode() == RESULT_OK) {
|
|
Log.i(TAG, "private space account login success");
|
|
setResult(RESULT_OK);
|
|
} else {
|
|
Log.i(TAG, "private space account login failed");
|
|
setResult(RESULT_CANCELED);
|
|
}
|
|
finish();
|
|
}
|
|
|
|
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 {
|
|
Log.i(TAG, "separate private space lock not setup");
|
|
setResult(RESULT_CANCELED);
|
|
}
|
|
finish();
|
|
}
|
|
}
|