From 49bda530d23ca69651e48823e92cb90e5ebbc949 Mon Sep 17 00:00:00 2001 From: Jackal Guo Date: Mon, 14 Sep 2020 09:27:58 +0800 Subject: [PATCH] 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 --- .../android/server/pm/PackageInstallerSession.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/services/core/java/com/android/server/pm/PackageInstallerSession.java b/services/core/java/com/android/server/pm/PackageInstallerSession.java index ca125320bbf2a..9107b584263f5 100644 --- a/services/core/java/com/android/server/pm/PackageInstallerSession.java +++ b/services/core/java/com/android/server/pm/PackageInstallerSession.java @@ -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);