From e95cf897590b5ab6b25ac286e8baf6eaec9dd297 Mon Sep 17 00:00:00 2001 From: Davide Garberi Date: Fri, 10 May 2019 20:36:24 +0200 Subject: msm8996-common: configpanel: Adapt for z2_plus * Remove nodes we aren't using, we'll use this only to enable/disable fingerprint wakeup and disable proximity check Change-Id: Ibe24cacbe77d6913fa35ed77fefb4e969269f7df --- configpanel/AndroidManifest.xml | 2 - configpanel/res/xml/button_panel.xml | 10 --- .../settings/device/ButtonSettingsFragment.java | 3 +- .../ConfigPanelSearchIndexablesProvider.java | 4 +- .../org/lineageos/settings/device/Constants.java | 21 +---- .../org/lineageos/settings/device/KeyHandler.java | 94 ---------------------- .../src/org/lineageos/settings/device/Startup.java | 5 +- 7 files changed, 4 insertions(+), 135 deletions(-) delete mode 100644 configpanel/src/org/lineageos/settings/device/KeyHandler.java diff --git a/configpanel/AndroidManifest.xml b/configpanel/AndroidManifest.xml index f62e7fc..4ee1dad 100644 --- a/configpanel/AndroidManifest.xml +++ b/configpanel/AndroidManifest.xml @@ -56,8 +56,6 @@ - - diff --git a/configpanel/res/xml/button_panel.xml b/configpanel/res/xml/button_panel.xml index 43f4902..6e13cb6 100644 --- a/configpanel/res/xml/button_panel.xml +++ b/configpanel/res/xml/button_panel.xml @@ -17,20 +17,10 @@ --> - - - - sNodeDependencyMap = new HashMap<>(); public static final String[] sButtonPrefKeys = { - BUTTON_SWAP_KEY, - FP_HOME_KEY, FP_WAKEUP_KEY }; static { - if (FileUtils.fileExists(Constants.CYTTSP_BUTTON_SWAP_NODE)) { - sBooleanNodePreferenceMap.put(BUTTON_SWAP_KEY, CYTTSP_BUTTON_SWAP_NODE); - } else if (FileUtils.fileExists(Constants.TOUCHPANEL_BUTTON_SWAP_NODE)) { - sBooleanNodePreferenceMap.put(BUTTON_SWAP_KEY, TOUCHPANEL_BUTTON_SWAP_NODE); - } - sBooleanNodePreferenceMap.put(FP_HOME_KEY, FP_HOME_KEY_NODE); sBooleanNodePreferenceMap.put(FP_WAKEUP_KEY, FP_WAKEUP_NODE); - sNodeDefaultMap.put(BUTTON_SWAP_KEY, false); - sNodeDefaultMap.put(FP_HOME_KEY, false); sNodeDefaultMap.put(FP_WAKEUP_KEY, true); - - sNodeDependencyMap.put(FP_HOME_KEY, new String[]{ VIRTUAL_KEYS_NODE, "1" }); } } diff --git a/configpanel/src/org/lineageos/settings/device/KeyHandler.java b/configpanel/src/org/lineageos/settings/device/KeyHandler.java deleted file mode 100644 index 247624b..0000000 --- a/configpanel/src/org/lineageos/settings/device/KeyHandler.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (C) 2017-2019 The LineageOS Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.lineageos.settings.device; - -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; -import android.content.IntentFilter; -import android.os.UserHandle; -import android.provider.Settings; -import android.util.Log; -import android.view.KeyEvent; - -import com.android.internal.os.DeviceKeyHandler; - -import lineageos.providers.LineageSettings; - -import org.lineageos.internal.util.FileUtils; - -public class KeyHandler implements DeviceKeyHandler { - - private static final String TAG = KeyHandler.class.getSimpleName(); - - private static final String FP_HOME_NODE = "/sys/devices/soc/soc:fpc_fpc1020/enable_key_events"; - - private static boolean sScreenTurnedOn = true; - private static final boolean DEBUG = false; - - private final Context mContext; - - private final BroadcastReceiver mScreenStateReceiver = new BroadcastReceiver() { - @Override - public void onReceive(Context context, Intent intent) { - if (intent.getAction().equals(Intent.ACTION_SCREEN_OFF)) { - sScreenTurnedOn = false; - } else if (intent.getAction().equals(Intent.ACTION_SCREEN_ON)) { - sScreenTurnedOn = true; - } - } - }; - - public KeyHandler(Context context) { - mContext = context; - - IntentFilter screenStateFilter = new IntentFilter(); - screenStateFilter.addAction(Intent.ACTION_SCREEN_OFF); - screenStateFilter.addAction(Intent.ACTION_SCREEN_ON); - mContext.registerReceiver(mScreenStateReceiver, screenStateFilter); - } - - public KeyEvent handleKeyEvent(KeyEvent event) { - boolean virtualKeysEnabled = LineageSettings.System.getIntForUser( - mContext.getContentResolver(), - LineageSettings.System.FORCE_SHOW_NAVBAR, 0, UserHandle.USER_CURRENT) != 0; - boolean fingerprintHomeButtonEnabled = FileUtils.isFileReadable(FP_HOME_NODE) && - FileUtils.readOneLine(FP_HOME_NODE).equals("1"); - - if (!hasSetupCompleted()) { - return event; - } - - if (event.getKeyCode() == KeyEvent.KEYCODE_HOME) { - if (event.getScanCode() == 96) { - if (DEBUG) Log.d(TAG, "Fingerprint home button tapped"); - return virtualKeysEnabled ? null : event; - } - if (event.getScanCode() == 102) { - if (DEBUG) Log.d(TAG, "Mechanical home button pressed"); - return sScreenTurnedOn && - (virtualKeysEnabled || fingerprintHomeButtonEnabled) ? null : event; - } - } - return event; - } - - private boolean hasSetupCompleted() { - return Settings.Secure.getInt(mContext.getContentResolver(), - Settings.Secure.USER_SETUP_COMPLETE, 0) != 0; - } -} diff --git a/configpanel/src/org/lineageos/settings/device/Startup.java b/configpanel/src/org/lineageos/settings/device/Startup.java index 4311cb5..2f3f8fd 100644 --- a/configpanel/src/org/lineageos/settings/device/Startup.java +++ b/configpanel/src/org/lineageos/settings/device/Startup.java @@ -70,10 +70,7 @@ public class Startup extends BroadcastReceiver { } static boolean hasButtonProcs() { - return (FileUtils.fileExists(Constants.CYTTSP_BUTTON_SWAP_NODE) || - FileUtils.fileExists(Constants.FP_HOME_KEY_NODE) || - FileUtils.fileExists(Constants.FP_WAKEUP_NODE) || - FileUtils.fileExists(Constants.TOUCHPANEL_BUTTON_SWAP_NODE)); + return (FileUtils.fileExists(Constants.FP_WAKEUP_NODE)); } private void disableComponent(Context context, String component) { -- cgit v1.2.3