Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e6f446f4 authored by Yi Jiang's avatar Yi Jiang Committed by Android (Google) Code Review
Browse files

Merge "Add system content priority api for internal use" into main

parents 5c8b497d bd2a4eb6
Loading
Loading
Loading
Loading
+23 −0
Original line number Diff line number Diff line
@@ -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);

    /**
@@ -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}.
+8 −0
Original line number Diff line number Diff line
@@ -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);
@@ -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
};