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

Commit d5b4a58d authored by Rob Carr's avatar Rob Carr Committed by Android (Google) Code Review
Browse files

Merge changes from topic "sfinput4"

* changes:
  ScreenMagnifier: Track SurfaceFlinger Input
  Forward SurfaceInsets to InputWindowInfo
  Track native changes: Rework InputApplicationInfo
  Replace InputWindowInfo#inputChannel with an IBinder token.
  Fix name for canReceiveTouchInput
  Fix pointer capture
  Cleanup Input left-overs.
  Port other InputWindowHandles to input surfaces.
  Port InputConsumerImpl to SurfaceFlinger input.
  Pass InputWindowInfo to SurfaceFlinger.
parents cf28097f 51141c0a
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package android.view;

import android.os.IBinder;

/**
 * Functions as a handle for an application that can receive input.
 * Enables the native input dispatcher to refer indirectly to the window manager's
@@ -28,19 +30,18 @@ public final class InputApplicationHandle {
    @SuppressWarnings("unused")
    private long ptr;

    // The window manager's application window token.
    public final Object appWindowToken;

    // Application name.
    public String name;

    // Dispatching timeout.
    public long dispatchingTimeoutNanos;

    public IBinder token;

    private native void nativeDispose();

    public InputApplicationHandle(Object appWindowToken) {
        this.appWindowToken = appWindowToken;
    public InputApplicationHandle(IBinder token) {
        this.token = token;
    }

    @Override
+5 −2
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package android.view;

import android.graphics.Region;
import android.os.IBinder;
import android.view.IWindow;
import android.view.InputChannel;

@@ -37,8 +38,8 @@ public final class InputWindowHandle {
    // The client window.
    public final IWindow clientWindow;

    // The input channel associated with the window.
    public InputChannel inputChannel;
    // The token assosciated with the window.
    public IBinder token;

    // The window name.
    public String name;
@@ -56,6 +57,8 @@ public final class InputWindowHandle {
    public int frameRight;
    public int frameBottom;

    public int surfaceInset;

    // Global scaling factor applied to touch events when they are dispatched
    // to the window
    public float scaleFactor;
+14 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@
#include <utils/threads.h>

#include "android_hardware_input_InputApplicationHandle.h"
#include "android_util_Binder.h"

namespace android {

@@ -29,6 +30,7 @@ static struct {
    jfieldID ptr;
    jfieldID name;
    jfieldID dispatchingTimeoutNanos;
    jfieldID token;
} gInputApplicationHandleClassInfo;

static Mutex gHandleMutex;
@@ -75,6 +77,15 @@ bool NativeInputApplicationHandle::updateInfo() {
    mInfo->dispatchingTimeout = env->GetLongField(obj,
            gInputApplicationHandleClassInfo.dispatchingTimeoutNanos);

    jobject tokenObj = env->GetObjectField(obj,
            gInputApplicationHandleClassInfo.token);
    if (tokenObj) {
        mInfo->token = ibinderForJavaObject(env, tokenObj);
        env->DeleteLocalRef(tokenObj);
    } else {
        mInfo->token.clear();
    }

    env->DeleteLocalRef(obj);
    return true;
}
@@ -153,6 +164,9 @@ int register_android_server_InputApplicationHandle(JNIEnv* env) {
            clazz,
            "dispatchingTimeoutNanos", "J");

    GET_FIELD_ID(gInputApplicationHandleClassInfo.token, clazz,
            "token", "Landroid/os/IBinder;");

    return 0;
}

+30 −21
Original line number Diff line number Diff line
@@ -21,19 +21,19 @@
#include <android_runtime/AndroidRuntime.h>
#include <utils/threads.h>

#include <android_view_InputChannel.h>
#include <android/graphics/Region.h>
#include <ui/Region.h>

#include "android_hardware_input_InputWindowHandle.h"
#include "android_hardware_input_InputApplicationHandle.h"
#include "android_util_Binder.h"

namespace android {

static struct {
    jfieldID ptr;
    jfieldID inputApplicationHandle;
    jfieldID inputChannel;
    jfieldID token;
    jfieldID name;
    jfieldID layoutParamsFlags;
    jfieldID layoutParamsType;
@@ -42,6 +42,7 @@ static struct {
    jfieldID frameTop;
    jfieldID frameRight;
    jfieldID frameBottom;
    jfieldID surfaceInset;
    jfieldID scaleFactor;
    jfieldID touchableRegion;
    jfieldID visible;
@@ -61,9 +62,7 @@ static Mutex gHandleMutex;

// --- NativeInputWindowHandle ---

NativeInputWindowHandle::NativeInputWindowHandle(
        const sp<InputApplicationHandle>& inputApplicationHandle, jweak objWeak) :
        InputWindowHandle(inputApplicationHandle),
NativeInputWindowHandle::NativeInputWindowHandle(jweak objWeak) :
        mObjWeak(objWeak) {
}

@@ -86,13 +85,12 @@ bool NativeInputWindowHandle::updateInfo() {

    mInfo.touchableRegion.clear();

    jobject inputChannelObj = env->GetObjectField(obj,
            gInputWindowHandleClassInfo.inputChannel);
    if (inputChannelObj) {
        mInfo.inputChannel = android_view_InputChannel_getInputChannel(env, inputChannelObj);
        env->DeleteLocalRef(inputChannelObj);
    jobject tokenObj = env->GetObjectField(obj,
            gInputWindowHandleClassInfo.token);
    if (tokenObj) {
        mInfo.token = ibinderForJavaObject(env, tokenObj);
    } else {
        mInfo.inputChannel.clear();
        mInfo.token.clear();
    }

    jstring nameObj = jstring(env->GetObjectField(obj,
@@ -120,7 +118,9 @@ bool NativeInputWindowHandle::updateInfo() {
            gInputWindowHandleClassInfo.frameRight);
    mInfo.frameBottom = env->GetIntField(obj,
            gInputWindowHandleClassInfo.frameBottom);
    mInfo.scaleFactor = env->GetFloatField(obj,
    mInfo.surfaceInset = env->GetIntField(obj,
            gInputWindowHandleClassInfo.surfaceInset);
    mInfo.globalScaleFactor = env->GetFloatField(obj,
            gInputWindowHandleClassInfo.scaleFactor);

    jobject regionObj = env->GetObjectField(obj,
@@ -155,6 +155,18 @@ bool NativeInputWindowHandle::updateInfo() {
    mInfo.displayId = env->GetIntField(obj,
            gInputWindowHandleClassInfo.displayId);

    jobject inputApplicationHandleObj = env->GetObjectField(obj,
            gInputWindowHandleClassInfo.inputApplicationHandle);
    if (inputApplicationHandleObj) {
        sp<InputApplicationHandle> inputApplicationHandle =
            android_server_InputApplicationHandle_getHandle(env, inputApplicationHandleObj);
        if (inputApplicationHandle != nullptr) {
            inputApplicationHandle->updateInfo();
            mInfo.applicationInfo = *(inputApplicationHandle->getInfo());
        }
        env->DeleteLocalRef(inputApplicationHandleObj);
    }

    env->DeleteLocalRef(obj);
    return true;
}
@@ -175,14 +187,8 @@ sp<NativeInputWindowHandle> android_server_InputWindowHandle_getHandle(
    if (ptr) {
        handle = reinterpret_cast<NativeInputWindowHandle*>(ptr);
    } else {
        jobject inputApplicationHandleObj = env->GetObjectField(inputWindowHandleObj,
                gInputWindowHandleClassInfo.inputApplicationHandle);
        sp<InputApplicationHandle> inputApplicationHandle =
                android_server_InputApplicationHandle_getHandle(env, inputApplicationHandleObj);
        env->DeleteLocalRef(inputApplicationHandleObj);

        jweak objWeak = env->NewWeakGlobalRef(inputWindowHandleObj);
        handle = new NativeInputWindowHandle(inputApplicationHandle, objWeak);
        handle = new NativeInputWindowHandle(objWeak);
        handle->incStrong((void*)android_server_InputWindowHandle_getHandle);
        env->SetLongField(inputWindowHandleObj, gInputWindowHandleClassInfo.ptr,
                reinterpret_cast<jlong>(handle));
@@ -236,8 +242,8 @@ int register_android_server_InputWindowHandle(JNIEnv* env) {
            clazz,
            "inputApplicationHandle", "Landroid/view/InputApplicationHandle;");

    GET_FIELD_ID(gInputWindowHandleClassInfo.inputChannel, clazz,
            "inputChannel", "Landroid/view/InputChannel;");
    GET_FIELD_ID(gInputWindowHandleClassInfo.token, clazz,
            "token", "Landroid/os/IBinder;");

    GET_FIELD_ID(gInputWindowHandleClassInfo.name, clazz,
            "name", "Ljava/lang/String;");
@@ -263,6 +269,9 @@ int register_android_server_InputWindowHandle(JNIEnv* env) {
    GET_FIELD_ID(gInputWindowHandleClassInfo.frameBottom, clazz,
            "frameBottom", "I");

    GET_FIELD_ID(gInputWindowHandleClassInfo.surfaceInset, clazz,
            "surfaceInset", "I");

    GET_FIELD_ID(gInputWindowHandleClassInfo.scaleFactor, clazz,
            "scaleFactor", "F");

+1 −2
Original line number Diff line number Diff line
@@ -26,8 +26,7 @@ namespace android {

class NativeInputWindowHandle : public InputWindowHandle {
public:
    NativeInputWindowHandle(const sp<InputApplicationHandle>& inputApplicationHandle,
            jweak objWeak);
    NativeInputWindowHandle(jweak objWeak);
    virtual ~NativeInputWindowHandle();

    jobject getInputWindowHandleObjLocalRef(JNIEnv* env);
Loading