diff options
| author | 2024-03-29 14:37:38 -0700 | |
|---|---|---|
| committer | 2024-04-16 13:01:05 -0700 | |
| commit | 8a26738127d83b42da2a3a66a07a65ce45a558fb (patch) | |
| tree | ca3c81692f76e5838e753f6d785568802c79a483 | |
| parent | 553ca7e5c558cd5651e93a570351742682a8dadc (diff) | |
Add SensitiveNotificationAppProtectionSession logs
Bug: 331946904
Test: statsd_testdrive 830
Test: statsd_testdrive 831
Test: atest SensitiveContentProtectionManagerServiceNotificationTest
Flag: android.permission.flags.sensitive_content_improvements
Change-Id: Icf8e1d65d2c0e7cbe99d67d575d64aeb75584814
| -rw-r--r-- | services/core/java/com/android/server/SensitiveContentProtectionManagerService.java | 60 |
1 files changed, 57 insertions, 3 deletions
diff --git a/services/core/java/com/android/server/SensitiveContentProtectionManagerService.java b/services/core/java/com/android/server/SensitiveContentProtectionManagerService.java index 1e7bc397825c..6c7546eca50b 100644 --- a/services/core/java/com/android/server/SensitiveContentProtectionManagerService.java +++ b/services/core/java/com/android/server/SensitiveContentProtectionManagerService.java @@ -16,6 +16,7 @@ package com.android.server; +import static android.permission.flags.Flags.sensitiveContentImprovements; import static android.permission.flags.Flags.sensitiveNotificationAppProtection; import static android.provider.Settings.Global.DISABLE_SCREEN_SHARE_PROTECTIONS_FOR_APPS_AND_NOTIFICATIONS; import static android.view.flags.Flags.sensitiveContentAppProtection; @@ -24,6 +25,7 @@ import static com.android.internal.util.FrameworkStatsLog.SENSITIVE_CONTENT_MEDI import static com.android.internal.util.FrameworkStatsLog.SENSITIVE_CONTENT_MEDIA_PROJECTION_SESSION__SOURCE__FRAMEWORKS; 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 android.annotation.NonNull; import android.annotation.Nullable; @@ -91,9 +93,11 @@ public final class SensitiveContentProtectionManagerService extends SystemServic private boolean mProjectionActive = false; private static class MediaProjectionSession { - final int mUid; - final long mSessionId; - final boolean mIsExempted; + private final int mUid; + private final long mSessionId; + private final boolean mIsExempted; + private final ArraySet<String> mAllSeenNotificationKeys = new ArraySet<>(); + private final ArraySet<String> mSeenOtpNotificationKeys = new ArraySet<>(); MediaProjectionSession(int uid, boolean isExempted, long sessionId) { mUid = uid; @@ -123,6 +127,14 @@ public final class SensitiveContentProtectionManagerService extends SystemServic ); } + public void logAppNotificationsProtected() { + FrameworkStatsLog.write( + SENSITIVE_NOTIFICATION_APP_PROTECTION_SESSION, + mSessionId, + mAllSeenNotificationKeys.size(), + mSeenOtpNotificationKeys.size()); + } + public void logAppBlocked(int uid) { FrameworkStatsLog.write( FrameworkStatsLog.SENSITIVE_CONTENT_APP_PROTECTION, @@ -142,6 +154,32 @@ public final class SensitiveContentProtectionManagerService extends SystemServic FrameworkStatsLog.SENSITIVE_CONTENT_APP_PROTECTION__STATE__UNBLOCKED ); } + + private void addSeenNotificationKey(String key) { + mAllSeenNotificationKeys.add(key); + } + + private void addSeenOtpNotificationKey(String key) { + mAllSeenNotificationKeys.add(key); + mSeenOtpNotificationKeys.add(key); + } + + public void addSeenNotifications( + @NonNull StatusBarNotification[] notifications, + @NonNull RankingMap rankingMap) { + for (StatusBarNotification sbn : notifications) { + if (sbn == null) { + Log.w(TAG, "Unable to parse null notification"); + continue; + } + + if (notificationHasSensitiveContent(sbn, rankingMap)) { + addSeenOtpNotificationKey(sbn.getKey()); + } else { + addSeenNotificationKey(sbn.getKey()); + } + } + } } private final MediaProjectionManager.Callback mProjectionCallback = @@ -297,6 +335,9 @@ public final class SensitiveContentProtectionManagerService extends SystemServic mProjectionActive = false; if (mMediaProjectionSession != null) { mMediaProjectionSession.logProjectionSessionStop(); + if (sensitiveContentImprovements()) { + mMediaProjectionSession.logAppNotificationsProtected(); + } mMediaProjectionSession = null; } @@ -334,9 +375,14 @@ public final class SensitiveContentProtectionManagerService extends SystemServic notifications = new StatusBarNotification[0]; } + if (sensitiveContentImprovements() && mMediaProjectionSession != null) { + mMediaProjectionSession.addSeenNotifications(notifications, rankingMap); + } + // notify windowmanager of any currently posted sensitive content notifications ArraySet<PackageInfo> packageInfos = getSensitivePackagesFromNotifications(notifications, rankingMap); + if (packageInfos.size() > 0) { mWindowManager.addBlockScreenCaptureForApps(packageInfos); } @@ -420,6 +466,14 @@ public final class SensitiveContentProtectionManagerService extends SystemServic mWindowManager.addBlockScreenCaptureForApps( new ArraySet(Set.of(packageInfo))); } + + if (sensitiveContentImprovements() && mMediaProjectionSession != null) { + if (packageInfo != null) { + mMediaProjectionSession.addSeenOtpNotificationKey(sbn.getKey()); + } else { + mMediaProjectionSession.addSeenNotificationKey(sbn.getKey()); + } + } } } finally { Trace.traceEnd(Trace.TRACE_TAG_SYSTEM_SERVER); |