Handling of issues while migrating primary storage
am: 1ec941db0c
* commit '1ec941db0ce37a864b5aa1a92111e5c52953c33e':
Handling of issues while migrating primary storage
Change-Id: I95283e6b84be28c026867b47ce84a1425e8b3859
This commit is contained in:
@@ -3434,6 +3434,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>
|
||||
|
@@ -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());
|
||||
|
@@ -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();
|
||||
|
Reference in New Issue
Block a user