Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d98de2e2 authored by Jeff Sharkey's avatar Jeff Sharkey
Browse files

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
parent 68ef6010
Loading
Loading
Loading
Loading
+22 −1
Original line number Diff line number Diff line
@@ -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) {
+2 −2
Original line number Diff line number Diff line
@@ -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) {
+4 −4
Original line number Diff line number Diff line
@@ -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);
+1 −1
Original line number Diff line number Diff line
@@ -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);
+2 −2
Original line number Diff line number Diff line
@@ -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);
            }
        };

Loading