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) {
|
||||
|
Reference in New Issue
Block a user