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

Commit 24e7a9fd authored by Charles Chen's avatar Charles Chen
Browse files

Make some IStatusBar APIs support multi-display(1/N)

In this CL, we add parameter displayId in some IStatusBar APIs and also
group flags into an inner class and make it exist per display.

TODO: 1. We left SystemUi implementation in later CL.
      2. Investigate which part of disable should support multi-display
         after main function completes.
      3. Refactor registerStatusBar as an IStatusBar API.
Note: remove mLightsOutListener in NavigationBarTransitions since no one uses it.

Test: atest SystemUITests
Bug: 117478341

Change-Id: Ie50a72f5d18e1f055ff2be4f1d7ac06da0117051
parent 33793f62
Loading
Loading
Loading
Loading
+25 −16
Original line number Diff line number Diff line
@@ -29,7 +29,7 @@ oneway interface IStatusBar
{
    void setIcon(String slot, in StatusBarIcon icon);
    void removeIcon(String slot);
    void disable(int state1, int state2);
    void disable(int displayId, int state1, int state2);
    void animateExpandNotificationsPanel();
    void animateExpandSettingsPanel(String subPanel);
    void animateCollapsePanels();
@@ -38,8 +38,9 @@ oneway interface IStatusBar
    void showWirelessChargingAnimation(int batteryLevel);

    /**
     * Notifies the status bar of a System UI visibility flag change.
     * Notifies System UI side of a visibility flag change on the specified display.
     *
     * @param displayId the id of the display to notify
     * @param vis the visibility flags except SYSTEM_UI_FLAG_LIGHT_STATUS_BAR which will be reported
     *            separately in fullscreenStackVis and dockedStackVis
     * @param fullscreenStackVis the flags which only apply in the region of the fullscreen stack,
@@ -50,13 +51,13 @@ oneway interface IStatusBar
     * @param fullscreenBounds the current bounds of the fullscreen stack, in screen coordinates
     * @param dockedBounds the current bounds of the docked stack, in screen coordinates
     */
    void setSystemUiVisibility(int vis, int fullscreenStackVis, int dockedStackVis, int mask,
            in Rect fullscreenBounds, in Rect dockedBounds);
    void setSystemUiVisibility(int displayId, int vis, int fullscreenStackVis, int dockedStackVis,
            int mask, in Rect fullscreenBounds, in Rect dockedBounds);

    void topAppWindowChanged(boolean menuVisible);
    void setImeWindowStatus(in IBinder token, int vis, int backDisposition,
    void topAppWindowChanged(int displayId, boolean menuVisible);
    void setImeWindowStatus(int displayId, in IBinder token, int vis, int backDisposition,
            boolean showImeSwitcher);
    void setWindowState(int window, int state);
    void setWindowState(int display, int window, int state);

    void showRecentApps(boolean triggeredFromAltTab);
    void hideRecentApps(boolean triggeredFromAltTab, boolean triggeredFromHomeKey);
@@ -70,30 +71,38 @@ oneway interface IStatusBar
    void toggleKeyboardShortcutsMenu(int deviceId);

    /**
     * Notifies the status bar that an app transition is pending to delay applying some flags with
     * visual impact until {@link #appTransitionReady} is called.
     * Notifies System UI on the specified display that an app transition is pending to delay
     * applying some flags with visual impact until {@link #appTransitionReady} is called.
     *
     * @param displayId the id of the display to notify
     */
    void appTransitionPending();
    void appTransitionPending(int displayId);

    /**
     * Notifies the status bar that a pending app transition has been cancelled.
     * Notifies System UI on the specified display that a pending app transition has been cancelled.
     *
     * @param displayId the id of the display to notify
     */
    void appTransitionCancelled();
    void appTransitionCancelled(int displayId);

    /**
     * Notifies the status bar that an app transition is now being executed.
     * Notifies System UI on the specified display that an app transition is now being executed.
     *
     * @param displayId the id of the display to notify
     * @param statusBarAnimationsStartTime the desired start time for all visual animations in the
     *        status bar caused by this app transition in uptime millis
     * @param statusBarAnimationsDuration the duration for all visual animations in the status
     *        bar caused by this app transition in millis
     */
    void appTransitionStarting(long statusBarAnimationsStartTime, long statusBarAnimationsDuration);
    void appTransitionStarting(int displayId, long statusBarAnimationsStartTime,
            long statusBarAnimationsDuration);

    /**
     * Notifies the status bar that an app transition is done.
     * Notifies System UI on the specified display that an app transition is done.
     *
     * @param displayId the id of the display to notify
     */
    void appTransitionFinished();
    void appTransitionFinished(int displayId);

    void showAssistDisclosure();
    void startAssist(in Bundle args);
+2 −1
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@ interface IStatusBarService
    void setIcon(String slot, String iconPackage, int iconId, int iconLevel, String contentDescription);
    void setIconVisibility(String slot, boolean visible);
    void removeIcon(String slot);
    // TODO(b/117478341): support back button change when IME is showing on a external display.
    void setImeWindowStatus(in IBinder token, int vis, int backDisposition,
            boolean showImeSwitcher);
    void expandSettingsPanel(String subPanel);
@@ -69,7 +70,7 @@ interface IStatusBarService
    void onNotificationSmartRepliesAdded(in String key, in int replyCount);
    void onNotificationSmartReplySent(in String key, in int replyIndex, in CharSequence reply, boolean generatedByAssistant);
    void onNotificationSettingsViewed(String key);
    void setSystemUiVisibility(int vis, int mask, String cause);
    void setSystemUiVisibility(int displayId, int vis, int mask, String cause);

    void onGlobalActionsShown();
    void onGlobalActionsHidden();
+27 −10
Original line number Diff line number Diff line
@@ -223,7 +223,9 @@ public class CommandQueue extends IStatusBar.Stub {
        }
    }

    public void disable(int state1, int state2) {
    // TODO(b/117478341): Add multi-display support.
    @Override
    public void disable(int displayId, int state1, int state2) {
        disable(state1, state2, true);
    }

@@ -266,8 +268,10 @@ public class CommandQueue extends IStatusBar.Stub {
        }
    }

    public void setSystemUiVisibility(int vis, int fullscreenStackVis, int dockedStackVis,
            int mask, Rect fullscreenStackBounds, Rect dockedStackBounds) {
    // TODO(b/117478341): Add multi-display support.
    @Override
    public void setSystemUiVisibility(int displayId, int vis, int fullscreenStackVis,
            int dockedStackVis, int mask, Rect fullscreenStackBounds, Rect dockedStackBounds) {
        synchronized (mLock) {
            // Don't coalesce these, since it might have one time flags set such as
            // STATUS_BAR_UNHIDE which might get lost.
@@ -282,7 +286,9 @@ public class CommandQueue extends IStatusBar.Stub {
        }
    }

    public void topAppWindowChanged(boolean menuVisible) {
    // TODO(b/117478341): Add multi-display support.
    @Override
    public void topAppWindowChanged(int displayId, boolean menuVisible) {
        synchronized (mLock) {
            mHandler.removeMessages(MSG_TOP_APP_WINDOW_CHANGED);
            mHandler.obtainMessage(MSG_TOP_APP_WINDOW_CHANGED, menuVisible ? 1 : 0, 0,
@@ -290,7 +296,9 @@ public class CommandQueue extends IStatusBar.Stub {
        }
    }

    public void setImeWindowStatus(IBinder token, int vis, int backDisposition,
    // TODO(b/117478341): Add multi-display support.
    @Override
    public void setImeWindowStatus(int displayId, IBinder token, int vis, int backDisposition,
            boolean showImeSwitcher) {
        synchronized (mLock) {
            mHandler.removeMessages(MSG_SHOW_IME_BUTTON);
@@ -371,7 +379,9 @@ public class CommandQueue extends IStatusBar.Stub {
        }
    }

    public void setWindowState(int window, int state) {
    // TODO(b/117478341): Add multi-display support.
    @Override
    public void setWindowState(int displayId, int window, int state) {
        synchronized (mLock) {
            // don't coalesce these
            mHandler.obtainMessage(MSG_SET_WINDOW_STATE, window, state, null).sendToTarget();
@@ -385,7 +395,9 @@ public class CommandQueue extends IStatusBar.Stub {
        }
    }

    public void appTransitionPending() {
    // TODO(b/117478341): Add multi-display support.
    @Override
    public void appTransitionPending(int displayId) {
        appTransitionPending(false /* forced */);
    }

@@ -395,13 +407,17 @@ public class CommandQueue extends IStatusBar.Stub {
        }
    }

    public void appTransitionCancelled() {
    // TODO(b/117478341): Add multi-display support.
    @Override
    public void appTransitionCancelled(int displayId) {
        synchronized (mLock) {
            mHandler.sendEmptyMessage(MSG_APP_TRANSITION_CANCELLED);
        }
    }

    public void appTransitionStarting(long startTime, long duration) {
    // TODO(b/117478341): Add multi-display support.
    @Override
    public void appTransitionStarting(int displayId, long startTime, long duration) {
        appTransitionStarting(startTime, duration, false /* forced */);
    }

@@ -412,8 +428,9 @@ public class CommandQueue extends IStatusBar.Stub {
        }
    }

    // TODO(b/117478341): Add multi-display support.
    @Override
    public void appTransitionFinished() {
    public void appTransitionFinished(int displayId) {
        synchronized (mLock) {
            mHandler.sendEmptyMessage(MSG_APP_TRANSITION_FINISHED);
        }
+0 −20
Original line number Diff line number Diff line
@@ -24,7 +24,6 @@ import android.util.SparseArray;
import android.view.Display;
import android.view.IWallpaperVisibilityListener;
import android.view.IWindowManager;
import android.view.MotionEvent;
import android.view.View;

import com.android.internal.statusbar.IStatusBarService;
@@ -165,23 +164,4 @@ public final class NavigationBarTransitions extends BarTransitions {
        }
        mView.onDarkIntensityChange(darkIntensity);
    }

    private final View.OnTouchListener mLightsOutListener = new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent ev) {
            if (ev.getAction() == MotionEvent.ACTION_DOWN) {
                // even though setting the systemUI visibility below will turn these views
                // on, we need them to come up faster so that they can catch this motion
                // event
                applyLightsOut(false, false, false);

                try {
                    mBarService.setSystemUiVisibility(0, View.SYSTEM_UI_FLAG_LOW_PROFILE,
                            "LightsOutListener");
                } catch (android.os.RemoteException ex) {
                }
            }
            return false;
        }
    };
}
+20 −9
Original line number Diff line number Diff line
@@ -14,6 +14,8 @@

package com.android.systemui.statusbar;

import static android.view.Display.DEFAULT_DISPLAY;

import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
@@ -64,11 +66,12 @@ public class CommandQueueTest extends SysuiTestCase {
        verify(mCallbacks).removeIcon(eq(slot));
    }

    // TODO(b/117478341): add test case for multi-display
    @Test
    public void testDisable() {
        int state1 = 14;
        int state2 = 42;
        mCommandQueue.disable(state1, state2);
        mCommandQueue.disable(DEFAULT_DISPLAY, state1, state2);
        waitForIdleSync();
        verify(mCallbacks).disable(eq(state1), eq(state2), eq(true));
    }
@@ -95,24 +98,27 @@ public class CommandQueueTest extends SysuiTestCase {
        verify(mCallbacks).animateExpandSettingsPanel(eq(panel));
    }

    // TODO(b/117478341): add test case for multi-display
    @Test
    public void testSetSystemUiVisibility() {
        Rect r = new Rect();
        mCommandQueue.setSystemUiVisibility(1, 2, 3, 4, null, r);
        mCommandQueue.setSystemUiVisibility(DEFAULT_DISPLAY, 1, 2, 3, 4, null, r);
        waitForIdleSync();
        verify(mCallbacks).setSystemUiVisibility(eq(1), eq(2), eq(3), eq(4), eq(null), eq(r));
    }

    // TODO(b/117478341): add test case for multi-display
    @Test
    public void testTopAppWindowChanged() {
        mCommandQueue.topAppWindowChanged(true);
        mCommandQueue.topAppWindowChanged(DEFAULT_DISPLAY, true);
        waitForIdleSync();
        verify(mCallbacks).topAppWindowChanged(eq(true));
    }

    // TODO(b/117478341): add test case for multi-display
    @Test
    public void testShowImeButton() {
        mCommandQueue.setImeWindowStatus(null, 1, 2, true);
        mCommandQueue.setImeWindowStatus(DEFAULT_DISPLAY, null, 1, 2, true);
        waitForIdleSync();
        verify(mCallbacks).setImeWindowStatus(eq(null), eq(1), eq(2), eq(true));
    }
@@ -166,9 +172,10 @@ public class CommandQueueTest extends SysuiTestCase {
        verify(mCallbacks).toggleKeyboardShortcutsMenu(eq(1));
    }

    // TODO(b/117478341): add test case for multi-display
    @Test
    public void testSetWindowState() {
        mCommandQueue.setWindowState(1, 2);
        mCommandQueue.setWindowState(DEFAULT_DISPLAY, 1, 2);
        waitForIdleSync();
        verify(mCallbacks).setWindowState(eq(1), eq(2));
    }
@@ -180,30 +187,34 @@ public class CommandQueueTest extends SysuiTestCase {
        verify(mCallbacks).showScreenPinningRequest(eq(1));
    }

    // TODO(b/117478341): add test case for multi-display
    @Test
    public void testAppTransitionPending() {
        mCommandQueue.appTransitionPending();
        mCommandQueue.appTransitionPending(DEFAULT_DISPLAY);
        waitForIdleSync();
        verify(mCallbacks).appTransitionPending(eq(false));
    }

    // TODO(b/117478341): add test case for multi-display
    @Test
    public void testAppTransitionCancelled() {
        mCommandQueue.appTransitionCancelled();
        mCommandQueue.appTransitionCancelled(DEFAULT_DISPLAY);
        waitForIdleSync();
        verify(mCallbacks).appTransitionCancelled();
    }

    // TODO(b/117478341): add test case for multi-display
    @Test
    public void testAppTransitionStarting() {
        mCommandQueue.appTransitionStarting(1, 2);
        mCommandQueue.appTransitionStarting(DEFAULT_DISPLAY, 1, 2);
        waitForIdleSync();
        verify(mCallbacks).appTransitionStarting(eq(1L), eq(2L), eq(false));
    }

    // TODO(b/117478341): add test case for multi-display
    @Test
    public void testAppTransitionFinished() {
        mCommandQueue.appTransitionFinished();
        mCommandQueue.appTransitionFinished(DEFAULT_DISPLAY);
        waitForIdleSync();
        verify(mCallbacks).appTransitionFinished();
    }
Loading