diff options
Diffstat (limited to 'core/java/android/app')
-rw-r--r-- | core/java/android/app/Activity.java | 2 | ||||
-rw-r--r-- | core/java/android/app/ActivityThread.java | 33 | ||||
-rw-r--r-- | core/java/android/app/ApplicationThreadNative.java | 45 | ||||
-rw-r--r-- | core/java/android/app/ContextImpl.java | 12 | ||||
-rw-r--r-- | core/java/android/app/IApplicationThread.java | 15 | ||||
-rw-r--r-- | core/java/android/app/ResourcesManager.java | 48 |
6 files changed, 86 insertions, 69 deletions
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java index 23b05c4..a597d5e 100644 --- a/core/java/android/app/Activity.java +++ b/core/java/android/app/Activity.java @@ -4607,7 +4607,7 @@ public class Activity extends ContextThemeWrapper if (Looper.myLooper() != mMainThread.getLooper()) { throw new IllegalStateException("Must be called from main thread"); } - mMainThread.requestRelaunchActivity(mToken, null, null, 0, false, null, false); + mMainThread.requestRelaunchActivity(mToken, null, null, 0, false, null, null, false); } /** diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java index ea37b89..de3c95c 100644 --- a/core/java/android/app/ActivityThread.java +++ b/core/java/android/app/ActivityThread.java @@ -293,6 +293,7 @@ public final class ActivityThread { boolean hideForNow; Configuration newConfig; Configuration createdConfig; + Configuration overrideConfig; ActivityClientRecord nextIdle; ProfilerInfo profilerInfo; @@ -615,12 +616,13 @@ public final class ActivityThread { // we use token to identify this activity without having to send the // activity itself back to the activity manager. (matters more with ipc) + @Override public final void scheduleLaunchActivity(Intent intent, IBinder token, int ident, - ActivityInfo info, Configuration curConfig, CompatibilityInfo compatInfo, - String referrer, IVoiceInteractor voiceInteractor, int procState, Bundle state, - PersistableBundle persistentState, List<ResultInfo> pendingResults, - List<ReferrerIntent> pendingNewIntents, boolean notResumed, boolean isForward, - ProfilerInfo profilerInfo) { + ActivityInfo info, Configuration curConfig, Configuration overrideConfig, + CompatibilityInfo compatInfo, String referrer, IVoiceInteractor voiceInteractor, + int procState, Bundle state, PersistableBundle persistentState, + List<ResultInfo> pendingResults, List<ReferrerIntent> pendingNewIntents, + boolean notResumed, boolean isForward, ProfilerInfo profilerInfo) { updateProcessState(procState, false); @@ -644,16 +646,19 @@ public final class ActivityThread { r.profilerInfo = profilerInfo; + r.overrideConfig = overrideConfig; updatePendingConfiguration(curConfig); sendMessage(H.LAUNCH_ACTIVITY, r); } + @Override public final void scheduleRelaunchActivity(IBinder token, List<ResultInfo> pendingResults, List<ReferrerIntent> pendingNewIntents, - int configChanges, boolean notResumed, Configuration config) { + int configChanges, boolean notResumed, Configuration config, + Configuration overrideConfig) { requestRelaunchActivity(token, pendingResults, pendingNewIntents, - configChanges, notResumed, config, true); + configChanges, notResumed, config, overrideConfig, true); } public final void scheduleNewIntent(List<ReferrerIntent> intents, IBinder token) { @@ -887,6 +892,7 @@ public final class ActivityThread { sendMessage(H.LOW_MEMORY, null); } + @Override public void scheduleActivityConfigurationChanged(IBinder token) { sendMessage(H.ACTIVITY_CONFIGURATION_CHANGED, token); } @@ -1668,7 +1674,7 @@ public final class ActivityThread { String[] libDirs, int displayId, Configuration overrideConfiguration, LoadedApk pkgInfo) { return mResourcesManager.getTopLevelResources(resDir, splitResDirs, overlayDirs, libDirs, - displayId, overrideConfiguration, pkgInfo.getCompatibilityInfo(), null); + displayId, overrideConfiguration, pkgInfo.getCompatibilityInfo()); } final Handler getHandler() { @@ -2353,7 +2359,8 @@ public final class ActivityThread { private Context createBaseContextForActivity(ActivityClientRecord r, final Activity activity) { - ContextImpl appContext = ContextImpl.createActivityContext(this, r.packageInfo, r.token); + ContextImpl appContext = + ContextImpl.createActivityContext(this, r.packageInfo, r.overrideConfig); appContext.setOuterContext(activity); Context baseContext = appContext; @@ -3561,7 +3568,7 @@ public final class ActivityThread { // request all activities to relaunch for the changes to take place for (Map.Entry<IBinder, ActivityClientRecord> entry : mActivities.entrySet()) { - requestRelaunchActivity(entry.getKey(), null, null, 0, false, null, false); + requestRelaunchActivity(entry.getKey(), null, null, 0, false, null, null, false); } } } @@ -3805,7 +3812,7 @@ public final class ActivityThread { public final void requestRelaunchActivity(IBinder token, List<ResultInfo> pendingResults, List<ReferrerIntent> pendingNewIntents, int configChanges, boolean notResumed, Configuration config, - boolean fromServer) { + Configuration overrideConfig, boolean fromServer) { ActivityClientRecord target = null; synchronized (mResourcesManager) { @@ -3854,6 +3861,9 @@ public final class ActivityThread { if (config != null) { target.createdConfig = config; } + if (overrideConfig != null) { + target.overrideConfig = overrideConfig; + } target.pendingConfigChanges |= configChanges; } } @@ -3966,6 +3976,7 @@ public final class ActivityThread { } } r.startsNotResumed = tmp.startsNotResumed; + r.overrideConfig = tmp.overrideConfig; handleLaunchActivity(r, currentIntent); } diff --git a/core/java/android/app/ApplicationThreadNative.java b/core/java/android/app/ApplicationThreadNative.java index eb3ddb2..349b66d 100644 --- a/core/java/android/app/ApplicationThreadNative.java +++ b/core/java/android/app/ApplicationThreadNative.java @@ -140,6 +140,10 @@ public abstract class ApplicationThreadNative extends Binder int ident = data.readInt(); ActivityInfo info = ActivityInfo.CREATOR.createFromParcel(data); Configuration curConfig = Configuration.CREATOR.createFromParcel(data); + Configuration overrideConfig = null; + if (data.readInt() != 0) { + overrideConfig = Configuration.CREATOR.createFromParcel(data); + } CompatibilityInfo compatInfo = CompatibilityInfo.CREATOR.createFromParcel(data); String referrer = data.readString(); IVoiceInteractor voiceInteractor = IVoiceInteractor.Stub.asInterface( @@ -153,8 +157,8 @@ public abstract class ApplicationThreadNative extends Binder boolean isForward = data.readInt() != 0; ProfilerInfo profilerInfo = data.readInt() != 0 ? ProfilerInfo.CREATOR.createFromParcel(data) : null; - scheduleLaunchActivity(intent, b, ident, info, curConfig, compatInfo, referrer, - voiceInteractor, procState, state, persistentState, ri, pi, + scheduleLaunchActivity(intent, b, ident, info, curConfig, overrideConfig, compatInfo, + referrer, voiceInteractor, procState, state, persistentState, ri, pi, notResumed, isForward, profilerInfo); return true; } @@ -167,14 +171,15 @@ public abstract class ApplicationThreadNative extends Binder List<ReferrerIntent> pi = data.createTypedArrayList(ReferrerIntent.CREATOR); int configChanges = data.readInt(); boolean notResumed = data.readInt() != 0; - Configuration config = null; + Configuration config = Configuration.CREATOR.createFromParcel(data); + Configuration overrideConfig = null; if (data.readInt() != 0) { - config = Configuration.CREATOR.createFromParcel(data); + overrideConfig = Configuration.CREATOR.createFromParcel(data); } - scheduleRelaunchActivity(b, ri, pi, configChanges, notResumed, config); + scheduleRelaunchActivity(b, ri, pi, configChanges, notResumed, config, overrideConfig); return true; } - + case SCHEDULE_NEW_INTENT_TRANSACTION: { data.enforceInterface(IApplicationThread.descriptor); @@ -775,11 +780,11 @@ class ApplicationThreadProxy implements IApplicationThread { } public final void scheduleLaunchActivity(Intent intent, IBinder token, int ident, - ActivityInfo info, Configuration curConfig, CompatibilityInfo compatInfo, - String referrer, IVoiceInteractor voiceInteractor, int procState, Bundle state, - PersistableBundle persistentState, List<ResultInfo> pendingResults, - List<ReferrerIntent> pendingNewIntents, boolean notResumed, boolean isForward, - ProfilerInfo profilerInfo) throws RemoteException { + ActivityInfo info, Configuration curConfig, Configuration overrideConfig, + CompatibilityInfo compatInfo, String referrer, IVoiceInteractor voiceInteractor, + int procState, Bundle state, PersistableBundle persistentState, + List<ResultInfo> pendingResults, List<ReferrerIntent> pendingNewIntents, + boolean notResumed, boolean isForward, ProfilerInfo profilerInfo) throws RemoteException { Parcel data = Parcel.obtain(); data.writeInterfaceToken(IApplicationThread.descriptor); intent.writeToParcel(data, 0); @@ -787,6 +792,12 @@ class ApplicationThreadProxy implements IApplicationThread { data.writeInt(ident); info.writeToParcel(data, 0); curConfig.writeToParcel(data, 0); + if (overrideConfig != null) { + data.writeInt(1); + overrideConfig.writeToParcel(data, 0); + } else { + data.writeInt(0); + } compatInfo.writeToParcel(data, 0); data.writeString(referrer); data.writeStrongBinder(voiceInteractor != null ? voiceInteractor.asBinder() : null); @@ -810,8 +821,8 @@ class ApplicationThreadProxy implements IApplicationThread { public final void scheduleRelaunchActivity(IBinder token, List<ResultInfo> pendingResults, List<ReferrerIntent> pendingNewIntents, - int configChanges, boolean notResumed, Configuration config) - throws RemoteException { + int configChanges, boolean notResumed, Configuration config, + Configuration overrideConfig) throws RemoteException { Parcel data = Parcel.obtain(); data.writeInterfaceToken(IApplicationThread.descriptor); data.writeStrongBinder(token); @@ -819,9 +830,10 @@ class ApplicationThreadProxy implements IApplicationThread { data.writeTypedList(pendingNewIntents); data.writeInt(configChanges); data.writeInt(notResumed ? 1 : 0); - if (config != null) { + config.writeToParcel(data, 0); + if (overrideConfig != null) { data.writeInt(1); - config.writeToParcel(data, 0); + overrideConfig.writeToParcel(data, 0); } else { data.writeInt(0); } @@ -1112,8 +1124,7 @@ class ApplicationThreadProxy implements IApplicationThread { data.recycle(); } - public final void scheduleActivityConfigurationChanged( - IBinder token) throws RemoteException { + public final void scheduleActivityConfigurationChanged(IBinder token) throws RemoteException { Parcel data = Parcel.obtain(); data.writeInterfaceToken(IApplicationThread.descriptor); data.writeStrongBinder(token); diff --git a/core/java/android/app/ContextImpl.java b/core/java/android/app/ContextImpl.java index e9df8c6..39caf0b 100644 --- a/core/java/android/app/ContextImpl.java +++ b/core/java/android/app/ContextImpl.java @@ -2264,11 +2264,10 @@ class ContextImpl extends Context { } static ContextImpl createActivityContext(ActivityThread mainThread, - LoadedApk packageInfo, IBinder activityToken) { + LoadedApk packageInfo, Configuration overrideConfiguration) { 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); + return new ContextImpl(null, mainThread, packageInfo, null, null, false, null, + overrideConfiguration); } private ContextImpl(ContextImpl container, ActivityThread mainThread, @@ -2303,15 +2302,14 @@ class ContextImpl extends Context { Resources resources = packageInfo.getResources(mainThread); if (resources != null) { - if (activityToken != null - || displayId != Display.DEFAULT_DISPLAY + if (displayId != Display.DEFAULT_DISPLAY || overrideConfiguration != null || (compatInfo != null && compatInfo.applicationScale != resources.getCompatibilityInfo().applicationScale)) { resources = mResourcesManager.getTopLevelResources(packageInfo.getResDir(), packageInfo.getSplitResDirs(), packageInfo.getOverlayDirs(), packageInfo.getApplicationInfo().sharedLibraryFiles, displayId, - overrideConfiguration, compatInfo, activityToken); + overrideConfiguration, compatInfo); } } mResources = resources; diff --git a/core/java/android/app/IApplicationThread.java b/core/java/android/app/IApplicationThread.java index 8bf8cd7..f2c912e 100644 --- a/core/java/android/app/IApplicationThread.java +++ b/core/java/android/app/IApplicationThread.java @@ -33,7 +33,6 @@ import android.os.PersistableBundle; import android.os.RemoteException; import android.os.IBinder; import android.os.IInterface; -import android.service.voice.IVoiceInteractionSession; import com.android.internal.app.IVoiceInteractor; import com.android.internal.content.ReferrerIntent; @@ -59,14 +58,14 @@ public interface IApplicationThread extends IInterface { throws RemoteException; void scheduleSendResult(IBinder token, List<ResultInfo> results) throws RemoteException; void scheduleLaunchActivity(Intent intent, IBinder token, int ident, - ActivityInfo info, Configuration curConfig, CompatibilityInfo compatInfo, - String referrer, IVoiceInteractor voiceInteractor, int procState, Bundle state, - PersistableBundle persistentState, List<ResultInfo> pendingResults, - List<ReferrerIntent> pendingNewIntents, boolean notResumed, boolean isForward, - ProfilerInfo profilerInfo) throws RemoteException; + ActivityInfo info, Configuration curConfig, Configuration overrideConfig, + CompatibilityInfo compatInfo, String referrer, IVoiceInteractor voiceInteractor, + int procState, Bundle state, PersistableBundle persistentState, + List<ResultInfo> pendingResults, List<ReferrerIntent> pendingNewIntents, + boolean notResumed, boolean isForward, ProfilerInfo profilerInfo) throws RemoteException; void scheduleRelaunchActivity(IBinder token, List<ResultInfo> pendingResults, - List<ReferrerIntent> pendingNewIntents, int configChanges, - boolean notResumed, Configuration config) throws RemoteException; + List<ReferrerIntent> pendingNewIntents, int configChanges, boolean notResumed, + Configuration config, Configuration overrideConfig) throws RemoteException; void scheduleNewIntent(List<ReferrerIntent> intent, IBinder token) throws RemoteException; void scheduleDestroyActivity(IBinder token, boolean finished, int configChanges) throws RemoteException; diff --git a/core/java/android/app/ResourcesManager.java b/core/java/android/app/ResourcesManager.java index 1691d8e..fac40b2 100644 --- a/core/java/android/app/ResourcesManager.java +++ b/core/java/android/app/ResourcesManager.java @@ -25,7 +25,6 @@ import android.content.res.Configuration; import android.content.res.Resources; import android.content.res.ResourcesKey; import android.hardware.display.DisplayManagerGlobal; -import android.os.IBinder; import android.util.ArrayMap; import android.util.DisplayMetrics; import android.util.Slog; @@ -38,8 +37,7 @@ import java.util.Locale; /** @hide */ public class ResourcesManager { static final String TAG = "ResourcesManager"; - static final boolean DEBUG_CACHE = false; - static final boolean DEBUG_STATS = true; + private static final boolean DEBUG = false; private static ResourcesManager sResourcesManager; final ArrayMap<ResourcesKey, WeakReference<Resources> > mActiveResources @@ -51,7 +49,6 @@ public class ResourcesManager { CompatibilityInfo mResCompatibilityInfo; Configuration mResConfiguration; - final Configuration mTmpConfig = new Configuration(); public static ResourcesManager getInstance() { synchronized (ResourcesManager.class) { @@ -144,30 +141,32 @@ public class ResourcesManager { * Creates the top level Resources for applications with the given compatibility info. * * @param resDir the resource directory. + * @param splitResDirs split resource directories. * @param overlayDirs the resource overlay directories. * @param libDirs the shared library resource dirs this app references. - * @param compatInfo the compability info. Must not be null. - * @param token the application token for determining stack bounds. + * @param displayId display Id. + * @param overrideConfiguration override configurations. + * @param compatInfo the compatibility info. Must not be null. */ public Resources getTopLevelResources(String resDir, String[] splitResDirs, String[] overlayDirs, String[] libDirs, int displayId, - Configuration overrideConfiguration, CompatibilityInfo compatInfo, IBinder token) { + Configuration overrideConfiguration, CompatibilityInfo compatInfo) { final float scale = compatInfo.applicationScale; - ResourcesKey key = new ResourcesKey(resDir, displayId, overrideConfiguration, scale, token); + Configuration overrideConfigCopy = (overrideConfiguration != null) + ? new Configuration(overrideConfiguration) : null; + ResourcesKey key = new ResourcesKey(resDir, displayId, overrideConfigCopy, scale); Resources r; synchronized (this) { // Resources is app scale dependent. - if (false) { - Slog.w(TAG, "getTopLevelResources: " + resDir + " / " + scale); - } + if (DEBUG) Slog.w(TAG, "getTopLevelResources: " + resDir + " / " + scale); + WeakReference<Resources> wr = mActiveResources.get(key); r = wr != null ? wr.get() : null; //if (r != null) Slog.i(TAG, "isUpToDate " + resDir + ": " + r.getAssets().isUpToDate()); if (r != null && r.getAssets().isUpToDate()) { - if (false) { - Slog.w(TAG, "Returning cached resources " + r + " " + resDir - + ": appScale=" + r.getCompatibilityInfo().applicationScale); - } + if (DEBUG) Slog.w(TAG, "Returning cached resources " + r + " " + resDir + + ": appScale=" + r.getCompatibilityInfo().applicationScale + + " key=" + key + " overrideConfig=" + overrideConfiguration); return r; } } @@ -213,7 +212,7 @@ public class ResourcesManager { //Slog.i(TAG, "Resource: key=" + key + ", display metrics=" + metrics); DisplayMetrics dm = getDisplayMetricsLocked(displayId); Configuration config; - boolean isDefaultDisplay = (displayId == Display.DEFAULT_DISPLAY); + final boolean isDefaultDisplay = (displayId == Display.DEFAULT_DISPLAY); final boolean hasOverrideConfig = key.hasOverrideConfiguration(); if (!isDefaultDisplay || hasOverrideConfig) { config = new Configuration(getConfiguration()); @@ -222,16 +221,14 @@ public class ResourcesManager { } if (hasOverrideConfig) { config.updateFrom(key.mOverrideConfiguration); + if (DEBUG) Slog.v(TAG, "Applied overrideConfig=" + key.mOverrideConfiguration); } } else { config = getConfiguration(); } - r = new Resources(assets, dm, config, compatInfo, token); - if (false) { - Slog.i(TAG, "Created app resources " + resDir + " " + r + ": " - + r.getConfiguration() + " appScale=" - + r.getCompatibilityInfo().applicationScale); - } + r = new Resources(assets, dm, config, compatInfo); + if (DEBUG) Slog.i(TAG, "Created app resources " + resDir + " " + r + ": " + + r.getConfiguration() + " appScale=" + r.getCompatibilityInfo().applicationScale); synchronized (this) { WeakReference<Resources> wr = mActiveResources.get(key); @@ -244,7 +241,8 @@ public class ResourcesManager { } // XXX need to remove entries when weak references go away - mActiveResources.put(key, new WeakReference<Resources>(r)); + mActiveResources.put(key, new WeakReference<>(r)); + if (DEBUG) Slog.v(TAG, "mActiveResources.size()=" + mActiveResources.size()); return r; } } @@ -255,7 +253,7 @@ public class ResourcesManager { mResConfiguration = new Configuration(); } if (!mResConfiguration.isOtherSeqNewer(config) && compat == null) { - if (DEBUG_CONFIGURATION) Slog.v(TAG, "Skipping new config: curSeq=" + if (DEBUG || DEBUG_CONFIGURATION) Slog.v(TAG, "Skipping new config: curSeq=" + mResConfiguration.seq + ", newSeq=" + config.seq); return false; } @@ -287,7 +285,7 @@ public class ResourcesManager { ResourcesKey key = mActiveResources.keyAt(i); Resources r = mActiveResources.valueAt(i).get(); if (r != null) { - if (DEBUG_CONFIGURATION) Slog.v(TAG, "Changing resources " + if (DEBUG || DEBUG_CONFIGURATION) Slog.v(TAG, "Changing resources " + r + " config to: " + config); int displayId = key.mDisplayId; boolean isDefaultDisplay = (displayId == Display.DEFAULT_DISPLAY); |