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
This commit is contained in:
Bruno Martins
2017-12-25 21:16:28 +00:00
parent 112da99f2a
commit 5bcd8016d2
3 changed files with 105 additions and 0 deletions

View File

@@ -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