Add One Lock settings inside private space settings page
This includes below changes: 1. Add new sub settings page in Private Space settings with option to swithch between private profile lock and device screen lock 2. Call Private profile lock setup when swithcing to private lock from screen lock. 3. Preference to change private lock when a separate Private lock is set Bug: 308862923 Test: atest UseOneLockPreferenceControllerTest, PrivateSpaceLockControllerTest Change-Id: I0a6d8c7dfbd0ffea19db03ffd6dfe7aa520c9684
This commit is contained in:
@@ -1,50 +0,0 @@
|
||||
/*
|
||||
* 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 android.content.Context;
|
||||
|
||||
import com.android.settings.core.TogglePreferenceController;
|
||||
|
||||
/** Represents the preference controller for using the same lock as the screen lock */
|
||||
public class UseOneLockController extends TogglePreferenceController {
|
||||
public UseOneLockController(Context context, String preferenceKey) {
|
||||
super(context, preferenceKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return AVAILABLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChecked() {
|
||||
// TODO(b/293569406) Need to save this to a persistent store, maybe like SettingsProvider
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setChecked(boolean isChecked) {
|
||||
// TODO(b/293569406) Need to save this to a persistent store, maybe like SettingsProvider
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSliceHighlightMenuRes() {
|
||||
return 0;
|
||||
}
|
||||
}
|
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* 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.onelock;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SettingsPreferenceFragment;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
|
||||
/** Represents the preference controller to enroll biometrics for private space lock. */
|
||||
public class FaceFingerprintUnlockController extends AbstractPreferenceController {
|
||||
private static final String KEY_SET_UNSET_FACE_FINGERPRINT = "private_space_biometrics";
|
||||
|
||||
public FaceFingerprintUnlockController(Context context, SettingsPreferenceFragment host) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAvailable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPreferenceKey() {
|
||||
return KEY_SET_UNSET_FACE_FINGERPRINT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handlePreferenceTreeClick(Preference preference) {
|
||||
return TextUtils.equals(preference.getKey(), getPreferenceKey());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateState(Preference preference) {
|
||||
//TODO(b/308862923) : Add condition to check and enable when separate private lock is set.
|
||||
preference.setSummary(mContext.getString(R.string.lock_settings_profile_unified_summary));
|
||||
preference.setEnabled(false);
|
||||
}
|
||||
}
|
@@ -0,0 +1,134 @@
|
||||
/*
|
||||
* 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.onelock;
|
||||
|
||||
import static com.android.internal.widget.LockPatternUtils.CREDENTIAL_TYPE_PASSWORD;
|
||||
import static com.android.internal.widget.LockPatternUtils.CREDENTIAL_TYPE_PATTERN;
|
||||
import static com.android.internal.widget.LockPatternUtils.CREDENTIAL_TYPE_PIN;
|
||||
import static com.android.settings.password.ChooseLockGeneric.ChooseLockGenericFragment.HIDE_INSECURE_OPTIONS;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
|
||||
import com.android.internal.widget.LockPatternUtils;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SettingsPreferenceFragment;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.core.SubSettingLauncher;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settings.password.ChooseLockGeneric;
|
||||
import com.android.settings.privatespace.PrivateSpaceMaintainer;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
import com.android.settingslib.transition.SettingsTransitionHelper;
|
||||
|
||||
|
||||
/** Represents the preference controller for changing private space lock. */
|
||||
public class PrivateSpaceLockController extends AbstractPreferenceController {
|
||||
private static final String TAG = "PrivateSpaceLockContr";
|
||||
private static final String KEY_CHANGE_PROFILE_LOCK =
|
||||
"change_private_space_lock";
|
||||
|
||||
private final SettingsPreferenceFragment mHost;
|
||||
private final UserManager mUserManager;
|
||||
private final LockPatternUtils mLockPatternUtils;
|
||||
private final int mProfileUserId;
|
||||
|
||||
public PrivateSpaceLockController(Context context, SettingsPreferenceFragment host) {
|
||||
super(context);
|
||||
mUserManager = context.getSystemService(UserManager.class);
|
||||
mLockPatternUtils = FeatureFactory.getFeatureFactory()
|
||||
.getSecurityFeatureProvider()
|
||||
.getLockPatternUtils(context);
|
||||
mHost = host;
|
||||
UserHandle privateProfileHandle = PrivateSpaceMaintainer.getInstance(context)
|
||||
.getPrivateProfileHandle();
|
||||
if (privateProfileHandle != null) {
|
||||
mProfileUserId = privateProfileHandle.getIdentifier();
|
||||
} else {
|
||||
mProfileUserId = -1;
|
||||
Log.e(TAG, "Private profile user handle is not expected to be null.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAvailable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPreferenceKey() {
|
||||
return KEY_CHANGE_PROFILE_LOCK;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handlePreferenceTreeClick(Preference preference) {
|
||||
if (!TextUtils.equals(preference.getKey(), getPreferenceKey())) {
|
||||
return false;
|
||||
}
|
||||
//Checks if the profile is in quiet mode and show a dialog to unpause the profile.
|
||||
if (Utils.startQuietModeDialogIfNecessary(mContext, mUserManager,
|
||||
mProfileUserId)) {
|
||||
return false;
|
||||
}
|
||||
final Bundle extras = new Bundle();
|
||||
extras.putInt(Intent.EXTRA_USER_ID, mProfileUserId);
|
||||
extras.putBoolean(HIDE_INSECURE_OPTIONS, true);
|
||||
new SubSettingLauncher(mContext)
|
||||
.setDestination(ChooseLockGeneric.ChooseLockGenericFragment.class.getName())
|
||||
.setSourceMetricsCategory(mHost.getMetricsCategory())
|
||||
.setArguments(extras)
|
||||
.setExtras(extras)
|
||||
.setTransitionType(SettingsTransitionHelper.TransitionType.TRANSITION_SLIDE)
|
||||
.launch();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateState(Preference preference) {
|
||||
if (mLockPatternUtils.isSeparateProfileChallengeEnabled(mProfileUserId)) {
|
||||
preference.setSummary(
|
||||
mContext.getString(getCredentialTypeResId(mProfileUserId)));
|
||||
preference.setEnabled(true);
|
||||
} else {
|
||||
preference.setSummary(mContext.getString(
|
||||
R.string.lock_settings_profile_unified_summary));
|
||||
preference.setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
private int getCredentialTypeResId(int userId) {
|
||||
int credentialType = mLockPatternUtils.getCredentialTypeForUser(userId);
|
||||
switch (credentialType) {
|
||||
case CREDENTIAL_TYPE_PATTERN :
|
||||
return R.string.unlock_set_unlock_mode_pattern;
|
||||
case CREDENTIAL_TYPE_PIN:
|
||||
return R.string.unlock_set_unlock_mode_pin;
|
||||
case CREDENTIAL_TYPE_PASSWORD:
|
||||
return R.string.unlock_set_unlock_mode_password;
|
||||
default:
|
||||
// This is returned for CREDENTIAL_TYPE_NONE
|
||||
return R.string.unlock_set_unlock_mode_off;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* 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.onelock;
|
||||
|
||||
import static com.android.internal.widget.LockPatternUtils.CREDENTIAL_TYPE_PASSWORD;
|
||||
import static com.android.internal.widget.LockPatternUtils.CREDENTIAL_TYPE_PATTERN;
|
||||
import static com.android.internal.widget.LockPatternUtils.CREDENTIAL_TYPE_PIN;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.UserHandle;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.internal.widget.LockPatternUtils;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settings.privatespace.PrivateSpaceMaintainer;
|
||||
|
||||
/** Represents the preference controller for using the same lock as the screen lock */
|
||||
public class UseOneLockController extends BasePreferenceController {
|
||||
private static final String TAG = "UseOneLockController";
|
||||
private final LockPatternUtils mLockPatternUtils;
|
||||
private final PrivateSpaceMaintainer mPrivateSpaceMaintainer;
|
||||
|
||||
public UseOneLockController(Context context, String preferenceKey) {
|
||||
super(context, preferenceKey);
|
||||
mPrivateSpaceMaintainer = PrivateSpaceMaintainer.getInstance(mContext);
|
||||
mLockPatternUtils = FeatureFactory.getFeatureFactory()
|
||||
.getSecurityFeatureProvider()
|
||||
.getLockPatternUtils(context);
|
||||
}
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return AVAILABLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSliceHighlightMenuRes() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence getSummary() {
|
||||
UserHandle privateProfileHandle = mPrivateSpaceMaintainer.getPrivateProfileHandle();
|
||||
if (privateProfileHandle != null) {
|
||||
int privateUserId = privateProfileHandle.getIdentifier();
|
||||
if (mLockPatternUtils.isSeparateProfileChallengeEnabled(privateUserId)) {
|
||||
return mContext.getString(getCredentialTypeResId(privateUserId));
|
||||
}
|
||||
} else {
|
||||
Log.w(TAG, "Did not find Private Space.");
|
||||
}
|
||||
return mContext.getString(R.string.private_space_screen_lock_summary);
|
||||
}
|
||||
|
||||
private int getCredentialTypeResId(int userId) {
|
||||
int credentialType = mLockPatternUtils.getCredentialTypeForUser(userId);
|
||||
switch (credentialType) {
|
||||
case CREDENTIAL_TYPE_PATTERN:
|
||||
return R.string.unlock_set_unlock_mode_pattern;
|
||||
case CREDENTIAL_TYPE_PIN:
|
||||
return R.string.unlock_set_unlock_mode_pin;
|
||||
case CREDENTIAL_TYPE_PASSWORD:
|
||||
return R.string.unlock_set_unlock_mode_password;
|
||||
default:
|
||||
// This is returned for CREDENTIAL_TYPE_NONE
|
||||
return R.string.unlock_set_unlock_mode_off;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,216 @@
|
||||
/*
|
||||
* 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.onelock;
|
||||
|
||||
import static com.android.settings.privatespace.PrivateSpaceSetupActivity.EXTRA_ACTION_TYPE;
|
||||
import static com.android.settings.privatespace.PrivateSpaceSetupActivity.SET_LOCK_ACTION;
|
||||
import static com.android.settings.privatespace.onelock.UseOneLockSettingsFragment.UNIFY_PRIVATE_LOCK_WITH_DEVICE_REQUEST;
|
||||
import static com.android.settings.privatespace.onelock.UseOneLockSettingsFragment.UNUNIFY_PRIVATE_LOCK_FROM_DEVICE_REQUEST;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.internal.widget.LockPatternUtils;
|
||||
import com.android.internal.widget.LockscreenCredential;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SettingsPreferenceFragment;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.core.SubSettingLauncher;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settings.password.ChooseLockGeneric;
|
||||
import com.android.settings.password.ChooseLockSettingsHelper;
|
||||
import com.android.settings.privatespace.PrivateProfileContextHelperActivity;
|
||||
import com.android.settings.privatespace.PrivateSpaceMaintainer;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
import com.android.settingslib.transition.SettingsTransitionHelper;
|
||||
import com.android.settingslib.widget.MainSwitchPreference;
|
||||
|
||||
/** Represents the preference controller for using the same lock as the screen lock */
|
||||
public class UseOneLockControllerSwitch extends AbstractPreferenceController
|
||||
implements Preference.OnPreferenceChangeListener {
|
||||
private static final String TAG = "UseOneLockSwitch";
|
||||
private static final String KEY_UNIFICATION = "private_lock_unification";
|
||||
private final String mPreferenceKey;
|
||||
private final SettingsPreferenceFragment mHost;
|
||||
private final LockPatternUtils mLockPatternUtils;
|
||||
private final UserManager mUserManager;
|
||||
private final int mProfileUserId;
|
||||
private final UserHandle mUserHandle;
|
||||
private LockscreenCredential mCurrentDevicePassword;
|
||||
private LockscreenCredential mCurrentProfilePassword;
|
||||
private MainSwitchPreference mUnifyProfile;
|
||||
|
||||
@Override
|
||||
public void displayPreference(PreferenceScreen screen) {
|
||||
super.displayPreference(screen);
|
||||
mUnifyProfile = screen.findPreference(mPreferenceKey);
|
||||
}
|
||||
public UseOneLockControllerSwitch(Context context, SettingsPreferenceFragment host) {
|
||||
this(context, host, KEY_UNIFICATION);
|
||||
}
|
||||
|
||||
public UseOneLockControllerSwitch(Context context, SettingsPreferenceFragment host,
|
||||
String key) {
|
||||
super(context);
|
||||
mHost = host;
|
||||
mUserManager = context.getSystemService(UserManager.class);
|
||||
mLockPatternUtils = FeatureFactory.getFeatureFactory().getSecurityFeatureProvider()
|
||||
.getLockPatternUtils(context);
|
||||
mUserHandle = PrivateSpaceMaintainer.getInstance(context).getPrivateProfileHandle();
|
||||
mProfileUserId = mUserHandle != null ? mUserHandle.getIdentifier() : -1;
|
||||
mCurrentDevicePassword = LockscreenCredential.createNone();
|
||||
mCurrentProfilePassword = LockscreenCredential.createNone();
|
||||
this.mPreferenceKey = key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPreferenceKey() {
|
||||
return mPreferenceKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAvailable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object value) {
|
||||
//Checks if the profile is in quiet mode and show a dialog to unpause the profile.
|
||||
if (Utils.startQuietModeDialogIfNecessary(mContext, mUserManager, mProfileUserId)) {
|
||||
return false;
|
||||
}
|
||||
final boolean useOneLock = (Boolean) value;
|
||||
if (useOneLock) {
|
||||
startUnification();
|
||||
} else {
|
||||
showAlertDialog();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateState(Preference preference) {
|
||||
if (mUnifyProfile != null) {
|
||||
final boolean separate =
|
||||
mLockPatternUtils.isSeparateProfileChallengeEnabled(mProfileUserId);
|
||||
mUnifyProfile.setChecked(!separate);
|
||||
}
|
||||
}
|
||||
|
||||
/** Method to handle onActivityResult */
|
||||
public boolean handleActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
if (requestCode == UNUNIFY_PRIVATE_LOCK_FROM_DEVICE_REQUEST
|
||||
&& resultCode == Activity.RESULT_OK) {
|
||||
mCurrentDevicePassword =
|
||||
data.getParcelableExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
|
||||
separateLocks();
|
||||
return true;
|
||||
} else if (requestCode == UNIFY_PRIVATE_LOCK_WITH_DEVICE_REQUEST
|
||||
&& resultCode == Activity.RESULT_OK) {
|
||||
mCurrentProfilePassword =
|
||||
data.getParcelableExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
|
||||
unifyLocks();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void separateLocks() {
|
||||
final Bundle extras = new Bundle();
|
||||
extras.putInt(Intent.EXTRA_USER_ID, mProfileUserId);
|
||||
extras.putParcelable(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD, mCurrentDevicePassword);
|
||||
new SubSettingLauncher(mContext)
|
||||
.setDestination(ChooseLockGeneric.ChooseLockGenericFragment.class.getName())
|
||||
.setSourceMetricsCategory(mHost.getMetricsCategory())
|
||||
.setArguments(extras)
|
||||
.setTransitionType(SettingsTransitionHelper.TransitionType.TRANSITION_SLIDE)
|
||||
.launch();
|
||||
}
|
||||
|
||||
/** Unify primary and profile locks. */
|
||||
public void startUnification() {
|
||||
// Confirm profile lock
|
||||
final ChooseLockSettingsHelper.Builder builder =
|
||||
new ChooseLockSettingsHelper.Builder(mHost.getActivity(), mHost);
|
||||
final boolean launched = builder.setRequestCode(UNIFY_PRIVATE_LOCK_WITH_DEVICE_REQUEST)
|
||||
.setReturnCredentials(true)
|
||||
.setUserId(mProfileUserId)
|
||||
.show();
|
||||
if (!launched) {
|
||||
// If profile has no lock, go straight to unification.
|
||||
unifyLocks();
|
||||
}
|
||||
}
|
||||
|
||||
private void unifyLocks() {
|
||||
unifyKeepingDeviceLock();
|
||||
if (mCurrentDevicePassword != null) {
|
||||
mCurrentDevicePassword.zeroize();
|
||||
mCurrentDevicePassword = null;
|
||||
}
|
||||
if (mCurrentProfilePassword != null) {
|
||||
mCurrentProfilePassword.zeroize();
|
||||
mCurrentProfilePassword = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void unifyKeepingDeviceLock() {
|
||||
mLockPatternUtils.setSeparateProfileChallengeEnabled(mProfileUserId, false,
|
||||
mCurrentProfilePassword);
|
||||
}
|
||||
|
||||
private void showAlertDialog() {
|
||||
if (mUserHandle == null) {
|
||||
Log.e(TAG, "Private profile user handle is not expected to be null");
|
||||
mUnifyProfile.setChecked(true);
|
||||
return;
|
||||
}
|
||||
new AlertDialog.Builder(mContext)
|
||||
.setMessage(R.string.private_space_new_lock_title)
|
||||
.setPositiveButton(
|
||||
R.string.privatespace_set_lock_label,
|
||||
(dialog, which) -> {
|
||||
Intent intent = new Intent(mContext,
|
||||
PrivateProfileContextHelperActivity.class);
|
||||
intent.putExtra(EXTRA_ACTION_TYPE, SET_LOCK_ACTION);
|
||||
((Activity) mContext).startActivityForResultAsUser(intent,
|
||||
UNUNIFY_PRIVATE_LOCK_FROM_DEVICE_REQUEST,
|
||||
/*Options*/ null, mUserHandle);
|
||||
})
|
||||
.setNegativeButton(R.string.privatespace_cancel_label,
|
||||
(DialogInterface dialog, int which) -> {
|
||||
mUnifyProfile.setChecked(true);
|
||||
dialog.dismiss();
|
||||
})
|
||||
.setOnCancelListener(
|
||||
(DialogInterface dialog) -> {
|
||||
mUnifyProfile.setChecked(true);
|
||||
dialog.dismiss();
|
||||
})
|
||||
.show();
|
||||
}
|
||||
}
|
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* 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.onelock;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class UseOneLockSettingsFragment extends DashboardFragment {
|
||||
private static final String TAG = "UseOneLockSettings";
|
||||
public static final int UNIFY_PRIVATE_LOCK_WITH_DEVICE_REQUEST = 1;
|
||||
public static final int UNUNIFY_PRIVATE_LOCK_FROM_DEVICE_REQUEST = 2;
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
return SettingsEnums.PRIVATE_SPACE_SETTINGS;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getPreferenceScreenResId() {
|
||||
return R.xml.privatespace_one_lock;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getLogTag() {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
|
||||
final List<AbstractPreferenceController> controllers = new ArrayList<>();
|
||||
controllers.add(new UseOneLockControllerSwitch(context, this));
|
||||
controllers.add(new PrivateSpaceLockController(context, this));
|
||||
controllers.add(new FaceFingerprintUnlockController(context, this));
|
||||
return controllers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
||||
if (use(UseOneLockControllerSwitch.class)
|
||||
.handleActivityResult(requestCode, resultCode, data)) {
|
||||
return;
|
||||
}
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user