Log if installers drop attribute installLocation

Installers that don't respect installLocation from APKs may result
in a bad user experience when users use adoptable storage. We still
allow this, but just log it.

Bug: 109668833
Test: Install APKs that explicitly set installLocation, and check
      the installLocation from install session.
Change-Id: Idfb33e79cb0df75af68faa3a70ea8559ea1ca003
This commit is contained in:
Jackal Guo
2020-09-14 09:27:58 +08:00
parent 13b0184efc
commit 49bda530d2

View File

@@ -2270,6 +2270,17 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
"Invalid filename: " + targetName);
}
// Yell loudly if installers drop attribute installLocation when apps explicitly set.
if (apk.installLocation != PackageInfo.INSTALL_LOCATION_UNSPECIFIED) {
final String installerPackageName = getInstallerPackageName();
if (installerPackageName != null
&& (params.installLocation != apk.installLocation)) {
Slog.wtf(TAG, installerPackageName
+ " drops manifest attribute android:installLocation in " + targetName
+ " for " + mPackageName);
}
}
final File targetFile = new File(stageDir, targetName);
resolveAndStageFileLocked(addedFile, targetFile);