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

Commit 4630947e authored by Hiroki Sato's avatar Hiroki Sato
Browse files

Allow system windows to disable ActivityRecordInputSink

Some system window want to disable ActivityRecordInputSink so that input
events pass through it.

This adds a flag in ActivityRecord to toggle the behavior.
This is guared by Manifest.permission.INTERNAL_SYSTEM_WINDOW.

Bug: 262477923
Test: ActivityRecordInputSinkTests
Change-Id: I258f06dbb4238b7b0ae43870d8e7ca3165e76f43
parent 4490339b
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import static android.Manifest.permission.CONTROL_REMOTE_APP_TRANSITION_ANIMATIO
import static android.Manifest.permission.DETECT_SCREEN_CAPTURE;
import static android.Manifest.permission.INTERACT_ACROSS_USERS;
import static android.Manifest.permission.INTERACT_ACROSS_USERS_FULL;
import static android.Manifest.permission.INTERNAL_SYSTEM_WINDOW;
import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED;
import static android.app.WindowConfiguration.inMultiWindowMode;
import static android.os.Process.myUid;
@@ -9439,6 +9440,15 @@ public class Activity extends ContextThemeWrapper
        ActivityClient.getInstance().enableTaskLocaleOverride(mToken);
    }

    /**
     * Request ActivityRecordInputSink to enable or disable blocking input events.
     * @hide
     */
    @RequiresPermission(INTERNAL_SYSTEM_WINDOW)
    public void setActivityRecordInputSinkEnabled(boolean enabled) {
        ActivityClient.getInstance().setActivityRecordInputSinkEnabled(mToken, enabled);
    }

    class HostCallbacks extends FragmentHostCallback<Activity> {
        public HostCallbacks() {
            super(Activity.this /*activity*/);
+11 −0
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package android.app;

import static android.Manifest.permission.INTERNAL_SYSTEM_WINDOW;

import android.annotation.Nullable;
import android.annotation.RequiresPermission;
import android.content.ComponentName;
@@ -614,6 +616,15 @@ public class ActivityClient {
        }
    }

    @RequiresPermission(INTERNAL_SYSTEM_WINDOW)
    void setActivityRecordInputSinkEnabled(IBinder activityToken, boolean enabled) {
        try {
            getActivityClientController().setActivityRecordInputSinkEnabled(activityToken, enabled);
        } catch (RemoteException e) {
            e.rethrowFromSystemServer();
        }
    }

    /**
     * Shows or hides a Camera app compat toggle for stretched issues with the requested state.
     *
+10 −0
Original line number Diff line number Diff line
@@ -191,4 +191,14 @@ interface IActivityClientController {
     */
    boolean isRequestedToLaunchInTaskFragment(in IBinder activityToken,
            in IBinder taskFragmentToken);

    /**
     * Enable or disable ActivityRecordInputSink to block input events.
     *
     * @param token The token for the activity that requests to toggle.
     * @param enabled Whether the input evens are blocked by ActivityRecordInputSink.
     */
    @JavaPassthrough(annotation = "@android.annotation.RequiresPermission(android.Manifest"
            + ".permission.INTERNAL_SYSTEM_WINDOW)")
    oneway void setActivityRecordInputSinkEnabled(in IBinder activityToken, boolean enabled);
}
+9 −1
Original line number Diff line number Diff line
@@ -39,3 +39,11 @@ flag {
    description: "Remove uses of ScreenCapture#captureDisplay"
    bug: "293445881"
}

flag {
    namespace: "window_surfaces"
    name: "allow_disable_activity_record_input_sink"
    description: "Whether to allow system activity to disable ActivityRecordInputSink"
    is_fixed_read_only: true
    bug: "262477923"
}
+17 −0
Original line number Diff line number Diff line
@@ -55,6 +55,7 @@ import static com.android.server.wm.ActivityTaskManagerDebugConfig.TAG_WITH_CLAS
import static com.android.server.wm.ActivityTaskManagerService.RELAUNCH_REASON_NONE;
import static com.android.server.wm.ActivityTaskManagerService.TAG_SWITCH;
import static com.android.server.wm.ActivityTaskManagerService.enforceNotIsolatedCaller;
import static com.android.window.flags.Flags.allowDisableActivityRecordInputSink;

import android.Manifest;
import android.annotation.ColorInt;
@@ -1688,4 +1689,20 @@ class ActivityClientController extends IActivityClientController.Stub {
            return r.mRequestedLaunchingTaskFragmentToken == taskFragmentToken;
        }
    }

    @Override
    public void setActivityRecordInputSinkEnabled(IBinder activityToken, boolean enabled) {
        if (!allowDisableActivityRecordInputSink()) {
            return;
        }

        mService.mAmInternal.enforceCallingPermission(
                Manifest.permission.INTERNAL_SYSTEM_WINDOW, "setActivityRecordInputSinkEnabled");
        synchronized (mGlobalLock) {
            final ActivityRecord r = ActivityRecord.forTokenLocked(activityToken);
            if (r != null) {
                r.mActivityRecordInputSinkEnabled = enabled;
            }
        }
    }
}
Loading