diff options
Diffstat (limited to 'core')
| -rw-r--r-- | core/java/android/view/SurfaceControl.java | 16 | ||||
| -rw-r--r-- | core/jni/android_view_SurfaceControl.cpp | 21 |
2 files changed, 37 insertions, 0 deletions
diff --git a/core/java/android/view/SurfaceControl.java b/core/java/android/view/SurfaceControl.java index aaf85aff2e8f..070cf110ac6f 100644 --- a/core/java/android/view/SurfaceControl.java +++ b/core/java/android/view/SurfaceControl.java @@ -157,6 +157,8 @@ public final class SurfaceControl implements Parcelable { IBinder displayToken, long numFrames, long timestamp); private static native int nativeGetActiveConfig(IBinder displayToken); private static native boolean nativeSetActiveConfig(IBinder displayToken, int id); + private static native boolean nativeSetAllowedDisplayConfigs(IBinder displayToken, + int[] allowedConfigs); private static native int[] nativeGetDisplayColorModes(IBinder displayToken); private static native SurfaceControl.DisplayPrimaries nativeGetDisplayNativePrimaries( IBinder displayToken); @@ -1521,6 +1523,20 @@ public final class SurfaceControl implements Parcelable { /** * @hide */ + public static boolean setAllowedDisplayConfigs(IBinder displayToken, int[] allowedConfigs) { + if (displayToken == null) { + throw new IllegalArgumentException("displayToken must not be null"); + } + if (allowedConfigs == null) { + throw new IllegalArgumentException("allowedConfigs must not be null"); + } + + return nativeSetAllowedDisplayConfigs(displayToken, allowedConfigs); + } + + /** + * @hide + */ public static int[] getDisplayColorModes(IBinder displayToken) { if (displayToken == null) { throw new IllegalArgumentException("displayToken must not be null"); diff --git a/core/jni/android_view_SurfaceControl.cpp b/core/jni/android_view_SurfaceControl.cpp index 003ee37995af..f32d2b72c2eb 100644 --- a/core/jni/android_view_SurfaceControl.cpp +++ b/core/jni/android_view_SurfaceControl.cpp @@ -698,6 +698,25 @@ static jobjectArray nativeGetDisplayConfigs(JNIEnv* env, jclass clazz, return configArray; } +static jboolean nativeSetAllowedDisplayConfigs(JNIEnv* env, jclass clazz, + jobject tokenObj, jintArray configArray) { + sp<IBinder> token(ibinderForJavaObject(env, tokenObj)); + if (token == nullptr) return JNI_FALSE; + + std::vector<int32_t> allowedConfigs; + jsize configArraySize = env->GetArrayLength(configArray); + allowedConfigs.reserve(configArraySize); + + jint* configArrayElements = env->GetIntArrayElements(configArray, 0); + for (int i = 0; i < configArraySize; i++) { + allowedConfigs.push_back(configArrayElements[i]); + } + env->ReleaseIntArrayElements(configArray, configArrayElements, 0); + + size_t result = SurfaceComposerClient::setAllowedDisplayConfigs(token, allowedConfigs); + return result == NO_ERROR ? JNI_TRUE : JNI_FALSE; +} + static jint nativeGetActiveConfig(JNIEnv* env, jclass clazz, jobject tokenObj) { sp<IBinder> token(ibinderForJavaObject(env, tokenObj)); if (token == NULL) return -1; @@ -1194,6 +1213,8 @@ static const JNINativeMethod sSurfaceControlMethods[] = { (void*)nativeGetActiveConfig }, {"nativeSetActiveConfig", "(Landroid/os/IBinder;I)Z", (void*)nativeSetActiveConfig }, + {"nativeSetAllowedDisplayConfigs", "(Landroid/os/IBinder;[I)Z", + (void*)nativeSetAllowedDisplayConfigs }, {"nativeGetDisplayColorModes", "(Landroid/os/IBinder;)[I", (void*)nativeGetDisplayColorModes}, {"nativeGetDisplayNativePrimaries", "(Landroid/os/IBinder;)Landroid/view/SurfaceControl$DisplayPrimaries;", |
