diff options
5 files changed, 27 insertions, 1 deletions
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index 4dfbb6fa2d05..ba97acf547c9 100644 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -9869,6 +9869,14 @@ public final class Settings { "reminder_exp_learning_event_count"; /** + * Whether to show clipboard access notifications. + * + * @hide + */ + public static final String CLIPBOARD_SHOW_ACCESS_NOTIFICATIONS = + "clipboard_show_access_notifications"; + + /** * These entries are considered common between the personal and the managed profile, * since the managed profile doesn't get to change them. */ diff --git a/core/proto/android/providers/settings/secure.proto b/core/proto/android/providers/settings/secure.proto index 632d372bf7ab..dca6002d23f8 100644 --- a/core/proto/android/providers/settings/secure.proto +++ b/core/proto/android/providers/settings/secure.proto @@ -192,6 +192,12 @@ message SecureSettingsProto { optional Camera camera = 12; optional SettingProto carrier_apps_handled = 13 [ (android.privacy).dest = DEST_AUTOMATIC ]; + + message Clipboard { + optional SettingProto show_access_notifications = 1 [ (android.privacy).dest = DEST_AUTOMATIC ]; + } + optional Clipboard clipboard = 89; + optional SettingProto cmas_additional_broadcast_pkg = 14 [ (android.privacy).dest = DEST_AUTOMATIC ]; repeated SettingProto completed_categories = 15; optional SettingProto connectivity_release_pending_intent_delay_ms = 16 [ (android.privacy).dest = DEST_AUTOMATIC ]; @@ -647,5 +653,5 @@ message SecureSettingsProto { // Please insert fields in alphabetical order and group them into messages // if possible (to avoid reaching the method limit). - // Next tag = 89; + // Next tag = 90; } diff --git a/packages/SettingsProvider/src/android/provider/settings/validators/SecureSettingsValidators.java b/packages/SettingsProvider/src/android/provider/settings/validators/SecureSettingsValidators.java index ed2b6c92530b..0a7a22179f78 100644 --- a/packages/SettingsProvider/src/android/provider/settings/validators/SecureSettingsValidators.java +++ b/packages/SettingsProvider/src/android/provider/settings/validators/SecureSettingsValidators.java @@ -280,5 +280,6 @@ public class SecureSettingsValidators { VALIDATORS.put(Secure.ACCESSIBILITY_FLOATING_MENU_OPACITY, new InclusiveFloatRangeValidator(0.0f, 1.0f)); VALIDATORS.put(Secure.ACCESSIBILITY_FLOATING_MENU_FADE_ENABLED, BOOLEAN_VALIDATOR); + VALIDATORS.put(Secure.CLIPBOARD_SHOW_ACCESS_NOTIFICATIONS, BOOLEAN_VALIDATOR); } } diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProtoDumpUtil.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProtoDumpUtil.java index a0b952882162..7288371899ce 100644 --- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProtoDumpUtil.java +++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProtoDumpUtil.java @@ -1990,6 +1990,13 @@ class SettingsProtoDumpUtil { dumpSetting(s, p, Settings.Secure.CARRIER_APPS_HANDLED, SecureSettingsProto.CARRIER_APPS_HANDLED); + + final long clipboardToken = p.start(SecureSettingsProto.CLIPBOARD); + dumpSetting(s, p, + Settings.Secure.CLIPBOARD_SHOW_ACCESS_NOTIFICATIONS, + SecureSettingsProto.Clipboard.SHOW_ACCESS_NOTIFICATIONS); + p.end(clipboardToken); + dumpSetting(s, p, Settings.Secure.CMAS_ADDITIONAL_BROADCAST_PKG, SecureSettingsProto.CMAS_ADDITIONAL_BROADCAST_PKG); diff --git a/services/core/java/com/android/server/clipboard/ClipboardService.java b/services/core/java/com/android/server/clipboard/ClipboardService.java index e0d1375b4069..6d6edbb60613 100644 --- a/services/core/java/com/android/server/clipboard/ClipboardService.java +++ b/services/core/java/com/android/server/clipboard/ClipboardService.java @@ -922,6 +922,10 @@ public class ClipboardService extends SystemService { if (!mShowAccessNotifications) { return; } + if (Settings.Secure.getInt(getContext().getContentResolver(), + Settings.Secure.CLIPBOARD_SHOW_ACCESS_NOTIFICATIONS, 1) == 0) { + return; + } // Don't notify if the app accessing the clipboard is the same as the current owner. if (UserHandle.isSameApp(uid, clipboard.primaryClipUid)) { return; |