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

Commit 6aed2ee2 authored by Siarhei Vishniakou's avatar Siarhei Vishniakou
Browse files

Use bool var judge whether the navi-keys enabled



[Performance] if device enabled the system navigation keys,the system
will go to readthe Settings.Secure.SYSTEM_NAVIGATION_KEYS_ENABLED
provider while the driverreport KEYCODE_SYSTEM_NAVIGATION_RIGHT
every times,this operation has a serious impact on performance

Test: cherry-picked from aosp
Change-Id: Ia30d14c136b7798e2997d43bc601cb361c853e0d
Signed-off-by: default avatar周雷 <zhoulei5@xiaomi.com>
parent f4a36820
Loading
Loading
Loading
Loading
+10 −6
Original line number Diff line number Diff line
@@ -720,6 +720,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    // Behavior of rotation suggestions. (See Settings.Secure.SHOW_ROTATION_SUGGESTION)
    int mShowRotationSuggestions;

    // Whether system navigation keys are enabled
    boolean mSystemNavigationKeysEnabled;

    Display mDisplay;

    int mLandscapeRotation = 0;  // default landscape rotation
@@ -983,6 +986,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            resolver.registerContentObserver(Settings.Global.getUriFor(
                    Settings.Global.POLICY_CONTROL), false, this,
                    UserHandle.USER_ALL);
            resolver.registerContentObserver(Settings.Global.getUriFor(
                    Settings.Secure.SYSTEM_NAVIGATION_KEYS_ENABLED), false, this,
                    UserHandle.USER_ALL);
            updateSettings();
        }

@@ -2358,6 +2364,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                    Settings.Secure.INCALL_BACK_BUTTON_BEHAVIOR,
                    Settings.Secure.INCALL_BACK_BUTTON_BEHAVIOR_DEFAULT,
                    UserHandle.USER_CURRENT);
            mSystemNavigationKeysEnabled = Settings.Secure.getIntForUser(resolver,
                    Settings.Secure.SYSTEM_NAVIGATION_KEYS_ENABLED,
                    0, UserHandle.USER_CURRENT) == 1;

            // Configure rotation suggestions.
            int showRotationSuggestions = Settings.Secure.getIntForUser(resolver,
@@ -6201,7 +6210,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        if (event.getAction() == KeyEvent.ACTION_UP) {
            if (!mAccessibilityManager.isEnabled()
                    || !mAccessibilityManager.sendFingerprintGesture(event.getKeyCode())) {
                if (areSystemNavigationKeysEnabled()) {
                if (mSystemNavigationKeysEnabled) {
                    sendSystemKeyToStatusBarAsync(event.getKeyCode());
                }
            }
@@ -7780,11 +7789,6 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                Settings.Global.THEATER_MODE_ON, 0) == 1;
    }

    private boolean areSystemNavigationKeysEnabled() {
        return Settings.Secure.getIntForUser(mContext.getContentResolver(),
                Settings.Secure.SYSTEM_NAVIGATION_KEYS_ENABLED, 0, UserHandle.USER_CURRENT) == 1;
    }

    @Override
    public boolean performHapticFeedbackLw(WindowState win, int effectId, boolean always) {
        if (!mVibrator.hasVibrator()) {