Merge "Moves shelf offset into SysUI package"
This commit is contained in:
@@ -54,14 +54,6 @@ oneway interface IPinnedStackListener {
|
||||
*/
|
||||
void onImeVisibilityChanged(boolean imeVisible, int imeHeight);
|
||||
|
||||
/**
|
||||
* Called when window manager decides to adjust the pinned stack bounds because of the shelf, or
|
||||
* when the listener is first registered to allow the listener to synchronized its state with
|
||||
* the controller. This call will always be followed by a onMovementBoundsChanged() call
|
||||
* with fromShelfAdjustment set to {@code true}.
|
||||
*/
|
||||
void onShelfVisibilityChanged(boolean shelfVisible, int shelfHeight);
|
||||
|
||||
/**
|
||||
* Called when window manager decides to adjust the minimized state, or when the listener
|
||||
* is first registered to allow the listener to synchronized its state with the controller.
|
||||
|
||||
@@ -325,12 +325,6 @@ interface IWindowManager
|
||||
*/
|
||||
oneway void setPipVisibility(boolean visible);
|
||||
|
||||
/**
|
||||
* Called by System UI to notify of changes to the visibility and height of the shelf.
|
||||
*/
|
||||
@UnsupportedAppUsage
|
||||
void setShelfHeight(boolean visible, int shelfHeight);
|
||||
|
||||
/**
|
||||
* Called by System UI to enable or disable haptic feedback on the navigation bar buttons.
|
||||
*/
|
||||
|
||||
@@ -109,4 +109,9 @@ interface ISystemUiProxy {
|
||||
* Ends the system screen pinning.
|
||||
*/
|
||||
void stopScreenPinning() = 17;
|
||||
|
||||
/**
|
||||
* Sets the shelf height and visibility.
|
||||
*/
|
||||
void setShelfHeight(boolean visible, int shelfHeight) = 20;
|
||||
}
|
||||
|
||||
@@ -68,13 +68,6 @@ public class PinnedStackListenerForwarder extends IPinnedStackListener.Stub {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onShelfVisibilityChanged(boolean shelfVisible, int shelfHeight) {
|
||||
for (PinnedStackListener listener : mListeners) {
|
||||
listener.onShelfVisibilityChanged(shelfVisible, shelfHeight);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMinimizedStateChanged(boolean isMinimized) {
|
||||
for (PinnedStackListener listener : mListeners) {
|
||||
@@ -143,8 +136,6 @@ public class PinnedStackListenerForwarder extends IPinnedStackListener.Stub {
|
||||
|
||||
public void onImeVisibilityChanged(boolean imeVisible, int imeHeight) {}
|
||||
|
||||
public void onShelfVisibilityChanged(boolean shelfVisible, int shelfHeight) {}
|
||||
|
||||
public void onMinimizedStateChanged(boolean isMinimized) {}
|
||||
|
||||
public void onActionsChanged(ParceledListSlice actions) {}
|
||||
|
||||
@@ -143,14 +143,6 @@ public class WindowManagerWrapper {
|
||||
}
|
||||
}
|
||||
|
||||
public void setShelfHeight(boolean visible, int shelfHeight) {
|
||||
try {
|
||||
WindowManagerGlobal.getWindowManagerService().setShelfHeight(visible, shelfHeight);
|
||||
} catch (RemoteException e) {
|
||||
Log.w(TAG, "Failed to set shelf height");
|
||||
}
|
||||
}
|
||||
|
||||
public void setRecentsVisibility(boolean visible) {
|
||||
try {
|
||||
WindowManagerGlobal.getWindowManagerService().setRecentsVisibility(visible);
|
||||
|
||||
@@ -27,5 +27,6 @@ public interface BasePipManager {
|
||||
default void expandPip() {}
|
||||
default void hidePipMenu(Runnable onStartCallback, Runnable onEndCallback) {}
|
||||
void onConfigurationChanged(Configuration newConfig);
|
||||
default void setShelfHeight(boolean visible, int height) {}
|
||||
default void dump(PrintWriter pw) {}
|
||||
}
|
||||
|
||||
@@ -55,6 +55,12 @@ public class PipBoundsHandler {
|
||||
private final Rect mTmpInsets = new Rect();
|
||||
private final Point mTmpDisplaySize = new Point();
|
||||
|
||||
/**
|
||||
* Tracks the destination bounds, used for any following
|
||||
* {@link #onMovementBoundsChanged(Rect, Rect, Rect, DisplayInfo)} calculations.
|
||||
*/
|
||||
private final Rect mLastDestinationBounds = new Rect();
|
||||
|
||||
private IPinnedStackController mPinnedStackController;
|
||||
private ComponentName mLastPipComponentName;
|
||||
private float mReentrySnapFraction = INVALID_SNAP_FRACTION;
|
||||
@@ -119,6 +125,21 @@ public class PipBoundsHandler {
|
||||
mCurrentMinSize = minEdgeSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets both shelf visibility and its height if applicable.
|
||||
* @return {@code true} if the internal shelf state is changed, {@code false} otherwise.
|
||||
*/
|
||||
public boolean setShelfHeight(boolean shelfVisible, int shelfHeight) {
|
||||
final boolean shelfShowing = shelfVisible && shelfHeight > 0;
|
||||
if (shelfShowing == mIsShelfShowing && shelfHeight == mShelfHeight) {
|
||||
return false;
|
||||
}
|
||||
|
||||
mIsShelfShowing = shelfVisible;
|
||||
mShelfHeight = shelfHeight;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Responds to IPinnedStackListener on IME visibility change.
|
||||
*/
|
||||
@@ -127,14 +148,6 @@ public class PipBoundsHandler {
|
||||
mImeHeight = imeHeight;
|
||||
}
|
||||
|
||||
/**
|
||||
* Responds to IPinnedStackListener on shelf visibility change.
|
||||
*/
|
||||
public void onShelfVisibilityChanged(boolean shelfVisible, int shelfHeight) {
|
||||
mIsShelfShowing = shelfVisible;
|
||||
mShelfHeight = shelfHeight;
|
||||
}
|
||||
|
||||
/**
|
||||
* Responds to IPinnedStackListener on minimized state change.
|
||||
*/
|
||||
@@ -185,6 +198,10 @@ public class PipBoundsHandler {
|
||||
mLastPipComponentName = null;
|
||||
}
|
||||
|
||||
public Rect getLastDestinationBounds() {
|
||||
return mLastDestinationBounds;
|
||||
}
|
||||
|
||||
/**
|
||||
* Responds to IPinnedStackListener on {@link DisplayInfo} change.
|
||||
* It will normally follow up with a
|
||||
@@ -232,6 +249,7 @@ public class PipBoundsHandler {
|
||||
try {
|
||||
mPinnedStackController.startAnimation(destinationBounds, sourceRectHint,
|
||||
-1 /* animationDuration */);
|
||||
mLastDestinationBounds.set(destinationBounds);
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Failed to start PiP animation from SysUI", e);
|
||||
}
|
||||
|
||||
@@ -85,6 +85,14 @@ public class PipUI extends SystemUI implements CommandQueue.Callbacks {
|
||||
mPipManager.onConfigurationChanged(newConfig);
|
||||
}
|
||||
|
||||
public void setShelfHeight(boolean visible, int height) {
|
||||
if (mPipManager == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
mPipManager.setShelfHeight(visible, height);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
|
||||
if (mPipManager == null) {
|
||||
|
||||
@@ -142,14 +142,6 @@ public class PipManager implements BasePipManager {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onShelfVisibilityChanged(boolean shelfVisible, int shelfHeight) {
|
||||
mHandler.post(() -> {
|
||||
mPipBoundsHandler.onShelfVisibilityChanged(shelfVisible, shelfHeight);
|
||||
mTouchHandler.onShelfVisibilityChanged(shelfVisible, shelfHeight);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMinimizedStateChanged(boolean isMinimized) {
|
||||
mHandler.post(() -> {
|
||||
@@ -161,14 +153,8 @@ public class PipManager implements BasePipManager {
|
||||
@Override
|
||||
public void onMovementBoundsChanged(Rect animatingBounds, boolean fromImeAdjustment,
|
||||
boolean fromShelfAdjustment) {
|
||||
mHandler.post(() -> {
|
||||
// Populate the inset / normal bounds and DisplayInfo from mPipBoundsHandler first.
|
||||
mPipBoundsHandler.onMovementBoundsChanged(mTmpInsetBounds, mTmpNormalBounds,
|
||||
animatingBounds, mTmpDisplayInfo);
|
||||
mTouchHandler.onMovementBoundsChanged(mTmpInsetBounds, mTmpNormalBounds,
|
||||
animatingBounds, fromImeAdjustment, fromShelfAdjustment,
|
||||
mTmpDisplayInfo.rotation);
|
||||
});
|
||||
mHandler.post(() -> updateMovementBounds(animatingBounds, fromImeAdjustment,
|
||||
fromShelfAdjustment));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -279,6 +265,31 @@ public class PipManager implements BasePipManager {
|
||||
mTouchHandler.showPictureInPictureMenu();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets both shelf visibility and its height.
|
||||
*/
|
||||
@Override
|
||||
public void setShelfHeight(boolean visible, int height) {
|
||||
mHandler.post(() -> {
|
||||
final boolean changed = mPipBoundsHandler.setShelfHeight(visible, height);
|
||||
if (changed) {
|
||||
mTouchHandler.onShelfVisibilityChanged(visible, height);
|
||||
updateMovementBounds(mPipBoundsHandler.getLastDestinationBounds(),
|
||||
false /* fromImeAdjustment */, true /* fromShelfAdjustment */);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void updateMovementBounds(Rect animatingBounds, boolean fromImeAdjustment,
|
||||
boolean fromShelfAdjustment) {
|
||||
// Populate inset / normal bounds and DisplayInfo from mPipBoundsHandler first.
|
||||
mPipBoundsHandler.onMovementBoundsChanged(mTmpInsetBounds, mTmpNormalBounds,
|
||||
animatingBounds, mTmpDisplayInfo);
|
||||
mTouchHandler.onMovementBoundsChanged(mTmpInsetBounds, mTmpNormalBounds,
|
||||
animatingBounds, fromImeAdjustment, fromShelfAdjustment,
|
||||
mTmpDisplayInfo.rotation);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an instance of {@link PipManager}.
|
||||
*/
|
||||
|
||||
@@ -58,6 +58,7 @@ import com.android.internal.policy.ScreenDecorationsUtils;
|
||||
import com.android.systemui.Dumpable;
|
||||
import com.android.systemui.SysUiServiceProvider;
|
||||
import com.android.systemui.model.SysUiState;
|
||||
import com.android.systemui.pip.PipUI;
|
||||
import com.android.systemui.recents.OverviewProxyService.OverviewProxyListener;
|
||||
import com.android.systemui.shared.recents.IOverviewProxy;
|
||||
import com.android.systemui.shared.recents.ISystemUiProxy;
|
||||
@@ -353,6 +354,20 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setShelfHeight(boolean visible, int shelfHeight) {
|
||||
if (!verifyCaller("setShelfHeight")) {
|
||||
return;
|
||||
}
|
||||
long token = Binder.clearCallingIdentity();
|
||||
try {
|
||||
final PipUI component = SysUiServiceProvider.getComponent(mContext, PipUI.class);
|
||||
component.setShelfHeight(visible, shelfHeight);
|
||||
} finally {
|
||||
Binder.restoreCallingIdentity(token);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean verifyCaller(String reason) {
|
||||
final int callerId = Binder.getCallingUserHandle().getIdentifier();
|
||||
if (callerId != mCurrentBoundedUserId) {
|
||||
|
||||
@@ -90,8 +90,6 @@ class PinnedStackController {
|
||||
private boolean mIsMinimized;
|
||||
private boolean mIsImeShowing;
|
||||
private int mImeHeight;
|
||||
private boolean mIsShelfShowing;
|
||||
private int mShelfHeight;
|
||||
|
||||
// The set of actions and aspect-ratio for the that are currently allowed on the PiP activity
|
||||
private ArrayList<RemoteAction> mActions = new ArrayList<>();
|
||||
@@ -216,7 +214,6 @@ class PinnedStackController {
|
||||
mPinnedStackListener = listener;
|
||||
notifyDisplayInfoChanged(mDisplayInfo);
|
||||
notifyImeVisibilityChanged(mIsImeShowing, mImeHeight);
|
||||
notifyShelfVisibilityChanged(mIsShelfShowing, mShelfHeight);
|
||||
// The movement bounds notification needs to be sent before the minimized state, since
|
||||
// SystemUI may use the bounds to retore the minimized position
|
||||
notifyMovementBoundsChanged(false /* fromImeAdjustment */,
|
||||
@@ -278,9 +275,7 @@ class PinnedStackController {
|
||||
mSnapAlgorithm.applySnapFraction(defaultBounds, movementBounds, snapFraction);
|
||||
} else {
|
||||
Gravity.apply(mDefaultStackGravity, size.getWidth(), size.getHeight(), insetBounds,
|
||||
0, Math.max(mIsImeShowing ? mImeHeight : 0,
|
||||
mIsShelfShowing ? mShelfHeight : 0),
|
||||
defaultBounds);
|
||||
0, mIsImeShowing ? mImeHeight : 0, defaultBounds);
|
||||
}
|
||||
return defaultBounds;
|
||||
}
|
||||
@@ -366,21 +361,6 @@ class PinnedStackController {
|
||||
notifyMovementBoundsChanged(true /* fromImeAdjustment */, false /* fromShelfAdjustment */);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the shelf state and height.
|
||||
*/
|
||||
void setAdjustedForShelf(boolean adjustedForShelf, int shelfHeight) {
|
||||
final boolean shelfShowing = adjustedForShelf && shelfHeight > 0;
|
||||
if (shelfShowing == mIsShelfShowing && shelfHeight == mShelfHeight) {
|
||||
return;
|
||||
}
|
||||
|
||||
mIsShelfShowing = shelfShowing;
|
||||
mShelfHeight = shelfHeight;
|
||||
notifyShelfVisibilityChanged(shelfShowing, shelfHeight);
|
||||
notifyMovementBoundsChanged(false /* fromImeAdjustment */, true /* fromShelfAdjustment */);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the current aspect ratio.
|
||||
*/
|
||||
@@ -439,16 +419,6 @@ class PinnedStackController {
|
||||
}
|
||||
}
|
||||
|
||||
private void notifyShelfVisibilityChanged(boolean shelfVisible, int shelfHeight) {
|
||||
if (mPinnedStackListener != null) {
|
||||
try {
|
||||
mPinnedStackListener.onShelfVisibilityChanged(shelfVisible, shelfHeight);
|
||||
} catch (RemoteException e) {
|
||||
Slog.e(TAG_WM, "Error delivering bounds changed event.", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void notifyAspectRatioChanged(float aspectRatio) {
|
||||
if (mPinnedStackListener == null) return;
|
||||
try {
|
||||
@@ -613,8 +583,6 @@ class PinnedStackController {
|
||||
pw.println();
|
||||
pw.println(prefix + " mIsImeShowing=" + mIsImeShowing);
|
||||
pw.println(prefix + " mImeHeight=" + mImeHeight);
|
||||
pw.println(prefix + " mIsShelfShowing=" + mIsShelfShowing);
|
||||
pw.println(prefix + " mShelfHeight=" + mShelfHeight);
|
||||
pw.println(prefix + " mIsMinimized=" + mIsMinimized);
|
||||
pw.println(prefix + " mAspectRatio=" + mAspectRatio);
|
||||
pw.println(prefix + " mMinAspectRatio=" + mMinAspectRatio);
|
||||
|
||||
@@ -5593,16 +5593,6 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setShelfHeight(boolean visible, int shelfHeight) {
|
||||
mAtmInternal.enforceCallerIsRecentsOrHasPermission(android.Manifest.permission.STATUS_BAR,
|
||||
"setShelfHeight()");
|
||||
synchronized (mGlobalLock) {
|
||||
getDefaultDisplayContentLocked().getPinnedStackController().setAdjustedForShelf(visible,
|
||||
shelfHeight);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void statusBarVisibilityChanged(int displayId, int visibility) {
|
||||
if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.STATUS_BAR)
|
||||
|
||||
@@ -1,82 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2018 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.server.wm;
|
||||
|
||||
import static android.view.Display.DEFAULT_DISPLAY;
|
||||
|
||||
import static com.android.dx.mockito.inline.extended.ExtendedMockito.never;
|
||||
import static com.android.dx.mockito.inline.extended.ExtendedMockito.reset;
|
||||
import static com.android.dx.mockito.inline.extended.ExtendedMockito.verify;
|
||||
import static com.android.dx.mockito.inline.extended.ExtendedMockito.when;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyBoolean;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
|
||||
import android.os.RemoteException;
|
||||
import android.platform.test.annotations.Presubmit;
|
||||
import android.view.IPinnedStackListener;
|
||||
|
||||
import androidx.test.filters.SmallTest;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
/**
|
||||
* Build/Install/Run:
|
||||
* atest FrameworksServicesTests:PinnedStackControllerTest
|
||||
*/
|
||||
@SmallTest
|
||||
@Presubmit
|
||||
public class PinnedStackControllerTest extends WindowTestsBase {
|
||||
|
||||
private static final int SHELF_HEIGHT = 300;
|
||||
|
||||
@Mock private IPinnedStackListener mIPinnedStackListener;
|
||||
@Mock private IPinnedStackListener.Stub mIPinnedStackListenerStub;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
|
||||
when(mIPinnedStackListener.asBinder()).thenReturn(mIPinnedStackListenerStub);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setShelfHeight_shelfVisibilityChangedTriggered() throws RemoteException {
|
||||
mWm.mAtmService.mSupportsPictureInPicture = true;
|
||||
mWm.registerPinnedStackListener(DEFAULT_DISPLAY, mIPinnedStackListener);
|
||||
|
||||
verify(mIPinnedStackListener).onImeVisibilityChanged(false, 0);
|
||||
verify(mIPinnedStackListener).onShelfVisibilityChanged(false, 0);
|
||||
verify(mIPinnedStackListener).onMovementBoundsChanged(any(), eq(false),
|
||||
eq(false));
|
||||
verify(mIPinnedStackListener).onActionsChanged(any());
|
||||
verify(mIPinnedStackListener).onMinimizedStateChanged(anyBoolean());
|
||||
|
||||
reset(mIPinnedStackListener);
|
||||
|
||||
mWm.setShelfHeight(true, SHELF_HEIGHT);
|
||||
verify(mIPinnedStackListener).onShelfVisibilityChanged(true, SHELF_HEIGHT);
|
||||
verify(mIPinnedStackListener).onMovementBoundsChanged(any(), eq(false),
|
||||
eq(true));
|
||||
verify(mIPinnedStackListener, never()).onImeVisibilityChanged(anyBoolean(), anyInt());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user