From 5bcd8016d29f344917970fbe8fd7e1420a6f5ee5 Mon Sep 17 00:00:00 2001 From: Bruno Martins Date: Mon, 25 Dec 2017 21:16:28 +0000 Subject: [PATCH] lineage-sdk: Import device keys custom rebinding configs and add helpers * Used to "live" in fw/b since ever, but will be here from now on. * This also brings AOSP configs (config_longPressOnHomeBehavior and config_doubleTapOnHomeBehavior) to the SDK since those are being extended, putting everything in one place. * Long pressing home button will now default to launch assistant and menu button to open recent apps, leaving the past behind. Change-Id: I0ca2b2cf9a565a334c3edf19a978fa6d2c4d2ea3 --- lineage/res/res/values/config.xml | 64 +++++++++++++++++++ lineage/res/res/values/symbols.xml | 6 ++ .../internal/util/DeviceKeysConstants.java | 35 ++++++++++ 3 files changed, 105 insertions(+) diff --git a/lineage/res/res/values/config.xml b/lineage/res/res/values/config.xml index cdd8d4e4..89404dde 100644 --- a/lineage/res/res/values/config.xml +++ b/lineage/res/res/values/config.xml @@ -168,4 +168,68 @@ For example, a device with Home, Back and Menu keys would set this config to 7. --> 79 + + + 3 + + + 0 + + + 2 + + + 9 diff --git a/lineage/res/res/values/symbols.xml b/lineage/res/res/values/symbols.xml index 6ffd51fd..fbce76d6 100644 --- a/lineage/res/res/values/symbols.xml +++ b/lineage/res/res/values/symbols.xml @@ -120,6 +120,12 @@ + + + + + + diff --git a/sdk/src/java/org/lineageos/internal/util/DeviceKeysConstants.java b/sdk/src/java/org/lineageos/internal/util/DeviceKeysConstants.java index 053afa93..17d7e701 100644 --- a/sdk/src/java/org/lineageos/internal/util/DeviceKeysConstants.java +++ b/sdk/src/java/org/lineageos/internal/util/DeviceKeysConstants.java @@ -16,7 +16,42 @@ package org.lineageos.internal.util; +import android.content.ContentResolver; +import android.os.UserHandle; + +import lineageos.providers.LineageSettings; + public class DeviceKeysConstants { + // Available custom actions to perform on a key press. + // Must match values for KEY_HOME_LONG_PRESS_ACTION in: + // sdk/src/java/lineageos/providers/LineageSettings.java + public enum Action { + NOTHING, + MENU, + APP_SWITCH, + SEARCH, + VOICE_SEARCH, + IN_APP_SEARCH, + LAUNCH_CAMERA, + SLEEP, + LAST_APP, + SPLIT_SCREEN, + SINGLE_HAND_LEFT, + SINGLE_HAND_RIGHT; + + public static Action fromIntSafe(int id) { + if (id < NOTHING.ordinal() || id > Action.values().length) { + return NOTHING; + } + return Action.values()[id]; + } + + public static Action fromSettings(ContentResolver cr, String setting, Action def) { + return fromIntSafe(LineageSettings.System.getIntForUser(cr, + setting, def.ordinal(), UserHandle.USER_CURRENT)); + } + } + // Masks for checking presence of hardware keys. // Must match values in: // lineage/res/res/values/config.xml