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

Commit abacba4c authored by Manjeet Rulhania's avatar Manjeet Rulhania Committed by Android (Google) Code Review
Browse files

Merge "Add new method to remove blocked packages in WindowManagerInternal" into main

parents af889dbe 41a9167b
Loading
Loading
Loading
Loading
+11 −0
Original line number Original line Diff line number Diff line
@@ -55,6 +55,17 @@ public class SensitiveContentPackages {
        return true;
        return true;
    }
    }


    /**
     * Clears apps added to collection of apps in which screen capture should be disabled.
     *
     * @param packageInfos set of {@link PackageInfo} whose windows should be unblocked
     *                     from capture.
     * @return {@code true} if packages set is modified, {@code false} otherwise.
     */
    public boolean removeBlockScreenCaptureForApps(@NonNull ArraySet<PackageInfo> packageInfos) {
        return mProtectedPackages.removeAll(packageInfos);
    }

    /**
    /**
     * Clears the set of package/uid pairs that should be blocked from screen capture
     * Clears the set of package/uid pairs that should be blocked from screen capture
     *
     *
+9 −0
Original line number Original line Diff line number Diff line
@@ -1043,6 +1043,15 @@ public abstract class WindowManagerInternal {
    /**
    /**
     * Clears apps added to collection of apps in which screen capture should be disabled.
     * Clears apps added to collection of apps in which screen capture should be disabled.
     *
     *
     * @param packageInfos set of {@link PackageInfo} whose windows should be unblocked
     *                     from capture.
     */
    public abstract void removeBlockScreenCaptureForApps(
            @NonNull ArraySet<PackageInfo> packageInfos);

    /**
     * Clears all apps added to collection of apps in which screen capture should be disabled.
     *
     * <p> This clears and resets any existing set or added applications from
     * <p> This clears and resets any existing set or added applications from
     * * {@link #addBlockScreenCaptureForApps(ArraySet)}
     * * {@link #addBlockScreenCaptureForApps(ArraySet)}
     */
     */
+11 −0
Original line number Original line Diff line number Diff line
@@ -8631,6 +8631,17 @@ public class WindowManagerService extends IWindowManager.Stub
            }
            }
        }
        }


        @Override
        public void removeBlockScreenCaptureForApps(ArraySet<PackageInfo> packageInfos) {
            synchronized (mGlobalLock) {
                boolean modified =
                        mSensitiveContentPackages.removeBlockScreenCaptureForApps(packageInfos);
                if (modified) {
                    WindowManagerService.this.refreshScreenCaptureDisabled();
                }
            }
        }

        @Override
        @Override
        public void clearBlockedApps() {
        public void clearBlockedApps() {
            synchronized (mGlobalLock) {
            synchronized (mGlobalLock) {
+19 −0
Original line number Original line Diff line number Diff line
@@ -1424,6 +1424,25 @@ public class WindowStateTests extends WindowTestsBase {
        assertFalse(window2.isSecureLocked());
        assertFalse(window2.isSecureLocked());
    }
    }


    @Test
    @RequiresFlagsEnabled(FLAG_SENSITIVE_NOTIFICATION_APP_PROTECTION)
    public void testIsSecureLocked_sensitiveContentBlockOrClearScreenCaptureForApp() {
        String testPackage = "test";
        int ownerId = 20;
        final WindowState window = createWindow(null, TYPE_APPLICATION, "window", ownerId);
        window.mAttrs.packageName = testPackage;
        assertFalse(window.isSecureLocked());

        PackageInfo blockedPackage = new PackageInfo(testPackage, ownerId);
        ArraySet<PackageInfo> blockedPackages = new ArraySet();
        blockedPackages.add(blockedPackage);
        mWm.mSensitiveContentPackages.addBlockScreenCaptureForApps(blockedPackages);
        assertTrue(window.isSecureLocked());

        mWm.mSensitiveContentPackages.removeBlockScreenCaptureForApps(blockedPackages);
        assertFalse(window.isSecureLocked());
    }

    private static class TestImeTargetChangeListener implements ImeTargetChangeListener {
    private static class TestImeTargetChangeListener implements ImeTargetChangeListener {
        private IBinder mImeTargetToken;
        private IBinder mImeTargetToken;
        private boolean mIsRemoved;
        private boolean mIsRemoved;