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 static com.android.settings.deviceinfo.StorageSettings.TAG;
|
||||||
|
|
||||||
import android.annotation.LayoutRes;
|
import android.annotation.LayoutRes;
|
||||||
|
import android.annotation.NonNull;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.drawable.Drawable;
|
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))
|
((TextView) aux.requireViewById(R.id.storage_wizard_migrate_v2_checklist_media))
|
||||||
.setText(TextUtils.expandTemplate(
|
.setText(TextUtils.expandTemplate(
|
||||||
getText(R.string.storage_wizard_migrate_v2_checklist_media),
|
getText(R.string.storage_wizard_migrate_v2_checklist_media),
|
||||||
mDisk.getShortDescription()));
|
getDiskShortDescription()));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setBackButtonText(int resId, CharSequence... args) {
|
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() {
|
private final StorageEventListener mStorageListener = new StorageEventListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onDiskDestroyed(DiskInfo disk) {
|
public void onDiskDestroyed(DiskInfo disk) {
|
||||||
|
@@ -57,8 +57,8 @@ public class StorageWizardFormatProgress extends StorageWizardBase {
|
|||||||
|
|
||||||
mFormatPrivate = getIntent().getBooleanExtra(EXTRA_FORMAT_PRIVATE, false);
|
mFormatPrivate = getIntent().getBooleanExtra(EXTRA_FORMAT_PRIVATE, false);
|
||||||
|
|
||||||
setHeaderText(R.string.storage_wizard_format_progress_title, mDisk.getShortDescription());
|
setHeaderText(R.string.storage_wizard_format_progress_title, getDiskShortDescription());
|
||||||
setBodyText(R.string.storage_wizard_format_progress_body, mDisk.getDescription());
|
setBodyText(R.string.storage_wizard_format_progress_body, getDiskDescription());
|
||||||
|
|
||||||
mTask = (PartitionTask) getLastNonConfigurationInstance();
|
mTask = (PartitionTask) getLastNonConfigurationInstance();
|
||||||
if (mTask == null) {
|
if (mTask == null) {
|
||||||
|
@@ -39,10 +39,10 @@ public class StorageWizardFormatSlow extends StorageWizardBase {
|
|||||||
|
|
||||||
mFormatPrivate = getIntent().getBooleanExtra(EXTRA_FORMAT_PRIVATE, false);
|
mFormatPrivate = getIntent().getBooleanExtra(EXTRA_FORMAT_PRIVATE, false);
|
||||||
|
|
||||||
setHeaderText(R.string.storage_wizard_slow_v2_title, mDisk.getShortDescription());
|
setHeaderText(R.string.storage_wizard_slow_v2_title, getDiskShortDescription());
|
||||||
setBodyText(R.string.storage_wizard_slow_v2_body, mDisk.getDescription(),
|
setBodyText(R.string.storage_wizard_slow_v2_body, getDiskDescription(),
|
||||||
mDisk.getShortDescription(), mDisk.getShortDescription(),
|
getDiskShortDescription(), getDiskShortDescription(),
|
||||||
mDisk.getShortDescription());
|
getDiskShortDescription());
|
||||||
|
|
||||||
setBackButtonText(R.string.storage_wizard_slow_v2_start_over);
|
setBackButtonText(R.string.storage_wizard_slow_v2_start_over);
|
||||||
setNextButtonText(R.string.storage_wizard_slow_v2_continue);
|
setNextButtonText(R.string.storage_wizard_slow_v2_continue);
|
||||||
|
@@ -45,7 +45,7 @@ public class StorageWizardInit extends StorageWizardBase {
|
|||||||
mIsPermittedToAdopt = UserManager.get(this).isAdminUser()
|
mIsPermittedToAdopt = UserManager.get(this).isAdminUser()
|
||||||
&& !ActivityManager.isUserAMonkey();
|
&& !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);
|
mExternal = requireViewById(R.id.storage_wizard_init_external);
|
||||||
mInternal = requireViewById(R.id.storage_wizard_init_internal);
|
mInternal = requireViewById(R.id.storage_wizard_init_internal);
|
||||||
|
@@ -59,7 +59,7 @@ public class StorageWizardMigrateConfirm extends StorageWizardBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setIcon(R.drawable.ic_swap_horiz);
|
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);
|
setBodyText(R.string.memory_calculating_size);
|
||||||
setAuxChecklist();
|
setAuxChecklist();
|
||||||
|
|
||||||
@@ -67,7 +67,7 @@ public class StorageWizardMigrateConfirm extends StorageWizardBase {
|
|||||||
@Override
|
@Override
|
||||||
public void onPostExecute(String size, String time) {
|
public void onPostExecute(String size, String time) {
|
||||||
setBodyText(R.string.storage_wizard_migrate_v2_body,
|
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);
|
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);
|
final VolumeInfo privateVol = findFirstVolume(VolumeInfo.TYPE_PRIVATE);
|
||||||
if (privateVol != null) {
|
if (privateVol != null) {
|
||||||
if (getIntent().getBooleanExtra(EXTRA_MIGRATE_SKIP, false)) {
|
if (getIntent().getBooleanExtra(EXTRA_MIGRATE_SKIP, false)) {
|
||||||
setBodyText(R.string.storage_wizard_ready_v2_internal_body,
|
setBodyText(R.string.storage_wizard_ready_v2_internal_body,
|
||||||
mDisk.getDescription());
|
getDiskDescription());
|
||||||
} else {
|
} else {
|
||||||
setBodyText(R.string.storage_wizard_ready_v2_internal_moved_body,
|
setBodyText(R.string.storage_wizard_ready_v2_internal_moved_body,
|
||||||
mDisk.getDescription(), mDisk.getShortDescription());
|
getDiskDescription(), getDiskShortDescription());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
setBodyText(R.string.storage_wizard_ready_v2_external_body,
|
setBodyText(R.string.storage_wizard_ready_v2_external_body,
|
||||||
mDisk.getDescription());
|
getDiskDescription());
|
||||||
}
|
}
|
||||||
|
|
||||||
setNextButtonText(R.string.done);
|
setNextButtonText(R.string.done);
|
||||||
|
Reference in New Issue
Block a user