Skip to content

feat: add watch pairing tweaks - #29

Merged
SoClear merged 2 commits into
SoClear:mainfrom
Mzdyl:WatchPairing
May 16, 2026
Merged

feat: add watch pairing tweaks#29
SoClear merged 2 commits into
SoClear:mainfrom
Mzdyl:WatchPairing

Conversation

@Mzdyl

@Mzdyl Mzdyl commented May 12, 2026

Copy link
Copy Markdown
Contributor

No description provided.

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

Copy link
Copy Markdown

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 introduces functionality to bypass region and CSC checks during Samsung Watch pairing. Key additions include a new WatchPairing hook class, updated preference models, and UI components for configuring connection modes and GMS supplementation. Feedback highlights a potential crash in WatchPairing.kt when modifying the package list if the returned set is immutable, and suggests consolidating duplicate constants between the UI and hook logic to a shared location for better maintainability.

Comment on lines +137 to +140
val packages = param.result as? MutableSet<*> ?: return
@Suppress("UNCHECKED_CAST")
(packages as MutableSet<String>).add("com.google.android.wearable.app.cn")
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

Directly casting the result to MutableSet and calling add can cause a crash if the target application returns an immutable set (e.g., via Collections.unmodifiableSet or Set.of). It is safer to create a new mutable copy of the set, modify it, and then set it as the new result.

                        val packages = param.result as? Set<*> ?: return
                        val newSet = packages.toMutableSet()
                        @Suppress("UNCHECKED_CAST")
                        (newSet as MutableSet<String>).add("com.google.android.wearable.app.cn")
                        param.result = newSet

import io.github.soclear.oneuix.ui.component.SelectItem
import io.github.soclear.oneuix.ui.component.SwitchItem

private const val WATCH_PAIRING_MODE_CN = 1

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

This constant is a duplicate of WatchPairing.MODE_WEAROS_CN. To improve maintainability and ensure consistency between the UI and the hook logic, these constants should be moved to a shared location, such as a companion object in Preference.kt or a dedicated constants file.

@SoClear

SoClear commented May 16, 2026

Copy link
Copy Markdown
Owner

挺好的

@SoClear
SoClear merged commit a8251ba into SoClear:main May 16, 2026
1 check passed
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