Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit dfeb99ae authored by Oli Lan's avatar Oli Lan
Browse files

Add a setting to control whether clipboard access notifications are shown.

This adds a setting to turn on/off the toast notifications shown when
an app accesses clipboard.

Bug: 182349993
Test: atest SettingsProviderTest
Change-Id: I6922ed5a74fae17602a2ac20a199a7d6c03014b9
parent bc80405a
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -9868,6 +9868,14 @@ public final class Settings {
        public static final String ASSIST_HANDLES_LEARNING_EVENT_COUNT =
                "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.
+7 −1
Original line number Diff line number Diff line
@@ -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;
}
+1 −0
Original line number Diff line number Diff line
@@ -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);
    }
}
+7 −0
Original line number Diff line number Diff line
@@ -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);
+4 −0
Original line number Diff line number Diff line
@@ -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;