Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 327664f3 authored by Wei Sheng Shih's avatar Wei Sheng Shih Committed by Android (Google) Code Review
Browse files

Merge "Only let app generate progress when client side using DecorView" into main

parents 7e8de9ce 77cdcfaf
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -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;
@@ -271,6 +272,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;
@@ -1576,6 +1578,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;
+6 −0
Original line number Diff line number Diff line
@@ -3307,6 +3307,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.
@@ -3500,6 +3505,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,
+27 −2
Original line number Diff line number Diff line
@@ -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);
    }

    /**
@@ -223,6 +229,14 @@ public final class BackNavigationInfo implements Parcelable {
        return mTouchableRegion;
    }

    /**
     * @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.
@@ -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);
        }
    }
}
+2 −1
Original line number Diff line number Diff line
@@ -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);
    }

    /**
+2 −1
Original line number Diff line number Diff line
@@ -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();
Loading