89 lines
3.6 KiB
Diff
89 lines
3.6 KiB
Diff
From 7dbc3c83213b1dacce2eaa90835721b13f504781 Mon Sep 17 00:00:00 2001
|
|
From: Andy CrossGate Yan <GeForce8800Ultra@gmail.com>
|
|
Date: Sun, 19 Nov 2023 23:07:03 +0800
|
|
Subject: [PATCH 5/5] Restore getPhysicalDisplayIds in SurfaceControl
|
|
|
|
For convenience of accessing DynamicDisplayInfo from Settings
|
|
Copy over the updated implementation from DisplayControl while we're at it
|
|
|
|
This partially reverts commit e2f333728788ad88a65208a6119aed90e13e7040.
|
|
|
|
Change-Id: Ie056ecaf76acbc70d73e1c26cc4542088fcda18d
|
|
---
|
|
core/java/android/view/SurfaceControl.java | 8 ++++++++
|
|
core/jni/android_view_SurfaceControl.cpp | 18 ++++++++++++++++++
|
|
2 files changed, 26 insertions(+)
|
|
|
|
diff --git a/core/java/android/view/SurfaceControl.java b/core/java/android/view/SurfaceControl.java
|
|
index cbbe7856178d..253eb492bd8b 100644
|
|
--- a/core/java/android/view/SurfaceControl.java
|
|
+++ b/core/java/android/view/SurfaceControl.java
|
|
@@ -181,6 +181,7 @@ public final class SurfaceControl implements Parcelable {
|
|
private static native boolean nativeClearAnimationFrameStats();
|
|
private static native boolean nativeGetAnimationFrameStats(WindowAnimationFrameStats outStats);
|
|
|
|
+ private static native long[] nativeGetPhysicalDisplayIds();
|
|
private static native void nativeSetDisplaySurface(long transactionObj,
|
|
IBinder displayToken, long nativeSurfaceObject);
|
|
private static native void nativeSetDisplayLayerStack(long transactionObj,
|
|
@@ -2440,6 +2441,13 @@ public final class SurfaceControl implements Parcelable {
|
|
IVirtualDisplayCallback.Stub.asInterface(displayToken));
|
|
}
|
|
|
|
+ /**
|
|
+ * @hide
|
|
+ */
|
|
+ public static long[] getPhysicalDisplayIds() {
|
|
+ return nativeGetPhysicalDisplayIds();
|
|
+ }
|
|
+
|
|
/**
|
|
* Returns whether protected content is supported in GPU composition.
|
|
* @hide
|
|
diff --git a/core/jni/android_view_SurfaceControl.cpp b/core/jni/android_view_SurfaceControl.cpp
|
|
index db42246ca76c..0be04bb380d8 100644
|
|
--- a/core/jni/android_view_SurfaceControl.cpp
|
|
+++ b/core/jni/android_view_SurfaceControl.cpp
|
|
@@ -36,6 +36,7 @@
|
|
#include <gui/SurfaceComposerClient.h>
|
|
#include <jni.h>
|
|
#include <nativehelper/JNIHelp.h>
|
|
+#include <nativehelper/ScopedPrimitiveArray.h>
|
|
#include <nativehelper/ScopedUtfChars.h>
|
|
#include <private/gui/ComposerService.h>
|
|
#include <stdio.h>
|
|
@@ -1010,6 +1011,21 @@ static void nativeSetDestinationFrame(JNIEnv* env, jclass clazz, jlong transacti
|
|
transaction->setDestinationFrame(ctrl, crop);
|
|
}
|
|
|
|
+static jlongArray nativeGetPhysicalDisplayIds(JNIEnv* env, jclass clazz) {
|
|
+ const auto displayIds = SurfaceComposerClient::getPhysicalDisplayIds();
|
|
+ ScopedLongArrayRW values(env, env->NewLongArray(displayIds.size()));
|
|
+ if (values.get() == nullptr) {
|
|
+ jniThrowException(env, "java/lang/OutOfMemoryError", nullptr);
|
|
+ return nullptr;
|
|
+ }
|
|
+
|
|
+ for (size_t i = 0; i < displayIds.size(); ++i) {
|
|
+ values[i] = static_cast<jlong>(displayIds[i].value);
|
|
+ }
|
|
+
|
|
+ return values.getJavaArray();
|
|
+}
|
|
+
|
|
static jobject nativeGetDisplayedContentSamplingAttributes(JNIEnv* env, jclass clazz,
|
|
jobject tokenObj) {
|
|
sp<IBinder> token(ibinderForJavaObject(env, tokenObj));
|
|
@@ -2187,6 +2203,8 @@ static const JNINativeMethod sSurfaceControlMethods[] = {
|
|
(void*)nativeSetFrameRateCategory},
|
|
{"nativeSetFrameRateSelectionStrategy", "(JJI)V",
|
|
(void*)nativeSetFrameRateSelectionStrategy},
|
|
+ {"nativeGetPhysicalDisplayIds", "()[J",
|
|
+ (void*)nativeGetPhysicalDisplayIds },
|
|
{"nativeSetDisplaySurface", "(JLandroid/os/IBinder;J)V",
|
|
(void*)nativeSetDisplaySurface },
|
|
{"nativeSetDisplayLayerStack", "(JLandroid/os/IBinder;I)V",
|
|
--
|
|
2.34.1
|
|
|