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 c45a426e8e6343922ff9c6f7380e4e7bbdf360a1)
(cherry picked from commit 58cd8bc29e092fc6c13f893c1cd497e7c3b75bdb)
diff --git a/services/core/java/com/android/server/pm/ApexManager.java b/services/core/java/com/android/server/pm/ApexManager.java
index d9d9491..1be8390 100644
--- a/services/core/java/com/android/server/pm/ApexManager.java
+++ b/services/core/java/com/android/server/pm/ApexManager.java
@@ -757,12 +757,15 @@
         void registerApkInApex(AndroidPackage pkg) {
             synchronized (mLock) {
                 for (ActiveApexInfo aai : mActiveApexInfosCache) {
-                    if (pkg.getBaseCodePath().startsWith(aai.apexDirectory.getAbsolutePath())) {
+                    if (pkg.getBaseCodePath().startsWith(
+                            aai.apexDirectory.getAbsolutePath() + File.separator)) {
                         List<String> apks = mApksInApex.get(aai.apexModuleName);
                         if (apks == null) {
                             apks = Lists.newArrayList();
                             mApksInApex.put(aai.apexModuleName, apks);
                         }
+                        Slog.i(TAG, "Registering " + pkg.getPackageName() + " as apk-in-apex of "
+                                + aai.apexModuleName);
                         apks.add(pkg.getPackageName());
                     }
                 }