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

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

Add mechanism for a task's windows to be trusted overlays am: 47fb132e

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

Change-Id: Ia323593ceba41580d88b6d058ae0bfc8c92dce3f
parents 3d570b73 47fb132e
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -139,6 +139,8 @@ public final class SurfaceControl implements Parcelable {
            int blurRadius);
    private static native void nativeSetLayerStack(long transactionObj, long nativeObject,
            int layerStack);
    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);
@@ -3037,6 +3039,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.
+12 −1
Original line number Diff line number Diff line
@@ -627,6 +627,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) {
    auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
@@ -1666,7 +1674,10 @@ static const JNINativeMethod sSurfaceControlMethods[] = {
            (void*)nativeSetGlobalShadowSettings },
    {"nativeGetHandle", "(J)J",
            (void*)nativeGetHandle },
    {"nativeSetFixedTransformHint", "(JJI)V", (void*)nativeSetFixedTransformHint},
    {"nativeSetFixedTransformHint", "(JJI)V", 
            (void*)nativeSetFixedTransformHint},
    {"nativeSetTrustedOverlay", "(JJZ)V",
            (void*)nativeSetTrustedOverlay },
};

int register_android_view_SurfaceControl(JNIEnv* env)
+1 −1
Original line number Diff line number Diff line
@@ -715,7 +715,7 @@ class ActivityStack extends Task {
                    : WINDOWING_MODE_FULLSCREEN;
        }
        if (currentMode == WINDOWING_MODE_PINNED) {
            mAtmService.getTaskChangeNotificationController().notifyActivityUnpinned();
            mRootWindowContainer.notifyActivityPipModeChanged(this, null);
        }
        if (likelyResolvedMode == WINDOWING_MODE_PINNED
                && taskDisplayArea.getRootPinnedTask() != null) {
+21 −1
Original line number Diff line number Diff line
@@ -2219,7 +2219,27 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
        ensureActivitiesVisible(null, 0, false /* preserveWindows */);
        resumeFocusedStacksTopActivities();

        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(@NonNull Task task, @Nullable ActivityRecord r) {
        final boolean inPip = r != null;
        if (inPip) {
            mService.getTaskChangeNotificationController().notifyActivityPinned(r);
        } else {
            mService.getTaskChangeNotificationController().notifyActivityUnpinned();
        }
        mWindowManager.mPolicy.setPipVisibilityLw(inPip);
        mWmService.mTransactionFactory.get()
                .setTrustedOverlay(task.getSurfaceControl(), inPip)
                .apply();
    }

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

@@ -4617,5 +4617,4 @@ class Task extends WindowContainer<WindowContainer> {
    long getProtoFieldId() {
        return TASK;
    }

}
Loading