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;
private Preference mFormatPublic;
private Preference mFormatPrivate;
+ private boolean mIsPermittedToAdopt;
+
private boolean isVolumeValid() {
return (mVolume != null) && (mVolume.getType() == VolumeInfo.TYPE_PUBLIC)
&& mVolume.isMountedReadable();
final Context context = getActivity();
+ mIsPermittedToAdopt = UserManager.get(context).isAdminUser();
+
mStorageManager = context.getSystemService(StorageManager.class);
if (DocumentsContract.ACTION_DOCUMENT_ROOT_SETTINGS.equals(
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() {
screen.addPreference(mUnmount);
}
screen.addPreference(mFormatPublic);
- if (mDisk.isAdoptable()) {
+ if (mDisk.isAdoptable() && mIsPermittedToAdopt) {
screen.addPreference(mFormatPrivate);
}
}
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;
private RadioButton mRadioExternal;
private RadioButton mRadioInternal;
+ private boolean mIsPermittedToAdopt;
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
setContentView(R.layout.storage_wizard_init);
+ mIsPermittedToAdopt = UserManager.get(this).isAdminUser();
+
setIllustrationInternal(true);
setHeaderText(R.string.storage_wizard_init_title, mDisk.getDescription());
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() {