diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java index 76a133b65a03f..d6f024b651392 100644 --- a/core/java/android/app/ActivityThread.java +++ b/core/java/android/app/ActivityThread.java @@ -123,6 +123,7 @@ public final class ActivityThread { private static final boolean DEBUG_BROADCAST = false; private static final boolean DEBUG_RESULTS = false; private static final boolean DEBUG_BACKUP = true; + private static final boolean DEBUG_CONFIGURATION = false; private static final long MIN_TIME_BETWEEN_GCS = 5*1000; private static final Pattern PATTERN_SEMICOLON = Pattern.compile(";"); private static final int SQLITE_MEM_RELEASED_EVENT_LOG_TAG = 75003; @@ -2388,6 +2389,8 @@ public final class ActivityThread { appContext.setOuterContext(activity); CharSequence title = r.activityInfo.loadLabel(appContext.getPackageManager()); Configuration config = new Configuration(mConfiguration); + if (DEBUG_CONFIGURATION) Log.v(TAG, "Launching activity " + + r.activityInfo.name + " with config " + config); activity.attach(appContext, this, getInstrumentation(), r.token, r.ident, app, r.intent, r.activityInfo, title, r.parent, r.embeddedID, r.lastNonConfigurationInstance, @@ -2954,6 +2957,8 @@ public final class ActivityThread { if (!r.activity.mFinished && !a.mStartedActivity && r.activity.mDecor != null && !r.hideForNow) { if (r.newConfig != null) { + if (DEBUG_CONFIGURATION) Log.v(TAG, "Resuming activity " + + r.activityInfo.name + " with newConfig " + r.newConfig); performConfigurationChanged(r.activity, r.newConfig); r.newConfig = null; } @@ -3195,6 +3200,8 @@ public final class ActivityThread { } } if (r.newConfig != null) { + if (DEBUG_CONFIGURATION) Log.v(TAG, "Updating activity vis " + + r.activityInfo.name + " with new config " + r.newConfig); performConfigurationChanged(r.activity, r.newConfig); r.newConfig = null; } @@ -3476,6 +3483,10 @@ public final class ActivityThread { Configuration changedConfig = null; + if (DEBUG_CONFIGURATION) Log.v(TAG, "Relaunching activity " + + tmp.token + " with configChanges=0x" + + Integer.toHexString(configChanges)); + // First: make sure we have the most recent configuration and most // recent version of the activity, or skip it if some previous call // had taken a more recent version. @@ -3494,6 +3505,7 @@ public final class ActivityThread { } if (tmp == null) { + if (DEBUG_CONFIGURATION) Log.v(TAG, "Abort, activity not relaunching!"); return; } @@ -3503,13 +3515,16 @@ public final class ActivityThread { } } + if (DEBUG_CONFIGURATION) Log.v(TAG, "Relaunching activity " + + tmp.token + ": changedConfig=" + changedConfig); + // If there was a pending configuration change, execute it first. if (changedConfig != null) { handleConfigurationChanged(changedConfig); } ActivityRecord r = mActivities.get(tmp.token); - if (localLOGV) Log.v(TAG, "Handling relaunch of " + r); + if (DEBUG_CONFIGURATION) Log.v(TAG, "Handling relaunch of " + r); if (r == null) { return; } @@ -3595,6 +3610,8 @@ public final class ActivityThread { // the activity manager may, before then, decide the // activity needs to be destroyed to handle its new // configuration. + if (DEBUG_CONFIGURATION) Log.v(TAG, "Setting activity " + + ar.activityInfo.name + " newConfig=" + newConfig); ar.newConfig = newConfig; } } @@ -3652,6 +3669,8 @@ public final class ActivityThread { } } + if (DEBUG_CONFIGURATION) Log.v(TAG, "Config callback " + cb + + ": shouldChangeConfig=" + shouldChangeConfig); if (shouldChangeConfig) { cb.onConfigurationChanged(config); @@ -3679,6 +3698,9 @@ public final class ActivityThread { ArrayList callbacks = new ArrayList(); + if (DEBUG_CONFIGURATION) Log.v(TAG, "Handle configuration changed: " + + config); + synchronized(mPackages) { if (mConfiguration == null) { mConfiguration = new Configuration(); @@ -3729,6 +3751,9 @@ public final class ActivityThread { return; } + if (DEBUG_CONFIGURATION) Log.v(TAG, "Handle activity config changed: " + + r.activityInfo.name); + performConfigurationChanged(r.activity, mConfiguration); } diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java index c6c6d55c6da96..38f09dd782efa 100644 --- a/services/java/com/android/server/am/ActivityManagerService.java +++ b/services/java/com/android/server/am/ActivityManagerService.java @@ -141,6 +141,7 @@ public final class ActivityManagerService extends ActivityManagerNative implemen static final boolean DEBUG_USER_LEAVING = localLOGV || false; static final boolean DEBUG_RESULTS = localLOGV || false; static final boolean DEBUG_BACKUP = localLOGV || true; + static final boolean DEBUG_CONFIGURATION = localLOGV || false; static final boolean VALIDATE_TOKENS = false; static final boolean SHOW_ACTIVITY_START_TIME = true; @@ -5295,6 +5296,8 @@ public final class ActivityManagerService extends ActivityManagerNative implemen if (app.instrumentationClass != null) { ensurePackageDexOpt(app.instrumentationClass.getPackageName()); } + if (DEBUG_CONFIGURATION) Log.v(TAG, "Binding proc " + + processName + " with config " + mConfiguration); thread.bindApplication(processName, app.instrumentationInfo != null ? app.instrumentationInfo : app.info, providers, app.instrumentationClass, app.instrumentationProfileFile, @@ -8327,6 +8330,7 @@ public final class ActivityManagerService extends ActivityManagerNative implemen // This happens before any activities are started, so we can // change mConfiguration in-place. mConfiguration.updateFrom(configuration); + if (DEBUG_CONFIGURATION) Log.v(TAG, "Initial config: " + mConfiguration); } } @@ -12714,7 +12718,7 @@ public final class ActivityManagerService extends ActivityManagerNative implemen Configuration newConfig = new Configuration(mConfiguration); changes = newConfig.updateFrom(values); if (changes != 0) { - if (DEBUG_SWITCH) { + if (DEBUG_SWITCH || DEBUG_CONFIGURATION) { Log.i(TAG, "Updating configuration to: " + values); } @@ -12738,6 +12742,8 @@ public final class ActivityManagerService extends ActivityManagerNative implemen ProcessRecord app = mLRUProcesses.get(i); try { if (app.thread != null) { + if (DEBUG_CONFIGURATION) Log.v(TAG, "Sending to proc " + + app.processName + " new config " + mConfiguration); app.thread.scheduleConfigurationChanged(mConfiguration); } } catch (Exception e) { @@ -12821,19 +12827,21 @@ public final class ActivityManagerService extends ActivityManagerNative implemen */ private final boolean ensureActivityConfigurationLocked(HistoryRecord r, int globalChanges) { - if (DEBUG_SWITCH) Log.i(TAG, "Ensuring correct configuration: " + r); + if (DEBUG_SWITCH || DEBUG_CONFIGURATION) Log.v(TAG, + "Ensuring correct configuration: " + r); // Short circuit: if the two configurations are the exact same // object (the common case), then there is nothing to do. Configuration newConfig = mConfiguration; if (r.configuration == newConfig) { - if (DEBUG_SWITCH) Log.i(TAG, "Configuration unchanged in " + r); + if (DEBUG_SWITCH || DEBUG_CONFIGURATION) Log.v(TAG, + "Configuration unchanged in " + r); return true; } // We don't worry about activities that are finishing. if (r.finishing) { - if (DEBUG_SWITCH) Log.i(TAG, + if (DEBUG_SWITCH || DEBUG_CONFIGURATION) Log.v(TAG, "Configuration doesn't matter in finishing " + r); r.stopFreezingScreenLocked(false); return true; @@ -12847,7 +12855,7 @@ public final class ActivityManagerService extends ActivityManagerNative implemen // If the activity isn't currently running, just leave the new // configuration and it will pick that up next time it starts. if (r.app == null || r.app.thread == null) { - if (DEBUG_SWITCH) Log.i(TAG, + if (DEBUG_SWITCH || DEBUG_CONFIGURATION) Log.v(TAG, "Configuration doesn't matter not running " + r); r.stopFreezingScreenLocked(false); return true; @@ -12859,22 +12867,26 @@ public final class ActivityManagerService extends ActivityManagerNative implemen // Figure out what has changed between the two configurations. int changes = oldConfig.diff(newConfig); - if (DEBUG_SWITCH) { - Log.i(TAG, "Checking to restart " + r.info.name + ": changed=0x" + if (DEBUG_SWITCH || DEBUG_CONFIGURATION) { + Log.v(TAG, "Checking to restart " + r.info.name + ": changed=0x" + Integer.toHexString(changes) + ", handles=0x" - + Integer.toHexString(r.info.configChanges)); + + Integer.toHexString(r.info.configChanges) + + ", newConfig=" + newConfig); } if ((changes&(~r.info.configChanges)) != 0) { // Aha, the activity isn't handling the change, so DIE DIE DIE. r.configChangeFlags |= changes; r.startFreezingScreenLocked(r.app, globalChanges); if (r.app == null || r.app.thread == null) { - if (DEBUG_SWITCH) Log.i(TAG, "Switch is destroying non-running " + r); + if (DEBUG_SWITCH || DEBUG_CONFIGURATION) Log.v(TAG, + "Switch is destroying non-running " + r); destroyActivityLocked(r, true); } else if (r.state == ActivityState.PAUSING) { // A little annoying: we are waiting for this activity to // finish pausing. Let's not do anything now, but just // flag that it needs to be restarted when done pausing. + if (DEBUG_SWITCH || DEBUG_CONFIGURATION) Log.v(TAG, + "Switch is skipping already pausing " + r); r.configDestroy = true; return true; } else if (r.state == ActivityState.RESUMED) { @@ -12882,11 +12894,13 @@ public final class ActivityManagerService extends ActivityManagerNative implemen // and we need to restart the top, resumed activity. // Instead of doing the normal handshaking, just say // "restart!". - if (DEBUG_SWITCH) Log.i(TAG, "Switch is restarting resumed " + r); + if (DEBUG_SWITCH || DEBUG_CONFIGURATION) Log.v(TAG, + "Switch is restarting resumed " + r); relaunchActivityLocked(r, r.configChangeFlags, true); r.configChangeFlags = 0; } else { - if (DEBUG_SWITCH) Log.i(TAG, "Switch is restarting non-resumed " + r); + if (DEBUG_SWITCH || DEBUG_CONFIGURATION) Log.v(TAG, + "Switch is restarting non-resumed " + r); relaunchActivityLocked(r, r.configChangeFlags, false); r.configChangeFlags = 0; } @@ -12904,6 +12918,7 @@ public final class ActivityManagerService extends ActivityManagerNative implemen // it last got. if (r.app != null && r.app.thread != null) { try { + if (DEBUG_CONFIGURATION) Log.v(TAG, "Sending new config to " + r); r.app.thread.scheduleActivityConfigurationChanged(r); } catch (RemoteException e) { // If process died, whatever.