From 655b3e166675fcb74a12b2f52a37c4e79149fc44 Mon Sep 17 00:00:00 2001 From: Holden Warriner Date: Mon, 30 Sep 2024 16:13:27 -0400 Subject: [PATCH] Add back SB A11y impls for Android on SB 14/15 (#4167) Add back SB A11y impls for Android on SB 14/15 b/370027229 --- cobalt/media/base/drm_system.h | 2 +- starboard/android/shared/BUILD.gn | 9 +++++++-- .../shared/accessibility_get_caption_settings.cc | 15 +++++++++++++-- .../shared/accessibility_get_display_settings.cc | 15 +++++++++++++-- .../accessibility_get_text_to_speech_settings.cc | 15 +++++++++++++-- .../shared/accessibility_set_captions_enabled.cc | 13 +++++++++++-- starboard/android/shared/application_android.cc | 13 ++++++++++++- starboard/android/shared/system_get_extensions.cc | 4 ++++ .../shared/starboard/accessibility_internal.h | 6 +++++- 9 files changed, 79 insertions(+), 13 deletions(-) diff --git a/cobalt/media/base/drm_system.h b/cobalt/media/base/drm_system.h index db49a8fffd28..c4801c54eb03 100644 --- a/cobalt/media/base/drm_system.h +++ b/cobalt/media/base/drm_system.h @@ -254,7 +254,7 @@ class DrmSystem : public base::RefCounted { TicketToSessionUpdateMap ticket_to_session_update_map_; MediaMetricsProvider media_metrics_provider_; - + DISALLOW_COPY_AND_ASSIGN(DrmSystem); }; diff --git a/starboard/android/shared/BUILD.gn b/starboard/android/shared/BUILD.gn index 468371ae6a5a..0eead1b5ccb8 100644 --- a/starboard/android/shared/BUILD.gn +++ b/starboard/android/shared/BUILD.gn @@ -272,8 +272,6 @@ static_library("starboard_platform") { "//starboard/shared/stub/window_set_on_screen_keyboard_keep_focus.cc", "//starboard/shared/stub/window_show_on_screen_keyboard.cc", "//starboard/shared/stub/window_update_on_screen_keyboard_suggestions.cc", - "accessibility_extension.cc", - "accessibility_extension.h", "accessibility_get_caption_settings.cc", "accessibility_get_display_settings.cc", "accessibility_get_text_to_speech_settings.cc", @@ -435,6 +433,13 @@ static_library("starboard_platform") { "window_internal.h", ] + if (sb_api_version >= 16) { + sources += [ + "accessibility_extension.cc", + "accessibility_extension.h", + ] + } + sources += game_activity_source_files sources += common_player_sources diff --git a/starboard/android/shared/accessibility_get_caption_settings.cc b/starboard/android/shared/accessibility_get_caption_settings.cc index 3057366d1ae5..96768f0a9ae8 100644 --- a/starboard/android/shared/accessibility_get_caption_settings.cc +++ b/starboard/android/shared/accessibility_get_caption_settings.cc @@ -16,6 +16,11 @@ #include #include +#if SB_API_VERSION < 16 +#include "starboard/accessibility.h" +#else // SB_API_VERSION < 16 +#include "starboard/android/shared/accessibility_extension.h" +#endif // SB_API_VERSION < 16 #include "starboard/android/shared/jni_env_ext.h" #include "starboard/android/shared/jni_utils.h" #include "starboard/common/log.h" @@ -23,8 +28,6 @@ #include "starboard/configuration.h" #include "starboard/shared/starboard/accessibility_internal.h" -#include "starboard/android/shared/accessibility_extension.h" - namespace starboard { namespace android { namespace shared { @@ -168,3 +171,11 @@ bool GetCaptionSettings(SbAccessibilityCaptionSettings* caption_settings) { } // namespace shared } // namespace android } // namespace starboard + +#if SB_API_VERSION < 16 +bool SbAccessibilityGetCaptionSettings( + SbAccessibilityCaptionSettings* caption_settings) { + return starboard::android::shared::accessibility::GetCaptionSettings( + caption_settings); +} +#endif // SB_API_VERSION < 16 diff --git a/starboard/android/shared/accessibility_get_display_settings.cc b/starboard/android/shared/accessibility_get_display_settings.cc index 057e02c6061d..37612da1fba7 100644 --- a/starboard/android/shared/accessibility_get_display_settings.cc +++ b/starboard/android/shared/accessibility_get_display_settings.cc @@ -12,11 +12,14 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if SB_API_VERSION < 16 +#include "starboard/accessibility.h" +#else // SB_API_VERSION < 16 +#include "starboard/android/shared/accessibility_extension.h" +#endif // SB_API_VERSION < 16 #include "starboard/android/shared/jni_env_ext.h" #include "starboard/common/memory.h" -#include "starboard/android/shared/accessibility_extension.h" - namespace starboard { namespace android { namespace shared { @@ -44,3 +47,11 @@ bool GetDisplaySettings(SbAccessibilityDisplaySettings* out_setting) { } // namespace shared } // namespace android } // namespace starboard + +#if SB_API_VERSION < 16 +bool SbAccessibilityGetDisplaySettings( + SbAccessibilityDisplaySettings* out_setting) { + return starboard::android::shared::accessibility::GetDisplaySettings( + out_setting); +} +#endif // SB_API_VERSION < 16 diff --git a/starboard/android/shared/accessibility_get_text_to_speech_settings.cc b/starboard/android/shared/accessibility_get_text_to_speech_settings.cc index a9b01482d5dd..86ccff77bc63 100644 --- a/starboard/android/shared/accessibility_get_text_to_speech_settings.cc +++ b/starboard/android/shared/accessibility_get_text_to_speech_settings.cc @@ -12,12 +12,15 @@ // See the License for the specific language governing permissions and // limitations under the License. +#if SB_API_VERSION < 16 +#include "starboard/accessibility.h" +#else // SB_API_VERSION < 16 +#include "starboard/android/shared/accessibility_extension.h" +#endif // SB_API_VERSION < 16 #include "starboard/android/shared/jni_env_ext.h" #include "starboard/android/shared/jni_utils.h" #include "starboard/common/memory.h" -#include "starboard/android/shared/accessibility_extension.h" - namespace starboard { namespace android { namespace shared { @@ -50,3 +53,11 @@ bool GetTextToSpeechSettings(SbAccessibilityTextToSpeechSettings* out_setting) { } // namespace shared } // namespace android } // namespace starboard + +#if SB_API_VERSION < 16 +bool SbAccessibilityGetTextToSpeechSettings( + SbAccessibilityTextToSpeechSettings* out_setting) { + return starboard::android::shared::accessibility::GetTextToSpeechSettings( + out_setting); +} +#endif // SB_API_VERSION < 16 diff --git a/starboard/android/shared/accessibility_set_captions_enabled.cc b/starboard/android/shared/accessibility_set_captions_enabled.cc index 2e94ef5c7c48..6eb6e4ca8c4a 100644 --- a/starboard/android/shared/accessibility_set_captions_enabled.cc +++ b/starboard/android/shared/accessibility_set_captions_enabled.cc @@ -12,9 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "starboard/configuration.h" - +#if SB_API_VERSION < 16 +#include "starboard/accessibility.h" +#else // SB_API_VERSION < 16 #include "starboard/android/shared/accessibility_extension.h" +#endif // SB_API_VERSION < 16 +#include "starboard/configuration.h" namespace starboard { namespace android { @@ -29,3 +32,9 @@ bool SetCaptionsEnabled(bool enabled) { } // namespace shared } // namespace android } // namespace starboard + +#if SB_API_VERSION < 16 +bool SbAccessibilitySetCaptionsEnabled(bool enabled) { + return starboard::android::shared::accessibility::SetCaptionsEnabled(enabled); +} +#endif // SB_API_VERSION < 16 diff --git a/starboard/android/shared/application_android.cc b/starboard/android/shared/application_android.cc index 820b339d6f45..ac981527e865 100644 --- a/starboard/android/shared/application_android.cc +++ b/starboard/android/shared/application_android.cc @@ -23,7 +23,11 @@ #include #include -#include "starboard/extension/accessibility.h" +#if SB_API_VERSION < 16 +#include "starboard/accessibility.h" +#else // SB_API_VERSION < 16 +#include "starboard/android/shared/accessibility_extension.h" +#endif // SB_API_VERSION < 16 #include "starboard/android/shared/file_internal.h" #include "starboard/android/shared/input_events_generator.h" @@ -349,13 +353,20 @@ void ApplicationAndroid::ProcessAndroidCommand() { // We assume that it can only change when our focus changes // (because the user exits and enters the app) so we check // for changes here. +#if SB_API_VERSION >= 16 auto accessibility_api = static_cast( SbSystemGetExtension(kStarboardExtensionAccessibilityName)); SB_CHECK(accessibility_api); // We expect this to be always present + +#endif // SB_API_VERSION >= 16 SbAccessibilityDisplaySettings settings; memset(&settings, 0, sizeof(settings)); +#if SB_API_VERSION >= 16 if (!accessibility_api->GetDisplaySettings(&settings)) { +#else // SB_API_VERSION >= 16 + if (!SbAccessibilityGetDisplaySettings(&settings)) { +#endif // SB_API_VERSION >= 16 break; } diff --git a/starboard/android/shared/system_get_extensions.cc b/starboard/android/shared/system_get_extensions.cc index beb84c1df9e6..dfcba96fcc09 100644 --- a/starboard/android/shared/system_get_extensions.cc +++ b/starboard/android/shared/system_get_extensions.cc @@ -14,7 +14,9 @@ #include "starboard/system.h" +#if SB_API_VERSION >= 16 #include "starboard/android/shared/accessibility_extension.h" +#endif // SB_API_VERSION >= 16 #include "starboard/android/shared/android_media_session_client.h" #include "starboard/android/shared/configuration.h" #include "starboard/android/shared/graphics.h" @@ -80,9 +82,11 @@ const void* SbSystemGetExtension(const char* name) { if (strcmp(name, kStarboardExtensionPlayerSetMaxVideoInputSizeName) == 0) { return starboard::android::shared::GetPlayerSetMaxVideoInputSizeApi(); } +#if SB_API_VERSION >= 16 if (strcmp(name, kStarboardExtensionAccessibilityName) == 0) { return starboard::android::shared::GetAccessibilityApi(); } +#endif // SB_API_VERSION >= 16 #if SB_IS(EVERGREEN_COMPATIBLE) if (strcmp(name, kStarboardExtensionLoaderAppMetricsName) == 0) { return starboard::shared::starboard::GetLoaderAppMetricsApi(); diff --git a/starboard/shared/starboard/accessibility_internal.h b/starboard/shared/starboard/accessibility_internal.h index 4a0494129608..783824682f57 100644 --- a/starboard/shared/starboard/accessibility_internal.h +++ b/starboard/shared/starboard/accessibility_internal.h @@ -22,7 +22,11 @@ #include -#include "starboard/extension/accessibility.h" +#if SB_API_VERSION < 16 +#include "starboard/accessibility.h" +#else // SB_API_VERSION < 16 +#include "starboard/android/shared/accessibility_extension.h" +#endif // SB_API_VERSION < 16 #include "starboard/common/log.h"