Group some Security settings to a separate "Advanced settings" screen
Test: adb shell am start -a android.settings.SECURITY_SETTINGS opens Advanced Security Settings screen Test: atest SettingsUnitTests:SecurityAdvancedSettingsTest Test: atest SettingsUnitTests:SecurityAdvancedSettingsControllerTest Bug: 204416998 Change-Id: If9c6da812ffb7c046b3b00a084007950801e1d4f
This commit is contained in:
@@ -1675,6 +1675,19 @@
|
||||
android:value="true" />
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name="Settings$SecurityAdvancedSettings"
|
||||
android:label="@string/security_advanced_settings"
|
||||
android:exported="true"
|
||||
android:icon="@drawable/ic_settings_security">
|
||||
<intent-filter android:priority="1">
|
||||
<action android:name="com.android.settings.security.SECURITY_ADVANCED_SETTINGS" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
|
||||
android:value="com.android.settings.security.SecurityAdvancedSettings" />
|
||||
</activity>
|
||||
|
||||
<activity android:name="MonitoringCertInfoActivity"
|
||||
android:label=""
|
||||
android:theme="@style/Transparent"
|
||||
|
@@ -1244,6 +1244,15 @@
|
||||
<string name="security_settings_fingerprint_enroll_lift_touch_again">Lift finger, then touch sensor again</string>
|
||||
<!-- Text shown during fingerprint enrollment to indicate bad sensor calibration. [CHAR LIMIT=100] -->
|
||||
<string name="security_settings_fingerprint_bad_calibration">Can\u2019t use fingerprint sensor. Visit a repair provider</string>
|
||||
<!-- Title for Advanced Security Settings [CHAR LIMIT=60] -->
|
||||
<string name="security_advanced_settings">Advanced settings</string>
|
||||
<!-- String for summary to be shown in Advanced settings tile in Security page, when there is a work profile set up on the device. Smart Lock is a brand name. [CHAR_LIMIT=NONE] -->
|
||||
<string name="security_advanced_settings_work_profile_settings_summary">Work profile lock, Smart Lock</string>
|
||||
<!-- String for summary to be shown in Advanced settings tile in Security page, when there is no work profile set up on the device. Smart Lock is a brand name. [CHAR_LIMIT=NONE] -->
|
||||
<string name="security_advanced_settings_no_work_profile_settings_summary">Smart Lock and more</string>
|
||||
<!-- Search keywords for Advanced settings in Security page. [CHAR_LIMIT=NONE] -->
|
||||
<string name="security_advanced_settings_keywords">Advanced settings</string>
|
||||
|
||||
|
||||
<!-- Text shown when "Add fingerprint" button is disabled -->
|
||||
<string name="fingerprint_add_max">You can add up to <xliff:g id="count" example="5">%d</xliff:g> fingerprints</string>
|
||||
|
141
res/xml/security_advanced_settings.xml
Normal file
141
res/xml/security_advanced_settings.xml
Normal file
@@ -0,0 +1,141 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2021 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.
|
||||
-->
|
||||
|
||||
<PreferenceScreen
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:settings="http://schemas.android.com/apk/res-auto"
|
||||
android:title="@string/security_advanced_settings">
|
||||
|
||||
<PreferenceCategory
|
||||
android:order="1"
|
||||
android:key="dashboard_title_placeholder" />
|
||||
|
||||
<!-- Main security section - for trust agents added in code. -->
|
||||
<PreferenceCategory
|
||||
android:order="10"
|
||||
android:key="security_category" />
|
||||
|
||||
<PreferenceCategory
|
||||
android:order="40"
|
||||
android:key="security_settings_device_admin_category"
|
||||
android:layout="@layout/preference_category_no_label">
|
||||
|
||||
<Preference
|
||||
android:key="manage_device_admin"
|
||||
android:title="@string/manage_device_admin"
|
||||
android:summary="@string/summary_placeholder"
|
||||
android:fragment=
|
||||
"com.android.settings.applications.specialaccess.deviceadmin.DeviceAdminSettings"
|
||||
settings:controller=
|
||||
"com.android.settings.enterprise.ManageDeviceAdminPreferenceController" />
|
||||
|
||||
<Preference
|
||||
android:key="enterprise_privacy"
|
||||
android:title="@string/enterprise_privacy_settings"
|
||||
android:summary="@string/summary_placeholder"
|
||||
android:fragment="com.android.settings.enterprise.EnterprisePrivacySettings" />
|
||||
|
||||
<Preference
|
||||
android:key="financed_privacy"
|
||||
android:title="@string/financed_privacy_settings"
|
||||
android:summary="@string/summary_placeholder"
|
||||
android:fragment="com.android.settings.enterprise.EnterprisePrivacySettings" />
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
<Preference
|
||||
android:order="50"
|
||||
android:key="sim_lock_settings"
|
||||
android:title="@string/sim_lock_settings_category">
|
||||
|
||||
<intent
|
||||
android:action="android.intent.action.MAIN"
|
||||
android:targetPackage="com.android.settings"
|
||||
android:targetClass="com.android.settings.Settings$IccLockSettingsActivity" />
|
||||
|
||||
</Preference>
|
||||
|
||||
<Preference
|
||||
android:order="60"
|
||||
android:key="encryption_and_credential"
|
||||
android:title="@string/encryption_and_credential_settings_title"
|
||||
android:summary="@string/encryption_and_credential_settings_summary"
|
||||
android:fragment="com.android.settings.security.EncryptionAndCredential" />
|
||||
|
||||
<Preference
|
||||
android:order="70"
|
||||
android:key="manage_trust_agents"
|
||||
android:title="@string/manage_trust_agents"
|
||||
android:summary="@string/summary_placeholder"
|
||||
android:fragment="com.android.settings.security.trustagent.TrustAgentSettings" />
|
||||
|
||||
<Preference
|
||||
android:order="80"
|
||||
android:key="screen_pinning_settings"
|
||||
android:title="@string/screen_pinning_title"
|
||||
android:summary="@string/summary_placeholder"
|
||||
android:fragment="com.android.settings.security.ScreenPinningSettings"
|
||||
settings:keywords="@string/keywords_app_pinning" />
|
||||
|
||||
<SwitchPreference
|
||||
android:order="90"
|
||||
android:key="confirm_sim_deletion"
|
||||
android:title="@string/confirm_sim_deletion_title"
|
||||
android:summary="@string/confirm_sim_deletion_description"
|
||||
settings:controller="com.android.settings.security.ConfirmSimDeletionPreferenceController"/>
|
||||
|
||||
<!-- work profile security section -->
|
||||
<PreferenceCategory
|
||||
android:order="100"
|
||||
android:key="security_category_profile"
|
||||
android:title="@string/lock_settings_profile_title">
|
||||
|
||||
<!-- security_settings_unification -->
|
||||
<com.android.settingslib.RestrictedSwitchPreference
|
||||
android:key="unification"
|
||||
android:title="@string/lock_settings_profile_unification_title"
|
||||
android:summary="@string/lock_settings_profile_unification_summary"
|
||||
settings:keywords="@string/keywords_unification" />
|
||||
|
||||
<com.android.settingslib.RestrictedPreference
|
||||
android:key="unlock_set_or_change_profile"
|
||||
android:title="@string/unlock_set_unlock_launch_picker_title_profile"
|
||||
android:summary="@string/unlock_set_unlock_mode_pattern"
|
||||
settings:keywords="@string/keywords_lockscreen" />
|
||||
|
||||
<SwitchPreference
|
||||
android:key="visiblepattern_profile"
|
||||
android:title="@string/lockpattern_settings_enable_visible_pattern_title_profile" />
|
||||
|
||||
<com.android.settingslib.RestrictedPreference
|
||||
android:key="fingerprint_settings_profile"
|
||||
android:title="@string/security_settings_work_fingerprint_preference_title"
|
||||
android:summary="@string/summary_placeholder" />
|
||||
|
||||
<com.android.settingslib.RestrictedPreference
|
||||
android:key="face_settings_profile"
|
||||
android:title="@string/security_settings_face_preference_title"
|
||||
android:summary="@string/summary_placeholder" />
|
||||
|
||||
<com.android.settingslib.RestrictedPreference
|
||||
android:key="biometric_settings_profile"
|
||||
android:title="@string/security_settings_biometric_preference_title"
|
||||
android:summary="@string/summary_placeholder" />
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
</PreferenceScreen>
|
@@ -62,112 +62,13 @@
|
||||
settings:keywords="@string/keywords_biometric_settings" />
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
android:order="40"
|
||||
android:key="security_settings_device_admin_category"
|
||||
android:layout="@layout/preference_category_no_label">
|
||||
|
||||
<Preference
|
||||
android:key="manage_device_admin"
|
||||
android:title="@string/manage_device_admin"
|
||||
android:summary="@string/summary_placeholder"
|
||||
android:fragment="com.android.settings.applications.specialaccess.deviceadmin.DeviceAdminSettings"
|
||||
settings:controller="com.android.settings.enterprise.ManageDeviceAdminPreferenceController" />
|
||||
|
||||
<Preference
|
||||
android:key="enterprise_privacy"
|
||||
android:title="@string/enterprise_privacy_settings"
|
||||
android:summary="@string/summary_placeholder"
|
||||
android:fragment="com.android.settings.enterprise.EnterprisePrivacySettings" />
|
||||
|
||||
<Preference
|
||||
android:key="financed_privacy"
|
||||
android:title="@string/financed_privacy_settings"
|
||||
android:summary="@string/summary_placeholder"
|
||||
android:fragment="com.android.settings.enterprise.EnterprisePrivacySettings" />
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
<Preference
|
||||
android:order="50"
|
||||
android:key="sim_lock_settings"
|
||||
android:title="@string/sim_lock_settings_category">
|
||||
|
||||
<intent
|
||||
android:action="android.intent.action.MAIN"
|
||||
android:targetPackage="com.android.settings"
|
||||
android:targetClass="com.android.settings.Settings$IccLockSettingsActivity" />
|
||||
|
||||
</Preference>
|
||||
|
||||
<Preference
|
||||
android:order="60"
|
||||
android:key="encryption_and_credential"
|
||||
android:title="@string/encryption_and_credential_settings_title"
|
||||
android:summary="@string/encryption_and_credential_settings_summary"
|
||||
android:fragment="com.android.settings.security.EncryptionAndCredential" />
|
||||
|
||||
<Preference
|
||||
android:order="70"
|
||||
android:key="manage_trust_agents"
|
||||
android:title="@string/manage_trust_agents"
|
||||
android:summary="@string/summary_placeholder"
|
||||
android:fragment="com.android.settings.security.trustagent.TrustAgentSettings" />
|
||||
|
||||
<Preference
|
||||
android:order="80"
|
||||
android:key="screen_pinning_settings"
|
||||
android:title="@string/screen_pinning_title"
|
||||
android:summary="@string/summary_placeholder"
|
||||
android:fragment="com.android.settings.security.ScreenPinningSettings"
|
||||
settings:keywords="@string/keywords_app_pinning" />
|
||||
|
||||
<SwitchPreference
|
||||
android:order="90"
|
||||
android:key="confirm_sim_deletion"
|
||||
android:title="@string/confirm_sim_deletion_title"
|
||||
android:summary="@string/confirm_sim_deletion_description"
|
||||
settings:controller="com.android.settings.security.ConfirmSimDeletionPreferenceController"/>
|
||||
|
||||
<!-- work profile security section -->
|
||||
<PreferenceCategory
|
||||
android:order="100"
|
||||
android:key="security_category_profile"
|
||||
android:title="@string/lock_settings_profile_title">
|
||||
|
||||
<!-- security_settings_unification -->
|
||||
<com.android.settingslib.RestrictedSwitchPreference
|
||||
android:key="unification"
|
||||
android:title="@string/lock_settings_profile_unification_title"
|
||||
android:summary="@string/lock_settings_profile_unification_summary"
|
||||
settings:keywords="@string/keywords_unification" />
|
||||
|
||||
<com.android.settingslib.RestrictedPreference
|
||||
android:key="unlock_set_or_change_profile"
|
||||
android:title="@string/unlock_set_unlock_launch_picker_title_profile"
|
||||
android:summary="@string/unlock_set_unlock_mode_pattern"
|
||||
settings:keywords="@string/keywords_lockscreen" />
|
||||
|
||||
<SwitchPreference
|
||||
android:key="visiblepattern_profile"
|
||||
android:title="@string/lockpattern_settings_enable_visible_pattern_title_profile"
|
||||
settings:controller="com.android.settings.security.VisiblePatternProfilePreferenceController" />
|
||||
|
||||
<com.android.settingslib.RestrictedPreference
|
||||
android:key="fingerprint_settings_profile"
|
||||
android:title="@string/security_settings_work_fingerprint_preference_title"
|
||||
android:summary="@string/summary_placeholder" />
|
||||
|
||||
<com.android.settingslib.RestrictedPreference
|
||||
android:key="face_settings_profile"
|
||||
android:title="@string/security_settings_face_preference_title"
|
||||
android:summary="@string/summary_placeholder" />
|
||||
|
||||
<com.android.settingslib.RestrictedPreference
|
||||
android:key="biometric_settings_profile"
|
||||
android:title="@string/security_settings_biometric_preference_title"
|
||||
android:summary="@string/summary_placeholder" />
|
||||
|
||||
</PreferenceCategory>
|
||||
android:key="security_advanced_settings"
|
||||
android:title="@string/security_advanced_settings"
|
||||
android:summary="@string/summary_placeholder"
|
||||
android:fragment="com.android.settings.security.SecurityAdvancedSettings"
|
||||
settings:controller="com.android.settings.security.SecurityAdvancedSettingsController"
|
||||
settings:keywords="@string/security_advanced_settings_keywords" />
|
||||
|
||||
</PreferenceScreen>
|
@@ -190,6 +190,8 @@ public class Settings extends SettingsActivity {
|
||||
return alternativeFragmentClassname;
|
||||
}
|
||||
}
|
||||
/** Activity for the Advanced security settings. */
|
||||
public static class SecurityAdvancedSettings extends SettingsActivity { /* empty */ }
|
||||
public static class UsageAccessSettingsActivity extends SettingsActivity { /* empty */ }
|
||||
public static class AppUsageAccessSettingsActivity extends SettingsActivity { /* empty */ }
|
||||
public static class LocationSettingsActivity extends SettingsActivity { /* empty */ }
|
||||
|
@@ -150,6 +150,7 @@ import com.android.settings.print.PrintSettingsFragment;
|
||||
import com.android.settings.privacy.PrivacyDashboardFragment;
|
||||
import com.android.settings.security.CryptKeeperSettings;
|
||||
import com.android.settings.security.LockscreenDashboardFragment;
|
||||
import com.android.settings.security.SecurityAdvancedSettings;
|
||||
import com.android.settings.security.SecuritySettings;
|
||||
import com.android.settings.shortcut.CreateShortcut;
|
||||
import com.android.settings.sound.MediaControlsSettings;
|
||||
@@ -215,6 +216,7 @@ public class SettingsGateway {
|
||||
PrivacyDashboardFragment.class.getName(),
|
||||
LocationServices.class.getName(),
|
||||
SecuritySettings.class.getName(),
|
||||
SecurityAdvancedSettings.class.getName(),
|
||||
UsageAccessDetails.class.getName(),
|
||||
PrivacySettings.class.getName(),
|
||||
DeviceAdminSettings.class.getName(),
|
||||
|
@@ -43,6 +43,7 @@ import com.android.settings.notification.SoundSettings;
|
||||
import com.android.settings.notification.zen.ZenModeSettings;
|
||||
import com.android.settings.privacy.PrivacyDashboardFragment;
|
||||
import com.android.settings.security.LockscreenDashboardFragment;
|
||||
import com.android.settings.security.SecurityAdvancedSettings;
|
||||
import com.android.settings.security.SecuritySettings;
|
||||
import com.android.settings.system.SystemDashboardFragment;
|
||||
import com.android.settingslib.drawer.CategoryKey;
|
||||
@@ -90,6 +91,8 @@ public class DashboardFragmentRegistry {
|
||||
CategoryKey.CATEGORY_STORAGE);
|
||||
PARENT_TO_CATEGORY_KEY_MAP.put(SecuritySettings.class.getName(),
|
||||
CategoryKey.CATEGORY_SECURITY);
|
||||
PARENT_TO_CATEGORY_KEY_MAP.put(SecurityAdvancedSettings.class.getName(),
|
||||
CategoryKey.CATEGORY_SECURITY_ADVANCED_SETTINGS);
|
||||
PARENT_TO_CATEGORY_KEY_MAP.put(AccountDetailDashboardFragment.class.getName(),
|
||||
CategoryKey.CATEGORY_ACCOUNT_DETAIL);
|
||||
PARENT_TO_CATEGORY_KEY_MAP.put(AccountDashboardFragment.class.getName(),
|
||||
|
140
src/com/android/settings/security/SecurityAdvancedSettings.java
Normal file
140
src/com/android/settings/security/SecurityAdvancedSettings.java
Normal file
@@ -0,0 +1,140 @@
|
||||
/*
|
||||
* Copyright (C) 2021 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.security;
|
||||
|
||||
import static com.android.settings.security.EncryptionStatusPreferenceController.PREF_KEY_ENCRYPTION_SECURITY_PAGE;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.biometrics.combination.CombinedBiometricProfileStatusPreferenceController;
|
||||
import com.android.settings.biometrics.face.FaceProfileStatusPreferenceController;
|
||||
import com.android.settings.biometrics.fingerprint.FingerprintProfileStatusPreferenceController;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settings.enterprise.EnterprisePrivacyPreferenceController;
|
||||
import com.android.settings.enterprise.FinancedPrivacyPreferenceController;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settings.security.trustagent.ManageTrustAgentsPreferenceController;
|
||||
import com.android.settings.security.trustagent.TrustAgentListPreferenceController;
|
||||
import com.android.settings.widget.PreferenceCategoryController;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||
import com.android.settingslib.drawer.CategoryKey;
|
||||
import com.android.settingslib.search.SearchIndexable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* An overflow menu for {@code SecuritySettings} containing advanced security settings.
|
||||
*
|
||||
* <p>This includes all work-profile related settings.
|
||||
*/
|
||||
@SearchIndexable
|
||||
public class SecurityAdvancedSettings extends DashboardFragment {
|
||||
|
||||
private static final String TAG = "SecurityAdvancedSettings";
|
||||
private static final String WORK_PROFILE_SECURITY_CATEGORY = "security_category_profile";
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
return SettingsEnums.SECURITY_ADVANCED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCategoryKey() {
|
||||
return CategoryKey.CATEGORY_SECURITY_ADVANCED_SETTINGS;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getPreferenceScreenResId() {
|
||||
return R.xml.security_advanced_settings;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getLogTag() {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
|
||||
return buildPreferenceControllers(context, getSettingsLifecycle(), this /* host*/);
|
||||
}
|
||||
|
||||
/**
|
||||
* see confirmPatternThenDisableAndClear
|
||||
*/
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
if (use(TrustAgentListPreferenceController.class)
|
||||
.handleActivityResult(requestCode, resultCode)) {
|
||||
return;
|
||||
}
|
||||
if (use(LockUnificationPreferenceController.class)
|
||||
.handleActivityResult(requestCode, resultCode, data)) {
|
||||
return;
|
||||
}
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
}
|
||||
|
||||
private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
|
||||
Lifecycle lifecycle, DashboardFragment host) {
|
||||
final List<AbstractPreferenceController> controllers = new ArrayList<>();
|
||||
controllers.add(new EnterprisePrivacyPreferenceController(context));
|
||||
controllers.add(new FinancedPrivacyPreferenceController(context));
|
||||
controllers.add(new ManageTrustAgentsPreferenceController(context));
|
||||
controllers.add(new ScreenPinningPreferenceController(context));
|
||||
controllers.add(new SimLockPreferenceController(context));
|
||||
controllers.add(new EncryptionStatusPreferenceController(context,
|
||||
PREF_KEY_ENCRYPTION_SECURITY_PAGE));
|
||||
controllers.add(new TrustAgentListPreferenceController(context, host, lifecycle));
|
||||
|
||||
final List<AbstractPreferenceController> profileSecurityControllers = new ArrayList<>();
|
||||
profileSecurityControllers.add(new ChangeProfileScreenLockPreferenceController(
|
||||
context, host));
|
||||
profileSecurityControllers.add(new LockUnificationPreferenceController(context, host));
|
||||
profileSecurityControllers.add(new VisiblePatternProfilePreferenceController(
|
||||
context, lifecycle));
|
||||
profileSecurityControllers.add(new FaceProfileStatusPreferenceController(
|
||||
context, lifecycle));
|
||||
profileSecurityControllers.add(new FingerprintProfileStatusPreferenceController(
|
||||
context, lifecycle));
|
||||
profileSecurityControllers
|
||||
.add(new CombinedBiometricProfileStatusPreferenceController(context, lifecycle));
|
||||
controllers.add(new PreferenceCategoryController(context, WORK_PROFILE_SECURITY_CATEGORY)
|
||||
.setChildren(profileSecurityControllers));
|
||||
controllers.addAll(profileSecurityControllers);
|
||||
|
||||
return controllers;
|
||||
}
|
||||
|
||||
/**
|
||||
* For Search. Please keep it in sync when updating "createPreferenceHierarchy()"
|
||||
*/
|
||||
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
||||
new BaseSearchIndexProvider(R.xml.security_advanced_settings) {
|
||||
|
||||
@Override
|
||||
public List<AbstractPreferenceController> createPreferenceControllers(Context
|
||||
context) {
|
||||
return buildPreferenceControllers(context, null /* lifecycle */,
|
||||
null /* host*/);
|
||||
}
|
||||
};
|
||||
}
|
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (C) 2021 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.security;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.pm.CrossProfileApps;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
|
||||
/**
|
||||
* Controller to decide the summary of "Advanced settings" option in the
|
||||
* Security settings screen.
|
||||
*/
|
||||
public class SecurityAdvancedSettingsController extends BasePreferenceController {
|
||||
|
||||
private final CrossProfileApps mCrossProfileApps;
|
||||
|
||||
public SecurityAdvancedSettingsController(Context context, String preferenceKey) {
|
||||
super(context, preferenceKey);
|
||||
|
||||
mCrossProfileApps = context.getSystemService(CrossProfileApps.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return AVAILABLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence getSummary() {
|
||||
return isWorkProfilePresent()
|
||||
? mContext.getResources().getString(
|
||||
R.string.security_advanced_settings_work_profile_settings_summary)
|
||||
: mContext.getResources().getString(
|
||||
R.string.security_advanced_settings_no_work_profile_settings_summary);
|
||||
}
|
||||
|
||||
private boolean isWorkProfilePresent() {
|
||||
return !mCrossProfileApps.getTargetUserProfiles().isEmpty();
|
||||
}
|
||||
}
|
@@ -15,25 +15,18 @@
|
||||
*/
|
||||
package com.android.settings.security;
|
||||
|
||||
import static com.android.settings.security.EncryptionStatusPreferenceController.PREF_KEY_ENCRYPTION_SECURITY_PAGE;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.biometrics.combination.CombinedBiometricProfileStatusPreferenceController;
|
||||
import com.android.settings.biometrics.combination.CombinedBiometricStatusPreferenceController;
|
||||
import com.android.settings.biometrics.face.FaceProfileStatusPreferenceController;
|
||||
import com.android.settings.biometrics.face.FaceStatusPreferenceController;
|
||||
import com.android.settings.biometrics.fingerprint.FingerprintProfileStatusPreferenceController;
|
||||
import com.android.settings.biometrics.fingerprint.FingerprintStatusPreferenceController;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settings.enterprise.EnterprisePrivacyPreferenceController;
|
||||
import com.android.settings.enterprise.FinancedPrivacyPreferenceController;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settings.safetycenter.SafetyCenterStatus;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settings.security.trustagent.ManageTrustAgentsPreferenceController;
|
||||
import com.android.settings.security.trustagent.TrustAgentListPreferenceController;
|
||||
import com.android.settings.widget.PreferenceCategoryController;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
@@ -48,7 +41,6 @@ public class SecuritySettings extends DashboardFragment {
|
||||
|
||||
private static final String TAG = "SecuritySettings";
|
||||
private static final String SECURITY_CATEGORY = "security_category";
|
||||
private static final String WORK_PROFILE_SECURITY_CATEGORY = "security_category_profile";
|
||||
|
||||
public static final int CHANGE_TRUST_AGENT_SETTINGS = 126;
|
||||
public static final int UNIFY_LOCK_CONFIRM_PROFILE_REQUEST = 129;
|
||||
@@ -106,15 +98,6 @@ public class SecuritySettings extends DashboardFragment {
|
||||
private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
|
||||
Lifecycle lifecycle, SecuritySettings host) {
|
||||
final List<AbstractPreferenceController> controllers = new ArrayList<>();
|
||||
controllers.add(new EnterprisePrivacyPreferenceController(context));
|
||||
controllers.add(new FinancedPrivacyPreferenceController(context));
|
||||
controllers.add(new ManageTrustAgentsPreferenceController(context));
|
||||
controllers.add(new ScreenPinningPreferenceController(context));
|
||||
controllers.add(new SimLockPreferenceController(context));
|
||||
controllers.add(new EncryptionStatusPreferenceController(context,
|
||||
PREF_KEY_ENCRYPTION_SECURITY_PAGE));
|
||||
controllers.add(new TrustAgentListPreferenceController(context, host, lifecycle));
|
||||
|
||||
final List<AbstractPreferenceController> securityPreferenceControllers = new ArrayList<>();
|
||||
securityPreferenceControllers.add(new FaceStatusPreferenceController(context, lifecycle));
|
||||
securityPreferenceControllers.add(new FingerprintStatusPreferenceController(
|
||||
@@ -126,22 +109,6 @@ public class SecuritySettings extends DashboardFragment {
|
||||
.setChildren(securityPreferenceControllers));
|
||||
controllers.addAll(securityPreferenceControllers);
|
||||
|
||||
final List<AbstractPreferenceController> profileSecurityControllers = new ArrayList<>();
|
||||
profileSecurityControllers.add(new ChangeProfileScreenLockPreferenceController(
|
||||
context, host));
|
||||
profileSecurityControllers.add(new LockUnificationPreferenceController(context, host));
|
||||
profileSecurityControllers.add(new VisiblePatternProfilePreferenceController(
|
||||
context, lifecycle));
|
||||
profileSecurityControllers.add(new FaceProfileStatusPreferenceController(
|
||||
context, lifecycle));
|
||||
profileSecurityControllers.add(new FingerprintProfileStatusPreferenceController(
|
||||
context, lifecycle));
|
||||
profileSecurityControllers
|
||||
.add(new CombinedBiometricProfileStatusPreferenceController(context, lifecycle));
|
||||
controllers.add(new PreferenceCategoryController(context, WORK_PROFILE_SECURITY_CATEGORY)
|
||||
.setChildren(profileSecurityControllers));
|
||||
controllers.addAll(profileSecurityControllers);
|
||||
|
||||
return controllers;
|
||||
}
|
||||
|
||||
@@ -161,7 +128,8 @@ public class SecuritySettings extends DashboardFragment {
|
||||
@Override
|
||||
protected boolean isPageSearchEnabled(Context context) {
|
||||
return !FeatureFactory.getFactory(context).getSecuritySettingsFeatureProvider()
|
||||
.hasAlternativeSecuritySettingsFragment();
|
||||
.hasAlternativeSecuritySettingsFragment()
|
||||
&& !SafetyCenterStatus.isEnabled();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Copyright (C) 2021 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.security;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.pm.CrossProfileApps;
|
||||
import android.os.UserHandle;
|
||||
|
||||
import androidx.test.core.app.ApplicationProvider;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
|
||||
import com.android.settings.testutils.ResourcesUtils;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class SecurityAdvancedSettingsControllerTest {
|
||||
|
||||
private static final String PREFERENCE_KEY = "security_advanced_settings";
|
||||
private static final String NO_WORK_PROFILE_SUMMARY_RESOURCE_NAME =
|
||||
"security_advanced_settings_no_work_profile_settings_summary";
|
||||
private static final String WORK_PROFILE_SUMMARY_RESOURCE_NAME =
|
||||
"security_advanced_settings_work_profile_settings_summary";
|
||||
|
||||
@Mock
|
||||
private CrossProfileApps mCrossProfileApps;
|
||||
private Context mContext;
|
||||
|
||||
private SecurityAdvancedSettingsController mController;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mContext = spy(ApplicationProvider.getApplicationContext());
|
||||
when(mContext.getSystemService(CrossProfileApps.class)).thenReturn(mCrossProfileApps);
|
||||
|
||||
mController = new SecurityAdvancedSettingsController(mContext, PREFERENCE_KEY);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSummary_withoutWorkProfile() {
|
||||
when(mCrossProfileApps.getTargetUserProfiles()).thenReturn(Collections.emptyList());
|
||||
|
||||
assertThat(mController.getSummary())
|
||||
.isEqualTo(getResourcesString(NO_WORK_PROFILE_SUMMARY_RESOURCE_NAME));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSummary_withWorkProfile() {
|
||||
when(mCrossProfileApps.getTargetUserProfiles()).thenReturn(
|
||||
Collections.singletonList(new UserHandle(0))
|
||||
);
|
||||
|
||||
assertThat(mController.getSummary())
|
||||
.isEqualTo(getResourcesString(WORK_PROFILE_SUMMARY_RESOURCE_NAME));
|
||||
}
|
||||
|
||||
private String getResourcesString(String resName) {
|
||||
return ResourcesUtils.getResourcesString(mContext, resName);
|
||||
}
|
||||
}
|
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Copyright (C) 2021 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.security;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Looper;
|
||||
|
||||
import androidx.test.annotation.UiThreadTest;
|
||||
import androidx.test.core.app.ApplicationProvider;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
|
||||
import com.android.settings.testutils.ResourcesUtils;
|
||||
import com.android.settingslib.drawer.CategoryKey;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class SecurityAdvancedSettingsTest {
|
||||
private static final String SCREEN_XML_RESOURCE_NAME = "security_advanced_settings";
|
||||
|
||||
private Context mContext;
|
||||
private SecurityAdvancedSettings mSecurityAdvancedSettings;
|
||||
|
||||
@Before
|
||||
@UiThreadTest
|
||||
public void setUp() {
|
||||
if (Looper.myLooper() == null) {
|
||||
Looper.prepare();
|
||||
}
|
||||
|
||||
mContext = ApplicationProvider.getApplicationContext();
|
||||
|
||||
mSecurityAdvancedSettings = new SecurityAdvancedSettings();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getPreferenceXml_returnsAdvancedSettings() {
|
||||
assertThat(mSecurityAdvancedSettings.getPreferenceScreenResId())
|
||||
.isEqualTo(getXmlResId(SCREEN_XML_RESOURCE_NAME));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getCategoryKey_whenCalled_returnsSecurity() {
|
||||
assertThat(mSecurityAdvancedSettings.getCategoryKey())
|
||||
.isEqualTo(CategoryKey.CATEGORY_SECURITY_ADVANCED_SETTINGS);
|
||||
}
|
||||
|
||||
private int getXmlResId(String resName) {
|
||||
return ResourcesUtils.getResourcesId(mContext, "xml", resName);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user