Skip to content

Commit d4cb4ad

Browse files
rakucofayev-g
andauthored
tvOS: Make the accessibility extension code work in Chrobalt (youtube#9221)
The code in the tree came directly from C25 and did not build as-is. * Remove the existing implementations of GetDisplaySettings(), GetCaptionSettings() and SetCaptionsEnabled() and provide stub implementations instead. These functions are part of the Starboard API for the a11y extension but nothing in the tree calls them. * Remove the nested namespaces that were removed from the tree in main. * Provide a GetTextToSpeechSettings() implementation that does not use code that was removed. Just query UIAccessibilityIsVoiceOverRunning() to determine whether TTS is active or not. Together with youtube#9219 (and a follow-up that enables the accessibility extension), this should be enough code to make h5vcc_accessibility determine whether VoiceOver is on or not on tvOS. Bug: 478127016 Bug: 447135715 Co-authored-by: fayev-g <fayev@google.com>
1 parent f07228c commit d4cb4ad

7 files changed

+31
-285
lines changed

starboard/tvos/shared/BUILD.gn

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ static_library("starboard_platform") {
7878
"//starboard/shared/starboard/window_set_default_options.cc",
7979
"//starboard/shared/stub/storage_write_record.cc",
8080
"//starboard/shared/stub/system_symbolize.cc",
81+
"accessibility_extension.cc",
82+
"accessibility_extension.h",
83+
"accessibility_get_text_to_speech_settings.mm",
8184
"application_darwin.h",
8285
"application_darwin.mm",
8386
"configuration_constants.cc",

starboard/tvos/shared/accessibility_extension.cc

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,36 @@
1717
#include "starboard/extension/accessibility.h"
1818

1919
namespace starboard {
20-
namespace shared {
21-
namespace uikit {
20+
21+
namespace {
22+
23+
// The following functions are part of the Starboard API for this extension
24+
// but are not used anywhere in Chrobalt.
25+
26+
bool GetDisplaySettings(SbAccessibilityDisplaySettings* out_setting) {
27+
return false;
28+
}
29+
30+
bool GetCaptionSettings(SbAccessibilityCaptionSettings* caption_settings) {
31+
return false;
32+
}
33+
34+
bool SetCaptionsEnabled(bool enabled) {
35+
return false;
36+
}
37+
38+
} // namespace
2239

2340
const StarboardExtensionAccessibilityApi kAccessibilityAPI = {
2441
kStarboardExtensionAccessibilityName,
2542
1,
26-
&accessibility::GetTextToSpeechSettings,
27-
&accessibility::GetDisplaySettings,
28-
&accessibility::GetCaptionSettings,
29-
&accessibility::SetCaptionsEnabled};
43+
&GetTextToSpeechSettings,
44+
&GetDisplaySettings,
45+
&GetCaptionSettings,
46+
&SetCaptionsEnabled};
3047

3148
const void* GetAccessibilityApi() {
3249
return &kAccessibilityAPI;
3350
}
3451

35-
} // namespace uikit
36-
} // namespace shared
3752
} // namespace starboard

starboard/tvos/shared/accessibility_extension.h

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,11 @@
1818
#include "starboard/extension/accessibility.h"
1919

2020
namespace starboard {
21-
namespace shared {
22-
namespace uikit {
23-
24-
namespace accessibility {
25-
26-
bool GetCaptionSettings(SbAccessibilityCaptionSettings* caption_settings);
27-
28-
bool GetDisplaySettings(SbAccessibilityDisplaySettings* out_setting);
2921

3022
bool GetTextToSpeechSettings(SbAccessibilityTextToSpeechSettings* out_setting);
3123

32-
bool SetCaptionsEnabled(bool enabled);
33-
34-
} // namespace accessibility
35-
3624
const void* GetAccessibilityApi();
3725

38-
} // namespace uikit
39-
} // namespace shared
4026
} // namespace starboard
4127

4228
#endif // STARBOARD_TVOS_SHARED_ACCESSIBILITY_EXTENSION_H_

starboard/tvos/shared/accessibility_get_caption_settings.mm

Lines changed: 0 additions & 158 deletions
This file was deleted.

starboard/tvos/shared/accessibility_get_display_settings.mm

Lines changed: 0 additions & 43 deletions
This file was deleted.

starboard/tvos/shared/accessibility_get_text_to_speech_settings.mm

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,35 +12,23 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
#import <Foundation/Foundation.h>
15+
#import <UIKit/UIKit.h>
1616

1717
#include "starboard/common/memory.h"
1818
#include "starboard/tvos/shared/accessibility_extension.h"
19-
#import "starboard/tvos/shared/speech_synthesizer.h"
20-
#import "starboard/tvos/shared/starboard_application.h"
2119

2220
namespace starboard {
23-
namespace shared {
24-
namespace uikit {
25-
26-
namespace accessibility {
2721

2822
bool GetTextToSpeechSettings(SbAccessibilityTextToSpeechSettings* out_setting) {
2923
if (!out_setting ||
30-
!starboard::common::MemoryIsZero(
31-
out_setting, sizeof(SbAccessibilityTextToSpeechSettings))) {
24+
!MemoryIsZero(out_setting, sizeof(SbAccessibilityTextToSpeechSettings))) {
3225
return false;
3326
}
3427

35-
@autoreleasepool {
36-
out_setting->has_text_to_speech_setting = true;
37-
out_setting->is_text_to_speech_enabled =
38-
SBDGetApplication().speechSynthesizer.screenReaderActive;
39-
}
28+
out_setting->has_text_to_speech_setting = true;
29+
out_setting->is_text_to_speech_enabled = UIAccessibilityIsVoiceOverRunning();
30+
4031
return true;
4132
}
4233

43-
} // namespace accessibility
44-
} // namespace uikit
45-
} // namespace shared
4634
} // namespace starboard

starboard/tvos/shared/accessibility_set_captions_enabled.mm

Lines changed: 0 additions & 45 deletions
This file was deleted.

0 commit comments

Comments
 (0)