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

Commit b7353e25 authored by Ethan Chen's avatar Ethan Chen
Browse files

Reduce number of binder calls by saving nav bar state

Change-Id: I3729d05a34a661cb74e998c40b61c615cdbf83a6
parent 686a4e8f
Loading
Loading
Loading
Loading
+18 −9
Original line number Diff line number Diff line
@@ -221,6 +221,9 @@ public class ViewConfiguration {
    private final int mOverflingDistance;
    private final boolean mFadingMarqueeEnabled;

    private boolean sHasPermanentMenuKey;
    private boolean sHasPermanentMenuKeySet;

    private Context mContext;

    static final SparseArray<ViewConfiguration> sConfigurations =
@@ -290,6 +293,16 @@ public class ViewConfiguration {
        mOverscrollDistance = (int) (sizeAndDensity * OVERSCROLL_DISTANCE + 0.5f);
        mOverflingDistance = (int) (sizeAndDensity * OVERFLING_DISTANCE + 0.5f);

        if (!sHasPermanentMenuKeySet) {
            IWindowManager wm = WindowManagerGlobal.getWindowManagerService();
            try {
                sHasPermanentMenuKey = !wm.hasSystemNavBar() && !wm.hasNavigationBar();
                sHasPermanentMenuKeySet = true;
            } catch (RemoteException ex) {
                sHasPermanentMenuKey = false;
            }
        }

        mFadingMarqueeEnabled = res.getBoolean(
                com.android.internal.R.bool.config_ui_enableFadingMarquee);
        mTouchSlop = res.getDimensionPixelSize(
@@ -670,15 +683,10 @@ public class ViewConfiguration {
     * @return true if a permanent menu key is present, false otherwise.
     */
    public boolean hasPermanentMenuKey() {
        IWindowManager wm = WindowManagerGlobal.getWindowManagerService();
        // Report no menu key if device has soft buttons
        try {
            if (wm.hasSystemNavBar() || wm.hasNavigationBar()) {
        // Report no menu key if only soft buttons are available
        if (!sHasPermanentMenuKey) {
            return false;
        }
        } catch (RemoteException ex) {
            // do nothing, continue trying to guess
        }

        // Report no menu key if overflow button is forced to enabled
        ContentResolver res = mContext.getContentResolver();
@@ -689,10 +697,11 @@ public class ViewConfiguration {
        }

        // Report menu key presence based on hardware key rebinding
        IWindowManager wm = WindowManagerGlobal.getWindowManagerService();
        try {
            return wm.hasMenuKeyEnabled();
        } catch (RemoteException ex) {
            return true;
            return sHasPermanentMenuKey;
        }
    }