Skip to content

Commit d119bd8

Browse files
committed
Apps on adopted storage should stay there during update
An update to an app on adopted storage via a PackageInstaller.Session (eg gplay) will result in the app silently ending up back on internal storage if the (new) manifest sets INSTALL_LOCATION_INTERNAL_ONLY. However, the app data is not moved with it so the end result is that data looks like it's been wiped. Ideally, the app and data would be moved to internal. Next best would be that the user is informed that they need to uninstall and reinstall. For now, persist the app in the adopted storage location so that the user doesn't lose app data. Change-Id: I1f178ea361a875c6df6b3b20a2e44071124c39c4
1 parent 6573f4d commit d119bd8

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

core/java/com/android/internal/content/PackageHelper.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -378,15 +378,6 @@ public static String resolveInstallVolume(Context context, String packageName,
378378
installLocation = PackageInfo.INSTALL_LOCATION_INTERNAL_ONLY;
379379
}
380380

381-
// If app expresses strong desire for internal space, honor it
382-
if (installLocation == PackageInfo.INSTALL_LOCATION_INTERNAL_ONLY) {
383-
if (fitsOnInternal) {
384-
return null;
385-
} else {
386-
throw new IOException("Requested internal only, but not enough space");
387-
}
388-
}
389-
390381
// If app already exists somewhere, prefer to stay on that volume
391382
if (existingInfo != null) {
392383
if (existingInfo.volumeUuid == null && fitsOnInternal) {
@@ -397,6 +388,15 @@ public static String resolveInstallVolume(Context context, String packageName,
397388
}
398389
}
399390

391+
// If app expresses strong desire for internal space, honor it
392+
if (installLocation == PackageInfo.INSTALL_LOCATION_INTERNAL_ONLY) {
393+
if (fitsOnInternal) {
394+
return null;
395+
} else {
396+
throw new IOException("Requested internal only, but not enough space");
397+
}
398+
}
399+
400400
// We're left with either preferring external or auto, so just pick
401401
// volume with most space
402402
if (bestCandidate != null) {

0 commit comments

Comments
 (0)