Storage accessors; persist nickname, flags.
Move to using new public accessors on DiskInfo and VolumeInfo. Persist nickname changes, and remember when user has initialized a public volume. Also skip the migration part of storage wizard until it's implemented. Bug: 19993667 Change-Id: I642fb43afb95380fddd48a1dad438e87b06454da
This commit is contained in:
@@ -48,7 +48,7 @@ public class PrivateVolumeFormatConfirm extends InstrumentedFragment {
|
|||||||
final StorageManager storage = getActivity().getSystemService(StorageManager.class);
|
final StorageManager storage = getActivity().getSystemService(StorageManager.class);
|
||||||
final String volumeId = getArguments().getString(VolumeInfo.EXTRA_VOLUME_ID);
|
final String volumeId = getArguments().getString(VolumeInfo.EXTRA_VOLUME_ID);
|
||||||
mVolume = storage.findVolumeById(volumeId);
|
mVolume = storage.findVolumeById(volumeId);
|
||||||
mDisk = storage.findDiskById(mVolume.diskId);
|
mDisk = storage.findDiskById(mVolume.getDiskId());
|
||||||
|
|
||||||
final View view = inflater.inflate(R.layout.storage_internal_format, container, false);
|
final View view = inflater.inflate(R.layout.storage_internal_format, container, false);
|
||||||
final TextView body = (TextView) view.findViewById(R.id.body);
|
final TextView body = (TextView) view.findViewById(R.id.body);
|
||||||
@@ -65,7 +65,7 @@ public class PrivateVolumeFormatConfirm extends InstrumentedFragment {
|
|||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
final Intent intent = new Intent(getActivity(), StorageWizardFormatProgress.class);
|
final Intent intent = new Intent(getActivity(), StorageWizardFormatProgress.class);
|
||||||
intent.putExtra(DiskInfo.EXTRA_DISK_ID, mDisk.id);
|
intent.putExtra(DiskInfo.EXTRA_DISK_ID, mDisk.getId());
|
||||||
intent.putExtra(StorageWizardFormatProgress.EXTRA_FORMAT_PUBLIC, true);
|
intent.putExtra(StorageWizardFormatProgress.EXTRA_FORMAT_PUBLIC, true);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
getActivity().finish();
|
getActivity().finish();
|
||||||
|
@@ -121,13 +121,13 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment {
|
|||||||
mVolume = mStorageManager.findVolumeById(mVolumeId);
|
mVolume = mStorageManager.findVolumeById(mVolumeId);
|
||||||
|
|
||||||
Preconditions.checkNotNull(mVolume);
|
Preconditions.checkNotNull(mVolume);
|
||||||
Preconditions.checkState(mVolume.type == VolumeInfo.TYPE_PRIVATE);
|
Preconditions.checkState(mVolume.getType() == VolumeInfo.TYPE_PRIVATE);
|
||||||
|
|
||||||
addPreferencesFromResource(R.xml.device_info_storage_volume);
|
addPreferencesFromResource(R.xml.device_info_storage_volume);
|
||||||
|
|
||||||
// Find the emulated shared storage layered above this private volume
|
// Find the emulated shared storage layered above this private volume
|
||||||
mSharedVolume = mStorageManager.findVolumeById(
|
mSharedVolume = mStorageManager.findVolumeById(
|
||||||
mVolume.id.replace("private", "emulated"));
|
mVolume.getId().replace("private", "emulated"));
|
||||||
|
|
||||||
mMeasure = new StorageMeasurement(context, mVolume, mSharedVolume);
|
mMeasure = new StorageMeasurement(context, mVolume, mSharedVolume);
|
||||||
mMeasure.setReceiver(mReceiver);
|
mMeasure.setReceiver(mReceiver);
|
||||||
@@ -168,7 +168,7 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment {
|
|||||||
|
|
||||||
screen.removeAll();
|
screen.removeAll();
|
||||||
|
|
||||||
if (mVolume.state != VolumeInfo.STATE_MOUNTED) {
|
if (mVolume.getState() != VolumeInfo.STATE_MOUNTED) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -202,7 +202,7 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final File file = new File(mVolume.path);
|
final File file = mVolume.getPath();
|
||||||
mTotalSize = file.getTotalSpace();
|
mTotalSize = file.getTotalSpace();
|
||||||
mAvailSize = file.getFreeSpace();
|
mAvailSize = file.getFreeSpace();
|
||||||
|
|
||||||
@@ -272,15 +272,15 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment {
|
|||||||
|
|
||||||
// Actions live in menu for non-internal private volumes; they're shown
|
// Actions live in menu for non-internal private volumes; they're shown
|
||||||
// as preference items for public volumes.
|
// as preference items for public volumes.
|
||||||
if (VolumeInfo.ID_PRIVATE_INTERNAL.equals(mVolume.id)) {
|
if (VolumeInfo.ID_PRIVATE_INTERNAL.equals(mVolume.getId())) {
|
||||||
rename.setVisible(false);
|
rename.setVisible(false);
|
||||||
mount.setVisible(false);
|
mount.setVisible(false);
|
||||||
unmount.setVisible(false);
|
unmount.setVisible(false);
|
||||||
format.setVisible(false);
|
format.setVisible(false);
|
||||||
} else {
|
} else {
|
||||||
rename.setVisible(mVolume.type == VolumeInfo.TYPE_PRIVATE);
|
rename.setVisible(mVolume.getType() == VolumeInfo.TYPE_PRIVATE);
|
||||||
mount.setVisible(mVolume.state == VolumeInfo.STATE_UNMOUNTED);
|
mount.setVisible(mVolume.getState() == VolumeInfo.STATE_UNMOUNTED);
|
||||||
unmount.setVisible(mVolume.state == VolumeInfo.STATE_MOUNTED);
|
unmount.setVisible(mVolume.getState() == VolumeInfo.STATE_MOUNTED);
|
||||||
format.setVisible(true);
|
format.setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -300,12 +300,12 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment {
|
|||||||
new MountTask(context, mVolume).execute();
|
new MountTask(context, mVolume).execute();
|
||||||
return true;
|
return true;
|
||||||
case R.id.storage_unmount:
|
case R.id.storage_unmount:
|
||||||
args.putString(VolumeInfo.EXTRA_VOLUME_ID, mVolume.id);
|
args.putString(VolumeInfo.EXTRA_VOLUME_ID, mVolume.getId());
|
||||||
startFragment(this, PrivateVolumeUnmountConfirm.class.getCanonicalName(),
|
startFragment(this, PrivateVolumeUnmountConfirm.class.getCanonicalName(),
|
||||||
R.string.storage_menu_unmount, 0, args);
|
R.string.storage_menu_unmount, 0, args);
|
||||||
return true;
|
return true;
|
||||||
case R.id.storage_format:
|
case R.id.storage_format:
|
||||||
args.putString(VolumeInfo.EXTRA_VOLUME_ID, mVolume.id);
|
args.putString(VolumeInfo.EXTRA_VOLUME_ID, mVolume.getId());
|
||||||
startFragment(this, PrivateVolumeFormatConfirm.class.getCanonicalName(),
|
startFragment(this, PrivateVolumeFormatConfirm.class.getCanonicalName(),
|
||||||
R.string.storage_menu_format, 0, args);
|
R.string.storage_menu_format, 0, args);
|
||||||
return true;
|
return true;
|
||||||
@@ -428,7 +428,7 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment {
|
|||||||
private final StorageEventListener mStorageListener = new StorageEventListener() {
|
private final StorageEventListener mStorageListener = new StorageEventListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onVolumeStateChanged(VolumeInfo vol, int oldState, int newState) {
|
public void onVolumeStateChanged(VolumeInfo vol, int oldState, int newState) {
|
||||||
if (Objects.equals(mVolume.id, vol.id)) {
|
if (Objects.equals(mVolume.getId(), vol.getId())) {
|
||||||
mVolume = vol;
|
mVolume = vol;
|
||||||
refresh();
|
refresh();
|
||||||
}
|
}
|
||||||
@@ -462,8 +462,8 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment {
|
|||||||
final View view = dialogInflater.inflate(R.layout.dialog_edittext, null, false);
|
final View view = dialogInflater.inflate(R.layout.dialog_edittext, null, false);
|
||||||
final EditText nickname = (EditText) view.findViewById(R.id.edittext);
|
final EditText nickname = (EditText) view.findViewById(R.id.edittext);
|
||||||
|
|
||||||
if (!TextUtils.isEmpty(vol.nickname)) {
|
if (!TextUtils.isEmpty(vol.getNickname())) {
|
||||||
nickname.setText(vol.nickname);
|
nickname.setText(vol.getNickname());
|
||||||
} else {
|
} else {
|
||||||
nickname.setText(storageManager.getBestVolumeDescription(vol));
|
nickname.setText(storageManager.getBestVolumeDescription(vol));
|
||||||
}
|
}
|
||||||
@@ -475,7 +475,8 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment {
|
|||||||
new DialogInterface.OnClickListener() {
|
new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
// TODO: persist the edited nickname!
|
// TODO: move to background thread
|
||||||
|
storageManager.setVolumeNickname(volId, nickname.getText().toString());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
builder.setNegativeButton(R.string.cancel, null);
|
builder.setNegativeButton(R.string.cancel, null);
|
||||||
|
@@ -48,7 +48,7 @@ public class PrivateVolumeUnmountConfirm extends InstrumentedFragment {
|
|||||||
final StorageManager storage = getActivity().getSystemService(StorageManager.class);
|
final StorageManager storage = getActivity().getSystemService(StorageManager.class);
|
||||||
final String volumeId = getArguments().getString(VolumeInfo.EXTRA_VOLUME_ID);
|
final String volumeId = getArguments().getString(VolumeInfo.EXTRA_VOLUME_ID);
|
||||||
mVolume = storage.findVolumeById(volumeId);
|
mVolume = storage.findVolumeById(volumeId);
|
||||||
mDisk = storage.findDiskById(mVolume.id);
|
mDisk = storage.findDiskById(mVolume.getId());
|
||||||
|
|
||||||
final View view = inflater.inflate(R.layout.storage_internal_unmount, container, false);
|
final View view = inflater.inflate(R.layout.storage_internal_unmount, container, false);
|
||||||
final TextView body = (TextView) view.findViewById(R.id.body);
|
final TextView body = (TextView) view.findViewById(R.id.body);
|
||||||
|
@@ -91,12 +91,12 @@ public class PublicVolumeSettings extends SettingsPreferenceFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Preconditions.checkNotNull(mVolume);
|
Preconditions.checkNotNull(mVolume);
|
||||||
Preconditions.checkState(mVolume.type == VolumeInfo.TYPE_PUBLIC);
|
Preconditions.checkState(mVolume.getType() == VolumeInfo.TYPE_PUBLIC);
|
||||||
|
|
||||||
mDisk = mStorageManager.findDiskById(mVolume.diskId);
|
mDisk = mStorageManager.findDiskById(mVolume.getDiskId());
|
||||||
Preconditions.checkNotNull(mDisk);
|
Preconditions.checkNotNull(mDisk);
|
||||||
|
|
||||||
mVolumeId = mVolume.id;
|
mVolumeId = mVolume.getId();
|
||||||
|
|
||||||
addPreferencesFromResource(R.xml.device_info_storage_volume);
|
addPreferencesFromResource(R.xml.device_info_storage_volume);
|
||||||
|
|
||||||
@@ -118,24 +118,24 @@ public class PublicVolumeSettings extends SettingsPreferenceFragment {
|
|||||||
|
|
||||||
screen.removeAll();
|
screen.removeAll();
|
||||||
|
|
||||||
if (mVolume.state == VolumeInfo.STATE_MOUNTED) {
|
if (mVolume.getState() == VolumeInfo.STATE_MOUNTED) {
|
||||||
screen.addPreference(mGraph);
|
screen.addPreference(mGraph);
|
||||||
screen.addPreference(mTotal);
|
screen.addPreference(mTotal);
|
||||||
screen.addPreference(mAvailable);
|
screen.addPreference(mAvailable);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mVolume.state == VolumeInfo.STATE_UNMOUNTED) {
|
if (mVolume.getState() == VolumeInfo.STATE_UNMOUNTED) {
|
||||||
screen.addPreference(mMount);
|
screen.addPreference(mMount);
|
||||||
}
|
}
|
||||||
if (mVolume.state == VolumeInfo.STATE_MOUNTED) {
|
if (mVolume.getState() == VolumeInfo.STATE_MOUNTED) {
|
||||||
screen.addPreference(mUnmount);
|
screen.addPreference(mUnmount);
|
||||||
}
|
}
|
||||||
screen.addPreference(mFormat);
|
screen.addPreference(mFormat);
|
||||||
if ((mDisk.flags & DiskInfo.FLAG_ADOPTABLE) != 0) {
|
if (mDisk.isAdoptable()) {
|
||||||
screen.addPreference(mFormatInternal);
|
screen.addPreference(mFormatInternal);
|
||||||
}
|
}
|
||||||
|
|
||||||
final File file = new File(mVolume.path);
|
final File file = mVolume.getPath();
|
||||||
mTotalSize = file.getTotalSpace();
|
mTotalSize = file.getTotalSpace();
|
||||||
mAvailSize = file.getFreeSpace();
|
mAvailSize = file.getFreeSpace();
|
||||||
|
|
||||||
@@ -200,7 +200,7 @@ public class PublicVolumeSettings extends SettingsPreferenceFragment {
|
|||||||
new FormatTask(context, mVolume).execute();
|
new FormatTask(context, mVolume).execute();
|
||||||
} else if (pref == mFormatInternal) {
|
} else if (pref == mFormatInternal) {
|
||||||
final Intent intent = new Intent(context, StorageWizardFormatConfirm.class);
|
final Intent intent = new Intent(context, StorageWizardFormatConfirm.class);
|
||||||
intent.putExtra(DiskInfo.EXTRA_DISK_ID, mDisk.id);
|
intent.putExtra(DiskInfo.EXTRA_DISK_ID, mDisk.getId());
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -210,7 +210,7 @@ public class PublicVolumeSettings extends SettingsPreferenceFragment {
|
|||||||
private final StorageEventListener mStorageListener = new StorageEventListener() {
|
private final StorageEventListener mStorageListener = new StorageEventListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onVolumeStateChanged(VolumeInfo vol, int oldState, int newState) {
|
public void onVolumeStateChanged(VolumeInfo vol, int oldState, int newState) {
|
||||||
if (Objects.equals(mVolume.id, vol.id)) {
|
if (Objects.equals(mVolume.getId(), vol.getId())) {
|
||||||
mVolume = vol;
|
mVolume = vol;
|
||||||
refresh();
|
refresh();
|
||||||
}
|
}
|
||||||
|
@@ -345,7 +345,7 @@ public class StorageMeasurement {
|
|||||||
final Message finished = mMeasurementHandler.obtainMessage(MeasurementHandler.MSG_COMPLETED,
|
final Message finished = mMeasurementHandler.obtainMessage(MeasurementHandler.MSG_COMPLETED,
|
||||||
details);
|
details);
|
||||||
|
|
||||||
if (mSharedVolume != null && mSharedVolume.state == VolumeInfo.STATE_MOUNTED) {
|
if (mSharedVolume != null && mSharedVolume.getState() == VolumeInfo.STATE_MOUNTED) {
|
||||||
final File basePath = mSharedVolume.getPathForUser(currentUser);
|
final File basePath = mSharedVolume.getPathForUser(currentUser);
|
||||||
|
|
||||||
// Measure media types for emulated storage, or for primary physical
|
// Measure media types for emulated storage, or for primary physical
|
||||||
@@ -359,7 +359,7 @@ public class StorageMeasurement {
|
|||||||
// Measure misc files not counted under media
|
// Measure misc files not counted under media
|
||||||
details.miscSize = measureMisc(imcs, basePath);
|
details.miscSize = measureMisc(imcs, basePath);
|
||||||
|
|
||||||
if (mSharedVolume.type == VolumeInfo.TYPE_EMULATED) {
|
if (mSharedVolume.getType() == VolumeInfo.TYPE_EMULATED) {
|
||||||
// Measure total emulated storage of all users; internal apps data
|
// Measure total emulated storage of all users; internal apps data
|
||||||
// will be spliced in later
|
// will be spliced in later
|
||||||
for (UserInfo user : users) {
|
for (UserInfo user : users) {
|
||||||
@@ -371,14 +371,14 @@ public class StorageMeasurement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Measure all apps hosted on this volume for all users
|
// Measure all apps hosted on this volume for all users
|
||||||
if (mVolume.type == VolumeInfo.TYPE_PRIVATE) {
|
if (mVolume.getType() == VolumeInfo.TYPE_PRIVATE) {
|
||||||
final List<ApplicationInfo> apps = packageManager.getInstalledApplications(
|
final List<ApplicationInfo> apps = packageManager.getInstalledApplications(
|
||||||
PackageManager.GET_UNINSTALLED_PACKAGES
|
PackageManager.GET_UNINSTALLED_PACKAGES
|
||||||
| PackageManager.GET_DISABLED_COMPONENTS);
|
| PackageManager.GET_DISABLED_COMPONENTS);
|
||||||
|
|
||||||
final List<ApplicationInfo> volumeApps = new ArrayList<>();
|
final List<ApplicationInfo> volumeApps = new ArrayList<>();
|
||||||
for (ApplicationInfo app : apps) {
|
for (ApplicationInfo app : apps) {
|
||||||
if (Objects.equals(app.volumeUuid, mVolume.fsUuid)) {
|
if (Objects.equals(app.volumeUuid, mVolume.getFsUuid())) {
|
||||||
volumeApps.add(app);
|
volumeApps.add(app);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -94,10 +94,12 @@ public class StorageSettings extends SettingsPreferenceFragment implements Index
|
|||||||
private static final Comparator<VolumeInfo> sVolumeComparator = new Comparator<VolumeInfo>() {
|
private static final Comparator<VolumeInfo> sVolumeComparator = new Comparator<VolumeInfo>() {
|
||||||
@Override
|
@Override
|
||||||
public int compare(VolumeInfo lhs, VolumeInfo rhs) {
|
public int compare(VolumeInfo lhs, VolumeInfo rhs) {
|
||||||
if (VolumeInfo.ID_PRIVATE_INTERNAL.equals(lhs.id)) {
|
if (VolumeInfo.ID_PRIVATE_INTERNAL.equals(lhs.getId())) {
|
||||||
return -1;
|
return -1;
|
||||||
} else if (lhs.getDescription() == null) {
|
} else if (lhs.getDescription() == null) {
|
||||||
return 1;
|
return 1;
|
||||||
|
} else if (rhs.getDescription() == null) {
|
||||||
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
return lhs.getDescription().compareTo(rhs.getDescription());
|
return lhs.getDescription().compareTo(rhs.getDescription());
|
||||||
}
|
}
|
||||||
@@ -114,7 +116,13 @@ public class StorageSettings extends SettingsPreferenceFragment implements Index
|
|||||||
};
|
};
|
||||||
|
|
||||||
private static boolean isInteresting(VolumeInfo vol) {
|
private static boolean isInteresting(VolumeInfo vol) {
|
||||||
return vol.type == VolumeInfo.TYPE_PRIVATE || vol.type == VolumeInfo.TYPE_PUBLIC;
|
switch(vol.getType()) {
|
||||||
|
case VolumeInfo.TYPE_PRIVATE:
|
||||||
|
case VolumeInfo.TYPE_PUBLIC:
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void refresh() {
|
private void refresh() {
|
||||||
@@ -128,9 +136,9 @@ public class StorageSettings extends SettingsPreferenceFragment implements Index
|
|||||||
Collections.sort(volumes, sVolumeComparator);
|
Collections.sort(volumes, sVolumeComparator);
|
||||||
|
|
||||||
for (VolumeInfo vol : volumes) {
|
for (VolumeInfo vol : volumes) {
|
||||||
if (vol.type == VolumeInfo.TYPE_PRIVATE) {
|
if (vol.getType() == VolumeInfo.TYPE_PRIVATE) {
|
||||||
mInternalCategory.addPreference(new StorageVolumePreference(context, vol));
|
mInternalCategory.addPreference(new StorageVolumePreference(context, vol));
|
||||||
} else if (vol.type == VolumeInfo.TYPE_PUBLIC) {
|
} else if (vol.getType() == VolumeInfo.TYPE_PUBLIC) {
|
||||||
mExternalCategory.addPreference(new StorageVolumePreference(context, vol));
|
mExternalCategory.addPreference(new StorageVolumePreference(context, vol));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -186,15 +194,15 @@ public class StorageSettings extends SettingsPreferenceFragment implements Index
|
|||||||
if (vol == null) {
|
if (vol == null) {
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
} else if (vol.type == VolumeInfo.TYPE_PRIVATE) {
|
} else if (vol.getType() == VolumeInfo.TYPE_PRIVATE) {
|
||||||
final Bundle args = new Bundle();
|
final Bundle args = new Bundle();
|
||||||
args.putString(VolumeInfo.EXTRA_VOLUME_ID, volId);
|
args.putString(VolumeInfo.EXTRA_VOLUME_ID, volId);
|
||||||
startFragment(this, PrivateVolumeSettings.class.getCanonicalName(),
|
startFragment(this, PrivateVolumeSettings.class.getCanonicalName(),
|
||||||
-1, 0, args);
|
-1, 0, args);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} else if (vol.type == VolumeInfo.TYPE_PUBLIC) {
|
} else if (vol.getType() == VolumeInfo.TYPE_PUBLIC) {
|
||||||
if (vol.state == VolumeInfo.STATE_MOUNTED) {
|
if (vol.getState() == VolumeInfo.STATE_MOUNTED) {
|
||||||
startActivity(vol.buildBrowseIntent());
|
startActivity(vol.buildBrowseIntent());
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
@@ -218,7 +226,7 @@ public class StorageSettings extends SettingsPreferenceFragment implements Index
|
|||||||
public MountTask(Context context, VolumeInfo volume) {
|
public MountTask(Context context, VolumeInfo volume) {
|
||||||
mContext = context.getApplicationContext();
|
mContext = context.getApplicationContext();
|
||||||
mStorageManager = mContext.getSystemService(StorageManager.class);
|
mStorageManager = mContext.getSystemService(StorageManager.class);
|
||||||
mVolumeId = volume.id;
|
mVolumeId = volume.getId();
|
||||||
mDescription = mStorageManager.getBestVolumeDescription(volume);
|
mDescription = mStorageManager.getBestVolumeDescription(volume);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -254,7 +262,7 @@ public class StorageSettings extends SettingsPreferenceFragment implements Index
|
|||||||
public UnmountTask(Context context, VolumeInfo volume) {
|
public UnmountTask(Context context, VolumeInfo volume) {
|
||||||
mContext = context.getApplicationContext();
|
mContext = context.getApplicationContext();
|
||||||
mStorageManager = mContext.getSystemService(StorageManager.class);
|
mStorageManager = mContext.getSystemService(StorageManager.class);
|
||||||
mVolumeId = volume.id;
|
mVolumeId = volume.getId();
|
||||||
mDescription = mStorageManager.getBestVolumeDescription(volume);
|
mDescription = mStorageManager.getBestVolumeDescription(volume);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -290,7 +298,7 @@ public class StorageSettings extends SettingsPreferenceFragment implements Index
|
|||||||
public FormatTask(Context context, VolumeInfo volume) {
|
public FormatTask(Context context, VolumeInfo volume) {
|
||||||
mContext = context.getApplicationContext();
|
mContext = context.getApplicationContext();
|
||||||
mStorageManager = mContext.getSystemService(StorageManager.class);
|
mStorageManager = mContext.getSystemService(StorageManager.class);
|
||||||
mVolumeId = volume.id;
|
mVolumeId = volume.getId();
|
||||||
mDescription = mStorageManager.getBestVolumeDescription(volume);
|
mDescription = mStorageManager.getBestVolumeDescription(volume);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -44,13 +44,13 @@ public class StorageVolumePreference extends Preference {
|
|||||||
mStorageManager = context.getSystemService(StorageManager.class);
|
mStorageManager = context.getSystemService(StorageManager.class);
|
||||||
mVolume = volume;
|
mVolume = volume;
|
||||||
|
|
||||||
setKey(volume.id);
|
setKey(volume.getId());
|
||||||
setTitle(mStorageManager.getBestVolumeDescription(volume));
|
setTitle(mStorageManager.getBestVolumeDescription(volume));
|
||||||
|
|
||||||
switch (volume.state) {
|
switch (volume.getState()) {
|
||||||
case VolumeInfo.STATE_MOUNTED:
|
case VolumeInfo.STATE_MOUNTED:
|
||||||
// TODO: move statfs() to background thread
|
// TODO: move statfs() to background thread
|
||||||
final File path = new File(volume.path);
|
final File path = volume.getPath();
|
||||||
final String free = Formatter.formatFileSize(context, path.getFreeSpace());
|
final String free = Formatter.formatFileSize(context, path.getFreeSpace());
|
||||||
final String total = Formatter.formatFileSize(context, path.getTotalSpace());
|
final String total = Formatter.formatFileSize(context, path.getTotalSpace());
|
||||||
setSummary(context.getString(R.string.storage_volume_summary, free, total));
|
setSummary(context.getString(R.string.storage_volume_summary, free, total));
|
||||||
@@ -58,13 +58,14 @@ public class StorageVolumePreference extends Preference {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: better icons
|
// TODO: better icons
|
||||||
if (VolumeInfo.ID_PRIVATE_INTERNAL.equals(volume.id)) {
|
if (VolumeInfo.ID_PRIVATE_INTERNAL.equals(volume.getId())) {
|
||||||
setIcon(context.getDrawable(R.drawable.ic_settings_storage));
|
setIcon(context.getDrawable(R.drawable.ic_settings_storage));
|
||||||
} else {
|
} else {
|
||||||
setIcon(context.getDrawable(R.drawable.ic_sim_sd));
|
setIcon(context.getDrawable(R.drawable.ic_sim_sd));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (volume.type == VolumeInfo.TYPE_PUBLIC && volume.state == VolumeInfo.STATE_MOUNTED) {
|
if (volume.getType() == VolumeInfo.TYPE_PUBLIC
|
||||||
|
&& volume.getState() == VolumeInfo.STATE_MOUNTED) {
|
||||||
setWidgetLayoutResource(R.layout.preference_storage_action);
|
setWidgetLayoutResource(R.layout.preference_storage_action);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -57,7 +57,7 @@ public abstract class StorageWizardBase extends Activity implements NavigationBa
|
|||||||
if (!TextUtils.isEmpty(diskId)) {
|
if (!TextUtils.isEmpty(diskId)) {
|
||||||
mDisk = mStorage.findDiskById(diskId);
|
mDisk = mStorage.findDiskById(diskId);
|
||||||
} else {
|
} else {
|
||||||
mDisk = mStorage.findDiskById(mVolume.diskId);
|
mDisk = mStorage.findDiskById(mVolume.getDiskId());
|
||||||
}
|
}
|
||||||
|
|
||||||
setTheme(R.style.SuwThemeMaterial_Light);
|
setTheme(R.style.SuwThemeMaterial_Light);
|
||||||
|
@@ -42,7 +42,7 @@ public class StorageWizardFormatConfirm extends StorageWizardBase {
|
|||||||
@Override
|
@Override
|
||||||
public void onNavigateNext() {
|
public void onNavigateNext() {
|
||||||
final Intent intent = new Intent(this, StorageWizardFormatProgress.class);
|
final Intent intent = new Intent(this, StorageWizardFormatProgress.class);
|
||||||
intent.putExtra(DiskInfo.EXTRA_DISK_ID, mDisk.id);
|
intent.putExtra(DiskInfo.EXTRA_DISK_ID, mDisk.getId());
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
finishAffinity();
|
finishAffinity();
|
||||||
}
|
}
|
||||||
|
@@ -59,9 +59,9 @@ public class StorageWizardFormatProgress extends StorageWizardBase {
|
|||||||
protected Exception doInBackground(Void... params) {
|
protected Exception doInBackground(Void... params) {
|
||||||
try {
|
try {
|
||||||
if (mFormatPublic) {
|
if (mFormatPublic) {
|
||||||
mStorage.partitionPublic(mDisk.id);
|
mStorage.partitionPublic(mDisk.getId());
|
||||||
} else {
|
} else {
|
||||||
mStorage.partitionPrivate(mDisk.id);
|
mStorage.partitionPrivate(mDisk.getId());
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -74,8 +74,12 @@ public class StorageWizardFormatProgress extends StorageWizardBase {
|
|||||||
final Context context = StorageWizardFormatProgress.this;
|
final Context context = StorageWizardFormatProgress.this;
|
||||||
if (e == null) {
|
if (e == null) {
|
||||||
if (!mFormatPublic) {
|
if (!mFormatPublic) {
|
||||||
final Intent intent = new Intent(context, StorageWizardMigrate.class);
|
// TODO: bring back migration once implemented
|
||||||
intent.putExtra(DiskInfo.EXTRA_DISK_ID, mDisk.id);
|
// final Intent intent = new Intent(context, StorageWizardMigrate.class);
|
||||||
|
// intent.putExtra(DiskInfo.EXTRA_DISK_ID, mDisk.getId());
|
||||||
|
// startActivity(intent);
|
||||||
|
final Intent intent = new Intent(context, StorageWizardReady.class);
|
||||||
|
intent.putExtra(DiskInfo.EXTRA_DISK_ID, mDisk.getId());
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
finishAffinity();
|
finishAffinity();
|
||||||
|
@@ -72,12 +72,15 @@ public class StorageWizardInit extends StorageWizardBase {
|
|||||||
@Override
|
@Override
|
||||||
public void onNavigateNext() {
|
public void onNavigateNext() {
|
||||||
if (mRadioExternal.isChecked()) {
|
if (mRadioExternal.isChecked()) {
|
||||||
|
// Remember that user made decision
|
||||||
|
mStorage.setVolumeInited(mVolume.getId(), true);
|
||||||
|
|
||||||
final Intent intent = new Intent(this, StorageWizardReady.class);
|
final Intent intent = new Intent(this, StorageWizardReady.class);
|
||||||
intent.putExtra(DiskInfo.EXTRA_DISK_ID, mDisk.id);
|
intent.putExtra(DiskInfo.EXTRA_DISK_ID, mDisk.getId());
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
} else if (mRadioInternal.isChecked()) {
|
} else if (mRadioInternal.isChecked()) {
|
||||||
final Intent intent = new Intent(this, StorageWizardFormatConfirm.class);
|
final Intent intent = new Intent(this, StorageWizardFormatConfirm.class);
|
||||||
intent.putExtra(DiskInfo.EXTRA_DISK_ID, mDisk.id);
|
intent.putExtra(DiskInfo.EXTRA_DISK_ID, mDisk.getId());
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -71,11 +71,11 @@ public class StorageWizardMigrate extends StorageWizardBase {
|
|||||||
public void onNavigateNext() {
|
public void onNavigateNext() {
|
||||||
if (mRadioNow.isChecked()) {
|
if (mRadioNow.isChecked()) {
|
||||||
final Intent intent = new Intent(this, StorageWizardMigrateConfirm.class);
|
final Intent intent = new Intent(this, StorageWizardMigrateConfirm.class);
|
||||||
intent.putExtra(DiskInfo.EXTRA_DISK_ID, mDisk.id);
|
intent.putExtra(DiskInfo.EXTRA_DISK_ID, mDisk.getId());
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
} else if (mRadioLater.isChecked()) {
|
} else if (mRadioLater.isChecked()) {
|
||||||
final Intent intent = new Intent(this, StorageWizardReady.class);
|
final Intent intent = new Intent(this, StorageWizardReady.class);
|
||||||
intent.putExtra(DiskInfo.EXTRA_DISK_ID, mDisk.id);
|
intent.putExtra(DiskInfo.EXTRA_DISK_ID, mDisk.getId());
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -46,7 +46,7 @@ public class StorageWizardMigrateConfirm extends StorageWizardBase {
|
|||||||
@Override
|
@Override
|
||||||
public void onNavigateNext() {
|
public void onNavigateNext() {
|
||||||
final Intent intent = new Intent(this, StorageWizardMigrateProgress.class);
|
final Intent intent = new Intent(this, StorageWizardMigrateProgress.class);
|
||||||
intent.putExtra(DiskInfo.EXTRA_DISK_ID, mDisk.id);
|
intent.putExtra(DiskInfo.EXTRA_DISK_ID, mDisk.getId());
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
finishAffinity();
|
finishAffinity();
|
||||||
}
|
}
|
||||||
|
@@ -62,7 +62,7 @@ public class StorageWizardMigrateProgress extends StorageWizardBase {
|
|||||||
final Context context = StorageWizardMigrateProgress.this;
|
final Context context = StorageWizardMigrateProgress.this;
|
||||||
if (e == null) {
|
if (e == null) {
|
||||||
final Intent intent = new Intent(context, StorageWizardReady.class);
|
final Intent intent = new Intent(context, StorageWizardReady.class);
|
||||||
intent.putExtra(DiskInfo.EXTRA_DISK_ID, mDisk.id);
|
intent.putExtra(DiskInfo.EXTRA_DISK_ID, mDisk.getId());
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
finishAffinity();
|
finishAffinity();
|
||||||
|
|
||||||
|
@@ -22,6 +22,9 @@ import android.os.storage.VolumeInfo;
|
|||||||
import com.android.internal.util.Preconditions;
|
import com.android.internal.util.Preconditions;
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
public class StorageWizardReady extends StorageWizardBase {
|
public class StorageWizardReady extends StorageWizardBase {
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
@@ -34,15 +37,15 @@ public class StorageWizardReady extends StorageWizardBase {
|
|||||||
|
|
||||||
// TODO: handle mixed partition cases instead of just guessing based on
|
// TODO: handle mixed partition cases instead of just guessing based on
|
||||||
// first volume type we encounter
|
// first volume type we encounter
|
||||||
for (String volId : mDisk.volumeIds) {
|
final List<VolumeInfo> vols = mStorage.getVolumes();
|
||||||
final VolumeInfo vol = mStorage.findVolumeById(volId);
|
for (VolumeInfo vol : vols) {
|
||||||
if (vol == null) continue;
|
if (!Objects.equals(mDisk.getId(), vol.getDiskId())) continue;
|
||||||
|
|
||||||
if (vol.type == VolumeInfo.TYPE_PUBLIC) {
|
if (vol.getType() == VolumeInfo.TYPE_PUBLIC) {
|
||||||
setBodyText(R.string.storage_wizard_ready_external_body,
|
setBodyText(R.string.storage_wizard_ready_external_body,
|
||||||
mDisk.getDescription());
|
mDisk.getDescription());
|
||||||
break;
|
break;
|
||||||
} else if (vol.type == VolumeInfo.TYPE_PRIVATE) {
|
} else if (vol.getType() == VolumeInfo.TYPE_PRIVATE) {
|
||||||
setBodyText(R.string.storage_wizard_ready_internal_body,
|
setBodyText(R.string.storage_wizard_ready_internal_body,
|
||||||
mDisk.getDescription());
|
mDisk.getDescription());
|
||||||
break;
|
break;
|
||||||
|
Reference in New Issue
Block a user