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

Commit 9a230e01 authored by Dianne Hackborn's avatar Dianne Hackborn
Browse files

Fix issue #5371530: SYSTEMUI_FLAG_HIDE_NAVIGATION reasserts itself immediately

This cleans up how ui flags are managed between the client and window manager.
It still reports the global UI mode state to the callback, but we now only clear
certain flags when the system goes out of a state (currently this just means the
hide nav bar mode), and don't corrupt other flags in the application when the
global state changes.

Also introduces a sequence number between the app and window manager, to avoid
using bad old data coming from the app during these transitions.

Change-Id: I40bbd12d9b7b69fc0ff1c7dc0cb58a933d4dfb23
parent fe7fcd23
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -565,7 +565,7 @@ public abstract class WallpaperService extends Service {
                        mLayout.windowAnimations =
                                com.android.internal.R.style.Animation_Wallpaper;
                        mInputChannel = new InputChannel();
                        if (mSession.add(mWindow, mLayout, View.VISIBLE, mContentInsets,
                        if (mSession.add(mWindow, mWindow.mSeq, mLayout, View.VISIBLE, mContentInsets,
                                mInputChannel) < 0) {
                            Log.w(TAG, "Failed to add window while updating wallpaper surface.");
                            return;
@@ -580,7 +580,7 @@ public abstract class WallpaperService extends Service {
                    mDrawingAllowed = true;

                    final int relayoutResult = mSession.relayout(
                        mWindow, mLayout, mWidth, mHeight,
                        mWindow, mWindow.mSeq, mLayout, mWidth, mHeight,
                            View.VISIBLE, false, mWinFrame, mContentInsets,
                            mVisibleInsets, mConfiguration, mSurfaceHolder.mSurface);

+2 −1
Original line number Diff line number Diff line
@@ -74,5 +74,6 @@ oneway interface IWindow {
    /**
     * System chrome visibility changes
     */
     void dispatchSystemUiVisibilityChanged(int visibility);
     void dispatchSystemUiVisibilityChanged(int seq, int globalVisibility,
            int localValue, int localChanges);
}
+4 −3
Original line number Diff line number Diff line
@@ -34,10 +34,10 @@ import android.view.Surface;
 * {@hide}
 */
interface IWindowSession {
    int add(IWindow window, in WindowManager.LayoutParams attrs,
    int add(IWindow window, int seq, in WindowManager.LayoutParams attrs,
            in int viewVisibility, out Rect outContentInsets,
            out InputChannel outInputChannel);
    int addWithoutInputChannel(IWindow window, in WindowManager.LayoutParams attrs,
    int addWithoutInputChannel(IWindow window, int seq, in WindowManager.LayoutParams attrs,
            in int viewVisibility, out Rect outContentInsets);
    void remove(IWindow window);
    
@@ -49,6 +49,7 @@ interface IWindowSession {
     * to draw the window's contents.
     * 
     * @param window The window being modified.
     * @param seq Ordering sequence number.
     * @param attrs If non-null, new attributes to apply to the window.
     * @param requestedWidth The width the window wants to be.
     * @param requestedHeight The height the window wants to be.
@@ -77,7 +78,7 @@ interface IWindowSession {
     * @return int Result flags: {@link WindowManagerImpl#RELAYOUT_SHOW_FOCUS},
     * {@link WindowManagerImpl#RELAYOUT_FIRST_TIME}.
     */
    int relayout(IWindow window, in WindowManager.LayoutParams attrs,
    int relayout(IWindow window, int seq, in WindowManager.LayoutParams attrs,
            int requestedWidth, int requestedHeight, int viewVisibility,
            boolean insetsPending, out Rect outFrame, out Rect outContentInsets,
            out Rect outVisibleInsets, out Configuration outConfig,
+3 −3
Original line number Diff line number Diff line
@@ -266,7 +266,7 @@ public class SurfaceView extends View {
            try {
                DisplayMetrics metrics = getResources().getDisplayMetrics();
                mLayout.x = metrics.widthPixels * 3;
                mSession.relayout(mWindow, mLayout, mWidth, mHeight, VISIBLE, false,
                mSession.relayout(mWindow, mWindow.mSeq, mLayout, mWidth, mHeight, VISIBLE, false,
                        mWinFrame, mContentInsets, mVisibleInsets, mConfiguration, mSurface);
            } catch (RemoteException e) {
                // Ignore
@@ -492,7 +492,7 @@ public class SurfaceView extends View {
                    mWindow = new MyWindow(this);
                    mLayout.type = mWindowType;
                    mLayout.gravity = Gravity.LEFT|Gravity.TOP;
                    mSession.addWithoutInputChannel(mWindow, mLayout,
                    mSession.addWithoutInputChannel(mWindow, mWindow.mSeq, mLayout,
                            mVisible ? VISIBLE : GONE, mContentInsets);
                }
                
@@ -513,7 +513,7 @@ public class SurfaceView extends View {
                    mDrawingStopped = !visible;
    
                    final int relayoutResult = mSession.relayout(
                        mWindow, mLayout, mWidth, mHeight,
                        mWindow, mWindow.mSeq, mLayout, mWidth, mHeight,
                            visible ? VISIBLE : GONE, false, mWinFrame, mContentInsets,
                            mVisibleInsets, mConfiguration, mSurface);
                    if ((relayoutResult&WindowManagerImpl.RELAYOUT_FIRST_TIME) != 0) {
+28 −2
Original line number Diff line number Diff line
@@ -1924,6 +1924,15 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
     */
    public static final int PUBLIC_STATUS_BAR_VISIBILITY_MASK = 0x0000FFFF;
    /**
     * These are the system UI flags that can be cleared by events outside
     * of an application.  Currently this is just the ability to tap on the
     * screen while hiding the navigation bar to have it return.
     * @hide
     */
    public static final int SYSTEM_UI_CLEARABLE_FLAGS =
            SYSTEM_UI_FLAG_LOW_PROFILE | SYSTEM_UI_FLAG_HIDE_NAVIGATION;
    /**
     * Find views that render the specified text.
     *
@@ -13027,6 +13036,8 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
    }
    /**
     * Dispatch callbacks to {@link #setOnSystemUiVisibilityChangeListener} down
     * the view hierarchy.
     */
    public void dispatchSystemUiVisibilityChanged(int visibility) {
        if (mOnSystemUiVisibilityChangeListener != null) {
@@ -13035,6 +13046,13 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
        }
    }
    void updateLocalSystemUiVisibility(int localValue, int localChanges) {
        int val = (mSystemUiVisibility&~localChanges) | (localValue&localChanges);
        if (val != mSystemUiVisibility) {
            setSystemUiVisibility(val);
        }
    }
    /**
     * Creates an image that the system displays during the drag and drop
     * operation. This is called a &quot;drag shadow&quot;. The default implementation
@@ -14108,7 +14126,8 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
    /**
     * Interface definition for a callback to be invoked when the status bar changes
     * visibility.
     * visibility.  This reports <strong>global</strong> changes to the system UI
     * state, not just what the application is requesting.
     *
     * @see View#setOnSystemUiVisibilityChangeListener(android.view.View.OnSystemUiVisibilityChangeListener) 
     */
@@ -14118,7 +14137,9 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
         * {@link View#setSystemUiVisibility(int)}.
         *
         * @param visibility  Bitwise-or of flags {@link #SYSTEM_UI_FLAG_LOW_PROFILE} or
         * {@link #SYSTEM_UI_FLAG_HIDE_NAVIGATION}.
         * {@link #SYSTEM_UI_FLAG_HIDE_NAVIGATION}.  This tells you the
         * <strong>global</strong> state of the UI visibility flags, not what your
         * app is currently applying.
         */
        public void onSystemUiVisibilityChange(int visibility);
    }
@@ -14375,6 +14396,11 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
         */
        boolean mRecomputeGlobalAttributes;
        /**
         * Always report new attributes at next traversal.
         */
        boolean mForceReportNewAttributes;
        /**
         * Set during a traveral if any views want to keep the screen on.
         */
Loading