diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/recents/IOverviewProxy.aidl b/packages/SystemUI/shared/src/com/android/systemui/shared/recents/IOverviewProxy.aidl index 114472b15f024..277b2e31f7be5 100644 --- a/packages/SystemUI/shared/src/com/android/systemui/shared/recents/IOverviewProxy.aidl +++ b/packages/SystemUI/shared/src/com/android/systemui/shared/recents/IOverviewProxy.aidl @@ -75,4 +75,10 @@ oneway interface IOverviewProxy { * Sent when the split screen is resized */ void onSplitScreenSecondaryBoundsChanged(in Rect bounds, in Rect insets) = 17; + + /** + * Sent IME status changes + */ + void onImeWindowStatusChanged(int displayId, IBinder token, int vis, int backDisposition, + boolean showImeSwitcher) = 18; } diff --git a/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarController.java b/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarController.java index 3544f60601a86..e76cfffe4c843 100644 --- a/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarController.java +++ b/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarController.java @@ -113,6 +113,7 @@ public class NavigationBarController implements Callbacks, private final Handler mHandler; private final DisplayManager mDisplayManager; private final NavigationBarOverlayController mNavBarOverlayController; + private final TaskbarDelegate mTaskbarDelegate; private int mNavMode; private boolean mIsTablet; @@ -182,6 +183,7 @@ public class NavigationBarController implements Callbacks, mNavBarOverlayController = navBarOverlayController; mNavMode = mNavigationModeController.addListener(this); mNavigationModeController.addListener(this); + mTaskbarDelegate = new TaskbarDelegate(mOverviewProxyService); } @Override @@ -190,17 +192,7 @@ public class NavigationBarController implements Callbacks, mIsTablet = isTablet(newConfig); boolean largeScreenChanged = mIsTablet != isOldConfigTablet; // If we folded/unfolded while in 3 button, show navbar in folded state, hide in unfolded - if (isThreeButtonTaskbarFlagEnabled() && - largeScreenChanged && mNavMode == NAV_BAR_MODE_3BUTTON) { - if (!mIsTablet) { - // Folded state, show 3 button nav bar - createNavigationBar(mContext.getDisplay(), null, null); - } else { - // Unfolded state, hide 3 button nav bars - for (int i = 0; i < mNavigationBars.size(); i++) { - removeNavigationBar(mNavigationBars.keyAt(i)); - } - } + if (largeScreenChanged && updateNavbarForTaskbar()) { return; } @@ -221,14 +213,8 @@ public class NavigationBarController implements Callbacks, mNavMode = mode; mHandler.post(() -> { // create/destroy nav bar based on nav mode only in unfolded state - if (isThreeButtonTaskbarFlagEnabled() && oldMode != mNavMode && mIsTablet) { - if (oldMode == NAV_BAR_MODE_3BUTTON && - mNavigationBars.get(mContext.getDisplayId()) == null) { - // We remove navbar for 3 button unfolded, add it back in - createNavigationBar(mContext.getDisplay(), null, null); - } else if (mNavMode == NAV_BAR_MODE_3BUTTON) { - removeNavigationBar(mContext.getDisplayId()); - } + if (oldMode != mNavMode) { + updateNavbarForTaskbar(); } for (int i = 0; i < mNavigationBars.size(); i++) { NavigationBar navBar = mNavigationBars.valueAt(i); @@ -243,6 +229,27 @@ public class NavigationBarController implements Callbacks, }); } + /** + * @return {@code true} if navbar was added/removed, false otherwise + */ + public boolean updateNavbarForTaskbar() { + if (!isThreeButtonTaskbarFlagEnabled()) { + return false; + } + + if (mIsTablet && mNavMode == NAV_BAR_MODE_3BUTTON) { + // Remove navigation bar when taskbar is showing, currently only for 3 button mode + removeNavigationBar(mContext.getDisplayId()); + mCommandQueue.addCallback(mTaskbarDelegate); + } else if (mNavigationBars.get(mContext.getDisplayId()) == null) { + // Add navigation bar after taskbar goes away + createNavigationBar(mContext.getDisplay(), null, null); + mCommandQueue.removeCallback(mTaskbarDelegate); + } + + return true; + } + @Override public void onDisplayRemoved(int displayId) { removeNavigationBar(displayId); diff --git a/packages/SystemUI/src/com/android/systemui/navigationbar/TaskbarDelegate.java b/packages/SystemUI/src/com/android/systemui/navigationbar/TaskbarDelegate.java new file mode 100644 index 0000000000000..03147d8f10852 --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/navigationbar/TaskbarDelegate.java @@ -0,0 +1,38 @@ +/* + * Copyright 2021 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.systemui.navigationbar; + +import android.os.IBinder; + +import com.android.systemui.recents.OverviewProxyService; +import com.android.systemui.statusbar.CommandQueue; + +public class TaskbarDelegate implements CommandQueue.Callbacks { + + private final OverviewProxyService mOverviewProxyService; + + public TaskbarDelegate(OverviewProxyService overviewProxyService) { + mOverviewProxyService = overviewProxyService; + } + + @Override + public void setImeWindowStatus(int displayId, IBinder token, int vis, int backDisposition, + boolean showImeSwitcher) { + mOverviewProxyService.notifyImeWindowStatus(displayId, token, vis, backDisposition, + showImeSwitcher); + } +} diff --git a/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java b/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java index 6d23739b9c780..4aa5e624a5044 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java +++ b/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java @@ -916,6 +916,21 @@ public class OverviewProxyService extends CurrentUserTracker implements } } + public void notifyImeWindowStatus(int displayId, IBinder token, int vis, int backDisposition, + boolean showImeSwitcher) { + try { + if (mOverviewProxy != null) { + mOverviewProxy.onImeWindowStatusChanged(displayId, token, vis, backDisposition, + showImeSwitcher); + } else { + Log.e(TAG_OPS, "Failed to get overview proxy for setting IME status."); + } + } catch (RemoteException e) { + Log.e(TAG_OPS, "Failed to call notifyImeWindowStatus()", e); + } + + } + private void updateEnabledState() { mIsEnabled = mContext.getPackageManager().resolveServiceAsUser(mQuickStepIntent, MATCH_SYSTEM_ONLY, @@ -954,5 +969,7 @@ public class OverviewProxyService extends CurrentUserTracker implements default void onAssistantProgress(@FloatRange(from = 0.0, to = 1.0) float progress) {} default void onAssistantGestureCompletion(float velocity) {} default void startAssistant(Bundle bundle) {} + default void onImeWindowStatusChanged(int displayId, IBinder token, int vis, + int backDisposition, boolean showImeSwitcher) {} } }