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

This commit is contained in:
Winson Chung
2021-07-23 01:04:18 +00:00
committed by Android (Google) Code Review
5 changed files with 37 additions and 4 deletions

View File

@@ -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);
@@ -3413,6 +3415,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.

View File

@@ -823,6 +823,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);
@@ -1984,6 +1992,8 @@ static const JNINativeMethod sSurfaceControlMethods[] = {
(void*)nativeSetTransformHint },
{"nativeGetTransformHint", "(J)I",
(void*)nativeGetTransformHint },
{"nativeSetTrustedOverlay", "(JJZ)V",
(void*)nativeSetTrustedOverlay },
// clang-format on
};

View File

@@ -2206,16 +2206,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);
@@ -2223,6 +2224,9 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
mService.getTaskChangeNotificationController().notifyActivityUnpinned();
}
mWindowManager.mPolicy.setPipVisibilityLw(inPip);
mWmService.mTransactionFactory.get()
.setTrustedOverlay(task.getSurfaceControl(), inPip)
.apply();
}
void executeAppTransitionForAllDisplay() {

View File

@@ -1437,7 +1437,7 @@ class Task extends WindowContainer<WindowContainer> {
&& (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);
}
}
@@ -5394,7 +5394,7 @@ class Task extends WindowContainer<WindowContainer> {
: 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

View File

@@ -265,4 +265,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;
}
}