Skip to content

aosp: Report the text-to-speech state to Cobalt - #13186

Merged
andrewsavage1 merged 6 commits into
youtube:mainfrom
ogarai:yts/fix_aosp_text_to_speech_setting
Oct 20, 2026
Merged

andrewsavage1 merged 6 commits into
youtube:mainfrom
ogarai:yts/fix_aosp_text_to_speech_setting

Conversation

@ogarai

@ogarai ogarai commented Oct 7, 2026 •

Copy link
Copy Markdown
Collaborator

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

@ogarai
ogarai requested a review from a team as a code owner October 7, 2026 17:34
@github-actions

github-actions Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor
Context State Description
CI / All Pass ✅ PASS All checks passed
CI / android ✅ PASS Passed
CI / evergreen ✅ PASS Passed
CI / linux ✅ PASS Passed
CI / tvos ✅ PASS Passed
@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

🤖 Gemini Suggested Commit Message


Error: Could not parse a valid response from the Gemini API. Please check the API response logs in the workflow run.

💡 Pro Tips for a Better Commit Message:

  1. Influence the Result: Want to change the output? You can write custom prompts or instructions directly in the Pull Request description. The model uses that text to generate the message.
  2. Re-run the Generator: Post a comment with: /generate-commit-message

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@ogarai
ogarai force-pushed the yts/fix_aosp_text_to_speech_setting branch from bd0d250 to a1ef86b Compare October 8, 2026 17:12
@ogarai
ogarai requested a review from haozheng-cobalt October 8, 2026 17:13
@ogarai
ogarai requested a review from hferreiro October 8, 2026 17:23
@ogarai

ogarai commented Oct 15, 2026

Copy link
Copy Markdown
Collaborator Author

@haozheng-cobalt Please take a look at the replies and the latest change.

@ogarai

ogarai commented Oct 15, 2026

Copy link
Copy Markdown
Collaborator Author

@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?

@ogarai

ogarai commented Oct 19, 2026

Copy link
Copy Markdown
Collaborator Author

Gentle ping @haozheng-cobalt

@haozheng-cobalt haozheng-cobalt left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've verified that this change does not impact 1p ATV platform.

auto-merge was automatically disabled October 20, 2026 01:59

Head branch was pushed to by a user without write access

@ogarai
ogarai force-pushed the yts/fix_aosp_text_to_speech_setting branch from 871d418 to e7d13d4 Compare October 20, 2026 01:59
@andrewsavage1
andrewsavage1 merged commit 685152c into youtube:main Oct 20, 2026
711 of 714 checks passed
cobalt-github-releaser-bot pushed a commit that referenced this pull request Oct 20, 2026
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)
cobalt-github-releaser-bot pushed a commit that referenced this pull request Oct 20, 2026
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)
briantting pushed a commit that referenced this pull request Oct 20, 2026
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)
briantting pushed a commit that referenced this pull request Oct 26, 2026
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)
briantting pushed a commit to briantting/cobalt that referenced this pull request Oct 26, 2026
…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)
briantting added a commit that referenced this pull request Oct 26, 2026
#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>
andrewsavage1 added a commit that referenced this pull request Oct 29, 2026
Partially reverts commit 685152c
(#13186) to restore the `BUILDFLAG(IS_PARTNER_TOOLCHAIN)` definition and
GN define.

Bug: 492704919
TAG=agy
CONV=fa3dfb4d-33a8-4f4d-ba93-b5c544078a04
donpaul999 added a commit that referenced this pull request Nov 3, 2026
### 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
@ogarai
ogarai deleted the yts/fix_aosp_text_to_speech_setting branch November 4, 2026 14:50
cobalt-github-releaser-bot pushed a commit that referenced this pull request Nov 23, 2026
Refer to original PR: #13657

Partially reverts commit 685152c
(#13186) to restore the `BUILDFLAG(IS_PARTNER_TOOLCHAIN)` definition and
GN define.

Bug: 492704919
TAG=agy
CONV=fa3dfb4d-33a8-4f4d-ba93-b5c544078a04

(cherry picked from commit 1b96bb7)
cobalt-github-releaser-bot pushed a commit that referenced this pull request Nov 23, 2026
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)
cobalt-roller-and-merger Bot pushed a commit that referenced this pull request Nov 24, 2026
Refer to original PR: #13657

Partially reverts commit 685152c
(#13186) to restore the `BUILDFLAG(IS_PARTNER_TOOLCHAIN)` definition and
GN define.

Bug: 492704919
TAG=agy
CONV=fa3dfb4d-33a8-4f4d-ba93-b5c544078a04

(cherry picked from commit 1b96bb7)
cobalt-roller-and-merger Bot pushed a commit that referenced this pull request Nov 24, 2026
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

5 participants