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

Commit 09074b74 authored by Tony Mak's avatar Tony Mak
Browse files

Do not pass assist data and screenshot to VIS if one of the windows is from private profile

Check if there is any window on the current display is coming from
the private profile, if so, do not allow passing the data to VIS.

Bug: 323128958

Test: Added tests in android.voiceinteraction.cts.VoiceInteractionServiceTest
Test: Manual. Write a simple VIS app for testing.
1. Trigger the VIS test app when the personal app is in foreground.
The VIS app can get the data.

2. Trigger the VIS test app when the private space app is in foreground.
The VIS app cannot get the data.

3. Enables split screen. One app from personal and one app from private
space. The VIS cannot get the data.

Change-Id: Ic0490ff8da6fd74ab8c762fee13e1822abdf8acd
parent 4ad87918
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -225,7 +225,7 @@ interface IActivityTaskManager {
            boolean focused, boolean newSessionId);
    boolean requestAutofillData(in IAssistDataReceiver receiver, in Bundle receiverExtras,
            in IBinder activityToken, int flags);
    boolean isAssistDataAllowedOnCurrentActivity();
    boolean isAssistDataAllowed();
    boolean requestAssistDataForTask(in IAssistDataReceiver receiver, int taskId,
            in String callingPackageName, String callingAttributionTag);

+1 −1
Original line number Diff line number Diff line
@@ -222,7 +222,7 @@ public class AssistDataRequester extends IAssistDataReceiver.Stub {
        // Ensure that the current activity supports assist data
        boolean isAssistDataAllowed = false;
        try {
            isAssistDataAllowed = mActivityTaskManager.isAssistDataAllowedOnCurrentActivity();
            isAssistDataAllowed = mActivityTaskManager.isAssistDataAllowed();
        } catch (RemoteException e) {
            // Should never happen
        }
+12 −2
Original line number Diff line number Diff line
@@ -3505,8 +3505,9 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
    }

    @Override
    public boolean isAssistDataAllowedOnCurrentActivity() {
    public boolean isAssistDataAllowed() {
        int userId;
        boolean hasRestrictedWindow;
        synchronized (mGlobalLock) {
            final Task focusedRootTask = getTopDisplayFocusedRootTask();
            if (focusedRootTask == null || focusedRootTask.isActivityTypeAssistant()) {
@@ -3518,8 +3519,17 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
                return false;
            }
            userId = activity.mUserId;
            DisplayContent displayContent = activity.getDisplayContent();
            if (displayContent == null) {
                return false;
            }
            hasRestrictedWindow = displayContent.forAllWindows(windowState -> {
                return windowState.isOnScreen() && UserManager.isUserTypePrivateProfile(
                        getUserManager().getProfileType(windowState.mShowUserId));
            }, true /* traverseTopToBottom */);
        }
        return DevicePolicyCache.getInstance().isScreenCaptureAllowed(userId);
        return DevicePolicyCache.getInstance().isScreenCaptureAllowed(userId)
                && !hasRestrictedWindow;
    }

    private void onLocalVoiceInteractionStartedLocked(IBinder activity,
+1 −1
Original line number Diff line number Diff line
@@ -146,7 +146,7 @@ public class AssistDataRequesterTest {

    private void setupMocks(boolean currentActivityAssistAllowed, boolean assistStructureAllowed,
            boolean assistScreenshotAllowed) throws Exception {
        doReturn(currentActivityAssistAllowed).when(mAtm).isAssistDataAllowedOnCurrentActivity();
        doReturn(currentActivityAssistAllowed).when(mAtm).isAssistDataAllowed();
        doReturn(assistStructureAllowed ? MODE_ALLOWED : MODE_ERRORED).when(mAppOpsManager)
                .noteOpNoThrow(eq(OP_ASSIST_STRUCTURE), anyInt(), anyString(), any(), any());
        doReturn(assistScreenshotAllowed ? MODE_ALLOWED : MODE_ERRORED).when(mAppOpsManager)