Find graceful description when missing disk.
Certain volumes (like internal storage) don't have a corresponding DiskInfo object, so we need to fall back to using the VolumeInfo description instead. Bug: 77991425 Test: atest com.android.settings.ui.StorageWizardTest Change-Id: I92d377035b6028dd31527100da54bfb1d1828ae9
This commit is contained in:
@@ -22,6 +22,7 @@ import static android.os.storage.VolumeInfo.EXTRA_VOLUME_ID;
|
||||
import static com.android.settings.deviceinfo.StorageSettings.TAG;
|
||||
|
||||
import android.annotation.LayoutRes;
|
||||
import android.annotation.NonNull;
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.graphics.drawable.Drawable;
|
||||
@@ -145,7 +146,7 @@ public abstract class StorageWizardBase extends Activity {
|
||||
((TextView) aux.requireViewById(R.id.storage_wizard_migrate_v2_checklist_media))
|
||||
.setText(TextUtils.expandTemplate(
|
||||
getText(R.string.storage_wizard_migrate_v2_checklist_media),
|
||||
mDisk.getShortDescription()));
|
||||
getDiskShortDescription()));
|
||||
}
|
||||
|
||||
protected void setBackButtonText(int resId, CharSequence... args) {
|
||||
@@ -228,6 +229,26 @@ public abstract class StorageWizardBase extends Activity {
|
||||
}
|
||||
}
|
||||
|
||||
protected @NonNull CharSequence getDiskDescription() {
|
||||
if (mDisk != null) {
|
||||
return mDisk.getDescription();
|
||||
} else if (mVolume != null) {
|
||||
return mVolume.getDescription();
|
||||
} else {
|
||||
return getText(R.string.unknown);
|
||||
}
|
||||
}
|
||||
|
||||
protected @NonNull CharSequence getDiskShortDescription() {
|
||||
if (mDisk != null) {
|
||||
return mDisk.getShortDescription();
|
||||
} else if (mVolume != null) {
|
||||
return mVolume.getDescription();
|
||||
} else {
|
||||
return getText(R.string.unknown);
|
||||
}
|
||||
}
|
||||
|
||||
private final StorageEventListener mStorageListener = new StorageEventListener() {
|
||||
@Override
|
||||
public void onDiskDestroyed(DiskInfo disk) {
|
||||
|
@@ -57,8 +57,8 @@ public class StorageWizardFormatProgress extends StorageWizardBase {
|
||||
|
||||
mFormatPrivate = getIntent().getBooleanExtra(EXTRA_FORMAT_PRIVATE, false);
|
||||
|
||||
setHeaderText(R.string.storage_wizard_format_progress_title, mDisk.getShortDescription());
|
||||
setBodyText(R.string.storage_wizard_format_progress_body, mDisk.getDescription());
|
||||
setHeaderText(R.string.storage_wizard_format_progress_title, getDiskShortDescription());
|
||||
setBodyText(R.string.storage_wizard_format_progress_body, getDiskDescription());
|
||||
|
||||
mTask = (PartitionTask) getLastNonConfigurationInstance();
|
||||
if (mTask == null) {
|
||||
|
@@ -39,10 +39,10 @@ public class StorageWizardFormatSlow extends StorageWizardBase {
|
||||
|
||||
mFormatPrivate = getIntent().getBooleanExtra(EXTRA_FORMAT_PRIVATE, false);
|
||||
|
||||
setHeaderText(R.string.storage_wizard_slow_v2_title, mDisk.getShortDescription());
|
||||
setBodyText(R.string.storage_wizard_slow_v2_body, mDisk.getDescription(),
|
||||
mDisk.getShortDescription(), mDisk.getShortDescription(),
|
||||
mDisk.getShortDescription());
|
||||
setHeaderText(R.string.storage_wizard_slow_v2_title, getDiskShortDescription());
|
||||
setBodyText(R.string.storage_wizard_slow_v2_body, getDiskDescription(),
|
||||
getDiskShortDescription(), getDiskShortDescription(),
|
||||
getDiskShortDescription());
|
||||
|
||||
setBackButtonText(R.string.storage_wizard_slow_v2_start_over);
|
||||
setNextButtonText(R.string.storage_wizard_slow_v2_continue);
|
||||
|
@@ -45,7 +45,7 @@ public class StorageWizardInit extends StorageWizardBase {
|
||||
mIsPermittedToAdopt = UserManager.get(this).isAdminUser()
|
||||
&& !ActivityManager.isUserAMonkey();
|
||||
|
||||
setHeaderText(R.string.storage_wizard_init_v2_title, mDisk.getShortDescription());
|
||||
setHeaderText(R.string.storage_wizard_init_v2_title, getDiskShortDescription());
|
||||
|
||||
mExternal = requireViewById(R.id.storage_wizard_init_external);
|
||||
mInternal = requireViewById(R.id.storage_wizard_init_internal);
|
||||
|
@@ -59,7 +59,7 @@ public class StorageWizardMigrateConfirm extends StorageWizardBase {
|
||||
}
|
||||
|
||||
setIcon(R.drawable.ic_swap_horiz);
|
||||
setHeaderText(R.string.storage_wizard_migrate_v2_title, mDisk.getShortDescription());
|
||||
setHeaderText(R.string.storage_wizard_migrate_v2_title, getDiskShortDescription());
|
||||
setBodyText(R.string.memory_calculating_size);
|
||||
setAuxChecklist();
|
||||
|
||||
@@ -67,7 +67,7 @@ public class StorageWizardMigrateConfirm extends StorageWizardBase {
|
||||
@Override
|
||||
public void onPostExecute(String size, String time) {
|
||||
setBodyText(R.string.storage_wizard_migrate_v2_body,
|
||||
mDisk.getDescription(), size, time);
|
||||
getDiskDescription(), size, time);
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -33,20 +33,20 @@ public class StorageWizardReady extends StorageWizardBase {
|
||||
}
|
||||
setContentView(R.layout.storage_wizard_generic);
|
||||
|
||||
setHeaderText(R.string.storage_wizard_ready_title, mDisk.getShortDescription());
|
||||
setHeaderText(R.string.storage_wizard_ready_title, getDiskShortDescription());
|
||||
|
||||
final VolumeInfo privateVol = findFirstVolume(VolumeInfo.TYPE_PRIVATE);
|
||||
if (privateVol != null) {
|
||||
if (getIntent().getBooleanExtra(EXTRA_MIGRATE_SKIP, false)) {
|
||||
setBodyText(R.string.storage_wizard_ready_v2_internal_body,
|
||||
mDisk.getDescription());
|
||||
getDiskDescription());
|
||||
} else {
|
||||
setBodyText(R.string.storage_wizard_ready_v2_internal_moved_body,
|
||||
mDisk.getDescription(), mDisk.getShortDescription());
|
||||
getDiskDescription(), getDiskShortDescription());
|
||||
}
|
||||
} else {
|
||||
setBodyText(R.string.storage_wizard_ready_v2_external_body,
|
||||
mDisk.getDescription());
|
||||
getDiskDescription());
|
||||
}
|
||||
|
||||
setNextButtonText(R.string.done);
|
||||
|
Reference in New Issue
Block a user