Add mechanism for a task's windows to be trusted overlays
- Exposes a method to set that a certain part of the SF hierarchy is trusted, and sets this state for tasks in PIP. Bug: 191529039 Test: Manual, try using permission dialog while PIP is active Change-Id: I170cb5a7d22ef569eb36de21cc0bcbef60dd385e
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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
|
||||
};
|
||||
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user