Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c066205c authored by Calin Juravle's avatar Calin Juravle
Browse files

Do not try to resolve realpath in DexManager.

PM should already provide the real path of the application directory.

Test: runtest -x .../DexManagerTests.java

Bug: 33807524
Bug: 32871170
Change-Id: I700419157bf5532af6437812b7e0a76f80057022
parent ae89c4c1
Loading
Loading
Loading
Loading
+15 −13
Original line number Diff line number Diff line
@@ -2622,19 +2622,6 @@ public class PackageManagerService extends IPackageManager.Stub {
            mPackageUsage.read(mPackages);
            mCompilerStats.read();
            // Read and update the usage of dex files.
            // At this point we know the code paths  of the packages, so we can validate
            // the disk file and build the internal cache.
            // The usage file is expected to be small so loading and verifying it
            // should take a fairly small time compare to the other activities (e.g. package
            // scanning).
            final Map<Integer, List<PackageInfo>> userPackages = new HashMap<>();
            final int[] currentUserIds = UserManagerService.getInstance().getUserIds();
            for (int userId : currentUserIds) {
                userPackages.put(userId, getInstalledPackages(/*flags*/ 0, userId).getList());
            }
            mDexManager.load(userPackages);
            EventLog.writeEvent(EventLogTags.BOOT_PROGRESS_PMS_SCAN_END,
                    SystemClock.uptimeMillis());
            Slog.i(TAG, "Time to scan packages: "
@@ -2792,6 +2779,21 @@ public class PackageManagerService extends IPackageManager.Stub {
            }
            mEphemeralApplicationRegistry = new EphemeralApplicationRegistry(this);
            // Read and update the usage of dex files.
            // Do this at the end of PM init so that all the packages have their
            // data directory reconciled.
            // At this point we know the code paths of the packages, so we can validate
            // the disk file and build the internal cache.
            // The usage file is expected to be small so loading and verifying it
            // should take a fairly small time compare to the other activities (e.g. package
            // scanning).
            final Map<Integer, List<PackageInfo>> userPackages = new HashMap<>();
            final int[] currentUserIds = UserManagerService.getInstance().getUserIds();
            for (int userId : currentUserIds) {
                userPackages.put(userId, getInstalledPackages(/*flags*/ 0, userId).getList());
            }
            mDexManager.load(userPackages);
        } // synchronized (mPackages)
        } // synchronized (mInstallLock)
+14 −13
Original line number Diff line number Diff line
@@ -265,19 +265,6 @@ public class DexManager {
        public void mergeAppDataDirs(ApplicationInfo ai, int userId) {
            Set<String> dataDirs = putIfAbsent(mAppDataDirs, userId, new HashSet<>());
            dataDirs.add(ai.dataDir);

            // Compute and cache the real path as well since data dir may be a symlink.
            // e.g. /data/data/ -> /data/user/0/
            try {
                dataDirs.add(PackageManagerServiceUtils.realpath(new File(ai.dataDir)));
            } catch (IOException e) {
                if (DEBUG) {
                    // Verify why we're getting spam at boot for some devices.
                    // b/33807524
                    Slog.w(TAG, "Error to get realpath of " + ai.dataDir, e);
                }
            }

        }

        public int searchDex(String dexPath, int userId) {
@@ -302,6 +289,20 @@ public class DexManager {
                    return DEX_SEARCH_FOUND_SECONDARY;
                }
            }

            // TODO(calin): What if we get a symlink? e.g. data dir may be a symlink,
            // /data/data/ -> /data/user/0/.
            if (DEBUG) {
                try {
                    String dexPathReal = PackageManagerServiceUtils.realpath(new File(dexPath));
                    if (dexPathReal != dexPath) {
                        Slog.d(TAG, "Dex loaded with symlink. dexPath=" +
                                dexPath + " dexPathReal=" + dexPathReal);
                    }
                } catch (IOException e) {
                    // Ignore
                }
            }
            return DEX_SEARCH_NOT_FOUND;
        }
    }