diff --git a/core/java/android/window/WindowOnBackInvokedDispatcher.java b/core/java/android/window/WindowOnBackInvokedDispatcher.java
index 632208cdb97c4..849e0b32591ac 100644
--- a/core/java/android/window/WindowOnBackInvokedDispatcher.java
+++ b/core/java/android/window/WindowOnBackInvokedDispatcher.java
@@ -23,6 +23,7 @@ import android.content.Context;
import android.content.ContextWrapper;
import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo;
+import android.content.res.TypedArray;
import android.os.Handler;
import android.os.RemoteException;
import android.os.SystemProperties;
@@ -33,6 +34,7 @@ import android.view.IWindowSession;
import androidx.annotation.VisibleForTesting;
+
import java.io.PrintWriter;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
@@ -62,6 +64,9 @@ public class WindowOnBackInvokedDispatcher implements OnBackInvokedDispatcher {
.getInt("persist.wm.debug.predictive_back", 1) != 0;
private static final boolean ALWAYS_ENFORCE_PREDICTIVE_BACK = SystemProperties
.getInt("persist.wm.debug.predictive_back_always_enforce", 0) != 0;
+ private static final boolean PREDICTIVE_BACK_FALLBACK_WINDOW_ATTRIBUTE =
+ SystemProperties.getInt("persist.wm.debug.predictive_back_fallback_window_attribute", 0)
+ != 0;
@Nullable
private ImeOnBackInvokedDispatcher mImeDispatcher;
@@ -500,6 +505,31 @@ public class WindowOnBackInvokedDispatcher implements OnBackInvokedDispatcher {
applicationInfo.packageName,
requestsPredictiveBack));
}
+
+ if (PREDICTIVE_BACK_FALLBACK_WINDOW_ATTRIBUTE && !requestsPredictiveBack) {
+ // Compatibility check for legacy window style flag used by Wear OS.
+ // Note on compatibility behavior:
+ // 1. windowSwipeToDismiss should be respected for all apps not opted in.
+ // 2. windowSwipeToDismiss should be true for all apps not opted in, which
+ // enables the PB animation for them.
+ // 3. windowSwipeToDismiss=false should be respected for apps not opted in,
+ // which disables PB & onBackPressed caused by BackAnimController's
+ // setTrigger(true)
+ TypedArray windowAttr =
+ context.obtainStyledAttributes(
+ new int[] {android.R.attr.windowSwipeToDismiss});
+ boolean windowSwipeToDismiss = true;
+ if (windowAttr.getIndexCount() > 0) {
+ windowSwipeToDismiss = windowAttr.getBoolean(0, true);
+ }
+ windowAttr.recycle();
+
+ if (DEBUG) {
+ Log.i(TAG, "falling back to windowSwipeToDismiss: " + windowSwipeToDismiss);
+ }
+
+ requestsPredictiveBack = windowSwipeToDismiss;
+ }
}
return requestsPredictiveBack;
diff --git a/core/res/res/values-watch/config_material.xml b/core/res/res/values-watch/config_material.xml
index 03d3637b150db..529f18b78e4dd 100644
--- a/core/res/res/values-watch/config_material.xml
+++ b/core/res/res/values-watch/config_material.xml
@@ -30,9 +30,6 @@
true
-
- true
-
@drawable/scrollbar_vertical_thumb
@drawable/scrollbar_vertical_track