Fix getPackageInfo("android") in the system server.
The fix for bug 16555230 attempted to return the same LoadedApk object between the system context object and the activity thread's list of opened packaged. This ensured that we used the same classLoader on both these objects (among other things). However, the object the Context owns is actually incomplete (and necessarily so) because it might be created before the package manager is and we need the package manager to construct a complete LoadedApk object. Work around this by manually setting the classloader and aInfo for "android" contexts created by the system server's activity thread. bug: 18167468 Change-Id: I623634f912111f89eaf716b8258d1926d2513dcd
This commit is contained in:
@@ -1742,6 +1742,12 @@ public final class ActivityThread {
|
||||
new LoadedApk(this, aInfo, compatInfo, baseLoader,
|
||||
securityViolation, includeCode &&
|
||||
(aInfo.flags&ApplicationInfo.FLAG_HAS_CODE) != 0, registerPackage);
|
||||
|
||||
if (mSystemThread && "android".equals(aInfo.packageName)) {
|
||||
packageInfo.installSystemApplicationInfo(aInfo,
|
||||
getSystemContext().mPackageInfo.getClassLoader());
|
||||
}
|
||||
|
||||
if (includeCode) {
|
||||
mPackages.put(aInfo.packageName,
|
||||
new WeakReference<LoadedApk>(packageInfo));
|
||||
@@ -1802,10 +1808,6 @@ public final class ActivityThread {
|
||||
synchronized (this) {
|
||||
getSystemContext().installSystemApplicationInfo(info, classLoader);
|
||||
|
||||
// The code package for "android" in the system server needs
|
||||
// to be the system context's package.
|
||||
mPackages.put("android", new WeakReference<LoadedApk>(getSystemContext().mPackageInfo));
|
||||
|
||||
// give ourselves a default profiler
|
||||
mProfiler = new Profiler();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user