Fix devices with primary physical storage.
Always assume the factory-reset default primary storage before parsing
storage settings. Without this, we'd always default to picking
internal emulated storage during first boot or upgrade.
Bump version code to re-evaluate this for devices that default to
physical storage as primary.
Also restrict available move targets when storage is physical, since
we can't really translate between multi-user and non-multi-user aware
storage.
Bug: 20836019
Change-Id: I186ded1aa3dd9cea67497a4f53b0973031174ccd
diff --git a/core/java/android/app/ApplicationPackageManager.java b/core/java/android/app/ApplicationPackageManager.java
index 90293a4..07eee12 100644
--- a/core/java/android/app/ApplicationPackageManager.java
+++ b/core/java/android/app/ApplicationPackageManager.java
@@ -1571,9 +1571,15 @@
final VolumeInfo currentVol = getPrimaryStorageCurrentVolume();
final List<VolumeInfo> vols = storage.getVolumes();
final List<VolumeInfo> candidates = new ArrayList<>();
- for (VolumeInfo vol : vols) {
- if (Objects.equals(vol, currentVol) || isPrimaryStorageCandidateVolume(vol)) {
- candidates.add(vol);
+ if (Objects.equals(StorageManager.UUID_PRIMARY_PHYSICAL,
+ storage.getPrimaryStorageUuid()) && currentVol != null) {
+ // TODO: support moving primary physical to emulated volume
+ candidates.add(currentVol);
+ } else {
+ for (VolumeInfo vol : vols) {
+ if (Objects.equals(vol, currentVol) || isPrimaryStorageCandidateVolume(vol)) {
+ candidates.add(vol);
+ }
}
}
return candidates;
@@ -1590,12 +1596,7 @@
return false;
}
- // We can move to public volumes on legacy devices
- if ((vol.getType() == VolumeInfo.TYPE_PUBLIC) && vol.getDisk().isDefaultPrimary()) {
- return true;
- }
-
- // Otherwise we can move to any private volume
+ // We can move to any private volume
return (vol.getType() == VolumeInfo.TYPE_PRIVATE);
}