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

Commit 8c0d482f authored by Winson Chung's avatar Winson Chung Committed by Automerger Merge Worker
Browse files

Merge "Add mechanism for a task's windows to be trusted overlays" into sc-dev...

Merge "Add mechanism for a task's windows to be trusted overlays" into sc-dev am: 24706f06 am: 2446c0eb

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15150506

Change-Id: I44bbdc70ac3b455f7e018acf3596624f5c1622ef
parents d8e9b5ec 2446c0eb
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -148,6 +148,8 @@ public final class SurfaceControl implements Parcelable {
            float width, float height, float vecX, float vecY,
            float maxStretchAmountX, float maxStretchAmountY, float childRelativeLeft,
            float childRelativeTop, float childRelativeRight, float childRelativeBottom);
    private static native void nativeSetTrustedOverlay(long transactionObj, long nativeObject,
            boolean isTrustedOverlay);

    private static native boolean nativeClearContentFrameStats(long nativeObject);
    private static native boolean nativeGetContentFrameStats(long nativeObject, WindowContentFrameStats outStats);
@@ -3435,6 +3437,17 @@ public final class SurfaceControl implements Parcelable {
            return this;
        }

        /**
         * Sets the trusted overlay state on this SurfaceControl and it is inherited to all the
         * children. The caller must hold the ACCESS_SURFACE_FLINGER permission.
         * @hide
         */
        public Transaction setTrustedOverlay(SurfaceControl sc, boolean isTrustedOverlay) {
            checkPreconditions(sc);
            nativeSetTrustedOverlay(mNativeObject, sc.mNativeObject, isTrustedOverlay);
            return this;
        }

         /**
         * Merge the other transaction into this transaction, clearing the
         * other transaction as if it had been applied.
+10 −0
Original line number Diff line number Diff line
@@ -825,6 +825,14 @@ static void nativeSetShadowRadius(JNIEnv* env, jclass clazz, jlong transactionOb
    transaction->setShadowRadius(ctrl, shadowRadius);
}

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

    SurfaceControl* const ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
    transaction->setTrustedOverlay(ctrl, isTrustedOverlay);
}

static void nativeSetFrameRate(JNIEnv* env, jclass clazz, jlong transactionObj, jlong nativeObject,
                               jfloat frameRate, jint compatibility, jint changeFrameRateStrategy) {
    auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
@@ -1999,6 +2007,8 @@ static const JNINativeMethod sSurfaceControlMethods[] = {
            (void*)nativeSetTransformHint },
    {"nativeGetTransformHint", "(J)I",
            (void*)nativeGetTransformHint },
    {"nativeSetTrustedOverlay", "(JJZ)V",
            (void*)nativeSetTrustedOverlay },
        // clang-format on
};

+6 −2
Original line number Diff line number Diff line
@@ -2212,16 +2212,17 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
        ensureActivitiesVisible(null, 0, false /* preserveWindows */);
        resumeFocusedTasksTopActivities();

        notifyActivityPipModeChanged(r);
        notifyActivityPipModeChanged(r.getTask(), r);
    }

    /**
     * Notifies when an activity enters or leaves PIP mode.
     *
     * @param task the task of {@param r}
     * @param r indicates the activity currently in PIP, can be null to indicate no activity is
     *          currently in PIP mode.
     */
    void notifyActivityPipModeChanged(@Nullable ActivityRecord r) {
    void notifyActivityPipModeChanged(@NonNull Task task, @Nullable ActivityRecord r) {
        final boolean inPip = r != null;
        if (inPip) {
            mService.getTaskChangeNotificationController().notifyActivityPinned(r);
@@ -2229,6 +2230,9 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
            mService.getTaskChangeNotificationController().notifyActivityUnpinned();
        }
        mWindowManager.mPolicy.setPipVisibilityLw(inPip);
        mWmService.mTransactionFactory.get()
                .setTrustedOverlay(task.getSurfaceControl(), inPip)
                .apply();
    }

    void executeAppTransitionForAllDisplay() {
+2 −2
Original line number Diff line number Diff line
@@ -1203,7 +1203,7 @@ class Task extends TaskFragment {
                    && (newParent == null || !newParent.inPinnedWindowingMode())) {
                // Notify if a task from the root pinned task is being removed
                // (or moved depending on the mode).
                mRootWindowContainer.notifyActivityPipModeChanged(null);
                mRootWindowContainer.notifyActivityPipModeChanged(this, null);
            }
        }

@@ -4576,7 +4576,7 @@ class Task extends TaskFragment {
                    : WINDOWING_MODE_FULLSCREEN;
        }
        if (currentMode == WINDOWING_MODE_PINNED) {
            mRootWindowContainer.notifyActivityPipModeChanged(null);
            mRootWindowContainer.notifyActivityPipModeChanged(this, null);
        }
        if (likelyResolvedMode == WINDOWING_MODE_PINNED) {
            // In the case that we've disabled affecting the SysUI flags as a part of seamlessly
+6 −0
Original line number Diff line number Diff line
@@ -270,4 +270,10 @@ public class StubTransaction extends SurfaceControl.Transaction {
    public SurfaceControl.Transaction setColorSpace(SurfaceControl sc, ColorSpace colorSpace) {
        return this;
    }

    @Override
    public SurfaceControl.Transaction setTrustedOverlay(SurfaceControl sc,
            boolean isTrustedOverlay) {
        return this;
    }
}