summaryrefslogtreecommitdiff
path: root/core/java/android/app/ConfigurationController.java
diff options
context:
space:
mode:
authorRiddle Hsu <riddlehsu@google.com>2021-12-09 16:51:28 +0800
committerRiddle Hsu <riddlehsu@google.com>2021-12-09 16:51:28 +0800
commit45e4bcf994c821ec5ee6c45ea568f1342a8de426 (patch)
treee66d5717acf44dea2d6faf1b4b5c91b39653d478 /core/java/android/app/ConfigurationController.java
parentd43efc90ab2893851724e92cca8ebe70182fd543 (diff)
Reduce unnecessary overhead of SystemUiContext
- Do not report change when initializing DisplayContent (DisplayContent#isReady() is false). This reduces boot time by dozen of milliseconds (RootWindowContainer#setWindowManager). - Only create SystemUiContext if needed. Most of processes don't use it. This reduces many registrations (e.g. according to the number of processes, it maybe from ~60 to ~10), which involve binder/listener creation/invocation, especially the extra cost of dispatching configuration to the context which no one uses. - Store token as IWindowToken to avoid object creation every time by asInterface. Bug: 207620458 Test: atest InputMethodMenuControllerTest WindowContextControllerTest Change-Id: I867e9f81116796c42048195406d74feccf4772d3
Diffstat (limited to 'core/java/android/app/ConfigurationController.java')
-rw-r--r--core/java/android/app/ConfigurationController.java10
1 files changed, 7 insertions, 3 deletions
diff --git a/core/java/android/app/ConfigurationController.java b/core/java/android/app/ConfigurationController.java
index 8637e31eb122..58f60a6a59a7 100644
--- a/core/java/android/app/ConfigurationController.java
+++ b/core/java/android/app/ConfigurationController.java
@@ -154,9 +154,12 @@ class ConfigurationController {
int configDiff;
boolean equivalent;
+ // Get theme outside of synchronization to avoid nested lock.
+ final Resources.Theme systemTheme = mActivityThread.getSystemContext().getTheme();
+ final ContextImpl systemUiContext = mActivityThread.getSystemUiContextNoCreate();
+ final Resources.Theme systemUiTheme =
+ systemUiContext != null ? systemUiContext.getTheme() : null;
synchronized (mResourcesManager) {
- final Resources.Theme systemTheme = mActivityThread.getSystemContext().getTheme();
- final Resources.Theme systemUiTheme = mActivityThread.getSystemUiContext().getTheme();
if (mPendingConfiguration != null) {
if (!mPendingConfiguration.isOtherSeqNewer(config)) {
config = mPendingConfiguration;
@@ -207,7 +210,8 @@ class ConfigurationController {
systemTheme.rebase();
}
- if ((systemUiTheme.getChangingConfigurations() & configDiff) != 0) {
+ if (systemUiTheme != null
+ && (systemUiTheme.getChangingConfigurations() & configDiff) != 0) {
systemUiTheme.rebase();
}
}