summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/java/android/view/ViewRootImpl.java5
-rw-r--r--core/java/android/view/WindowManager.java6
-rw-r--r--core/java/android/window/BackNavigationInfo.java29
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/back/BackAnimationController.java3
-rw-r--r--libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/back/BackAnimationControllerTest.java3
-rw-r--r--services/core/java/com/android/server/wm/BackNavigationController.java3
6 files changed, 45 insertions, 4 deletions
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index a26150c469fe..d27ed76150ec 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -25,6 +25,7 @@ import static android.os.Trace.TRACE_TAG_VIEW;
import static android.view.Display.DEFAULT_DISPLAY;
import static android.view.Display.INVALID_DISPLAY;
import static android.view.DragEvent.ACTION_DRAG_LOCATION;
+import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_APP_PROGRESS_GENERATION_ALLOWED;
import static android.view.flags.Flags.sensitiveContentPrematureProtectionRemovedFix;
import static android.view.InputDevice.SOURCE_CLASS_NONE;
import static android.view.InsetsSource.ID_IME;
@@ -269,6 +270,7 @@ import com.android.internal.inputmethod.ImeTracing;
import com.android.internal.inputmethod.InputMethodDebug;
import com.android.internal.os.IResultReceiver;
import com.android.internal.os.SomeArgs;
+import com.android.internal.policy.DecorView;
import com.android.internal.policy.PhoneFallbackEventHandler;
import com.android.internal.util.FastPrintWriter;
import com.android.internal.view.BaseSurfaceHolder;
@@ -1564,6 +1566,9 @@ public final class ViewRootImpl implements ViewParent,
pendingInsetsController.replayAndAttach(mInsetsController);
}
}
+ if (mView instanceof DecorView) {
+ mWindowAttributes.privateFlags |= PRIVATE_FLAG_APP_PROGRESS_GENERATION_ALLOWED;
+ }
try {
mOrigWindowType = mWindowAttributes.type;
diff --git a/core/java/android/view/WindowManager.java b/core/java/android/view/WindowManager.java
index 42bf420b9812..6e1c8981eecb 100644
--- a/core/java/android/view/WindowManager.java
+++ b/core/java/android/view/WindowManager.java
@@ -3312,6 +3312,11 @@ public interface WindowManager extends ViewManager {
@UnsupportedAppUsage
public static final int PRIVATE_FLAG_NO_MOVE_ANIMATION = 1 << 6;
+ /** Window flag: the client side view can intercept back progress, so system does not
+ * need to pilfer pointers.
+ * {@hide} */
+ public static final int PRIVATE_FLAG_APP_PROGRESS_GENERATION_ALLOWED = 1 << 7;
+
/** Window flag: a special option intended for system dialogs. When
* this flag is set, the window will demand focus unconditionally when
* it is created.
@@ -3505,6 +3510,7 @@ public interface WindowManager extends ViewManager {
SYSTEM_FLAG_SHOW_FOR_ALL_USERS,
PRIVATE_FLAG_UNRESTRICTED_GESTURE_EXCLUSION,
PRIVATE_FLAG_NO_MOVE_ANIMATION,
+ PRIVATE_FLAG_APP_PROGRESS_GENERATION_ALLOWED,
PRIVATE_FLAG_SYSTEM_ERROR,
PRIVATE_FLAG_OPTIMIZE_MEASURE,
PRIVATE_FLAG_DISABLE_WALLPAPER_TOUCH_EVENTS,
diff --git a/core/java/android/window/BackNavigationInfo.java b/core/java/android/window/BackNavigationInfo.java
index 57bded7ff2a0..59639d04b45b 100644
--- a/core/java/android/window/BackNavigationInfo.java
+++ b/core/java/android/window/BackNavigationInfo.java
@@ -117,6 +117,8 @@ public final class BackNavigationInfo implements Parcelable {
@NonNull
private final Rect mTouchableRegion;
+ private final boolean mAppProgressGenerationAllowed;
+
/**
* Create a new {@link BackNavigationInfo} instance.
*
@@ -132,7 +134,8 @@ public final class BackNavigationInfo implements Parcelable {
boolean isAnimationCallback,
@Nullable CustomAnimationInfo customAnimationInfo,
int letterboxColor,
- @Nullable Rect touchableRegion) {
+ @Nullable Rect touchableRegion,
+ boolean appProgressGenerationAllowed) {
mType = type;
mOnBackNavigationDone = onBackNavigationDone;
mOnBackInvokedCallback = onBackInvokedCallback;
@@ -141,6 +144,7 @@ public final class BackNavigationInfo implements Parcelable {
mCustomAnimationInfo = customAnimationInfo;
mLetterboxColor = letterboxColor;
mTouchableRegion = new Rect(touchableRegion);
+ mAppProgressGenerationAllowed = appProgressGenerationAllowed;
}
private BackNavigationInfo(@NonNull Parcel in) {
@@ -152,6 +156,7 @@ public final class BackNavigationInfo implements Parcelable {
mCustomAnimationInfo = in.readTypedObject(CustomAnimationInfo.CREATOR);
mLetterboxColor = in.readInt();
mTouchableRegion = in.readTypedObject(Rect.CREATOR);
+ mAppProgressGenerationAllowed = in.readBoolean();
}
/** @hide */
@@ -165,6 +170,7 @@ public final class BackNavigationInfo implements Parcelable {
dest.writeTypedObject(mCustomAnimationInfo, flags);
dest.writeInt(mLetterboxColor);
dest.writeTypedObject(mTouchableRegion, flags);
+ dest.writeBoolean(mAppProgressGenerationAllowed);
}
/**
@@ -224,6 +230,14 @@ public final class BackNavigationInfo implements Parcelable {
}
/**
+ * @return The client side view is able to intercept back progress event.
+ * @hide
+ */
+ public boolean isAppProgressGenerationAllowed() {
+ return mAppProgressGenerationAllowed;
+ }
+
+ /**
* Callback to be called when the back preview is finished in order to notify the server that
* it can clean up the resources created for the animation.
* @hide
@@ -420,6 +434,7 @@ public final class BackNavigationInfo implements Parcelable {
private int mLetterboxColor = Color.TRANSPARENT;
private Rect mTouchableRegion;
+ private boolean mAppProgressGenerationAllowed;
/**
* @see BackNavigationInfo#getType()
@@ -502,6 +517,15 @@ public final class BackNavigationInfo implements Parcelable {
mTouchableRegion = new Rect(rect);
return this;
}
+
+ /**
+ * @param allowed Whether client side view able to intercept back progress event.
+ */
+ public Builder setAppProgressAllowed(boolean allowed) {
+ mAppProgressGenerationAllowed = allowed;
+ return this;
+ }
+
/**
* Builds and returns an instance of {@link BackNavigationInfo}
*/
@@ -512,7 +536,8 @@ public final class BackNavigationInfo implements Parcelable {
mAnimationCallback,
mCustomAnimationInfo,
mLetterboxColor,
- mTouchableRegion);
+ mTouchableRegion,
+ mAppProgressGenerationAllowed);
}
}
}
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/back/BackAnimationController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/back/BackAnimationController.java
index 0fd21f3798ac..7041ea307b0f 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/back/BackAnimationController.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/back/BackAnimationController.java
@@ -437,7 +437,8 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont
}
private boolean isAppProgressGenerationAllowed() {
- return mBackNavigationInfo.getTouchableRegion().equals(mTouchableArea);
+ return mBackNavigationInfo.isAppProgressGenerationAllowed()
+ && mBackNavigationInfo.getTouchableRegion().equals(mTouchableArea);
}
/**
diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/back/BackAnimationControllerTest.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/back/BackAnimationControllerTest.java
index 1903586fc317..57e469d5cbd2 100644
--- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/back/BackAnimationControllerTest.java
+++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/back/BackAnimationControllerTest.java
@@ -550,7 +550,8 @@ public class BackAnimationControllerTest extends ShellTestCase {
.setType(type)
.setOnBackInvokedCallback(mAppCallback)
.setOnBackNavigationDone(new RemoteCallback(result))
- .setTouchableRegion(mTouchableRegion));
+ .setTouchableRegion(mTouchableRegion)
+ .setAppProgressAllowed(true));
triggerBackGesture();
mShellExecutor.flushAll();
releaseBackGesture();
diff --git a/services/core/java/com/android/server/wm/BackNavigationController.java b/services/core/java/com/android/server/wm/BackNavigationController.java
index 0febec9169c0..e48649fe802e 100644
--- a/services/core/java/com/android/server/wm/BackNavigationController.java
+++ b/services/core/java/com/android/server/wm/BackNavigationController.java
@@ -19,6 +19,7 @@ package com.android.server.wm;
import static android.app.ActivityTaskManager.INVALID_TASK_ID;
import static android.view.RemoteAnimationTarget.MODE_CLOSING;
import static android.view.RemoteAnimationTarget.MODE_OPENING;
+import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_APP_PROGRESS_GENERATION_ALLOWED;
import static android.view.WindowManager.LayoutParams.TYPE_BASE_APPLICATION;
import static android.view.WindowManager.TRANSIT_CHANGE;
import static android.view.WindowManager.TRANSIT_CLOSE;
@@ -201,6 +202,8 @@ class BackNavigationController {
infoBuilder.setOnBackInvokedCallback(callbackInfo.getCallback());
infoBuilder.setAnimationCallback(callbackInfo.isAnimationCallback());
infoBuilder.setTouchableRegion(window.getFrame());
+ infoBuilder.setAppProgressAllowed((window.getAttrs().privateFlags
+ & PRIVATE_FLAG_APP_PROGRESS_GENERATION_ALLOWED) != 0);
mNavigationMonitor.startMonitor(window, navigationObserver);
ProtoLog.d(WM_DEBUG_BACK_PREVIEW, "startBackNavigation currentTask=%s, "