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

Commit abcfb326 authored by Charles Chen's avatar Charles Chen Committed by Android (Google) Code Review
Browse files

Merge "Remove the enable_window_context_override_type flag" into main

parents be5b3518 b7effa88
Loading
Loading
Loading
Loading
+22 −30
Original line number Diff line number Diff line
@@ -60,8 +60,6 @@ import android.view.View.OnApplyWindowInsetsListener;
import android.view.accessibility.AccessibilityEvent;
import android.window.OnBackInvokedDispatcher;

import com.android.window.flags.Flags;

import java.util.Collections;
import java.util.List;

@@ -334,7 +332,6 @@ public abstract class Window {
    private boolean mDestroyed;

    private boolean mOverlayWithDecorCaptionEnabled = true;
    private boolean mCloseOnSwipeEnabled = false;

    /**
     * To check if toolkitSetFrameRateReadOnly flag is enabled
@@ -364,7 +361,7 @@ public abstract class Window {
         *
         * @return boolean Return true if this event was consumed.
         */
        public boolean dispatchKeyEvent(KeyEvent event);
        boolean dispatchKeyEvent(KeyEvent event);

        /**
         * Called to process a key shortcut event.
@@ -375,7 +372,7 @@ public abstract class Window {
         * @param event The key shortcut event.
         * @return True if this event was consumed.
         */
        public boolean dispatchKeyShortcutEvent(KeyEvent event);
        boolean dispatchKeyShortcutEvent(KeyEvent event);

        /**
         * Called to process touch screen events.  At the very least your
@@ -387,7 +384,7 @@ public abstract class Window {
         *
         * @return boolean Return true if this event was consumed.
         */
        public boolean dispatchTouchEvent(MotionEvent event);
        boolean dispatchTouchEvent(MotionEvent event);

        /**
         * Called to process trackball events.  At the very least your
@@ -399,7 +396,7 @@ public abstract class Window {
         *
         * @return boolean Return true if this event was consumed.
         */
        public boolean dispatchTrackballEvent(MotionEvent event);
        boolean dispatchTrackballEvent(MotionEvent event);

        /**
         * Called to process generic motion events.  At the very least your
@@ -411,7 +408,7 @@ public abstract class Window {
         *
         * @return boolean Return true if this event was consumed.
         */
        public boolean dispatchGenericMotionEvent(MotionEvent event);
        boolean dispatchGenericMotionEvent(MotionEvent event);

        /**
         * Called to process population of {@link AccessibilityEvent}s.
@@ -420,7 +417,7 @@ public abstract class Window {
         *
         * @return boolean Return true if event population was completed.
         */
        public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event);
        boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event);

        /**
         * Instantiate the view to display in the panel for 'featureId'.
@@ -434,7 +431,7 @@ public abstract class Window {
         * @see #onPreparePanel
         */
        @Nullable
        public View onCreatePanelView(int featureId);
        View onCreatePanelView(int featureId);

        /**
         * Initialize the contents of the menu for panel 'featureId'.  This is
@@ -498,7 +495,7 @@ public abstract class Window {
         * This is called whenever the current window attributes change.
         *
         */
        public void onWindowAttributesChanged(WindowManager.LayoutParams attrs);
        void onWindowAttributesChanged(WindowManager.LayoutParams attrs);

        /**
         * This hook is called whenever the content view of the screen changes
@@ -508,7 +505,7 @@ public abstract class Window {
         * {@link Window#addContentView(View, android.view.ViewGroup.LayoutParams)
         * Window.addContentView}).
         */
        public void onContentChanged();
        void onContentChanged();

        /**
         * This hook is called whenever the window focus changes.  See
@@ -517,21 +514,21 @@ public abstract class Window {
         *
         * @param hasFocus Whether the window now has focus.
         */
        public void onWindowFocusChanged(boolean hasFocus);
        void onWindowFocusChanged(boolean hasFocus);

        /**
         * Called when the window has been attached to the window manager.
         * See {@link View#onAttachedToWindow() View.onAttachedToWindow()}
         * for more information.
         */
        public void onAttachedToWindow();
        void onAttachedToWindow();

        /**
         * Called when the window has been detached from the window manager.
         * See {@link View#onDetachedFromWindow() View.onDetachedFromWindow()}
         * for more information.
         */
        public void onDetachedFromWindow();
        void onDetachedFromWindow();

        /**
         * Called when a panel is being closed.  If another logical subsequent
@@ -551,7 +548,7 @@ public abstract class Window {
         *
         * @see android.app.Activity#onSearchRequested()
         */
        public boolean onSearchRequested();
        boolean onSearchRequested();

        /**
         * Called when the user signals the desire to start a search.
@@ -560,7 +557,7 @@ public abstract class Window {
         *                   start a search.
         * @return true if search launched, false if activity refuses (blocks)
         */
        public boolean onSearchRequested(SearchEvent searchEvent);
        boolean onSearchRequested(SearchEvent searchEvent);

        /**
         * Called when an action mode is being started for this window. Gives the
@@ -574,7 +571,7 @@ public abstract class Window {
         * @return The ActionMode that was started, or null if the system should present it
         */
        @Nullable
        public ActionMode onWindowStartingActionMode(ActionMode.Callback callback);
        ActionMode onWindowStartingActionMode(ActionMode.Callback callback);

        /**
         * Called when an action mode is being started for this window. Gives the
@@ -587,7 +584,7 @@ public abstract class Window {
         * @return The ActionMode that was started, or null if the system should present it
         */
        @Nullable
        public ActionMode onWindowStartingActionMode(ActionMode.Callback callback, int type);
        ActionMode onWindowStartingActionMode(ActionMode.Callback callback, int type);

        /**
         * Called when an action mode has been started. The appropriate mode callback
@@ -595,7 +592,7 @@ public abstract class Window {
         *
         * @param mode The new mode that has just been started.
         */
        public void onActionModeStarted(ActionMode mode);
        void onActionModeStarted(ActionMode mode);

        /**
         * Called when an action mode has been finished. The appropriate mode callback
@@ -603,7 +600,7 @@ public abstract class Window {
         *
         * @param mode The mode that was just finished.
         */
        public void onActionModeFinished(ActionMode mode);
        void onActionModeFinished(ActionMode mode);

        /**
         * Called when Keyboard Shortcuts are requested for the current window.
@@ -612,15 +609,15 @@ public abstract class Window {
         * @param menu The current menu, which may be null.
         * @param deviceId The id for the connected device the shortcuts should be provided for.
         */
        default public void onProvideKeyboardShortcuts(
                List<KeyboardShortcutGroup> data, @Nullable Menu menu, int deviceId) { };
        default void onProvideKeyboardShortcuts(
                List<KeyboardShortcutGroup> data, @Nullable Menu menu, int deviceId) { }

        /**
         * Called when pointer capture is enabled or disabled for the current window.
         *
         * @param hasCapture True if the window has pointer capture.
         */
        default public void onPointerCaptureChanged(boolean hasCapture) { };
        default void onPointerCaptureChanged(boolean hasCapture) { }
    }

    /** @hide */
@@ -931,8 +928,6 @@ public abstract class Window {
            @Nullable String appName,
            boolean hardwareAccelerated,
            boolean createLocalWindowManager) {
        // If the flag is not enabled, we can only create a new instance of WindowManager.
        createLocalWindowManager |= !Flags.enableWindowContextOverrideType();
        mAppToken = appToken;
        mAppName = appName;
        mHardwareAccelerated = hardwareAccelerated;
@@ -1709,10 +1704,7 @@ public abstract class Window {
        final boolean isOutside =
                event.getAction() == MotionEvent.ACTION_UP && isOutOfBounds(context, event)
                || event.getAction() == MotionEvent.ACTION_OUTSIDE;
        if (mCloseOnTouchOutside && peekDecorView() != null && isOutside) {
            return true;
        }
        return false;
        return mCloseOnTouchOutside && peekDecorView() != null && isOutside;
    }

    /* Sets the Sustained Performance requirement for the calling window.
+1 −6
Original line number Diff line number Diff line
@@ -49,7 +49,6 @@ import android.window.WindowProvider;
import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.os.IResultReceiver;
import com.android.window.flags.Flags;

import java.util.ArrayList;
import java.util.Iterator;
@@ -177,10 +176,9 @@ public final class WindowManagerImpl implements WindowManager {
    }

    private void applyTokens(@NonNull ViewGroup.LayoutParams params) {
        if (!(params instanceof WindowManager.LayoutParams)) {
        if (!(params instanceof LayoutParams wparams)) {
            throw new IllegalArgumentException("Params must be WindowManager.LayoutParams");
        }
        final WindowManager.LayoutParams wparams = (WindowManager.LayoutParams) params;
        assertWindowContextTypeMatches(wparams.type);
        // Only use the default token if we don't have a parent window and a token.
        if (mDefaultToken != null && mParentWindow == null && wparams.token == null) {
@@ -214,9 +212,6 @@ public final class WindowManagerImpl implements WindowManager {
    private void applyWindowTypeOverrideIfNeeded(
            @NonNull ViewGroup.LayoutParams params,
            @NonNull View view) {
        if (!Flags.enableWindowContextOverrideType()) {
            return;
        }
        if (!(params instanceof WindowManager.LayoutParams wparams)) {
            throw new IllegalArgumentException("Params must be WindowManager.LayoutParams");
        }
+1 −7
Original line number Diff line number Diff line
@@ -65,7 +65,7 @@ public class WindowContext extends ContextWrapper implements WindowProvider,
            new ComponentCallbacksController();
    private final WindowContextController mController;

    private WindowManager mWindowManager;
    private final WindowManager mWindowManager;

    private Window mWindow;

@@ -203,9 +203,6 @@ public class WindowContext extends ContextWrapper implements WindowProvider,
     *     window type mentioned above.
     */
    public void setWindowTypeOverride(@WindowType int windowTypeOverride) {
        if (!Flags.enableWindowContextOverrideType()) {
            return;
        }
        if (!isValidWindowType(windowTypeOverride) && windowTypeOverride != INVALID_WINDOW_TYPE) {
            throw new IllegalArgumentException(
                    "The window type override must be either "
@@ -231,9 +228,6 @@ public class WindowContext extends ContextWrapper implements WindowProvider,
     * @throws IllegalStateException if window has been attached.
     */
    public void attachWindow(@NonNull View window) {
        if (!Flags.enableWindowContextOverrideType()) {
            return;
        }
        if (mWindow != null) {
            throw new IllegalStateException(
                    "This WindowContext has already attached a window. Window=" + mWindow
+0 −11
Original line number Diff line number Diff line
@@ -82,17 +82,6 @@ flag {
    bug: "399465821"
}

flag {
    namespace: "windowing_sdk"
    name: "enable_window_context_override_type"
    description: "Enable WindowContext to attach parent window and override window type"
    bug: "398759994"
    is_fixed_read_only: true
    metadata {
        purpose: PURPOSE_BUGFIX
    }
}

flag {
    namespace: "windowing_sdk"
    name: "enable_experimental_bubbles_controller"
+1 −9
Original line number Diff line number Diff line
@@ -414,7 +414,6 @@ public class WindowContextTest {
        );
    }

    @EnableFlags(Flags.FLAG_ENABLE_WINDOW_CONTEXT_OVERRIDE_TYPE)
    @Test
    public void testAttachWindow() throws InterruptedException {
        final View window = new View(mWindowContext);
@@ -441,7 +440,6 @@ public class WindowContextTest {
        assertThat(subWindowParams.token).isEqualTo(window.getWindowToken());
    }

    @EnableFlags(Flags.FLAG_ENABLE_WINDOW_CONTEXT_OVERRIDE_TYPE)
    @Test
    public void testSetWindowTypeOverride() {
        int windowType = INVALID_WINDOW_TYPE;
@@ -461,7 +459,6 @@ public class WindowContextTest {
                () -> mWindowContext.setWindowTypeOverride(invalidType));
    }

    @EnableFlags(Flags.FLAG_ENABLE_WINDOW_CONTEXT_OVERRIDE_TYPE)
    @Test
    public void testSetWindowTypeOverrideAndAddView_invalidWindowType_noOverride() {
        WindowManager.LayoutParams params =
@@ -473,7 +470,6 @@ public class WindowContextTest {
        assertThat(params.type).isEqualTo(TYPE_APPLICATION_OVERLAY);
    }

    @EnableFlags(Flags.FLAG_ENABLE_WINDOW_CONTEXT_OVERRIDE_TYPE)
    @Test
    public void testSetWindowTypeOverrideAndAddView_windowContextType_override() {
        int windowType = mWindowContext.getWindowType();
@@ -485,7 +481,6 @@ public class WindowContextTest {
        assertThat(params.type).isEqualTo(windowType);
    }

    @EnableFlags(Flags.FLAG_ENABLE_WINDOW_CONTEXT_OVERRIDE_TYPE)
    @Test
    public void testSetWindowTypeOverrideAndAddView_subWindowWithoutParentWindow_throwException() {
        WindowManager.LayoutParams params = new WindowManager.LayoutParams();
@@ -497,7 +492,6 @@ public class WindowContextTest {
                        wm.addView(new View(mWindowContext), params)));
    }

    @EnableFlags(Flags.FLAG_ENABLE_WINDOW_CONTEXT_OVERRIDE_TYPE)
    @Test
    public void testSetWindowTypeOverrideAndAddView_subWindowWithParentWindow_override()
            throws InterruptedException {
@@ -519,7 +513,6 @@ public class WindowContextTest {
        assertThat(params.type).isEqualTo(TYPE_APPLICATION_ATTACHED_DIALOG);
    }

    @EnableFlags(Flags.FLAG_ENABLE_WINDOW_CONTEXT_OVERRIDE_TYPE)
    @Test
    public void testSetWindowTypeOverrideAndUpdateLayout_diffType_noOverride() {
        final View view = new View(mWindowContext);
@@ -537,7 +530,6 @@ public class WindowContextTest {
        assertThat(params.type).isEqualTo(TYPE_APPLICATION_OVERLAY);
    }

    @EnableFlags(Flags.FLAG_ENABLE_WINDOW_CONTEXT_OVERRIDE_TYPE)
    @Test
    public void testBuildInteractionJankMonitorConfigWithWindowAttached_notCrash() {
        final ApplicationInfo appInfo = mWindowContext.getApplicationInfo();
@@ -668,7 +660,7 @@ public class WindowContextTest {

    private static class ConfigurationListener implements ComponentCallbacks {
        private Configuration mConfiguration;
        private CountDownLatch mLatch = new CountDownLatch(1);
        private final CountDownLatch mLatch = new CountDownLatch(1);

        @Override
        public void onConfigurationChanged(@NonNull Configuration newConfig) {
Loading