Merge "Added contentSize to WindowInfo" into main
diff --git a/core/java/android/view/InputWindowHandle.java b/core/java/android/view/InputWindowHandle.java
index 45b3fdd..6a588eb8 100644
--- a/core/java/android/view/InputWindowHandle.java
+++ b/core/java/android/view/InputWindowHandle.java
@@ -26,6 +26,7 @@
import android.gui.TouchOcclusionMode;
import android.os.IBinder;
import android.os.InputConfig;
+import android.util.Size;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -106,6 +107,9 @@
// Window frame.
public final Rect frame = new Rect();
+ // The real size of the content, excluding any crop. If no buffer is rendered, this is 0,0
+ public Size contentSize = new Size(0, 0);
+
public int surfaceInset;
// Global scaling factor applied to touch events when they are dispatched
@@ -199,6 +203,7 @@
transform.set(other.transform);
}
focusTransferTarget = other.focusTransferTarget;
+ contentSize = new Size(other.contentSize.getWidth(), other.contentSize.getHeight());
}
@Override
@@ -211,6 +216,7 @@
.append(", windowToken=").append(windowToken)
.append(", displayId=").append(displayId)
.append(", isClone=").append((inputConfig & InputConfig.CLONE) != 0)
+ .append(", contentSize=").append(contentSize)
.toString();
}
diff --git a/core/jni/android_hardware_input_InputWindowHandle.cpp b/core/jni/android_hardware_input_InputWindowHandle.cpp
index ea3c70f..c3d21a4 100644
--- a/core/jni/android_hardware_input_InputWindowHandle.cpp
+++ b/core/jni/android_hardware_input_InputWindowHandle.cpp
@@ -59,6 +59,7 @@
jfieldID layoutParamsType;
jfieldID dispatchingTimeoutMillis;
jfieldID frame;
+ jfieldID contentSize;
jfieldID surfaceInset;
jfieldID scaleFactor;
jfieldID touchableRegion;
@@ -281,6 +282,9 @@
ScopedLocalRef<jobject> rectObj(env, JNICommon::objFromRect(env, windowInfo.frame));
env->SetObjectField(inputWindowHandle, gInputWindowHandleClassInfo.frame, rectObj.get());
+ ScopedLocalRef<jobject> sizeObj(env, JNICommon::objFromSize(env, windowInfo.contentSize));
+ env->SetObjectField(inputWindowHandle, gInputWindowHandleClassInfo.contentSize, sizeObj.get());
+
env->SetIntField(inputWindowHandle, gInputWindowHandleClassInfo.surfaceInset,
windowInfo.surfaceInset);
env->SetFloatField(inputWindowHandle, gInputWindowHandleClassInfo.scaleFactor,
@@ -393,6 +397,9 @@
GET_FIELD_ID(gInputWindowHandleClassInfo.frame, clazz, "frame", "Landroid/graphics/Rect;");
+ GET_FIELD_ID(gInputWindowHandleClassInfo.contentSize, clazz, "contentSize",
+ "Landroid/util/Size;");
+
GET_FIELD_ID(gInputWindowHandleClassInfo.surfaceInset, clazz,
"surfaceInset", "I");
diff --git a/core/jni/jni_common.cpp b/core/jni/jni_common.cpp
index b81c9b6..dd69b16 100644
--- a/core/jni/jni_common.cpp
+++ b/core/jni/jni_common.cpp
@@ -34,6 +34,11 @@
jfieldID top;
} gRectClassInfo;
+static struct {
+ jclass clazz;
+ jmethodID ctor;
+} gSizeClassInfo;
+
Rect JNICommon::rectFromObj(JNIEnv* env, jobject rectObj) {
int left = env->GetIntField(rectObj, gRectClassInfo.left);
int top = env->GetIntField(rectObj, gRectClassInfo.top);
@@ -47,6 +52,10 @@
rect.right, rect.bottom);
}
+jobject JNICommon::objFromSize(JNIEnv* env, Size size) {
+ return env->NewObject(gSizeClassInfo.clazz, gSizeClassInfo.ctor, size.width, size.height);
+}
+
int register_jni_common(JNIEnv* env) {
jclass rectClazz = FindClassOrDie(env, "android/graphics/Rect");
gRectClassInfo.clazz = MakeGlobalRefOrDie(env, rectClazz);
@@ -55,6 +64,11 @@
gRectClassInfo.left = GetFieldIDOrDie(env, rectClazz, "left", "I");
gRectClassInfo.right = GetFieldIDOrDie(env, rectClazz, "right", "I");
gRectClassInfo.top = GetFieldIDOrDie(env, rectClazz, "top", "I");
+
+ jclass sizeClazz = FindClassOrDie(env, "android/util/Size");
+ gSizeClassInfo.clazz = MakeGlobalRefOrDie(env, sizeClazz);
+ gSizeClassInfo.ctor = GetMethodIDOrDie(env, sizeClazz, "<init>", "(II)V");
+
return 0;
}
diff --git a/core/jni/jni_common.h b/core/jni/jni_common.h
index d670a7d..f1c6014 100644
--- a/core/jni/jni_common.h
+++ b/core/jni/jni_common.h
@@ -14,14 +14,17 @@
* limitations under the License.
*/
#include <jni.h>
+#include <ui/Size.h>
namespace android {
class Rect;
+using ui::Size;
class JNICommon {
public:
static Rect rectFromObj(JNIEnv* env, jobject rectObj);
static jobject objFromRect(JNIEnv* env, Rect rect);
+ static jobject objFromSize(JNIEnv* env, Size size);
};
} // namespace android
\ No newline at end of file