diff options
-rw-r--r-- | res/xml/security_settings_misc.xml | 3 | ||||
-rw-r--r-- | src/com/android/settings/SecuritySettings.java | 82 |
2 files changed, 46 insertions, 39 deletions
diff --git a/res/xml/security_settings_misc.xml b/res/xml/security_settings_misc.xml index 6f9311a..41a84b9 100644 --- a/res/xml/security_settings_misc.xml +++ b/res/xml/security_settings_misc.xml @@ -60,7 +60,8 @@ android:persistent="false" /> </PreferenceCategory> - <PreferenceCategory android:title="@string/credentials_title" + <PreferenceCategory android:key="credentials_management" + android:title="@string/credentials_title" android:persistent="false"> <Preference android:title="@string/trusted_credentials" android:summary="@string/trusted_credentials_summary" diff --git a/src/com/android/settings/SecuritySettings.java b/src/com/android/settings/SecuritySettings.java index 1b63acb..2af212c 100644 --- a/src/com/android/settings/SecuritySettings.java +++ b/src/com/android/settings/SecuritySettings.java @@ -90,6 +90,7 @@ public class SecuritySettings extends SettingsPreferenceFragment private static final String KEY_TOGGLE_INSTALL_APPLICATIONS = "toggle_install_applications"; private static final String KEY_TOGGLE_VERIFY_APPLICATIONS = "toggle_verify_applications"; private static final String KEY_POWER_INSTANTLY_LOCKS = "power_button_instantly_locks"; + private static final String KEY_CREDENTIALS_MANAGER = "credentials_management"; private static final String PACKAGE_MIME_TYPE = "application/vnd.android.package-archive"; DevicePolicyManager mDPM; @@ -112,6 +113,8 @@ public class SecuritySettings extends SettingsPreferenceFragment private CheckBoxPreference mToggleVerifyApps; private CheckBoxPreference mPowerButtonInstantlyLocks; + private boolean mIsPrimary; + @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -164,7 +167,9 @@ public class SecuritySettings extends SettingsPreferenceFragment DevicePolicyManager dpm = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE); - if (UserHandle.myUserId() == 0) { + mIsPrimary = UserHandle.myUserId() == UserHandle.USER_OWNER; + + if (mIsPrimary) { switch (dpm.getStorageEncryptionStatus()) { case DevicePolicyManager.ENCRYPTION_STATUS_ACTIVE: // The device is currently encrypted. @@ -216,17 +221,40 @@ public class SecuritySettings extends SettingsPreferenceFragment } } - if (UserHandle.myUserId() > 0) { - return root; + mUserSelectedWidget = root.findPreference(KEY_CHOOSE_LOCKSCREEN_STATUS_WIDGET); + if (mUserSelectedWidget != null) { + AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(getActivity()); + int appWidgetId = getStatusAppWidgetId(); + if (appWidgetId == -1) { + mUserSelectedWidget.setSummary(getResources().getString(R.string.widget_default)); + } else { + AppWidgetProviderInfo appWidget = appWidgetManager.getAppWidgetInfo(appWidgetId); + if (appWidget != null) { + mUserSelectedWidget.setSummary(appWidget.label); + } + } + } + + mUserSelectedWidget = root.findPreference(KEY_CHOOSE_USER_SELECTED_LOCKSCREEN_WIDGET); + if (mUserSelectedWidget != null) { + AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(getActivity()); + int appWidgetId = getUserSelectedAppWidgetId(); + if (appWidgetId == -1) { + mUserSelectedWidget.setSummary(getResources().getString(R.string.widget_none)); + } else { + AppWidgetProviderInfo appWidget = appWidgetManager.getAppWidgetInfo(appWidgetId); + if (appWidget != null) { + mUserSelectedWidget.setSummary(appWidget.label); + } + } } - // Rest are for primary user... // Append the rest of the settings addPreferencesFromResource(R.xml.security_settings_misc); // Do not display SIM lock for devices without an Icc card TelephonyManager tm = TelephonyManager.getDefault(); - if (!tm.hasIccCard()) { + if (!mIsPrimary || !tm.hasIccCard()) { root.removePreference(root.findPreference(KEY_SIM_LOCK)); } else { // Disable SIM lock if sim card is missing or unknown @@ -241,50 +269,28 @@ public class SecuritySettings extends SettingsPreferenceFragment // Show password mShowPassword = (CheckBoxPreference) root.findPreference(KEY_SHOW_PASSWORD); - // Credential storage - mResetCredentials = root.findPreference(KEY_RESET_CREDENTIALS); + // Credential storage, only for primary user + if (mIsPrimary) { + mResetCredentials = root.findPreference(KEY_RESET_CREDENTIALS); + } else { + removePreference(KEY_CREDENTIALS_MANAGER); + } mToggleAppInstallation = (CheckBoxPreference) findPreference( KEY_TOGGLE_INSTALL_APPLICATIONS); mToggleAppInstallation.setChecked(isNonMarketAppsAllowed()); - // Package verification - if (showVerifierSetting()) { - mToggleVerifyApps = (CheckBoxPreference) findPreference(KEY_TOGGLE_VERIFY_APPLICATIONS); + // Package verification, only visible to primary user and if enabled + mToggleVerifyApps = (CheckBoxPreference) findPreference(KEY_TOGGLE_VERIFY_APPLICATIONS); + if (mIsPrimary && showVerifierSetting()) { if (isVerifierInstalled()) { mToggleVerifyApps.setChecked(isVerifyAppsEnabled()); } else { mToggleVerifyApps.setChecked(false); mToggleVerifyApps.setEnabled(false); } - } - - mUserSelectedWidget = root.findPreference(KEY_CHOOSE_LOCKSCREEN_STATUS_WIDGET); - if (mUserSelectedWidget != null) { - AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(getActivity()); - int appWidgetId = getStatusAppWidgetId(); - if (appWidgetId == -1) { - mUserSelectedWidget.setSummary(getResources().getString(R.string.widget_default)); - } else { - AppWidgetProviderInfo appWidget = appWidgetManager.getAppWidgetInfo(appWidgetId); - if (appWidget != null) { - mUserSelectedWidget.setSummary(appWidget.label); - } - } - } - - mUserSelectedWidget = root.findPreference(KEY_CHOOSE_USER_SELECTED_LOCKSCREEN_WIDGET); - if (mUserSelectedWidget != null) { - AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(getActivity()); - int appWidgetId = getUserSelectedAppWidgetId(); - if (appWidgetId == -1) { - mUserSelectedWidget.setSummary(getResources().getString(R.string.widget_none)); - } else { - AppWidgetProviderInfo appWidget = appWidgetManager.getAppWidgetInfo(appWidgetId); - if (appWidget != null) { - mUserSelectedWidget.setSummary(appWidget.label); - } - } + } else if (mToggleVerifyApps != null) { + mToggleVerifyApps.setEnabled(false); } return root; |