diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/settings/MasterClear.java | 4 | ||||
-rw-r--r-- | src/com/android/settings/PrivacySettings.java | 57 | ||||
-rw-r--r-- | src/com/android/settings/search/SearchIndexableResources.java | 2 |
3 files changed, 59 insertions, 4 deletions
diff --git a/src/com/android/settings/MasterClear.java b/src/com/android/settings/MasterClear.java index bbd98fb0c..f789b9352 100644 --- a/src/com/android/settings/MasterClear.java +++ b/src/com/android/settings/MasterClear.java @@ -28,6 +28,7 @@ import android.content.res.Resources; import android.graphics.drawable.Drawable; import android.os.Bundle; import android.os.Environment; +import android.os.Process; import android.os.SystemProperties; import android.os.UserManager; import android.preference.Preference; @@ -234,7 +235,8 @@ public class MasterClear extends Fragment { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - if (UserManager.get(getActivity()).hasUserRestriction( + if (!Process.myUserHandle().isOwner() + || UserManager.get(getActivity()).hasUserRestriction( UserManager.DISALLOW_FACTORY_RESET)) { return inflater.inflate(R.layout.master_clear_disallowed_screen, null); } 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 diff --git a/src/com/android/settings/search/SearchIndexableResources.java b/src/com/android/settings/search/SearchIndexableResources.java index 105ce7ef1..7b3fa77f9 100644 --- a/src/com/android/settings/search/SearchIndexableResources.java +++ b/src/com/android/settings/search/SearchIndexableResources.java @@ -224,7 +224,7 @@ public final class SearchIndexableResources { sResMap.put(PrivacySettings.class.getName(), new SearchIndexableResource( Ranking.getRankForClassName(PrivacySettings.class.getName()), - R.xml.privacy_settings, + NO_DATA_RES_ID, PrivacySettings.class.getName(), R.drawable.ic_settings_backup)); |