Rebase system theme on configuration change

Also makes native theme accesses thread-safe to avoid a race condition
when modifying the theme off the UI thread. Since drawable loading can
occur off the UI thread, we need to ensure Theme access is thread-safe
anyway.

This reverts commit c12ec70def2a5682c6cd7fdb3adaa82cc34d5bf6.

Change-Id: If8fecde76d62738a8e55eddf898eafc468afdba2
diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java
index eb64a9d..6e6c71f 100644
--- a/services/java/com/android/server/SystemServer.java
+++ b/services/java/com/android/server/SystemServer.java
@@ -1022,6 +1022,12 @@
         w.getDefaultDisplay().getMetrics(metrics);
         context.getResources().updateConfiguration(config, metrics);
 
+        // The system context's theme may be configuration-dependent.
+        final Theme systemTheme = context.getTheme();
+        if (systemTheme.getChangingConfigurations() != 0) {
+            systemTheme.rebase();
+        }
+
         try {
             // TODO: use boot phase
             mPowerManagerService.systemReady(mActivityManagerService.getAppOpsService());