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

Commit 1ec941db authored by Philip P. Moltmann's avatar Philip P. Moltmann
Browse files

Handling of issues while migrating primary storage

Bug: 28177789
Change-Id: Icfbd048ddf0a1d55df1e7273d49727357b98a452
parent 05c6a2c0
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -3432,6 +3432,10 @@
    <!-- Manage applications, text for Move button when move is in progress -->
    <string name="moving">Moving</string>
    <!-- Text of pop up message if the request for a "migrate primary storage" operation
         (see storage_menu_migrate) is denied as another is already in progress. [CHAR LIMIT=75] -->
    <string name="another_migration_already_in_progress">Another migration is already in progress.</string>
    <!-- Manage applications, text for move error messages -->
    <string name="insufficient_storage">Not enough storage space.</string>
    <string name="does_not_exist">App doesn\u2019t exist.</string>
+30 −1
Original line number Diff line number Diff line
@@ -19,11 +19,16 @@ package com.android.settings.deviceinfo;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.os.storage.DiskInfo;
import android.os.storage.StorageManager;
import android.os.storage.VolumeInfo;
import android.util.Log;

import android.widget.Toast;
import com.android.settings.R;

import java.util.Objects;

import static com.android.settings.deviceinfo.StorageSettings.TAG;

public class StorageWizardMigrateConfirm extends StorageWizardBase {
@@ -70,7 +75,31 @@ public class StorageWizardMigrateConfirm extends StorageWizardBase {

    @Override
    public void onNavigateNext() {
        final int moveId = getPackageManager().movePrimaryStorage(mVolume);
        int moveId;

        // We only expect exceptions from MountService#setPrimaryStorageUuid
        try {
            moveId = getPackageManager().movePrimaryStorage(mVolume);
        } catch (IllegalArgumentException e) {
            StorageManager sm = (StorageManager) getSystemService(STORAGE_SERVICE);

            if (Objects.equals(mVolume.getFsUuid(), sm.getPrimaryStorageVolume().getUuid())) {
                final Intent intent = new Intent(this, StorageWizardReady.class);
                intent.putExtra(DiskInfo.EXTRA_DISK_ID, mDisk.getId());
                startActivity(intent);
                finishAffinity();

                return;
            } else {
                throw e;
            }
        } catch (IllegalStateException e) {
            Toast.makeText(this, getString(R.string.another_migration_already_in_progress),
                    Toast.LENGTH_LONG).show();
            finishAffinity();

            return;
        }

        final Intent intent = new Intent(this, StorageWizardMigrateProgress.class);
        intent.putExtra(VolumeInfo.EXTRA_VOLUME_ID, mVolume.getId());
+5 −3
Original line number Diff line number Diff line
@@ -76,10 +76,12 @@ public class StorageWizardMigrateProgress extends StorageWizardBase {
                        finishIntent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
                        sendBroadcast(finishIntent);

                        if (!StorageWizardMigrateProgress.this.isFinishing()) {
                            final Intent intent = new Intent(context, StorageWizardReady.class);
                            intent.putExtra(DiskInfo.EXTRA_DISK_ID, mDisk.getId());
                            startActivity(intent);
                        }
                    }
                } else {
                    Toast.makeText(context, getString(R.string.insufficient_storage),
                            Toast.LENGTH_LONG).show();