Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 61da25aa authored by Siarhei Vishniakou's avatar Siarhei Vishniakou
Browse files

Move SPECIAL_FUNCTION from .kcm to .idc files

Currently, the only use of device-specific .kcm files is to specify
SPECIAL_FUNCTION flag (meaning that this keyboard is only used to
perform system control functions and not for typing).

Instead of adding a special .kcm file, use .idc files with se
keyboard.specialFunction = 1 to achieve the same functionality. This
allows the removal of all device-specific .kcm files.

The .kcm functionality will remain in P (with a warning). The
functionality will be removed in Q.

Bug: 67718661
Test: tested the codepath on Android wear device via logging
Change-Id: I1b4572456fa42caae1282dd8d3557820671b3610
parent c1d316f4
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -51,6 +51,9 @@ public:
        KEYBOARD_TYPE_PREDICTIVE = 2,
        KEYBOARD_TYPE_ALPHA = 3,
        KEYBOARD_TYPE_FULL = 4,
        /**
         * Deprecated. Set 'keyboard.specialFunction' to '1' in the device's IDC file instead.
         */
        KEYBOARD_TYPE_SPECIAL_FUNCTION = 5,
        KEYBOARD_TYPE_OVERLAY = 6,
    };
+3 −0
Original line number Diff line number Diff line
@@ -824,6 +824,9 @@ status_t KeyCharacterMap::Parser::parseType() {
    } else if (typeToken == "FULL") {
        type = KEYBOARD_TYPE_FULL;
    } else if (typeToken == "SPECIAL_FUNCTION") {
        ALOGW("The SPECIAL_FUNCTION type is now declared in the device's IDC file, please set "
                "the property 'keyboard.specialFunction' to '1' there instead.");
        // TODO: return BAD_VALUE here in Q
        type = KEYBOARD_TYPE_SPECIAL_FUNCTION;
    } else if (typeToken == "OVERLAY") {
        type = KEYBOARD_TYPE_OVERLAY;
+11 −1
Original line number Diff line number Diff line
@@ -148,9 +148,19 @@ String8 KeyMap::getPath(const InputDeviceIdentifier& deviceIdentifier,

// --- Global functions ---

bool isKeyboardSpecialFunction(const PropertyMap* config) {
    if (config == nullptr) {
        return false;
    }
    bool isSpecialFunction = false;
    config->tryGetProperty(String8("keyboard.specialFunction"), isSpecialFunction);
    return isSpecialFunction;
}

bool isEligibleBuiltInKeyboard(const InputDeviceIdentifier& deviceIdentifier,
        const PropertyMap* deviceConfiguration, const KeyMap* keyMap) {
    if (!keyMap->haveKeyCharacterMap()
    // TODO: remove the third OR statement (SPECIAL_FUNCTION) in Q
    if (!keyMap->haveKeyCharacterMap() || isKeyboardSpecialFunction(deviceConfiguration)
            || keyMap->keyCharacterMap->getKeyboardType()
                    == KeyCharacterMap::KEYBOARD_TYPE_SPECIAL_FUNCTION) {
        return false;