Loading packages/SystemUI/src/com/android/systemui/stackdivider/Divider.java +228 −259 Original line number Diff line number Diff line Loading @@ -129,12 +129,10 @@ public class Divider extends SystemUI implements DividerView.DividerCallbacks, } }; private DisplayImeController.ImePositionProcessor mImePositionProcessor = new DisplayImeController.ImePositionProcessor() { private class DividerImeController implements DisplayImeController.ImePositionProcessor { /** * These are the y positions of the top of the IME surface when it is hidden and * when it is shown respectively. These are NOT necessarily the top of the visible * IME itself. * These are the y positions of the top of the IME surface when it is hidden and when it is * shown respectively. These are NOT necessarily the top of the visible IME itself. */ private int mHiddenTop = 0; private int mShownTop = 0; Loading @@ -142,8 +140,7 @@ public class Divider extends SystemUI implements DividerView.DividerCallbacks, // The following are target states (what we are curretly animating towards). /** * {@code true} if, at the end of the animation, the split task positions should be * adjusted by height of the IME. This happens when the secondary split is the IME * target. * adjusted by height of the IME. This happens when the secondary split is the IME target. */ private boolean mTargetAdjusted = false; /** Loading @@ -153,9 +150,7 @@ public class Divider extends SystemUI implements DividerView.DividerCallbacks, private boolean mTargetShown = false; // The following are the current (most recent) states set during animation /** * {@code true} if the secondary split has IME focus. */ /** {@code true} if the secondary split has IME focus. */ private boolean mSecondaryHasFocus = false; /** The dimming currently applied to the primary/secondary splits. */ private float mLastPrimaryDim = 0.f; Loading @@ -166,10 +161,7 @@ public class Divider extends SystemUI implements DividerView.DividerCallbacks, // The following are states reached last time an animation fully completed. /** {@code true} if the IME was shown/visible by the last-completed animation. */ private boolean mImeWasShown = false; /** * {@code true} if the split positions were adjusted by the last-completed * animation. */ /** {@code true} if the split positions were adjusted by the last-completed animation. */ private boolean mAdjusted = false; /** Loading Loading @@ -210,6 +202,10 @@ public class Divider extends SystemUI implements DividerView.DividerCallbacks, // different split's editor has gained focus while the IME is still visible. startAsyncAnimation(); } updateImeAdjustState(); } private void updateImeAdjustState() { // Reposition the server's secondary split position so that it evaluates // insets properly. WindowContainerTransaction wct = new WindowContainerTransaction(); Loading Loading @@ -271,17 +267,16 @@ public class Divider extends SystemUI implements DividerView.DividerCallbacks, private void onProgress(float progress, SurfaceControl.Transaction t) { if (mTargetAdjusted != mAdjusted) { final float fraction = mTargetAdjusted ? progress : 1.f - progress; mLastAdjustTop = (int) (fraction * mShownTop + (1.f - fraction) * mHiddenTop); mLastAdjustTop = (int) (fraction * mShownTop + (1.f - fraction) * mHiddenTop); mSplitLayout.updateAdjustedBounds(mLastAdjustTop, mHiddenTop, mShownTop); mView.resizeSplitSurfaces(t, mSplitLayout.mAdjustedPrimary, mSplitLayout.mAdjustedSecondary); } final float invProg = 1.f - progress; final float targetPrimaryDim = (mSecondaryHasFocus && mTargetShown) ? ADJUSTED_NONFOCUS_DIM : 0.f; final float targetSecondaryDim = (!mSecondaryHasFocus && mTargetShown) ? ADJUSTED_NONFOCUS_DIM : 0.f; final float targetPrimaryDim = (mSecondaryHasFocus && mTargetShown) ? ADJUSTED_NONFOCUS_DIM : 0.f; final float targetSecondaryDim = (!mSecondaryHasFocus && mTargetShown) ? ADJUSTED_NONFOCUS_DIM : 0.f; mView.setResizeDimLayer(t, true /* primary */, mLastPrimaryDim * invProg + progress * targetPrimaryDim); mView.setResizeDimLayer(t, false /* primary */, Loading Loading @@ -339,7 +334,8 @@ public class Divider extends SystemUI implements DividerView.DividerCallbacks, }); mAnimation.start(); } }; } private final DividerImeController mImePositionProcessor = new DividerImeController(); public Divider(Context context, Optional<Lazy<Recents>> recentsOptionalLazy, DisplayController displayController, SystemWindows systemWindows, Loading Loading @@ -513,42 +509,37 @@ public class Divider extends SystemUI implements DividerView.DividerCallbacks, } } private void setHomeStackResizable(boolean resizable) { if (mHomeStackResizable == resizable) { return; } mHomeStackResizable = resizable; if (!inSplitMode()) { return; /** Switch to minimized state if appropriate */ public void setMinimized(final boolean minimized) { mHandler.post(() -> { setHomeMinimized(minimized, mHomeStackResizable); }); } WindowManagerProxy.applyHomeTasksMinimized(mSplitLayout, mSplits.mSecondary.token); private void setHomeMinimized(final boolean minimized, boolean homeStackResizable) { WindowContainerTransaction wct = new WindowContainerTransaction(); // Update minimized state if (mMinimized != minimized) { mMinimized = minimized; } // Always set this because we could be entering split when mMinimized is already true wct.setFocusable(mSplits.mPrimary.token, !mMinimized); private void updateMinimizedDockedStack(final boolean minimized, final long animDuration, final boolean isHomeStackResizable) { setHomeStackResizable(isHomeStackResizable); if (animDuration > 0) { mView.setMinimizedDockStack(minimized, animDuration, isHomeStackResizable); } else { mView.setMinimizedDockStack(minimized, isHomeStackResizable); // Update home-stack resizability if (mHomeStackResizable != homeStackResizable) { mHomeStackResizable = homeStackResizable; if (inSplitMode()) { WindowManagerProxy.applyHomeTasksMinimized( mSplitLayout, mSplits.mSecondary.token, wct); } updateTouchable(); } /** Switch to minimized state if appropriate */ public void setMinimized(final boolean minimized) { mHandler.post(() -> { if (!inSplitMode()) { return; } if (mMinimized == minimized) { return; // Sync state to DividerView if it exists. if (mView != null) { mView.setMinimizedDockStack(minimized, getAnimDuration(), homeStackResizable); } mMinimized = minimized; WindowManagerProxy.applyPrimaryFocusable(mSplits, !mMinimized); mView.setMinimizedDockStack(minimized, getAnimDuration(), mHomeStackResizable); updateTouchable(); }); WindowManagerProxy.applyContainerTransaction(wct); } void setAdjustedForIme(boolean adjustedForIme) { Loading Loading @@ -646,46 +637,24 @@ public class Divider extends SystemUI implements DividerView.DividerCallbacks, } void ensureMinimizedSplit() { final boolean wasMinimized = mMinimized; mMinimized = true; setHomeStackResizable(mSplits.mSecondary.isResizable()); WindowManagerProxy.applyPrimaryFocusable(mSplits, false /* focusable */); setHomeMinimized(true /* minimized */, mSplits.mSecondary.isResizable()); if (!inSplitMode()) { // Wasn't in split-mode yet, so enter now. if (DEBUG) { Log.d(TAG, " entering split mode with minimized=true"); } updateVisibility(true /* visible */); } else if (!wasMinimized) { if (DEBUG) { Log.d(TAG, " in split mode, but minimizing "); } // Was already in split-mode, update just minimized state. updateMinimizedDockedStack(mMinimized, getAnimDuration(), mHomeStackResizable); } } void ensureNormalSplit() { if (mMinimized) { WindowManagerProxy.applyPrimaryFocusable(mSplits, true /* focusable */); } setHomeMinimized(false /* minimized */, mHomeStackResizable); if (!inSplitMode()) { // Wasn't in split-mode, so enter now. if (DEBUG) { Log.d(TAG, " enter split mode unminimized "); } mMinimized = false; updateVisibility(true /* visible */); } if (mMinimized) { // Was in minimized state, so leave that. if (DEBUG) { Log.d(TAG, " in split mode already, but unminimizing "); } mMinimized = false; updateMinimizedDockedStack(mMinimized, getAnimDuration(), mHomeStackResizable); } } } packages/SystemUI/src/com/android/systemui/stackdivider/DividerWindowManager.java +3 −0 Original line number Diff line number Diff line Loading @@ -88,6 +88,9 @@ public class DividerWindowManager { } public void setTouchable(boolean touchable) { if (mView == null) { return; } boolean changed = false; if (!touchable && (mLp.flags & FLAG_NOT_TOUCHABLE) == 0) { mLp.flags |= FLAG_NOT_TOUCHABLE; Loading packages/SystemUI/src/com/android/systemui/stackdivider/WindowManagerProxy.java +3 −18 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import static android.app.WindowConfiguration.ACTIVITY_TYPE_RECENTS; import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN; import static android.view.Display.DEFAULT_DISPLAY; import android.annotation.NonNull; import android.app.ActivityManager; import android.app.ActivityTaskManager; import android.graphics.Rect; Loading Loading @@ -137,17 +138,13 @@ public class WindowManagerProxy { return resizable; } static void applyHomeTasksMinimized(SplitDisplayLayout layout, IWindowContainer parent) { applyHomeTasksMinimized(layout, parent, null /* transaction */); } /** * Assign a fixed override-bounds to home tasks that reflect their geometry while the primary * split is minimized. This actually "sticks out" of the secondary split area, but when in * minimized mode, the secondary split gets a 'negative' crop to expose it. */ static boolean applyHomeTasksMinimized(SplitDisplayLayout layout, IWindowContainer parent, WindowContainerTransaction t) { @NonNull WindowContainerTransaction wct) { // Resize the home/recents stacks to the larger minimized-state size final Rect homeBounds; final ArrayList<IWindowContainer> homeStacks = new ArrayList<>(); Loading @@ -158,19 +155,9 @@ public class WindowManagerProxy { homeBounds = new Rect(0, 0, layout.mDisplayLayout.width(), layout.mDisplayLayout.height()); } WindowContainerTransaction wct = t != null ? t : new WindowContainerTransaction(); for (int i = homeStacks.size() - 1; i >= 0; --i) { wct.setBounds(homeStacks.get(i), homeBounds); } if (t != null) { return isHomeResizable; } try { ActivityTaskManager.getTaskOrganizerController().applyContainerTransaction(wct, null /* organizer */); } catch (RemoteException e) { Log.e(TAG, "Failed to resize home stacks ", e); } return isHomeResizable; } Loading Loading @@ -301,10 +288,8 @@ public class WindowManagerProxy { } } static void applyPrimaryFocusable(SplitScreenTaskOrganizer splits, boolean focusable) { static void applyContainerTransaction(WindowContainerTransaction wct) { try { WindowContainerTransaction wct = new WindowContainerTransaction(); wct.setFocusable(splits.mPrimary.token, focusable); ActivityTaskManager.getTaskOrganizerController().applyContainerTransaction(wct, null /* organizer */); } catch (RemoteException e) { Loading Loading
packages/SystemUI/src/com/android/systemui/stackdivider/Divider.java +228 −259 Original line number Diff line number Diff line Loading @@ -129,12 +129,10 @@ public class Divider extends SystemUI implements DividerView.DividerCallbacks, } }; private DisplayImeController.ImePositionProcessor mImePositionProcessor = new DisplayImeController.ImePositionProcessor() { private class DividerImeController implements DisplayImeController.ImePositionProcessor { /** * These are the y positions of the top of the IME surface when it is hidden and * when it is shown respectively. These are NOT necessarily the top of the visible * IME itself. * These are the y positions of the top of the IME surface when it is hidden and when it is * shown respectively. These are NOT necessarily the top of the visible IME itself. */ private int mHiddenTop = 0; private int mShownTop = 0; Loading @@ -142,8 +140,7 @@ public class Divider extends SystemUI implements DividerView.DividerCallbacks, // The following are target states (what we are curretly animating towards). /** * {@code true} if, at the end of the animation, the split task positions should be * adjusted by height of the IME. This happens when the secondary split is the IME * target. * adjusted by height of the IME. This happens when the secondary split is the IME target. */ private boolean mTargetAdjusted = false; /** Loading @@ -153,9 +150,7 @@ public class Divider extends SystemUI implements DividerView.DividerCallbacks, private boolean mTargetShown = false; // The following are the current (most recent) states set during animation /** * {@code true} if the secondary split has IME focus. */ /** {@code true} if the secondary split has IME focus. */ private boolean mSecondaryHasFocus = false; /** The dimming currently applied to the primary/secondary splits. */ private float mLastPrimaryDim = 0.f; Loading @@ -166,10 +161,7 @@ public class Divider extends SystemUI implements DividerView.DividerCallbacks, // The following are states reached last time an animation fully completed. /** {@code true} if the IME was shown/visible by the last-completed animation. */ private boolean mImeWasShown = false; /** * {@code true} if the split positions were adjusted by the last-completed * animation. */ /** {@code true} if the split positions were adjusted by the last-completed animation. */ private boolean mAdjusted = false; /** Loading Loading @@ -210,6 +202,10 @@ public class Divider extends SystemUI implements DividerView.DividerCallbacks, // different split's editor has gained focus while the IME is still visible. startAsyncAnimation(); } updateImeAdjustState(); } private void updateImeAdjustState() { // Reposition the server's secondary split position so that it evaluates // insets properly. WindowContainerTransaction wct = new WindowContainerTransaction(); Loading Loading @@ -271,17 +267,16 @@ public class Divider extends SystemUI implements DividerView.DividerCallbacks, private void onProgress(float progress, SurfaceControl.Transaction t) { if (mTargetAdjusted != mAdjusted) { final float fraction = mTargetAdjusted ? progress : 1.f - progress; mLastAdjustTop = (int) (fraction * mShownTop + (1.f - fraction) * mHiddenTop); mLastAdjustTop = (int) (fraction * mShownTop + (1.f - fraction) * mHiddenTop); mSplitLayout.updateAdjustedBounds(mLastAdjustTop, mHiddenTop, mShownTop); mView.resizeSplitSurfaces(t, mSplitLayout.mAdjustedPrimary, mSplitLayout.mAdjustedSecondary); } final float invProg = 1.f - progress; final float targetPrimaryDim = (mSecondaryHasFocus && mTargetShown) ? ADJUSTED_NONFOCUS_DIM : 0.f; final float targetSecondaryDim = (!mSecondaryHasFocus && mTargetShown) ? ADJUSTED_NONFOCUS_DIM : 0.f; final float targetPrimaryDim = (mSecondaryHasFocus && mTargetShown) ? ADJUSTED_NONFOCUS_DIM : 0.f; final float targetSecondaryDim = (!mSecondaryHasFocus && mTargetShown) ? ADJUSTED_NONFOCUS_DIM : 0.f; mView.setResizeDimLayer(t, true /* primary */, mLastPrimaryDim * invProg + progress * targetPrimaryDim); mView.setResizeDimLayer(t, false /* primary */, Loading Loading @@ -339,7 +334,8 @@ public class Divider extends SystemUI implements DividerView.DividerCallbacks, }); mAnimation.start(); } }; } private final DividerImeController mImePositionProcessor = new DividerImeController(); public Divider(Context context, Optional<Lazy<Recents>> recentsOptionalLazy, DisplayController displayController, SystemWindows systemWindows, Loading Loading @@ -513,42 +509,37 @@ public class Divider extends SystemUI implements DividerView.DividerCallbacks, } } private void setHomeStackResizable(boolean resizable) { if (mHomeStackResizable == resizable) { return; } mHomeStackResizable = resizable; if (!inSplitMode()) { return; /** Switch to minimized state if appropriate */ public void setMinimized(final boolean minimized) { mHandler.post(() -> { setHomeMinimized(minimized, mHomeStackResizable); }); } WindowManagerProxy.applyHomeTasksMinimized(mSplitLayout, mSplits.mSecondary.token); private void setHomeMinimized(final boolean minimized, boolean homeStackResizable) { WindowContainerTransaction wct = new WindowContainerTransaction(); // Update minimized state if (mMinimized != minimized) { mMinimized = minimized; } // Always set this because we could be entering split when mMinimized is already true wct.setFocusable(mSplits.mPrimary.token, !mMinimized); private void updateMinimizedDockedStack(final boolean minimized, final long animDuration, final boolean isHomeStackResizable) { setHomeStackResizable(isHomeStackResizable); if (animDuration > 0) { mView.setMinimizedDockStack(minimized, animDuration, isHomeStackResizable); } else { mView.setMinimizedDockStack(minimized, isHomeStackResizable); // Update home-stack resizability if (mHomeStackResizable != homeStackResizable) { mHomeStackResizable = homeStackResizable; if (inSplitMode()) { WindowManagerProxy.applyHomeTasksMinimized( mSplitLayout, mSplits.mSecondary.token, wct); } updateTouchable(); } /** Switch to minimized state if appropriate */ public void setMinimized(final boolean minimized) { mHandler.post(() -> { if (!inSplitMode()) { return; } if (mMinimized == minimized) { return; // Sync state to DividerView if it exists. if (mView != null) { mView.setMinimizedDockStack(minimized, getAnimDuration(), homeStackResizable); } mMinimized = minimized; WindowManagerProxy.applyPrimaryFocusable(mSplits, !mMinimized); mView.setMinimizedDockStack(minimized, getAnimDuration(), mHomeStackResizable); updateTouchable(); }); WindowManagerProxy.applyContainerTransaction(wct); } void setAdjustedForIme(boolean adjustedForIme) { Loading Loading @@ -646,46 +637,24 @@ public class Divider extends SystemUI implements DividerView.DividerCallbacks, } void ensureMinimizedSplit() { final boolean wasMinimized = mMinimized; mMinimized = true; setHomeStackResizable(mSplits.mSecondary.isResizable()); WindowManagerProxy.applyPrimaryFocusable(mSplits, false /* focusable */); setHomeMinimized(true /* minimized */, mSplits.mSecondary.isResizable()); if (!inSplitMode()) { // Wasn't in split-mode yet, so enter now. if (DEBUG) { Log.d(TAG, " entering split mode with minimized=true"); } updateVisibility(true /* visible */); } else if (!wasMinimized) { if (DEBUG) { Log.d(TAG, " in split mode, but minimizing "); } // Was already in split-mode, update just minimized state. updateMinimizedDockedStack(mMinimized, getAnimDuration(), mHomeStackResizable); } } void ensureNormalSplit() { if (mMinimized) { WindowManagerProxy.applyPrimaryFocusable(mSplits, true /* focusable */); } setHomeMinimized(false /* minimized */, mHomeStackResizable); if (!inSplitMode()) { // Wasn't in split-mode, so enter now. if (DEBUG) { Log.d(TAG, " enter split mode unminimized "); } mMinimized = false; updateVisibility(true /* visible */); } if (mMinimized) { // Was in minimized state, so leave that. if (DEBUG) { Log.d(TAG, " in split mode already, but unminimizing "); } mMinimized = false; updateMinimizedDockedStack(mMinimized, getAnimDuration(), mHomeStackResizable); } } }
packages/SystemUI/src/com/android/systemui/stackdivider/DividerWindowManager.java +3 −0 Original line number Diff line number Diff line Loading @@ -88,6 +88,9 @@ public class DividerWindowManager { } public void setTouchable(boolean touchable) { if (mView == null) { return; } boolean changed = false; if (!touchable && (mLp.flags & FLAG_NOT_TOUCHABLE) == 0) { mLp.flags |= FLAG_NOT_TOUCHABLE; Loading
packages/SystemUI/src/com/android/systemui/stackdivider/WindowManagerProxy.java +3 −18 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import static android.app.WindowConfiguration.ACTIVITY_TYPE_RECENTS; import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN; import static android.view.Display.DEFAULT_DISPLAY; import android.annotation.NonNull; import android.app.ActivityManager; import android.app.ActivityTaskManager; import android.graphics.Rect; Loading Loading @@ -137,17 +138,13 @@ public class WindowManagerProxy { return resizable; } static void applyHomeTasksMinimized(SplitDisplayLayout layout, IWindowContainer parent) { applyHomeTasksMinimized(layout, parent, null /* transaction */); } /** * Assign a fixed override-bounds to home tasks that reflect their geometry while the primary * split is minimized. This actually "sticks out" of the secondary split area, but when in * minimized mode, the secondary split gets a 'negative' crop to expose it. */ static boolean applyHomeTasksMinimized(SplitDisplayLayout layout, IWindowContainer parent, WindowContainerTransaction t) { @NonNull WindowContainerTransaction wct) { // Resize the home/recents stacks to the larger minimized-state size final Rect homeBounds; final ArrayList<IWindowContainer> homeStacks = new ArrayList<>(); Loading @@ -158,19 +155,9 @@ public class WindowManagerProxy { homeBounds = new Rect(0, 0, layout.mDisplayLayout.width(), layout.mDisplayLayout.height()); } WindowContainerTransaction wct = t != null ? t : new WindowContainerTransaction(); for (int i = homeStacks.size() - 1; i >= 0; --i) { wct.setBounds(homeStacks.get(i), homeBounds); } if (t != null) { return isHomeResizable; } try { ActivityTaskManager.getTaskOrganizerController().applyContainerTransaction(wct, null /* organizer */); } catch (RemoteException e) { Log.e(TAG, "Failed to resize home stacks ", e); } return isHomeResizable; } Loading Loading @@ -301,10 +288,8 @@ public class WindowManagerProxy { } } static void applyPrimaryFocusable(SplitScreenTaskOrganizer splits, boolean focusable) { static void applyContainerTransaction(WindowContainerTransaction wct) { try { WindowContainerTransaction wct = new WindowContainerTransaction(); wct.setFocusable(splits.mPrimary.token, focusable); ActivityTaskManager.getTaskOrganizerController().applyContainerTransaction(wct, null /* organizer */); } catch (RemoteException e) { Loading