summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Yifei Zhang <yfz@google.com> 2023-10-11 17:03:56 -0700
committer Yifei Zhang <yfz@google.com> 2023-10-11 17:08:57 -0700
commit996ff0ceb33f218b5e90b9be93cb059337b45cfd (patch)
tree1d4a94b29e80d876c876584afd64509c79fae7ba
parente86f6d51cbd8c05d3991d41e07d4099f30e960fc (diff)
swipe-dismiss: use original context for theme check
- For legacy windowSwipeToDismiss resolution, use the original context instead of base context. (Wear-specific compat behavior) - Dialog uses a ContextWrapper that introduces additional theming. The base context would not correctly reflect the value for the window. Test: atest ClockworkSystemUI Bug: 294170826 Change-Id: I8a3098266d03b1de18925367ae281f72db3a61a1
-rw-r--r--core/java/android/window/WindowOnBackInvokedDispatcher.java5
1 files changed, 4 insertions, 1 deletions
diff --git a/core/java/android/window/WindowOnBackInvokedDispatcher.java b/core/java/android/window/WindowOnBackInvokedDispatcher.java
index 0ee07bbb3b5c..90fe7542c69c 100644
--- a/core/java/android/window/WindowOnBackInvokedDispatcher.java
+++ b/core/java/android/window/WindowOnBackInvokedDispatcher.java
@@ -491,6 +491,7 @@ public class WindowOnBackInvokedDispatcher implements OnBackInvokedDispatcher {
boolean requestsPredictiveBack = false;
// Check if the context is from an activity.
+ Context originalContext = context;
while ((context instanceof ContextWrapper) && !(context instanceof Activity)) {
context = ((ContextWrapper) context).getBaseContext();
}
@@ -539,8 +540,10 @@ public class WindowOnBackInvokedDispatcher implements OnBackInvokedDispatcher {
// 3. windowSwipeToDismiss=false should be respected for apps not opted in,
// which disables PB & onBackPressed caused by BackAnimController's
// setTrigger(true)
+ // Use the original context to resolve the styled attribute so that they stay
+ // true to the window.
TypedArray windowAttr =
- context.obtainStyledAttributes(
+ originalContext.obtainStyledAttributes(
new int[] {android.R.attr.windowSwipeToDismiss});
boolean windowSwipeToDismiss = true;
if (windowAttr.getIndexCount() > 0) {