Loading core/java/android/view/SurfaceControl.java +11 −0 Original line number Diff line number Diff line Loading @@ -160,6 +160,7 @@ public final class SurfaceControl implements Parcelable { private static native boolean nativeSetActiveConfig(IBinder displayToken, int id); private static native boolean nativeSetAllowedDisplayConfigs(IBinder displayToken, int[] allowedConfigs); private static native int[] nativeGetAllowedDisplayConfigs(IBinder displayToken); private static native int[] nativeGetDisplayColorModes(IBinder displayToken); private static native SurfaceControl.DisplayPrimaries nativeGetDisplayNativePrimaries( IBinder displayToken); Loading Loading @@ -1535,6 +1536,16 @@ public final class SurfaceControl implements Parcelable { return nativeSetAllowedDisplayConfigs(displayToken, allowedConfigs); } /** * @hide */ public static int[] getAllowedDisplayConfigs(IBinder displayToken) { if (displayToken == null) { throw new IllegalArgumentException("displayToken must not be null"); } return nativeGetAllowedDisplayConfigs(displayToken); } /** * @hide */ Loading core/jni/android_view_SurfaceControl.cpp +25 −0 Original line number Diff line number Diff line Loading @@ -717,6 +717,29 @@ static jboolean nativeSetAllowedDisplayConfigs(JNIEnv* env, jclass clazz, return result == NO_ERROR ? JNI_TRUE : JNI_FALSE; } static jintArray nativeGetAllowedDisplayConfigs(JNIEnv* env, jclass clazz, jobject tokenObj) { sp<IBinder> token(ibinderForJavaObject(env, tokenObj)); if (token == nullptr) return JNI_FALSE; std::vector<int32_t> allowedConfigs; size_t result = SurfaceComposerClient::getAllowedDisplayConfigs(token, &allowedConfigs); if (result != NO_ERROR) { return nullptr; } jintArray allowedConfigsArray = env->NewIntArray(allowedConfigs.size()); if (allowedConfigsArray == nullptr) { jniThrowException(env, "java/lang/OutOfMemoryError", NULL); return nullptr; } jint* allowedConfigsArrayValues = env->GetIntArrayElements(allowedConfigsArray, 0); for (size_t i = 0; i < allowedConfigs.size(); i++) { allowedConfigsArrayValues[i] = static_cast<jint>(allowedConfigs[i]); } env->ReleaseIntArrayElements(allowedConfigsArray, allowedConfigsArrayValues, 0); return allowedConfigsArray; } static jint nativeGetActiveConfig(JNIEnv* env, jclass clazz, jobject tokenObj) { sp<IBinder> token(ibinderForJavaObject(env, tokenObj)); if (token == NULL) return -1; Loading Loading @@ -1215,6 +1238,8 @@ static const JNINativeMethod sSurfaceControlMethods[] = { (void*)nativeSetActiveConfig }, {"nativeSetAllowedDisplayConfigs", "(Landroid/os/IBinder;[I)Z", (void*)nativeSetAllowedDisplayConfigs }, {"nativeGetAllowedDisplayConfigs", "(Landroid/os/IBinder;)[I", (void*)nativeGetAllowedDisplayConfigs }, {"nativeGetDisplayColorModes", "(Landroid/os/IBinder;)[I", (void*)nativeGetDisplayColorModes}, {"nativeGetDisplayNativePrimaries", "(Landroid/os/IBinder;)Landroid/view/SurfaceControl$DisplayPrimaries;", Loading Loading
core/java/android/view/SurfaceControl.java +11 −0 Original line number Diff line number Diff line Loading @@ -160,6 +160,7 @@ public final class SurfaceControl implements Parcelable { private static native boolean nativeSetActiveConfig(IBinder displayToken, int id); private static native boolean nativeSetAllowedDisplayConfigs(IBinder displayToken, int[] allowedConfigs); private static native int[] nativeGetAllowedDisplayConfigs(IBinder displayToken); private static native int[] nativeGetDisplayColorModes(IBinder displayToken); private static native SurfaceControl.DisplayPrimaries nativeGetDisplayNativePrimaries( IBinder displayToken); Loading Loading @@ -1535,6 +1536,16 @@ public final class SurfaceControl implements Parcelable { return nativeSetAllowedDisplayConfigs(displayToken, allowedConfigs); } /** * @hide */ public static int[] getAllowedDisplayConfigs(IBinder displayToken) { if (displayToken == null) { throw new IllegalArgumentException("displayToken must not be null"); } return nativeGetAllowedDisplayConfigs(displayToken); } /** * @hide */ Loading
core/jni/android_view_SurfaceControl.cpp +25 −0 Original line number Diff line number Diff line Loading @@ -717,6 +717,29 @@ static jboolean nativeSetAllowedDisplayConfigs(JNIEnv* env, jclass clazz, return result == NO_ERROR ? JNI_TRUE : JNI_FALSE; } static jintArray nativeGetAllowedDisplayConfigs(JNIEnv* env, jclass clazz, jobject tokenObj) { sp<IBinder> token(ibinderForJavaObject(env, tokenObj)); if (token == nullptr) return JNI_FALSE; std::vector<int32_t> allowedConfigs; size_t result = SurfaceComposerClient::getAllowedDisplayConfigs(token, &allowedConfigs); if (result != NO_ERROR) { return nullptr; } jintArray allowedConfigsArray = env->NewIntArray(allowedConfigs.size()); if (allowedConfigsArray == nullptr) { jniThrowException(env, "java/lang/OutOfMemoryError", NULL); return nullptr; } jint* allowedConfigsArrayValues = env->GetIntArrayElements(allowedConfigsArray, 0); for (size_t i = 0; i < allowedConfigs.size(); i++) { allowedConfigsArrayValues[i] = static_cast<jint>(allowedConfigs[i]); } env->ReleaseIntArrayElements(allowedConfigsArray, allowedConfigsArrayValues, 0); return allowedConfigsArray; } static jint nativeGetActiveConfig(JNIEnv* env, jclass clazz, jobject tokenObj) { sp<IBinder> token(ibinderForJavaObject(env, tokenObj)); if (token == NULL) return -1; Loading Loading @@ -1215,6 +1238,8 @@ static const JNINativeMethod sSurfaceControlMethods[] = { (void*)nativeSetActiveConfig }, {"nativeSetAllowedDisplayConfigs", "(Landroid/os/IBinder;[I)Z", (void*)nativeSetAllowedDisplayConfigs }, {"nativeGetAllowedDisplayConfigs", "(Landroid/os/IBinder;)[I", (void*)nativeGetAllowedDisplayConfigs }, {"nativeGetDisplayColorModes", "(Landroid/os/IBinder;)[I", (void*)nativeGetDisplayColorModes}, {"nativeGetDisplayNativePrimaries", "(Landroid/os/IBinder;)Landroid/view/SurfaceControl$DisplayPrimaries;", Loading