diff options
| author | 2020-08-25 19:09:00 +0800 | |
|---|---|---|
| committer | 2020-08-25 19:15:04 +0800 | |
| commit | eb0d1b6e347c0673b68515826570583ece441a3c (patch) | |
| tree | b1ee1c3355fc2ab73c08d89f35bc23e9ea0835ff | |
| parent | 4c2e287219d0345ab81a066f91f535ad53e6d653 (diff) | |
Decouple OverViewProxyService from DividerView
Add registerBoundsChangeListener API to let others register split screen
bounds chagne listener to decouple OverViewProxyService from DividerView.
Bug: 161116823
Test: atest SystemUITests
Test: manual check splitscreen and recents behavior
Change-Id: I25d0bfaa8c044a91266c35d977bcfba76e8d1c24
4 files changed, 40 insertions, 8 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java b/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java index c0cc58638e3f..263bbdbf7c35 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java +++ b/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java @@ -98,6 +98,7 @@ import java.io.PrintWriter; import java.util.ArrayList; import java.util.List; import java.util.Optional; +import java.util.function.BiConsumer; import javax.inject.Inject; @@ -592,6 +593,8 @@ public class OverviewProxyService extends CurrentUserTracker implements }; private final StatusBarWindowCallback mStatusBarWindowCallback = this::onStatusBarStateChanged; + private final BiConsumer<Rect, Rect> mSplitScreenBoundsChangeListener = + this::notifySplitScreenBoundsChanged; // This is the death handler for the binder from the launcher service private final IBinder.DeathRecipient mOverviewServiceDeathRcpt @@ -613,7 +616,6 @@ public class OverviewProxyService extends CurrentUserTracker implements mNavBarControllerLazy = navBarControllerLazy; mStatusBarWinController = statusBarWinController; mConnectionBackoffAttempts = 0; - mSplitScreenOptional = splitScreenOptional; mRecentsComponentName = ComponentName.unflattenFromString(context.getString( com.android.internal.R.string.config_recentsComponentName)); mQuickStepIntent = new Intent(ACTION_QUICKSTEP) @@ -653,6 +655,10 @@ public class OverviewProxyService extends CurrentUserTracker implements }); mCommandQueue = commandQueue; + splitScreenOptional.ifPresent(splitScreen -> + splitScreen.registerBoundsChangeListener(mSplitScreenBoundsChangeListener)); + mSplitScreenOptional = splitScreenOptional; + // Listen for user setup startTracking(); diff --git a/packages/SystemUI/src/com/android/systemui/stackdivider/DividerView.java b/packages/SystemUI/src/com/android/systemui/stackdivider/DividerView.java index 95f048b0b06d..fdf24b1e1a7e 100644 --- a/packages/SystemUI/src/com/android/systemui/stackdivider/DividerView.java +++ b/packages/SystemUI/src/com/android/systemui/stackdivider/DividerView.java @@ -62,10 +62,8 @@ import com.android.internal.logging.nano.MetricsProto.MetricsEvent; import com.android.internal.policy.DividerSnapAlgorithm; import com.android.internal.policy.DividerSnapAlgorithm.SnapTarget; import com.android.internal.policy.DockedDividerUtils; -import com.android.systemui.Dependency; import com.android.systemui.Interpolators; import com.android.systemui.R; -import com.android.systemui.recents.OverviewProxyService; import com.android.systemui.statusbar.FlingAnimationUtils; import java.util.function.Consumer; @@ -138,6 +136,7 @@ public class DividerView extends FrameLayout implements OnTouchListener, private final Rect mOtherInsetRect = new Rect(); private final Rect mLastResizeRect = new Rect(); private final Rect mTmpRect = new Rect(); + private SplitScreenController mSplitScreenController; private WindowManagerProxy mWindowManagerProxy; private DividerWindowManager mWindowManager; private VelocityTracker mVelocityTracker; @@ -353,9 +352,11 @@ public class DividerView extends FrameLayout implements OnTouchListener, } } - public void injectDependencies(DividerWindowManager windowManager, DividerState dividerState, + void injectDependencies(SplitScreenController splitScreenController, + DividerWindowManager windowManager, DividerState dividerState, DividerCallbacks callback, SplitScreenTaskOrganizer tiles, SplitDisplayLayout sdl, DividerImeController imeController, WindowManagerProxy wmProxy) { + mSplitScreenController = splitScreenController; mWindowManager = windowManager; mState = dividerState; mCallback = callback; @@ -697,8 +698,7 @@ public class DividerView extends FrameLayout implements OnTouchListener, mTmpRect.top = 0; break; } - Dependency.get(OverviewProxyService.class) - .notifySplitScreenBoundsChanged(mOtherTaskRect, mTmpRect); + mSplitScreenController.notifyBoundsChanged(mOtherTaskRect, mTmpRect); } private void cancelFlingAnimation() { diff --git a/packages/SystemUI/src/com/android/systemui/stackdivider/SplitScreen.java b/packages/SystemUI/src/com/android/systemui/stackdivider/SplitScreen.java index 91850cc46ab6..93b1f86a5dc2 100644 --- a/packages/SystemUI/src/com/android/systemui/stackdivider/SplitScreen.java +++ b/packages/SystemUI/src/com/android/systemui/stackdivider/SplitScreen.java @@ -16,9 +16,11 @@ package com.android.systemui.stackdivider; +import android.graphics.Rect; import android.window.WindowContainerToken; import java.io.PrintWriter; +import java.util.function.BiConsumer; import java.util.function.Consumer; /** @@ -81,6 +83,9 @@ public interface SplitScreen { /** Registers listener that gets called whenever the existence of the divider changes. */ void registerInSplitScreenListener(Consumer<Boolean> listener); + /** Registers listener that gets called whenever the split screen bounds changes. */ + void registerBoundsChangeListener(BiConsumer<Rect, Rect> listener); + /** @return the container token for the secondary split root task. */ WindowContainerToken getSecondaryRoot(); } diff --git a/packages/SystemUI/src/com/android/systemui/stackdivider/SplitScreenController.java b/packages/SystemUI/src/com/android/systemui/stackdivider/SplitScreenController.java index 11773f6d358c..360b49555612 100644 --- a/packages/SystemUI/src/com/android/systemui/stackdivider/SplitScreenController.java +++ b/packages/SystemUI/src/com/android/systemui/stackdivider/SplitScreenController.java @@ -46,6 +46,7 @@ import com.android.wm.shell.common.TransactionPool; import java.io.PrintWriter; import java.lang.ref.WeakReference; import java.util.ArrayList; +import java.util.function.BiConsumer; import java.util.function.Consumer; /** @@ -73,6 +74,8 @@ public class SplitScreenController implements SplitScreen, private final ArrayList<WeakReference<Consumer<Boolean>>> mDockedStackExistsListeners = new ArrayList<>(); + private final ArrayList<WeakReference<BiConsumer<Rect, Rect>>> mBoundsChangedListeners = + new ArrayList<>(); private DividerWindowManager mWindowManager; @@ -257,8 +260,8 @@ public class SplitScreenController implements SplitScreen, mView = (DividerView) LayoutInflater.from(dctx).inflate(R.layout.docked_stack_divider, null); DisplayLayout displayLayout = mDisplayController.getDisplayLayout(mContext.getDisplayId()); - mView.injectDependencies(mWindowManager, mDividerState, mForcedResizableController, mSplits, - mSplitLayout, mImePositionProcessor, mWindowManagerProxy); + mView.injectDependencies(this, mWindowManager, mDividerState, mForcedResizableController, + mSplits, mSplitLayout, mImePositionProcessor, mWindowManagerProxy); mView.setVisibility(mVisible ? View.VISIBLE : View.INVISIBLE); mView.setMinimizedDockStack(mMinimized, mHomeStackResizable, null /* transaction */); final int size = dctx.getResources().getDimensionPixelSize( @@ -466,6 +469,24 @@ public class SplitScreenController implements SplitScreen, } } + @Override + public void registerBoundsChangeListener(BiConsumer<Rect, Rect> listener) { + synchronized (mBoundsChangedListeners) { + mBoundsChangedListeners.add(new WeakReference<>(listener)); + } + } + + /** Notifies the bounds of split screen changed. */ + void notifyBoundsChanged(Rect secondaryWindowBounds, Rect secondaryWindowInsets) { + synchronized (mBoundsChangedListeners) { + mBoundsChangedListeners.removeIf(wf -> { + BiConsumer<Rect, Rect> l = wf.get(); + if (l != null) l.accept(secondaryWindowBounds, secondaryWindowInsets); + return l == null; + }); + } + } + void startEnterSplit() { update(mDisplayController.getDisplayContext( mContext.getDisplayId()).getResources().getConfiguration()); |