Create security status preference category.
Bug: 31002801 Test: make RunSettingsRoboTests Change-Id: I513253e79f91e41686bad9abac8548bb366fc98d
This commit is contained in:
@@ -752,6 +752,8 @@
|
|||||||
<string name="security_passwords_title">Passwords</string>
|
<string name="security_passwords_title">Passwords</string>
|
||||||
<!-- Summary for settings preference disabled by administrator [CHAR LIMIT=50] -->
|
<!-- Summary for settings preference disabled by administrator [CHAR LIMIT=50] -->
|
||||||
<string name="disabled_by_administrator_summary">Disabled by administrator</string>
|
<string name="disabled_by_administrator_summary">Disabled by administrator</string>
|
||||||
|
<!-- In the security screen, the header title for security statuses -->
|
||||||
|
<string name="security_status_title">Security status</string>
|
||||||
|
|
||||||
<!-- Fingerprint enrollment and settings --><skip />
|
<!-- Fingerprint enrollment and settings --><skip />
|
||||||
<!-- Title shown for menu item that launches fingerprint settings or enrollment [CHAR LIMIT=22] -->
|
<!-- Title shown for menu item that launches fingerprint settings or enrollment [CHAR LIMIT=22] -->
|
||||||
|
24
res/xml/security_settings_status.xml
Normal file
24
res/xml/security_settings_status.xml
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Copyright (C) 2017 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"
|
||||||
|
android:title="@string/security_settings_title">
|
||||||
|
|
||||||
|
<PreferenceCategory
|
||||||
|
android:key="security_status"
|
||||||
|
android:title="@string/security_status_title"/>
|
||||||
|
|
||||||
|
</PreferenceScreen>
|
@@ -126,9 +126,13 @@ public class SecuritySettings extends SettingsPreferenceFragment
|
|||||||
private static final String KEY_TRUST_AGENT = "trust_agent";
|
private static final String KEY_TRUST_AGENT = "trust_agent";
|
||||||
private static final String KEY_SCREEN_PINNING = "screen_pinning_settings";
|
private static final String KEY_SCREEN_PINNING = "screen_pinning_settings";
|
||||||
|
|
||||||
|
// Security status
|
||||||
|
private static final String KEY_SECURITY_STATUS = "security_status";
|
||||||
|
private static final String SECURITY_STATUS_KEY_PREFIX = "security_status_";
|
||||||
|
|
||||||
// Package verifier Settings
|
// Package verifier Settings
|
||||||
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
|
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
|
||||||
static final String KEY_PACKAGE_VERIFIER_STATE = "package_verifier_state";
|
static final String KEY_PACKAGE_VERIFIER_STATUS = "security_status_package_verifier";
|
||||||
private static final int PACKAGE_VERIFIER_STATE_ENABLED = 1;
|
private static final int PACKAGE_VERIFIER_STATE_ENABLED = 1;
|
||||||
|
|
||||||
// These switch preferences need special handling since they're not all stored in Settings.
|
// These switch preferences need special handling since they're not all stored in Settings.
|
||||||
@@ -261,6 +265,9 @@ public class SecuritySettings extends SettingsPreferenceFragment
|
|||||||
addPreferencesFromResource(R.xml.security_settings);
|
addPreferencesFromResource(R.xml.security_settings);
|
||||||
root = getPreferenceScreen();
|
root = getPreferenceScreen();
|
||||||
|
|
||||||
|
// Add category for security status
|
||||||
|
addPreferencesFromResource(R.xml.security_settings_status);
|
||||||
|
|
||||||
// Add options for lock/unlock screen
|
// Add options for lock/unlock screen
|
||||||
final int resid = getResIdForLockUnlockScreen(getActivity(), mLockPatternUtils,
|
final int resid = getResIdForLockUnlockScreen(getActivity(), mLockPatternUtils,
|
||||||
mManagedPasswordProvider, MY_USER_ID);
|
mManagedPasswordProvider, MY_USER_ID);
|
||||||
@@ -428,19 +435,38 @@ public class SecuritySettings extends SettingsPreferenceFragment
|
|||||||
Index.getInstance(getActivity())
|
Index.getInstance(getActivity())
|
||||||
.updateFromClassNameResource(SecuritySettings.class.getName(), true, true);
|
.updateFromClassNameResource(SecuritySettings.class.getName(), true, true);
|
||||||
|
|
||||||
|
PreferenceGroup securityStatusPreferenceGroup =
|
||||||
|
(PreferenceGroup) root.findPreference(KEY_SECURITY_STATUS);
|
||||||
if (mDashboardFeatureProvider.isEnabled()) {
|
if (mDashboardFeatureProvider.isEnabled()) {
|
||||||
final List<Preference> tilePrefs = mDashboardFeatureProvider.getPreferencesForCategory(
|
final List<Preference> tilePrefs = mDashboardFeatureProvider.getPreferencesForCategory(
|
||||||
getActivity(), getPrefContext(), CategoryKey.CATEGORY_SECURITY);
|
getActivity(), getPrefContext(), CategoryKey.CATEGORY_SECURITY);
|
||||||
|
int numSecurityStatusPrefs = 0;
|
||||||
if (tilePrefs != null && !tilePrefs.isEmpty()) {
|
if (tilePrefs != null && !tilePrefs.isEmpty()) {
|
||||||
for (Preference preference : tilePrefs) {
|
for (Preference preference : tilePrefs) {
|
||||||
|
if (!TextUtils.isEmpty(preference.getKey())
|
||||||
|
&& preference.getKey().startsWith(SECURITY_STATUS_KEY_PREFIX)) {
|
||||||
|
// Injected security status settings are placed under the Security status
|
||||||
|
// category.
|
||||||
|
securityStatusPreferenceGroup.addPreference(preference);
|
||||||
|
numSecurityStatusPrefs++;
|
||||||
|
} else {
|
||||||
|
// Other injected settings are placed under the Security preference screen.
|
||||||
root.addPreference(preference);
|
root.addPreference(preference);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (numSecurityStatusPrefs == 0) {
|
||||||
|
root.removePreference(securityStatusPreferenceGroup);
|
||||||
|
} else if (numSecurityStatusPrefs > 0) {
|
||||||
// Update preference data with tile data. Security feature provider only updates the
|
// Update preference data with tile data. Security feature provider only updates the
|
||||||
// data if it actually needs to be changed.
|
// data if it actually needs to be changed.
|
||||||
mSecurityFeatureProvider.updatePreferences(getActivity(), root,
|
mSecurityFeatureProvider.updatePreferences(getActivity(), root,
|
||||||
mDashboardFeatureProvider.getTilesForCategory(CategoryKey.CATEGORY_SECURITY));
|
mDashboardFeatureProvider.getTilesForCategory(
|
||||||
|
CategoryKey.CATEGORY_SECURITY));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
root.removePreference(root.findPreference(KEY_SECURITY_STATUS));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < SWITCH_PREFERENCE_KEYS.length; i++) {
|
for (int i = 0; i < SWITCH_PREFERENCE_KEYS.length; i++) {
|
||||||
@@ -1365,7 +1391,7 @@ public class SecuritySettings extends SettingsPreferenceFragment
|
|||||||
}
|
}
|
||||||
for (int i = 0; i < tilesCount; i++) {
|
for (int i = 0; i < tilesCount; i++) {
|
||||||
Tile tile = dashboardCategory.getTile(i);
|
Tile tile = dashboardCategory.getTile(i);
|
||||||
if (!KEY_PACKAGE_VERIFIER_STATE.equals(tile.key)) {
|
if (!KEY_PACKAGE_VERIFIER_STATUS.equals(tile.key)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
String summaryUri = tile.metaData.getString(
|
String summaryUri = tile.metaData.getString(
|
||||||
|
@@ -144,7 +144,7 @@ public class SecuritySettingsTest {
|
|||||||
public void testGetPackageVerifierSummary_matchingTile() {
|
public void testGetPackageVerifierSummary_matchingTile() {
|
||||||
when(mDashboardCategory.getTilesCount()).thenReturn(1);
|
when(mDashboardCategory.getTilesCount()).thenReturn(1);
|
||||||
Tile tile = new Tile();
|
Tile tile = new Tile();
|
||||||
tile.key = SecuritySettings.KEY_PACKAGE_VERIFIER_STATE;
|
tile.key = SecuritySettings.KEY_PACKAGE_VERIFIER_STATUS;
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
bundle.putString(TileUtils.META_DATA_PREFERENCE_SUMMARY_URI, "content://host/path");
|
bundle.putString(TileUtils.META_DATA_PREFERENCE_SUMMARY_URI, "content://host/path");
|
||||||
tile.metaData = bundle;
|
tile.metaData = bundle;
|
||||||
|
Reference in New Issue
Block a user