Repository navigation
aosp: Report the text-to-speech state to Cobalt - #13186
Conversation
|
🤖 Gemini Suggested Commit Message💡 Pro Tips for a Better Commit Message:
|
There was a problem hiding this comment.
Code Review
This pull request re-enables and implements the accessibility text-to-speech settings API for Android, adding support for touch exploration checks in Java and injecting settings change events in C++ for AOSP builds. Feedback on the changes suggests adding a null check for AccessibilityManager in CobaltTextToSpeechHelper.java to prevent a potential NullPointerException, and checking if Application::Get() returns a null pointer before dereferencing it in text_to_speech_helper.cc.
bd0d250 to
a1ef86b
Compare
|
@haozheng-cobalt Please take a look at the replies and the latest change. |
|
@haozheng-cobalt On a separate note, I see work on the actual speech synthesis impl, which is out of scope for this PR, was started in #4912. Were you planning to work on it or would you like me to take a look at that? |
|
Gentle ping @haozheng-cobalt |
haozheng-cobalt
left a comment
There was a problem hiding this comment.
I've verified that this change does not impact 1p ATV platform.
Head branch was pushed to by a user without write access
871d418 to
e7d13d4
Compare
Refer to original PR: #13186 On AOSP, window.h5vcc.accessibility.textToSpeech was always false. Cobalt reads it through the Starboard accessibility extension, which Android disabled. Its text-to-speech getter was also a stub. Changes were never reported, since Starboard can't call into Cobalt there. Enable the extension and read the setting from the screen reader state. Report changes as a Starboard text-to-speech settings event, which Cobalt already handles. Android TV still reads the state over JNI and calls into Cobalt directly. Test: The yts test DAB Settings TTS passes. It failed before. Bug: 532158865 (cherry picked from commit 685152c)
Refer to original PR: #13186 On AOSP, window.h5vcc.accessibility.textToSpeech was always false. Cobalt reads it through the Starboard accessibility extension, which Android disabled. Its text-to-speech getter was also a stub. Changes were never reported, since Starboard can't call into Cobalt there. Enable the extension and read the setting from the screen reader state. Report changes as a Starboard text-to-speech settings event, which Cobalt already handles. Android TV still reads the state over JNI and calls into Cobalt directly. Test: The yts test DAB Settings TTS passes. It failed before. Bug: 532158865 (cherry picked from commit 685152c)
Refer to original PR: #13186 On AOSP, window.h5vcc.accessibility.textToSpeech was always false. Cobalt reads it through the Starboard accessibility extension, which Android disabled. Its text-to-speech getter was also a stub. Changes were never reported, since Starboard can't call into Cobalt there. Enable the extension and read the setting from the screen reader state. Report changes as a Starboard text-to-speech settings event, which Cobalt already handles. Android TV still reads the state over JNI and calls into Cobalt directly. Test: The yts test DAB Settings TTS passes. It failed before. Bug: 532158865 (cherry picked from commit 685152c)
Refer to original PR: #13186 On AOSP, window.h5vcc.accessibility.textToSpeech was always false. Cobalt reads it through the Starboard accessibility extension, which Android disabled. Its text-to-speech getter was also a stub. Changes were never reported, since Starboard can't call into Cobalt there. Enable the extension and read the setting from the screen reader state. Report changes as a Starboard text-to-speech settings event, which Cobalt already handles. Android TV still reads the state over JNI and calls into Cobalt directly. Test: The yts test DAB Settings TTS passes. It failed before. Bug: 532158865 (cherry picked from commit 685152c)
…tate to Cobalt Refer to original PR: youtube#13186 On AOSP, window.h5vcc.accessibility.textToSpeech was always false. Cobalt reads it through the Starboard accessibility extension, which Android disabled. Its text-to-speech getter was also a stub. Changes were never reported, since Starboard can't call into Cobalt there. Enable the extension and read the setting from the screen reader state. Report changes as a Starboard text-to-speech settings event, which Cobalt already handles. Android TV still reads the state over JNI and calls into Cobalt directly. Test: The yts test DAB Settings TTS passes. It failed before. Bug: 532158865 (cherry picked from commit 685152c)
#13624) … Cobalt Refer to original PR: #13186 On AOSP, window.h5vcc.accessibility.textToSpeech was always false. Cobalt reads it through the Starboard accessibility extension, which Android disabled. Its text-to-speech getter was also a stub. Changes were never reported, since Starboard can't call into Cobalt there. Enable the extension and read the setting from the screen reader state. Report changes as a Starboard text-to-speech settings event, which Cobalt already handles. Android TV still reads the state over JNI and calls into Cobalt directly. Test: The yts test DAB Settings TTS passes. It failed before. Bug: 532158865 (cherry picked from commit 685152c) Co-authored-by: Orko Garai <orko@igalia.com>
### Summary On Android, `BaseStarboardBridge.getCaptionSettings()` reads the current system `CaptioningManager` state on demand, but no `CaptioningManager.CaptioningChangeListener` was registered to observe changes made while the app is running or resumed. As a result, toggling system closed captions or updating caption styles at the OS level did not dispatch `kSbEventTypeAccessibilityCaptionSettingsChanged`. ### Changes * **`cobalt/android/apk/app/src/main/java/dev/cobalt/coat/BaseStarboardBridge.java`**: * Register a `CaptioningManager.CaptioningChangeListener` (`onEnabledChanged`, `onUserStyleChanged`, `onFontScaleChanged`) in `onActivityStart()` and unregister it in `onActivityStop()` (respecting both coordinated and legacy overlapping-activity lifecycles) and `afterStopped()`. * Dispatch `mNatives.sendCaptionSettingsChangedEvent()` when caption settings change and when registering the listener on start/resume while the native Starboard application is active (`mApplicationStarted && !mApplicationStopped`). * **`starboard/event.h`, `starboard/CHANGELOG.md` & `cobalt/updater/one_app_only_sandbox.cc`**: * Restore `kSbEventTypeAccessibilityCaptionSettingsChanged` in `SbEventType` (paralleling `kSbEventTypeAccessibilityTextToSpeechSettingsChanged` in #8324). * **`starboard/shared/starboard/application.h` & `starboard/shared/starboard/application.cc`**: * Add `Application::InjectCaptionSettingsChangedEvent()` (paralleling `InjectAccessibilityTextToSpeechSettingsChangedEvent` in #13186). * **`starboard/android/shared/base_starboard_bridge.cc`**: * Implement `JNI_BaseStarboardBridge_SendCaptionSettingsChangedEvent`, guarded by `#if BUILDFLAG(IS_STARBOARD)` to inject `kSbEventTypeAccessibilityCaptionSettingsChanged` via `Application::GetIfExists()->InjectCaptionSettingsChangedEvent()`. * **`cobalt/android/apk/app/src/test/java/dev/cobalt/coat/BaseStarboardBridgeTest.java`**: * Add Robolectric unit tests covering `CaptioningChangeListener` registration, `applicationStarted()` / `applicationStopping()` gating, callback forwarding, and overlapping activity transitions. Bug: 450024477
Refer to original PR: #13745 ### Summary On Android, `BaseStarboardBridge.getCaptionSettings()` reads the current system `CaptioningManager` state on demand, but no `CaptioningManager.CaptioningChangeListener` was registered to observe changes made while the app is running or resumed. As a result, toggling system closed captions or updating caption styles at the OS level did not dispatch `kSbEventTypeAccessibilityCaptionSettingsChanged`. ### Changes * **`cobalt/android/apk/app/src/main/java/dev/cobalt/coat/BaseStarboardBridge.java`**: * Register a `CaptioningManager.CaptioningChangeListener` (`onEnabledChanged`, `onUserStyleChanged`, `onFontScaleChanged`) in `onActivityStart()` and unregister it in `onActivityStop()` (respecting both coordinated and legacy overlapping-activity lifecycles) and `afterStopped()`. * Dispatch `mNatives.sendCaptionSettingsChangedEvent()` when caption settings change and when registering the listener on start/resume while the native Starboard application is active (`mApplicationStarted && !mApplicationStopped`). * **`starboard/event.h`, `starboard/CHANGELOG.md` & `cobalt/updater/one_app_only_sandbox.cc`**: * Restore `kSbEventTypeAccessibilityCaptionSettingsChanged` in `SbEventType` (paralleling `kSbEventTypeAccessibilityTextToSpeechSettingsChanged` in #8324). * **`starboard/shared/starboard/application.h` & `starboard/shared/starboard/application.cc`**: * Add `Application::InjectCaptionSettingsChangedEvent()` (paralleling `InjectAccessibilityTextToSpeechSettingsChangedEvent` in #13186). * **`starboard/android/shared/base_starboard_bridge.cc`**: * Implement `JNI_BaseStarboardBridge_SendCaptionSettingsChangedEvent`, guarded by `#if BUILDFLAG(IS_STARBOARD)` to inject `kSbEventTypeAccessibilityCaptionSettingsChanged` via `Application::GetIfExists()->InjectCaptionSettingsChangedEvent()`. * **`cobalt/android/apk/app/src/test/java/dev/cobalt/coat/BaseStarboardBridgeTest.java`**: * Add Robolectric unit tests covering `CaptioningChangeListener` registration, `applicationStarted()` / `applicationStopping()` gating, callback forwarding, and overlapping activity transitions. Bug: 450024477 (cherry picked from commit ca614c2)
Refer to original PR: #13745 ### Summary On Android, `BaseStarboardBridge.getCaptionSettings()` reads the current system `CaptioningManager` state on demand, but no `CaptioningManager.CaptioningChangeListener` was registered to observe changes made while the app is running or resumed. As a result, toggling system closed captions or updating caption styles at the OS level did not dispatch `kSbEventTypeAccessibilityCaptionSettingsChanged`. ### Changes * **`cobalt/android/apk/app/src/main/java/dev/cobalt/coat/BaseStarboardBridge.java`**: * Register a `CaptioningManager.CaptioningChangeListener` (`onEnabledChanged`, `onUserStyleChanged`, `onFontScaleChanged`) in `onActivityStart()` and unregister it in `onActivityStop()` (respecting both coordinated and legacy overlapping-activity lifecycles) and `afterStopped()`. * Dispatch `mNatives.sendCaptionSettingsChangedEvent()` when caption settings change and when registering the listener on start/resume while the native Starboard application is active (`mApplicationStarted && !mApplicationStopped`). * **`starboard/event.h`, `starboard/CHANGELOG.md` & `cobalt/updater/one_app_only_sandbox.cc`**: * Restore `kSbEventTypeAccessibilityCaptionSettingsChanged` in `SbEventType` (paralleling `kSbEventTypeAccessibilityTextToSpeechSettingsChanged` in #8324). * **`starboard/shared/starboard/application.h` & `starboard/shared/starboard/application.cc`**: * Add `Application::InjectCaptionSettingsChangedEvent()` (paralleling `InjectAccessibilityTextToSpeechSettingsChangedEvent` in #13186). * **`starboard/android/shared/base_starboard_bridge.cc`**: * Implement `JNI_BaseStarboardBridge_SendCaptionSettingsChangedEvent`, guarded by `#if BUILDFLAG(IS_STARBOARD)` to inject `kSbEventTypeAccessibilityCaptionSettingsChanged` via `Application::GetIfExists()->InjectCaptionSettingsChangedEvent()`. * **`cobalt/android/apk/app/src/test/java/dev/cobalt/coat/BaseStarboardBridgeTest.java`**: * Add Robolectric unit tests covering `CaptioningChangeListener` registration, `applicationStarted()` / `applicationStopping()` gating, callback forwarding, and overlapping activity transitions. Bug: 450024477 (cherry picked from commit ca614c2)
On AOSP, window.h5vcc.accessibility.textToSpeech was always false. Cobalt reads it through the Starboard accessibility extension, which Android disabled. Its text-to-speech getter was also a stub. Changes were never reported, since Starboard can't call into Cobalt there.
Enable the extension and read the setting from the screen reader state. Report changes as a Starboard text-to-speech settings event, which Cobalt already handles. Android TV still reads the state over JNI and calls into Cobalt directly.
Test: The yts test DAB Settings TTS passes. It failed before.
Bug: 532158865