diff --git a/res/values/strings.xml b/res/values/strings.xml index dc2c416419e..9762f83f0d7 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -11979,6 +11979,11 @@ Allow this device to run Mock Modem service for instrumentation testing. Do not enable this during normal usage of the phone + + Disable screen share protections + + Disables system applied app and notifications protections during screen sharing + Media diff --git a/res/xml/development_settings.xml b/res/xml/development_settings.xml index fb5e2809434..c0b6560b9a4 100644 --- a/res/xml/development_settings.xml +++ b/res/xml/development_settings.xml @@ -705,6 +705,11 @@ android:title="@string/show_notification_channel_warnings" android:summary="@string/show_notification_channel_warnings_summary" /> + + (controller.getPreferenceKey())) + .thenReturn(preference) + controller.displayPreference(screen) + } + + @Test + fun onPreferenceChange_settingEnabled_shouldDisableSensitiveContentProtection() { + controller.onPreferenceChange(preference, true /* new value */) + val mode = Settings.Global.getInt( + context.contentResolver, + DISABLE_SCREEN_SHARE_PROTECTIONS_FOR_APPS_AND_NOTIFICATIONS, + -1 /* default */ + ) + + assertEquals(mode, SETTING_VALUE_ON) + } + + @Test + fun onPreferenceChange_settingDisabled_shouldEnableSensitiveContentProtection() { + controller.onPreferenceChange(preference, false /* new value */) + val mode = Settings.Global.getInt( + context.contentResolver, + DISABLE_SCREEN_SHARE_PROTECTIONS_FOR_APPS_AND_NOTIFICATIONS, + -1 /* default */ + ) + + assertEquals(mode, SETTING_VALUE_OFF) + } + + @Test + fun updateState_settingEnabled_preferenceShouldBeChecked() { + Settings.Global.putInt( + context.contentResolver, + DISABLE_SCREEN_SHARE_PROTECTIONS_FOR_APPS_AND_NOTIFICATIONS, + SETTING_VALUE_ON + ) + controller.updateState(preference) + + verify(preference).isChecked = true + } + + @Test + fun updateState_settingDisabled_preferenceShouldNotBeChecked() { + Settings.Global.putInt( + context.contentResolver, + DISABLE_SCREEN_SHARE_PROTECTIONS_FOR_APPS_AND_NOTIFICATIONS, + SETTING_VALUE_OFF + ) + controller.updateState(preference) + + verify(preference).isChecked = false + } + + @Test + fun onDeveloperOptionsSwitchDisabled_preferenceShouldBeDisabled() { + controller.onDeveloperOptionsSwitchDisabled() + val mode = Settings.Global.getInt( + context.contentResolver, + DISABLE_SCREEN_SHARE_PROTECTIONS_FOR_APPS_AND_NOTIFICATIONS, + -1 /* default */ + ) + + assertEquals(mode, SETTING_VALUE_OFF) + verify(preference).isChecked = false + verify(preference).isEnabled = false + } + + @Test + @RequiresFlagsDisabled( + FLAG_SENSITIVE_NOTIFICATION_APP_PROTECTION, + FLAG_SCREENSHARE_NOTIFICATION_HIDING) + fun isAvailable_flagsDisabled_returnFalse() { + assertFalse(controller.isAvailable) + } + + @Test + @RequiresFlagsEnabled(FLAG_SENSITIVE_NOTIFICATION_APP_PROTECTION) + fun isAvailable_sensitiveNotificationAppProtectionEnabled_returnTrue() { + assertTrue(controller.isAvailable) + } + + @Test + @RequiresFlagsEnabled(FLAG_SCREENSHARE_NOTIFICATION_HIDING) + fun isAvailable_screenshareNotificationHidingEnabled_returnTrue() { + assertTrue(controller.isAvailable) + } +} \ No newline at end of file