Loading services/core/java/com/android/server/SensitiveContentProtectionManagerService.java +11 −0 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ import static com.android.internal.util.FrameworkStatsLog.SENSITIVE_CONTENT_MEDI import static com.android.internal.util.FrameworkStatsLog.SENSITIVE_CONTENT_MEDIA_PROJECTION_SESSION__STATE__START; import static com.android.internal.util.FrameworkStatsLog.SENSITIVE_CONTENT_MEDIA_PROJECTION_SESSION__STATE__STOP; import static com.android.internal.util.FrameworkStatsLog.SENSITIVE_NOTIFICATION_APP_PROTECTION_SESSION; import static com.android.server.wm.WindowManagerInternal.OnWindowRemovedListener; import android.annotation.NonNull; import android.annotation.Nullable; Loading Loading @@ -210,6 +211,12 @@ public final class SensitiveContentProtectionManagerService extends SystemServic } }; private final OnWindowRemovedListener mOnWindowRemovedListener = token -> { synchronized (mSensitiveContentProtectionLock) { mPackagesShowingSensitiveContent.removeIf(pkgInfo -> pkgInfo.getWindowToken() == token); } }; public SensitiveContentProtectionManagerService(@NonNull Context context) { super(context); if (sensitiveNotificationAppProtection()) { Loading Loading @@ -265,6 +272,10 @@ public final class SensitiveContentProtectionManagerService extends SystemServic // Intra-process call, should never happen. } } if (sensitiveContentAppProtection()) { mWindowManager.registerOnWindowRemovedListener(mOnWindowRemovedListener); } } /** Cleanup any callbacks and listeners */ Loading services/core/java/com/android/server/wm/WindowManagerInternal.java +26 −0 Original line number Diff line number Diff line Loading @@ -305,6 +305,18 @@ public abstract class WindowManagerInternal { boolean wereRevealedFromSwipeOnSystemBar); } /** * An interface to be notified on window removal. */ public interface OnWindowRemovedListener { /** * Called when a window is removed. * * @param token the client token */ void onWindowRemoved(IBinder token); } /** * An interface to be notified when keyguard exit animation should start. */ Loading Loading @@ -1075,6 +1087,20 @@ public abstract class WindowManagerInternal { */ public abstract void clearBlockedApps(); /** * Register a listener to receive a callback on window removal. * * @param listener the listener to be registered. */ public abstract void registerOnWindowRemovedListener(OnWindowRemovedListener listener); /** * Removes the listener. * * @param listener the listener to be removed. */ public abstract void unregisterOnWindowRemovedListener(OnWindowRemovedListener listener); /** * Moves the current focus to the adjacent activity if it has the latest created window. */ Loading services/core/java/com/android/server/wm/WindowManagerService.java +41 −1 Original line number Diff line number Diff line Loading @@ -53,6 +53,7 @@ import static android.service.dreams.Flags.dreamHandlesConfirmKeys; import static android.view.ContentRecordingSession.RECORD_CONTENT_TASK; import static android.view.Display.DEFAULT_DISPLAY; import static android.view.Display.INVALID_DISPLAY; import static android.view.flags.Flags.sensitiveContentAppProtection; import static android.view.WindowManager.DISPLAY_IME_POLICY_FALLBACK_DISPLAY; import static android.view.WindowManager.DISPLAY_IME_POLICY_LOCAL; import static android.view.WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW; Loading Loading @@ -147,6 +148,7 @@ import static com.android.server.wm.WindowManagerDebugConfig.SHOW_STACK_CRAWLS; import static com.android.server.wm.WindowManagerDebugConfig.SHOW_VERBOSE_TRANSACTIONS; import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME; import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM; import static com.android.server.wm.WindowManagerInternal.OnWindowRemovedListener; import static com.android.server.wm.WindowManagerServiceDumpProto.BACK_NAVIGATION; import static com.android.server.wm.WindowManagerServiceDumpProto.DISPLAY_FROZEN; import static com.android.server.wm.WindowManagerServiceDumpProto.FOCUSED_APP; Loading Loading @@ -489,6 +491,9 @@ public class WindowManagerService extends IWindowManager.Stub private final RemoteCallbackList<IKeyguardLockedStateListener> mKeyguardLockedStateListeners = new RemoteCallbackList<>(); private final List<OnWindowRemovedListener> mOnWindowRemovedListeners = new ArrayList<>(); private boolean mDispatchedKeyguardLockedState = false; // VR Vr2d Display Id. Loading Loading @@ -2073,7 +2078,11 @@ public class WindowManagerService extends IWindowManager.Stub */ void postWindowRemoveCleanupLocked(WindowState win) { ProtoLog.v(WM_DEBUG_ADD_REMOVE, "postWindowRemoveCleanupLocked: %s", win); mWindowMap.remove(win.mClient.asBinder()); final IBinder client = win.mClient.asBinder(); mWindowMap.remove(client); if (sensitiveContentAppProtection()) { notifyWindowRemovedListeners(client); } final DisplayContent dc = win.getDisplayContent(); dc.getDisplayRotation().markForSeamlessRotation(win, false /* seamlesslyRotated */); Loading Loading @@ -5335,6 +5344,23 @@ public class WindowManagerService extends IWindowManager.Stub } } private void notifyWindowRemovedListeners(IBinder client) { OnWindowRemovedListener[] windowRemovedListeners; synchronized (mGlobalLock) { if (mOnWindowRemovedListeners.isEmpty()) { return; } windowRemovedListeners = new OnWindowRemovedListener[mOnWindowRemovedListeners.size()]; mOnWindowRemovedListeners.toArray(windowRemovedListeners); } mH.post(() -> { int size = windowRemovedListeners.length; for (int i = 0; i < size; i++) { windowRemovedListeners[i].onWindowRemoved(client); } }); } private void notifyWindowsChanged() { WindowChangeListener[] windowChangeListeners; synchronized (mGlobalLock) { Loading Loading @@ -8867,6 +8893,20 @@ public class WindowManagerService extends IWindowManager.Stub } } @Override public void registerOnWindowRemovedListener(OnWindowRemovedListener listener) { synchronized (mGlobalLock) { mOnWindowRemovedListeners.add(listener); } } @Override public void unregisterOnWindowRemovedListener(OnWindowRemovedListener listener) { synchronized (mGlobalLock) { mOnWindowRemovedListeners.remove(listener); } } @Override public boolean moveFocusToAdjacentEmbeddedActivityIfNeeded() { synchronized (mGlobalLock) { Loading services/tests/mockingservicestests/src/com/android/server/SensitiveContentProtectionManagerServiceContentTest.java +4 −6 Original line number Diff line number Diff line Loading @@ -26,7 +26,6 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.atLeast; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyZeroInteractions; import android.content.pm.PackageManagerInternal; import android.media.projection.MediaProjectionInfo; Loading Loading @@ -108,7 +107,7 @@ public class SensitiveContentProtectionManagerServiceContentTest { mMediaPorjectionCallback.onStart(exemptedRecorderPackage); mSensitiveContentProtectionManagerService.setSensitiveContentProtection( mPackageInfo.getWindowToken(), mPackageInfo.getPkg(), mPackageInfo.getUid(), true); verifyZeroInteractions(mWindowManager); verify(mWindowManager, never()).addBlockScreenCaptureForApps(mPackageInfoCaptor.capture()); } @Test Loading @@ -135,7 +134,7 @@ public class SensitiveContentProtectionManagerServiceContentTest { // when screen sharing is not active, no app window should be blocked. mSensitiveContentProtectionManagerService.setSensitiveContentProtection( mPackageInfo.getWindowToken(), mPackageInfo.getPkg(), mPackageInfo.getUid(), true); verifyZeroInteractions(mWindowManager); verify(mWindowManager, never()).addBlockScreenCaptureForApps(mPackageInfoCaptor.capture()); } @Test Loading @@ -158,8 +157,7 @@ public class SensitiveContentProtectionManagerServiceContentTest { mMediaPorjectionCallback.onStart(mMediaProjectionInfo); mSensitiveContentProtectionManagerService.setSensitiveContentProtection( mPackageInfo.getWindowToken(), mPackageInfo.getPkg(), mPackageInfo.getUid(), true); verify(mWindowManager, never()) .addBlockScreenCaptureForApps(mPackageInfoCaptor.capture()); verify(mWindowManager, never()).addBlockScreenCaptureForApps(mPackageInfoCaptor.capture()); } @Test Loading @@ -168,7 +166,7 @@ public class SensitiveContentProtectionManagerServiceContentTest { mMediaProjectionCallbackCaptor.getValue().onStart(mMediaProjectionInfo); mSensitiveContentProtectionManagerService.setSensitiveContentProtection( mPackageInfo.getWindowToken(), mPackageInfo.getPkg(), mPackageInfo.getUid(), true); verifyZeroInteractions(mWindowManager); verify(mWindowManager, never()).addBlockScreenCaptureForApps(mPackageInfoCaptor.capture()); } private void mockDisabledViaDeveloperOption() { Loading services/tests/mockingservicestests/src/com/android/server/SensitiveContentProtectionManagerServiceNotificationTest.java +34 −26 Original line number Diff line number Diff line Loading @@ -30,7 +30,6 @@ import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.never; 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.content.pm.PackageManagerInternal; Loading Loading @@ -102,6 +101,8 @@ public class SensitiveContentProtectionManagerServiceNotificationTest { @Captor ArgumentCaptor<MediaProjectionManager.Callback> mMediaProjectionCallbackCaptor; @Captor private ArgumentCaptor<ArraySet<PackageInfo>> mPackageInfoCaptor; @Mock private MediaProjectionManager mProjectionManager; Loading Loading @@ -309,7 +310,7 @@ public class SensitiveContentProtectionManagerServiceNotificationTest { mMediaProjectionCallbackCaptor.getValue().onStart(mediaProjectionInfo); verifyZeroInteractions(mWindowManager); verify(mWindowManager, never()).addBlockScreenCaptureForApps(mPackageInfoCaptor.capture()); } @Test Loading Loading @@ -469,7 +470,7 @@ public class SensitiveContentProtectionManagerServiceNotificationTest { mMediaProjectionCallbackCaptor.getValue().onStart(createMediaProjectionInfo()); verifyZeroInteractions(mWindowManager); verify(mWindowManager, never()).addBlockScreenCaptureForApps(mPackageInfoCaptor.capture()); } @Test Loading @@ -480,7 +481,7 @@ public class SensitiveContentProtectionManagerServiceNotificationTest { mSensitiveContentProtectionManagerService.mNotificationListener.onListenerConnected(); verifyZeroInteractions(mWindowManager); verify(mWindowManager, never()).addBlockScreenCaptureForApps(mPackageInfoCaptor.capture()); } @Test Loading @@ -495,7 +496,7 @@ public class SensitiveContentProtectionManagerServiceNotificationTest { mSensitiveContentProtectionManagerService.mNotificationListener.onListenerConnected(); verifyZeroInteractions(mWindowManager); verify(mWindowManager, never()).addBlockScreenCaptureForApps(mPackageInfoCaptor.capture()); } @Test Loading @@ -519,7 +520,7 @@ public class SensitiveContentProtectionManagerServiceNotificationTest { mSensitiveContentProtectionManagerService.mNotificationListener.onListenerConnected(); verifyZeroInteractions(mWindowManager); verify(mWindowManager, never()).addBlockScreenCaptureForApps(mPackageInfoCaptor.capture()); } @Test Loading @@ -530,7 +531,7 @@ public class SensitiveContentProtectionManagerServiceNotificationTest { mSensitiveContentProtectionManagerService.mNotificationListener.onListenerConnected(); verifyZeroInteractions(mWindowManager); verify(mWindowManager, never()).addBlockScreenCaptureForApps(mPackageInfoCaptor.capture()); } @Test Loading @@ -541,7 +542,7 @@ public class SensitiveContentProtectionManagerServiceNotificationTest { mSensitiveContentProtectionManagerService.mNotificationListener.onListenerConnected(); verifyZeroInteractions(mWindowManager); verify(mWindowManager, never()).addBlockScreenCaptureForApps(mPackageInfoCaptor.capture()); } @Test Loading @@ -557,7 +558,7 @@ public class SensitiveContentProtectionManagerServiceNotificationTest { mSensitiveContentProtectionManagerService.mNotificationListener.onListenerConnected(); verifyZeroInteractions(mWindowManager); verify(mWindowManager, never()).addBlockScreenCaptureForApps(mPackageInfoCaptor.capture()); } @Test Loading @@ -574,7 +575,7 @@ public class SensitiveContentProtectionManagerServiceNotificationTest { mSensitiveContentProtectionManagerService.mNotificationListener.onListenerConnected(); verifyZeroInteractions(mWindowManager); verify(mWindowManager, never()).addBlockScreenCaptureForApps(mPackageInfoCaptor.capture()); } @Test Loading @@ -586,7 +587,7 @@ public class SensitiveContentProtectionManagerServiceNotificationTest { mMediaProjectionCallbackCaptor.getValue().onStart(createMediaProjectionInfo()); mSensitiveContentProtectionManagerService.mNotificationListener.onListenerConnected(); verifyZeroInteractions(mWindowManager); verify(mWindowManager, never()).addBlockScreenCaptureForApps(mPackageInfoCaptor.capture()); } @Test Loading @@ -598,7 +599,7 @@ public class SensitiveContentProtectionManagerServiceNotificationTest { mSensitiveContentProtectionManagerService.mNotificationListener .onNotificationRankingUpdate(mRankingMap); verifyZeroInteractions(mWindowManager); verifyNoBlockOrClearInteractionWithWindowManager(); } @Test Loading @@ -614,7 +615,7 @@ public class SensitiveContentProtectionManagerServiceNotificationTest { mSensitiveContentProtectionManagerService.mNotificationListener .onNotificationRankingUpdate(mRankingMap); verifyZeroInteractions(mWindowManager); verifyNoBlockOrClearInteractionWithWindowManager(); } @Test Loading @@ -640,7 +641,7 @@ public class SensitiveContentProtectionManagerServiceNotificationTest { mSensitiveContentProtectionManagerService.mNotificationListener .onNotificationRankingUpdate(mRankingMap); verifyZeroInteractions(mWindowManager); verify(mWindowManager, never()).addBlockScreenCaptureForApps(mPackageInfoCaptor.capture()); } @Test Loading @@ -652,7 +653,7 @@ public class SensitiveContentProtectionManagerServiceNotificationTest { mSensitiveContentProtectionManagerService.mNotificationListener .onNotificationRankingUpdate(mRankingMap); verifyZeroInteractions(mWindowManager); verify(mWindowManager, never()).addBlockScreenCaptureForApps(mPackageInfoCaptor.capture()); } @Test Loading @@ -666,7 +667,7 @@ public class SensitiveContentProtectionManagerServiceNotificationTest { mSensitiveContentProtectionManagerService.mNotificationListener .onNotificationRankingUpdate(null); verifyZeroInteractions(mWindowManager); verify(mWindowManager, never()).addBlockScreenCaptureForApps(mPackageInfoCaptor.capture()); } @Test Loading @@ -684,7 +685,7 @@ public class SensitiveContentProtectionManagerServiceNotificationTest { mSensitiveContentProtectionManagerService.mNotificationListener .onNotificationRankingUpdate(mRankingMap); verifyZeroInteractions(mWindowManager); verify(mWindowManager, never()).addBlockScreenCaptureForApps(mPackageInfoCaptor.capture()); } @Test Loading @@ -702,7 +703,7 @@ public class SensitiveContentProtectionManagerServiceNotificationTest { mSensitiveContentProtectionManagerService.mNotificationListener .onNotificationRankingUpdate(mRankingMap); verifyZeroInteractions(mWindowManager); verify(mWindowManager, never()).addBlockScreenCaptureForApps(mPackageInfoCaptor.capture()); } @Test Loading @@ -715,7 +716,7 @@ public class SensitiveContentProtectionManagerServiceNotificationTest { mSensitiveContentProtectionManagerService.mNotificationListener .onNotificationRankingUpdate(mRankingMap); verifyZeroInteractions(mWindowManager); verify(mWindowManager, never()).addBlockScreenCaptureForApps(mPackageInfoCaptor.capture()); } @Test Loading @@ -727,7 +728,7 @@ public class SensitiveContentProtectionManagerServiceNotificationTest { mSensitiveContentProtectionManagerService.mNotificationListener .onNotificationPosted(mNotification1, mRankingMap); verifyZeroInteractions(mWindowManager); verifyNoBlockOrClearInteractionWithWindowManager(); } @Test Loading @@ -743,7 +744,7 @@ public class SensitiveContentProtectionManagerServiceNotificationTest { mSensitiveContentProtectionManagerService.mNotificationListener .onNotificationPosted(mNotification1, mRankingMap); verifyZeroInteractions(mWindowManager); verifyNoBlockOrClearInteractionWithWindowManager(); } @Test Loading Loading @@ -773,7 +774,7 @@ public class SensitiveContentProtectionManagerServiceNotificationTest { mSensitiveContentProtectionManagerService.mNotificationListener .onNotificationPosted(mNotification2, mRankingMap); verifyZeroInteractions(mWindowManager); verify(mWindowManager, never()).addBlockScreenCaptureForApps(mPackageInfoCaptor.capture()); } @Test Loading @@ -787,7 +788,7 @@ public class SensitiveContentProtectionManagerServiceNotificationTest { mSensitiveContentProtectionManagerService.mNotificationListener .onNotificationPosted(null, mRankingMap); verifyZeroInteractions(mWindowManager); verify(mWindowManager, never()).addBlockScreenCaptureForApps(mPackageInfoCaptor.capture()); } @Test Loading @@ -801,7 +802,7 @@ public class SensitiveContentProtectionManagerServiceNotificationTest { mSensitiveContentProtectionManagerService.mNotificationListener .onNotificationPosted(mNotification1, null); verifyZeroInteractions(mWindowManager); verify(mWindowManager, never()).addBlockScreenCaptureForApps(mPackageInfoCaptor.capture()); } @Test Loading @@ -816,7 +817,7 @@ public class SensitiveContentProtectionManagerServiceNotificationTest { mSensitiveContentProtectionManagerService.mNotificationListener .onNotificationPosted(mNotification1, mRankingMap); verifyZeroInteractions(mWindowManager); verify(mWindowManager, never()).addBlockScreenCaptureForApps(mPackageInfoCaptor.capture()); } @Test Loading @@ -829,7 +830,14 @@ public class SensitiveContentProtectionManagerServiceNotificationTest { mSensitiveContentProtectionManagerService.mNotificationListener .onNotificationPosted(mNotification1, mRankingMap); verifyZeroInteractions(mWindowManager); verify(mWindowManager, never()).addBlockScreenCaptureForApps(mPackageInfoCaptor.capture()); } private void verifyNoBlockOrClearInteractionWithWindowManager() { verify(mWindowManager, never()).addBlockScreenCaptureForApps(mPackageInfoCaptor.capture()); verify(mWindowManager, never()).clearBlockedApps(); verify(mWindowManager, never()) .removeBlockScreenCaptureForApps(mPackageInfoCaptor.capture()); } private void mockDisabledViaDevelopOption() { Loading Loading
services/core/java/com/android/server/SensitiveContentProtectionManagerService.java +11 −0 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ import static com.android.internal.util.FrameworkStatsLog.SENSITIVE_CONTENT_MEDI import static com.android.internal.util.FrameworkStatsLog.SENSITIVE_CONTENT_MEDIA_PROJECTION_SESSION__STATE__START; import static com.android.internal.util.FrameworkStatsLog.SENSITIVE_CONTENT_MEDIA_PROJECTION_SESSION__STATE__STOP; import static com.android.internal.util.FrameworkStatsLog.SENSITIVE_NOTIFICATION_APP_PROTECTION_SESSION; import static com.android.server.wm.WindowManagerInternal.OnWindowRemovedListener; import android.annotation.NonNull; import android.annotation.Nullable; Loading Loading @@ -210,6 +211,12 @@ public final class SensitiveContentProtectionManagerService extends SystemServic } }; private final OnWindowRemovedListener mOnWindowRemovedListener = token -> { synchronized (mSensitiveContentProtectionLock) { mPackagesShowingSensitiveContent.removeIf(pkgInfo -> pkgInfo.getWindowToken() == token); } }; public SensitiveContentProtectionManagerService(@NonNull Context context) { super(context); if (sensitiveNotificationAppProtection()) { Loading Loading @@ -265,6 +272,10 @@ public final class SensitiveContentProtectionManagerService extends SystemServic // Intra-process call, should never happen. } } if (sensitiveContentAppProtection()) { mWindowManager.registerOnWindowRemovedListener(mOnWindowRemovedListener); } } /** Cleanup any callbacks and listeners */ Loading
services/core/java/com/android/server/wm/WindowManagerInternal.java +26 −0 Original line number Diff line number Diff line Loading @@ -305,6 +305,18 @@ public abstract class WindowManagerInternal { boolean wereRevealedFromSwipeOnSystemBar); } /** * An interface to be notified on window removal. */ public interface OnWindowRemovedListener { /** * Called when a window is removed. * * @param token the client token */ void onWindowRemoved(IBinder token); } /** * An interface to be notified when keyguard exit animation should start. */ Loading Loading @@ -1075,6 +1087,20 @@ public abstract class WindowManagerInternal { */ public abstract void clearBlockedApps(); /** * Register a listener to receive a callback on window removal. * * @param listener the listener to be registered. */ public abstract void registerOnWindowRemovedListener(OnWindowRemovedListener listener); /** * Removes the listener. * * @param listener the listener to be removed. */ public abstract void unregisterOnWindowRemovedListener(OnWindowRemovedListener listener); /** * Moves the current focus to the adjacent activity if it has the latest created window. */ Loading
services/core/java/com/android/server/wm/WindowManagerService.java +41 −1 Original line number Diff line number Diff line Loading @@ -53,6 +53,7 @@ import static android.service.dreams.Flags.dreamHandlesConfirmKeys; import static android.view.ContentRecordingSession.RECORD_CONTENT_TASK; import static android.view.Display.DEFAULT_DISPLAY; import static android.view.Display.INVALID_DISPLAY; import static android.view.flags.Flags.sensitiveContentAppProtection; import static android.view.WindowManager.DISPLAY_IME_POLICY_FALLBACK_DISPLAY; import static android.view.WindowManager.DISPLAY_IME_POLICY_LOCAL; import static android.view.WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW; Loading Loading @@ -147,6 +148,7 @@ import static com.android.server.wm.WindowManagerDebugConfig.SHOW_STACK_CRAWLS; import static com.android.server.wm.WindowManagerDebugConfig.SHOW_VERBOSE_TRANSACTIONS; import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME; import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM; import static com.android.server.wm.WindowManagerInternal.OnWindowRemovedListener; import static com.android.server.wm.WindowManagerServiceDumpProto.BACK_NAVIGATION; import static com.android.server.wm.WindowManagerServiceDumpProto.DISPLAY_FROZEN; import static com.android.server.wm.WindowManagerServiceDumpProto.FOCUSED_APP; Loading Loading @@ -489,6 +491,9 @@ public class WindowManagerService extends IWindowManager.Stub private final RemoteCallbackList<IKeyguardLockedStateListener> mKeyguardLockedStateListeners = new RemoteCallbackList<>(); private final List<OnWindowRemovedListener> mOnWindowRemovedListeners = new ArrayList<>(); private boolean mDispatchedKeyguardLockedState = false; // VR Vr2d Display Id. Loading Loading @@ -2073,7 +2078,11 @@ public class WindowManagerService extends IWindowManager.Stub */ void postWindowRemoveCleanupLocked(WindowState win) { ProtoLog.v(WM_DEBUG_ADD_REMOVE, "postWindowRemoveCleanupLocked: %s", win); mWindowMap.remove(win.mClient.asBinder()); final IBinder client = win.mClient.asBinder(); mWindowMap.remove(client); if (sensitiveContentAppProtection()) { notifyWindowRemovedListeners(client); } final DisplayContent dc = win.getDisplayContent(); dc.getDisplayRotation().markForSeamlessRotation(win, false /* seamlesslyRotated */); Loading Loading @@ -5335,6 +5344,23 @@ public class WindowManagerService extends IWindowManager.Stub } } private void notifyWindowRemovedListeners(IBinder client) { OnWindowRemovedListener[] windowRemovedListeners; synchronized (mGlobalLock) { if (mOnWindowRemovedListeners.isEmpty()) { return; } windowRemovedListeners = new OnWindowRemovedListener[mOnWindowRemovedListeners.size()]; mOnWindowRemovedListeners.toArray(windowRemovedListeners); } mH.post(() -> { int size = windowRemovedListeners.length; for (int i = 0; i < size; i++) { windowRemovedListeners[i].onWindowRemoved(client); } }); } private void notifyWindowsChanged() { WindowChangeListener[] windowChangeListeners; synchronized (mGlobalLock) { Loading Loading @@ -8867,6 +8893,20 @@ public class WindowManagerService extends IWindowManager.Stub } } @Override public void registerOnWindowRemovedListener(OnWindowRemovedListener listener) { synchronized (mGlobalLock) { mOnWindowRemovedListeners.add(listener); } } @Override public void unregisterOnWindowRemovedListener(OnWindowRemovedListener listener) { synchronized (mGlobalLock) { mOnWindowRemovedListeners.remove(listener); } } @Override public boolean moveFocusToAdjacentEmbeddedActivityIfNeeded() { synchronized (mGlobalLock) { Loading
services/tests/mockingservicestests/src/com/android/server/SensitiveContentProtectionManagerServiceContentTest.java +4 −6 Original line number Diff line number Diff line Loading @@ -26,7 +26,6 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.atLeast; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyZeroInteractions; import android.content.pm.PackageManagerInternal; import android.media.projection.MediaProjectionInfo; Loading Loading @@ -108,7 +107,7 @@ public class SensitiveContentProtectionManagerServiceContentTest { mMediaPorjectionCallback.onStart(exemptedRecorderPackage); mSensitiveContentProtectionManagerService.setSensitiveContentProtection( mPackageInfo.getWindowToken(), mPackageInfo.getPkg(), mPackageInfo.getUid(), true); verifyZeroInteractions(mWindowManager); verify(mWindowManager, never()).addBlockScreenCaptureForApps(mPackageInfoCaptor.capture()); } @Test Loading @@ -135,7 +134,7 @@ public class SensitiveContentProtectionManagerServiceContentTest { // when screen sharing is not active, no app window should be blocked. mSensitiveContentProtectionManagerService.setSensitiveContentProtection( mPackageInfo.getWindowToken(), mPackageInfo.getPkg(), mPackageInfo.getUid(), true); verifyZeroInteractions(mWindowManager); verify(mWindowManager, never()).addBlockScreenCaptureForApps(mPackageInfoCaptor.capture()); } @Test Loading @@ -158,8 +157,7 @@ public class SensitiveContentProtectionManagerServiceContentTest { mMediaPorjectionCallback.onStart(mMediaProjectionInfo); mSensitiveContentProtectionManagerService.setSensitiveContentProtection( mPackageInfo.getWindowToken(), mPackageInfo.getPkg(), mPackageInfo.getUid(), true); verify(mWindowManager, never()) .addBlockScreenCaptureForApps(mPackageInfoCaptor.capture()); verify(mWindowManager, never()).addBlockScreenCaptureForApps(mPackageInfoCaptor.capture()); } @Test Loading @@ -168,7 +166,7 @@ public class SensitiveContentProtectionManagerServiceContentTest { mMediaProjectionCallbackCaptor.getValue().onStart(mMediaProjectionInfo); mSensitiveContentProtectionManagerService.setSensitiveContentProtection( mPackageInfo.getWindowToken(), mPackageInfo.getPkg(), mPackageInfo.getUid(), true); verifyZeroInteractions(mWindowManager); verify(mWindowManager, never()).addBlockScreenCaptureForApps(mPackageInfoCaptor.capture()); } private void mockDisabledViaDeveloperOption() { Loading
services/tests/mockingservicestests/src/com/android/server/SensitiveContentProtectionManagerServiceNotificationTest.java +34 −26 Original line number Diff line number Diff line Loading @@ -30,7 +30,6 @@ import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.never; 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.content.pm.PackageManagerInternal; Loading Loading @@ -102,6 +101,8 @@ public class SensitiveContentProtectionManagerServiceNotificationTest { @Captor ArgumentCaptor<MediaProjectionManager.Callback> mMediaProjectionCallbackCaptor; @Captor private ArgumentCaptor<ArraySet<PackageInfo>> mPackageInfoCaptor; @Mock private MediaProjectionManager mProjectionManager; Loading Loading @@ -309,7 +310,7 @@ public class SensitiveContentProtectionManagerServiceNotificationTest { mMediaProjectionCallbackCaptor.getValue().onStart(mediaProjectionInfo); verifyZeroInteractions(mWindowManager); verify(mWindowManager, never()).addBlockScreenCaptureForApps(mPackageInfoCaptor.capture()); } @Test Loading Loading @@ -469,7 +470,7 @@ public class SensitiveContentProtectionManagerServiceNotificationTest { mMediaProjectionCallbackCaptor.getValue().onStart(createMediaProjectionInfo()); verifyZeroInteractions(mWindowManager); verify(mWindowManager, never()).addBlockScreenCaptureForApps(mPackageInfoCaptor.capture()); } @Test Loading @@ -480,7 +481,7 @@ public class SensitiveContentProtectionManagerServiceNotificationTest { mSensitiveContentProtectionManagerService.mNotificationListener.onListenerConnected(); verifyZeroInteractions(mWindowManager); verify(mWindowManager, never()).addBlockScreenCaptureForApps(mPackageInfoCaptor.capture()); } @Test Loading @@ -495,7 +496,7 @@ public class SensitiveContentProtectionManagerServiceNotificationTest { mSensitiveContentProtectionManagerService.mNotificationListener.onListenerConnected(); verifyZeroInteractions(mWindowManager); verify(mWindowManager, never()).addBlockScreenCaptureForApps(mPackageInfoCaptor.capture()); } @Test Loading @@ -519,7 +520,7 @@ public class SensitiveContentProtectionManagerServiceNotificationTest { mSensitiveContentProtectionManagerService.mNotificationListener.onListenerConnected(); verifyZeroInteractions(mWindowManager); verify(mWindowManager, never()).addBlockScreenCaptureForApps(mPackageInfoCaptor.capture()); } @Test Loading @@ -530,7 +531,7 @@ public class SensitiveContentProtectionManagerServiceNotificationTest { mSensitiveContentProtectionManagerService.mNotificationListener.onListenerConnected(); verifyZeroInteractions(mWindowManager); verify(mWindowManager, never()).addBlockScreenCaptureForApps(mPackageInfoCaptor.capture()); } @Test Loading @@ -541,7 +542,7 @@ public class SensitiveContentProtectionManagerServiceNotificationTest { mSensitiveContentProtectionManagerService.mNotificationListener.onListenerConnected(); verifyZeroInteractions(mWindowManager); verify(mWindowManager, never()).addBlockScreenCaptureForApps(mPackageInfoCaptor.capture()); } @Test Loading @@ -557,7 +558,7 @@ public class SensitiveContentProtectionManagerServiceNotificationTest { mSensitiveContentProtectionManagerService.mNotificationListener.onListenerConnected(); verifyZeroInteractions(mWindowManager); verify(mWindowManager, never()).addBlockScreenCaptureForApps(mPackageInfoCaptor.capture()); } @Test Loading @@ -574,7 +575,7 @@ public class SensitiveContentProtectionManagerServiceNotificationTest { mSensitiveContentProtectionManagerService.mNotificationListener.onListenerConnected(); verifyZeroInteractions(mWindowManager); verify(mWindowManager, never()).addBlockScreenCaptureForApps(mPackageInfoCaptor.capture()); } @Test Loading @@ -586,7 +587,7 @@ public class SensitiveContentProtectionManagerServiceNotificationTest { mMediaProjectionCallbackCaptor.getValue().onStart(createMediaProjectionInfo()); mSensitiveContentProtectionManagerService.mNotificationListener.onListenerConnected(); verifyZeroInteractions(mWindowManager); verify(mWindowManager, never()).addBlockScreenCaptureForApps(mPackageInfoCaptor.capture()); } @Test Loading @@ -598,7 +599,7 @@ public class SensitiveContentProtectionManagerServiceNotificationTest { mSensitiveContentProtectionManagerService.mNotificationListener .onNotificationRankingUpdate(mRankingMap); verifyZeroInteractions(mWindowManager); verifyNoBlockOrClearInteractionWithWindowManager(); } @Test Loading @@ -614,7 +615,7 @@ public class SensitiveContentProtectionManagerServiceNotificationTest { mSensitiveContentProtectionManagerService.mNotificationListener .onNotificationRankingUpdate(mRankingMap); verifyZeroInteractions(mWindowManager); verifyNoBlockOrClearInteractionWithWindowManager(); } @Test Loading @@ -640,7 +641,7 @@ public class SensitiveContentProtectionManagerServiceNotificationTest { mSensitiveContentProtectionManagerService.mNotificationListener .onNotificationRankingUpdate(mRankingMap); verifyZeroInteractions(mWindowManager); verify(mWindowManager, never()).addBlockScreenCaptureForApps(mPackageInfoCaptor.capture()); } @Test Loading @@ -652,7 +653,7 @@ public class SensitiveContentProtectionManagerServiceNotificationTest { mSensitiveContentProtectionManagerService.mNotificationListener .onNotificationRankingUpdate(mRankingMap); verifyZeroInteractions(mWindowManager); verify(mWindowManager, never()).addBlockScreenCaptureForApps(mPackageInfoCaptor.capture()); } @Test Loading @@ -666,7 +667,7 @@ public class SensitiveContentProtectionManagerServiceNotificationTest { mSensitiveContentProtectionManagerService.mNotificationListener .onNotificationRankingUpdate(null); verifyZeroInteractions(mWindowManager); verify(mWindowManager, never()).addBlockScreenCaptureForApps(mPackageInfoCaptor.capture()); } @Test Loading @@ -684,7 +685,7 @@ public class SensitiveContentProtectionManagerServiceNotificationTest { mSensitiveContentProtectionManagerService.mNotificationListener .onNotificationRankingUpdate(mRankingMap); verifyZeroInteractions(mWindowManager); verify(mWindowManager, never()).addBlockScreenCaptureForApps(mPackageInfoCaptor.capture()); } @Test Loading @@ -702,7 +703,7 @@ public class SensitiveContentProtectionManagerServiceNotificationTest { mSensitiveContentProtectionManagerService.mNotificationListener .onNotificationRankingUpdate(mRankingMap); verifyZeroInteractions(mWindowManager); verify(mWindowManager, never()).addBlockScreenCaptureForApps(mPackageInfoCaptor.capture()); } @Test Loading @@ -715,7 +716,7 @@ public class SensitiveContentProtectionManagerServiceNotificationTest { mSensitiveContentProtectionManagerService.mNotificationListener .onNotificationRankingUpdate(mRankingMap); verifyZeroInteractions(mWindowManager); verify(mWindowManager, never()).addBlockScreenCaptureForApps(mPackageInfoCaptor.capture()); } @Test Loading @@ -727,7 +728,7 @@ public class SensitiveContentProtectionManagerServiceNotificationTest { mSensitiveContentProtectionManagerService.mNotificationListener .onNotificationPosted(mNotification1, mRankingMap); verifyZeroInteractions(mWindowManager); verifyNoBlockOrClearInteractionWithWindowManager(); } @Test Loading @@ -743,7 +744,7 @@ public class SensitiveContentProtectionManagerServiceNotificationTest { mSensitiveContentProtectionManagerService.mNotificationListener .onNotificationPosted(mNotification1, mRankingMap); verifyZeroInteractions(mWindowManager); verifyNoBlockOrClearInteractionWithWindowManager(); } @Test Loading Loading @@ -773,7 +774,7 @@ public class SensitiveContentProtectionManagerServiceNotificationTest { mSensitiveContentProtectionManagerService.mNotificationListener .onNotificationPosted(mNotification2, mRankingMap); verifyZeroInteractions(mWindowManager); verify(mWindowManager, never()).addBlockScreenCaptureForApps(mPackageInfoCaptor.capture()); } @Test Loading @@ -787,7 +788,7 @@ public class SensitiveContentProtectionManagerServiceNotificationTest { mSensitiveContentProtectionManagerService.mNotificationListener .onNotificationPosted(null, mRankingMap); verifyZeroInteractions(mWindowManager); verify(mWindowManager, never()).addBlockScreenCaptureForApps(mPackageInfoCaptor.capture()); } @Test Loading @@ -801,7 +802,7 @@ public class SensitiveContentProtectionManagerServiceNotificationTest { mSensitiveContentProtectionManagerService.mNotificationListener .onNotificationPosted(mNotification1, null); verifyZeroInteractions(mWindowManager); verify(mWindowManager, never()).addBlockScreenCaptureForApps(mPackageInfoCaptor.capture()); } @Test Loading @@ -816,7 +817,7 @@ public class SensitiveContentProtectionManagerServiceNotificationTest { mSensitiveContentProtectionManagerService.mNotificationListener .onNotificationPosted(mNotification1, mRankingMap); verifyZeroInteractions(mWindowManager); verify(mWindowManager, never()).addBlockScreenCaptureForApps(mPackageInfoCaptor.capture()); } @Test Loading @@ -829,7 +830,14 @@ public class SensitiveContentProtectionManagerServiceNotificationTest { mSensitiveContentProtectionManagerService.mNotificationListener .onNotificationPosted(mNotification1, mRankingMap); verifyZeroInteractions(mWindowManager); verify(mWindowManager, never()).addBlockScreenCaptureForApps(mPackageInfoCaptor.capture()); } private void verifyNoBlockOrClearInteractionWithWindowManager() { verify(mWindowManager, never()).addBlockScreenCaptureForApps(mPackageInfoCaptor.capture()); verify(mWindowManager, never()).clearBlockedApps(); verify(mWindowManager, never()) .removeBlockScreenCaptureForApps(mPackageInfoCaptor.capture()); } private void mockDisabledViaDevelopOption() { Loading