Merge "Sending NavbarSurfaceControl to Recents" into tm-qpr-dev

This commit is contained in:
Sunny Goyal
2022-11-02 16:43:22 +00:00
committed by Android (Google) Code Review
7 changed files with 60 additions and 71 deletions

View File

@@ -20,6 +20,7 @@ import android.graphics.Rect;
import android.graphics.Region;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.SurfaceControl;
import com.android.systemui.shared.recents.ISystemUiProxy;
oneway interface IOverviewProxy {
@@ -43,12 +44,6 @@ oneway interface IOverviewProxy {
*/
void onOverviewHidden(boolean triggeredFromAltTab, boolean triggeredFromHomeKey) = 8;
/**
* Sent when there was an action on one of the onboarding tips view.
* TODO: Move this implementation to SystemUI completely
*/
void onTip(int actionType, int viewType) = 10;
/**
* Sent when device assistant changes its default assistant whether it is available or not.
*/
@@ -59,13 +54,6 @@ oneway interface IOverviewProxy {
*/
void onAssistantVisibilityChanged(float visibility) = 14;
/**
* Sent when back is triggered.
* TODO: Move this implementation to SystemUI completely
*/
void onBackAction(boolean completed, int downX, int downY, boolean isButton,
boolean gestureSwipeLeft) = 15;
/**
* Sent when some system ui state changes.
*/
@@ -115,4 +103,9 @@ oneway interface IOverviewProxy {
* Sent when split keyboard shortcut is triggered to enter stage split.
*/
void enterStageSplitFromRunningApp(boolean leftOrTop) = 25;
/**
* Sent when the surface for navigation bar is created or changed
*/
void onNavigationBarSurface(in SurfaceControl surface) = 26;
}

View File

@@ -106,9 +106,6 @@ interface ISystemUiProxy {
/** Sets home rotation enabled. */
void setHomeRotationEnabled(boolean enabled) = 45;
/** Notifies that a swipe-up gesture has started */
oneway void notifySwipeUpGestureStarted() = 46;
/** Notifies when taskbar status updated */
oneway void notifyTaskbarStatus(boolean visible, boolean stashed) = 47;

View File

@@ -85,7 +85,11 @@ import android.view.InsetsVisibilities;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.Surface;
import android.view.SurfaceControl;
import android.view.SurfaceControl.Transaction;
import android.view.View;
import android.view.ViewRootImpl;
import android.view.ViewRootImpl.SurfaceChangedCallback;
import android.view.ViewTreeObserver;
import android.view.ViewTreeObserver.InternalInsetsInfo;
import android.view.ViewTreeObserver.OnComputeInternalInsetsListener;
@@ -353,15 +357,6 @@ public class NavigationBar extends ViewController<NavigationBarView> implements
updateScreenPinningGestures();
}
@Override
public void onQuickStepStarted() {
// Use navbar dragging as a signal to hide the rotate button
mView.getRotationButtonController().setRotateSuggestionButtonState(false);
// Hide the notifications panel when quick step starts
mShadeController.collapsePanel(true /* animate */);
}
@Override
public void onPrioritizedRotation(@Surface.Rotation int rotation) {
mStartingQuickSwitchRotation = rotation;
@@ -475,6 +470,24 @@ public class NavigationBar extends ViewController<NavigationBarView> implements
}
};
private final ViewRootImpl.SurfaceChangedCallback mSurfaceChangedCallback =
new SurfaceChangedCallback() {
@Override
public void surfaceCreated(Transaction t) {
notifyNavigationBarSurface();
}
@Override
public void surfaceDestroyed() {
notifyNavigationBarSurface();
}
@Override
public void surfaceReplaced(Transaction t) {
notifyNavigationBarSurface();
}
};
@Inject
NavigationBar(
NavigationBarView navigationBarView,
@@ -701,6 +714,8 @@ public class NavigationBar extends ViewController<NavigationBarView> implements
mView.getViewTreeObserver().addOnComputeInternalInsetsListener(
mOnComputeInternalInsetsListener);
mView.getViewRootImpl().addSurfaceChangedCallback(mSurfaceChangedCallback);
notifyNavigationBarSurface();
mNavBarHelper.registerNavTaskStateUpdater(mNavbarTaskbarStateUpdater);
@@ -779,6 +794,10 @@ public class NavigationBar extends ViewController<NavigationBarView> implements
mHandler.removeCallbacks(mEnableLayoutTransitions);
mNavBarHelper.removeNavTaskStateUpdater(mNavbarTaskbarStateUpdater);
mPipOptional.ifPresent(mView::removePipExclusionBoundsChangeListener);
ViewRootImpl viewRoot = mView.getViewRootImpl();
if (viewRoot != null) {
viewRoot.removeSurfaceChangedCallback(mSurfaceChangedCallback);
}
mFrame = null;
mOrientationHandle = null;
}
@@ -932,6 +951,12 @@ public class NavigationBar extends ViewController<NavigationBarView> implements
}
}
private void notifyNavigationBarSurface() {
ViewRootImpl viewRoot = mView.getViewRootImpl();
SurfaceControl surface = viewRoot != null ? viewRoot.getSurfaceControl() : null;
mOverviewProxyService.onNavigationBarSurfaceChanged(surface);
}
private int deltaRotation(int oldRotation, int newRotation) {
int delta = newRotation - oldRotation;
if (delta < 0) delta += 4;

View File

@@ -412,10 +412,6 @@ public class KeyButtonView extends ImageView implements ButtonInterface {
logSomePresses(action, flags);
if (mCode == KeyEvent.KEYCODE_BACK && flags != KeyEvent.FLAG_LONG_PRESS) {
Log.i(TAG, "Back button event: " + KeyEvent.actionToString(action));
if (action == MotionEvent.ACTION_UP) {
mOverviewProxyService.notifyBackAction((flags & KeyEvent.FLAG_CANCELED) == 0,
-1, -1, true /* isButton */, false /* gestureSwipeLeft */);
}
}
final int repeatCount = (flags & KeyEvent.FLAG_LONG_PRESS) != 0 ? 1 : 0;
final KeyEvent ev = new KeyEvent(mDownTime, when, action, mCode, repeatCount,

View File

@@ -287,8 +287,6 @@ public class EdgeBackGestureHandler extends CurrentUserTracker
mBackAnimation.setTriggerBack(true);
}
mOverviewProxyService.notifyBackAction(true, (int) mDownPoint.x,
(int) mDownPoint.y, false /* isButton */, !mIsOnLeftEdge);
logGesture(mInRejectedExclusion
? SysUiStatsLog.BACK_GESTURE__TYPE__COMPLETED_REJECTED
: SysUiStatsLog.BACK_GESTURE__TYPE__COMPLETED);
@@ -300,8 +298,6 @@ public class EdgeBackGestureHandler extends CurrentUserTracker
mBackAnimation.setTriggerBack(false);
}
logGesture(SysUiStatsLog.BACK_GESTURE__TYPE__INCOMPLETE);
mOverviewProxyService.notifyBackAction(false, (int) mDownPoint.x,
(int) mDownPoint.y, false /* isButton */, !mIsOnLeftEdge);
}
@Override
@@ -785,9 +781,6 @@ public class EdgeBackGestureHandler extends CurrentUserTracker
if (mExcludeRegion.contains(x, y)) {
if (withinRange) {
// Log as exclusion only if it is in acceptable range in the first place.
mOverviewProxyService.notifyBackAction(
false /* completed */, -1, -1, false /* isButton */, !mIsOnLeftEdge);
// We don't have the end point for logging purposes.
mEndPoint.x = -1;
mEndPoint.y = -1;

View File

@@ -64,6 +64,7 @@ import android.view.KeyCharacterMap;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.Surface;
import android.view.SurfaceControl;
import android.view.accessibility.AccessibilityManager;
import android.view.inputmethod.InputMethodManager;
@@ -149,6 +150,7 @@ public class OverviewProxyService extends CurrentUserTracker implements
private final UiEventLogger mUiEventLogger;
private Region mActiveNavBarRegion;
private SurfaceControl mNavigationBarSurface;
private IOverviewProxy mOverviewProxy;
private int mConnectionBackoffAttempts;
@@ -217,17 +219,15 @@ public class OverviewProxyService extends CurrentUserTracker implements
}
@Override
public void onBackPressed() throws RemoteException {
public void onBackPressed() {
verifyCallerAndClearCallingIdentityPostMain("onBackPressed", () -> {
sendEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_BACK);
sendEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_BACK);
notifyBackAction(true, -1, -1, true, false);
});
}
@Override
public void onImeSwitcherPressed() throws RemoteException {
public void onImeSwitcherPressed() {
// TODO(b/204901476) We're intentionally using DEFAULT_DISPLAY for now since
// Launcher/Taskbar isn't display aware.
mContext.getSystemService(InputMethodManager.class)
@@ -315,12 +315,6 @@ public class OverviewProxyService extends CurrentUserTracker implements
});
}
@Override
public void notifySwipeUpGestureStarted() {
verifyCallerAndClearCallingIdentityPostMain("notifySwipeUpGestureStarted", () ->
notifySwipeUpGestureStartedInternal());
}
@Override
public void notifyPrioritizedRotation(@Surface.Rotation int rotation) {
verifyCallerAndClearCallingIdentityPostMain("notifyPrioritizedRotation", () ->
@@ -443,6 +437,7 @@ public class OverviewProxyService extends CurrentUserTracker implements
Log.e(TAG_OPS, "Failed to call onInitialize()", e);
}
dispatchNavButtonBounds();
dispatchNavigationBarSurface();
// Force-update the systemui state flags
updateSystemUiStateFlags();
@@ -597,11 +592,18 @@ public class OverviewProxyService extends CurrentUserTracker implements
.commitUpdate(mContext.getDisplayId());
}
public void notifyBackAction(boolean completed, int downX, int downY, boolean isButton,
boolean gestureSwipeLeft) {
/**
* Called when the navigation bar surface is created or changed
*/
public void onNavigationBarSurfaceChanged(SurfaceControl navbarSurface) {
mNavigationBarSurface = navbarSurface;
dispatchNavigationBarSurface();
}
private void dispatchNavigationBarSurface() {
try {
if (mOverviewProxy != null) {
mOverviewProxy.onBackAction(completed, downX, downY, isButton, gestureSwipeLeft);
mOverviewProxy.onNavigationBarSurface(mNavigationBarSurface);
}
} catch (RemoteException e) {
Log.e(TAG_OPS, "Failed to notify back action", e);
@@ -800,24 +802,12 @@ public class OverviewProxyService extends CurrentUserTracker implements
}
}
public void notifyQuickStepStarted() {
for (int i = mConnectionCallbacks.size() - 1; i >= 0; --i) {
mConnectionCallbacks.get(i).onQuickStepStarted();
}
}
private void notifyPrioritizedRotationInternal(@Surface.Rotation int rotation) {
for (int i = mConnectionCallbacks.size() - 1; i >= 0; --i) {
mConnectionCallbacks.get(i).onPrioritizedRotation(rotation);
}
}
public void notifyQuickScrubStarted() {
for (int i = mConnectionCallbacks.size() - 1; i >= 0; --i) {
mConnectionCallbacks.get(i).onQuickScrubStarted();
}
}
private void notifyAssistantProgress(@FloatRange(from = 0.0, to = 1.0) float progress) {
for (int i = mConnectionCallbacks.size() - 1; i >= 0; --i) {
mConnectionCallbacks.get(i).onAssistantProgress(progress);
@@ -836,12 +826,6 @@ public class OverviewProxyService extends CurrentUserTracker implements
}
}
private void notifySwipeUpGestureStartedInternal() {
for (int i = mConnectionCallbacks.size() - 1; i >= 0; --i) {
mConnectionCallbacks.get(i).onSwipeUpGestureStarted();
}
}
public void notifyAssistantVisibilityChanged(float visibility) {
try {
if (mOverviewProxy != null) {
@@ -1005,23 +989,20 @@ public class OverviewProxyService extends CurrentUserTracker implements
pw.print(" mWindowCornerRadius="); pw.println(mWindowCornerRadius);
pw.print(" mSupportsRoundedCornersOnWindows="); pw.println(mSupportsRoundedCornersOnWindows);
pw.print(" mActiveNavBarRegion="); pw.println(mActiveNavBarRegion);
pw.print(" mNavigationBarSurface="); pw.println(mNavigationBarSurface);
pw.print(" mNavBarMode="); pw.println(mNavBarMode);
mSysUiState.dump(pw, args);
}
public interface OverviewProxyListener {
default void onConnectionChanged(boolean isConnected) {}
default void onQuickStepStarted() {}
default void onSwipeUpGestureStarted() {}
default void onPrioritizedRotation(@Surface.Rotation int rotation) {}
default void onOverviewShown(boolean fromHome) {}
default void onQuickScrubStarted() {}
/** Notify the recents app (overview) is started by 3-button navigation. */
default void onToggleRecentApps() {}
default void onHomeRotationEnabled(boolean enabled) {}
default void onTaskbarStatusUpdated(boolean visible, boolean stashed) {}
default void onTaskbarAutohideSuspend(boolean suspend) {}
default void onSystemUiStateChanged(int sysuiStateFlags) {}
default void onAssistantProgress(@FloatRange(from = 0.0, to = 1.0) float progress) {}
default void onAssistantGestureCompletion(float velocity) {}
default void startAssistant(Bundle bundle) {}

View File

@@ -61,6 +61,7 @@ import android.view.Display;
import android.view.DisplayInfo;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewRootImpl;
import android.view.ViewTreeObserver;
import android.view.WindowInsets;
import android.view.WindowManager;
@@ -201,6 +202,8 @@ public class NavigationBarTest extends SysuiTestCase {
private WakefulnessLifecycle mWakefulnessLifecycle;
@Mock
private Resources mResources;
@Mock
private ViewRootImpl mViewRootImpl;
private FakeExecutor mFakeExecutor = new FakeExecutor(new FakeSystemClock());
private DeviceConfigProxyFake mDeviceConfigProxyFake = new DeviceConfigProxyFake();
@@ -227,6 +230,7 @@ public class NavigationBarTest extends SysuiTestCase {
when(mUserContextProvider.createCurrentUserContext(any(Context.class)))
.thenReturn(mContext);
when(mNavigationBarView.getResources()).thenReturn(mResources);
when(mNavigationBarView.getViewRootImpl()).thenReturn(mViewRootImpl);
setupSysuiDependency();
// This class inflates views that call Dependency.get, thus these injections are still
// necessary.