Skip to content

Commit 301aaf6

Browse files
samiul-48android-build-team Robot
authored andcommitted
Prevent apk-in-apex from being registered under wrong apex
Without this fix, an apk-in-apex located in path /apex/com.android.mediaprovider will be added as apk-in-apex for com.android.media too, just because they have the same prefix. Added a info log too to make it easier to understand which apk-in-apex is being registered under which apex. Bug: 170640411 Test: Manual testing Change-Id: Idc989ac84777589b4bdd72012833cdbdab7e872c Merged-In: Idc989ac84777589b4bdd72012833cdbdab7e872c (cherry picked from commit c45a426) (cherry picked from commit 58cd8bc)
1 parent de4179c commit 301aaf6

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

services/core/java/com/android/server/pm/ApexManager.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -757,12 +757,15 @@ boolean uninstallApex(String apexPackagePath) {
757757
void registerApkInApex(AndroidPackage pkg) {
758758
synchronized (mLock) {
759759
for (ActiveApexInfo aai : mActiveApexInfosCache) {
760-
if (pkg.getBaseCodePath().startsWith(aai.apexDirectory.getAbsolutePath())) {
760+
if (pkg.getBaseCodePath().startsWith(
761+
aai.apexDirectory.getAbsolutePath() + File.separator)) {
761762
List<String> apks = mApksInApex.get(aai.apexModuleName);
762763
if (apks == null) {
763764
apks = Lists.newArrayList();
764765
mApksInApex.put(aai.apexModuleName, apks);
765766
}
767+
Slog.i(TAG, "Registering " + pkg.getPackageName() + " as apk-in-apex of "
768+
+ aai.apexModuleName);
766769
apks.add(pkg.getPackageName());
767770
}
768771
}

0 commit comments

Comments
 (0)