-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
288 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
LOCAL_PATH:= $(call my-dir) | ||
|
||
include $(CLEAR_VARS) | ||
LOCAL_MODULE := org.pixelexperience.keyhandler | ||
LOCAL_SRC_FILES := $(call all-java-files-under,src) | ||
LOCAL_MODULE_TAGS := optional | ||
LOCAL_DEX_PREOPT := false | ||
include $(BUILD_JAVA_LIBRARY) |
76 changes: 76 additions & 0 deletions
76
keyhandler/src/org/pixelexperience/settings/device/KeyHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package org.pixelexperience.settings.device; | ||
|
||
import android.app.ActivityManager; | ||
import android.provider.Settings; | ||
import android.content.pm.ActivityInfo; | ||
import android.content.pm.PackageManager; | ||
import android.content.Context; | ||
import android.content.ContentResolver; | ||
import android.view.KeyEvent; | ||
import android.view.InputDevice; | ||
|
||
import java.util.List; | ||
|
||
import com.android.internal.os.DeviceKeyHandler; | ||
import com.android.internal.util.ArrayUtils; | ||
|
||
public class KeyHandler implements DeviceKeyHandler { | ||
|
||
private static final int FP_KEYCODE = KeyEvent.KEYCODE_DPAD_CENTER; | ||
private static final int FP_SCANCODE = 96; | ||
private static final String[] FP_EVENTS = new String[]{"fpc_irq_wakeup", "fp-keys", "uinput-fpc", "uinput-goodix"}; | ||
|
||
private static final String FP_SHUTTER_PREF_KEY = "pref_fingerprint_capture_key"; | ||
private static final String[] ALLOWED_CAMERA_PACKAGES = new String[]{"com.android.camera"}; | ||
|
||
private static ActivityManager am; | ||
private static PackageManager pm; | ||
private static ContentResolver resolver; | ||
|
||
public KeyHandler(Context context) { | ||
am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); | ||
pm = context.getPackageManager(); | ||
resolver = context.getContentResolver(); | ||
} | ||
|
||
public KeyEvent handleKeyEvent(KeyEvent event) { | ||
String deviceName = ""; | ||
int keyCode = event.getKeyCode(); | ||
int scanCode = event.getScanCode(); | ||
int action = event.getAction(); | ||
|
||
if (event.getDeviceId() != -1){ | ||
InputDevice device = InputDevice.getDevice(event.getDeviceId()); | ||
if (device != null){ | ||
deviceName = device.getName(); | ||
} | ||
} | ||
|
||
if (keyCode == FP_KEYCODE && scanCode == FP_SCANCODE && ArrayUtils.contains(FP_EVENTS, deviceName)){ | ||
if (action != KeyEvent.ACTION_DOWN) { | ||
return null; | ||
} | ||
ActivityInfo runningActivity = getRunningActivityInfo(); | ||
if (runningActivity != null && ArrayUtils.contains(ALLOWED_CAMERA_PACKAGES, runningActivity.packageName)){ | ||
return Settings.Secure.getInt(resolver, FP_SHUTTER_PREF_KEY, 0) == 1 ? event : null; | ||
}else{ | ||
return null; | ||
} | ||
} | ||
|
||
return event; | ||
} | ||
|
||
private static ActivityInfo getRunningActivityInfo() { | ||
List<ActivityManager.RunningTaskInfo> tasks = am.getRunningTasks(1); | ||
if (tasks != null && !tasks.isEmpty()) { | ||
ActivityManager.RunningTaskInfo top = tasks.get(0); | ||
try { | ||
return pm.getActivityInfo(top.topActivity, 0); | ||
} catch (PackageManager.NameNotFoundException e) { | ||
} | ||
} | ||
return null; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- | ||
~ Copyright (C) 2018 The Android Open Source 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 | ||
--> | ||
|
||
<!-- | ||
This XML file declares which platform apps that need to access internal APIs. | ||
--> | ||
<config> | ||
<hidden-api-whitelisted-app package="android.car.cluster.maserati" /> | ||
<hidden-api-whitelisted-app package="com.android.apps.tag" /> | ||
<hidden-api-whitelisted-app package="com.android.auto.embedded.cts.verifier" /> | ||
<hidden-api-whitelisted-app package="com.android.car.carlauncher" /> | ||
<hidden-api-whitelisted-app package="com.android.car.home" /> | ||
<hidden-api-whitelisted-app package="com.android.car.retaildemo" /> | ||
<hidden-api-whitelisted-app package="com.android.car.settingslib.robotests" /> | ||
<hidden-api-whitelisted-app package="com.android.car.setupwizardlib.robotests" /> | ||
<hidden-api-whitelisted-app package="com.android.cardock" /> | ||
<hidden-api-whitelisted-app package="com.android.connectivity.metrics" /> | ||
<hidden-api-whitelisted-app package="com.android.facelock" /> | ||
<hidden-api-whitelisted-app package="com.android.google.gce.gceservice" /> | ||
<hidden-api-whitelisted-app package="com.android.hotwordenrollment.okgoogle" /> | ||
<hidden-api-whitelisted-app package="com.android.hotwordenrollment.tgoogle" /> | ||
<hidden-api-whitelisted-app package="com.android.hotwordenrollment.xgoogle" /> | ||
<hidden-api-whitelisted-app package="com.android.inputmethod.latin" /> | ||
<hidden-api-whitelisted-app package="com.android.media.update" /> | ||
<hidden-api-whitelisted-app package="com.android.netspeed" /> | ||
<hidden-api-whitelisted-app package="com.android.onemedia" /> | ||
<hidden-api-whitelisted-app package="com.android.pixellogger" /> | ||
<hidden-api-whitelisted-app package="com.android.ramdump" /> | ||
<hidden-api-whitelisted-app package="com.android.settingslib.robotests" /> | ||
<hidden-api-whitelisted-app package="com.android.simappdialog" /> | ||
<hidden-api-whitelisted-app package="com.android.statsd.dogfood" /> | ||
<hidden-api-whitelisted-app package="com.android.statsd.loadtest" /> | ||
<hidden-api-whitelisted-app package="com.android.systemui.shared" /> | ||
<hidden-api-whitelisted-app package="com.android.test.power" /> | ||
<hidden-api-whitelisted-app package="com.android.test.voiceenrollment" /> | ||
<hidden-api-whitelisted-app package="com.android.tv.provision" /> | ||
<hidden-api-whitelisted-app package="com.google.SSRestartDetector" /> | ||
<hidden-api-whitelisted-app package="com.google.android.apps.nexuslauncher" /> | ||
<hidden-api-whitelisted-app package="com.google.android.asdiv" /> | ||
<hidden-api-whitelisted-app package="com.google.android.athome.globalkeyinterceptor" /> | ||
<hidden-api-whitelisted-app package="com.google.android.car.bugreport" /> | ||
<hidden-api-whitelisted-app package="com.google.android.car.defaultstoragemonitoringcompanionapp" /> | ||
<hidden-api-whitelisted-app package="com.google.android.car.diagnosticrecorder" /> | ||
<hidden-api-whitelisted-app package="com.google.android.car.diagnosticverifier" /> | ||
<hidden-api-whitelisted-app package="com.google.android.car.diskwriteapp" /> | ||
<hidden-api-whitelisted-app package="com.google.android.car.flashapp" /> | ||
<hidden-api-whitelisted-app package="com.google.android.car.kitchensink" /> | ||
<hidden-api-whitelisted-app package="com.google.android.car.obd2app" /> | ||
<hidden-api-whitelisted-app package="com.google.android.car.setupwizard" /> | ||
<hidden-api-whitelisted-app package="com.google.android.car.usb.aoap.host" /> | ||
<hidden-api-whitelisted-app package="com.google.android.car.vms.subscriber" /> | ||
<hidden-api-whitelisted-app package="com.google.android.carrier" /> | ||
<hidden-api-whitelisted-app package="com.google.android.carriersetup" /> | ||
<hidden-api-whitelisted-app package="com.google.android.connectivitymonitor" /> | ||
<hidden-api-whitelisted-app package="com.google.android.edu.harnesssettings" /> | ||
<hidden-api-whitelisted-app package="com.google.android.ext.services" /> | ||
<hidden-api-whitelisted-app package="com.google.android.factoryota" /> | ||
<hidden-api-whitelisted-app package="com.google.android.feedback" /> | ||
<hidden-api-whitelisted-app package="com.google.android.gsf" /> | ||
<hidden-api-whitelisted-app package="com.google.android.hardwareinfo" /> | ||
<hidden-api-whitelisted-app package="com.google.android.hiddenmenu" /> | ||
<hidden-api-whitelisted-app package="com.google.android.onetimeinitializer" /> | ||
<hidden-api-whitelisted-app package="com.google.android.packageinstaller" /> | ||
<hidden-api-whitelisted-app package="com.google.android.partner.provisioning" /> | ||
<hidden-api-whitelisted-app package="com.google.android.partnersetup" /> | ||
<hidden-api-whitelisted-app package="com.google.android.preloaded_drawable_viewer" /> | ||
<hidden-api-whitelisted-app package="com.google.android.printservice.recommendation" /> | ||
<hidden-api-whitelisted-app package="com.google.android.sampledeviceowner" /> | ||
<hidden-api-whitelisted-app package="com.google.android.apps.scone" /> | ||
<hidden-api-whitelisted-app package="com.google.android.sdksetup" /> | ||
<hidden-api-whitelisted-app package="com.google.android.setupwizard" /> | ||
<hidden-api-whitelisted-app package="com.google.android.storagemanager" /> | ||
<hidden-api-whitelisted-app package="com.google.android.tag" /> | ||
<hidden-api-whitelisted-app package="com.google.android.tungsten.overscan" /> | ||
<hidden-api-whitelisted-app package="com.google.android.tungsten.setupwraith" /> | ||
<hidden-api-whitelisted-app package="com.google.android.tv.bugreportsender" /> | ||
<hidden-api-whitelisted-app package="com.google.android.tv.frameworkpackagestubs" /> | ||
<hidden-api-whitelisted-app package="com.google.android.tv.pairedsetup" /> | ||
<hidden-api-whitelisted-app package="com.google.android.vendorloggingservice" /> | ||
<hidden-api-whitelisted-app package="com.google.android.volta" /> | ||
<hidden-api-whitelisted-app package="com.google.android.wfcactivation" /> | ||
<hidden-api-whitelisted-app package="com.google.mds" /> | ||
<hidden-api-whitelisted-app package="com.google.modemservice" /> | ||
<hidden-api-whitelisted-app package="com.htc.omadm.trigger" /> | ||
<hidden-api-whitelisted-app package="com.qualcomm.qcrilmsgtunnel" /> | ||
<hidden-api-whitelisted-app package="org.chromium.arc.accessibilityhelper" /> | ||
<hidden-api-whitelisted-app package="org.chromium.arc.apkcacheprovider" /> | ||
<hidden-api-whitelisted-app package="org.chromium.arc.applauncher" /> | ||
<hidden-api-whitelisted-app package="org.chromium.arc.backup_settings" /> | ||
<hidden-api-whitelisted-app package="org.chromium.arc.cast_receiver" /> | ||
<hidden-api-whitelisted-app package="org.chromium.arc.crash_collector" /> | ||
<hidden-api-whitelisted-app package="org.chromium.arc.file_system" /> | ||
<hidden-api-whitelisted-app package="org.chromium.arc.gms" /> | ||
<hidden-api-whitelisted-app package="org.chromium.arc.home" /> | ||
<hidden-api-whitelisted-app package="org.chromium.arc.intent_helper" /> | ||
<hidden-api-whitelisted-app package="org.chromium.arc.tts" /> | ||
</config> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- Copyright (C) 2014 The Android Open Source 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. | ||
--> | ||
|
||
<!-- These are configurations that should exist on Google's own Nexus and GPe devices. --> | ||
<config> | ||
<feature name="com.google.android.feature.GOOGLE_BUILD" /> | ||
<!-- This should be added to all Nexus and GPe devices --> | ||
<feature name="com.google.android.feature.GOOGLE_EXPERIENCE" /> | ||
<!-- This should declare the version of Exchange that ships --> | ||
<feature name="com.google.android.feature.EXCHANGE_6_2" /> | ||
</config> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
|
||
<!-- These are configurations that should exist on Google's 2016 and newer Nexus devices. --> | ||
<config> | ||
<!-- This is meant to be the canonical feature identifying 2016 and newer Nexus devices. --> | ||
<feature name="com.google.android.feature.PIXEL_EXPERIENCE" /> | ||
|
||
<!-- Both versions of this string are needed due to a miscommunication. b/29978934 --> | ||
<feature name="com.google.android.apps.photos.NEXUS_PRELOAD" /> | ||
<feature name="com.google.android.apps.photos.nexus_preload" /> | ||
|
||
<!-- Enable Zero Touch Provisioning support for 2016 and newer Nexus devices. --> | ||
<feature name="com.google.android.feature.ZERO_TOUCH" /> | ||
|
||
<!-- Allow Google unbundled tethering entitlement app in background --> | ||
<allow-in-power-save package="com.google.android.tetheringentitlement" /> | ||
|
||
<!-- Allow ssr detector service in background --> | ||
<allow-in-power-save package="com.google.SSRestartDetector" /> | ||
|
||
<!-- Allow ramdump uploader service in background --> | ||
<allow-in-power-save package="com.android.ramdump" /> | ||
|
||
<!-- These are telephony components that need to run in the background --> | ||
<allow-in-power-save package="com.qualcomm.atfwd" /> | ||
<allow-in-power-save package="com.qualcomm.embms" /> | ||
<allow-in-power-save package="com.qualcomm.qti.telephonyservice" /> | ||
<allow-in-power-save package="com.qulacomm.qcrilmsgtunnel" /> | ||
<allow-in-power-save package="com.qualcomm.qti.ims" /> | ||
<allow-in-power-save package="com.qualcomm.qti.radioconfiginterface" /> | ||
</config> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
|
||
<!-- These are configurations that should exist on Google's 2017 and newer Nexus devices. --> | ||
<config> | ||
<!-- This is meant to be the canonical feature identifying 2017 and newer Nexus devices. --> | ||
<feature name="com.google.android.feature.PIXEL_2017_EXPERIENCE" /> | ||
</config> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
|
||
<!-- These are configurations that should exist on Google's 2017 devices (and not newer/older) --> | ||
<config> | ||
<!-- This defines the Photos preload feature for specifically the 2017 Pixel devices. --> | ||
<feature name="com.google.android.apps.photos.PIXEL_2017_PRELOAD" /> | ||
</config> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
add_lunch_combo beast_vince-userdebug | ||
add_lunch_combo aosp_vince-userdebug |