Handle missing migration source volume.
Users can try migrating primary storage while the current location is missing/unmounted. Fail gracefully instead of runtime restarting. Bug: 21927076 Change-Id: I54b92487faf9e62d5d309734bf4c436a9259d156
This commit is contained in:
@@ -81,6 +81,11 @@ public abstract class MigrateEstimateTask extends AsyncTask<Void, Void, Long> im
|
||||
final VolumeInfo privateVol = mContext.getPackageManager().getPrimaryStorageCurrentVolume();
|
||||
final VolumeInfo emulatedVol = mStorage.findEmulatedForPrivate(privateVol);
|
||||
|
||||
if (emulatedVol == null) {
|
||||
Log.w(TAG, "Failed to find current primary storage");
|
||||
return -1L;
|
||||
}
|
||||
|
||||
final String path = emulatedVol.getPath().getAbsolutePath();
|
||||
Log.d(TAG, "Estimating for current path " + path);
|
||||
|
||||
|
@@ -16,10 +16,13 @@
|
||||
|
||||
package com.android.settings.deviceinfo;
|
||||
|
||||
import static com.android.settings.deviceinfo.StorageSettings.TAG;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Bundle;
|
||||
import android.os.storage.VolumeInfo;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.settings.R;
|
||||
|
||||
@@ -36,12 +39,13 @@ public class StorageWizardMigrateConfirm extends StorageWizardBase {
|
||||
mVolume = findFirstVolume(VolumeInfo.TYPE_PRIVATE);
|
||||
}
|
||||
|
||||
if (mVolume == null) {
|
||||
final VolumeInfo sourceVol = getPackageManager().getPrimaryStorageCurrentVolume();
|
||||
if (sourceVol == null || mVolume == null) {
|
||||
Log.d(TAG, "Missing either source or target volume");
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
|
||||
final VolumeInfo sourceVol = getPackageManager().getPrimaryStorageCurrentVolume();
|
||||
final String sourceDescrip = mStorage.getBestVolumeDescription(sourceVol);
|
||||
final String targetDescrip = mStorage.getBestVolumeDescription(mVolume);
|
||||
|
||||
|
Reference in New Issue
Block a user