summaryrefslogtreecommitdiffstats
path: root/src/com/android/settings/deviceinfo
diff options
context:
space:
mode:
authorAmith Yamasani <yamasani@google.com>2015-06-30 23:00:27 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-06-30 23:00:28 +0000
commita8c4db48c26634836ade77f3f8f0403089245f9c (patch)
tree864f56398a96773926a3702d441fe1fce7274f70 /src/com/android/settings/deviceinfo
parenta8af51b2d8706455c8c541a4773c883341a5b73c (diff)
parent350274040e2f9adbf97aba53a2e7ab0c70f7ff5a (diff)
downloadpackages_apps_Settings-a8c4db48c26634836ade77f3f8f0403089245f9c.tar.gz
packages_apps_Settings-a8c4db48c26634836ade77f3f8f0403089245f9c.tar.bz2
packages_apps_Settings-a8c4db48c26634836ade77f3f8f0403089245f9c.zip
Merge "Only allow admin users to adopt sd card as internal storage." into mnc-dev
Diffstat (limited to 'src/com/android/settings/deviceinfo')
-rw-r--r--src/com/android/settings/deviceinfo/PublicVolumeSettings.java11
-rw-r--r--src/com/android/settings/deviceinfo/StorageWizardInit.java11
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() {