Merge "Only allow admin users to adopt sd card as internal storage." into mnc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
a8c4db48c2
@@ -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);
|
||||
}
|
||||
}
|
||||
|
@@ -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() {
|
||||
|
Reference in New Issue
Block a user