summaryrefslogtreecommitdiff
path: root/core/java/android/app/WindowTokenClient.java
diff options
context:
space:
mode:
authorCharles Chen <charlesccchen@google.com>2021-03-05 18:07:46 +0800
committerCharles Chen <charlesccchen@google.com>2021-03-19 21:56:35 +0800
commit0783811428958673b877674d0eff2c3fac11ceb1 (patch)
treeb4b886f1af3fbecbdd7778bdea748f3c625c1c05 /core/java/android/app/WindowTokenClient.java
parenta7ee1a9a4936985dc0e672903b1a3c45e68d1ef8 (diff)
Enable to listen to WindowContext's config changes
This CL overrides registerComponentCallbacks for WindowContext. Users can use below code snippet to listen to Configuration changes. ``` Context windowContext = context.createWindowContext( display, ...); windowContext.registerComponentCallbacks( new ComponentCallbacks() { @Override public void onConfigurationChanged( Configuration newConfig) { // Do Something } }); ``` Bug: 181134729 Test: atest WindowContextTests Test: atest ComponentCallbacksControllerTest Change-Id: Iff46607bae3c942a96b64dcc97708f3a8c33f23a
Diffstat (limited to 'core/java/android/app/WindowTokenClient.java')
-rw-r--r--core/java/android/app/WindowTokenClient.java4
1 files changed, 3 insertions, 1 deletions
diff --git a/core/java/android/app/WindowTokenClient.java b/core/java/android/app/WindowTokenClient.java
index 2298e84d755e..82cef072ad0f 100644
--- a/core/java/android/app/WindowTokenClient.java
+++ b/core/java/android/app/WindowTokenClient.java
@@ -61,7 +61,7 @@ public class WindowTokenClient extends IWindowToken.Stub {
@Override
public void onConfigurationChanged(Configuration newConfig, int newDisplayId) {
- final Context context = mContextRef.get();
+ final WindowContext context = mContextRef.get();
if (context == null) {
return;
}
@@ -72,6 +72,8 @@ public class WindowTokenClient extends IWindowToken.Stub {
if (displayChanged || configChanged) {
// TODO(ag/9789103): update resource manager logic to track non-activity tokens
mResourcesManager.updateResourcesForActivity(this, newConfig, newDisplayId);
+ ActivityThread.currentActivityThread().getHandler().post(
+ () -> context.dispatchConfigurationChanged(newConfig));
}
if (displayChanged) {
context.updateDisplay(newDisplayId);