Repository navigation
Conversation
|
Is it possible to merge the wear os edition into the phone version so just a single app works on both setup? |
|
Yes, that's doable, and it would actually simplify the PR: the asset selector change in The plan would be to turn The cost is small: in a quick spike with |
Prepare for a second frontend (Wear OS) by moving the non-UI parts of the app out of :apk into a new :shared Android library: view models, the view model factory, navigation routes, the terminal emulator, flash helpers and the small UI state types they depend on. AppSortBy and ThemeState are split out of their Compose files so :shared does not need Material 3. FlashUtils now targets the component of the app's own launch intent instead of referencing MainActivity, which stays in :apk. Packages and class names are unchanged and there is no change in behavior. Assisted-by: Claude Opus 5.5
Add :wear, a Wear OS frontend for the Magisk app built on the Wear Compose Material 3 libraries. It is a library of :apk, so a single APK serves both phones and watches; it shares :core and :shared with the phone UI. The main activity stays the only activity. Where useWearUi() is true (a watch on API 25 or later, the minimum of Wear Compose), it hands its content to WearUi instead of setting up the phone UI, and keeps running the common splash and initialization sequence. The check matches the watch-v25 resource qualifier, which replaces the activity theme and the splash background on those devices. Since Wear Compose is never used below API 25, :apk overrides the minimum SDK of those libraries. For now the Wear UI only shows the time on a black screen; the screens follow in later changes. JUnit is added to the version catalog for the module's JVM unit tests. Assisted-by: Claude Opus 5.5
Move the sanitizer and the timed provider query for the display name of an external flash request, and the startup checks for an unsupported install, from the phone MainActivity to :shared, so the Wear UI runs the same security-relevant code instead of a copy. The phone UI keeps its dialogs and behaves as before. rememberBiometricAuth, which asks for the device credential before a Superuser change when the setting requires it, moves to :shared as well. It only depends on the activity result API, not on a UI kit. The sanitizer gets JVM unit tests for control, bidi and tag characters, the length cap and trimming. Assisted-by: Claude Opus 5.5
Give the Wear UI its color scheme and a Navigation3 back stack shown with the Wear swipe-to-dismiss scene strategy. WearRoute adds the screens that only exist on Wear next to the shared Route, and WearNavigator saves the stack like the phone UI does. Screens that are not written yet show a placeholder. WearUi follows the phone UI's startup and handles the flash intent. Our own module downloads go straight to flashing; requests from other apps are confirmed with a Wear AlertDialog like on the phone: the display name is queried with a timeout and sanitized, its source is shown, and overlays are hidden while it is up. Most watches have no app for ACTION_OPEN_DOCUMENT, so the file picker falls back to listing the download folder through the root shell. It is also used when only a non-system app handles the action: the picker is started without a chooser, and any installed app could otherwise register for it and supply the file to install. The app creates the copy in its cache and root only writes into it: a file created by the root shell would get its SELinux level without the app's categories, and the app could neither open nor delete it. Assisted-by: Claude Opus 5.5
Replace the home placeholder with a screen that shows the installed Magisk version and code, whether it is running, and the Zygisk and ramdisk status, followed by shortcuts to Superuser, Modules, Logs, Settings, Install and Uninstall. Without an active Magisk only Install is offered. It reuses HomeViewModel from :shared and reloads it each time the screen is shown, as the phone UI does for its home tab. The screen also shows the environment fix confirmation raised by HomeViewModel's check: it runs fixEnv, or opens Install when only a reinstall can fix it, and shows a progress indicator while it runs. HomeStatus.of applies the Info.Env rule (supported version code and root) to raw values, so it is unit tested without touching Info, whose initializer cannot run on the JVM. HomeStatus.from is the production entry and delegates to it. Assisted-by: Claude Opus 5.5
Replace the Superuser placeholders with a list of apps that have a policy and a per-app detail screen. Each row shows the app icon, its name and the kind of root it gets, with a switch that flips the policy between Allow and Deny; tapping the row opens the details. The header links to the grant screen and the list ends with a link to the logs. The details toggle restricted root, notifications and logging, and revoke the policy after a confirmation, then return to the list. Like on the phone, changing a policy asks for authentication first when the Superuser setting requires it, which then replaces the confirmation of a revoke. Both screens use one activity-scoped SuperuserViewModel, as the phone UI does, so edits made in the details show up in the list immediately. App icons are drawn once at their small display size and cached. rootLabel picks the root kind label and is covered by unit tests. Assisted-by: Claude Opus 5.5
Replace the grant placeholder with a list of apps that had no policy when the screen opened. Tapping a row grants root and its "+" turns into a check mark with the kind of root it got; tapping again undoes the grant. The list ends with a switch that shows system apps. The mode chip at the top picks between full and restricted root for the next grant. It starts at the "restrict root capabilities" setting, which stays unchanged: toggleGrant now takes the mode, decided when the row is tapped, since the write happens later in the background and must not depend on what the setting is by then. A grant asks for authentication first when the Superuser setting requires it. New policies reach the Superuser list through the policy change event, as on the phone. Assisted-by: Claude Opus 5.5
Show the Superuser log grouped by day, with a dot telling granted from denied requests, and the Magisk log as one monospace item per parsed entry, so long logs stay cheap to scroll. A switch at the top picks the log; without root only the Magisk log exists, like on the phone. Both logs list the newest entries first and can be cleared after a confirmation. Define the error colour in the Wear theme, so denied requests and destructive actions share one red. Assisted-by: Claude Opus 5.5
List the installed modules with a switch each, open their details to remove or restore them and run their action, and install a module zip picked from storage after a confirmation, like the phone UI. The confirmation shows the provider of a picked file next to its name, as for a request from another app. A reboot button shows up once a module differs from its state when first loaded, since changes only apply after a reboot. The action output is shown as plain monospace text read from the terminal emulator. A horizontal swipe dismisses the screen on Wear, so there is no horizontal scrolling: the emulator is sized to the width that fits and wraps long lines itself. TerminalText is reused by the flash screen. While the action runs, BlockDismiss turns swipe-to-dismiss off and registers the screen's back callback with the navigator. NavDisplay's onBack hands back to the latest blocker instead of popping, so the exit confirmation does not depend on the order of back handlers and a hung script can always be left. From API 36 the swipe is predictive back, and turning it off in the scene strategy would swallow back entirely, so it stays on there and reaches the same callback. Assisted-by: Claude Opus 5.5
Install offers patching an image picked from storage, direct install and, with root on A/B devices, the inactive slot with the phone UI's warning, plus the patching options that apply to the device. Direct install asks for confirmation first. The flash screen shows the installer output with a progress ring on the screen edge. While a boot image is flashed or patched it cannot be left; a module zip can be left after confirming, like on the phone. Restoring the images warns first and shows the SHA1 of the stock boot backup read from Magisk's config. It only starts on a long press, and only when the backup exists. The home view model is now owned by the activity, so the restore screen shares it and its loading state with the home screen. Flashing and restoring keep the screen on, so the app stays in the foreground and is not killed for memory halfway through. Assisted-by: Claude Opus 5.5
Settings shows the phone UI's Magisk, Superuser and update settings that make sense on a watch, under the same conditions and through the same SettingsViewModel calls. Choices open a list of radio buttons in a dialog, and the custom channel URL is typed with the system keyboard through RemoteInput (androidx.wear:wear-input). The DenyList switches whole apps with toggleAll; picking single processes is left to the phone UI. Assisted-by: Claude Opus 5.5
The app modules now have JVM unit tests (:shared and :wear), but CI only assembles the APKs. Run testDebugUnitTest after the debug build, which already generated the files the build reads. Assisted-by: Claude Opus 5.5
|
Compared with the original version While at it, I also fixed a few things in the Wear screens: the grant screen now passes the selected root mode to |
Summary
This adds
:wear, a second frontend for the Magisk app, written for round Wear OS screens withWear Compose Material 3. The phone UI is unusable on a ~1.4" round display, and there is no
reasonable workaround: a global
wm densitychange breaks the system UI, and per-app DPI hookscan't reach the Magisk app because Zygisk deliberately skips it.
:wearis a separate APK with the same application ID, namespace, ABI list and signing as thephone app (it goes through
setupMainApk()), somagiskdtreats it as the manager and either APKcan manage the same install. It reuses
:coreand the phone app's view models unchanged; only thescreens are new.
Tested on a Samsung Galaxy Watch 4 (SM-R870, 450×450 round, One UI 6 Watch / Wear OS 5, API 34,
32-bit userspace).
Architecture
The series is 13 commits, each of which compiles on its own:
:sharedlibrary, extracted from:apk(Move app view models to a shared module).View models, the view model factory,
Route, the terminal emulator,FlashUtilsand the smallUI state types they need move from
:apkto a new Android library. This is a pure move:packages and class names are unchanged, the view models are 100% renames in git, and
AppSortBy/ThemeStateare split out of their Compose files so:shareddoes not pull inphone Material 3. The only code edit is that
FlashUtilstargets the component of the app'sown launch intent instead of referencing
:apk'sMainActivity.:apkbehaves exactly asbefore.
:wearmodule (Add Wear OS app module), depending on:coreand:shared. Wear Compose1.7.2 (foundation, material3, navigation3) and
androidx.wear:wear-inputare added to theversion catalog, plus
junitfor JVM unit tests.minSdkis 25 for this module only, becauseWear Compose requires it.
build.py wear(Build the Wear OS app in build.py): a new action that writesout/app-wear-<debug|release>.apk.allnow builds it as well, so CI produces both APKs; theworkflow uploads the Wear mapping and native debug symbols as a separate artifact.
docs/build.mdmentions the new action../build.py appis unchanged.Share display name and startup checks): the sanitizer andtimed provider query for the display name of an external flash request, and the
unsupported-install startup checks, move from the phone
MainActivityto:shared, so theWear app runs the same code instead of a copy. The sanitizer gets JVM tests. The phone app keeps
its dialogs and behaves as before.
strategy, file picker, then Home, Superuser, Grant, Logs, Modules, Install/Flash/Restore,
Settings and DenyList.
:core(Pick the update APK for the kind of device).The one non-string change in
:coreApart from new strings (English and Polish in
app/core/src/main/res, a few non-translatable onesin
resources.xml), the only change to:coreis the update asset selector inNetworkService.Without it, the existing selector takes the first non-debug APK of a release, so as soon as a
release carries both APKs:
job and its notification), and
With the change, a device with
FEATURE_WATCHonly accepts an asset whose name containswear(case-insensitive), and every other device skips such assets. If a release has no APK for the
device, no update is offered (an empty
UpdateInfo) instead of the previous!!failure, and thestable-to-beta auto switch only happens for a real version code. The debug channel looks for
app-wear-debug.apkon watches andapp-debug.apkelsewhere. This can't live in:wear, becauseupdate checking, the update job and the download subject are all in
:core.What is deliberately not shared
with different layout models (scaling/transforming lazy columns, edge buttons, curved time text,
swipe-to-dismiss instead of a back button). Sharing composables would mean
if (watch)in everyscreen, which is the thing this split avoids.
AppIconis a small, separate implementation onWear because it draws each icon once at its small display size and caches the bitmap.
NavigatorandLeaveInterruptedScreen.WearNavigatorkeeps the phoneNavigator'spush/pop/save behaviour (same duplicate-push guard, same root protection, same saver), but it
also owns Wear-only state: results of the in-app file picker screen, and the stack of screens
that currently block swipe-to-dismiss. Back from
NavDisplaygoes through that stack, so arunning module action or flash asks for confirmation deterministically instead of depending on
the order of back handlers; on the root, swipe is left to the system, which closes the app.
Moving
Navigatorto:sharedwould put this Wear state and back semantics into the phoneclass, or need an extra abstraction layer over a small class.
LeaveInterruptedScreenis a5-line private composable typed on the navigator; it is duplicated rather than routed through a
new common interface.
AlertDialogwithan
EdgeButton. The behaviour is the same (external flash confirmation with sanitized name andsource, unsupported-install messages shown one by one, env fix confirmation, exit confirmation
for a running job).
Feature parity with the phone app
toggleAll); per-process picking stays on the phone:coreWear-specific bits:
ACTION_OPEN_DOCUMENTresolves to
com.google.android.wearable.frameworkpackagestubs, a stub that only says that noapp can handle the action. The picker therefore resolves the handlers itself, skips known stub
packages (the Wear and AOSP framework package stubs), and pins the intent to a real picker if
one exists. Otherwise it opens an in-app screen that lists matching files in the Download folder
through the root shell. The app creates the destination file in its cache and root only writes
into it, because a file created by the root shell gets an SELinux level without the app's
categories, and the app could neither open nor delete it.
RemoteInput(system keyboard).halfway through. A boot image flash or patch can't be left; a module zip or a module action can be
left after confirming, like on the phone.
Testing
Builds (JDK 25, ONDK r30.2, on this branch):
compileDebugKotlinfor:apk,:sharedand:wearat each of the 13 commits: all pass../build.py app,./build.py wear,./build.py -r wear: pass. The release Wear APK goesthrough R8 and has
uses-feature android.hardware.type.watch; the phone APK does not../gradlew test: 27 JVM tests, 0 failures (:sharedDisplayNameTest;:wearDocumentPicker,RootFiles, HomeStatus, BackupInfo, RootLabel).
./gradlew lint: fails on master already. Compared with master, the only new errors areMissingTranslationfor the new strings (English and Polish only, as new strings are usuallyadded).
On the watch (Galaxy Watch 4 SM-R870, One UI 6 Watch, API 34), with Magisk built from this tree
and the boot image patched with its binaries:
magiskdaccepts it as the manager (no signature mismatch).requests from granted apps work, ungranted ones are rejected as in v31.1.
instead of the framework stub.
Not exercised on the device: an actual patch or direct install through the app (the boot image on
the test watch is built by an external pipeline), restore images (no stock backup on that watch),
and module action output.
Screenshots
Galaxy Watch 4, round-masked. The version string in the first screenshot comes from a local
config.prop.Home
Superuser
Grant
Logs
Modules
Module details
Install
Settings
Notes for maintainers
contains
wear, for exampleMagisk-Wear-v31.2.apk, next to the phone APK (whose name mustnot contain
wear). Canary/debug releases needapp-wear-debug.apknext toapp-debug.apk.Releases without a Wear asset simply offer no update on watches.
linkfrom the update JSON, so a custom channel usedon a watch must point at a Wear APK.
.github/workflows/build.ymlruns./build.py -vr alland./build.py -v all, and theWindows/Linux test builds run
build.py ... all, so:wearis built in every existing jobwithout new steps. The only workflow change is the extra symbols artifact for
app/wear. TheAVD tests still install and test the phone APK only.
app/core/src/main/res/values/strings.xml(prefixedwear_)with Polish translations; other locales fall back to English.
AI disclosure
Written with AI assistance (Claude Opus 5.5), reviewed, built and tested on the device by me.
Each commit carries an
Assisted-by: Claude Opus 5.5trailer, asAGENTS.mdasks.