Skip to content

Commit

Permalink
Add back SB A11y impls for Android on SB 14/15 (#4167)
Browse files Browse the repository at this point in the history
Add back SB A11y impls for Android on SB 14/15
    
 b/370027229
  • Loading branch information
hlwarriner authored Sep 30, 2024
1 parent 41b3527 commit 655b3e1
Show file tree
Hide file tree
Showing 9 changed files with 79 additions and 13 deletions.
2 changes: 1 addition & 1 deletion cobalt/media/base/drm_system.h
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ class DrmSystem : public base::RefCounted<DrmSystem> {
TicketToSessionUpdateMap ticket_to_session_update_map_;

MediaMetricsProvider media_metrics_provider_;

DISALLOW_COPY_AND_ASSIGN(DrmSystem);
};

Expand Down
9 changes: 7 additions & 2 deletions starboard/android/shared/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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

Expand Down
15 changes: 13 additions & 2 deletions starboard/android/shared/accessibility_get_caption_settings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,18 @@
#include <cstdlib>
#include <string>

#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"
#include "starboard/common/memory.h"
#include "starboard/configuration.h"
#include "starboard/shared/starboard/accessibility_internal.h"

#include "starboard/android/shared/accessibility_extension.h"

namespace starboard {
namespace android {
namespace shared {
Expand Down Expand Up @@ -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
15 changes: 13 additions & 2 deletions starboard/android/shared/accessibility_get_display_settings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
13 changes: 11 additions & 2 deletions starboard/android/shared/accessibility_set_captions_enabled.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
13 changes: 12 additions & 1 deletion starboard/android/shared/application_android.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@
#include <string>
#include <vector>

#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"
Expand Down Expand Up @@ -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<const StarboardExtensionAccessibilityApi*>(
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;
}

Expand Down
4 changes: 4 additions & 0 deletions starboard/android/shared/system_get_extensions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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();
Expand Down
6 changes: 5 additions & 1 deletion starboard/shared/starboard/accessibility_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@

#include <limits>

#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"

Expand Down

0 comments on commit 655b3e1

Please sign in to comment.