Remove sysui from having to manually notify pip visibility

- Set directly from the system when we enter/leave pip so there's
  no chance this gets out of sync

Bug: 167682726
Test: adb shell input keyevent 171 (ensures this still triggers the menu)

Change-Id: I73b4c5b6faebd505bf8e17b4c817b4d600025894
This commit is contained in:
Winson Chung
2020-09-03 14:24:35 -07:00
parent 182cd692ff
commit 8e51146233
5 changed files with 21 additions and 26 deletions

View File

@@ -392,11 +392,6 @@ interface IWindowManager
*/
oneway void setRecentsVisibility(boolean visible);
/**
* Called by System UI to notify of changes to the visibility of PIP.
*/
oneway void setPipVisibility(boolean visible);
/**
* Called by System UI to enable or disable haptic feedback on the navigation bar buttons.
*/

View File

@@ -153,12 +153,9 @@ public class WindowManagerWrapper {
}
}
@Deprecated
public void setPipVisibility(final boolean visible) {
try {
WindowManagerGlobal.getWindowManagerService().setPipVisibility(visible);
} catch (RemoteException e) {
Log.e(TAG, "Unable to reach window manager", e);
}
// To be removed
}
/**

View File

@@ -2201,7 +2201,22 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
ensureActivitiesVisible(null, 0, false /* preserveWindows */);
resumeFocusedStacksTopActivities();
mService.getTaskChangeNotificationController().notifyActivityPinned(r);
notifyActivityPipModeChanged(r);
}
/**
* Notifies when an activity enters or leaves PIP mode.
* @param r indicates the activity currently in PIP, can be null to indicate no activity is
* currently in PIP mode.
*/
void notifyActivityPipModeChanged(@Nullable ActivityRecord r) {
final boolean inPip = r != null;
if (inPip) {
mService.getTaskChangeNotificationController().notifyActivityPinned(r);
} else {
mService.getTaskChangeNotificationController().notifyActivityUnpinned();
}
mWindowManager.mPolicy.setPipVisibilityLw(inPip);
}
void executeAppTransitionForAllDisplay() {

View File

@@ -1434,7 +1434,7 @@ class Task extends WindowContainer<WindowContainer> {
&& (newParent == null || !newParent.inPinnedWindowingMode())) {
// Notify if a task from the pinned stack is being removed
// (or moved depending on the mode).
mAtmService.getTaskChangeNotificationController().notifyActivityUnpinned();
mRootWindowContainer.notifyActivityPipModeChanged(null);
}
}
@@ -5102,10 +5102,11 @@ class Task extends WindowContainer<WindowContainer> {
: WINDOWING_MODE_FULLSCREEN;
}
if (currentMode == WINDOWING_MODE_PINNED) {
mAtmService.getTaskChangeNotificationController().notifyActivityUnpinned();
mRootWindowContainer.notifyActivityPipModeChanged(null);
}
if (likelyResolvedMode == WINDOWING_MODE_PINNED
&& taskDisplayArea.getRootPinnedTask() != null) {
// Can only have 1 pip at a time, so replace an existing pip
taskDisplayArea.getRootPinnedTask().dismissPip();
}

View File

@@ -5751,19 +5751,6 @@ public class WindowManagerService extends IWindowManager.Stub
}
}
@Override
public void setPipVisibility(boolean visible) {
if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.STATUS_BAR)
!= PackageManager.PERMISSION_GRANTED) {
throw new SecurityException("Caller does not hold permission "
+ android.Manifest.permission.STATUS_BAR);
}
synchronized (mGlobalLock) {
mPolicy.setPipVisibilityLw(visible);
}
}
@Override
public void statusBarVisibilityChanged(int displayId, int visibility) {
if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.STATUS_BAR)