Loading res/xml/encryption_and_credential.xml +3 −8 Original line number Diff line number Diff line Loading @@ -24,25 +24,21 @@ android:order="100"> <com.android.settingslib.RestrictedPreference android:key="credential_storage_type" android:title="@string/credential_storage_type" android:persistent="false" /> android:title="@string/credential_storage_type" /> <Preference android:key="trusted_credentials" android:title="@string/trusted_credentials" android:summary="@string/trusted_credentials_summary" android:persistent="false" android:fragment="com.android.settings.TrustedCredentialsSettings"/> <com.android.settingslib.RestrictedPreference android:key="user_credentials" android:title="@string/user_credentials" android:summary="@string/user_credentials_summary" android:persistent="false" android:fragment="com.android.settings.UserCredentialsSettings"/> <com.android.settingslib.RestrictedPreference android:key="credentials_install" android:title="@string/credentials_install" android:summary="@string/credentials_install_summary" android:persistent="false"> android:summary="@string/credentials_install_summary"> <intent android:action="android.credentials.INSTALL" android:targetPackage="com.android.certinstaller" Loading @@ -52,8 +48,7 @@ <com.android.settingslib.RestrictedPreference android:key="credentials_reset" android:title="@string/credentials_reset" android:summary="@string/credentials_reset_summary" android:persistent="false"> android:summary="@string/credentials_reset_summary"> <intent android:action="com.android.credentials.RESET" android:targetPackage="com.android.settings" Loading res/xml/security_settings_encrypted.xml +1 −3 Original line number Diff line number Diff line Loading @@ -18,12 +18,10 @@ android:title="@string/security_settings_title"> <PreferenceCategory android:key="security_category" android:key="security_category_for_encrypted_device" android:title="@string/crypt_keeper_settings_title"> <Preference android:enabled="false" android:shouldDisableView="false" android:key="crypt_keeper_encrypt_title" android:title="@string/crypt_keeper_encrypt_title" android:summary="@string/crypt_keeper_encrypted_summary"/> Loading res/xml/security_settings_unencrypted.xml +2 −2 Original line number Diff line number Diff line Loading @@ -18,7 +18,7 @@ android:title="@string/crypt_keeper_settings_title"> <PreferenceCategory android:key="security_category" android:key="security_category_for_unencrypted_device" android:title="@string/crypt_keeper_settings_title"> <Preference Loading src/com/android/settings/EncryptionAndCredential.java +34 −63 Original line number Diff line number Diff line Loading @@ -20,7 +20,6 @@ import android.app.Activity; import android.app.admin.DevicePolicyManager; import android.content.Context; import android.content.Intent; import android.content.res.Resources; import android.os.Bundle; import android.os.UserHandle; import android.os.UserManager; Loading @@ -34,7 +33,6 @@ import com.android.internal.widget.LockPatternUtils; import com.android.settings.dashboard.DashboardFragment; import com.android.settings.search.BaseSearchIndexProvider; import com.android.settings.search.Indexable; import com.android.settings.search.SearchIndexableRaw; import com.android.settingslib.RestrictedLockUtils; import com.android.settingslib.RestrictedPreference; Loading Loading @@ -106,7 +104,6 @@ public class EncryptionAndCredential extends SettingsPreferenceFragment implemen } } // Credential storage mKeyStore = KeyStore.getInstance(); // needs to be initialized for onResume() Loading Loading @@ -182,83 +179,57 @@ public class EncryptionAndCredential extends SettingsPreferenceFragment implemen @Override public List<SearchIndexableResource> getXmlResourcesToIndex( Context context, boolean enabled) { final List<SearchIndexableResource> index = new ArrayList<SearchIndexableResource>(); final List<SearchIndexableResource> index = new ArrayList<>(); final DevicePolicyManager dpm = (DevicePolicyManager) context.getSystemService(Context.DEVICE_POLICY_SERVICE); final UserManager um = UserManager.get(context); if (um.isAdminUser()) { switch (dpm.getStorageEncryptionStatus()) { case DevicePolicyManager.ENCRYPTION_STATUS_ACTIVE: // The device is currently encrypted. // Add everything. We will suppress some of them in getNonIndexableKeys() index.add(getSearchResource(context, R.xml.encryption_and_credential)); index.add(getSearchResource(context, R.xml.security_settings_encrypted)); break; case DevicePolicyManager.ENCRYPTION_STATUS_INACTIVE: // This device supports encryption but isn't encrypted. index.add(getSearchResource(context, R.xml.security_settings_unencrypted)); break; } } return index; } @Override protected boolean isPageSearchEnabled(Context context) { final UserManager um = (UserManager) context.getSystemService(Context.USER_SERVICE); return um.isAdminUser(); } private SearchIndexableResource getSearchResource(Context context, int xmlResId) { final SearchIndexableResource sir = new SearchIndexableResource(context); sir.xmlResId = xmlResId; return sir; } @Override public List<SearchIndexableRaw> getRawDataToIndex(Context context, boolean enabled) { final List<SearchIndexableRaw> result = new ArrayList<SearchIndexableRaw>(); final Resources res = context.getResources(); final String screenTitle = res.getString( R.string.encryption_and_credential_settings_title); SearchIndexableRaw data = new SearchIndexableRaw(context); data.title = screenTitle; data.screenTitle = screenTitle; result.add(data); final UserManager um = UserManager.get(context); if (!um.isAdminUser()) { int resId = um.isLinkedUser() ? R.string.profile_info_settings_title : R.string.user_info_settings_title; data = new SearchIndexableRaw(context); data.title = res.getString(resId); data.screenTitle = screenTitle; result.add(data); } // Credential storage if (!um.hasUserRestriction(UserManager.DISALLOW_CONFIG_CREDENTIALS)) { KeyStore keyStore = KeyStore.getInstance(); final int storageSummaryRes = keyStore.isHardwareBacked() ? R.string.credential_storage_type_hardware : R.string.credential_storage_type_software; data = new SearchIndexableRaw(context); data.title = res.getString(storageSummaryRes); data.screenTitle = screenTitle; result.add(data); } return result; } @Override public List<String> getNonIndexableKeys(Context context) { final List<String> keys = super.getNonIndexableKeys(context); final UserManager um = UserManager.get(context); if (!isPageSearchEnabled(context)) { return keys; } final UserManager um = (UserManager) context.getSystemService(Context.USER_SERVICE); if (um.hasUserRestriction(UserManager.DISALLOW_CONFIG_CREDENTIALS)) { keys.add(KEY_CREDENTIALS_MANAGER); keys.add(KEY_RESET_CREDENTIALS); keys.add(KEY_CREDENTIALS_INSTALL); keys.add(KEY_CREDENTIAL_STORAGE_TYPE); keys.add(KEY_USER_CREDENTIALS); } final DevicePolicyManager dpm = (DevicePolicyManager) context.getSystemService(Context.DEVICE_POLICY_SERVICE); switch (dpm.getStorageEncryptionStatus()) { case DevicePolicyManager.ENCRYPTION_STATUS_ACTIVE: // The device is currently encrypted. Disable security_settings_unencrypted keys.addAll(getNonIndexableKeysFromXml( context, R.xml.security_settings_unencrypted)); break; default: // This device supports encryption but isn't encrypted. keys.addAll(getNonIndexableKeysFromXml( context, R.xml.security_settings_encrypted)); break; } return keys; Loading src/com/android/settings/search/BaseSearchIndexProvider.java +19 −10 Original line number Diff line number Diff line Loading @@ -16,10 +16,12 @@ package com.android.settings.search; import android.annotation.XmlRes; import android.content.Context; import android.content.res.XmlResourceParser; import android.provider.SearchIndexableResource; import android.support.annotation.CallSuper; import android.support.annotation.VisibleForTesting; import android.text.TextUtils; import android.util.AttributeSet; import android.util.Log; Loading Loading @@ -94,7 +96,15 @@ public class BaseSearchIndexProvider implements Indexable.SearchIndexProvider { } final List<String> nonIndexableKeys = new ArrayList<>(); for (SearchIndexableResource res : resources) { final XmlResourceParser parser = context.getResources().getXml(res.xmlResId); nonIndexableKeys.addAll(getNonIndexableKeysFromXml(context, res.xmlResId)); } return nonIndexableKeys; } @VisibleForTesting(otherwise = VisibleForTesting.PROTECTED) public List<String> getNonIndexableKeysFromXml(Context context, @XmlRes int xmlResId) { final List<String> nonIndexableKeys = new ArrayList<>(); final XmlResourceParser parser = context.getResources().getXml(xmlResId); final AttributeSet attrs = Xml.asAttributeSet(parser); try { while (parser.next() != XmlPullParser.END_DOCUMENT) { Loading @@ -104,8 +114,7 @@ public class BaseSearchIndexProvider implements Indexable.SearchIndexProvider { } } } catch (IOException | XmlPullParserException e) { Log.w(TAG, "Error parsing non-indexable from xml " + res.xmlResId); } Log.w(TAG, "Error parsing non-indexable from xml " + xmlResId); } return nonIndexableKeys; } Loading Loading
res/xml/encryption_and_credential.xml +3 −8 Original line number Diff line number Diff line Loading @@ -24,25 +24,21 @@ android:order="100"> <com.android.settingslib.RestrictedPreference android:key="credential_storage_type" android:title="@string/credential_storage_type" android:persistent="false" /> android:title="@string/credential_storage_type" /> <Preference android:key="trusted_credentials" android:title="@string/trusted_credentials" android:summary="@string/trusted_credentials_summary" android:persistent="false" android:fragment="com.android.settings.TrustedCredentialsSettings"/> <com.android.settingslib.RestrictedPreference android:key="user_credentials" android:title="@string/user_credentials" android:summary="@string/user_credentials_summary" android:persistent="false" android:fragment="com.android.settings.UserCredentialsSettings"/> <com.android.settingslib.RestrictedPreference android:key="credentials_install" android:title="@string/credentials_install" android:summary="@string/credentials_install_summary" android:persistent="false"> android:summary="@string/credentials_install_summary"> <intent android:action="android.credentials.INSTALL" android:targetPackage="com.android.certinstaller" Loading @@ -52,8 +48,7 @@ <com.android.settingslib.RestrictedPreference android:key="credentials_reset" android:title="@string/credentials_reset" android:summary="@string/credentials_reset_summary" android:persistent="false"> android:summary="@string/credentials_reset_summary"> <intent android:action="com.android.credentials.RESET" android:targetPackage="com.android.settings" Loading
res/xml/security_settings_encrypted.xml +1 −3 Original line number Diff line number Diff line Loading @@ -18,12 +18,10 @@ android:title="@string/security_settings_title"> <PreferenceCategory android:key="security_category" android:key="security_category_for_encrypted_device" android:title="@string/crypt_keeper_settings_title"> <Preference android:enabled="false" android:shouldDisableView="false" android:key="crypt_keeper_encrypt_title" android:title="@string/crypt_keeper_encrypt_title" android:summary="@string/crypt_keeper_encrypted_summary"/> Loading
res/xml/security_settings_unencrypted.xml +2 −2 Original line number Diff line number Diff line Loading @@ -18,7 +18,7 @@ android:title="@string/crypt_keeper_settings_title"> <PreferenceCategory android:key="security_category" android:key="security_category_for_unencrypted_device" android:title="@string/crypt_keeper_settings_title"> <Preference Loading
src/com/android/settings/EncryptionAndCredential.java +34 −63 Original line number Diff line number Diff line Loading @@ -20,7 +20,6 @@ import android.app.Activity; import android.app.admin.DevicePolicyManager; import android.content.Context; import android.content.Intent; import android.content.res.Resources; import android.os.Bundle; import android.os.UserHandle; import android.os.UserManager; Loading @@ -34,7 +33,6 @@ import com.android.internal.widget.LockPatternUtils; import com.android.settings.dashboard.DashboardFragment; import com.android.settings.search.BaseSearchIndexProvider; import com.android.settings.search.Indexable; import com.android.settings.search.SearchIndexableRaw; import com.android.settingslib.RestrictedLockUtils; import com.android.settingslib.RestrictedPreference; Loading Loading @@ -106,7 +104,6 @@ public class EncryptionAndCredential extends SettingsPreferenceFragment implemen } } // Credential storage mKeyStore = KeyStore.getInstance(); // needs to be initialized for onResume() Loading Loading @@ -182,83 +179,57 @@ public class EncryptionAndCredential extends SettingsPreferenceFragment implemen @Override public List<SearchIndexableResource> getXmlResourcesToIndex( Context context, boolean enabled) { final List<SearchIndexableResource> index = new ArrayList<SearchIndexableResource>(); final List<SearchIndexableResource> index = new ArrayList<>(); final DevicePolicyManager dpm = (DevicePolicyManager) context.getSystemService(Context.DEVICE_POLICY_SERVICE); final UserManager um = UserManager.get(context); if (um.isAdminUser()) { switch (dpm.getStorageEncryptionStatus()) { case DevicePolicyManager.ENCRYPTION_STATUS_ACTIVE: // The device is currently encrypted. // Add everything. We will suppress some of them in getNonIndexableKeys() index.add(getSearchResource(context, R.xml.encryption_and_credential)); index.add(getSearchResource(context, R.xml.security_settings_encrypted)); break; case DevicePolicyManager.ENCRYPTION_STATUS_INACTIVE: // This device supports encryption but isn't encrypted. index.add(getSearchResource(context, R.xml.security_settings_unencrypted)); break; } } return index; } @Override protected boolean isPageSearchEnabled(Context context) { final UserManager um = (UserManager) context.getSystemService(Context.USER_SERVICE); return um.isAdminUser(); } private SearchIndexableResource getSearchResource(Context context, int xmlResId) { final SearchIndexableResource sir = new SearchIndexableResource(context); sir.xmlResId = xmlResId; return sir; } @Override public List<SearchIndexableRaw> getRawDataToIndex(Context context, boolean enabled) { final List<SearchIndexableRaw> result = new ArrayList<SearchIndexableRaw>(); final Resources res = context.getResources(); final String screenTitle = res.getString( R.string.encryption_and_credential_settings_title); SearchIndexableRaw data = new SearchIndexableRaw(context); data.title = screenTitle; data.screenTitle = screenTitle; result.add(data); final UserManager um = UserManager.get(context); if (!um.isAdminUser()) { int resId = um.isLinkedUser() ? R.string.profile_info_settings_title : R.string.user_info_settings_title; data = new SearchIndexableRaw(context); data.title = res.getString(resId); data.screenTitle = screenTitle; result.add(data); } // Credential storage if (!um.hasUserRestriction(UserManager.DISALLOW_CONFIG_CREDENTIALS)) { KeyStore keyStore = KeyStore.getInstance(); final int storageSummaryRes = keyStore.isHardwareBacked() ? R.string.credential_storage_type_hardware : R.string.credential_storage_type_software; data = new SearchIndexableRaw(context); data.title = res.getString(storageSummaryRes); data.screenTitle = screenTitle; result.add(data); } return result; } @Override public List<String> getNonIndexableKeys(Context context) { final List<String> keys = super.getNonIndexableKeys(context); final UserManager um = UserManager.get(context); if (!isPageSearchEnabled(context)) { return keys; } final UserManager um = (UserManager) context.getSystemService(Context.USER_SERVICE); if (um.hasUserRestriction(UserManager.DISALLOW_CONFIG_CREDENTIALS)) { keys.add(KEY_CREDENTIALS_MANAGER); keys.add(KEY_RESET_CREDENTIALS); keys.add(KEY_CREDENTIALS_INSTALL); keys.add(KEY_CREDENTIAL_STORAGE_TYPE); keys.add(KEY_USER_CREDENTIALS); } final DevicePolicyManager dpm = (DevicePolicyManager) context.getSystemService(Context.DEVICE_POLICY_SERVICE); switch (dpm.getStorageEncryptionStatus()) { case DevicePolicyManager.ENCRYPTION_STATUS_ACTIVE: // The device is currently encrypted. Disable security_settings_unencrypted keys.addAll(getNonIndexableKeysFromXml( context, R.xml.security_settings_unencrypted)); break; default: // This device supports encryption but isn't encrypted. keys.addAll(getNonIndexableKeysFromXml( context, R.xml.security_settings_encrypted)); break; } return keys; Loading
src/com/android/settings/search/BaseSearchIndexProvider.java +19 −10 Original line number Diff line number Diff line Loading @@ -16,10 +16,12 @@ package com.android.settings.search; import android.annotation.XmlRes; import android.content.Context; import android.content.res.XmlResourceParser; import android.provider.SearchIndexableResource; import android.support.annotation.CallSuper; import android.support.annotation.VisibleForTesting; import android.text.TextUtils; import android.util.AttributeSet; import android.util.Log; Loading Loading @@ -94,7 +96,15 @@ public class BaseSearchIndexProvider implements Indexable.SearchIndexProvider { } final List<String> nonIndexableKeys = new ArrayList<>(); for (SearchIndexableResource res : resources) { final XmlResourceParser parser = context.getResources().getXml(res.xmlResId); nonIndexableKeys.addAll(getNonIndexableKeysFromXml(context, res.xmlResId)); } return nonIndexableKeys; } @VisibleForTesting(otherwise = VisibleForTesting.PROTECTED) public List<String> getNonIndexableKeysFromXml(Context context, @XmlRes int xmlResId) { final List<String> nonIndexableKeys = new ArrayList<>(); final XmlResourceParser parser = context.getResources().getXml(xmlResId); final AttributeSet attrs = Xml.asAttributeSet(parser); try { while (parser.next() != XmlPullParser.END_DOCUMENT) { Loading @@ -104,8 +114,7 @@ public class BaseSearchIndexProvider implements Indexable.SearchIndexProvider { } } } catch (IOException | XmlPullParserException e) { Log.w(TAG, "Error parsing non-indexable from xml " + res.xmlResId); } Log.w(TAG, "Error parsing non-indexable from xml " + xmlResId); } return nonIndexableKeys; } Loading