diff options
author | Amith Yamasani <yamasani@google.com> | 2015-06-30 14:23:54 -0700 |
---|---|---|
committer | Amith Yamasani <yamasani@google.com> | 2015-06-30 14:23:54 -0700 |
commit | 350274040e2f9adbf97aba53a2e7ab0c70f7ff5a (patch) | |
tree | 236adbc48102645795da72a8748a05517e4df7a3 /src/com/android/settings/deviceinfo | |
parent | 21e00f9819f48d33958a1bda87511e38809eb9f3 (diff) | |
download | packages_apps_Settings-350274040e2f9adbf97aba53a2e7ab0c70f7ff5a.tar.gz packages_apps_Settings-350274040e2f9adbf97aba53a2e7ab0c70f7ff5a.tar.bz2 packages_apps_Settings-350274040e2f9adbf97aba53a2e7ab0c70f7ff5a.zip |
Only allow admin users to adopt sd card as internal storage.
Bug: 21883016
Change-Id: I11ca324ab74ce2a8bf13064b4c7735aea132c562
Diffstat (limited to 'src/com/android/settings/deviceinfo')
-rw-r--r-- | src/com/android/settings/deviceinfo/PublicVolumeSettings.java | 11 | ||||
-rw-r--r-- | src/com/android/settings/deviceinfo/StorageWizardInit.java | 11 |
2 files changed, 20 insertions, 2 deletions
diff --git a/src/com/android/settings/deviceinfo/PublicVolumeSettings.java b/src/com/android/settings/deviceinfo/PublicVolumeSettings.java index 2987c12e3..9caf92ca5 100644 --- a/src/com/android/settings/deviceinfo/PublicVolumeSettings.java +++ b/src/com/android/settings/deviceinfo/PublicVolumeSettings.java @@ -20,6 +20,7 @@ import android.content.Context; import android.content.Intent; import android.net.Uri; import android.os.Bundle; +import android.os.UserManager; import android.os.storage.DiskInfo; import android.os.storage.StorageEventListener; import android.os.storage.StorageManager; @@ -64,6 +65,8 @@ public class PublicVolumeSettings extends SettingsPreferenceFragment { private Preference mFormatPublic; private Preference mFormatPrivate; + private boolean mIsPermittedToAdopt; + private boolean isVolumeValid() { return (mVolume != null) && (mVolume.getType() == VolumeInfo.TYPE_PUBLIC) && mVolume.isMountedReadable(); @@ -80,6 +83,8 @@ public class PublicVolumeSettings extends SettingsPreferenceFragment { final Context context = getActivity(); + mIsPermittedToAdopt = UserManager.get(context).isAdminUser(); + mStorageManager = context.getSystemService(StorageManager.class); if (DocumentsContract.ACTION_DOCUMENT_ROOT_SETTINGS.equals( @@ -109,7 +114,9 @@ public class PublicVolumeSettings extends SettingsPreferenceFragment { mMount = buildAction(R.string.storage_menu_mount); mUnmount = buildAction(R.string.storage_menu_unmount); mFormatPublic = buildAction(R.string.storage_menu_format); - mFormatPrivate = buildAction(R.string.storage_menu_format_private); + if (mIsPermittedToAdopt) { + mFormatPrivate = buildAction(R.string.storage_menu_format_private); + } } public void update() { @@ -148,7 +155,7 @@ public class PublicVolumeSettings extends SettingsPreferenceFragment { screen.addPreference(mUnmount); } screen.addPreference(mFormatPublic); - if (mDisk.isAdoptable()) { + if (mDisk.isAdoptable() && mIsPermittedToAdopt) { screen.addPreference(mFormatPrivate); } } diff --git a/src/com/android/settings/deviceinfo/StorageWizardInit.java b/src/com/android/settings/deviceinfo/StorageWizardInit.java index a72872c38..284e67d6d 100644 --- a/src/com/android/settings/deviceinfo/StorageWizardInit.java +++ b/src/com/android/settings/deviceinfo/StorageWizardInit.java @@ -18,6 +18,7 @@ package com.android.settings.deviceinfo; import android.content.Intent; import android.os.Bundle; +import android.os.UserManager; import android.os.storage.DiskInfo; import android.os.storage.VolumeInfo; import android.widget.CompoundButton; @@ -30,6 +31,8 @@ public class StorageWizardInit extends StorageWizardBase { private RadioButton mRadioExternal; private RadioButton mRadioInternal; + private boolean mIsPermittedToAdopt; + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -39,6 +42,8 @@ public class StorageWizardInit extends StorageWizardBase { } setContentView(R.layout.storage_wizard_init); + mIsPermittedToAdopt = UserManager.get(this).isAdminUser(); + setIllustrationInternal(true); setHeaderText(R.string.storage_wizard_init_title, mDisk.getDescription()); @@ -63,6 +68,12 @@ public class StorageWizardInit extends StorageWizardBase { onNavigateNext(); finish(); } + + // TODO: Show a message about why this is disabled for guest and that only an admin user + // can adopt an sd card. + if (!mIsPermittedToAdopt) { + mRadioInternal.setEnabled(false); + } } private final OnCheckedChangeListener mRadioListener = new OnCheckedChangeListener() { |