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

Commit eb8161a0 authored by Andy Labrada's avatar Andy Labrada Committed by Android (Google) Code Review
Browse files

Merge "SurfaceFlinger: Remove usage of window types to implement policy"

parents 6c5166c7 c87e1ce1
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@ import static android.graphics.Matrix.MSCALE_X;
import static android.graphics.Matrix.MSCALE_Y;
import static android.graphics.Matrix.MSKEW_X;
import static android.graphics.Matrix.MSKEW_Y;
import static android.view.SurfaceControl.METADATA_WINDOW_TYPE;
import static android.view.View.SYSTEM_UI_FLAG_VISIBLE;
import static android.view.WindowManager.LayoutParams.TYPE_WALLPAPER;

@@ -1168,12 +1167,14 @@ public abstract class WallpaperService extends Service {
                            mBbqSurfaceControl = new SurfaceControl.Builder()
                                    .setName("Wallpaper BBQ wrapper")
                                    .setHidden(false)
                                    // TODO(b/192291754)
                                    .setMetadata(METADATA_WINDOW_TYPE, TYPE_WALLPAPER)
                                    .setBLASTLayer()
                                    .setParent(mSurfaceControl)
                                    .setCallsite("Wallpaper#relayout")
                                    .build();
                            SurfaceControl.Transaction transaction =
                                    new SurfaceControl.Transaction();
                            transaction.setDefaultFrameRateCompatibility(mBbqSurfaceControl,
                                Surface.FRAME_RATE_COMPATIBILITY_MIN).apply();
                        }
                        // Propagate transform hint from WM, so we can use the right hint for the
                        // first frame.
+13 −0
Original line number Diff line number Diff line
@@ -228,6 +228,19 @@ public class Surface implements Parcelable {
     */
    public static final int FRAME_RATE_COMPATIBILITY_EXACT = 100;

    // From window.h. Keep these in sync.
    /**
     * This surface is ignored while choosing the refresh rate.
     * @hide
     */
    public static final int FRAME_RATE_COMPATIBILITY_NO_VOTE = 101;

    // From window.h. Keep these in sync.
    /**
     * This surface will vote for the minimum refresh rate.
     * @hide
     */
    public static final int FRAME_RATE_COMPATIBILITY_MIN = 102;

    /** @hide */
    @Retention(RetentionPolicy.SOURCE)
+21 −0
Original line number Diff line number Diff line
@@ -249,6 +249,8 @@ public final class SurfaceControl implements Parcelable {

    private static native void nativeSetFrameRate(long transactionObj, long nativeObject,
            float frameRate, int compatibility, int changeFrameRateStrategy);
    private static native void nativeSetDefaultFrameRateCompatibility(long transactionObj,
            long nativeObject, int compatibility);
    private static native long nativeGetHandle(long nativeObject);

    private static native void nativeSetFixedTransformHint(long transactionObj, long nativeObject,
@@ -3613,6 +3615,25 @@ public final class SurfaceControl implements Parcelable {
            return this;
        }

        /**
         * Sets the default frame rate compatibility for the surface {@link SurfaceControl}
         *
         * @param sc The SurfaceControl to specify the frame rate of.
         * @param compatibility The frame rate compatibility of this surface. The compatibility
         *               value may influence the system's choice of display frame rate.
         *
         * @return This transaction object.
         *
         * @hide
         */
        @NonNull
        public Transaction setDefaultFrameRateCompatibility(@NonNull SurfaceControl sc,
                @Surface.FrameRateCompatibility int compatibility) {
            checkPreconditions(sc);
            nativeSetDefaultFrameRateCompatibility(mNativeObject, sc.mNativeObject, compatibility);
            return this;
        }

        /**
         * Sets focus on the window identified by the input {@code token} if the window is focusable
         * otherwise the request is dropped.
+6 −1
Original line number Diff line number Diff line
@@ -3024,6 +3024,12 @@ public final class ViewRootImpl implements ViewParent,
                    if (surfaceControlChanged && mDisplayDecorationCached) {
                        updateDisplayDecoration();
                    }
                    if (surfaceControlChanged
                            && mWindowAttributes.type
                            == WindowManager.LayoutParams.TYPE_STATUS_BAR) {
                        mTransaction.setDefaultFrameRateCompatibility(mSurfaceControl,
                            Surface.FRAME_RATE_COMPATIBILITY_NO_VOTE).apply();
                    }
                }

                if (DEBUG_LAYOUT) Log.v(mTag, "relayout: frame=" + frame.toShortString()
@@ -3064,7 +3070,6 @@ public final class ViewRootImpl implements ViewParent,
                if (surfaceReplaced) {
                    mSurfaceSequenceId++;
                }

                if (alwaysConsumeSystemBarsChanged) {
                    mAttachInfo.mAlwaysConsumeSystemBars = mPendingAlwaysConsumeSystemBars;
                    dispatchApplyInsets = true;
+11 −0
Original line number Diff line number Diff line
@@ -1018,6 +1018,15 @@ static void nativeSetFrameRate(JNIEnv* env, jclass clazz, jlong transactionObj,
                              static_cast<int8_t>(changeFrameRateStrategy));
}

static void nativeSetDefaultFrameRateCompatibility(JNIEnv* env, jclass clazz, jlong transactionObj,
                                                   jlong nativeObject, jint compatibility) {
    auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);

    const auto ctrl = reinterpret_cast<SurfaceControl*>(nativeObject);

    transaction->setDefaultFrameRateCompatibility(ctrl, static_cast<int8_t>(compatibility));
}

static void nativeSetFixedTransformHint(JNIEnv* env, jclass clazz, jlong transactionObj,
                                        jlong nativeObject, jint transformHint) {
    auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
@@ -2157,6 +2166,8 @@ static const JNINativeMethod sSurfaceControlMethods[] = {
            (void*)nativeSetShadowRadius },
    {"nativeSetFrameRate", "(JJFII)V",
            (void*)nativeSetFrameRate },
    {"nativeSetDefaultFrameRateCompatibility", "(JJI)V",
            (void*)nativeSetDefaultFrameRateCompatibility},
    {"nativeGetPhysicalDisplayIds", "()[J",
            (void*)nativeGetPhysicalDisplayIds },
    {"nativeGetPrimaryPhysicalDisplayId", "()J",