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

Commit 80094cc2 authored by Tony Mak's avatar Tony Mak Committed by Android (Google) Code Review
Browse files

Merge "Do not pass assist data and screenshot to VIS if one of the windows is...

Merge "Do not pass assist data and screenshot to VIS if one of the windows is from private profile" into main
parents 88cc4aeb 09074b74
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)