diff options
8 files changed, 645 insertions, 85 deletions
diff --git a/services/core/java/com/android/server/SensitiveContentProtectionManagerService.java b/services/core/java/com/android/server/SensitiveContentProtectionManagerService.java index 70bd4b328b43..c3916422159e 100644 --- a/services/core/java/com/android/server/SensitiveContentProtectionManagerService.java +++ b/services/core/java/com/android/server/SensitiveContentProtectionManagerService.java @@ -34,11 +34,11 @@ import android.service.notification.StatusBarNotification; import android.util.ArraySet; import android.util.Log; +import com.android.internal.annotations.GuardedBy; import com.android.internal.annotations.VisibleForTesting; import com.android.server.wm.SensitiveContentPackages.PackageInfo; import com.android.server.wm.WindowManagerInternal; -import java.util.Collections; import java.util.Set; /** @@ -54,6 +54,10 @@ public final class SensitiveContentProtectionManagerService extends SystemServic private @Nullable MediaProjectionManager mProjectionManager; private @Nullable WindowManagerInternal mWindowManager; + final Object mSensitiveContentProtectionLock = new Object(); + @GuardedBy("mSensitiveContentProtectionLock") + private boolean mProjectionActive = false; + private final MediaProjectionManager.Callback mProjectionCallback = new MediaProjectionManager.Callback() { @Override @@ -132,14 +136,23 @@ public final class SensitiveContentProtectionManagerService extends SystemServic } private void onProjectionStart() { - StatusBarNotification[] notifications; - try { - notifications = mNotificationListener.getActiveNotifications(); - } catch (SecurityException e) { - Log.e(TAG, "SensitiveContentProtectionManagerService doesn't have access.", e); - notifications = new StatusBarNotification[0]; + synchronized (mSensitiveContentProtectionLock) { + mProjectionActive = true; + updateAppsThatShouldBlockScreenCapture(); } + } + + private void onProjectionEnd() { + synchronized (mSensitiveContentProtectionLock) { + mProjectionActive = false; + + // notify windowmanager to clear any sensitive notifications observed during projection + // session + mWindowManager.clearBlockedApps(); + } + } + private void updateAppsThatShouldBlockScreenCapture() { RankingMap rankingMap; try { rankingMap = mNotificationListener.getCurrentRanking(); @@ -148,41 +161,98 @@ public final class SensitiveContentProtectionManagerService extends SystemServic rankingMap = null; } - // notify windowmanager of any currently posted sensitive content notifications - Set<PackageInfo> packageInfos = getSensitivePackagesFromNotifications( - notifications, - rankingMap); - - mWindowManager.setShouldBlockScreenCaptureForApp(packageInfos); + updateAppsThatShouldBlockScreenCapture(rankingMap); } - private void onProjectionEnd() { - // notify windowmanager to clear any sensitive notifications observed during projection - // session - mWindowManager.setShouldBlockScreenCaptureForApp(Collections.emptySet()); + private void updateAppsThatShouldBlockScreenCapture(RankingMap rankingMap) { + StatusBarNotification[] notifications; + try { + notifications = mNotificationListener.getActiveNotifications(); + } catch (SecurityException e) { + Log.e(TAG, "SensitiveContentProtectionManagerService doesn't have access.", e); + notifications = new StatusBarNotification[0]; + } + + // notify windowmanager of any currently posted sensitive content notifications + ArraySet<PackageInfo> packageInfos = getSensitivePackagesFromNotifications( + notifications, rankingMap); + + mWindowManager.addBlockScreenCaptureForApps(packageInfos); } - private Set<PackageInfo> getSensitivePackagesFromNotifications( - StatusBarNotification[] notifications, RankingMap rankingMap) { + private ArraySet<PackageInfo> getSensitivePackagesFromNotifications( + @NonNull StatusBarNotification[] notifications, RankingMap rankingMap) { + ArraySet<PackageInfo> sensitivePackages = new ArraySet<>(); if (rankingMap == null) { Log.w(TAG, "Ranking map not initialized."); - return Collections.emptySet(); + return sensitivePackages; } - Set<PackageInfo> sensitivePackages = new ArraySet<>(); for (StatusBarNotification sbn : notifications) { - NotificationListenerService.Ranking ranking = - rankingMap.getRawRankingObject(sbn.getKey()); - if (ranking != null && ranking.hasSensitiveContent()) { - PackageInfo info = new PackageInfo(sbn.getPackageName(), sbn.getUid()); + PackageInfo info = getSensitivePackageFromNotification(sbn, rankingMap); + if (info != null) { sensitivePackages.add(info); } } return sensitivePackages; } - // TODO(b/317251408): add trigger that updates on onNotificationPosted, - // onNotificationRankingUpdate and onListenerConnected + private PackageInfo getSensitivePackageFromNotification(StatusBarNotification sbn, + RankingMap rankingMap) { + if (sbn == null) { + Log.w(TAG, "Unable to protect null notification"); + return null; + } + if (rankingMap == null) { + Log.w(TAG, "Ranking map not initialized."); + return null; + } + + NotificationListenerService.Ranking ranking = rankingMap.getRawRankingObject(sbn.getKey()); + if (ranking != null && ranking.hasSensitiveContent()) { + return new PackageInfo(sbn.getPackageName(), sbn.getUid()); + } + return null; + } + @VisibleForTesting - static class NotificationListener extends NotificationListenerService {} + class NotificationListener extends NotificationListenerService { + @Override + public void onListenerConnected() { + super.onListenerConnected(); + // Projection started before notification listener was connected + synchronized (mSensitiveContentProtectionLock) { + if (mProjectionActive) { + updateAppsThatShouldBlockScreenCapture(); + } + } + } + + @Override + public void onNotificationPosted(StatusBarNotification sbn, RankingMap rankingMap) { + super.onNotificationPosted(sbn, rankingMap); + synchronized (mSensitiveContentProtectionLock) { + if (!mProjectionActive) { + return; + } + + // notify windowmanager of any currently posted sensitive content notifications + PackageInfo packageInfo = getSensitivePackageFromNotification(sbn, rankingMap); + + if (packageInfo != null) { + mWindowManager.addBlockScreenCaptureForApps(new ArraySet(Set.of(packageInfo))); + } + } + } + + @Override + public void onNotificationRankingUpdate(RankingMap rankingMap) { + super.onNotificationRankingUpdate(rankingMap); + synchronized (mSensitiveContentProtectionLock) { + if (mProjectionActive) { + updateAppsThatShouldBlockScreenCapture(rankingMap); + } + } + } + } } diff --git a/services/core/java/com/android/server/wm/SensitiveContentPackages.java b/services/core/java/com/android/server/wm/SensitiveContentPackages.java index 3862b82512c3..a7d6903bbe30 100644 --- a/services/core/java/com/android/server/wm/SensitiveContentPackages.java +++ b/services/core/java/com/android/server/wm/SensitiveContentPackages.java @@ -21,7 +21,6 @@ import android.util.ArraySet; import java.io.PrintWriter; import java.util.Objects; -import java.util.Set; /** * Cache of distinct package/uid pairs that require being blocked from screen capture. This class is @@ -41,10 +40,33 @@ public class SensitiveContentPackages { return false; } - /** Replaces the set of package/uid pairs to set that should be blocked from screen capture */ - public void setShouldBlockScreenCaptureForApp(@NonNull Set<PackageInfo> packageInfos) { - mProtectedPackages.clear(); + /** + * Adds the set of package/uid pairs to set that should be blocked from screen capture + * + * @param packageInfos packages to be blocked + * @return {@code true} if packages set is modified, {@code false} otherwise. + */ + public boolean addBlockScreenCaptureForApps(@NonNull ArraySet<PackageInfo> packageInfos) { + if (mProtectedPackages.equals(packageInfos)) { + // new set is equal to current set of packages, no need to update + return false; + } mProtectedPackages.addAll(packageInfos); + return true; + } + + /** + * Clears the set of package/uid pairs that should be blocked from screen capture + * + * @return {@code true} if packages set is modified, {@code false} otherwise. + */ + public boolean clearBlockedApps() { + if (mProtectedPackages.isEmpty()) { + // set was already empty + return false; + } + mProtectedPackages.clear(); + return true; } void dump(PrintWriter pw) { diff --git a/services/core/java/com/android/server/wm/WindowManagerInternal.java b/services/core/java/com/android/server/wm/WindowManagerInternal.java index 22b690e85c35..f2a58e54bfbe 100644 --- a/services/core/java/com/android/server/wm/WindowManagerInternal.java +++ b/services/core/java/com/android/server/wm/WindowManagerInternal.java @@ -32,6 +32,7 @@ import android.hardware.display.VirtualDisplayConfig; import android.os.Bundle; import android.os.IBinder; import android.os.Message; +import android.util.ArraySet; import android.util.Pair; import android.view.ContentRecordingSession; import android.view.Display; @@ -1020,5 +1021,13 @@ public abstract class WindowManagerInternal { * * @param packageInfos set of {@link PackageInfo} whose windows should be blocked from capture */ - public abstract void setShouldBlockScreenCaptureForApp(@NonNull Set<PackageInfo> packageInfos); + public abstract void addBlockScreenCaptureForApps(@NonNull ArraySet<PackageInfo> packageInfos); + + /** + * Clears 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)} + */ + public abstract void clearBlockedApps(); } diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java index 95448352736f..15413fb472d3 100644 --- a/services/core/java/com/android/server/wm/WindowManagerService.java +++ b/services/core/java/com/android/server/wm/WindowManagerService.java @@ -369,7 +369,6 @@ import java.util.Map; import java.util.NoSuchElementException; import java.util.Objects; import java.util.Optional; -import java.util.Set; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import java.util.function.Function; @@ -8566,10 +8565,23 @@ public class WindowManagerService extends IWindowManager.Stub } @Override - public void setShouldBlockScreenCaptureForApp(Set<PackageInfo> packageInfos) { + public void addBlockScreenCaptureForApps(ArraySet<PackageInfo> packageInfos) { synchronized (mGlobalLock) { - mSensitiveContentPackages.setShouldBlockScreenCaptureForApp(packageInfos); - WindowManagerService.this.refreshScreenCaptureDisabled(); + boolean modified = + mSensitiveContentPackages.addBlockScreenCaptureForApps(packageInfos); + if (modified) { + WindowManagerService.this.refreshScreenCaptureDisabled(); + } + } + } + + @Override + public void clearBlockedApps() { + synchronized (mGlobalLock) { + boolean modified = mSensitiveContentPackages.clearBlockedApps(); + if (modified) { + WindowManagerService.this.refreshScreenCaptureDisabled(); + } } } } diff --git a/services/tests/mockingservicestests/src/com/android/server/SensitiveContentProtectionManagerServiceTest.java b/services/tests/mockingservicestests/src/com/android/server/SensitiveContentProtectionManagerServiceTest.java index b363fd4cc7cb..d78143381ae5 100644 --- a/services/tests/mockingservicestests/src/com/android/server/SensitiveContentProtectionManagerServiceTest.java +++ b/services/tests/mockingservicestests/src/com/android/server/SensitiveContentProtectionManagerServiceTest.java @@ -20,11 +20,13 @@ import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentat import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.doCallRealMethod; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyZeroInteractions; import static org.mockito.Mockito.when; import android.media.projection.MediaProjectionInfo; @@ -35,6 +37,7 @@ import android.service.notification.StatusBarNotification; import android.testing.AndroidTestingRunner; import android.testing.TestableContext; import android.testing.TestableLooper.RunWithLooper; +import android.util.ArraySet; import androidx.test.filters.SmallTest; @@ -52,7 +55,6 @@ import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.MockitoAnnotations; -import java.util.Collections; import java.util.Set; @SmallTest @@ -68,6 +70,8 @@ public class SensitiveContentProtectionManagerServiceTest { private static final int NOTIFICATION_UID_1 = 5; private static final int NOTIFICATION_UID_2 = 6; + private static final ArraySet<PackageInfo> EMPTY_SET = new ArraySet<>(); + @Rule public final TestableContext mContext = new TestableContext(getInstrumentation().getTargetContext(), null); @@ -107,6 +111,9 @@ public class SensitiveContentProtectionManagerServiceTest { mSensitiveContentProtectionManagerService.mNotificationListener = spy(mSensitiveContentProtectionManagerService.mNotificationListener); + doCallRealMethod() + .when(mSensitiveContentProtectionManagerService.mNotificationListener) + .onListenerConnected(); // Setup RankingMap and two possilbe rankings when(mSensitiveRanking.hasSensitiveContent()).thenReturn(true); @@ -128,7 +135,7 @@ public class SensitiveContentProtectionManagerServiceTest { mSensitiveContentProtectionManagerService.onDestroy(); } - private Set<PackageInfo> setupSensitiveNotification() { + private ArraySet<PackageInfo> setupSensitiveNotification() { // Setup Notification Values when(mNotification1.getKey()).thenReturn(NOTIFICATION_KEY_1); when(mNotification1.getPackageName()).thenReturn(NOTIFICATION_PKG_1); @@ -149,10 +156,11 @@ public class SensitiveContentProtectionManagerServiceTest { when(mRankingMap.getRawRankingObject(eq(NOTIFICATION_KEY_2))) .thenReturn(mNonSensitiveRanking); - return Set.of(new PackageInfo(NOTIFICATION_PKG_1, NOTIFICATION_UID_1)); + return new ArraySet<>( + Set.of(new PackageInfo(NOTIFICATION_PKG_1, NOTIFICATION_UID_1))); } - private Set<PackageInfo> setupMultipleSensitiveNotificationsFromSamePackageAndUid() { + private ArraySet<PackageInfo> setupMultipleSensitiveNotificationsFromSamePackageAndUid() { // Setup Notification Values when(mNotification1.getKey()).thenReturn(NOTIFICATION_KEY_1); when(mNotification1.getPackageName()).thenReturn(NOTIFICATION_PKG_1); @@ -173,10 +181,11 @@ public class SensitiveContentProtectionManagerServiceTest { when(mRankingMap.getRawRankingObject(eq(NOTIFICATION_KEY_2))) .thenReturn(mSensitiveRanking); - return Set.of(new PackageInfo(NOTIFICATION_PKG_1, NOTIFICATION_UID_1)); + return new ArraySet<>( + Set.of(new PackageInfo(NOTIFICATION_PKG_1, NOTIFICATION_UID_1))); } - private Set<PackageInfo> setupMultipleSensitiveNotificationsFromDifferentPackage() { + private ArraySet<PackageInfo> setupMultipleSensitiveNotificationsFromDifferentPackage() { // Setup Notification Values when(mNotification1.getKey()).thenReturn(NOTIFICATION_KEY_1); when(mNotification1.getPackageName()).thenReturn(NOTIFICATION_PKG_1); @@ -197,11 +206,12 @@ public class SensitiveContentProtectionManagerServiceTest { when(mRankingMap.getRawRankingObject(eq(NOTIFICATION_KEY_2))) .thenReturn(mSensitiveRanking); - return Set.of(new PackageInfo(NOTIFICATION_PKG_1, NOTIFICATION_UID_1), - new PackageInfo(NOTIFICATION_PKG_2, NOTIFICATION_UID_1)); + return new ArraySet<>( + Set.of(new PackageInfo(NOTIFICATION_PKG_1, NOTIFICATION_UID_1), + new PackageInfo(NOTIFICATION_PKG_2, NOTIFICATION_UID_1))); } - private Set<PackageInfo> setupMultipleSensitiveNotificationsFromDifferentUid() { + private ArraySet<PackageInfo> setupMultipleSensitiveNotificationsFromDifferentUid() { // Setup Notification Values when(mNotification1.getKey()).thenReturn(NOTIFICATION_KEY_1); when(mNotification1.getPackageName()).thenReturn(NOTIFICATION_PKG_1); @@ -222,8 +232,9 @@ public class SensitiveContentProtectionManagerServiceTest { when(mRankingMap.getRawRankingObject(eq(NOTIFICATION_KEY_2))) .thenReturn(mSensitiveRanking); - return Set.of(new PackageInfo(NOTIFICATION_PKG_1, NOTIFICATION_UID_1), - new PackageInfo(NOTIFICATION_PKG_1, NOTIFICATION_UID_2)); + return new ArraySet<>( + Set.of(new PackageInfo(NOTIFICATION_PKG_1, NOTIFICATION_UID_1), + new PackageInfo(NOTIFICATION_PKG_1, NOTIFICATION_UID_2))); } private void setupNoSensitiveNotifications() { @@ -251,11 +262,11 @@ public class SensitiveContentProtectionManagerServiceTest { @Test public void mediaProjectionOnStart_onProjectionStart_setWmBlockedPackages() { - Set<PackageInfo> expectedBlockedPackages = setupSensitiveNotification(); + ArraySet<PackageInfo> expectedBlockedPackages = setupSensitiveNotification(); mMediaProjectionCallbackCaptor.getValue().onStart(mock(MediaProjectionInfo.class)); - verify(mWindowManager).setShouldBlockScreenCaptureForApp(expectedBlockedPackages); + verify(mWindowManager).addBlockScreenCaptureForApps(expectedBlockedPackages); } @Test @@ -264,7 +275,7 @@ public class SensitiveContentProtectionManagerServiceTest { mMediaProjectionCallbackCaptor.getValue().onStart(mock(MediaProjectionInfo.class)); - verify(mWindowManager).setShouldBlockScreenCaptureForApp(Collections.emptySet()); + verify(mWindowManager).addBlockScreenCaptureForApps(EMPTY_SET); } @Test @@ -273,37 +284,37 @@ public class SensitiveContentProtectionManagerServiceTest { mMediaProjectionCallbackCaptor.getValue().onStart(mock(MediaProjectionInfo.class)); - verify(mWindowManager).setShouldBlockScreenCaptureForApp(Collections.emptySet()); + verify(mWindowManager).addBlockScreenCaptureForApps(EMPTY_SET); } @Test public void mediaProjectionOnStart_multipleNotifications_setWmBlockedPackages() { - Set<PackageInfo> expectedBlockedPackages = + ArraySet<PackageInfo> expectedBlockedPackages = setupMultipleSensitiveNotificationsFromSamePackageAndUid(); mMediaProjectionCallbackCaptor.getValue().onStart(mock(MediaProjectionInfo.class)); - verify(mWindowManager).setShouldBlockScreenCaptureForApp(expectedBlockedPackages); + verify(mWindowManager).addBlockScreenCaptureForApps(expectedBlockedPackages); } @Test public void mediaProjectionOnStart_multiplePackages_setWmBlockedPackages() { - Set<PackageInfo> expectedBlockedPackages = + ArraySet<PackageInfo> expectedBlockedPackages = setupMultipleSensitiveNotificationsFromDifferentPackage(); mMediaProjectionCallbackCaptor.getValue().onStart(mock(MediaProjectionInfo.class)); - verify(mWindowManager).setShouldBlockScreenCaptureForApp(expectedBlockedPackages); + verify(mWindowManager).addBlockScreenCaptureForApps(expectedBlockedPackages); } @Test public void mediaProjectionOnStart_multipleUid_setWmBlockedPackages() { - Set<PackageInfo> expectedBlockedPackages = + ArraySet<PackageInfo> expectedBlockedPackages = setupMultipleSensitiveNotificationsFromDifferentUid(); mMediaProjectionCallbackCaptor.getValue().onStart(mock(MediaProjectionInfo.class)); - verify(mWindowManager).setShouldBlockScreenCaptureForApp(expectedBlockedPackages); + verify(mWindowManager).addBlockScreenCaptureForApps(expectedBlockedPackages); } @Test @@ -316,12 +327,12 @@ public class SensitiveContentProtectionManagerServiceTest { mMediaProjectionCallbackCaptor.getValue().onStop(mediaProjectionInfo); - verify(mWindowManager).setShouldBlockScreenCaptureForApp(Collections.emptySet()); + verify(mWindowManager).clearBlockedApps(); } @Test public void mediaProjectionOnStart_afterOnStop_onProjectionStart_setWmBlockedPackages() { - Set<PackageInfo> expectedBlockedPackages = setupSensitiveNotification(); + ArraySet<PackageInfo> expectedBlockedPackages = setupSensitiveNotification(); MediaProjectionInfo mediaProjectionInfo = mock(MediaProjectionInfo.class); mMediaProjectionCallbackCaptor.getValue().onStart(mediaProjectionInfo); @@ -330,7 +341,7 @@ public class SensitiveContentProtectionManagerServiceTest { mMediaProjectionCallbackCaptor.getValue().onStart(mediaProjectionInfo); - verify(mWindowManager).setShouldBlockScreenCaptureForApp(expectedBlockedPackages); + verify(mWindowManager).addBlockScreenCaptureForApps(expectedBlockedPackages); } @Test @@ -341,7 +352,7 @@ public class SensitiveContentProtectionManagerServiceTest { mMediaProjectionCallbackCaptor.getValue().onStart(mock(MediaProjectionInfo.class)); - verify(mWindowManager).setShouldBlockScreenCaptureForApp(Collections.emptySet()); + verify(mWindowManager).addBlockScreenCaptureForApps(EMPTY_SET); } @Test @@ -352,7 +363,7 @@ public class SensitiveContentProtectionManagerServiceTest { mMediaProjectionCallbackCaptor.getValue().onStart(mock(MediaProjectionInfo.class)); - verify(mWindowManager).setShouldBlockScreenCaptureForApp(Collections.emptySet()); + verify(mWindowManager).addBlockScreenCaptureForApps(EMPTY_SET); } @Test @@ -363,7 +374,7 @@ public class SensitiveContentProtectionManagerServiceTest { mMediaProjectionCallbackCaptor.getValue().onStart(mock(MediaProjectionInfo.class)); - verify(mWindowManager).setShouldBlockScreenCaptureForApp(Collections.emptySet()); + verify(mWindowManager).addBlockScreenCaptureForApps(EMPTY_SET); } @Test @@ -376,6 +387,314 @@ public class SensitiveContentProtectionManagerServiceTest { mMediaProjectionCallbackCaptor.getValue().onStart(mock(MediaProjectionInfo.class)); - verify(mWindowManager).setShouldBlockScreenCaptureForApp(Collections.emptySet()); + verify(mWindowManager).addBlockScreenCaptureForApps(EMPTY_SET); + } + + @Test + public void nlsOnListenerConnected_projectionNotStarted_noop() { + // Sets up mNotification1 & mRankingMap to be a sensitive notification, and mNotification2 + // as non-sensitive + setupSensitiveNotification(); + + mSensitiveContentProtectionManagerService.mNotificationListener.onListenerConnected(); + + verifyZeroInteractions(mWindowManager); + } + + @Test + public void nlsOnListenerConnected_projectionStopped_noop() { + // Sets up mNotification1 & mRankingMap to be a sensitive notification, and mNotification2 + // as non-sensitive + setupSensitiveNotification(); + mMediaProjectionCallbackCaptor.getValue().onStart(mock(MediaProjectionInfo.class)); + mMediaProjectionCallbackCaptor.getValue().onStop(mock(MediaProjectionInfo.class)); + Mockito.reset(mWindowManager); + + mSensitiveContentProtectionManagerService.mNotificationListener.onListenerConnected(); + + verifyZeroInteractions(mWindowManager); + } + + @Test + public void nlsOnListenerConnected_projectionStarted_setWmBlockedPackages() { + // Sets up mNotification1 & mRankingMap to be a sensitive notification, and mNotification2 + // as non-sensitive + ArraySet<PackageInfo> expectedBlockedPackages = setupSensitiveNotification(); + mMediaProjectionCallbackCaptor.getValue().onStart(mock(MediaProjectionInfo.class)); + Mockito.reset(mWindowManager); + + mSensitiveContentProtectionManagerService.mNotificationListener.onListenerConnected(); + + verify(mWindowManager).addBlockScreenCaptureForApps(expectedBlockedPackages); + } + + @Test + public void nlsOnListenerConnected_noSensitiveNotifications_noBlockedPackages() { + setupNoSensitiveNotifications(); + mMediaProjectionCallbackCaptor.getValue().onStart(mock(MediaProjectionInfo.class)); + Mockito.reset(mWindowManager); + + mSensitiveContentProtectionManagerService.mNotificationListener.onListenerConnected(); + + verify(mWindowManager).addBlockScreenCaptureForApps(EMPTY_SET); + } + + @Test + public void nlsOnListenerConnected_noNotifications_noBlockedPackages() { + setupNoNotifications(); + mMediaProjectionCallbackCaptor.getValue().onStart(mock(MediaProjectionInfo.class)); + Mockito.reset(mWindowManager); + + mSensitiveContentProtectionManagerService.mNotificationListener.onListenerConnected(); + + verify(mWindowManager).addBlockScreenCaptureForApps(EMPTY_SET); + } + + @Test + public void nlsOnListenerConnected_nullRankingMap_noBlockedPackages() { + // Sets up mNotification1 & mRankingMap to be a sensitive notification, and mNotification2 + // as non-sensitive + setupSensitiveNotification(); + mMediaProjectionCallbackCaptor.getValue().onStart(mock(MediaProjectionInfo.class)); + Mockito.reset(mWindowManager); + doReturn(null) + .when(mSensitiveContentProtectionManagerService.mNotificationListener) + .getCurrentRanking(); + + mSensitiveContentProtectionManagerService.mNotificationListener.onListenerConnected(); + + verify(mWindowManager).addBlockScreenCaptureForApps(EMPTY_SET); + } + + @Test + public void nlsOnListenerConnected_missingRanking_noBlockedPackages() { + // Sets up mNotification1 & mRankingMap to be a sensitive notification, and mNotification2 + // as non-sensitive + setupSensitiveNotification(); + mMediaProjectionCallbackCaptor.getValue().onStart(mock(MediaProjectionInfo.class)); + Mockito.reset(mWindowManager); + when(mRankingMap.getRawRankingObject(eq(NOTIFICATION_KEY_1))).thenReturn(null); + doReturn(mRankingMap) + .when(mSensitiveContentProtectionManagerService.mNotificationListener) + .getCurrentRanking(); + + mSensitiveContentProtectionManagerService.mNotificationListener.onListenerConnected(); + + verify(mWindowManager).addBlockScreenCaptureForApps(EMPTY_SET); + } + + @Test + public void nlsOnNotificationRankingUpdate_projectionNotStarted_noop() { + // Sets up mNotification1 & mRankingMap to be a sensitive notification, and mNotification2 + // as non-sensitive + setupSensitiveNotification(); + + mSensitiveContentProtectionManagerService.mNotificationListener + .onNotificationRankingUpdate(mRankingMap); + + verifyZeroInteractions(mWindowManager); + } + + @Test + public void nlsOnNotificationRankingUpdate_projectionStopped_noop() { + // Sets up mNotification1 & mRankingMap to be a sensitive notification, and mNotification2 + // as non-sensitive + setupSensitiveNotification(); + mMediaProjectionCallbackCaptor.getValue().onStart(mock(MediaProjectionInfo.class)); + mMediaProjectionCallbackCaptor.getValue().onStop(mock(MediaProjectionInfo.class)); + Mockito.reset(mWindowManager); + + mSensitiveContentProtectionManagerService.mNotificationListener + .onNotificationRankingUpdate(mRankingMap); + + verifyZeroInteractions(mWindowManager); + } + + @Test + public void nlsOnNotificationRankingUpdate_projectionStarted_setWmBlockedPackages() { + // Sets up mNotification1 & mRankingMap to be a sensitive notification, and mNotification2 + // as non-sensitive + ArraySet<PackageInfo> expectedBlockedPackages = setupSensitiveNotification(); + mMediaProjectionCallbackCaptor.getValue().onStart(mock(MediaProjectionInfo.class)); + Mockito.reset(mWindowManager); + + mSensitiveContentProtectionManagerService.mNotificationListener + .onNotificationRankingUpdate(mRankingMap); + + verify(mWindowManager).addBlockScreenCaptureForApps(expectedBlockedPackages); + } + + @Test + public void nlsOnNotificationRankingUpdate_noSensitiveNotifications_noBlockedPackages() { + setupNoSensitiveNotifications(); + mMediaProjectionCallbackCaptor.getValue().onStart(mock(MediaProjectionInfo.class)); + Mockito.reset(mWindowManager); + + mSensitiveContentProtectionManagerService.mNotificationListener + .onNotificationRankingUpdate(mRankingMap); + + verify(mWindowManager).addBlockScreenCaptureForApps(EMPTY_SET); + } + + @Test + public void nlsOnNotificationRankingUpdate_noNotifications_noBlockedPackages() { + setupNoNotifications(); + mMediaProjectionCallbackCaptor.getValue().onStart(mock(MediaProjectionInfo.class)); + Mockito.reset(mWindowManager); + + mSensitiveContentProtectionManagerService.mNotificationListener + .onNotificationRankingUpdate(mRankingMap); + + verify(mWindowManager).addBlockScreenCaptureForApps(EMPTY_SET); + } + + @Test + public void nlsOnNotificationRankingUpdate_nullRankingMap_noBlockedPackages() { + // Sets up mNotification1 & mRankingMap to be a sensitive notification, and mNotification2 + // as non-sensitive + setupSensitiveNotification(); + mMediaProjectionCallbackCaptor.getValue().onStart(mock(MediaProjectionInfo.class)); + Mockito.reset(mWindowManager); + + mSensitiveContentProtectionManagerService.mNotificationListener + .onNotificationRankingUpdate(null); + + verify(mWindowManager).addBlockScreenCaptureForApps(EMPTY_SET); + } + + @Test + public void nlsOnNotificationRankingUpdate_missingRanking_noBlockedPackages() { + // Sets up mNotification1 & mRankingMap to be a sensitive notification, and mNotification2 + // as non-sensitive + setupSensitiveNotification(); + mMediaProjectionCallbackCaptor.getValue().onStart(mock(MediaProjectionInfo.class)); + Mockito.reset(mWindowManager); + when(mRankingMap.getRawRankingObject(eq(NOTIFICATION_KEY_1))).thenReturn(null); + doReturn(mRankingMap) + .when(mSensitiveContentProtectionManagerService.mNotificationListener) + .getCurrentRanking(); + + mSensitiveContentProtectionManagerService.mNotificationListener + .onNotificationRankingUpdate(mRankingMap); + + verify(mWindowManager).addBlockScreenCaptureForApps(EMPTY_SET); + } + + @Test + public void nlsOnNotificationRankingUpdate_getActiveNotificationsThrows_noBlockedPackages() { + // Sets up mNotification1 & mRankingMap to be a sensitive notification, and mNotification2 + // as non-sensitive + setupSensitiveNotification(); + mMediaProjectionCallbackCaptor.getValue().onStart(mock(MediaProjectionInfo.class)); + Mockito.reset(mWindowManager); + + doThrow(SecurityException.class) + .when(mSensitiveContentProtectionManagerService.mNotificationListener) + .getActiveNotifications(); + + mSensitiveContentProtectionManagerService.mNotificationListener + .onNotificationRankingUpdate(mRankingMap); + + verify(mWindowManager).addBlockScreenCaptureForApps(EMPTY_SET); + } + + @Test + public void nlsOnNotificationPosted_projectionNotStarted_noop() { + // Sets up mNotification1 & mRankingMap to be a sensitive notification, and mNotification2 + // as non-sensitive + setupSensitiveNotification(); + + mSensitiveContentProtectionManagerService.mNotificationListener + .onNotificationPosted(mNotification1, mRankingMap); + + verifyZeroInteractions(mWindowManager); + } + + @Test + public void nlsOnNotificationPosted_projectionStopped_noop() { + // Sets up mNotification1 & mRankingMap to be a sensitive notification, and mNotification2 + // as non-sensitive + setupSensitiveNotification(); + mMediaProjectionCallbackCaptor.getValue().onStart(mock(MediaProjectionInfo.class)); + mMediaProjectionCallbackCaptor.getValue().onStop(mock(MediaProjectionInfo.class)); + Mockito.reset(mWindowManager); + + mSensitiveContentProtectionManagerService.mNotificationListener + .onNotificationPosted(mNotification1, mRankingMap); + + verifyZeroInteractions(mWindowManager); + } + + @Test + public void nlsOnNotificationPosted_projectionStarted_setWmBlockedPackages() { + // Sets up mNotification1 & mRankingMap to be a sensitive notification, and mNotification2 + // as non-sensitive + setupSensitiveNotification(); + mMediaProjectionCallbackCaptor.getValue().onStart(mock(MediaProjectionInfo.class)); + Mockito.reset(mWindowManager); + + mSensitiveContentProtectionManagerService.mNotificationListener + .onNotificationPosted(mNotification1, mRankingMap); + + ArraySet<PackageInfo> expectedBlockedPackages = new ArraySet<>( + Set.of(new PackageInfo(NOTIFICATION_PKG_1, NOTIFICATION_UID_1))); + verify(mWindowManager).addBlockScreenCaptureForApps(expectedBlockedPackages); + } + + @Test + public void nlsOnNotificationPosted_noSensitiveNotifications_noBlockedPackages() { + // Sets up mNotification1 & mRankingMap to be a sensitive notification, and mNotification2 + // as non-sensitive + setupSensitiveNotification(); + mMediaProjectionCallbackCaptor.getValue().onStart(mock(MediaProjectionInfo.class)); + Mockito.reset(mWindowManager); + + mSensitiveContentProtectionManagerService.mNotificationListener + .onNotificationPosted(mNotification2, mRankingMap); + + verifyZeroInteractions(mWindowManager); + } + + @Test + public void nlsOnNotificationPosted_noNotifications_noBlockedPackages() { + // Sets up mNotification1 & mRankingMap to be a sensitive notification, and mNotification2 + // as non-sensitive + setupSensitiveNotification(); + mMediaProjectionCallbackCaptor.getValue().onStart(mock(MediaProjectionInfo.class)); + Mockito.reset(mWindowManager); + + mSensitiveContentProtectionManagerService.mNotificationListener + .onNotificationPosted(null, mRankingMap); + + verifyZeroInteractions(mWindowManager); + } + + @Test + public void nlsOnNotificationPosted_nullRankingMap_noBlockedPackages() { + // Sets up mNotification1 & mRankingMap to be a sensitive notification, and mNotification2 + // as non-sensitive + setupSensitiveNotification(); + mMediaProjectionCallbackCaptor.getValue().onStart(mock(MediaProjectionInfo.class)); + Mockito.reset(mWindowManager); + + mSensitiveContentProtectionManagerService.mNotificationListener + .onNotificationPosted(mNotification1, null); + + verifyZeroInteractions(mWindowManager); + } + + @Test + public void nlsOnNotificationPosted_missingRanking_noBlockedPackages() { + // Sets up mNotification1 & mRankingMap to be a sensitive notification, and mNotification2 + // as non-sensitive + setupSensitiveNotification(); + mMediaProjectionCallbackCaptor.getValue().onStart(mock(MediaProjectionInfo.class)); + Mockito.reset(mWindowManager); + when(mRankingMap.getRawRankingObject(eq(NOTIFICATION_KEY_1))).thenReturn(null); + + mSensitiveContentProtectionManagerService.mNotificationListener + .onNotificationPosted(mNotification1, mRankingMap); + + verifyZeroInteractions(mWindowManager); } } diff --git a/services/tests/wmtests/src/com/android/server/wm/SensitiveContentPackagesTest.java b/services/tests/wmtests/src/com/android/server/wm/SensitiveContentPackagesTest.java index 71dbc57e5065..298637266cc3 100644 --- a/services/tests/wmtests/src/com/android/server/wm/SensitiveContentPackagesTest.java +++ b/services/tests/wmtests/src/com/android/server/wm/SensitiveContentPackagesTest.java @@ -20,6 +20,7 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import android.platform.test.annotations.Presubmit; +import android.util.ArraySet; import androidx.test.filters.SmallTest; @@ -28,7 +29,6 @@ import com.android.server.wm.SensitiveContentPackages.PackageInfo; import org.junit.After; import org.junit.Test; -import java.util.Collections; import java.util.Set; /** @@ -52,18 +52,21 @@ public class SensitiveContentPackagesTest { @After public void tearDown() { - mSensitiveContentPackages.setShouldBlockScreenCaptureForApp(Collections.emptySet()); + mSensitiveContentPackages.clearBlockedApps(); } @Test - public void setShouldBlockScreenCaptureForApp() { - Set<PackageInfo> blockedApps = + public void addBlockScreenCaptureForApps() { + ArraySet<PackageInfo> blockedApps = new ArraySet( Set.of(new PackageInfo(APP_PKG_1, APP_UID_1), new PackageInfo(APP_PKG_1, APP_UID_2), new PackageInfo(APP_PKG_2, APP_UID_1), - new PackageInfo(APP_PKG_2, APP_UID_2)); + new PackageInfo(APP_PKG_2, APP_UID_2) + )); - mSensitiveContentPackages.setShouldBlockScreenCaptureForApp(blockedApps); + boolean modified = mSensitiveContentPackages.addBlockScreenCaptureForApps(blockedApps); + + assertTrue(modified); assertTrue(mSensitiveContentPackages.shouldBlockScreenCaptureForApp(APP_PKG_1, APP_UID_1)); assertTrue(mSensitiveContentPackages.shouldBlockScreenCaptureForApp(APP_PKG_1, APP_UID_2)); @@ -79,15 +82,93 @@ public class SensitiveContentPackagesTest { } @Test - public void setShouldBlockScreenCaptureForApp_empty() { - Set<PackageInfo> blockedApps = + public void addBlockScreenCaptureForApps_addedTwice() { + ArraySet<PackageInfo> blockedApps = new ArraySet( Set.of(new PackageInfo(APP_PKG_1, APP_UID_1), new PackageInfo(APP_PKG_1, APP_UID_2), new PackageInfo(APP_PKG_2, APP_UID_1), - new PackageInfo(APP_PKG_2, APP_UID_2)); + new PackageInfo(APP_PKG_2, APP_UID_2) + )); + + mSensitiveContentPackages.addBlockScreenCaptureForApps(blockedApps); + boolean modified = mSensitiveContentPackages.addBlockScreenCaptureForApps(blockedApps); + + assertFalse(modified); + + assertTrue(mSensitiveContentPackages.shouldBlockScreenCaptureForApp(APP_PKG_1, APP_UID_1)); + assertTrue(mSensitiveContentPackages.shouldBlockScreenCaptureForApp(APP_PKG_1, APP_UID_2)); + assertFalse(mSensitiveContentPackages.shouldBlockScreenCaptureForApp(APP_PKG_1, APP_UID_3)); + + assertTrue(mSensitiveContentPackages.shouldBlockScreenCaptureForApp(APP_PKG_2, APP_UID_1)); + assertTrue(mSensitiveContentPackages.shouldBlockScreenCaptureForApp(APP_PKG_2, APP_UID_2)); + assertFalse(mSensitiveContentPackages.shouldBlockScreenCaptureForApp(APP_PKG_2, APP_UID_3)); + + assertFalse(mSensitiveContentPackages.shouldBlockScreenCaptureForApp(APP_PKG_3, APP_UID_1)); + assertFalse(mSensitiveContentPackages.shouldBlockScreenCaptureForApp(APP_PKG_3, APP_UID_2)); + assertFalse(mSensitiveContentPackages.shouldBlockScreenCaptureForApp(APP_PKG_3, APP_UID_3)); + } + + @Test + public void addBlockScreenCaptureForApps_withPartialPreviousPackages() { + ArraySet<PackageInfo> blockedApps = new ArraySet( + Set.of(new PackageInfo(APP_PKG_1, APP_UID_1), + new PackageInfo(APP_PKG_1, APP_UID_2), + new PackageInfo(APP_PKG_2, APP_UID_1), + new PackageInfo(APP_PKG_2, APP_UID_2) + )); + + mSensitiveContentPackages.addBlockScreenCaptureForApps(blockedApps); + boolean modified = mSensitiveContentPackages + .addBlockScreenCaptureForApps( + new ArraySet(Set.of(new PackageInfo(APP_PKG_3, APP_UID_1)))); + + assertTrue(modified); + + assertTrue(mSensitiveContentPackages.shouldBlockScreenCaptureForApp(APP_PKG_1, APP_UID_1)); + assertTrue(mSensitiveContentPackages.shouldBlockScreenCaptureForApp(APP_PKG_1, APP_UID_2)); + assertFalse(mSensitiveContentPackages.shouldBlockScreenCaptureForApp(APP_PKG_1, APP_UID_3)); + + assertTrue(mSensitiveContentPackages.shouldBlockScreenCaptureForApp(APP_PKG_2, APP_UID_1)); + assertTrue(mSensitiveContentPackages.shouldBlockScreenCaptureForApp(APP_PKG_2, APP_UID_2)); + assertFalse(mSensitiveContentPackages.shouldBlockScreenCaptureForApp(APP_PKG_2, APP_UID_3)); + + assertTrue(mSensitiveContentPackages.shouldBlockScreenCaptureForApp(APP_PKG_3, APP_UID_1)); + assertFalse(mSensitiveContentPackages.shouldBlockScreenCaptureForApp(APP_PKG_3, APP_UID_2)); + assertFalse(mSensitiveContentPackages.shouldBlockScreenCaptureForApp(APP_PKG_3, APP_UID_3)); + } + + @Test + public void clearBlockedApps() { + ArraySet<PackageInfo> blockedApps = new ArraySet( + Set.of(new PackageInfo(APP_PKG_1, APP_UID_1), + new PackageInfo(APP_PKG_1, APP_UID_2), + new PackageInfo(APP_PKG_2, APP_UID_1), + new PackageInfo(APP_PKG_2, APP_UID_2) + )); + + mSensitiveContentPackages.addBlockScreenCaptureForApps(blockedApps); + boolean modified = mSensitiveContentPackages.clearBlockedApps(); + + assertTrue(modified); + + assertFalse(mSensitiveContentPackages.shouldBlockScreenCaptureForApp(APP_PKG_1, APP_UID_1)); + assertFalse(mSensitiveContentPackages.shouldBlockScreenCaptureForApp(APP_PKG_1, APP_UID_2)); + assertFalse(mSensitiveContentPackages.shouldBlockScreenCaptureForApp(APP_PKG_1, APP_UID_3)); + + assertFalse(mSensitiveContentPackages.shouldBlockScreenCaptureForApp(APP_PKG_2, APP_UID_1)); + assertFalse(mSensitiveContentPackages.shouldBlockScreenCaptureForApp(APP_PKG_2, APP_UID_2)); + assertFalse(mSensitiveContentPackages.shouldBlockScreenCaptureForApp(APP_PKG_2, APP_UID_3)); + + assertFalse(mSensitiveContentPackages.shouldBlockScreenCaptureForApp(APP_PKG_3, APP_UID_1)); + assertFalse(mSensitiveContentPackages.shouldBlockScreenCaptureForApp(APP_PKG_3, APP_UID_2)); + assertFalse(mSensitiveContentPackages.shouldBlockScreenCaptureForApp(APP_PKG_3, APP_UID_3)); + } + + @Test + public void clearBlockedApps_alreadyEmpty() { + boolean modified = mSensitiveContentPackages.clearBlockedApps(); - mSensitiveContentPackages.setShouldBlockScreenCaptureForApp(blockedApps); - mSensitiveContentPackages.setShouldBlockScreenCaptureForApp(Collections.emptySet()); + assertFalse(modified); assertFalse(mSensitiveContentPackages.shouldBlockScreenCaptureForApp(APP_PKG_1, APP_UID_1)); assertFalse(mSensitiveContentPackages.shouldBlockScreenCaptureForApp(APP_PKG_1, APP_UID_2)); diff --git a/services/tests/wmtests/src/com/android/server/wm/WindowManagerServiceTests.java b/services/tests/wmtests/src/com/android/server/wm/WindowManagerServiceTests.java index a1cc8d5d9188..fe9d83776ad9 100644 --- a/services/tests/wmtests/src/com/android/server/wm/WindowManagerServiceTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/WindowManagerServiceTests.java @@ -115,7 +115,6 @@ import org.junit.runner.RunWith; import org.mockito.ArgumentCaptor; import java.util.ArrayList; -import java.util.Collections; /** * Build/Install/Run: @@ -139,7 +138,7 @@ public class WindowManagerServiceTests extends WindowTestsBase { @After public void tearDown() { - mWm.mSensitiveContentPackages.setShouldBlockScreenCaptureForApp(Collections.emptySet()); + mWm.mSensitiveContentPackages.clearBlockedApps(); } @Test @@ -824,7 +823,7 @@ public class WindowManagerServiceTests extends WindowTestsBase { } @Test - public void setShouldBlockScreenCaptureForApp() { + public void addBlockScreenCaptureForApps() { String testPackage = "test"; int ownerId1 = 20; int ownerId2 = 21; @@ -833,7 +832,7 @@ public class WindowManagerServiceTests extends WindowTestsBase { blockedPackages.add(blockedPackage); WindowManagerInternal wmInternal = LocalServices.getService(WindowManagerInternal.class); - wmInternal.setShouldBlockScreenCaptureForApp(blockedPackages); + wmInternal.addBlockScreenCaptureForApps(blockedPackages); assertTrue(mWm.mSensitiveContentPackages .shouldBlockScreenCaptureForApp(testPackage, ownerId1)); @@ -843,7 +842,47 @@ public class WindowManagerServiceTests extends WindowTestsBase { } @Test - public void setShouldBlockScreenCaptureForApp_emptySet_clearsCache() { + public void addBlockScreenCaptureForApps_duplicate_verifyNoRefresh() { + String testPackage = "test"; + int ownerId1 = 20; + int ownerId2 = 21; + PackageInfo blockedPackage = new PackageInfo(testPackage, ownerId1); + ArraySet<PackageInfo> blockedPackages = new ArraySet(); + blockedPackages.add(blockedPackage); + + WindowManagerInternal wmInternal = LocalServices.getService(WindowManagerInternal.class); + wmInternal.addBlockScreenCaptureForApps(blockedPackages); + wmInternal.addBlockScreenCaptureForApps(blockedPackages); + + verify(mWm, times(1)).refreshScreenCaptureDisabled(); + } + + @Test + public void addBlockScreenCaptureForApps_notDuplicate_verifyRefresh() { + String testPackage = "test"; + int ownerId1 = 20; + int ownerId2 = 21; + PackageInfo blockedPackage = new PackageInfo(testPackage, ownerId1); + PackageInfo blockedPackage2 = new PackageInfo(testPackage, ownerId2); + ArraySet<PackageInfo> blockedPackages = new ArraySet(); + blockedPackages.add(blockedPackage); + ArraySet<PackageInfo> blockedPackages2 = new ArraySet(); + blockedPackages2.add(blockedPackage); + blockedPackages2.add(blockedPackage2); + + WindowManagerInternal wmInternal = LocalServices.getService(WindowManagerInternal.class); + wmInternal.addBlockScreenCaptureForApps(blockedPackages); + wmInternal.addBlockScreenCaptureForApps(blockedPackages2); + + assertTrue(mWm.mSensitiveContentPackages + .shouldBlockScreenCaptureForApp(testPackage, ownerId1)); + assertTrue(mWm.mSensitiveContentPackages + .shouldBlockScreenCaptureForApp(testPackage, ownerId2)); + verify(mWm, times(2)).refreshScreenCaptureDisabled(); + } + + @Test + public void clearBlockedApps_clearsCache() { String testPackage = "test"; int ownerId1 = 20; PackageInfo blockedPackage = new PackageInfo(testPackage, ownerId1); @@ -851,8 +890,8 @@ public class WindowManagerServiceTests extends WindowTestsBase { blockedPackages.add(blockedPackage); WindowManagerInternal wmInternal = LocalServices.getService(WindowManagerInternal.class); - wmInternal.setShouldBlockScreenCaptureForApp(blockedPackages); - wmInternal.setShouldBlockScreenCaptureForApp(Collections.emptySet()); + wmInternal.addBlockScreenCaptureForApps(blockedPackages); + wmInternal.clearBlockedApps(); assertFalse(mWm.mSensitiveContentPackages .shouldBlockScreenCaptureForApp(testPackage, ownerId1)); @@ -860,6 +899,14 @@ public class WindowManagerServiceTests extends WindowTestsBase { } @Test + public void clearBlockedApps_alreadyEmpty_verifyNoRefresh() { + WindowManagerInternal wmInternal = LocalServices.getService(WindowManagerInternal.class); + wmInternal.clearBlockedApps(); + + verify(mWm, never()).refreshScreenCaptureDisabled(); + } + + @Test public void testisLetterboxBackgroundMultiColored() { assertThat(setupLetterboxConfigurationWithBackgroundType( LETTERBOX_BACKGROUND_APP_COLOR_BACKGROUND_FLOATING)).isTrue(); diff --git a/services/tests/wmtests/src/com/android/server/wm/WindowStateTests.java b/services/tests/wmtests/src/com/android/server/wm/WindowStateTests.java index fb4edfacb8e3..a0562aa2f710 100644 --- a/services/tests/wmtests/src/com/android/server/wm/WindowStateTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/WindowStateTests.java @@ -136,7 +136,7 @@ public class WindowStateTests extends WindowTestsBase { @After public void tearDown() { - mWm.mSensitiveContentPackages.setShouldBlockScreenCaptureForApp(Collections.emptySet()); + mWm.mSensitiveContentPackages.clearBlockedApps(); } @Test @@ -1398,7 +1398,7 @@ public class WindowStateTests extends WindowTestsBase { PackageInfo blockedPackage = new PackageInfo(testPackage, ownerId1); ArraySet<PackageInfo> blockedPackages = new ArraySet(); blockedPackages.add(blockedPackage); - mWm.mSensitiveContentPackages.setShouldBlockScreenCaptureForApp(blockedPackages); + mWm.mSensitiveContentPackages.addBlockScreenCaptureForApps(blockedPackages); assertTrue(window1.isSecureLocked()); assertFalse(window2.isSecureLocked()); |