Revert "Minor LoadedApk refactoring."
This reverts commit 7541ca4d1aa48e3110187a83a8dccbfa72084148.
Change-Id: I2a6aa5038870c32c4145436f0463092c9b82dd23
Bug: 71501570
Test: manual
(cherry picked from commit 233a0b14ca1158b9844cd127d0beabfc3d601c1c)
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java
index 3dedeea..6c3dbf4 100644
--- a/core/java/android/app/ActivityThread.java
+++ b/core/java/android/app/ActivityThread.java
@@ -389,7 +389,7 @@
ActivityInfo activityInfo;
CompatibilityInfo compatInfo;
- public LoadedApk loadedApk;
+ public LoadedApk packageInfo;
List<ResultInfo> pendingResults;
List<ReferrerIntent> pendingIntents;
@@ -432,7 +432,7 @@
this.isForward = isForward;
this.profilerInfo = profilerInfo;
this.overrideConfig = overrideConfig;
- this.loadedApk = client.getLoadedApkNoCheck(activityInfo.applicationInfo,
+ this.packageInfo = client.getPackageInfoNoCheck(activityInfo.applicationInfo,
compatInfo);
init();
}
@@ -614,7 +614,7 @@
}
static final class AppBindData {
- LoadedApk loadedApk;
+ LoadedApk info;
String processName;
ApplicationInfo appInfo;
List<ProviderInfo> providers;
@@ -1913,13 +1913,13 @@
return mH;
}
- public final LoadedApk getLoadedApkForPackageName(String packageName,
- CompatibilityInfo compatInfo, int flags) {
- return getLoadedApkForPackageName(packageName, compatInfo, flags, UserHandle.myUserId());
+ public final LoadedApk getPackageInfo(String packageName, CompatibilityInfo compatInfo,
+ int flags) {
+ return getPackageInfo(packageName, compatInfo, flags, UserHandle.myUserId());
}
- public final LoadedApk getLoadedApkForPackageName(String packageName,
- CompatibilityInfo compatInfo, int flags, int userId) {
+ public final LoadedApk getPackageInfo(String packageName, CompatibilityInfo compatInfo,
+ int flags, int userId) {
final boolean differentUser = (UserHandle.myUserId() != userId);
synchronized (mResourcesManager) {
WeakReference<LoadedApk> ref;
@@ -1932,13 +1932,13 @@
ref = mResourcePackages.get(packageName);
}
- LoadedApk loadedApk = ref != null ? ref.get() : null;
- //Slog.i(TAG, "getLoadedApkForPackageName " + packageName + ": " + loadedApk);
- //if (loadedApk != null) Slog.i(TAG, "isUptoDate " + loadedApk.mResDir
- // + ": " + loadedApk.mResources.getAssets().isUpToDate());
- if (loadedApk != null && (loadedApk.mResources == null
- || loadedApk.mResources.getAssets().isUpToDate())) {
- if (loadedApk.isSecurityViolation()
+ LoadedApk packageInfo = ref != null ? ref.get() : null;
+ //Slog.i(TAG, "getPackageInfo " + packageName + ": " + packageInfo);
+ //if (packageInfo != null) Slog.i(TAG, "isUptoDate " + packageInfo.mResDir
+ // + ": " + packageInfo.mResources.getAssets().isUpToDate());
+ if (packageInfo != null && (packageInfo.mResources == null
+ || packageInfo.mResources.getAssets().isUpToDate())) {
+ if (packageInfo.isSecurityViolation()
&& (flags&Context.CONTEXT_IGNORE_SECURITY) == 0) {
throw new SecurityException(
"Requesting code from " + packageName
@@ -1946,7 +1946,7 @@
+ mBoundApplication.processName
+ "/" + mBoundApplication.appInfo.uid);
}
- return loadedApk;
+ return packageInfo;
}
}
@@ -1961,13 +1961,13 @@
}
if (ai != null) {
- return getLoadedApk(ai, compatInfo, flags);
+ return getPackageInfo(ai, compatInfo, flags);
}
return null;
}
- public final LoadedApk getLoadedApk(ApplicationInfo ai, CompatibilityInfo compatInfo,
+ public final LoadedApk getPackageInfo(ApplicationInfo ai, CompatibilityInfo compatInfo,
int flags) {
boolean includeCode = (flags&Context.CONTEXT_INCLUDE_CODE) != 0;
boolean securityViolation = includeCode && ai.uid != 0
@@ -1989,17 +1989,17 @@
throw new SecurityException(msg);
}
}
- return getLoadedApk(ai, compatInfo, null, securityViolation, includeCode,
+ return getPackageInfo(ai, compatInfo, null, securityViolation, includeCode,
registerPackage);
}
@Override
- public final LoadedApk getLoadedApkNoCheck(ApplicationInfo ai,
+ public final LoadedApk getPackageInfoNoCheck(ApplicationInfo ai,
CompatibilityInfo compatInfo) {
- return getLoadedApk(ai, compatInfo, null, false, true, false);
+ return getPackageInfo(ai, compatInfo, null, false, true, false);
}
- public final LoadedApk peekLoadedApk(String packageName, boolean includeCode) {
+ public final LoadedApk peekPackageInfo(String packageName, boolean includeCode) {
synchronized (mResourcesManager) {
WeakReference<LoadedApk> ref;
if (includeCode) {
@@ -2011,7 +2011,7 @@
}
}
- private LoadedApk getLoadedApk(ApplicationInfo aInfo, CompatibilityInfo compatInfo,
+ private LoadedApk getPackageInfo(ApplicationInfo aInfo, CompatibilityInfo compatInfo,
ClassLoader baseLoader, boolean securityViolation, boolean includeCode,
boolean registerPackage) {
final boolean differentUser = (UserHandle.myUserId() != UserHandle.getUserId(aInfo.uid));
@@ -2026,35 +2026,35 @@
ref = mResourcePackages.get(aInfo.packageName);
}
- LoadedApk loadedApk = ref != null ? ref.get() : null;
- if (loadedApk == null || (loadedApk.mResources != null
- && !loadedApk.mResources.getAssets().isUpToDate())) {
+ LoadedApk packageInfo = ref != null ? ref.get() : null;
+ if (packageInfo == null || (packageInfo.mResources != null
+ && !packageInfo.mResources.getAssets().isUpToDate())) {
if (localLOGV) Slog.v(TAG, (includeCode ? "Loading code package "
: "Loading resource-only package ") + aInfo.packageName
+ " (in " + (mBoundApplication != null
? mBoundApplication.processName : null)
+ ")");
- loadedApk =
+ packageInfo =
new LoadedApk(this, aInfo, compatInfo, baseLoader,
securityViolation, includeCode &&
(aInfo.flags&ApplicationInfo.FLAG_HAS_CODE) != 0, registerPackage);
if (mSystemThread && "android".equals(aInfo.packageName)) {
- loadedApk.installSystemApplicationInfo(aInfo,
- getSystemContext().mLoadedApk.getClassLoader());
+ packageInfo.installSystemApplicationInfo(aInfo,
+ getSystemContext().mPackageInfo.getClassLoader());
}
if (differentUser) {
// Caching not supported across users
} else if (includeCode) {
mPackages.put(aInfo.packageName,
- new WeakReference<LoadedApk>(loadedApk));
+ new WeakReference<LoadedApk>(packageInfo));
} else {
mResourcePackages.put(aInfo.packageName,
- new WeakReference<LoadedApk>(loadedApk));
+ new WeakReference<LoadedApk>(packageInfo));
}
}
- return loadedApk;
+ return packageInfo;
}
}
@@ -2778,8 +2778,8 @@
/** Core implementation of activity launch. */
private Activity performLaunchActivity(ActivityClientRecord r) {
ActivityInfo aInfo = r.activityInfo;
- if (r.loadedApk == null) {
- r.loadedApk = getLoadedApk(aInfo.applicationInfo, r.compatInfo,
+ if (r.packageInfo == null) {
+ r.packageInfo = getPackageInfo(aInfo.applicationInfo, r.compatInfo,
Context.CONTEXT_INCLUDE_CODE);
}
@@ -2816,15 +2816,15 @@
}
try {
- Application app = r.loadedApk.makeApplication(false, mInstrumentation);
+ Application app = r.packageInfo.makeApplication(false, mInstrumentation);
if (localLOGV) Slog.v(TAG, "Performing launch of " + r);
if (localLOGV) Slog.v(
TAG, r + ": app=" + app
+ ", appName=" + app.getPackageName()
- + ", pkg=" + r.loadedApk.getPackageName()
+ + ", pkg=" + r.packageInfo.getPackageName()
+ ", comp=" + r.intent.getComponent().toShortString()
- + ", dir=" + r.loadedApk.getAppDir());
+ + ", dir=" + r.packageInfo.getAppDir());
if (activity != null) {
CharSequence title = r.activityInfo.loadLabel(appContext.getPackageManager());
@@ -2969,7 +2969,7 @@
}
ContextImpl appContext = ContextImpl.createActivityContext(
- this, r.loadedApk, r.activityInfo, r.token, displayId, r.overrideConfig);
+ this, r.packageInfo, r.activityInfo, r.token, displayId, r.overrideConfig);
final DisplayManagerGlobal dm = DisplayManagerGlobal.getInstance();
// For debugging purposes, if the activity's package name contains the value of
@@ -2977,7 +2977,7 @@
// its content on a secondary display if there is one.
String pkgName = SystemProperties.get("debug.second-display.pkg");
if (pkgName != null && !pkgName.isEmpty()
- && r.loadedApk.mPackageName.contains(pkgName)) {
+ && r.packageInfo.mPackageName.contains(pkgName)) {
for (int id : dm.getDisplayIds()) {
if (id != Display.DEFAULT_DISPLAY) {
Display display =
@@ -3309,7 +3309,7 @@
String component = data.intent.getComponent().getClassName();
- LoadedApk loadedApk = getLoadedApkNoCheck(
+ LoadedApk packageInfo = getPackageInfoNoCheck(
data.info.applicationInfo, data.compatInfo);
IActivityManager mgr = ActivityManager.getService();
@@ -3318,7 +3318,7 @@
BroadcastReceiver receiver;
ContextImpl context;
try {
- app = loadedApk.makeApplication(false, mInstrumentation);
+ app = packageInfo.makeApplication(false, mInstrumentation);
context = (ContextImpl) app.getBaseContext();
if (data.info.splitName != null) {
context = (ContextImpl) context.createContextForSplit(data.info.splitName);
@@ -3327,7 +3327,7 @@
data.intent.setExtrasClassLoader(cl);
data.intent.prepareToEnterProcess();
data.setExtrasClassLoader(cl);
- receiver = loadedApk.getAppFactory()
+ receiver = packageInfo.getAppFactory()
.instantiateReceiver(cl, data.info.name, data.intent);
} catch (Exception e) {
if (DEBUG_BROADCAST) Slog.i(TAG,
@@ -3343,9 +3343,9 @@
TAG, "Performing receive of " + data.intent
+ ": app=" + app
+ ", appName=" + app.getPackageName()
- + ", pkg=" + loadedApk.getPackageName()
+ + ", pkg=" + packageInfo.getPackageName()
+ ", comp=" + data.intent.getComponent().toShortString()
- + ", dir=" + loadedApk.getAppDir());
+ + ", dir=" + packageInfo.getAppDir());
sCurrentBroadcastIntent.set(data.intent);
receiver.setPendingResult(data);
@@ -3390,8 +3390,8 @@
unscheduleGcIdler();
// instantiate the BackupAgent class named in the manifest
- LoadedApk loadedApk = getLoadedApkNoCheck(data.appInfo, data.compatInfo);
- String packageName = loadedApk.mPackageName;
+ LoadedApk packageInfo = getPackageInfoNoCheck(data.appInfo, data.compatInfo);
+ String packageName = packageInfo.mPackageName;
if (packageName == null) {
Slog.d(TAG, "Asked to create backup agent for nonexistent package");
return;
@@ -3417,11 +3417,11 @@
try {
if (DEBUG_BACKUP) Slog.v(TAG, "Initializing agent class " + classname);
- java.lang.ClassLoader cl = loadedApk.getClassLoader();
+ java.lang.ClassLoader cl = packageInfo.getClassLoader();
agent = (BackupAgent) cl.loadClass(classname).newInstance();
// set up the agent's context
- ContextImpl context = ContextImpl.createAppContext(this, loadedApk);
+ ContextImpl context = ContextImpl.createAppContext(this, packageInfo);
context.setOuterContext(agent);
agent.attach(context);
@@ -3457,8 +3457,8 @@
private void handleDestroyBackupAgent(CreateBackupAgentData data) {
if (DEBUG_BACKUP) Slog.v(TAG, "handleDestroyBackupAgent: " + data);
- LoadedApk loadedApk = getLoadedApkNoCheck(data.appInfo, data.compatInfo);
- String packageName = loadedApk.mPackageName;
+ LoadedApk packageInfo = getPackageInfoNoCheck(data.appInfo, data.compatInfo);
+ String packageName = packageInfo.mPackageName;
BackupAgent agent = mBackupAgents.get(packageName);
if (agent != null) {
try {
@@ -3478,12 +3478,12 @@
// we are back active so skip it.
unscheduleGcIdler();
- LoadedApk loadedApk = getLoadedApkNoCheck(
+ LoadedApk packageInfo = getPackageInfoNoCheck(
data.info.applicationInfo, data.compatInfo);
Service service = null;
try {
- java.lang.ClassLoader cl = loadedApk.getClassLoader();
- service = loadedApk.getAppFactory()
+ java.lang.ClassLoader cl = packageInfo.getClassLoader();
+ service = packageInfo.getAppFactory()
.instantiateService(cl, data.info.name, data.intent);
} catch (Exception e) {
if (!mInstrumentation.onException(service, e)) {
@@ -3496,10 +3496,10 @@
try {
if (localLOGV) Slog.v(TAG, "Creating service " + data.info.name);
- ContextImpl context = ContextImpl.createAppContext(this, loadedApk);
+ ContextImpl context = ContextImpl.createAppContext(this, packageInfo);
context.setOuterContext(service);
- Application app = loadedApk.makeApplication(false, mInstrumentation);
+ Application app = packageInfo.makeApplication(false, mInstrumentation);
service.attach(context, this, data.info.name, data.token, app,
ActivityManager.getService());
service.onCreate();
@@ -4363,11 +4363,11 @@
}
private void handleUpdatePackageCompatibilityInfo(UpdateCompatibilityData data) {
- LoadedApk apk = peekLoadedApk(data.pkg, false);
+ LoadedApk apk = peekPackageInfo(data.pkg, false);
if (apk != null) {
apk.setCompatibilityInfo(data.info);
}
- apk = peekLoadedApk(data.pkg, true);
+ apk = peekPackageInfo(data.pkg, true);
if (apk != null) {
apk.setCompatibilityInfo(data.info);
}
@@ -4861,7 +4861,7 @@
if (a != null) {
Configuration thisConfig = applyConfigCompatMainThread(
mCurDefaultDisplayDpi, newConfig,
- ar.loadedApk.getCompatibilityInfo());
+ ar.packageInfo.getCompatibilityInfo());
if (!ar.activity.mFinished && (allActivities || !ar.paused)) {
// If the activity is currently resumed, its configuration
// needs to change right now.
@@ -5347,7 +5347,7 @@
}
final void handleDispatchPackageBroadcast(int cmd, String[] packages) {
- boolean hasLoadedApk = false;
+ boolean hasPkgInfo = false;
switch (cmd) {
case ApplicationThreadConstants.PACKAGE_REMOVED:
case ApplicationThreadConstants.PACKAGE_REMOVED_DONT_KILL:
@@ -5358,14 +5358,14 @@
}
synchronized (mResourcesManager) {
for (int i = packages.length - 1; i >= 0; i--) {
- if (!hasLoadedApk) {
+ if (!hasPkgInfo) {
WeakReference<LoadedApk> ref = mPackages.get(packages[i]);
if (ref != null && ref.get() != null) {
- hasLoadedApk = true;
+ hasPkgInfo = true;
} else {
ref = mResourcePackages.get(packages[i]);
if (ref != null && ref.get() != null) {
- hasLoadedApk = true;
+ hasPkgInfo = true;
}
}
}
@@ -5385,21 +5385,21 @@
synchronized (mResourcesManager) {
for (int i = packages.length - 1; i >= 0; i--) {
WeakReference<LoadedApk> ref = mPackages.get(packages[i]);
- LoadedApk loadedApk = ref != null ? ref.get() : null;
- if (loadedApk != null) {
- hasLoadedApk = true;
+ LoadedApk pkgInfo = ref != null ? ref.get() : null;
+ if (pkgInfo != null) {
+ hasPkgInfo = true;
} else {
ref = mResourcePackages.get(packages[i]);
- loadedApk = ref != null ? ref.get() : null;
- if (loadedApk != null) {
- hasLoadedApk = true;
+ pkgInfo = ref != null ? ref.get() : null;
+ if (pkgInfo != null) {
+ hasPkgInfo = true;
}
}
// If the package is being replaced, yet it still has a valid
// LoadedApk object, the package was updated with _DONT_KILL.
// Adjust it's internal references to the application info and
// resources.
- if (loadedApk != null) {
+ if (pkgInfo != null) {
try {
final String packageName = packages[i];
final ApplicationInfo aInfo =
@@ -5413,13 +5413,13 @@
if (ar.activityInfo.applicationInfo.packageName
.equals(packageName)) {
ar.activityInfo.applicationInfo = aInfo;
- ar.loadedApk = loadedApk;
+ ar.packageInfo = pkgInfo;
}
}
}
final List<String> oldPaths =
sPackageManager.getPreviousCodePaths(packageName);
- loadedApk.updateApplicationInfo(aInfo, oldPaths);
+ pkgInfo.updateApplicationInfo(aInfo, oldPaths);
} catch (RemoteException e) {
}
}
@@ -5428,7 +5428,7 @@
break;
}
}
- ApplicationPackageManager.handlePackageBroadcast(cmd, packages, hasLoadedApk);
+ ApplicationPackageManager.handlePackageBroadcast(cmd, packages, hasPkgInfo);
}
final void handleLowMemory() {
@@ -5636,10 +5636,10 @@
applyCompatConfiguration(mCurDefaultDisplayDpi);
}
- data.loadedApk = getLoadedApkNoCheck(data.appInfo, data.compatInfo);
+ data.info = getPackageInfoNoCheck(data.appInfo, data.compatInfo);
if (agent != null) {
- handleAttachAgent(agent, data.loadedApk);
+ handleAttachAgent(agent, data.info);
}
/**
@@ -5684,7 +5684,7 @@
// XXX should have option to change the port.
Debug.changeDebugPort(8100);
if (data.debugMode == ApplicationThreadConstants.DEBUG_WAIT) {
- Slog.w(TAG, "Application " + data.loadedApk.getPackageName()
+ Slog.w(TAG, "Application " + data.info.getPackageName()
+ " is waiting for the debugger on port 8100...");
IActivityManager mgr = ActivityManager.getService();
@@ -5703,7 +5703,7 @@
}
} else {
- Slog.w(TAG, "Application " + data.loadedApk.getPackageName()
+ Slog.w(TAG, "Application " + data.info.getPackageName()
+ " can be debugged on port 8100...");
}
}
@@ -5751,14 +5751,14 @@
mInstrumentationAppDir = ii.sourceDir;
mInstrumentationSplitAppDirs = ii.splitSourceDirs;
mInstrumentationLibDir = getInstrumentationLibrary(data.appInfo, ii);
- mInstrumentedAppDir = data.loadedApk.getAppDir();
- mInstrumentedSplitAppDirs = data.loadedApk.getSplitAppDirs();
- mInstrumentedLibDir = data.loadedApk.getLibDir();
+ mInstrumentedAppDir = data.info.getAppDir();
+ mInstrumentedSplitAppDirs = data.info.getSplitAppDirs();
+ mInstrumentedLibDir = data.info.getLibDir();
} else {
ii = null;
}
- final ContextImpl appContext = ContextImpl.createAppContext(this, data.loadedApk);
+ final ContextImpl appContext = ContextImpl.createAppContext(this, data.info);
updateLocaleListFromAppContext(appContext,
mResourcesManager.getConfiguration().getLocales());
@@ -5802,9 +5802,9 @@
}
ii.copyTo(instrApp);
instrApp.initForUser(UserHandle.myUserId());
- final LoadedApk loadedApk = getLoadedApk(instrApp, data.compatInfo,
+ final LoadedApk pi = getPackageInfo(instrApp, data.compatInfo,
appContext.getClassLoader(), false, true, false);
- final ContextImpl instrContext = ContextImpl.createAppContext(this, loadedApk);
+ final ContextImpl instrContext = ContextImpl.createAppContext(this, pi);
try {
final ClassLoader cl = instrContext.getClassLoader();
@@ -5849,7 +5849,7 @@
try {
// If the app is being launched for full backup or restore, bring it up in
// a restricted environment with the base application class.
- app = data.loadedApk.makeApplication(data.restrictedBackupMode, null);
+ app = data.info.makeApplication(data.restrictedBackupMode, null);
mInitialApplication = app;
// don't bring up providers in restricted mode; they may depend on the
@@ -5903,7 +5903,7 @@
final int preloadedFontsResource = info.metaData.getInt(
ApplicationInfo.METADATA_PRELOADED_FONTS, 0);
if (preloadedFontsResource != 0) {
- data.loadedApk.getResources().preloadFonts(preloadedFontsResource);
+ data.info.getResources().preloadFonts(preloadedFontsResource);
}
}
} catch (RemoteException e) {
@@ -6361,12 +6361,12 @@
try {
final java.lang.ClassLoader cl = c.getClassLoader();
- LoadedApk loadedApk = peekLoadedApk(ai.packageName, true);
- if (loadedApk == null) {
+ LoadedApk packageInfo = peekPackageInfo(ai.packageName, true);
+ if (packageInfo == null) {
// System startup case.
- loadedApk = getSystemContext().mLoadedApk;
+ packageInfo = getSystemContext().mPackageInfo;
}
- localProvider = loadedApk.getAppFactory()
+ localProvider = packageInfo.getAppFactory()
.instantiateProvider(cl, info.name);
provider = localProvider.getIContentProvider();
if (provider == null) {
@@ -6515,8 +6515,8 @@
mInstrumentation = new Instrumentation();
mInstrumentation.basicInit(this);
ContextImpl context = ContextImpl.createAppContext(
- this, getSystemContext().mLoadedApk);
- mInitialApplication = context.mLoadedApk.makeApplication(true, null);
+ this, getSystemContext().mPackageInfo);
+ mInitialApplication = context.mPackageInfo.makeApplication(true, null);
mInitialApplication.onCreate();
} catch (Exception e) {
throw new RuntimeException(
diff --git a/core/java/android/app/Application.java b/core/java/android/app/Application.java
index 5a739ea..a13ac49 100644
--- a/core/java/android/app/Application.java
+++ b/core/java/android/app/Application.java
@@ -197,7 +197,7 @@
*/
/* package */ final void attach(Context context) {
attachBaseContext(context);
- mLoadedApk = ContextImpl.getImpl(context).mLoadedApk;
+ mLoadedApk = ContextImpl.getImpl(context).mPackageInfo;
}
/* package */ void dispatchActivityCreated(Activity activity, Bundle savedInstanceState) {
diff --git a/core/java/android/app/ApplicationPackageManager.java b/core/java/android/app/ApplicationPackageManager.java
index cc68c05..6b0a2f9 100644
--- a/core/java/android/app/ApplicationPackageManager.java
+++ b/core/java/android/app/ApplicationPackageManager.java
@@ -1409,7 +1409,7 @@
sameUid ? app.sourceDir : app.publicSourceDir,
sameUid ? app.splitSourceDirs : app.splitPublicSourceDirs,
app.resourceDirs, app.sharedLibraryFiles, Display.DEFAULT_DISPLAY,
- mContext.mLoadedApk);
+ mContext.mPackageInfo);
if (r != null) {
return r;
}
diff --git a/core/java/android/app/ClientTransactionHandler.java b/core/java/android/app/ClientTransactionHandler.java
index 0f66652..5b61fdf 100644
--- a/core/java/android/app/ClientTransactionHandler.java
+++ b/core/java/android/app/ClientTransactionHandler.java
@@ -111,7 +111,7 @@
PendingTransactionActions pendingActions);
/** Get package info. */
- public abstract LoadedApk getLoadedApkNoCheck(ApplicationInfo ai,
+ public abstract LoadedApk getPackageInfoNoCheck(ApplicationInfo ai,
CompatibilityInfo compatInfo);
/** Deliver app configuration change notification. */
diff --git a/core/java/android/app/ContextImpl.java b/core/java/android/app/ContextImpl.java
index ea94042..6496110 100644
--- a/core/java/android/app/ContextImpl.java
+++ b/core/java/android/app/ContextImpl.java
@@ -159,7 +159,7 @@
private ArrayMap<String, File> mSharedPrefsPaths;
final @NonNull ActivityThread mMainThread;
- final @NonNull LoadedApk mLoadedApk;
+ final @NonNull LoadedApk mPackageInfo;
private @Nullable ClassLoader mClassLoader;
private final @Nullable IBinder mActivityToken;
@@ -257,8 +257,8 @@
@Override
public Context getApplicationContext() {
- return (mLoadedApk != null) ?
- mLoadedApk.getApplication() : mMainThread.getApplication();
+ return (mPackageInfo != null) ?
+ mPackageInfo.getApplication() : mMainThread.getApplication();
}
@Override
@@ -302,15 +302,15 @@
@Override
public ClassLoader getClassLoader() {
- return mClassLoader != null ? mClassLoader : (mLoadedApk != null ? mLoadedApk.getClassLoader() : ClassLoader.getSystemClassLoader());
+ return mClassLoader != null ? mClassLoader : (mPackageInfo != null ? mPackageInfo.getClassLoader() : ClassLoader.getSystemClassLoader());
}
@Override
public String getPackageName() {
- if (mLoadedApk != null) {
- return mLoadedApk.getPackageName();
+ if (mPackageInfo != null) {
+ return mPackageInfo.getPackageName();
}
- // No mLoadedApk means this is a Context for the system itself,
+ // No mPackageInfo means this is a Context for the system itself,
// and this here is its name.
return "android";
}
@@ -329,24 +329,24 @@
@Override
public ApplicationInfo getApplicationInfo() {
- if (mLoadedApk != null) {
- return mLoadedApk.getApplicationInfo();
+ if (mPackageInfo != null) {
+ return mPackageInfo.getApplicationInfo();
}
throw new RuntimeException("Not supported in system context");
}
@Override
public String getPackageResourcePath() {
- if (mLoadedApk != null) {
- return mLoadedApk.getResDir();
+ if (mPackageInfo != null) {
+ return mPackageInfo.getResDir();
}
throw new RuntimeException("Not supported in system context");
}
@Override
public String getPackageCodePath() {
- if (mLoadedApk != null) {
- return mLoadedApk.getAppDir();
+ if (mPackageInfo != null) {
+ return mPackageInfo.getAppDir();
}
throw new RuntimeException("Not supported in system context");
}
@@ -356,7 +356,7 @@
// At least one application in the world actually passes in a null
// name. This happened to work because when we generated the file name
// we would stringify it to "null.xml". Nice.
- if (mLoadedApk.getApplicationInfo().targetSdkVersion <
+ if (mPackageInfo.getApplicationInfo().targetSdkVersion <
Build.VERSION_CODES.KITKAT) {
if (name == null) {
name = "null";
@@ -1104,11 +1104,11 @@
warnIfCallingFromSystemProcess();
IIntentReceiver rd = null;
if (resultReceiver != null) {
- if (mLoadedApk != null) {
+ if (mPackageInfo != null) {
if (scheduler == null) {
scheduler = mMainThread.getHandler();
}
- rd = mLoadedApk.getReceiverDispatcher(
+ rd = mPackageInfo.getReceiverDispatcher(
resultReceiver, getOuterContext(), scheduler,
mMainThread.getInstrumentation(), false);
} else {
@@ -1208,11 +1208,11 @@
Handler scheduler, int initialCode, String initialData, Bundle initialExtras) {
IIntentReceiver rd = null;
if (resultReceiver != null) {
- if (mLoadedApk != null) {
+ if (mPackageInfo != null) {
if (scheduler == null) {
scheduler = mMainThread.getHandler();
}
- rd = mLoadedApk.getReceiverDispatcher(
+ rd = mPackageInfo.getReceiverDispatcher(
resultReceiver, getOuterContext(), scheduler,
mMainThread.getInstrumentation(), false);
} else {
@@ -1262,11 +1262,11 @@
warnIfCallingFromSystemProcess();
IIntentReceiver rd = null;
if (resultReceiver != null) {
- if (mLoadedApk != null) {
+ if (mPackageInfo != null) {
if (scheduler == null) {
scheduler = mMainThread.getHandler();
}
- rd = mLoadedApk.getReceiverDispatcher(
+ rd = mPackageInfo.getReceiverDispatcher(
resultReceiver, getOuterContext(), scheduler,
mMainThread.getInstrumentation(), false);
} else {
@@ -1344,11 +1344,11 @@
Bundle initialExtras) {
IIntentReceiver rd = null;
if (resultReceiver != null) {
- if (mLoadedApk != null) {
+ if (mPackageInfo != null) {
if (scheduler == null) {
scheduler = mMainThread.getHandler();
}
- rd = mLoadedApk.getReceiverDispatcher(
+ rd = mPackageInfo.getReceiverDispatcher(
resultReceiver, getOuterContext(), scheduler,
mMainThread.getInstrumentation(), false);
} else {
@@ -1425,11 +1425,11 @@
Handler scheduler, Context context, int flags) {
IIntentReceiver rd = null;
if (receiver != null) {
- if (mLoadedApk != null && context != null) {
+ if (mPackageInfo != null && context != null) {
if (scheduler == null) {
scheduler = mMainThread.getHandler();
}
- rd = mLoadedApk.getReceiverDispatcher(
+ rd = mPackageInfo.getReceiverDispatcher(
receiver, context, scheduler,
mMainThread.getInstrumentation(), true);
} else {
@@ -1456,8 +1456,8 @@
@Override
public void unregisterReceiver(BroadcastReceiver receiver) {
- if (mLoadedApk != null) {
- IIntentReceiver rd = mLoadedApk.forgetReceiverDispatcher(
+ if (mPackageInfo != null) {
+ IIntentReceiver rd = mPackageInfo.forgetReceiverDispatcher(
getOuterContext(), receiver);
try {
ActivityManager.getService().unregisterReceiver(rd);
@@ -1590,7 +1590,7 @@
@Override
public IServiceConnection getServiceDispatcher(ServiceConnection conn, Handler handler,
int flags) {
- return mLoadedApk.getServiceDispatcher(conn, getOuterContext(), handler, flags);
+ return mPackageInfo.getServiceDispatcher(conn, getOuterContext(), handler, flags);
}
/** @hide */
@@ -1612,16 +1612,16 @@
if (conn == null) {
throw new IllegalArgumentException("connection is null");
}
- if (mLoadedApk != null) {
- sd = mLoadedApk.getServiceDispatcher(conn, getOuterContext(), handler, flags);
+ if (mPackageInfo != null) {
+ sd = mPackageInfo.getServiceDispatcher(conn, getOuterContext(), handler, flags);
} else {
throw new RuntimeException("Not supported in system context");
}
validateServiceIntent(service);
try {
IBinder token = getActivityToken();
- if (token == null && (flags&BIND_AUTO_CREATE) == 0 && mLoadedApk != null
- && mLoadedApk.getApplicationInfo().targetSdkVersion
+ if (token == null && (flags&BIND_AUTO_CREATE) == 0 && mPackageInfo != null
+ && mPackageInfo.getApplicationInfo().targetSdkVersion
< android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
flags |= BIND_WAIVE_PRIORITY;
}
@@ -1645,8 +1645,8 @@
if (conn == null) {
throw new IllegalArgumentException("connection is null");
}
- if (mLoadedApk != null) {
- IServiceConnection sd = mLoadedApk.forgetServiceDispatcher(
+ if (mPackageInfo != null) {
+ IServiceConnection sd = mPackageInfo.forgetServiceDispatcher(
getOuterContext(), conn);
try {
ActivityManager.getService().unbindService(sd);
@@ -1991,20 +1991,40 @@
}
}
+ private static Resources createResources(IBinder activityToken, LoadedApk pi, String splitName,
+ int displayId, Configuration overrideConfig, CompatibilityInfo compatInfo) {
+ final String[] splitResDirs;
+ final ClassLoader classLoader;
+ try {
+ splitResDirs = pi.getSplitPaths(splitName);
+ classLoader = pi.getSplitClassLoader(splitName);
+ } catch (NameNotFoundException e) {
+ throw new RuntimeException(e);
+ }
+ return ResourcesManager.getInstance().getResources(activityToken,
+ pi.getResDir(),
+ splitResDirs,
+ pi.getOverlayDirs(),
+ pi.getApplicationInfo().sharedLibraryFiles,
+ displayId,
+ overrideConfig,
+ compatInfo,
+ classLoader);
+ }
+
@Override
public Context createApplicationContext(ApplicationInfo application, int flags)
throws NameNotFoundException {
- LoadedApk loadedApk = mMainThread.getLoadedApk(application,
- mResources.getCompatibilityInfo(),
+ LoadedApk pi = mMainThread.getPackageInfo(application, mResources.getCompatibilityInfo(),
flags | CONTEXT_REGISTER_PACKAGE);
- if (loadedApk != null) {
- ContextImpl c = new ContextImpl(this, mMainThread, loadedApk, null, mActivityToken,
+ if (pi != null) {
+ ContextImpl c = new ContextImpl(this, mMainThread, pi, null, mActivityToken,
new UserHandle(UserHandle.getUserId(application.uid)), flags, null);
final int displayId = mDisplay != null
? mDisplay.getDisplayId() : Display.DEFAULT_DISPLAY;
- c.setResources(loadedApk.createResources(mActivityToken, null, displayId, null,
+ c.setResources(createResources(mActivityToken, pi, null, displayId, null,
getDisplayAdjustments(displayId).getCompatibilityInfo()));
if (c.mResources != null) {
return c;
@@ -2028,21 +2048,20 @@
if (packageName.equals("system") || packageName.equals("android")) {
// The system resources are loaded in every application, so we can safely copy
// the context without reloading Resources.
- return new ContextImpl(this, mMainThread, mLoadedApk, null, mActivityToken, user,
+ return new ContextImpl(this, mMainThread, mPackageInfo, null, mActivityToken, user,
flags, null);
}
- LoadedApk loadedApk = mMainThread.getLoadedApkForPackageName(packageName,
- mResources.getCompatibilityInfo(),
+ LoadedApk pi = mMainThread.getPackageInfo(packageName, mResources.getCompatibilityInfo(),
flags | CONTEXT_REGISTER_PACKAGE, user.getIdentifier());
- if (loadedApk != null) {
- ContextImpl c = new ContextImpl(this, mMainThread, loadedApk, null, mActivityToken, user,
+ if (pi != null) {
+ ContextImpl c = new ContextImpl(this, mMainThread, pi, null, mActivityToken, user,
flags, null);
final int displayId = mDisplay != null
? mDisplay.getDisplayId() : Display.DEFAULT_DISPLAY;
- c.setResources(loadedApk.createResources(mActivityToken, null, displayId, null,
+ c.setResources(createResources(mActivityToken, pi, null, displayId, null,
getDisplayAdjustments(displayId).getCompatibilityInfo()));
if (c.mResources != null) {
return c;
@@ -2056,21 +2075,30 @@
@Override
public Context createContextForSplit(String splitName) throws NameNotFoundException {
- if (!mLoadedApk.getApplicationInfo().requestsIsolatedSplitLoading()) {
+ if (!mPackageInfo.getApplicationInfo().requestsIsolatedSplitLoading()) {
// All Splits are always loaded.
return this;
}
- final ClassLoader classLoader = mLoadedApk.getSplitClassLoader(splitName);
+ final ClassLoader classLoader = mPackageInfo.getSplitClassLoader(splitName);
+ final String[] paths = mPackageInfo.getSplitPaths(splitName);
- final ContextImpl context = new ContextImpl(this, mMainThread, mLoadedApk, splitName,
+ final ContextImpl context = new ContextImpl(this, mMainThread, mPackageInfo, splitName,
mActivityToken, mUser, mFlags, classLoader);
final int displayId = mDisplay != null
? mDisplay.getDisplayId() : Display.DEFAULT_DISPLAY;
- context.setResources(mLoadedApk.getOrCreateResourcesForSplit(splitName,
- mActivityToken, displayId));
+ context.setResources(ResourcesManager.getInstance().getResources(
+ mActivityToken,
+ mPackageInfo.getResDir(),
+ paths,
+ mPackageInfo.getOverlayDirs(),
+ mPackageInfo.getApplicationInfo().sharedLibraryFiles,
+ displayId,
+ null,
+ mPackageInfo.getCompatibilityInfo(),
+ classLoader));
return context;
}
@@ -2080,11 +2108,11 @@
throw new IllegalArgumentException("overrideConfiguration must not be null");
}
- ContextImpl context = new ContextImpl(this, mMainThread, mLoadedApk, mSplitName,
+ ContextImpl context = new ContextImpl(this, mMainThread, mPackageInfo, mSplitName,
mActivityToken, mUser, mFlags, mClassLoader);
final int displayId = mDisplay != null ? mDisplay.getDisplayId() : Display.DEFAULT_DISPLAY;
- context.setResources(mLoadedApk.createResources(mActivityToken, mSplitName, displayId,
+ context.setResources(createResources(mActivityToken, mPackageInfo, mSplitName, displayId,
overrideConfiguration, getDisplayAdjustments(displayId).getCompatibilityInfo()));
return context;
}
@@ -2095,11 +2123,11 @@
throw new IllegalArgumentException("display must not be null");
}
- ContextImpl context = new ContextImpl(this, mMainThread, mLoadedApk, mSplitName,
+ ContextImpl context = new ContextImpl(this, mMainThread, mPackageInfo, mSplitName,
mActivityToken, mUser, mFlags, mClassLoader);
final int displayId = display.getDisplayId();
- context.setResources(mLoadedApk.createResources(mActivityToken, mSplitName, displayId,
+ context.setResources(createResources(mActivityToken, mPackageInfo, mSplitName, displayId,
null, getDisplayAdjustments(displayId).getCompatibilityInfo()));
context.mDisplay = display;
return context;
@@ -2109,7 +2137,7 @@
public Context createDeviceProtectedStorageContext() {
final int flags = (mFlags & ~Context.CONTEXT_CREDENTIAL_PROTECTED_STORAGE)
| Context.CONTEXT_DEVICE_PROTECTED_STORAGE;
- return new ContextImpl(this, mMainThread, mLoadedApk, mSplitName, mActivityToken, mUser,
+ return new ContextImpl(this, mMainThread, mPackageInfo, mSplitName, mActivityToken, mUser,
flags, mClassLoader);
}
@@ -2117,7 +2145,7 @@
public Context createCredentialProtectedStorageContext() {
final int flags = (mFlags & ~Context.CONTEXT_DEVICE_PROTECTED_STORAGE)
| Context.CONTEXT_CREDENTIAL_PROTECTED_STORAGE;
- return new ContextImpl(this, mMainThread, mLoadedApk, mSplitName, mActivityToken, mUser,
+ return new ContextImpl(this, mMainThread, mPackageInfo, mSplitName, mActivityToken, mUser,
flags, mClassLoader);
}
@@ -2166,14 +2194,14 @@
@Override
public File getDataDir() {
- if (mLoadedApk != null) {
+ if (mPackageInfo != null) {
File res = null;
if (isCredentialProtectedStorage()) {
- res = mLoadedApk.getCredentialProtectedDataDirFile();
+ res = mPackageInfo.getCredentialProtectedDataDirFile();
} else if (isDeviceProtectedStorage()) {
- res = mLoadedApk.getDeviceProtectedDataDirFile();
+ res = mPackageInfo.getDeviceProtectedDataDirFile();
} else {
- res = mLoadedApk.getDataDirFile();
+ res = mPackageInfo.getDataDirFile();
}
if (res != null) {
@@ -2224,10 +2252,10 @@
}
static ContextImpl createSystemContext(ActivityThread mainThread) {
- LoadedApk loadedApk = new LoadedApk(mainThread);
- ContextImpl context = new ContextImpl(null, mainThread, loadedApk, null, null, null, 0,
+ LoadedApk packageInfo = new LoadedApk(mainThread);
+ ContextImpl context = new ContextImpl(null, mainThread, packageInfo, null, null, null, 0,
null);
- context.setResources(loadedApk.getResources());
+ context.setResources(packageInfo.getResources());
context.mResources.updateConfiguration(context.mResourcesManager.getConfiguration(),
context.mResourcesManager.getDisplayMetrics());
return context;
@@ -2238,35 +2266,35 @@
* Make sure that the created system UI context shares the same LoadedApk as the system context.
*/
static ContextImpl createSystemUiContext(ContextImpl systemContext) {
- final LoadedApk loadedApk = systemContext.mLoadedApk;
- ContextImpl context = new ContextImpl(null, systemContext.mMainThread, loadedApk, null,
+ final LoadedApk packageInfo = systemContext.mPackageInfo;
+ ContextImpl context = new ContextImpl(null, systemContext.mMainThread, packageInfo, null,
null, null, 0, null);
- context.setResources(loadedApk.createResources(null, null, Display.DEFAULT_DISPLAY, null,
- loadedApk.getCompatibilityInfo()));
+ context.setResources(createResources(null, packageInfo, null, Display.DEFAULT_DISPLAY, null,
+ packageInfo.getCompatibilityInfo()));
return context;
}
- static ContextImpl createAppContext(ActivityThread mainThread, LoadedApk loadedApk) {
- if (loadedApk == null) throw new IllegalArgumentException("loadedApk");
- ContextImpl context = new ContextImpl(null, mainThread, loadedApk, null, null, null, 0,
+ static ContextImpl createAppContext(ActivityThread mainThread, LoadedApk packageInfo) {
+ if (packageInfo == null) throw new IllegalArgumentException("packageInfo");
+ ContextImpl context = new ContextImpl(null, mainThread, packageInfo, null, null, null, 0,
null);
- context.setResources(loadedApk.getResources());
+ context.setResources(packageInfo.getResources());
return context;
}
static ContextImpl createActivityContext(ActivityThread mainThread,
- LoadedApk loadedApk, ActivityInfo activityInfo, IBinder activityToken, int displayId,
+ LoadedApk packageInfo, ActivityInfo activityInfo, IBinder activityToken, int displayId,
Configuration overrideConfiguration) {
- if (loadedApk == null) throw new IllegalArgumentException("loadedApk");
+ if (packageInfo == null) throw new IllegalArgumentException("packageInfo");
- String[] splitDirs = loadedApk.getSplitResDirs();
- ClassLoader classLoader = loadedApk.getClassLoader();
+ String[] splitDirs = packageInfo.getSplitResDirs();
+ ClassLoader classLoader = packageInfo.getClassLoader();
- if (loadedApk.getApplicationInfo().requestsIsolatedSplitLoading()) {
+ if (packageInfo.getApplicationInfo().requestsIsolatedSplitLoading()) {
Trace.traceBegin(Trace.TRACE_TAG_RESOURCES, "SplitDependencies");
try {
- classLoader = loadedApk.getSplitClassLoader(activityInfo.splitName);
- splitDirs = loadedApk.getSplitPaths(activityInfo.splitName);
+ classLoader = packageInfo.getSplitClassLoader(activityInfo.splitName);
+ splitDirs = packageInfo.getSplitPaths(activityInfo.splitName);
} catch (NameNotFoundException e) {
// Nothing above us can handle a NameNotFoundException, better crash.
throw new RuntimeException(e);
@@ -2275,14 +2303,14 @@
}
}
- ContextImpl context = new ContextImpl(null, mainThread, loadedApk, activityInfo.splitName,
+ ContextImpl context = new ContextImpl(null, mainThread, packageInfo, activityInfo.splitName,
activityToken, null, 0, classLoader);
// Clamp display ID to DEFAULT_DISPLAY if it is INVALID_DISPLAY.
displayId = (displayId != Display.INVALID_DISPLAY) ? displayId : Display.DEFAULT_DISPLAY;
final CompatibilityInfo compatInfo = (displayId == Display.DEFAULT_DISPLAY)
- ? loadedApk.getCompatibilityInfo()
+ ? packageInfo.getCompatibilityInfo()
: CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO;
final ResourcesManager resourcesManager = ResourcesManager.getInstance();
@@ -2290,10 +2318,10 @@
// Create the base resources for which all configuration contexts for this Activity
// will be rebased upon.
context.setResources(resourcesManager.createBaseActivityResources(activityToken,
- loadedApk.getResDir(),
+ packageInfo.getResDir(),
splitDirs,
- loadedApk.getOverlayDirs(),
- loadedApk.getApplicationInfo().sharedLibraryFiles,
+ packageInfo.getOverlayDirs(),
+ packageInfo.getApplicationInfo().sharedLibraryFiles,
displayId,
overrideConfiguration,
compatInfo,
@@ -2304,7 +2332,7 @@
}
private ContextImpl(@Nullable ContextImpl container, @NonNull ActivityThread mainThread,
- @NonNull LoadedApk loadedApk, @Nullable String splitName,
+ @NonNull LoadedApk packageInfo, @Nullable String splitName,
@Nullable IBinder activityToken, @Nullable UserHandle user, int flags,
@Nullable ClassLoader classLoader) {
mOuterContext = this;
@@ -2313,10 +2341,10 @@
// location for application.
if ((flags & (Context.CONTEXT_CREDENTIAL_PROTECTED_STORAGE
| Context.CONTEXT_DEVICE_PROTECTED_STORAGE)) == 0) {
- final File dataDir = loadedApk.getDataDirFile();
- if (Objects.equals(dataDir, loadedApk.getCredentialProtectedDataDirFile())) {
+ final File dataDir = packageInfo.getDataDirFile();
+ if (Objects.equals(dataDir, packageInfo.getCredentialProtectedDataDirFile())) {
flags |= Context.CONTEXT_CREDENTIAL_PROTECTED_STORAGE;
- } else if (Objects.equals(dataDir, loadedApk.getDeviceProtectedDataDirFile())) {
+ } else if (Objects.equals(dataDir, packageInfo.getDeviceProtectedDataDirFile())) {
flags |= Context.CONTEXT_DEVICE_PROTECTED_STORAGE;
}
}
@@ -2330,7 +2358,7 @@
}
mUser = user;
- mLoadedApk = loadedApk;
+ mPackageInfo = packageInfo;
mSplitName = splitName;
mClassLoader = classLoader;
mResourcesManager = ResourcesManager.getInstance();
@@ -2341,8 +2369,8 @@
setResources(container.mResources);
mDisplay = container.mDisplay;
} else {
- mBasePackageName = loadedApk.mPackageName;
- ApplicationInfo ainfo = loadedApk.getApplicationInfo();
+ mBasePackageName = packageInfo.mPackageName;
+ ApplicationInfo ainfo = packageInfo.getApplicationInfo();
if (ainfo.uid == Process.SYSTEM_UID && ainfo.uid != Process.myUid()) {
// Special case: system components allow themselves to be loaded in to other
// processes. For purposes of app ops, we must then consider the context as
@@ -2365,7 +2393,7 @@
}
void installSystemApplicationInfo(ApplicationInfo info, ClassLoader classLoader) {
- mLoadedApk.installSystemApplicationInfo(info, classLoader);
+ mPackageInfo.installSystemApplicationInfo(info, classLoader);
}
final void scheduleFinalCleanup(String who, String what) {
@@ -2374,7 +2402,7 @@
final void performFinalCleanup(String who, String what) {
//Log.i(TAG, "Cleanup up context: " + this);
- mLoadedApk.removeContextRegistrations(getOuterContext(), who, what);
+ mPackageInfo.removeContextRegistrations(getOuterContext(), who, what);
}
final Context getReceiverRestrictedContext() {
diff --git a/core/java/android/app/Instrumentation.java b/core/java/android/app/Instrumentation.java
index 198bce6..67f5a2e 100644
--- a/core/java/android/app/Instrumentation.java
+++ b/core/java/android/app/Instrumentation.java
@@ -1216,10 +1216,10 @@
+ " disabling AppComponentFactory", new Throwable());
return AppComponentFactory.DEFAULT;
}
- LoadedApk loadedApk = mThread.peekLoadedApk(pkg, true);
+ LoadedApk apk = mThread.peekPackageInfo(pkg, true);
// This is in the case of starting up "android".
- if (loadedApk == null) loadedApk = mThread.getSystemContext().mLoadedApk;
- return loadedApk.getAppFactory();
+ if (apk == null) apk = mThread.getSystemContext().mPackageInfo;
+ return apk.getAppFactory();
}
private void prePerformCreate(Activity activity) {
diff --git a/core/java/android/app/LoadedApk.java b/core/java/android/app/LoadedApk.java
index d24d4f3..ea5932c 100644
--- a/core/java/android/app/LoadedApk.java
+++ b/core/java/android/app/LoadedApk.java
@@ -32,7 +32,6 @@
import android.content.pm.split.SplitDependencyLoader;
import android.content.res.AssetManager;
import android.content.res.CompatibilityInfo;
-import android.content.res.Configuration;
import android.content.res.Resources;
import android.os.Build;
import android.os.Bundle;
@@ -964,78 +963,14 @@
throw new AssertionError("null split not found");
}
- mResources = ResourcesManager.getInstance().getResources(
- null,
- mResDir,
- splitPaths,
- mOverlayDirs,
- mApplicationInfo.sharedLibraryFiles,
- Display.DEFAULT_DISPLAY,
- null,
- getCompatibilityInfo(),
+ mResources = ResourcesManager.getInstance().getResources(null, mResDir,
+ splitPaths, mOverlayDirs, mApplicationInfo.sharedLibraryFiles,
+ Display.DEFAULT_DISPLAY, null, getCompatibilityInfo(),
getClassLoader());
}
return mResources;
}
- public Resources getOrCreateResourcesForSplit(@NonNull String splitName,
- @Nullable IBinder activityToken, int displayId) throws NameNotFoundException {
- return ResourcesManager.getInstance().getResources(
- activityToken,
- mResDir,
- getSplitPaths(splitName),
- mOverlayDirs,
- mApplicationInfo.sharedLibraryFiles,
- displayId,
- null,
- getCompatibilityInfo(),
- getSplitClassLoader(splitName));
- }
-
- /**
- * Creates the top level resources for the given package. Will return an existing
- * Resources if one has already been created.
- */
- public Resources getOrCreateTopLevelResources(@NonNull ApplicationInfo appInfo) {
- // Request for this app, short circuit
- if (appInfo.uid == Process.myUid()) {
- return getResources();
- }
-
- // Get resources for a different package
- return ResourcesManager.getInstance().getResources(
- null,
- appInfo.publicSourceDir,
- appInfo.splitPublicSourceDirs,
- appInfo.resourceDirs,
- appInfo.sharedLibraryFiles,
- Display.DEFAULT_DISPLAY,
- null,
- getCompatibilityInfo(),
- getClassLoader());
- }
-
- public Resources createResources(IBinder activityToken, String splitName,
- int displayId, Configuration overrideConfig, CompatibilityInfo compatInfo) {
- final String[] splitResDirs;
- final ClassLoader classLoader;
- try {
- splitResDirs = getSplitPaths(splitName);
- classLoader = getSplitClassLoader(splitName);
- } catch (NameNotFoundException e) {
- throw new RuntimeException(e);
- }
- return ResourcesManager.getInstance().getResources(activityToken,
- mResDir,
- splitResDirs,
- mOverlayDirs,
- mApplicationInfo.sharedLibraryFiles,
- displayId,
- overrideConfig,
- compatInfo,
- classLoader);
- }
-
public Application makeApplication(boolean forceDefaultAppClass,
Instrumentation instrumentation) {
if (mApplication != null) {
diff --git a/core/java/android/app/servertransaction/PendingTransactionActions.java b/core/java/android/app/servertransaction/PendingTransactionActions.java
index 8304c1c..073d28c 100644
--- a/core/java/android/app/servertransaction/PendingTransactionActions.java
+++ b/core/java/android/app/servertransaction/PendingTransactionActions.java
@@ -134,7 +134,7 @@
Bundle.dumpStats(pw, mPersistentState);
if (ex instanceof TransactionTooLargeException
- && mActivity.loadedApk.getTargetSdkVersion() < Build.VERSION_CODES.N) {
+ && mActivity.packageInfo.getTargetSdkVersion() < Build.VERSION_CODES.N) {
Log.e(TAG, "App sent too much data in instance state, so it was ignored", ex);
return;
}