Loading services/core/java/com/android/server/SensitiveContentProtectionManagerService.java +27 −15 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.server; import static android.provider.Settings.Global.DISABLE_SCREEN_SHARE_PROTECTIONS_FOR_APPS_AND_NOTIFICATIONS; import static com.android.internal.util.Preconditions.checkNotNull; import static com.android.server.notification.Flags.sensitiveNotificationAppProtection; import android.annotation.NonNull; import android.annotation.Nullable; Loading Loading @@ -50,8 +51,12 @@ import java.util.Set; public final class SensitiveContentProtectionManagerService extends SystemService { private static final String TAG = "SensitiveContentProtect"; private static final boolean DEBUG = false; private static final boolean sNotificationProtectionEnabled = sensitiveNotificationAppProtection(); @VisibleForTesting NotificationListener mNotificationListener; @VisibleForTesting @Nullable NotificationListener mNotificationListener; private @Nullable MediaProjectionManager mProjectionManager; private @Nullable WindowManagerInternal mWindowManager; Loading Loading @@ -88,8 +93,10 @@ public final class SensitiveContentProtectionManagerService extends SystemServic public SensitiveContentProtectionManagerService(@NonNull Context context) { super(context); if (sNotificationProtectionEnabled) { mNotificationListener = new NotificationListener(); } } @Override public void onStart() {} Loading Loading @@ -120,6 +127,7 @@ public final class SensitiveContentProtectionManagerService extends SystemServic // handler, delegate, and binder death recipient mProjectionManager.addCallback(mProjectionCallback, getContext().getMainThreadHandler()); if (sNotificationProtectionEnabled) { try { mNotificationListener.registerAsSystemService( getContext(), Loading @@ -129,6 +137,7 @@ public final class SensitiveContentProtectionManagerService extends SystemServic // Intra-process call, should never happen. } } } /** Cleanup any callbacks and listeners */ @VisibleForTesting Loading @@ -136,12 +145,13 @@ public final class SensitiveContentProtectionManagerService extends SystemServic if (mProjectionManager != null) { mProjectionManager.removeCallback(mProjectionCallback); } if (sNotificationProtectionEnabled) { try { mNotificationListener.unregisterAsSystemService(); } catch (RemoteException e) { // Intra-process call, should never happen. } } if (mWindowManager != null) { onProjectionEnd(); Loading @@ -160,9 +170,11 @@ public final class SensitiveContentProtectionManagerService extends SystemServic synchronized (mSensitiveContentProtectionLock) { mProjectionActive = true; if (sNotificationProtectionEnabled) { updateAppsThatShouldBlockScreenCapture(); } } } private void onProjectionEnd() { synchronized (mSensitiveContentProtectionLock) { Loading services/java/com/android/server/SystemServer.java +2 −1 Original line number Diff line number Diff line Loading @@ -3014,7 +3014,8 @@ public final class SystemServer implements Dumpable { t.traceEnd(); } if (com.android.server.notification.Flags.sensitiveNotificationAppProtection()) { if (com.android.server.notification.Flags.sensitiveNotificationAppProtection() || android.view.flags.Flags.sensitiveContentAppProtection()) { t.traceBegin("StartSensitiveContentProtectionManager"); mSystemServiceManager.startService(SensitiveContentProtectionManagerService.class); t.traceEnd(); Loading services/tests/mockingservicestests/src/com/android/server/SensitiveContentProtectionManagerServiceTest.java +9 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,8 @@ package com.android.server; import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static com.android.server.notification.Flags.FLAG_SENSITIVE_NOTIFICATION_APP_PROTECTION; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doCallRealMethod; Loading @@ -31,6 +33,9 @@ import static org.mockito.Mockito.when; import android.media.projection.MediaProjectionInfo; import android.media.projection.MediaProjectionManager; import android.platform.test.annotations.RequiresFlagsEnabled; import android.platform.test.flag.junit.CheckFlagsRule; import android.platform.test.flag.junit.DeviceFlagsValueProvider; import android.provider.Settings; import android.service.notification.NotificationListenerService.Ranking; import android.service.notification.NotificationListenerService.RankingMap; Loading Loading @@ -61,6 +66,7 @@ import java.util.Set; @SmallTest @RunWith(AndroidTestingRunner.class) @RunWithLooper @RequiresFlagsEnabled(FLAG_SENSITIVE_NOTIFICATION_APP_PROTECTION) public class SensitiveContentProtectionManagerServiceTest { private static final String NOTIFICATION_KEY_1 = "com.android.server.notification.TEST_KEY_1"; private static final String NOTIFICATION_KEY_2 = "com.android.server.notification.TEST_KEY_2"; Loading @@ -73,6 +79,9 @@ public class SensitiveContentProtectionManagerServiceTest { private static final ArraySet<PackageInfo> EMPTY_SET = new ArraySet<>(); @Rule public final CheckFlagsRule mCheckFlagsRule = DeviceFlagsValueProvider.createCheckFlagsRule(); @Rule public final TestableContext mContext = new TestableContext(getInstrumentation().getTargetContext(), null); Loading Loading
services/core/java/com/android/server/SensitiveContentProtectionManagerService.java +27 −15 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.server; import static android.provider.Settings.Global.DISABLE_SCREEN_SHARE_PROTECTIONS_FOR_APPS_AND_NOTIFICATIONS; import static com.android.internal.util.Preconditions.checkNotNull; import static com.android.server.notification.Flags.sensitiveNotificationAppProtection; import android.annotation.NonNull; import android.annotation.Nullable; Loading Loading @@ -50,8 +51,12 @@ import java.util.Set; public final class SensitiveContentProtectionManagerService extends SystemService { private static final String TAG = "SensitiveContentProtect"; private static final boolean DEBUG = false; private static final boolean sNotificationProtectionEnabled = sensitiveNotificationAppProtection(); @VisibleForTesting NotificationListener mNotificationListener; @VisibleForTesting @Nullable NotificationListener mNotificationListener; private @Nullable MediaProjectionManager mProjectionManager; private @Nullable WindowManagerInternal mWindowManager; Loading Loading @@ -88,8 +93,10 @@ public final class SensitiveContentProtectionManagerService extends SystemServic public SensitiveContentProtectionManagerService(@NonNull Context context) { super(context); if (sNotificationProtectionEnabled) { mNotificationListener = new NotificationListener(); } } @Override public void onStart() {} Loading Loading @@ -120,6 +127,7 @@ public final class SensitiveContentProtectionManagerService extends SystemServic // handler, delegate, and binder death recipient mProjectionManager.addCallback(mProjectionCallback, getContext().getMainThreadHandler()); if (sNotificationProtectionEnabled) { try { mNotificationListener.registerAsSystemService( getContext(), Loading @@ -129,6 +137,7 @@ public final class SensitiveContentProtectionManagerService extends SystemServic // Intra-process call, should never happen. } } } /** Cleanup any callbacks and listeners */ @VisibleForTesting Loading @@ -136,12 +145,13 @@ public final class SensitiveContentProtectionManagerService extends SystemServic if (mProjectionManager != null) { mProjectionManager.removeCallback(mProjectionCallback); } if (sNotificationProtectionEnabled) { try { mNotificationListener.unregisterAsSystemService(); } catch (RemoteException e) { // Intra-process call, should never happen. } } if (mWindowManager != null) { onProjectionEnd(); Loading @@ -160,9 +170,11 @@ public final class SensitiveContentProtectionManagerService extends SystemServic synchronized (mSensitiveContentProtectionLock) { mProjectionActive = true; if (sNotificationProtectionEnabled) { updateAppsThatShouldBlockScreenCapture(); } } } private void onProjectionEnd() { synchronized (mSensitiveContentProtectionLock) { Loading
services/java/com/android/server/SystemServer.java +2 −1 Original line number Diff line number Diff line Loading @@ -3014,7 +3014,8 @@ public final class SystemServer implements Dumpable { t.traceEnd(); } if (com.android.server.notification.Flags.sensitiveNotificationAppProtection()) { if (com.android.server.notification.Flags.sensitiveNotificationAppProtection() || android.view.flags.Flags.sensitiveContentAppProtection()) { t.traceBegin("StartSensitiveContentProtectionManager"); mSystemServiceManager.startService(SensitiveContentProtectionManagerService.class); t.traceEnd(); Loading
services/tests/mockingservicestests/src/com/android/server/SensitiveContentProtectionManagerServiceTest.java +9 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,8 @@ package com.android.server; import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; import static com.android.server.notification.Flags.FLAG_SENSITIVE_NOTIFICATION_APP_PROTECTION; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doCallRealMethod; Loading @@ -31,6 +33,9 @@ import static org.mockito.Mockito.when; import android.media.projection.MediaProjectionInfo; import android.media.projection.MediaProjectionManager; import android.platform.test.annotations.RequiresFlagsEnabled; import android.platform.test.flag.junit.CheckFlagsRule; import android.platform.test.flag.junit.DeviceFlagsValueProvider; import android.provider.Settings; import android.service.notification.NotificationListenerService.Ranking; import android.service.notification.NotificationListenerService.RankingMap; Loading Loading @@ -61,6 +66,7 @@ import java.util.Set; @SmallTest @RunWith(AndroidTestingRunner.class) @RunWithLooper @RequiresFlagsEnabled(FLAG_SENSITIVE_NOTIFICATION_APP_PROTECTION) public class SensitiveContentProtectionManagerServiceTest { private static final String NOTIFICATION_KEY_1 = "com.android.server.notification.TEST_KEY_1"; private static final String NOTIFICATION_KEY_2 = "com.android.server.notification.TEST_KEY_2"; Loading @@ -73,6 +79,9 @@ public class SensitiveContentProtectionManagerServiceTest { private static final ArraySet<PackageInfo> EMPTY_SET = new ArraySet<>(); @Rule public final CheckFlagsRule mCheckFlagsRule = DeviceFlagsValueProvider.createCheckFlagsRule(); @Rule public final TestableContext mContext = new TestableContext(getInstrumentation().getTargetContext(), null); Loading