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

Commit 271eae23 authored by Bruno Martins's avatar Bruno Martins
Browse files

Add support for runtime toggle of navbar

This is a refactor of the following changes, so to make use of tuner API.

Author: Timo Wendt <timo@tjwendt.de>
Date:   Thu Aug 30 12:18:41 2012 +0300

    Runtime toggle of navbar

    This adds the framework support for enabling the Navigation bar
    on devices with hardware keys. It is toggled from Settings, and
    depends on device-specific support for the KeyDisabler hardware
    control

    Change-Id: I88fecb2ca1e8613591c327a93f53909b00239cd8

    wm: Nullify hardkey function assignments if enabling the navbar

    This caused erroneous (and sometimes duplicate) events being generated
    due to the regular key function assignments. The navbar does its
    own action management, so don't try to derive from the actions
    usually present in hard keys.

    Change-Id: I82866e24547f8145cac4f07820ae90aacce09281

    Update DEV_FORCE_SHOW_NAVBAR constant.

    Change-Id: Ie5b4317162c514d22276956f81007e064a3d0f32

    Settings: Move DEV_FORCE_SHOW_NAVBAR load to loadSecureSettings.

    Change-Id: I6ac53b8c9f7fce6f9ca6b4ad7bf31a1c1e896863

Author: Paul Keith <javelinanddart@gmail.com>
Date:   Tue Jan 16 15:47:07 2018 +0100

    PhoneWindowManager: Make sure KeyDisabler is always called on boot

    * Otherwise, some KeyDisabler classes are left in a weird state
    * Because we don't keep track of whether an initial state was ever set,
      we never call KeyDisabler on boot if the setting is set to 0
    * To remedy this, keep track of whether an initial state was set

    Change-Id: Ib432ed3278dd8f4f4cba3ba488879b3c1cd9c8f4

Change-Id: I4a6d3f89bc171c3921875b24c077cb78c03517ad
parent b9587bb3
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -283,6 +283,8 @@ public class StatusBar extends SystemUI implements DemoMode, TunerService.Tunabl
            "lineagesystem:" + LineageSettings.System.STATUS_BAR_BRIGHTNESS_CONTROL;
    private static final String LOCKSCREEN_MEDIA_METADATA =
            "lineagesecure:" + LineageSettings.Secure.LOCKSCREEN_MEDIA_METADATA;
    private static final String FORCE_SHOW_NAVBAR =
            "lineagesystem:" + LineageSettings.System.FORCE_SHOW_NAVBAR;

    private static final String BANNER_ACTION_CANCEL =
            "com.android.systemui.statusbar.banner_action_cancel";
@@ -702,6 +704,7 @@ public class StatusBar extends SystemUI implements DemoMode, TunerService.Tunabl
        tunerService.addTunable(this, SCREEN_BRIGHTNESS_MODE);
        tunerService.addTunable(this, STATUS_BAR_BRIGHTNESS_CONTROL);
        tunerService.addTunable(this, LOCKSCREEN_MEDIA_METADATA);
        tunerService.addTunable(this, FORCE_SHOW_NAVBAR);

        mDisplayManager = mContext.getSystemService(DisplayManager.class);

@@ -5776,6 +5779,15 @@ public class StatusBar extends SystemUI implements DemoMode, TunerService.Tunabl
            mBrightnessControl = newValue != null && Integer.parseInt(newValue) == 1;
        } else if (LOCKSCREEN_MEDIA_METADATA.equals(key)) {
            mShowMediaMetadata = newValue != null && Integer.parseInt(newValue) == 1;
        } else if (mWindowManagerService != null && FORCE_SHOW_NAVBAR.equals(key)) {
            boolean forcedVisibility = newValue != null && Integer.parseInt(newValue) == 1;

            if (forcedVisibility && mNavigationBarView == null) {
                createNavigationBar();
            } else if (mNavigationBarView != null) {
                mWindowManager.removeViewImmediate(mNavigationBarView);
                mNavigationBarView = null;
            }
        }
    }
    // End Extra BaseStatusBarMethods.
+27 −1
Original line number Diff line number Diff line
@@ -290,6 +290,7 @@ import com.android.server.wm.DisplayFrames;
import com.android.server.wm.WindowManagerInternal;
import com.android.server.wm.WindowManagerInternal.AppTransitionListener;

import lineageos.hardware.LineageHardwareManager;
import lineageos.providers.LineageSettings;

import java.io.File;
@@ -723,6 +724,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    int mInitialMetaState;
    boolean mForceShowSystemBars;

    boolean mNeedsNavigationBar;
    int mForceNavbar = -1;

    // support for activating the lock screen while the screen is on
    boolean mAllowLockscreenWhenOn;
    int mLockScreenTimeout;
@@ -861,6 +865,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    private static final int MSG_REQUEST_TRANSIENT_BARS_ARG_STATUS = 0;
    private static final int MSG_REQUEST_TRANSIENT_BARS_ARG_NAVIGATION = 1;

    private LineageHardwareManager mLineageHardware;

    private class PolicyHandler extends Handler {
        @Override
        public void handleMessage(Message msg) {
@@ -1029,6 +1035,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                    Settings.Secure.SYSTEM_NAVIGATION_KEYS_ENABLED), false, this,
                    UserHandle.USER_ALL);

            resolver.registerContentObserver(LineageSettings.System.getUriFor(
                    LineageSettings.System.FORCE_SHOW_NAVBAR), false, this,
                    UserHandle.USER_ALL);
            resolver.registerContentObserver(LineageSettings.System.getUriFor(
                    LineageSettings.System.ACCELEROMETER_ROTATION_ANGLES), false, this,
                    UserHandle.USER_ALL);
@@ -2066,7 +2075,6 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            mOrientationListener.setCurrentRotation(windowManager.getDefaultDisplayRotation());
        } catch (RemoteException ex) { }
        mSettingsObserver = new SettingsObserver(mHandler);
        mSettingsObserver.observe();
        mShortcutManager = new ShortcutManager(context);
        mUiMode = context.getResources().getInteger(
                com.android.internal.R.integer.config_defaultUiModeType);
@@ -2426,6 +2434,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            mHasNavigationBar = true;
        }

        mNeedsNavigationBar = mHasNavigationBar;

        // For demo purposes, allow the rotation of the HDMI display to be controlled.
        // By default, HDMI locks rotation to landscape.
        if ("portrait".equals(SystemProperties.get("persist.demo.hdmirotation"))) {
@@ -2521,6 +2531,17 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                updateWakeGestureListenerLp();
            }

            int forceNavbar = LineageSettings.System.getInt(resolver,
                    LineageSettings.System.FORCE_SHOW_NAVBAR, 0);
            if (forceNavbar != mForceNavbar) {
                mForceNavbar = forceNavbar;
                if (mLineageHardware.isSupported(LineageHardwareManager.FEATURE_KEY_DISABLE)) {
                    mLineageHardware.set(LineageHardwareManager.FEATURE_KEY_DISABLE,
                            mForceNavbar == 1);
                }
                mHasNavigationBar = mNeedsNavigationBar || mForceNavbar == 1;
            }

            // Configure rotation lock.
            int userRotation = Settings.System.getIntForUser(resolver,
                    Settings.System.USER_ROTATION, Surface.ROTATION_0,
@@ -7691,6 +7712,11 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            mVrManagerInternal.addPersistentVrModeStateListener(mPersistentVrModeListener);
        }

        mLineageHardware = LineageHardwareManager.getInstance(mContext);
        // Ensure observe happens in systemReady() since we need
        // LineageHardwareService to be up and running
        mSettingsObserver.observe();

        readCameraLensCoverState();
        updateUiMode();
        synchronized (mLock) {
+10 −1
Original line number Diff line number Diff line
@@ -689,6 +689,8 @@ public final class PowerManagerService extends SystemService
    private SensorEventListener mProximityListener;
    private android.os.PowerManager.WakeLock mProximityWakeLock;

    private boolean mForceNavbar;

    public PowerManagerService(Context context) {
        super(context);
        mContext = context;
@@ -896,6 +898,9 @@ public final class PowerManagerService extends SystemService
        resolver.registerContentObserver(LineageSettings.Global.getUriFor(
                LineageSettings.Global.WAKE_WHEN_PLUGGED_OR_UNPLUGGED),
                false, mSettingsObserver, UserHandle.USER_ALL);
        resolver.registerContentObserver(LineageSettings.System.getUriFor(
                LineageSettings.System.FORCE_SHOW_NAVBAR),
                false, mSettingsObserver, UserHandle.USER_ALL);

        IVrManager vrManager = (IVrManager) getBinderService(Context.VR_SERVICE);
        if (vrManager != null) {
@@ -1036,6 +1041,10 @@ public final class PowerManagerService extends SystemService
                LineageSettings.System.BUTTON_BACKLIGHT_ONLY_WHEN_PRESSED,
                0, UserHandle.USER_CURRENT) == 1;

        mForceNavbar = LineageSettings.System.getIntForUser(resolver,
                LineageSettings.System.FORCE_SHOW_NAVBAR,
                0, UserHandle.USER_CURRENT) == 1;

        mProximityWakeEnabled = LineageSettings.System.getInt(resolver,
                LineageSettings.System.PROXIMITY_ON_WAKE,
                mProximityWakeEnabledByDefaultConfig ? 1 : 0) == 1;
@@ -2066,7 +2075,7 @@ public final class PowerManagerService extends SystemService
                            if (mButtonBrightnessOverrideFromWindowManager >= 0) {
                                buttonBrightness = mButtonBrightnessOverrideFromWindowManager;
                            } else {
                                buttonBrightness = mButtonBrightness;
                                buttonBrightness = !mForceNavbar ? mButtonBrightness : 0;
                            }

                            mLastButtonActivityTime = mButtonLightOnKeypressOnly ?