diff options
author | Amith Yamasani <yamasani@google.com> | 2014-10-22 13:51:53 -0700 |
---|---|---|
committer | Amith Yamasani <yamasani@google.com> | 2014-10-22 13:51:53 -0700 |
commit | 4339a470d3c1059b6b0e0591e9da2a44ca52df2d (patch) | |
tree | 05cbd2df8b34c91083e0de416e1448113a77ae36 /src/com/android/settings/PrivacySettings.java | |
parent | 795c83780752d0301985d53e2e230c2088af825b (diff) | |
download | packages_apps_Settings-4339a470d3c1059b6b0e0591e9da2a44ca52df2d.tar.gz packages_apps_Settings-4339a470d3c1059b6b0e0591e9da2a44ca52df2d.tar.bz2 packages_apps_Settings-4339a470d3c1059b6b0e0591e9da2a44ca52df2d.zip |
Disable factory reset for secondary users
Search in Settings makes it possible to find the factory reset screen.
Disable the search index in PrivacySettings so that backup and reset
keywords don't get indexed for secondary users.
Also add additional safeguards for other entry points such as public
intents, so that the backup/reset screen does not show any options.
Bug: 18076086
Change-Id: Ie5135fbf4084038c99947a1a107ab4758f0c15a9
Diffstat (limited to 'src/com/android/settings/PrivacySettings.java')
-rw-r--r-- | src/com/android/settings/PrivacySettings.java | 57 |
1 files changed, 55 insertions, 2 deletions
diff --git a/src/com/android/settings/PrivacySettings.java b/src/com/android/settings/PrivacySettings.java index 1236c482c..0a9f086ad 100644 --- a/src/com/android/settings/PrivacySettings.java +++ b/src/com/android/settings/PrivacySettings.java @@ -24,15 +24,24 @@ import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.os.Bundle; +import android.os.Process; import android.os.RemoteException; import android.os.ServiceManager; +import android.os.UserHandle; import android.os.UserManager; import android.preference.Preference; import android.preference.Preference.OnPreferenceChangeListener; import android.preference.PreferenceScreen; import android.preference.SwitchPreference; +import android.provider.SearchIndexableResource; import android.provider.Settings; +import com.android.settings.search.BaseSearchIndexProvider; +import com.android.settings.search.Indexable.SearchIndexProvider; + +import java.util.ArrayList; +import java.util.List; + /** * Gesture lock pattern settings. */ @@ -51,6 +60,7 @@ public class PrivacySettings extends SettingsPreferenceFragment implements private SwitchPreference mAutoRestore; private Dialog mConfirmDialog; private PreferenceScreen mConfigure; + private boolean mEnabled; private static final int DIALOG_ERASE_BACKUP = 2; private int mDialogType; @@ -58,9 +68,14 @@ public class PrivacySettings extends SettingsPreferenceFragment implements @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + // Don't allow any access if this is a secondary user + mEnabled = Process.myUserHandle().isOwner(); + if (!mEnabled) { + return; + } + addPreferencesFromResource(R.xml.privacy_settings); final PreferenceScreen screen = getPreferenceScreen(); - mBackupManager = IBackupManager.Stub.asInterface( ServiceManager.getService(Context.BACKUP_SERVICE)); @@ -90,7 +105,9 @@ public class PrivacySettings extends SettingsPreferenceFragment implements super.onResume(); // Refresh UI - updateToggles(); + if (mEnabled) { + updateToggles(); + } } @Override @@ -233,4 +250,40 @@ public class PrivacySettings extends SettingsPreferenceFragment implements protected int getHelpResource() { return R.string.help_url_backup_reset; } + + /** + * For Search. + */ + public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER = + new PrivacySearchIndexProvider(); + + private static class PrivacySearchIndexProvider extends BaseSearchIndexProvider { + + boolean mIsPrimary; + + public PrivacySearchIndexProvider() { + super(); + + mIsPrimary = UserHandle.myUserId() == UserHandle.USER_OWNER; + } + + @Override + public List<SearchIndexableResource> getXmlResourcesToIndex( + Context context, boolean enabled) { + + List<SearchIndexableResource> result = new ArrayList<SearchIndexableResource>(); + + // For non-primary user, no backup or reset is available + if (!mIsPrimary) { + return result; + } + + SearchIndexableResource sir = new SearchIndexableResource(context); + sir.xmlResId = R.xml.privacy_settings; + result.add(sir); + + return result; + } + } + }
\ No newline at end of file |