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

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

Merge "Cache call to WM#hasNavigationBar" into main

parents cd9005f9 9701d6b4
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ import android.os.UserHandle;
import android.provider.Settings;
import android.util.Log;
import android.util.SparseArray;
import android.util.SparseBooleanArray;
import android.view.Display;
import android.view.IWindowManager;
import android.view.View;
@@ -94,6 +95,9 @@ public class NavigationBarControllerImpl implements
    @VisibleForTesting
    SparseArray<NavigationBar> mNavigationBars = new SparseArray<>();

    /** Local cache for {@link IWindowManager#hasNavigationBar(int)}. */
    private SparseBooleanArray mHasNavBar = new SparseBooleanArray();

    // Tracks config changes that will actually recreate the nav bar
    private final InterestingConfigChanges mConfigChanges = new InterestingConfigChanges(
            ActivityInfo.CONFIG_FONT_SCALE
@@ -221,10 +225,16 @@ public class NavigationBarControllerImpl implements
    }

    private boolean shouldCreateNavBarAndTaskBar(int displayId) {
        if (mHasNavBar.indexOfKey(displayId) > -1) {
            return mHasNavBar.get(displayId);
        }

        final IWindowManager wms = WindowManagerGlobal.getWindowManagerService();

        try {
            return wms.hasNavigationBar(displayId);
            boolean hasNavigationBar = wms.hasNavigationBar(displayId);
            mHasNavBar.put(displayId, hasNavigationBar);
            return hasNavigationBar;
        } catch (RemoteException e) {
            // Cannot get wms, just return false with warning message.
            Log.w(TAG, "Cannot get WindowManager.");