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

Commit 41a9167b authored by mrulhania's avatar mrulhania
Browse files

Add new method to remove blocked packages in WindowManagerInternal

The new overloads are requierd by "hide login page", adding
the feature flag to WindowState as well.

Bug: 324348549
Test: WindowStateTests
Change-Id: I02c3b4f8d4dab05a49e05110ac83e599abfb030d
parent 7f240701
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -55,6 +55,17 @@ public class SensitiveContentPackages {
        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
     *
+9 −0
Original line number 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.
     *
     * @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
     * * {@link #addBlockScreenCaptureForApps(ArraySet)}
     */
+11 −0
Original line number 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
        public void clearBlockedApps() {
            synchronized (mGlobalLock) {
+19 −0
Original line number Diff line number Diff line
@@ -1424,6 +1424,25 @@ public class WindowStateTests extends WindowTestsBase {
        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 IBinder mImeTargetToken;
        private boolean mIsRemoved;