Update process config when global config changed

This change will call process config update when a global config
changed. This will ensure the running process can get a up to dated
config.

Bug: 116429377
Bug: 113253755
Test: repro steps on the bug b/116429377 will not produce the bug
anymore.
Test: go/wm-smoke
Change-Id: If7f1f867f127e33e0c53e8be7179233e5340eea1
diff --git a/services/core/java/com/android/server/am/ActivityTaskManagerService.java b/services/core/java/com/android/server/am/ActivityTaskManagerService.java
index 4dd5a99..b369b71 100644
--- a/services/core/java/com/android/server/am/ActivityTaskManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityTaskManagerService.java
@@ -141,7 +141,6 @@
 import android.app.admin.DevicePolicyCache;
 import android.app.assist.AssistContent;
 import android.app.assist.AssistStructure;
-import android.app.servertransaction.ConfigurationChangeItem;
 import android.app.usage.UsageEvents;
 import android.content.ActivityNotFoundException;
 import android.content.ComponentName;
@@ -4525,19 +4524,13 @@
             mAm.mHandler.sendMessage(msg);
         }
 
-        // TODO: Consider using mPidMap to update configurations for processes.
-        for (int i = mAm.mLruProcesses.size() - 1; i >= 0; i--) {
-            ProcessRecord app = mAm.mLruProcesses.get(i);
-            try {
-                if (app.thread != null) {
-                    if (DEBUG_CONFIGURATION) Slog.v(TAG_CONFIGURATION, "Sending to proc "
-                            + app.processName + " new config " + configCopy);
-                    getLifecycleManager().scheduleTransaction(app.thread,
-                            ConfigurationChangeItem.obtain(configCopy));
-                }
-            } catch (Exception e) {
-                Slog.e(TAG_CONFIGURATION, "Failed to schedule configuration change", e);
+        for (int i = mPidMap.size() - 1; i >= 0; i--) {
+            WindowProcessController app = mPidMap.get(mPidMap.keyAt(i));
+            if (DEBUG_CONFIGURATION) {
+                Slog.v(TAG_CONFIGURATION, "Update process config of "
+                        + app.mName + " to new config " + configCopy);
             }
+            app.onConfigurationChanged(configCopy);
         }
 
         Intent intent = new Intent(Intent.ACTION_CONFIGURATION_CHANGED);