From 52efde97af4eae5a5b318ecd5d4532c44011bac1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=91=A8=E9=9B=B7?= Date: Wed, 28 Feb 2018 16:07:49 +0800 Subject: [PATCH] [Performance] Use bool var judge whether the navi-keys enabled MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Change-Id: Ia30d14c136b7798e2997d43bc601cb361c853e0d Merged-In: Ia30d14c136b7798e2997d43bc601cb361c853e0d Bug: 74392035 Signed-off-by: 周雷 --- .../server/policy/PhoneWindowManager.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/services/core/java/com/android/server/policy/PhoneWindowManager.java b/services/core/java/com/android/server/policy/PhoneWindowManager.java index d21947665c32b..3a88c28a85567 100644 --- a/services/core/java/com/android/server/policy/PhoneWindowManager.java +++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java @@ -722,6 +722,9 @@ public class PhoneWindowManager implements WindowManagerPolicy { // Behavior of Back button while in-call and screen on int mIncallBackBehavior; + // Whether system navigation keys are enabled + boolean mSystemNavigationKeysEnabled; + Display mDisplay; private int mDisplayRotation; @@ -978,6 +981,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(); } @@ -2309,6 +2315,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 wake gesture. boolean wakeGestureEnabledSetting = Settings.Secure.getIntForUser(resolver, @@ -6298,7 +6307,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()); } } @@ -7783,11 +7792,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()) {