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

Commit edc5c8c2 authored by Vaibhav Devmurari's avatar Vaibhav Devmurari
Browse files

Remove `enable_keyboard_classifier` flag

Flag: EXEMPT cleanup
Bug: 409609452
Test: Presubmits
Change-Id: Id751f72019f9a72e067e945f921dd510387c01e7
parent 7dfd5448
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -47,7 +47,6 @@ public:
private:
    std::optional<rust::Box<android::input::keyboardClassifier::KeyboardClassifier>>
            mRustClassifier;
    std::unordered_map<DeviceId, KeyboardType> mKeyboardTypeMap;
};

} // namespace android
+15 −43
Original line number Diff line number Diff line
@@ -17,45 +17,27 @@
#define LOG_TAG "KeyboardClassifier"

#include <android-base/logging.h>
#include <com_android_input_flags.h>
#include <ftl/flags.h>
#include <input/KeyboardClassifier.h>

#include "input_cxx_bridge.rs.h"

namespace input_flags = com::android::input::flags;

using android::input::RustInputDeviceIdentifier;

namespace android {

KeyboardClassifier::KeyboardClassifier() {
    if (input_flags::enable_keyboard_classifier()) {
    mRustClassifier = android::input::keyboardClassifier::create();
}
}

KeyboardType KeyboardClassifier::getKeyboardType(DeviceId deviceId) {
    if (mRustClassifier) {
    return static_cast<KeyboardType>(
            android::input::keyboardClassifier::getKeyboardType(**mRustClassifier, deviceId));
    } else {
        auto it = mKeyboardTypeMap.find(deviceId);
        if (it == mKeyboardTypeMap.end()) {
            return KeyboardType::NONE;
        }
        return it->second;
}
}

// Copied from EventHub.h
const uint32_t DEVICE_CLASS_KEYBOARD = android::os::IInputConstants::DEVICE_CLASS_KEYBOARD;
const uint32_t DEVICE_CLASS_ALPHAKEY = android::os::IInputConstants::DEVICE_CLASS_ALPHAKEY;

void KeyboardClassifier::notifyKeyboardChanged(DeviceId deviceId,
                                               const InputDeviceIdentifier& identifier,
                                               uint32_t deviceClasses) {
    if (mRustClassifier) {
    RustInputDeviceIdentifier rustIdentifier;
    rustIdentifier.name = rust::String::lossy(identifier.name);
    rustIdentifier.location = rust::String::lossy(identifier.location);
@@ -67,20 +49,10 @@ void KeyboardClassifier::notifyKeyboardChanged(DeviceId deviceId,
    rustIdentifier.descriptor = rust::String::lossy(identifier.descriptor);
    android::input::keyboardClassifier::notifyKeyboardChanged(**mRustClassifier, deviceId,
                                                                rustIdentifier, deviceClasses);
    } else {
        bool isKeyboard = (deviceClasses & DEVICE_CLASS_KEYBOARD) != 0;
        bool hasAlphabeticKey = (deviceClasses & DEVICE_CLASS_ALPHAKEY) != 0;
        mKeyboardTypeMap.insert_or_assign(deviceId,
                                          isKeyboard ? (hasAlphabeticKey
                                                                ? KeyboardType::ALPHABETIC
                                                                : KeyboardType::NON_ALPHABETIC)
                                                     : KeyboardType::NONE);
    }
}

void KeyboardClassifier::processKey(DeviceId deviceId, int32_t evdevCode, uint32_t metaState) {
    if (mRustClassifier &&
        !android::input::keyboardClassifier::isFinalized(**mRustClassifier, deviceId)) {
    if (!android::input::keyboardClassifier::isFinalized(**mRustClassifier, deviceId)) {
        android::input::keyboardClassifier::processKey(**mRustClassifier, deviceId, evdevCode,
                                                       metaState);
    }
+0 −7
Original line number Diff line number Diff line
@@ -122,13 +122,6 @@ flag {
  }
}

flag {
  name: "enable_keyboard_classifier"
  namespace: "input"
  description: "Keyboard classifier that classifies all keyboards into alphabetic or non-alphabetic"
  bug: "263559234"
}

flag {
  name: "show_pointers_for_partial_screenshare"
  namespace: "input"