Merge "Do not try to resolve realpath in DexManager."

This commit is contained in:
Calin Juravle
2017-01-09 18:12:14 +00:00
committed by Android (Google) Code Review
2 changed files with 29 additions and 26 deletions

View File

@@ -2640,19 +2640,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: "
@@ -2810,6 +2797,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)

View File

@@ -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;
}
}