am 73bd57f7: Merge "Retain display when creating specialized contexts. (DO NOT MERGE)" into klp-dev
* commit '73bd57f7abdb9eaf9239aa13945990acc6c97cd2': Retain display when creating specialized contexts. (DO NOT MERGE)
This commit is contained in:
@@ -152,7 +152,7 @@ public final class ActivityThread {
|
|||||||
private static final int LOG_ON_PAUSE_CALLED = 30021;
|
private static final int LOG_ON_PAUSE_CALLED = 30021;
|
||||||
private static final int LOG_ON_RESUME_CALLED = 30022;
|
private static final int LOG_ON_RESUME_CALLED = 30022;
|
||||||
|
|
||||||
static ContextImpl mSystemContext = null;
|
private ContextImpl mSystemContext;
|
||||||
|
|
||||||
static IPackageManager sPackageManager;
|
static IPackageManager sPackageManager;
|
||||||
|
|
||||||
@@ -1645,7 +1645,7 @@ public final class ActivityThread {
|
|||||||
? mBoundApplication.processName : null)
|
? mBoundApplication.processName : null)
|
||||||
+ ")");
|
+ ")");
|
||||||
packageInfo =
|
packageInfo =
|
||||||
new LoadedApk(this, aInfo, compatInfo, this, baseLoader,
|
new LoadedApk(this, aInfo, compatInfo, baseLoader,
|
||||||
securityViolation, includeCode &&
|
securityViolation, includeCode &&
|
||||||
(aInfo.flags&ApplicationInfo.FLAG_HAS_CODE) != 0);
|
(aInfo.flags&ApplicationInfo.FLAG_HAS_CODE) != 0);
|
||||||
if (includeCode) {
|
if (includeCode) {
|
||||||
@@ -1698,26 +1698,15 @@ public final class ActivityThread {
|
|||||||
public ContextImpl getSystemContext() {
|
public ContextImpl getSystemContext() {
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
if (mSystemContext == null) {
|
if (mSystemContext == null) {
|
||||||
ContextImpl context =
|
mSystemContext = ContextImpl.createSystemContext(this);
|
||||||
ContextImpl.createSystemContext(this);
|
|
||||||
LoadedApk info = new LoadedApk(this, "android", context, null,
|
|
||||||
CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO);
|
|
||||||
context.init(info, null, this);
|
|
||||||
context.getResources().updateConfiguration(mResourcesManager.getConfiguration(),
|
|
||||||
mResourcesManager.getDisplayMetricsLocked(Display.DEFAULT_DISPLAY));
|
|
||||||
mSystemContext = context;
|
|
||||||
//Slog.i(TAG, "Created system resources " + context.getResources()
|
|
||||||
// + ": " + context.getResources().getConfiguration());
|
|
||||||
}
|
}
|
||||||
|
return mSystemContext;
|
||||||
}
|
}
|
||||||
return mSystemContext;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void installSystemApplicationInfo(ApplicationInfo info) {
|
public void installSystemApplicationInfo(ApplicationInfo info) {
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
ContextImpl context = getSystemContext();
|
getSystemContext().installSystemApplicationInfo(info);
|
||||||
context.init(new LoadedApk(this, "android", context, info,
|
|
||||||
CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO), null, this);
|
|
||||||
|
|
||||||
// give ourselves a default profiler
|
// give ourselves a default profiler
|
||||||
mProfiler = new Profiler();
|
mProfiler = new Profiler();
|
||||||
@@ -2203,8 +2192,7 @@ public final class ActivityThread {
|
|||||||
|
|
||||||
private Context createBaseContextForActivity(ActivityClientRecord r,
|
private Context createBaseContextForActivity(ActivityClientRecord r,
|
||||||
final Activity activity) {
|
final Activity activity) {
|
||||||
ContextImpl appContext = new ContextImpl();
|
ContextImpl appContext = ContextImpl.createActivityContext(this, r.packageInfo, r.token);
|
||||||
appContext.init(r.packageInfo, r.token, this);
|
|
||||||
appContext.setOuterContext(activity);
|
appContext.setOuterContext(activity);
|
||||||
|
|
||||||
// For debugging purposes, if the activity's package name contains the value of
|
// For debugging purposes, if the activity's package name contains the value of
|
||||||
@@ -2489,8 +2477,7 @@ public final class ActivityThread {
|
|||||||
agent = (BackupAgent) cl.loadClass(classname).newInstance();
|
agent = (BackupAgent) cl.loadClass(classname).newInstance();
|
||||||
|
|
||||||
// set up the agent's context
|
// set up the agent's context
|
||||||
ContextImpl context = new ContextImpl();
|
ContextImpl context = ContextImpl.createAppContext(this, packageInfo);
|
||||||
context.init(packageInfo, null, this);
|
|
||||||
context.setOuterContext(agent);
|
context.setOuterContext(agent);
|
||||||
agent.attach(context);
|
agent.attach(context);
|
||||||
|
|
||||||
@@ -2562,11 +2549,10 @@ public final class ActivityThread {
|
|||||||
try {
|
try {
|
||||||
if (localLOGV) Slog.v(TAG, "Creating service " + data.info.name);
|
if (localLOGV) Slog.v(TAG, "Creating service " + data.info.name);
|
||||||
|
|
||||||
ContextImpl context = new ContextImpl();
|
ContextImpl context = ContextImpl.createAppContext(this, packageInfo);
|
||||||
context.init(packageInfo, null, this);
|
context.setOuterContext(service);
|
||||||
|
|
||||||
Application app = packageInfo.makeApplication(false, mInstrumentation);
|
Application app = packageInfo.makeApplication(false, mInstrumentation);
|
||||||
context.setOuterContext(service);
|
|
||||||
service.attach(context, this, data.info.name, data.token, app,
|
service.attach(context, this, data.info.name, data.token, app,
|
||||||
ActivityManagerNative.getDefault());
|
ActivityManagerNative.getDefault());
|
||||||
service.onCreate();
|
service.onCreate();
|
||||||
@@ -4162,8 +4148,7 @@ public final class ActivityThread {
|
|||||||
}
|
}
|
||||||
updateDefaultDensity();
|
updateDefaultDensity();
|
||||||
|
|
||||||
final ContextImpl appContext = new ContextImpl();
|
final ContextImpl appContext = ContextImpl.createAppContext(this, data.info);
|
||||||
appContext.init(data.info, null, this);
|
|
||||||
if (!Process.isIsolated()) {
|
if (!Process.isIsolated()) {
|
||||||
final File cacheDir = appContext.getCacheDir();
|
final File cacheDir = appContext.getCacheDir();
|
||||||
|
|
||||||
@@ -4274,8 +4259,7 @@ public final class ActivityThread {
|
|||||||
instrApp.nativeLibraryDir = ii.nativeLibraryDir;
|
instrApp.nativeLibraryDir = ii.nativeLibraryDir;
|
||||||
LoadedApk pi = getPackageInfo(instrApp, data.compatInfo,
|
LoadedApk pi = getPackageInfo(instrApp, data.compatInfo,
|
||||||
appContext.getClassLoader(), false, true);
|
appContext.getClassLoader(), false, true);
|
||||||
ContextImpl instrContext = new ContextImpl();
|
ContextImpl instrContext = ContextImpl.createAppContext(this, pi);
|
||||||
instrContext.init(pi, null, this);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
java.lang.ClassLoader cl = instrContext.getClassLoader();
|
java.lang.ClassLoader cl = instrContext.getClassLoader();
|
||||||
@@ -4890,8 +4874,8 @@ public final class ActivityThread {
|
|||||||
UserHandle.myUserId());
|
UserHandle.myUserId());
|
||||||
try {
|
try {
|
||||||
mInstrumentation = new Instrumentation();
|
mInstrumentation = new Instrumentation();
|
||||||
ContextImpl context = new ContextImpl();
|
ContextImpl context = ContextImpl.createAppContext(
|
||||||
context.init(getSystemContext().mPackageInfo, null, this);
|
this, getSystemContext().mPackageInfo);
|
||||||
Application app = Instrumentation.newApplication(Application.class, context);
|
Application app = Instrumentation.newApplication(Application.class, context);
|
||||||
mAllApplications.add(app);
|
mAllApplications.add(app);
|
||||||
mInitialApplication = app;
|
mInitialApplication = app;
|
||||||
|
|||||||
@@ -183,22 +183,31 @@ class ContextImpl extends Context {
|
|||||||
*/
|
*/
|
||||||
private static ArrayMap<String, ArrayMap<String, SharedPreferencesImpl>> sSharedPrefs;
|
private static ArrayMap<String, ArrayMap<String, SharedPreferencesImpl>> sSharedPrefs;
|
||||||
|
|
||||||
/*package*/ LoadedApk mPackageInfo;
|
final ActivityThread mMainThread;
|
||||||
private String mBasePackageName;
|
final LoadedApk mPackageInfo;
|
||||||
private String mOpPackageName;
|
|
||||||
private Resources mResources;
|
private final IBinder mActivityToken;
|
||||||
/*package*/ ActivityThread mMainThread;
|
|
||||||
|
private final UserHandle mUser;
|
||||||
|
|
||||||
|
private final ApplicationContentResolver mContentResolver;
|
||||||
|
|
||||||
|
private final String mBasePackageName;
|
||||||
|
private final String mOpPackageName;
|
||||||
|
|
||||||
|
private final ResourcesManager mResourcesManager;
|
||||||
|
private final Resources mResources;
|
||||||
|
private final Display mDisplay; // may be null if default display
|
||||||
|
private final DisplayAdjustments mDisplayAdjustments = new DisplayAdjustments();
|
||||||
|
private final Configuration mOverrideConfiguration;
|
||||||
|
|
||||||
|
private final boolean mRestricted;
|
||||||
|
|
||||||
private Context mOuterContext;
|
private Context mOuterContext;
|
||||||
private IBinder mActivityToken = null;
|
|
||||||
private ApplicationContentResolver mContentResolver;
|
|
||||||
private int mThemeResource = 0;
|
private int mThemeResource = 0;
|
||||||
private Resources.Theme mTheme = null;
|
private Resources.Theme mTheme = null;
|
||||||
private PackageManager mPackageManager;
|
private PackageManager mPackageManager;
|
||||||
private Display mDisplay; // may be null if default display
|
|
||||||
private Context mReceiverRestrictedContext = null;
|
private Context mReceiverRestrictedContext = null;
|
||||||
private boolean mRestricted;
|
|
||||||
private UserHandle mUser;
|
|
||||||
private ResourcesManager mResourcesManager;
|
|
||||||
|
|
||||||
private final Object mSync = new Object();
|
private final Object mSync = new Object();
|
||||||
|
|
||||||
@@ -220,8 +229,6 @@ class ContextImpl extends Context {
|
|||||||
|
|
||||||
private static final String[] EMPTY_FILE_LIST = {};
|
private static final String[] EMPTY_FILE_LIST = {};
|
||||||
|
|
||||||
final private DisplayAdjustments mDisplayAdjustments = new DisplayAdjustments();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Override this class when the system service constructor needs a
|
* Override this class when the system service constructor needs a
|
||||||
* ContextImpl. Else, use StaticServiceFetcher below.
|
* ContextImpl. Else, use StaticServiceFetcher below.
|
||||||
@@ -1879,20 +1886,17 @@ class ContextImpl extends Context {
|
|||||||
@Override
|
@Override
|
||||||
public Context createPackageContextAsUser(String packageName, int flags, UserHandle user)
|
public Context createPackageContextAsUser(String packageName, int flags, UserHandle user)
|
||||||
throws NameNotFoundException {
|
throws NameNotFoundException {
|
||||||
|
final boolean restricted = (flags & CONTEXT_RESTRICTED) == CONTEXT_RESTRICTED;
|
||||||
if (packageName.equals("system") || packageName.equals("android")) {
|
if (packageName.equals("system") || packageName.equals("android")) {
|
||||||
final ContextImpl context = new ContextImpl(mMainThread.getSystemContext());
|
return new ContextImpl(this, mMainThread, mPackageInfo, mActivityToken,
|
||||||
context.mRestricted = (flags & CONTEXT_RESTRICTED) == CONTEXT_RESTRICTED;
|
user, restricted, mDisplay, mOverrideConfiguration);
|
||||||
context.init(mPackageInfo, null, mMainThread, mResources, mBasePackageName, user);
|
|
||||||
return context;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LoadedApk pi =
|
LoadedApk pi = mMainThread.getPackageInfo(packageName, mResources.getCompatibilityInfo(),
|
||||||
mMainThread.getPackageInfo(packageName, mResources.getCompatibilityInfo(), flags,
|
flags, user.getIdentifier());
|
||||||
user.getIdentifier());
|
|
||||||
if (pi != null) {
|
if (pi != null) {
|
||||||
ContextImpl c = new ContextImpl();
|
ContextImpl c = new ContextImpl(this, mMainThread, pi, mActivityToken,
|
||||||
c.mRestricted = (flags & CONTEXT_RESTRICTED) == CONTEXT_RESTRICTED;
|
user, restricted, mDisplay, mOverrideConfiguration);
|
||||||
c.init(pi, null, mMainThread, mResources, mBasePackageName, user);
|
|
||||||
if (c.mResources != null) {
|
if (c.mResources != null) {
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
@@ -1900,7 +1904,7 @@ class ContextImpl extends Context {
|
|||||||
|
|
||||||
// Should be a better exception.
|
// Should be a better exception.
|
||||||
throw new PackageManager.NameNotFoundException(
|
throw new PackageManager.NameNotFoundException(
|
||||||
"Application package " + packageName + " not found");
|
"Application package " + packageName + " not found");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1909,12 +1913,8 @@ class ContextImpl extends Context {
|
|||||||
throw new IllegalArgumentException("overrideConfiguration must not be null");
|
throw new IllegalArgumentException("overrideConfiguration must not be null");
|
||||||
}
|
}
|
||||||
|
|
||||||
ContextImpl c = new ContextImpl();
|
return new ContextImpl(this, mMainThread, mPackageInfo, mActivityToken,
|
||||||
c.init(mPackageInfo, null, mMainThread);
|
mUser, mRestricted, mDisplay, overrideConfiguration);
|
||||||
c.mResources = mResourcesManager.getTopLevelResources(mPackageInfo.getResDir(),
|
|
||||||
getDisplayId(), overrideConfiguration, mResources.getCompatibilityInfo(),
|
|
||||||
mActivityToken);
|
|
||||||
return c;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1923,15 +1923,8 @@ class ContextImpl extends Context {
|
|||||||
throw new IllegalArgumentException("display must not be null");
|
throw new IllegalArgumentException("display must not be null");
|
||||||
}
|
}
|
||||||
|
|
||||||
int displayId = display.getDisplayId();
|
return new ContextImpl(this, mMainThread, mPackageInfo, mActivityToken,
|
||||||
|
mUser, mRestricted, display, mOverrideConfiguration);
|
||||||
ContextImpl context = new ContextImpl();
|
|
||||||
context.init(mPackageInfo, null, mMainThread);
|
|
||||||
context.mDisplay = display;
|
|
||||||
DisplayAdjustments daj = getDisplayAdjustments(displayId);
|
|
||||||
context.mResources = mResourcesManager.getTopLevelResources(mPackageInfo.getResDir(),
|
|
||||||
displayId, null, daj.getCompatibilityInfo(), null);
|
|
||||||
return context;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getDisplayId() {
|
private int getDisplayId() {
|
||||||
@@ -1973,43 +1966,76 @@ class ContextImpl extends Context {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static ContextImpl createSystemContext(ActivityThread mainThread) {
|
static ContextImpl createSystemContext(ActivityThread mainThread) {
|
||||||
final ContextImpl context = new ContextImpl();
|
LoadedApk packageInfo = new LoadedApk(mainThread);
|
||||||
context.init(Resources.getSystem(), mainThread, Process.myUserHandle());
|
ContextImpl context = new ContextImpl(null, mainThread,
|
||||||
|
packageInfo, null, null, false, null, null);
|
||||||
|
context.mResources.updateConfiguration(context.mResourcesManager.getConfiguration(),
|
||||||
|
context.mResourcesManager.getDisplayMetricsLocked(Display.DEFAULT_DISPLAY));
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
ContextImpl() {
|
static ContextImpl createAppContext(ActivityThread mainThread, LoadedApk packageInfo) {
|
||||||
|
if (packageInfo == null) throw new IllegalArgumentException("packageInfo");
|
||||||
|
return new ContextImpl(null, mainThread,
|
||||||
|
packageInfo, null, null, false, null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
static ContextImpl createActivityContext(ActivityThread mainThread,
|
||||||
|
LoadedApk packageInfo, IBinder activityToken) {
|
||||||
|
if (packageInfo == null) throw new IllegalArgumentException("packageInfo");
|
||||||
|
if (activityToken == null) throw new IllegalArgumentException("activityInfo");
|
||||||
|
return new ContextImpl(null, mainThread,
|
||||||
|
packageInfo, activityToken, null, false, null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private ContextImpl(ContextImpl container, ActivityThread mainThread,
|
||||||
|
LoadedApk packageInfo, IBinder activityToken, UserHandle user, boolean restricted,
|
||||||
|
Display display, Configuration overrideConfiguration) {
|
||||||
mOuterContext = this;
|
mOuterContext = this;
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
mMainThread = mainThread;
|
||||||
* Create a new ApplicationContext from an existing one. The new one
|
mActivityToken = activityToken;
|
||||||
* works and operates the same as the one it is copying.
|
mRestricted = restricted;
|
||||||
*
|
|
||||||
* @param context Existing application context.
|
|
||||||
*/
|
|
||||||
public ContextImpl(ContextImpl context) {
|
|
||||||
mPackageInfo = context.mPackageInfo;
|
|
||||||
mBasePackageName = context.mBasePackageName;
|
|
||||||
mOpPackageName = context.mOpPackageName;
|
|
||||||
mResources = context.mResources;
|
|
||||||
mMainThread = context.mMainThread;
|
|
||||||
mContentResolver = context.mContentResolver;
|
|
||||||
mUser = context.mUser;
|
|
||||||
mDisplay = context.mDisplay;
|
|
||||||
mOuterContext = this;
|
|
||||||
mDisplayAdjustments.setCompatibilityInfo(mPackageInfo.getCompatibilityInfo());
|
|
||||||
}
|
|
||||||
|
|
||||||
final void init(LoadedApk packageInfo, IBinder activityToken, ActivityThread mainThread) {
|
if (user == null) {
|
||||||
init(packageInfo, activityToken, mainThread, null, null, Process.myUserHandle());
|
user = Process.myUserHandle();
|
||||||
}
|
}
|
||||||
|
mUser = user;
|
||||||
|
|
||||||
final void init(LoadedApk packageInfo, IBinder activityToken, ActivityThread mainThread,
|
|
||||||
Resources container, String basePackageName, UserHandle user) {
|
|
||||||
mPackageInfo = packageInfo;
|
mPackageInfo = packageInfo;
|
||||||
if (basePackageName != null) {
|
mContentResolver = new ApplicationContentResolver(this, mainThread, user);
|
||||||
mBasePackageName = mOpPackageName = basePackageName;
|
mResourcesManager = ResourcesManager.getInstance();
|
||||||
|
mDisplay = display;
|
||||||
|
mOverrideConfiguration = overrideConfiguration;
|
||||||
|
|
||||||
|
final int displayId = getDisplayId();
|
||||||
|
CompatibilityInfo compatInfo = null;
|
||||||
|
if (container != null) {
|
||||||
|
compatInfo = container.getDisplayAdjustments(displayId).getCompatibilityInfo();
|
||||||
|
}
|
||||||
|
if (compatInfo == null && displayId == Display.DEFAULT_DISPLAY) {
|
||||||
|
compatInfo = packageInfo.getCompatibilityInfo();
|
||||||
|
}
|
||||||
|
mDisplayAdjustments.setCompatibilityInfo(compatInfo);
|
||||||
|
mDisplayAdjustments.setActivityToken(activityToken);
|
||||||
|
|
||||||
|
Resources resources = packageInfo.getResources(mainThread);
|
||||||
|
if (resources != null) {
|
||||||
|
if (activityToken != null
|
||||||
|
|| displayId != Display.DEFAULT_DISPLAY
|
||||||
|
|| overrideConfiguration != null
|
||||||
|
|| (compatInfo != null && compatInfo.applicationScale
|
||||||
|
!= resources.getCompatibilityInfo().applicationScale)) {
|
||||||
|
resources = mResourcesManager.getTopLevelResources(
|
||||||
|
packageInfo.getResDir(), displayId,
|
||||||
|
overrideConfiguration, compatInfo, activityToken);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mResources = resources;
|
||||||
|
|
||||||
|
if (container != null) {
|
||||||
|
mBasePackageName = container.mBasePackageName;
|
||||||
|
mOpPackageName = container.mOpPackageName;
|
||||||
} else {
|
} else {
|
||||||
mBasePackageName = packageInfo.mPackageName;
|
mBasePackageName = packageInfo.mPackageName;
|
||||||
ApplicationInfo ainfo = packageInfo.getApplicationInfo();
|
ApplicationInfo ainfo = packageInfo.getApplicationInfo();
|
||||||
@@ -2023,44 +2049,10 @@ class ContextImpl extends Context {
|
|||||||
mOpPackageName = mBasePackageName;
|
mOpPackageName = mBasePackageName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mResources = mPackageInfo.getResources(mainThread);
|
|
||||||
mResourcesManager = ResourcesManager.getInstance();
|
|
||||||
|
|
||||||
CompatibilityInfo compatInfo =
|
|
||||||
container == null ? null : container.getCompatibilityInfo();
|
|
||||||
if (mResources != null &&
|
|
||||||
((compatInfo != null && compatInfo.applicationScale !=
|
|
||||||
mResources.getCompatibilityInfo().applicationScale)
|
|
||||||
|| activityToken != null)) {
|
|
||||||
if (DEBUG) {
|
|
||||||
Log.d(TAG, "loaded context has different scaling. Using container's" +
|
|
||||||
" compatiblity info:" + container.getDisplayMetrics());
|
|
||||||
}
|
|
||||||
if (compatInfo == null) {
|
|
||||||
compatInfo = packageInfo.getCompatibilityInfo();
|
|
||||||
}
|
|
||||||
mDisplayAdjustments.setCompatibilityInfo(compatInfo);
|
|
||||||
mDisplayAdjustments.setActivityToken(activityToken);
|
|
||||||
mResources = mResourcesManager.getTopLevelResources(mPackageInfo.getResDir(),
|
|
||||||
Display.DEFAULT_DISPLAY, null, compatInfo, activityToken);
|
|
||||||
} else {
|
|
||||||
mDisplayAdjustments.setCompatibilityInfo(packageInfo.getCompatibilityInfo());
|
|
||||||
mDisplayAdjustments.setActivityToken(activityToken);
|
|
||||||
}
|
|
||||||
mMainThread = mainThread;
|
|
||||||
mActivityToken = activityToken;
|
|
||||||
mContentResolver = new ApplicationContentResolver(this, mainThread, user);
|
|
||||||
mUser = user;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final void init(Resources resources, ActivityThread mainThread, UserHandle user) {
|
void installSystemApplicationInfo(ApplicationInfo info) {
|
||||||
mPackageInfo = null;
|
mPackageInfo.installSystemApplicationInfo(info);
|
||||||
mBasePackageName = null;
|
|
||||||
mOpPackageName = null;
|
|
||||||
mResources = resources;
|
|
||||||
mMainThread = mainThread;
|
|
||||||
mContentResolver = new ApplicationContentResolver(this, mainThread, user);
|
|
||||||
mUser = user;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final void scheduleFinalCleanup(String who, String what) {
|
final void scheduleFinalCleanup(String who, String what) {
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ public final class LoadedApk {
|
|||||||
private static final String TAG = "LoadedApk";
|
private static final String TAG = "LoadedApk";
|
||||||
|
|
||||||
private final ActivityThread mActivityThread;
|
private final ActivityThread mActivityThread;
|
||||||
private final ApplicationInfo mApplicationInfo;
|
private ApplicationInfo mApplicationInfo;
|
||||||
final String mPackageName;
|
final String mPackageName;
|
||||||
private final String mAppDir;
|
private final String mAppDir;
|
||||||
private final String mResDir;
|
private final String mResDir;
|
||||||
@@ -110,8 +110,7 @@ public final class LoadedApk {
|
|||||||
* so MUST NOT call back out to the activity manager.
|
* so MUST NOT call back out to the activity manager.
|
||||||
*/
|
*/
|
||||||
public LoadedApk(ActivityThread activityThread, ApplicationInfo aInfo,
|
public LoadedApk(ActivityThread activityThread, ApplicationInfo aInfo,
|
||||||
CompatibilityInfo compatInfo,
|
CompatibilityInfo compatInfo, ClassLoader baseLoader,
|
||||||
ActivityThread mainThread, ClassLoader baseLoader,
|
|
||||||
boolean securityViolation, boolean includeCode) {
|
boolean securityViolation, boolean includeCode) {
|
||||||
mActivityThread = activityThread;
|
mActivityThread = activityThread;
|
||||||
mApplicationInfo = aInfo;
|
mApplicationInfo = aInfo;
|
||||||
@@ -132,31 +131,17 @@ public final class LoadedApk {
|
|||||||
mSecurityViolation = securityViolation;
|
mSecurityViolation = securityViolation;
|
||||||
mIncludeCode = includeCode;
|
mIncludeCode = includeCode;
|
||||||
mDisplayAdjustments.setCompatibilityInfo(compatInfo);
|
mDisplayAdjustments.setCompatibilityInfo(compatInfo);
|
||||||
|
|
||||||
if (mAppDir == null) {
|
|
||||||
if (ActivityThread.mSystemContext == null) {
|
|
||||||
ActivityThread.mSystemContext =
|
|
||||||
ContextImpl.createSystemContext(mainThread);
|
|
||||||
ResourcesManager resourcesManager = ResourcesManager.getInstance();
|
|
||||||
ActivityThread.mSystemContext.getResources().updateConfiguration(
|
|
||||||
resourcesManager.getConfiguration(),
|
|
||||||
resourcesManager.getDisplayMetricsLocked(
|
|
||||||
Display.DEFAULT_DISPLAY, mDisplayAdjustments), compatInfo);
|
|
||||||
//Slog.i(TAG, "Created system resources "
|
|
||||||
// + mSystemContext.getResources() + ": "
|
|
||||||
// + mSystemContext.getResources().getConfiguration());
|
|
||||||
}
|
|
||||||
mClassLoader = ActivityThread.mSystemContext.getClassLoader();
|
|
||||||
mResources = ActivityThread.mSystemContext.getResources();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public LoadedApk(ActivityThread activityThread, String name,
|
/**
|
||||||
Context systemContext, ApplicationInfo info, CompatibilityInfo compatInfo) {
|
* Create information about the system package.
|
||||||
|
* Must call {@link #installSystemApplicationInfo} later.
|
||||||
|
*/
|
||||||
|
LoadedApk(ActivityThread activityThread) {
|
||||||
mActivityThread = activityThread;
|
mActivityThread = activityThread;
|
||||||
mApplicationInfo = info != null ? info : new ApplicationInfo();
|
mApplicationInfo = new ApplicationInfo();
|
||||||
mApplicationInfo.packageName = name;
|
mApplicationInfo.packageName = "android";
|
||||||
mPackageName = name;
|
mPackageName = "android";
|
||||||
mAppDir = null;
|
mAppDir = null;
|
||||||
mResDir = null;
|
mResDir = null;
|
||||||
mSharedLibraries = null;
|
mSharedLibraries = null;
|
||||||
@@ -166,9 +151,16 @@ public final class LoadedApk {
|
|||||||
mBaseClassLoader = null;
|
mBaseClassLoader = null;
|
||||||
mSecurityViolation = false;
|
mSecurityViolation = false;
|
||||||
mIncludeCode = true;
|
mIncludeCode = true;
|
||||||
mClassLoader = systemContext.getClassLoader();
|
mClassLoader = ClassLoader.getSystemClassLoader();
|
||||||
mResources = systemContext.getResources();
|
mResources = Resources.getSystem();
|
||||||
mDisplayAdjustments.setCompatibilityInfo(compatInfo);
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets application info about the system package.
|
||||||
|
*/
|
||||||
|
void installSystemApplicationInfo(ApplicationInfo info) {
|
||||||
|
assert info.packageName.equals("android");
|
||||||
|
mApplicationInfo = info;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPackageName() {
|
public String getPackageName() {
|
||||||
@@ -506,8 +498,7 @@ public final class LoadedApk {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
java.lang.ClassLoader cl = getClassLoader();
|
java.lang.ClassLoader cl = getClassLoader();
|
||||||
ContextImpl appContext = new ContextImpl();
|
ContextImpl appContext = ContextImpl.createAppContext(mActivityThread, this);
|
||||||
appContext.init(this, null, mActivityThread);
|
|
||||||
app = mActivityThread.mInstrumentation.newApplication(
|
app = mActivityThread.mInstrumentation.newApplication(
|
||||||
cl, appClass, appContext);
|
cl, appClass, appContext);
|
||||||
appContext.setOuterContext(app);
|
appContext.setOuterContext(app);
|
||||||
|
|||||||
Reference in New Issue
Block a user