Merge "Allow some cross activity touches" into tm-dev

This commit is contained in:
Linus Tufvesson
2022-05-18 08:05:50 +00:00
committed by Android (Google) Code Review
2 changed files with 19 additions and 5 deletions

View File

@@ -926,6 +926,11 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
private final ActivityRecordInputSink mActivityRecordInputSink;
// Activities with this uid are allowed to not create an input sink while being in the same
// task and directly above this ActivityRecord. This field is updated whenever a new activity
// is launched from this ActivityRecord. Touches are always allowed within the same uid.
int mAllowedTouchUid;
private final Runnable mPauseTimeoutRunnable = new Runnable() {
@Override
public void run() {
@@ -2099,7 +2104,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
}
mAtmService.mPackageConfigPersister.updateConfigIfNeeded(this, mUserId, packageName);
mActivityRecordInputSink = new ActivityRecordInputSink(this);
mActivityRecordInputSink = new ActivityRecordInputSink(this, sourceRecord);
updateEnterpriseThumbnailDrawable(mAtmService.mUiContext);
}

View File

@@ -42,14 +42,16 @@ class ActivityRecordInputSink {
private InputWindowHandleWrapper mInputWindowHandleWrapper;
private SurfaceControl mSurfaceControl;
private boolean mDisabled = false;
ActivityRecordInputSink(ActivityRecord activityRecord) {
ActivityRecordInputSink(ActivityRecord activityRecord, ActivityRecord sourceRecord) {
mActivityRecord = activityRecord;
mIsCompatEnabled = CompatChanges.isChangeEnabled(ENABLE_TOUCH_OPAQUE_ACTIVITIES,
mActivityRecord.getUid());
mName = Integer.toHexString(System.identityHashCode(this)) + " ActivityRecordInputSink "
+ mActivityRecord.mActivityComponent.flattenToShortString();
if (sourceRecord != null) {
sourceRecord.mAllowedTouchUid = mActivityRecord.getUid();
}
}
public void applyChangesToSurfaceIfChanged(SurfaceControl.Transaction transaction) {
@@ -77,8 +79,15 @@ class ActivityRecordInputSink {
if (mInputWindowHandleWrapper == null) {
mInputWindowHandleWrapper = new InputWindowHandleWrapper(createInputWindowHandle());
}
if (mDisabled || !mIsCompatEnabled || mActivityRecord.isInTransition()) {
// TODO(b/208662670): Investigate if we can have feature active during animations.
// Don't block touches from passing through to an activity below us in the same task, if
// that activity is either from the same uid or if that activity has launched an activity
// in our uid.
final ActivityRecord activityBelowInTask =
mActivityRecord.getTask().getActivityBelow(mActivityRecord);
final boolean allowPassthrough = activityBelowInTask != null && (
activityBelowInTask.mAllowedTouchUid == mActivityRecord.getUid()
|| activityBelowInTask.isUid(mActivityRecord.getUid()));
if (allowPassthrough || !mIsCompatEnabled || mActivityRecord.isInTransition()) {
mInputWindowHandleWrapper.setInputConfigMasked(InputConfig.NOT_TOUCHABLE,
InputConfig.NOT_TOUCHABLE);
} else {