Loading core/java/android/view/SurfaceControl.java +23 −0 Original line number Diff line number Diff line Loading @@ -345,6 +345,8 @@ public final class SurfaceControl implements Parcelable { long nativeObject, long pictureProfileId); private static native void nativeSetContentPriority(long transactionObj, long nativeObject, int priority); private static native void nativeSetSystemContentPriority( long transactionObj, long nativeObject, int priority); private static native String nativeGetName(long nativeObject); /** Loading Loading @@ -5074,6 +5076,27 @@ public final class SurfaceControl implements Parcelable { return this; } /** * Sets the system-level importance of the window's content. * <p> * This priority is used by the system to make decisions for different use cases where the * resource is limited. * <p> * This is intended for system internal use. * * @param sc The SurfaceControl of the layer to update. * @param priority The system content priority to assign to this layer. The range of the * system priority is [-10. 10]. A window with higher priority value gets * preferred access to limited resources. * @hide */ public @NonNull Transaction setSystemContentPriority( @NonNull SurfaceControl sc, @IntRange(from = -10, to = 10) int priority) { checkPreconditions(sc); nativeSetSystemContentPriority(mNativeObject, sc.mNativeObject, priority); return this; } /** * Sets the caching hint for the layer. By default, the caching hint is * {@link CACHING_ENABLED}. Loading core/jni/android_view_SurfaceControl.cpp +8 −0 Original line number Diff line number Diff line Loading @@ -867,6 +867,13 @@ static void nativeSetContentPriority(JNIEnv* env, jclass clazz, jlong transactio transaction->setContentPriority(surfaceControl, priority); } static void nativeSetSystemContentPriority(JNIEnv* env, jclass clazz, jlong transactionObj, jlong surfaceControlObj, jint priority) { auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj); auto surfaceControl = SpFromRawPtr<SurfaceControl>(surfaceControlObj); transaction->setSystemContentPriority(surfaceControl, priority); } static void nativeSetCachingHint(JNIEnv* env, jclass clazz, jlong transactionObj, jlong nativeObject, jint cachingHint) { auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj); Loading Loading @@ -2884,6 +2891,7 @@ static const JNINativeMethod sSurfaceControlMethods[] = { {"nativeEnableDebugLogCallPoints", "(J)V", (void*)nativeEnableDebugLogCallPoints }, {"nativeSetPictureProfileId", "(JJJ)V", (void*)nativeSetPictureProfileId }, {"nativeSetContentPriority", "(JJI)V", (void*)nativeSetContentPriority }, {"nativeSetSystemContentPriority", "(JJI)V", (void*)nativeSetSystemContentPriority }, // clang-format on }; Loading Loading
core/java/android/view/SurfaceControl.java +23 −0 Original line number Diff line number Diff line Loading @@ -345,6 +345,8 @@ public final class SurfaceControl implements Parcelable { long nativeObject, long pictureProfileId); private static native void nativeSetContentPriority(long transactionObj, long nativeObject, int priority); private static native void nativeSetSystemContentPriority( long transactionObj, long nativeObject, int priority); private static native String nativeGetName(long nativeObject); /** Loading Loading @@ -5074,6 +5076,27 @@ public final class SurfaceControl implements Parcelable { return this; } /** * Sets the system-level importance of the window's content. * <p> * This priority is used by the system to make decisions for different use cases where the * resource is limited. * <p> * This is intended for system internal use. * * @param sc The SurfaceControl of the layer to update. * @param priority The system content priority to assign to this layer. The range of the * system priority is [-10. 10]. A window with higher priority value gets * preferred access to limited resources. * @hide */ public @NonNull Transaction setSystemContentPriority( @NonNull SurfaceControl sc, @IntRange(from = -10, to = 10) int priority) { checkPreconditions(sc); nativeSetSystemContentPriority(mNativeObject, sc.mNativeObject, priority); return this; } /** * Sets the caching hint for the layer. By default, the caching hint is * {@link CACHING_ENABLED}. Loading
core/jni/android_view_SurfaceControl.cpp +8 −0 Original line number Diff line number Diff line Loading @@ -867,6 +867,13 @@ static void nativeSetContentPriority(JNIEnv* env, jclass clazz, jlong transactio transaction->setContentPriority(surfaceControl, priority); } static void nativeSetSystemContentPriority(JNIEnv* env, jclass clazz, jlong transactionObj, jlong surfaceControlObj, jint priority) { auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj); auto surfaceControl = SpFromRawPtr<SurfaceControl>(surfaceControlObj); transaction->setSystemContentPriority(surfaceControl, priority); } static void nativeSetCachingHint(JNIEnv* env, jclass clazz, jlong transactionObj, jlong nativeObject, jint cachingHint) { auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj); Loading Loading @@ -2884,6 +2891,7 @@ static const JNINativeMethod sSurfaceControlMethods[] = { {"nativeEnableDebugLogCallPoints", "(J)V", (void*)nativeEnableDebugLogCallPoints }, {"nativeSetPictureProfileId", "(JJJ)V", (void*)nativeSetPictureProfileId }, {"nativeSetContentPriority", "(JJI)V", (void*)nativeSetContentPriority }, {"nativeSetSystemContentPriority", "(JJI)V", (void*)nativeSetSystemContentPriority }, // clang-format on }; Loading