Skip to content

feat(sdk): lock-screen media controls via LightMediaSession#100

Draft
tthayer wants to merge 4 commits into
lightphone:mainfrom
tthayer:feat/lock-screen-media-controls
Draft

feat(sdk): lock-screen media controls via LightMediaSession#100
tthayer wants to merge 4 commits into
lightphone:mainfrom
tthayer:feat/lock-screen-media-controls

Conversation

@tthayer

@tthayer tthayer commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Addresses #99
Add a LightMediaSession primitive so a tool can publish its playback to Android's media framework — a MediaSession plus a mediaPlayback foreground service and a MediaStyle notification — which LightOS surfaces on the lock screen and which routes headset/Bluetooth transport keys back to the tool.

  • plugin: allow FOREGROUND_SERVICE + FOREGROUND_SERVICE_MEDIA_PLAYBACK
  • client: LightMediaSession API (attach/setControls/update/release) + LightMediaService foreground service + manifest declaration
  • emulator: NowPlayingReader reads active sessions via MediaSessionManager (MEDIA_CONTENT_CONTROL as the platform-signed system app) and the lock screen renders track title + transport controls that drive the session

Tony Thayer-Osborne and others added 3 commits July 17, 2026 12:02
Add a LightMediaSession primitive so a tool can publish its playback to
Android's media framework — a MediaSession plus a mediaPlayback foreground
service and a MediaStyle notification — which LightOS surfaces on the lock
screen and which routes headset/Bluetooth transport keys back to the tool.

- plugin: allow FOREGROUND_SERVICE + FOREGROUND_SERVICE_MEDIA_PLAYBACK
- client: LightMediaSession API (attach/setControls/update/release) +
  LightMediaService foreground service + manifest <service> declaration
- emulator: NowPlayingReader reads active sessions via MediaSessionManager
  (MEDIA_CONTENT_CONTROL as the platform-signed system app) and the lock
  screen renders track title + transport controls that drive the session

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
When the selected media session stops or pauses, re-evaluate which active
session to show so the lock screen tracks the currently-playing (or most
recently active) tool rather than sticking to a stale one.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
- plugin: disable the NotificationPermission check for tool modules. A tool's
  only path to posting a notification is the SDK's guarded LightMediaSession
  (the sandbox blocks direct NotificationManager access), so the check is a
  false positive that every tool would inherit just by linking the SDK.
- client: guard LightMediaSession's notify() behind a POST_NOTIFICATIONS
  runtime check (best-effort; only shows for tools that opted in).
- emulator: tools:ignore ProtectedPermissions on MEDIA_CONTENT_CONTROL, which
  the platform-signed system-app emulator legitimately holds.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@jonathancaudill

Copy link
Copy Markdown

would be great for the lock screen controls to control generic playing content as well rather than just content routed thru lightmediasession. not sure if that's the behavior already!

@tthayer

tthayer commented Jul 20, 2026

Copy link
Copy Markdown
Contributor Author

Here is an example of it working:
lightos-lockscreen-media

@tthayer

tthayer commented Jul 23, 2026

Copy link
Copy Markdown
Contributor Author

I think it really just depends on the media player attaching to a LightMediaSession. Whichever attached last is the one that gets controls presented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants