Skip to content

Add fake watch setting and improve FakeLibPebble#226

Open
jmsunseri wants to merge 11 commits into
coredevices:masterfrom
jmsunseri:jmsunseri/feat/timeout-slider-improvements
Open

Add fake watch setting and improve FakeLibPebble#226
jmsunseri wants to merge 11 commits into
coredevices:masterfrom
jmsunseri:jmsunseri/feat/timeout-slider-improvements

Conversation

@jmsunseri

@jmsunseri jmsunseri commented May 31, 2026

Copy link
Copy Markdown
Contributor

Allow selecting a fake watch type from debug settings to use FakeLibPebble instead of a real Bluetooth connection. Simplify FakeLibPebble by removing random data generation and adding displayName to WatchHardwarePlatform.

image image image image

Allow selecting a fake watch type from debug settings to use
FakeLibPebble instead of a real Bluetooth connection. Simplify
FakeLibPebble by removing random data generation and adding
displayName to WatchHardwarePlatform.
@jmsunseri

Copy link
Copy Markdown
Contributor Author

cc @ericmigi

@sjp4

sjp4 commented May 31, 2026

Copy link
Copy Markdown
Member

Why do you want this?

@jmsunseri

Copy link
Copy Markdown
Contributor Author

Why do you want this?

I was working on a feature that required access to the settings of a watch but I was having a lot of difficulty connecting a watch to a google phone emulator and this seemed like a very simple work around so that you could access and test features that required a connected watch without the watch really being there.

@jmsunseri

Copy link
Copy Markdown
Contributor Author

@sjp4 is there anything blocking this from going forward? i've got several things i'd like to work on and improve and this would make it so much easier to work on these things?

jmsunseri added 6 commits June 2, 2026 10:39
Use `binds` to register additional types directly on the LibPebble
singleton instead of defining separate singleites with manual casts.

For LibPebble3 resolution, replace the unsafe cast with a safe `as?`
cast and provide a clearer error message when fake watches are in use.
Move add, remove, and set active fake watch operations out of
WatchSettingsScreen and into CoreConfigHolder extension functions.
Also add a transform-based update method to CoreConfigHolder.
Simplifies the consumer hardware filter in WatchSettingsScreen
and fixes FakeLibPebble to filter by ID and watchface type.

@sjp4 sjp4 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.

@sjp4 is there anything blocking this from going forward? i've got several things i'd like to work on and improve and this would make it so much easier to work on these things?

At the base level, this breaks the only thing we currently use FakeLibPebble for (compose previews) by removing randomisation.

Given that FakeLibPebble is only designed to power a few specific screens right now, the behaviour in a lot of the app will be undefined (likely crashes, weird behaviour in many places). It's also losing a lot of functionality that is not bluetooth related (i.e. that might be better served with a mock device transport in libpebble).

If we did go this route (powering the entire app with FakeLibPebble), we do not want to expose it to users (even behind the debug options flag) - it would need to be behind a buildconfig flag configured in gradle properties. We would also not want it controlled like that in settings/libpebbleconfig - it should use the discovery flow to add new devices, and persist them internally to FakeLibPebble.

PEBBLE_ROBERT_BIGBOARD_2(247u, WatchType.EMERY, "robert_bb2"),
CORE_OBELIX_BIGBOARD(244u, WatchType.EMERY, "obelix_bb"),
CORE_OBELIX_BIGBOARD_2(243u, WatchType.EMERY, "obelix_bb2"),
enum class WatchHardwarePlatform(val protocolNumber: UByte, private val _watchType: WatchType, val revision: String, val displayName: String, val isConsumer: Boolean = false) {

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.

Adding a user-facing name to a board doesn't really make sense - this is probably the wrong layer to do this (also many of the isConsumer flags here are wrong)

val fakeActiveWatch: WatchHardwarePlatform? = null,
) {
init {
require(fakeActiveWatch == null || fakeActiveWatch in fakeWatches) {

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.

this would crash the app on start

@jmsunseri

jmsunseri commented Jun 5, 2026 via email

Copy link
Copy Markdown
Contributor Author

…ble previews

- Add fakeWatchEnabled Gradle property exposed via CommonBuildKonfig

- Remove fake watch state from CoreConfig; persist in FakeWatchConfigStore

- Remove displayName/isConsumer from WatchHardwarePlatform; add UI-layer mapping

- Restore default FakeLibPebble randomized behavior for previews/tests

- Add ConfiguredFakeLibPebble for build-flag-enabled deterministic fake watches

- Gate watchModule selection and settings UI behind FAKE_WATCH_ENABLED
- Move fakeWatchItems and FakeWatchPickerDialog to coredevices.pebble.fake package

- Add StateFlow-based fakeWatches/activeFakeWatch to FakeWatchConfigStore

- Collect fake watch state in WatchSettingsScreen and pass to fakeWatchItems

- Fix UI not updating when removing fake watches
@jmsunseri

Copy link
Copy Markdown
Contributor Author

@sjp4 hopefully you like this implementation better

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