diff options
| -rw-r--r-- | core/api/current.txt | 1 | ||||
| -rw-r--r-- | core/java/android/view/ViewRootImpl.java | 10 | ||||
| -rw-r--r-- | core/java/android/window/BackEvent.java | 9 | ||||
| -rw-r--r-- | core/java/android/window/flags/windowing_frontend.aconfig | 8 |
4 files changed, 26 insertions, 2 deletions
diff --git a/core/api/current.txt b/core/api/current.txt index b95295cd4ad9..911e7de4c17d 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -61760,6 +61760,7 @@ package android.window { method public float getTouchX(); method public float getTouchY(); field public static final int EDGE_LEFT = 0; // 0x0 + field @FlaggedApi("com.android.window.flags.predictive_back_swipe_edge_none_api") public static final int EDGE_NONE = 2; // 0x2 field public static final int EDGE_RIGHT = 1; // 0x1 } diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index 0efded2d0eb9..d57a88075f8a 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -131,6 +131,7 @@ import static android.window.DesktopModeFlags.ENABLE_CAPTION_COMPAT_INSET_FORCE_ import static com.android.internal.annotations.VisibleForTesting.Visibility.PACKAGE; import static com.android.text.flags.Flags.disableHandwritingInitiatorForIme; import static com.android.window.flags.Flags.enableBufferTransformHintFromDisplay; +import static com.android.window.flags.Flags.predictiveBackSwipeEdgeNoneApi; import static com.android.window.flags.Flags.setScPropertiesInClient; import static com.android.window.flags.Flags.systemUiImmersiveConfirmationDialog; @@ -7559,8 +7560,13 @@ public final class ViewRootImpl implements ViewParent, // - 0 means the button was pressed. // - 1 means the button continues to be pressed (long press). if (keyEvent.getRepeatCount() == 0) { - animationCallback.onBackStarted( - new BackEvent(0, 0, 0f, BackEvent.EDGE_LEFT)); + BackEvent backEvent; + if (predictiveBackSwipeEdgeNoneApi()) { + backEvent = new BackEvent(0, 0, 0f, BackEvent.EDGE_NONE); + } else { + backEvent = new BackEvent(0, 0, 0f, BackEvent.EDGE_LEFT); + } + animationCallback.onBackStarted(backEvent); } break; case KeyEvent.ACTION_UP: diff --git a/core/java/android/window/BackEvent.java b/core/java/android/window/BackEvent.java index 23e572fcd577..90fac361c966 100644 --- a/core/java/android/window/BackEvent.java +++ b/core/java/android/window/BackEvent.java @@ -16,6 +16,7 @@ package android.window; +import static com.android.window.flags.Flags.FLAG_PREDICTIVE_BACK_SWIPE_EDGE_NONE_API; import static com.android.window.flags.Flags.FLAG_PREDICTIVE_BACK_TIMESTAMP_API; import static com.android.window.flags.Flags.predictiveBackTimestampApi; @@ -37,11 +38,19 @@ public final class BackEvent { public static final int EDGE_LEFT = 0; /** Indicates that the edge swipe starts from the right edge of the screen */ public static final int EDGE_RIGHT = 1; + /** + * Indicates that the back event was not triggered by an edge swipe back gesture. This applies + * to cases like using the back button in 3-button navigation or pressing a hardware back + * button. + */ + @FlaggedApi(FLAG_PREDICTIVE_BACK_SWIPE_EDGE_NONE_API) + public static final int EDGE_NONE = 2; /** @hide */ @IntDef({ EDGE_LEFT, EDGE_RIGHT, + EDGE_NONE, }) @Retention(RetentionPolicy.SOURCE) public @interface SwipeEdge{} diff --git a/core/java/android/window/flags/windowing_frontend.aconfig b/core/java/android/window/flags/windowing_frontend.aconfig index d15f52c39efa..966e835018f3 100644 --- a/core/java/android/window/flags/windowing_frontend.aconfig +++ b/core/java/android/window/flags/windowing_frontend.aconfig @@ -332,3 +332,11 @@ flag { is_fixed_read_only: true bug: "362938401" } + +flag { + name: "predictive_back_swipe_edge_none_api" + namespace: "systemui" + description: "EDGE_NONE swipeEdge option in BackEvent" + is_fixed_read_only: true + bug: "362938401" +} |