Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c5535ff0 authored by Vinit Nayak's avatar Vinit Nayak Committed by Android (Google) Code Review
Browse files

Merge "Pass IME visibility info to launcher" into sc-dev

parents 610ec381 8c4f7bb9
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -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;
}
+26 −19
Original line number Diff line number Diff line
@@ -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;
        }

@@ -224,14 +216,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);
@@ -246,6 +232,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);
+38 −0
Original line number Diff line number Diff line
/*
 * 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);
    }
}
+17 −0
Original line number Diff line number Diff line
@@ -933,6 +933,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() {
        final int currentUser = ActivityManagerWrapper.getInstance().getCurrentUserId();
        mIsEnabled = mContext.getPackageManager().resolveServiceAsUser(mQuickStepIntent,
@@ -983,5 +998,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) {}
    }
}