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

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

Change-Id: Id1226a57313811749baf131f0ed418b8d586cc94
This commit is contained in:
Winson Chung
2021-11-09 23:21:09 +00:00
committed by Automerger Merge Worker
6 changed files with 54 additions and 5 deletions

View File

@@ -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.

View File

@@ -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)

View File

@@ -716,7 +716,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) {

View File

@@ -2212,7 +2212,27 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
ensureActivitiesVisible(null, 0, false /* preserveWindows */);
resumeFocusedStacksTopActivities();
mService.getTaskChangeNotificationController().notifyActivityPinned(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(@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() {

View File

@@ -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);
}
}
@@ -4583,5 +4583,4 @@ class Task extends WindowContainer<WindowContainer> {
long getProtoFieldId() {
return TASK;
}
}

View File

@@ -277,4 +277,10 @@ public class StubTransaction extends SurfaceControl.Transaction {
public SurfaceControl.Transaction unsetFixedTransformHint(@NonNull SurfaceControl sc) {
return this;
}
@Override
public SurfaceControl.Transaction setTrustedOverlay(SurfaceControl sc,
boolean isTrustedOverlay) {
return this;
}
}