Cleanup IPinnedStackController and IPinnedStackListener 2/N

Deprecates the following
- IPinnedStackListener#onConfigurationChanged, switched to use
  onConfigurationChanged callback in WMShell
- IPinnedStackListener#onDisplayInfoChanged, switched to use
  DisplayChangeController

Bug: 174702196
Test: atest WMShellUnitTests
Change-Id: Id2161883bd520c99888a561ae058154da06ecb51
This commit is contained in:
Hongwei Wang
2020-12-03 12:04:20 -08:00
parent 8fac2df868
commit f1de2b6e76
12 changed files with 33 additions and 99 deletions

View File

@@ -57,19 +57,6 @@ oneway interface IPinnedStackListener {
*/
void onActivityHidden(in ComponentName componentName);
/**
* Called when the window manager has detected change on DisplayInfo, or
* when the listener is first registered to allow the listener to synchronized its state with
* the controller.
*/
void onDisplayInfoChanged(in DisplayInfo displayInfo);
/**
* Called by the window manager at the beginning of a configuration update cascade
* since the metrics from these resources are used for bounds calculations.
*/
void onConfigurationChanged();
/**
* Called by the window manager when the aspect ratio is reset.
*/

View File

@@ -20,7 +20,6 @@ import android.app.RemoteAction;
import android.content.ComponentName;
import android.content.pm.ParceledListSlice;
import android.os.RemoteException;
import android.view.DisplayInfo;
import android.view.IPinnedStackListener;
import android.view.WindowManagerGlobal;
@@ -85,18 +84,6 @@ public class PinnedStackListenerForwarder {
}
}
private void onDisplayInfoChanged(DisplayInfo displayInfo) {
for (PinnedStackListener listener : mListeners) {
listener.onDisplayInfoChanged(displayInfo);
}
}
private void onConfigurationChanged() {
for (PinnedStackListener listener : mListeners) {
listener.onConfigurationChanged();
}
}
private void onAspectRatioChanged(float aspectRatio) {
for (PinnedStackListener listener : mListeners) {
listener.onAspectRatioChanged(aspectRatio);
@@ -133,20 +120,6 @@ public class PinnedStackListenerForwarder {
});
}
@Override
public void onDisplayInfoChanged(DisplayInfo displayInfo) {
mShellMainExecutor.execute(() -> {
PinnedStackListenerForwarder.this.onDisplayInfoChanged(displayInfo);
});
}
@Override
public void onConfigurationChanged() {
mShellMainExecutor.execute(() -> {
PinnedStackListenerForwarder.this.onConfigurationChanged();
});
}
@Override
public void onAspectRatioChanged(float aspectRatio) {
mShellMainExecutor.execute(() -> {
@@ -168,10 +141,6 @@ public class PinnedStackListenerForwarder {
public void onActivityHidden(ComponentName componentName) {}
public void onDisplayInfoChanged(DisplayInfo displayInfo) {}
public void onConfigurationChanged() {}
public void onAspectRatioChanged(float aspectRatio) {}
}
}

View File

@@ -20,6 +20,7 @@ import android.annotation.Nullable;
import android.app.PictureInPictureParams;
import android.content.ComponentName;
import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
import android.graphics.Rect;
import com.android.wm.shell.common.annotations.ExternalThread;
@@ -81,6 +82,12 @@ public interface Pip {
default void movePipToFullscreen() {
}
/**
* Called when configuration is changed.
*/
default void onConfigurationChanged(Configuration newConfig) {
}
/**
* Called when display size or font size of settings changed
*/

View File

@@ -102,9 +102,7 @@ public class PipBoundsAlgorithm {
return mSnapAlgorithm;
}
/**
* Responds to IPinnedStackListener on configuration change.
*/
/** Responds to configuration change. */
public void onConfigurationChanged(Context context) {
reloadResources(context);
}

View File

@@ -502,7 +502,6 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
mPipMenuController.attach(leash);
if (mShouldIgnoreEnteringPipTransition) {
final Rect destinationBounds = mPipBoundsState.getBounds();
// animation is finished in the Launcher and here we directly apply the final touch.

View File

@@ -33,6 +33,7 @@ import android.content.ComponentName;
import android.content.Context;
import android.content.pm.ActivityInfo;
import android.content.pm.ParceledListSlice;
import android.content.res.Configuration;
import android.graphics.Rect;
import android.os.RemoteException;
import android.os.UserHandle;
@@ -104,6 +105,9 @@ public class PipController implements Pip, PipTaskOrganizer.PipTransitionCallbac
// Skip if we aren't in PIP or haven't actually entered PIP yet. We still need to update
// the display layout in the bounds handler in this case.
onDisplayRotationChangedNotInPip(mContext, toRotation);
// do not forget to update the movement bounds as well.
updateMovementBounds(mPipBoundsState.getNormalBounds(), true /* fromRotation */,
false /* fromImeAdjustment */, false /* fromShelfAdjustment */, t);
return;
}
// If there is an animation running (ie. from a shelf offset), then ensure that we calculate
@@ -136,7 +140,7 @@ public class PipController implements Pip, PipTaskOrganizer.PipTransitionCallbac
}
};
private DisplayController.OnDisplaysChangedListener mFixedRotationListener =
private final DisplayController.OnDisplaysChangedListener mFixedRotationListener =
new DisplayController.OnDisplaysChangedListener() {
@Override
public void onFixedRotationStarted(int displayId, int newRotation) {
@@ -187,18 +191,6 @@ public class PipController implements Pip, PipTaskOrganizer.PipTransitionCallbac
}
}
@Override
public void onDisplayInfoChanged(DisplayInfo displayInfo) {
mPipBoundsState.setDisplayInfo(displayInfo);
}
@Override
public void onConfigurationChanged() {
mPipBoundsAlgorithm.onConfigurationChanged(mContext);
mTouchHandler.onConfigurationChanged();
mPipBoundsState.onConfigurationChanged();
}
@Override
public void onAspectRatioChanged(float aspectRatio) {
// TODO(b/169373982): Remove this callback as it is redundant with PipTaskOrg params
@@ -333,6 +325,15 @@ public class PipController implements Pip, PipTaskOrganizer.PipTransitionCallbac
});
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
mMainExecutor.execute(() -> {
mPipBoundsAlgorithm.onConfigurationChanged(mContext);
mTouchHandler.onConfigurationChanged();
mPipBoundsState.onConfigurationChanged();
});
}
@Override
public void onDensityOrFontScaleChanged() {
mMainExecutor.execute(() -> {
@@ -532,7 +533,7 @@ public class PipController implements Pip, PipTaskOrganizer.PipTransitionCallbac
*
* @return {@code true} if internal {@link DisplayInfo} is rotated, {@code false} otherwise.
*/
public boolean onDisplayRotationChanged(Context context, Rect outBounds, Rect oldBounds,
private boolean onDisplayRotationChanged(Context context, Rect outBounds, Rect oldBounds,
Rect outInsetBounds,
int displayId, int fromRotation, int toRotation, WindowContainerTransaction t) {
// Bail early if the event is not sent to current {@link #mDisplayInfo}

View File

@@ -93,6 +93,7 @@ public class PipResizeGestureHandler {
private int mDelta;
private float mTouchSlop;
private boolean mAllowGesture;
private boolean mIsAttached;
private boolean mIsEnabled;

View File

@@ -86,7 +86,7 @@ public class PipTouchHandler {
private boolean mEnableStash = true;
// The reference inset bounds, used to determine the dismiss fraction
private Rect mInsetBounds = new Rect();
private final Rect mInsetBounds = new Rect();
private int mExpandedShortestEdgeSize;
// Used to workaround an issue where the WM rotation happens before we are notified, allowing
@@ -94,7 +94,8 @@ public class PipTouchHandler {
private int mDeferResizeToNormalBoundsUntilRotation = -1;
private int mDisplayRotation;
private Handler mHandler = new Handler();
private final Handler mHandler = new Handler();
private final PipAccessibilityInteractionConnection mConnection;
// Behaviour states
private int mMenuState = MENU_STATE_NONE;
@@ -108,7 +109,6 @@ public class PipTouchHandler {
private float mSavedSnapFraction = -1f;
private boolean mSendingHoverAccessibilityEvents;
private boolean mMovementWithinDismiss;
private PipAccessibilityInteractionConnection mConnection;
// Touch state
private final PipTouchState mTouchState;

View File

@@ -297,6 +297,7 @@ public class PipController implements Pip, PipTaskOrganizer.PipTransitionCallbac
/**
* Updates the PIP per configuration changed.
*/
@Override
public void onConfigurationChanged(Configuration newConfig) {
loadConfigurationsAndApply(newConfig);
mPipNotification.onConfigurationChanged(mContext);

View File

@@ -167,6 +167,11 @@ public final class WMShell extends SystemUI
});
mConfigurationController.addCallback(new ConfigurationController.ConfigurationListener() {
@Override
public void onConfigChanged(Configuration newConfig) {
pip.onConfigurationChanged(newConfig);
}
@Override
public void onDensityOrFontScaleChanged() {
pip.onDensityOrFontScaleChanged();

View File

@@ -2298,10 +2298,6 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
.setSubtype(getConfiguration().orientation)
.addTaggedData(MetricsEvent.FIELD_DISPLAY_ID, getDisplayId()));
}
if (mPinnedStackControllerLocked != null) {
mPinnedStackControllerLocked.onDisplayInfoChanged(getDisplayInfo());
}
}
/**

View File

@@ -127,7 +127,6 @@ class PinnedStackController {
try {
listener.asBinder().linkToDeath(mPinnedStackListenerDeathHandler, 0);
mPinnedStackListener = listener;
notifyDisplayInfoChanged(mDisplayInfo);
notifyImeVisibilityChanged(mIsImeShowing, mImeHeight);
notifyMovementBoundsChanged(false /* fromImeAdjustment */);
notifyActionsChanged(mActions);
@@ -171,23 +170,6 @@ class PinnedStackController {
}
}
private void setDisplayInfo(DisplayInfo displayInfo) {
mDisplayInfo.copyFrom(displayInfo);
notifyDisplayInfoChanged(mDisplayInfo);
}
/**
* In the case where the display rotation is changed but there is no stack, we can't depend on
* onTaskStackBoundsChanged() to be called. But we still should update our known display info
* with the new state so that we can update SystemUI.
*/
void onDisplayInfoChanged(DisplayInfo displayInfo) {
synchronized (mService.mGlobalLock) {
setDisplayInfo(displayInfo);
notifyMovementBoundsChanged(false /* fromImeAdjustment */);
}
}
/**
* Sets the Ime state and height.
*/
@@ -288,18 +270,6 @@ class PinnedStackController {
}
}
/**
* Notifies listeners that the PIP animation is about to happen.
*/
private void notifyDisplayInfoChanged(DisplayInfo displayInfo) {
if (mPinnedStackListener == null) return;
try {
mPinnedStackListener.onDisplayInfoChanged(displayInfo);
} catch (RemoteException e) {
Slog.e(TAG_WM, "Error delivering DisplayInfo changed event.", e);
}
}
void dump(String prefix, PrintWriter pw) {
pw.println(prefix + "PinnedStackController");
pw.println(prefix + " mIsImeShowing=" + mIsImeShowing);