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

Commit 17902c54 authored by chaviw's avatar chaviw
Browse files

Add onPointerDownOutsideFocus for events outside the focused window (3/4)

Add JNI callback to handle native callback for onPointerDownOutsideFocus.

Test: Builds, nothing to test yet.
Bug: 122535136
Change-Id: I3760f2f4beb469bbe3fbcec63df475dfa36892cc
parent 5e5b1b9e
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -1808,6 +1808,10 @@ public class InputManagerService extends IInputManager.Stub
                injectorPid, injectorUid) == PackageManager.PERMISSION_GRANTED;
    }

    // Native callback.
    private void onPointerDownOutsideFocus(IBinder touchedToken) {
    }

    // Native callback.
    private int getVirtualKeyQuietTimeMillis() {
        return mContext.getResources().getInteger(
+14 −0
Original line number Diff line number Diff line
@@ -96,6 +96,7 @@ static struct {
    jmethodID interceptKeyBeforeDispatching;
    jmethodID dispatchUnhandledKey;
    jmethodID checkInjectEventsPermission;
    jmethodID onPointerDownOutsideFocus;
    jmethodID getVirtualKeyQuietTimeMillis;
    jmethodID getExcludedDeviceNames;
    jmethodID getInputPortAssociations;
@@ -259,6 +260,7 @@ public:
    virtual void pokeUserActivity(nsecs_t eventTime, int32_t eventType);
    virtual bool checkInjectEventsPermissionNonReentrant(
            int32_t injectorPid, int32_t injectorUid);
    virtual void onPointerDownOutsideFocus(const sp<IBinder>& touchedToken);

    /* --- PointerControllerPolicyInterface implementation --- */

@@ -1205,6 +1207,15 @@ bool NativeInputManager::checkInjectEventsPermissionNonReentrant(
    return result;
}

void NativeInputManager::onPointerDownOutsideFocus(const sp<IBinder>& touchedToken) {
    ATRACE_CALL();
    JNIEnv* env = jniEnv();

    jobject touchedTokenObj = javaObjectForIBinder(env, touchedToken);
    env->CallVoidMethod(mServiceObj, gServiceClassInfo.onPointerDownOutsideFocus, touchedTokenObj);
    checkAndClearExceptionFromCallback(env, "onPointerDownOutsideFocus");
}

void NativeInputManager::loadPointerIcon(SpriteIcon* icon, int32_t displayId) {
    ATRACE_CALL();
    JNIEnv* env = jniEnv();
@@ -1809,6 +1820,9 @@ int register_android_server_InputManager(JNIEnv* env) {
    GET_METHOD_ID(gServiceClassInfo.checkInjectEventsPermission, clazz,
            "checkInjectEventsPermission", "(II)Z");

    GET_METHOD_ID(gServiceClassInfo.onPointerDownOutsideFocus, clazz,
            "onPointerDownOutsideFocus", "(Landroid/os/IBinder;)V");

    GET_METHOD_ID(gServiceClassInfo.getVirtualKeyQuietTimeMillis, clazz,
            "getVirtualKeyQuietTimeMillis", "()I");