Debugging for #2027266: app drawer showing up on the side

Nothing fixed, but this tells us what is going on.

Change-Id: I174d16a3864af2fa235e8cc7b1e74d32a375fb42
diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java
index d917d17..6858c75 100644
--- a/services/java/com/android/server/am/ActivityManagerService.java
+++ b/services/java/com/android/server/am/ActivityManagerService.java
@@ -141,6 +141,7 @@
     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 @@
             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,
@@ -8326,6 +8329,7 @@
             // 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);
         }
     }
 
@@ -12713,7 +12717,7 @@
             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);
                 }
                 
@@ -12737,6 +12741,8 @@
                     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) {
@@ -12820,19 +12826,21 @@
      */
     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;
@@ -12846,7 +12854,7 @@
         // 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;
@@ -12858,22 +12866,26 @@
 
             // 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) {
@@ -12881,11 +12893,13 @@
                     // 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;
                 }
@@ -12903,6 +12917,7 @@
         // 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.