layerctl 0.2.1__tar.gz → 0.2.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. layerctl-0.2.2/PKG-INFO +189 -0
  2. layerctl-0.2.2/README.en.md +161 -0
  3. layerctl-0.2.1/src/layerctl.egg-info/PKG-INFO → layerctl-0.2.2/README.md +25 -34
  4. {layerctl-0.2.1 → layerctl-0.2.2}/pyproject.toml +2 -2
  5. layerctl-0.2.2/src/layerctl.egg-info/PKG-INFO +189 -0
  6. {layerctl-0.2.1 → layerctl-0.2.2}/src/layerctl.egg-info/SOURCES.txt +1 -0
  7. layerctl-0.2.1/PKG-INFO +0 -241
  8. layerctl-0.2.1/README.md +0 -213
  9. {layerctl-0.2.1 → layerctl-0.2.2}/LICENSE +0 -0
  10. {layerctl-0.2.1 → layerctl-0.2.2}/setup.cfg +0 -0
  11. {layerctl-0.2.1 → layerctl-0.2.2}/src/layerctl/__init__.py +0 -0
  12. {layerctl-0.2.1 → layerctl-0.2.2}/src/layerctl/__main__.py +0 -0
  13. {layerctl-0.2.1 → layerctl-0.2.2}/src/layerctl/core.py +0 -0
  14. {layerctl-0.2.1 → layerctl-0.2.2}/src/layerctl/data/layers.tsv +0 -0
  15. {layerctl-0.2.1 → layerctl-0.2.2}/src/layerctl/importers.py +0 -0
  16. {layerctl-0.2.1 → layerctl-0.2.2}/src/layerctl/paths.py +0 -0
  17. {layerctl-0.2.1 → layerctl-0.2.2}/src/layerctl/profiles/__init__.py +0 -0
  18. {layerctl-0.2.1 → layerctl-0.2.2}/src/layerctl/profiles/base.py +0 -0
  19. {layerctl-0.2.1 → layerctl-0.2.2}/src/layerctl/profiles/generic.py +0 -0
  20. {layerctl-0.2.1 → layerctl-0.2.2}/src/layerctl/profiles/raven.py +0 -0
  21. {layerctl-0.2.1 → layerctl-0.2.2}/src/layerctl/profiles/sc53f.py +0 -0
  22. {layerctl-0.2.1 → layerctl-0.2.2}/src/layerctl/profiles/sh53d.py +0 -0
  23. {layerctl-0.2.1 → layerctl-0.2.2}/src/layerctl/stat.py +0 -0
  24. {layerctl-0.2.1 → layerctl-0.2.2}/src/layerctl/tui.py +0 -0
  25. {layerctl-0.2.1 → layerctl-0.2.2}/src/layerctl.egg-info/dependency_links.txt +0 -0
  26. {layerctl-0.2.1 → layerctl-0.2.2}/src/layerctl.egg-info/entry_points.txt +0 -0
  27. {layerctl-0.2.1 → layerctl-0.2.2}/src/layerctl.egg-info/top_level.txt +0 -0
  28. {layerctl-0.2.1 → layerctl-0.2.2}/tests/test_cli.py +0 -0
  29. {layerctl-0.2.1 → layerctl-0.2.2}/tests/test_core.py +0 -0
  30. {layerctl-0.2.1 → layerctl-0.2.2}/tests/test_diff.py +0 -0
  31. {layerctl-0.2.1 → layerctl-0.2.2}/tests/test_import.py +0 -0
  32. {layerctl-0.2.1 → layerctl-0.2.2}/tests/test_main_module.py +0 -0
  33. {layerctl-0.2.1 → layerctl-0.2.2}/tests/test_paths.py +0 -0
  34. {layerctl-0.2.1 → layerctl-0.2.2}/tests/test_plan.py +0 -0
  35. {layerctl-0.2.1 → layerctl-0.2.2}/tests/test_stat.py +0 -0
  36. {layerctl-0.2.1 → layerctl-0.2.2}/tests/test_su_transport.py +0 -0
  37. {layerctl-0.2.1 → layerctl-0.2.2}/tests/test_subcommands.py +0 -0
@@ -0,0 +1,189 @@
1
+ Metadata-Version: 2.4
2
+ Name: layerctl
3
+ Version: 0.2.2
4
+ Summary: Android layer switchboard — 意志(layers.tsv)/観測(observed)/plan-diff-apply
5
+ License-Expression: MIT
6
+ Project-URL: Homepage, https://github.com/tittiesmyluv/layerctl
7
+ Project-URL: Repository, https://github.com/tittiesmyluv/layerctl
8
+ Project-URL: Issues, https://github.com/tittiesmyluv/layerctl/issues
9
+ Keywords: android,adb,shizuku,termux,debloat,bloatware,battery,app-standby,standby-bucket,appops,cli
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Environment :: Console
12
+ Classifier: Intended Audience :: End Users/Desktop
13
+ Classifier: Natural Language :: Japanese
14
+ Classifier: Operating System :: POSIX :: Linux
15
+ Classifier: Operating System :: MacOS
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Programming Language :: Python :: 3.14
22
+ Classifier: Topic :: System :: Systems Administration
23
+ Classifier: Topic :: Utilities
24
+ Requires-Python: >=3.10
25
+ Description-Content-Type: text/markdown
26
+ License-File: LICENSE
27
+ Dynamic: license-file
28
+
29
+ [日本語](https://github.com/tittiesmyluv/layerctl/blob/main/README.md) | English
30
+
31
+ # layerctl
32
+
33
+ ![ci](https://github.com/tittiesmyluv/layerctl/actions/workflows/ci.yml/badge.svg)
34
+ [![PyPI](https://img.shields.io/pypi/v/layerctl)](https://pypi.org/project/layerctl/)
35
+
36
+ **layerctl** classifies every package on a non-root Android device into seven standby
37
+ layers, and applies only the difference between the will (`layers.tsv`) and the observed
38
+ state (`layers.observed.tsv`). Layer changes and cache sweeping (`am kill-all`) are
39
+ measured in separate stages, and the effects are reported as numbers.
40
+
41
+ **Who it's for**: people who want better battery discipline without rooting, and who
42
+ do not want to hand the whole device to bulk uninstallers.
43
+
44
+ **What it isn't**: it does not repair an existing su setup. It is **not a Canta/UAD
45
+ replacement** — the individual operations overlap with existing tools, and the value is
46
+ in the model ([Existing tools](https://github.com/tittiesmyluv/layerctl/blob/main/README.en.md#existing-tools)). Layer `D` needs root, so on a non-root
47
+ shell it is display-only.
48
+
49
+ The pages under `docs/` are written in Japanese.
50
+
51
+ ![layerctl dashboard](https://raw.githubusercontent.com/tittiesmyluv/layerctl/main/assets/dashboard.svg)
52
+
53
+ ## Seed first
54
+
55
+ The bundled `layers.tsv` carries UAD-derived generic defaults. It knows nothing about
56
+ your device. `snapshot` → `seed` is the real procedure: it promotes your observed state
57
+ into the will.
58
+
59
+ Without seeding, `diff` lists 372 packages that are in no will, plus 222 uninstalled —
60
+ 598 rows in total (measured 2026-12-04). That reads as breakage but means *will not
61
+ defined*; `seed` collapses it to zero. `plan` filters to installed packages, so it
62
+ stays safe before seeding too.
63
+
64
+ ## The layer model
65
+
66
+ | Layer | Name | Meaning | Command applied | Persistence |
67
+ |---|---|---|---|---|
68
+ | 0 | untouchable | protected / Doze whitelist | `dumpsys deviceidle whitelist +` | persists |
69
+ | A | daily | daily drivers, restrictions lifted | `appops allow` + bucket back to `working_set` | volatile |
70
+ | B1 | throttled | delayed notifications tolerated | `appops ignore` + `bucket restricted` | volatile |
71
+ | B2 | frequent | notifications kept | `appops allow` + `bucket frequent` | volatile |
72
+ | C1 | dead | disabled | `pm disable-user --user 0` | persists |
73
+ | C2 | pinned | cannot be killed, so restrained | `appops ignore` + `bucket restricted` | volatile |
74
+ | D | greyout | out of reach (root required) | — | excluded |
75
+
76
+ `0` and `C1` are written through `pm disable-user` and the doze whitelist, so nothing
77
+ rewrites them except an OTA. `A`, `B1`, `B2` and `C2` ride standby buckets, which the
78
+ system rewrites on prediction, timeout and usage detection. `--reapply` is therefore a
79
+ restatement, not a convergence: a few residuals are expected to oscillate.
80
+
81
+ `D` emits no commands on a non-root shell. It counts in the model but stays out of
82
+ `plan`.
83
+
84
+ ## Gains, measured in two stages
85
+
86
+ A non-root shell cannot read LMKD logs, so before/after deltas around `apply` are the
87
+ only evidence. Mixing layer commands and `am kill-all` in one measurement destroys the
88
+ attribution, so `apply` runs two stages by default:
89
+
90
+ 1. layer commands only → measure (the effect of layer changes)
91
+ 2. `am kill-all` → measure (the effect of the sweep)
92
+
93
+ Measured layer-command-only runs:
94
+
95
+ | Device | RAM | Free | procs | Commands | MemAvailable | SwapFree |
96
+ |---|---|---|---|---|---|---|
97
+ | Pixel 6 Pro | 12.0 GB | 68% | 700 | am 14 | −40.9 / −3.2 / −1.7 MB | ±0 |
98
+ | AQUOS wish3 | 3.6 GB | 28% | 1257 | pm 167 others | +70.4 MB | +316.3 MB |
99
+ | Galaxy A25 | 3.5 GB | 25% | 827 | am 18 / pm 2 | +36.5 MB | −60.2 MB |
100
+
101
+ Only wish3, carrying 167 `pm disable-user` entries, shows a clear gain (+70.4 MB). A25
102
+ gains +36.5 MB with two `pm` entries; the Pixel loses −40.9 MB with none. Within ±40 MB
103
+ the direction is not stable. Layer commands are not a "free memory" tool — their job is
104
+ changing future behaviour, not freeing pages now.
105
+
106
+ `am kill-all` is a different animal: a large first hit (**+1211.7 MB** on Pixel 6 Pro),
107
+ then decay — median +1.6 MB after convergence, worst swing down to −337.2 MB (wish3).
108
+ Full tables and old measurements: [docs/measurements.md](https://github.com/tittiesmyluv/layerctl/blob/main/docs/measurements.md).
109
+
110
+ ## Existing tools
111
+
112
+ Every individual operation exists elsewhere; the mapping is in
113
+ [docs/comparison.md](https://github.com/tittiesmyluv/layerctl/blob/main/docs/comparison.md). What does not exist elsewhere is the model:
114
+
115
+ | Property | Existing tools | layerctl |
116
+ |---|---|---|
117
+ | An explicit will covering every package to layers | — | `layers.tsv` |
118
+ | Will and observation kept apart | — | `layers.observed.tsv` |
119
+ | Applying only the difference | — | `plan` / `apply` |
120
+ | Effect reported as measurements | — | two-stage `apply` |
121
+ | Device-specific data chased out of code | — | `layerctl.profiles/` + `QUIRKS` |
122
+ | Transports treated as equivalent | one hard-coded path | rish / adb / su |
123
+
124
+ Off-the-shelf parts, new assembly. Architecture diagram and TUI key bindings are in the
125
+ [Japanese README](https://github.com/tittiesmyluv/layerctl/blob/main/README.md).
126
+
127
+ ## Known limits
128
+
129
+ - Bucket layers (`A`, `B1`, `B2`, `C2`) are volatile — the system writes them back, and
130
+ an OTA additionally resets `appops` (recover with `--reapply`).
131
+ - Protected packages (fmm / kgclient / knox.cloudmdm) will not hold `restricted`.
132
+ - `layers.tsv` is the will. `snapshot` never touches it; observations land in
133
+ `layers.observed.tsv`.
134
+ - Some devices keep rewriting particular packages' buckets. Those are recorded in
135
+ `QUIRKS.no_bucket_hold` (93 found on SC-53F in practice) and the bucket claim is
136
+ waived, so `plan` converges to zero.
137
+ - `verify` separates volatile write-backs (normal) from real persistent failures
138
+ (`pm disable-user` / doze whitelist reappearing).
139
+ - The will is per-device. `diff` reports the unseeded gap (598 rows above) instead of
140
+ hiding it.
141
+
142
+ Hardware-measured transport pitfalls are catalogued in [docs/transport.md](https://github.com/tittiesmyluv/layerctl/blob/main/docs/transport.md);
143
+ read it before touching transports.
144
+
145
+ ## Usage
146
+
147
+ Needs Android 11+, `python3` (standard library only, zero dependencies), and one
148
+ transport: `rish` (Shizuku) on-device, `adb` from USB, or `su` (pin a device with
149
+ `ANDROID_SERIAL` when several are attached).
150
+
151
+ ~~~sh
152
+ pipx install layerctl
153
+ layerctl profile # show active profile and detected capabilities
154
+ layerctl snapshot # scan current state into layers.observed.tsv (layers.tsv untouched)
155
+ layerctl seed # promote observations into layers.tsv (the will)
156
+ layerctl diff # show only will-vs-observation drift
157
+ layerctl plan # extract differential commands without running them
158
+ layerctl apply # apply the difference; layer stage / kill-all stage measured apart
159
+ layerctl verify # read-back verification of what was applied
160
+ layerctl reapply # restate everything (post-OTA recovery)
161
+ layerctl # TUI (no subcommand)
162
+ ~~~
163
+
164
+ Live dashboard: `layerctl-stat`.
165
+
166
+ ### From source (developers)
167
+
168
+ ~~~
169
+ git clone https://github.com/tittiesmyluv/layerctl && cd layerctl
170
+ ./layers profile # show active profile and detected capabilities
171
+ ./layers snapshot # scan current state into layers.observed.tsv (layers.tsv untouched)
172
+ ./layers seed # promote observations into layers.tsv (the will)
173
+ ./layers diff # show only will-vs-observation drift
174
+ ./layers plan # extract differential commands without running them
175
+ ./layers apply # apply the difference; layer stage / kill-all stage measured apart
176
+ ./layers verify # read-back verification of what was applied
177
+ ./layers reapply # restate everything (post-OTA recovery)
178
+ ./layers # TUI
179
+ ~~~
180
+
181
+ Machine-readable plan: `./layers plan --json`. Sweep-free run: `./layers apply --no-kill`.
182
+ External debloat lists: `./layers import f [--as C1 | --dry]`. Live dashboard: `layerctl-stat`.
183
+
184
+ Porting to another device means filling one file under `src/layerctl/profiles/`; procedure and field
185
+ meanings are in [docs/porting.md](https://github.com/tittiesmyluv/layerctl/blob/main/docs/porting.md).
186
+
187
+ ## License
188
+
189
+ MIT
@@ -0,0 +1,161 @@
1
+ [日本語](https://github.com/tittiesmyluv/layerctl/blob/main/README.md) | English
2
+
3
+ # layerctl
4
+
5
+ ![ci](https://github.com/tittiesmyluv/layerctl/actions/workflows/ci.yml/badge.svg)
6
+ [![PyPI](https://img.shields.io/pypi/v/layerctl)](https://pypi.org/project/layerctl/)
7
+
8
+ **layerctl** classifies every package on a non-root Android device into seven standby
9
+ layers, and applies only the difference between the will (`layers.tsv`) and the observed
10
+ state (`layers.observed.tsv`). Layer changes and cache sweeping (`am kill-all`) are
11
+ measured in separate stages, and the effects are reported as numbers.
12
+
13
+ **Who it's for**: people who want better battery discipline without rooting, and who
14
+ do not want to hand the whole device to bulk uninstallers.
15
+
16
+ **What it isn't**: it does not repair an existing su setup. It is **not a Canta/UAD
17
+ replacement** — the individual operations overlap with existing tools, and the value is
18
+ in the model ([Existing tools](https://github.com/tittiesmyluv/layerctl/blob/main/README.en.md#existing-tools)). Layer `D` needs root, so on a non-root
19
+ shell it is display-only.
20
+
21
+ The pages under `docs/` are written in Japanese.
22
+
23
+ ![layerctl dashboard](https://raw.githubusercontent.com/tittiesmyluv/layerctl/main/assets/dashboard.svg)
24
+
25
+ ## Seed first
26
+
27
+ The bundled `layers.tsv` carries UAD-derived generic defaults. It knows nothing about
28
+ your device. `snapshot` → `seed` is the real procedure: it promotes your observed state
29
+ into the will.
30
+
31
+ Without seeding, `diff` lists 372 packages that are in no will, plus 222 uninstalled —
32
+ 598 rows in total (measured 2026-12-04). That reads as breakage but means *will not
33
+ defined*; `seed` collapses it to zero. `plan` filters to installed packages, so it
34
+ stays safe before seeding too.
35
+
36
+ ## The layer model
37
+
38
+ | Layer | Name | Meaning | Command applied | Persistence |
39
+ |---|---|---|---|---|
40
+ | 0 | untouchable | protected / Doze whitelist | `dumpsys deviceidle whitelist +` | persists |
41
+ | A | daily | daily drivers, restrictions lifted | `appops allow` + bucket back to `working_set` | volatile |
42
+ | B1 | throttled | delayed notifications tolerated | `appops ignore` + `bucket restricted` | volatile |
43
+ | B2 | frequent | notifications kept | `appops allow` + `bucket frequent` | volatile |
44
+ | C1 | dead | disabled | `pm disable-user --user 0` | persists |
45
+ | C2 | pinned | cannot be killed, so restrained | `appops ignore` + `bucket restricted` | volatile |
46
+ | D | greyout | out of reach (root required) | — | excluded |
47
+
48
+ `0` and `C1` are written through `pm disable-user` and the doze whitelist, so nothing
49
+ rewrites them except an OTA. `A`, `B1`, `B2` and `C2` ride standby buckets, which the
50
+ system rewrites on prediction, timeout and usage detection. `--reapply` is therefore a
51
+ restatement, not a convergence: a few residuals are expected to oscillate.
52
+
53
+ `D` emits no commands on a non-root shell. It counts in the model but stays out of
54
+ `plan`.
55
+
56
+ ## Gains, measured in two stages
57
+
58
+ A non-root shell cannot read LMKD logs, so before/after deltas around `apply` are the
59
+ only evidence. Mixing layer commands and `am kill-all` in one measurement destroys the
60
+ attribution, so `apply` runs two stages by default:
61
+
62
+ 1. layer commands only → measure (the effect of layer changes)
63
+ 2. `am kill-all` → measure (the effect of the sweep)
64
+
65
+ Measured layer-command-only runs:
66
+
67
+ | Device | RAM | Free | procs | Commands | MemAvailable | SwapFree |
68
+ |---|---|---|---|---|---|---|
69
+ | Pixel 6 Pro | 12.0 GB | 68% | 700 | am 14 | −40.9 / −3.2 / −1.7 MB | ±0 |
70
+ | AQUOS wish3 | 3.6 GB | 28% | 1257 | pm 167 others | +70.4 MB | +316.3 MB |
71
+ | Galaxy A25 | 3.5 GB | 25% | 827 | am 18 / pm 2 | +36.5 MB | −60.2 MB |
72
+
73
+ Only wish3, carrying 167 `pm disable-user` entries, shows a clear gain (+70.4 MB). A25
74
+ gains +36.5 MB with two `pm` entries; the Pixel loses −40.9 MB with none. Within ±40 MB
75
+ the direction is not stable. Layer commands are not a "free memory" tool — their job is
76
+ changing future behaviour, not freeing pages now.
77
+
78
+ `am kill-all` is a different animal: a large first hit (**+1211.7 MB** on Pixel 6 Pro),
79
+ then decay — median +1.6 MB after convergence, worst swing down to −337.2 MB (wish3).
80
+ Full tables and old measurements: [docs/measurements.md](https://github.com/tittiesmyluv/layerctl/blob/main/docs/measurements.md).
81
+
82
+ ## Existing tools
83
+
84
+ Every individual operation exists elsewhere; the mapping is in
85
+ [docs/comparison.md](https://github.com/tittiesmyluv/layerctl/blob/main/docs/comparison.md). What does not exist elsewhere is the model:
86
+
87
+ | Property | Existing tools | layerctl |
88
+ |---|---|---|
89
+ | An explicit will covering every package to layers | — | `layers.tsv` |
90
+ | Will and observation kept apart | — | `layers.observed.tsv` |
91
+ | Applying only the difference | — | `plan` / `apply` |
92
+ | Effect reported as measurements | — | two-stage `apply` |
93
+ | Device-specific data chased out of code | — | `layerctl.profiles/` + `QUIRKS` |
94
+ | Transports treated as equivalent | one hard-coded path | rish / adb / su |
95
+
96
+ Off-the-shelf parts, new assembly. Architecture diagram and TUI key bindings are in the
97
+ [Japanese README](https://github.com/tittiesmyluv/layerctl/blob/main/README.md).
98
+
99
+ ## Known limits
100
+
101
+ - Bucket layers (`A`, `B1`, `B2`, `C2`) are volatile — the system writes them back, and
102
+ an OTA additionally resets `appops` (recover with `--reapply`).
103
+ - Protected packages (fmm / kgclient / knox.cloudmdm) will not hold `restricted`.
104
+ - `layers.tsv` is the will. `snapshot` never touches it; observations land in
105
+ `layers.observed.tsv`.
106
+ - Some devices keep rewriting particular packages' buckets. Those are recorded in
107
+ `QUIRKS.no_bucket_hold` (93 found on SC-53F in practice) and the bucket claim is
108
+ waived, so `plan` converges to zero.
109
+ - `verify` separates volatile write-backs (normal) from real persistent failures
110
+ (`pm disable-user` / doze whitelist reappearing).
111
+ - The will is per-device. `diff` reports the unseeded gap (598 rows above) instead of
112
+ hiding it.
113
+
114
+ Hardware-measured transport pitfalls are catalogued in [docs/transport.md](https://github.com/tittiesmyluv/layerctl/blob/main/docs/transport.md);
115
+ read it before touching transports.
116
+
117
+ ## Usage
118
+
119
+ Needs Android 11+, `python3` (standard library only, zero dependencies), and one
120
+ transport: `rish` (Shizuku) on-device, `adb` from USB, or `su` (pin a device with
121
+ `ANDROID_SERIAL` when several are attached).
122
+
123
+ ~~~sh
124
+ pipx install layerctl
125
+ layerctl profile # show active profile and detected capabilities
126
+ layerctl snapshot # scan current state into layers.observed.tsv (layers.tsv untouched)
127
+ layerctl seed # promote observations into layers.tsv (the will)
128
+ layerctl diff # show only will-vs-observation drift
129
+ layerctl plan # extract differential commands without running them
130
+ layerctl apply # apply the difference; layer stage / kill-all stage measured apart
131
+ layerctl verify # read-back verification of what was applied
132
+ layerctl reapply # restate everything (post-OTA recovery)
133
+ layerctl # TUI (no subcommand)
134
+ ~~~
135
+
136
+ Live dashboard: `layerctl-stat`.
137
+
138
+ ### From source (developers)
139
+
140
+ ~~~
141
+ git clone https://github.com/tittiesmyluv/layerctl && cd layerctl
142
+ ./layers profile # show active profile and detected capabilities
143
+ ./layers snapshot # scan current state into layers.observed.tsv (layers.tsv untouched)
144
+ ./layers seed # promote observations into layers.tsv (the will)
145
+ ./layers diff # show only will-vs-observation drift
146
+ ./layers plan # extract differential commands without running them
147
+ ./layers apply # apply the difference; layer stage / kill-all stage measured apart
148
+ ./layers verify # read-back verification of what was applied
149
+ ./layers reapply # restate everything (post-OTA recovery)
150
+ ./layers # TUI
151
+ ~~~
152
+
153
+ Machine-readable plan: `./layers plan --json`. Sweep-free run: `./layers apply --no-kill`.
154
+ External debloat lists: `./layers import f [--as C1 | --dry]`. Live dashboard: `layerctl-stat`.
155
+
156
+ Porting to another device means filling one file under `src/layerctl/profiles/`; procedure and field
157
+ meanings are in [docs/porting.md](https://github.com/tittiesmyluv/layerctl/blob/main/docs/porting.md).
158
+
159
+ ## License
160
+
161
+ MIT
@@ -1,36 +1,9 @@
1
- Metadata-Version: 2.4
2
- Name: layerctl
3
- Version: 0.2.1
4
- Summary: Android layer switchboard — 意志(layers.tsv)/観測(observed)/plan-diff-apply
5
- License-Expression: MIT
6
- Project-URL: Homepage, https://github.com/tittiesmyluv/layerctl
7
- Project-URL: Repository, https://github.com/tittiesmyluv/layerctl
8
- Project-URL: Issues, https://github.com/tittiesmyluv/layerctl/issues
9
- Keywords: android,adb,shizuku,termux,debloat,bloatware,battery,app-standby,standby-bucket,appops,cli
10
- Classifier: Development Status :: 4 - Beta
11
- Classifier: Environment :: Console
12
- Classifier: Intended Audience :: End Users/Desktop
13
- Classifier: Natural Language :: Japanese
14
- Classifier: Operating System :: POSIX :: Linux
15
- Classifier: Operating System :: MacOS
16
- Classifier: Programming Language :: Python :: 3
17
- Classifier: Programming Language :: Python :: 3.10
18
- Classifier: Programming Language :: Python :: 3.11
19
- Classifier: Programming Language :: Python :: 3.12
20
- Classifier: Programming Language :: Python :: 3.13
21
- Classifier: Programming Language :: Python :: 3.14
22
- Classifier: Topic :: System :: Systems Administration
23
- Classifier: Topic :: Utilities
24
- Requires-Python: >=3.10
25
- Description-Content-Type: text/markdown
26
- License-File: LICENSE
27
- Dynamic: license-file
28
-
29
1
  # layerctl
30
2
 
31
- [English](README.en.md) | 日本語
3
+ [English](https://github.com/tittiesmyluv/layerctl/blob/main/README.en.md) | 日本語
32
4
 
33
5
  ![ci](https://github.com/tittiesmyluv/layerctl/actions/workflows/ci.yml/badge.svg)
6
+ [![PyPI](https://img.shields.io/pypi/v/layerctl)](https://pypi.org/project/layerctl/)
34
7
 
35
8
  **layerctl** は、非 root の Android 端末の全パッケージを 7 つの待機層に分類し、
36
9
  意志(`layers.tsv`)と観測(`layers.observed.tsv`)の**差分だけ**を適用する CLI だ。
@@ -41,7 +14,7 @@ Dynamic: license-file
41
14
  置き換えもしない — 個々の操作は既存ツールと重なる(内訳は「既存ツールとの関係」節)。
42
15
  D 層は root が要るので、非 root では表示だけになる。
43
16
 
44
- ![layerctl dashboard](assets/dashboard.svg)
17
+ ![layerctl dashboard](https://raw.githubusercontent.com/tittiesmyluv/layerctl/main/assets/dashboard.svg)
45
18
 
46
19
  同梱の `layers.tsv` は UAD 由来の汎用初期値で、**あなたの端末を知らない**。まず `snapshot` → `seed`
47
20
  で自分の端末の意志を作るのが正規の手順だ。他機種の意志で `apply` しても、意志に無いインストール済み
@@ -75,7 +48,7 @@ D 層は root が要るので、非 root では表示だけになる。
75
48
 
76
49
  `am kill-all` は別物で、初回だけ大きく効き、以降は減衰する。初回 **+1211.7 MB**(Pixel 6 Pro)に
77
50
  対し、収束後の中央値は +1.6 MB、最小は −337.2 MB(wish3)まで振れる。全表・旧計測・読み方は
78
- [docs/measurements.md](docs/measurements.md)。
51
+ [docs/measurements.md](https://github.com/tittiesmyluv/layerctl/blob/main/docs/measurements.md)。
79
52
 
80
53
  ## アーキテクチャ
81
54
 
@@ -141,7 +114,7 @@ flowchart LR
141
114
 
142
115
  ## 既存ツールとの関係
143
116
 
144
- 正直に書く。個々の操作は既存ツールと重なっている — 対応表は [docs/comparison.md](docs/comparison.md)。
117
+ 正直に書く。個々の操作は既存ツールと重なっている — 対応表は [docs/comparison.md](https://github.com/tittiesmyluv/layerctl/blob/main/docs/comparison.md)。
145
118
 
146
119
  **重なっていないのはモデルのほう:**
147
120
 
@@ -159,6 +132,24 @@ flowchart LR
159
132
 
160
133
  ## 使い方
161
134
 
135
+ ~~~sh
136
+ pipx install layerctl
137
+ layerctl profile # 使用中のプロファイルと能力検出を表示
138
+ layerctl snapshot # 現状を走査して layers.observed.tsv に記録(layers.tsv は不変)
139
+ layerctl seed # 観測を layers.tsv(意志)へ昇格
140
+ layerctl diff # 意志と観測のズレだけ表示
141
+ layerctl plan # 差分コマンドだけ抽出。実行しない
142
+ layerctl apply # 差分を適用。層コマンドのみ / kill-all 後の2段で計測
143
+ layerctl verify # 適用結果を read-back 検証。永続の失敗と揮発の書き戻しを分ける
144
+ layerctl reapply # 全件を再主張(OTA 後の復旧用)
145
+ layerctl import f # 外部の debloat リストを取り込む(UAD JSON / TSV / プレーン)
146
+ layerctl # TUI(引数なしで起動)
147
+ ~~~
148
+
149
+ ライブダッシュボードは `layerctl-stat`。
150
+
151
+ ### ソースから(開発者向け)
152
+
162
153
  ~~~
163
154
  git clone https://github.com/tittiesmyluv/layerctl && cd layerctl
164
155
  ./layers profile # 使用中のプロファイルと能力検出を表示
@@ -224,13 +215,13 @@ TUI の操作:
224
215
 
225
216
  実機で確定した地雷 — rish は `2>&1` と `</dev/null` が必須、`timeout` は `--foreground`、
226
217
  `dumpsys euicc` は `econtroller`、`enabled=4` への `pm enable` は monkey で `4→0` に落としてから。
227
- 全表は [docs/transport.md](docs/transport.md)。輸送層を触る前に一度読め。
218
+ 全表は [docs/transport.md](https://github.com/tittiesmyluv/layerctl/blob/main/docs/transport.md)。輸送層を触る前に一度読め。
228
219
 
229
220
  ## 移植
230
221
 
231
222
  端末固有データは **`src/layerctl/profiles/` の1ファイルだけ**。`layerctl.tui` 本体は端末を知らず、輸送層も `layerctl.core.detect()` に閉じている。
232
223
  `generic.py` を雛形に固有値を埋めると `MATCH_MODEL` / `MATCH_PLATFORM` の一致で自動選択され、外れれば `generic` に落ちる。
233
- 手順と欄の意味は [docs/porting.md](docs/porting.md)。
224
+ 手順と欄の意味は [docs/porting.md](https://github.com/tittiesmyluv/layerctl/blob/main/docs/porting.md)。
234
225
 
235
226
  ~~~
236
227
  cp src/layerctl/profiles/generic.py src/layerctl/profiles/pixel9.py
@@ -4,9 +4,9 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "layerctl"
7
- version = "0.2.1"
7
+ version = "0.2.2"
8
8
  description = "Android layer switchboard — 意志(layers.tsv)/観測(observed)/plan-diff-apply"
9
- readme = "README.md"
9
+ readme = "README.en.md"
10
10
  requires-python = ">=3.10"
11
11
  license = "MIT"
12
12
  license-files = ["LICENSE"]
@@ -0,0 +1,189 @@
1
+ Metadata-Version: 2.4
2
+ Name: layerctl
3
+ Version: 0.2.2
4
+ Summary: Android layer switchboard — 意志(layers.tsv)/観測(observed)/plan-diff-apply
5
+ License-Expression: MIT
6
+ Project-URL: Homepage, https://github.com/tittiesmyluv/layerctl
7
+ Project-URL: Repository, https://github.com/tittiesmyluv/layerctl
8
+ Project-URL: Issues, https://github.com/tittiesmyluv/layerctl/issues
9
+ Keywords: android,adb,shizuku,termux,debloat,bloatware,battery,app-standby,standby-bucket,appops,cli
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Environment :: Console
12
+ Classifier: Intended Audience :: End Users/Desktop
13
+ Classifier: Natural Language :: Japanese
14
+ Classifier: Operating System :: POSIX :: Linux
15
+ Classifier: Operating System :: MacOS
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Programming Language :: Python :: 3.14
22
+ Classifier: Topic :: System :: Systems Administration
23
+ Classifier: Topic :: Utilities
24
+ Requires-Python: >=3.10
25
+ Description-Content-Type: text/markdown
26
+ License-File: LICENSE
27
+ Dynamic: license-file
28
+
29
+ [日本語](https://github.com/tittiesmyluv/layerctl/blob/main/README.md) | English
30
+
31
+ # layerctl
32
+
33
+ ![ci](https://github.com/tittiesmyluv/layerctl/actions/workflows/ci.yml/badge.svg)
34
+ [![PyPI](https://img.shields.io/pypi/v/layerctl)](https://pypi.org/project/layerctl/)
35
+
36
+ **layerctl** classifies every package on a non-root Android device into seven standby
37
+ layers, and applies only the difference between the will (`layers.tsv`) and the observed
38
+ state (`layers.observed.tsv`). Layer changes and cache sweeping (`am kill-all`) are
39
+ measured in separate stages, and the effects are reported as numbers.
40
+
41
+ **Who it's for**: people who want better battery discipline without rooting, and who
42
+ do not want to hand the whole device to bulk uninstallers.
43
+
44
+ **What it isn't**: it does not repair an existing su setup. It is **not a Canta/UAD
45
+ replacement** — the individual operations overlap with existing tools, and the value is
46
+ in the model ([Existing tools](https://github.com/tittiesmyluv/layerctl/blob/main/README.en.md#existing-tools)). Layer `D` needs root, so on a non-root
47
+ shell it is display-only.
48
+
49
+ The pages under `docs/` are written in Japanese.
50
+
51
+ ![layerctl dashboard](https://raw.githubusercontent.com/tittiesmyluv/layerctl/main/assets/dashboard.svg)
52
+
53
+ ## Seed first
54
+
55
+ The bundled `layers.tsv` carries UAD-derived generic defaults. It knows nothing about
56
+ your device. `snapshot` → `seed` is the real procedure: it promotes your observed state
57
+ into the will.
58
+
59
+ Without seeding, `diff` lists 372 packages that are in no will, plus 222 uninstalled —
60
+ 598 rows in total (measured 2026-12-04). That reads as breakage but means *will not
61
+ defined*; `seed` collapses it to zero. `plan` filters to installed packages, so it
62
+ stays safe before seeding too.
63
+
64
+ ## The layer model
65
+
66
+ | Layer | Name | Meaning | Command applied | Persistence |
67
+ |---|---|---|---|---|
68
+ | 0 | untouchable | protected / Doze whitelist | `dumpsys deviceidle whitelist +` | persists |
69
+ | A | daily | daily drivers, restrictions lifted | `appops allow` + bucket back to `working_set` | volatile |
70
+ | B1 | throttled | delayed notifications tolerated | `appops ignore` + `bucket restricted` | volatile |
71
+ | B2 | frequent | notifications kept | `appops allow` + `bucket frequent` | volatile |
72
+ | C1 | dead | disabled | `pm disable-user --user 0` | persists |
73
+ | C2 | pinned | cannot be killed, so restrained | `appops ignore` + `bucket restricted` | volatile |
74
+ | D | greyout | out of reach (root required) | — | excluded |
75
+
76
+ `0` and `C1` are written through `pm disable-user` and the doze whitelist, so nothing
77
+ rewrites them except an OTA. `A`, `B1`, `B2` and `C2` ride standby buckets, which the
78
+ system rewrites on prediction, timeout and usage detection. `--reapply` is therefore a
79
+ restatement, not a convergence: a few residuals are expected to oscillate.
80
+
81
+ `D` emits no commands on a non-root shell. It counts in the model but stays out of
82
+ `plan`.
83
+
84
+ ## Gains, measured in two stages
85
+
86
+ A non-root shell cannot read LMKD logs, so before/after deltas around `apply` are the
87
+ only evidence. Mixing layer commands and `am kill-all` in one measurement destroys the
88
+ attribution, so `apply` runs two stages by default:
89
+
90
+ 1. layer commands only → measure (the effect of layer changes)
91
+ 2. `am kill-all` → measure (the effect of the sweep)
92
+
93
+ Measured layer-command-only runs:
94
+
95
+ | Device | RAM | Free | procs | Commands | MemAvailable | SwapFree |
96
+ |---|---|---|---|---|---|---|
97
+ | Pixel 6 Pro | 12.0 GB | 68% | 700 | am 14 | −40.9 / −3.2 / −1.7 MB | ±0 |
98
+ | AQUOS wish3 | 3.6 GB | 28% | 1257 | pm 167 others | +70.4 MB | +316.3 MB |
99
+ | Galaxy A25 | 3.5 GB | 25% | 827 | am 18 / pm 2 | +36.5 MB | −60.2 MB |
100
+
101
+ Only wish3, carrying 167 `pm disable-user` entries, shows a clear gain (+70.4 MB). A25
102
+ gains +36.5 MB with two `pm` entries; the Pixel loses −40.9 MB with none. Within ±40 MB
103
+ the direction is not stable. Layer commands are not a "free memory" tool — their job is
104
+ changing future behaviour, not freeing pages now.
105
+
106
+ `am kill-all` is a different animal: a large first hit (**+1211.7 MB** on Pixel 6 Pro),
107
+ then decay — median +1.6 MB after convergence, worst swing down to −337.2 MB (wish3).
108
+ Full tables and old measurements: [docs/measurements.md](https://github.com/tittiesmyluv/layerctl/blob/main/docs/measurements.md).
109
+
110
+ ## Existing tools
111
+
112
+ Every individual operation exists elsewhere; the mapping is in
113
+ [docs/comparison.md](https://github.com/tittiesmyluv/layerctl/blob/main/docs/comparison.md). What does not exist elsewhere is the model:
114
+
115
+ | Property | Existing tools | layerctl |
116
+ |---|---|---|
117
+ | An explicit will covering every package to layers | — | `layers.tsv` |
118
+ | Will and observation kept apart | — | `layers.observed.tsv` |
119
+ | Applying only the difference | — | `plan` / `apply` |
120
+ | Effect reported as measurements | — | two-stage `apply` |
121
+ | Device-specific data chased out of code | — | `layerctl.profiles/` + `QUIRKS` |
122
+ | Transports treated as equivalent | one hard-coded path | rish / adb / su |
123
+
124
+ Off-the-shelf parts, new assembly. Architecture diagram and TUI key bindings are in the
125
+ [Japanese README](https://github.com/tittiesmyluv/layerctl/blob/main/README.md).
126
+
127
+ ## Known limits
128
+
129
+ - Bucket layers (`A`, `B1`, `B2`, `C2`) are volatile — the system writes them back, and
130
+ an OTA additionally resets `appops` (recover with `--reapply`).
131
+ - Protected packages (fmm / kgclient / knox.cloudmdm) will not hold `restricted`.
132
+ - `layers.tsv` is the will. `snapshot` never touches it; observations land in
133
+ `layers.observed.tsv`.
134
+ - Some devices keep rewriting particular packages' buckets. Those are recorded in
135
+ `QUIRKS.no_bucket_hold` (93 found on SC-53F in practice) and the bucket claim is
136
+ waived, so `plan` converges to zero.
137
+ - `verify` separates volatile write-backs (normal) from real persistent failures
138
+ (`pm disable-user` / doze whitelist reappearing).
139
+ - The will is per-device. `diff` reports the unseeded gap (598 rows above) instead of
140
+ hiding it.
141
+
142
+ Hardware-measured transport pitfalls are catalogued in [docs/transport.md](https://github.com/tittiesmyluv/layerctl/blob/main/docs/transport.md);
143
+ read it before touching transports.
144
+
145
+ ## Usage
146
+
147
+ Needs Android 11+, `python3` (standard library only, zero dependencies), and one
148
+ transport: `rish` (Shizuku) on-device, `adb` from USB, or `su` (pin a device with
149
+ `ANDROID_SERIAL` when several are attached).
150
+
151
+ ~~~sh
152
+ pipx install layerctl
153
+ layerctl profile # show active profile and detected capabilities
154
+ layerctl snapshot # scan current state into layers.observed.tsv (layers.tsv untouched)
155
+ layerctl seed # promote observations into layers.tsv (the will)
156
+ layerctl diff # show only will-vs-observation drift
157
+ layerctl plan # extract differential commands without running them
158
+ layerctl apply # apply the difference; layer stage / kill-all stage measured apart
159
+ layerctl verify # read-back verification of what was applied
160
+ layerctl reapply # restate everything (post-OTA recovery)
161
+ layerctl # TUI (no subcommand)
162
+ ~~~
163
+
164
+ Live dashboard: `layerctl-stat`.
165
+
166
+ ### From source (developers)
167
+
168
+ ~~~
169
+ git clone https://github.com/tittiesmyluv/layerctl && cd layerctl
170
+ ./layers profile # show active profile and detected capabilities
171
+ ./layers snapshot # scan current state into layers.observed.tsv (layers.tsv untouched)
172
+ ./layers seed # promote observations into layers.tsv (the will)
173
+ ./layers diff # show only will-vs-observation drift
174
+ ./layers plan # extract differential commands without running them
175
+ ./layers apply # apply the difference; layer stage / kill-all stage measured apart
176
+ ./layers verify # read-back verification of what was applied
177
+ ./layers reapply # restate everything (post-OTA recovery)
178
+ ./layers # TUI
179
+ ~~~
180
+
181
+ Machine-readable plan: `./layers plan --json`. Sweep-free run: `./layers apply --no-kill`.
182
+ External debloat lists: `./layers import f [--as C1 | --dry]`. Live dashboard: `layerctl-stat`.
183
+
184
+ Porting to another device means filling one file under `src/layerctl/profiles/`; procedure and field
185
+ meanings are in [docs/porting.md](https://github.com/tittiesmyluv/layerctl/blob/main/docs/porting.md).
186
+
187
+ ## License
188
+
189
+ MIT
@@ -1,4 +1,5 @@
1
1
  LICENSE
2
+ README.en.md
2
3
  README.md
3
4
  pyproject.toml
4
5
  src/layerctl/__init__.py
layerctl-0.2.1/PKG-INFO DELETED
@@ -1,241 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: layerctl
3
- Version: 0.2.1
4
- Summary: Android layer switchboard — 意志(layers.tsv)/観測(observed)/plan-diff-apply
5
- License-Expression: MIT
6
- Project-URL: Homepage, https://github.com/tittiesmyluv/layerctl
7
- Project-URL: Repository, https://github.com/tittiesmyluv/layerctl
8
- Project-URL: Issues, https://github.com/tittiesmyluv/layerctl/issues
9
- Keywords: android,adb,shizuku,termux,debloat,bloatware,battery,app-standby,standby-bucket,appops,cli
10
- Classifier: Development Status :: 4 - Beta
11
- Classifier: Environment :: Console
12
- Classifier: Intended Audience :: End Users/Desktop
13
- Classifier: Natural Language :: Japanese
14
- Classifier: Operating System :: POSIX :: Linux
15
- Classifier: Operating System :: MacOS
16
- Classifier: Programming Language :: Python :: 3
17
- Classifier: Programming Language :: Python :: 3.10
18
- Classifier: Programming Language :: Python :: 3.11
19
- Classifier: Programming Language :: Python :: 3.12
20
- Classifier: Programming Language :: Python :: 3.13
21
- Classifier: Programming Language :: Python :: 3.14
22
- Classifier: Topic :: System :: Systems Administration
23
- Classifier: Topic :: Utilities
24
- Requires-Python: >=3.10
25
- Description-Content-Type: text/markdown
26
- License-File: LICENSE
27
- Dynamic: license-file
28
-
29
- # layerctl
30
-
31
- [English](README.en.md) | 日本語
32
-
33
- ![ci](https://github.com/tittiesmyluv/layerctl/actions/workflows/ci.yml/badge.svg)
34
-
35
- **layerctl** は、非 root の Android 端末の全パッケージを 7 つの待機層に分類し、
36
- 意志(`layers.tsv`)と観測(`layers.observed.tsv`)の**差分だけ**を適用する CLI だ。
37
- 層コマンドの効果と掃除(`am kill-all`)の効果を**分けて実測**し、数字で報告する。
38
-
39
- **誰向け**: バッテリ持ちは磨きたいが root は取らず、全面削除(Canta/UAD)にも預けたくない人。
40
- **何ではない**: root は要求しない。既存の su 環境を直す道具でもない。Canta/UAD の代替でも、
41
- 置き換えもしない — 個々の操作は既存ツールと重なる(内訳は「既存ツールとの関係」節)。
42
- D 層は root が要るので、非 root では表示だけになる。
43
-
44
- ![layerctl dashboard](assets/dashboard.svg)
45
-
46
- 同梱の `layers.tsv` は UAD 由来の汎用初期値で、**あなたの端末を知らない**。まず `snapshot` → `seed`
47
- で自分の端末の意志を作るのが正規の手順だ。他機種の意志で `apply` しても、意志に無いインストール済み
48
- アプリは差分に出続ける — `seed` で消える。`plan` は installed で絞るので実行は安全。
49
-
50
- 未 `seed` の状態で `diff` を打つと、意志に無い 372 本と未インストール 222 本が差分として並ぶ
51
- (2026-12-04 実測、計 598)。故障ではなく「意志が未定義」の表示で、`seed` 一発で 0 に収束する。
52
-
53
- ## 効果: 2段で測る
54
-
55
- 非root では `dmesg` も LMKD のログも読めない。プロセスが何MB解放されたかを知る手段が無い。
56
- **だから適用前後の差分が唯一の物証になる。** ただし `am kill-all` を同じバッチに混ぜると、
57
- 解放が層変更のせいなのか掃除のせいなのか区別できない。そこで `apply` は2段で測る:
58
-
59
- 1. 層コマンドだけを適用 → 計測(層変更そのものの効果)
60
- 2. `am kill-all` → 計測(掃除の効果)
61
-
62
- `--no-kill` で2段目を止められる。
63
-
64
- ### 実測: 層コマンドのみ — 小さく、向きも一定しない
65
-
66
- | 端末 | RAM | 空き | procs | 中身 | MemAvailable | SwapFree |
67
- |---|---|---|---|---|---|---|
68
- | Pixel 6 Pro | 12.0 GB | 68% | 700 | am 14 | −40.9 / −3.2 / −1.7 MB | ±0 |
69
- | AQUOS wish3 | 3.6 GB | 28% | 1257 | pm 167 他 | +70.4 MB | +316.3 MB |
70
- | Galaxy A25 | 3.5 GB | 25% | 827 | am 18 / pm 2 | +36.5 MB | −60.2 MB |
71
-
72
- `pm disable-user` が167本ある wish3 だけはっきりプラス(+70.4 MB)。だが A25 は `pm` が2本でも
73
- +36.5 MB、Pixel は `pm` ゼロで −40.9 MB。**±40 MB の範囲で、向きは安定しない。**
74
- 層コマンドを「解放装置」と呼ぶのは無理がある。
75
-
76
- `am kill-all` は別物で、初回だけ大きく効き、以降は減衰する。初回 **+1211.7 MB**(Pixel 6 Pro)に
77
- 対し、収束後の中央値は +1.6 MB、最小は −337.2 MB(wish3)まで振れる。全表・旧計測・読み方は
78
- [docs/measurements.md](docs/measurements.md)。
79
-
80
- ## アーキテクチャ
81
-
82
- ~~~mermaid
83
- flowchart LR
84
- subgraph host["ホスト: Termux / macOS / Linux"]
85
- TUI["layerctl.tui<br/>層スイッチボード"]
86
- STAT["layerctl.stat<br/>ライブダッシュボード"]
87
- CORE["layerctl.core<br/>detect / snapshot / rates"]
88
- PROF["layerctl.profiles/<br/>端末固有データ + QUIRKS"]
89
- end
90
- subgraph dev["Android 端末 (非root)"]
91
- RISH["rish (Shizuku)"]
92
- ADB["adbd (USB)"]
93
- SU["su (任意)"]
94
- SH["/system/bin/sh uid 2000"]
95
- end
96
- TUI --> CORE
97
- STAT --> CORE
98
- TUI --> PROF
99
- CORE -->|自動選択| RISH
100
- CORE -->|自動選択| ADB
101
- CORE -->|自動選択| SU
102
- RISH --> SH
103
- ADB --> SH
104
- SU --> SH
105
- SH --> API["pm / cmd appops / dumpsys / deviceidle"]
106
- ~~~
107
-
108
- 本体は端末を知らない。輸送層とプロファイルの両方が差し替え可能で、
109
- `layerctl.tui` と `layerctl.stat` は `layerctl.core` の口だけを見る。
110
-
111
- ## 必要環境
112
-
113
- - Android 11 以上
114
- - `python3`(標準ライブラリのみ。依存なし)
115
- - 輸送層のいずれか:
116
- - `rish`(Shizuku を起動し `~/rish` に配置 + `chmod +x`)— 端末上で完結
117
- - `adb`(USB デバッグ)— PC から。`ANDROID_SERIAL` でデバイスを固定
118
- - macOS: `brew install android-platform-tools` などで導入。初回は端末側で RSA 承認が要る
119
- - `su`(root 経由。adb があれば `adb -s <serial> exec-out "su -c '<cmd>'"`。Termux 同居で固定するなら `VENICE_SU_LOCAL=1`)
120
- - `su 0 id` は対話プロンプトに落ちる個体がある。`su -c` を使え
121
- - root 不要
122
-
123
- ## 層モデル
124
-
125
- | 層 | 名前 | 意味 | 適用コマンド | 持続性 |
126
- |---|---|---|---|---|
127
- | 0 | untouchable | 不可侵 / Doze 保護 | `dumpsys deviceidle whitelist +` | 持続 |
128
- | A | daily | 常用 / 制限を解除 | `appops allow` + bucket を `working_set` へ戻す | 揮発 |
129
- | B1 | throttled | 通知遅延可 | `appops ignore` + `bucket restricted` | 揮発 |
130
- | B2 | frequent | 通知維持 | `appops allow` + `bucket frequent` | 揮発 |
131
- | C1 | dead | 無効化 | `pm disable-user --user 0` | 持続 |
132
- | C2 | pinned | 殺せないので縛る | `appops ignore` + `bucket restricted` | 揮発 |
133
- | D | greyout | 手が届かない(root 必須) | — | 対象外 |
134
-
135
- `0` と `C1` は `pm disable-user` と `deviceidle whitelist` で書かれるため
136
- **OTA 以外で崩れない**。`A` `B1` `B2` `C2` は bucket 系で**揮発する**。
137
- だから `--reapply` は収束演算ではなく**再主張**であり、残差は常に数本残って振動する。
138
-
139
- `D` は root が要るため非rootでは1本もコマンドを出さない。**表示専用の層**として数え、
140
- `plan` の対象からは外れる。
141
-
142
- ## 既存ツールとの関係
143
-
144
- 正直に書く。個々の操作は既存ツールと重なっている — 対応表は [docs/comparison.md](docs/comparison.md)。
145
-
146
- **重なっていないのはモデルのほう:**
147
-
148
- | 性質 | 既存 | layerctl |
149
- |---|---|---|
150
- | 全パッケージを層に固定した「意志」を持つ | — | `layers.tsv` |
151
- | 意志と観測を分離する | — | `layers.observed.tsv` |
152
- | 差分だけを適用する | — | `plan` / `apply` |
153
- | 適用の効果を実測で報告する | — | `apply` の2段計測 |
154
- | 端末固有データをコードから追い出す | — | `layerctl.profiles/` + `QUIRKS` |
155
- | 輸送層を等価に抽象する | どれか1経路に固定 | rish / adb / su |
156
-
157
- 要するに **部品は既製品、組み立て方が新しい。** Greenify の代替ではなく
158
- 「Android のアプリ層を宣言的に管理する」道具として使え。
159
-
160
- ## 使い方
161
-
162
- ~~~
163
- git clone https://github.com/tittiesmyluv/layerctl && cd layerctl
164
- ./layers profile # 使用中のプロファイルと能力検出を表示
165
- ./layers snapshot # 現状を走査して layers.observed.tsv に記録(layers.tsv は不変)
166
- ./layers seed # 観測を layers.tsv(意志)へ昇格
167
- ./layers diff # 意志と観測のズレだけ表示
168
- ./layers plan # 差分コマンドだけ抽出。実行しない
169
- ./layers apply # 差分を適用。層コマンドのみ / kill-all 後の2段で計測
170
- ./layers verify # 適用結果を read-back 検証。永続の失敗と揮発の書き戻しを分ける
171
- ./layers reapply # 全件を再主張(OTA 後の復旧用)
172
- ./layers import f # 外部の debloat リストを取り込む(UAD JSON / TSV / プレーン)
173
- ./layers # TUI
174
- ~~~
175
-
176
- `apply` は適用後に read-back して検証する。**揮発コマンドが書き戻されたのか、
177
- 永続コマンドが本当に効かなかったのかを分けて報告する**(揮発は異常ではない)。
178
-
179
- ~~~sh
180
- ./layers plan --json # 差分を JSON で出す(他ツールから食える)
181
- ./layers apply --no-kill # 掃除を撃たず、層コマンドだけ
182
- ./layers apply --repeat 7 # 掃除を7回サンプルして中央値・最小・最大を出す
183
- ./layers import f --as C1 # verdict を無視して全部 C1 として取り込む
184
- ./layers import f --dry # プレビューのみ
185
- ~~~
186
-
187
- ライブダッシュボード:
188
-
189
- ~~~
190
- layerctl-stat # curses。メモリ / swap / CPU / RX / TX をスパークライン表示
191
- layerctl-stat --dump # 1フレームを素テキストで(CI / 検品用)
192
- ~~~
193
-
194
- TUI の操作:
195
-
196
- | キー | 動作 |
197
- |---|---|
198
- | `j` `k` | 上下移動 |
199
- | `tab` | 層パネル / パッケージパネルの切替 |
200
- | `space` | 層を巡回(0→A→B1→B2→C1→C2→D→0) |
201
- | `a` | 選択中の1本を適用(risk>=3 は `y` 確認) |
202
- | `A` | staged 全件を一括適用 |
203
- | `w` | layers.tsv に保存 |
204
- | `R` | 全件を再主張 |
205
- | `q` | 保存して終了 |
206
-
207
- ## 既知の限界
208
-
209
- - bucket 系の層は揮発する。システムが予測・時間切れ・利用検知で書き戻す
210
- - 保護パッケージ(fmm / kgclient / knox.cloudmdm)は `restricted` を保持しない
211
- - `EXEMPTED` は doze whitelist と同義ではない
212
- - OTA は `appops` をリセットする。`--reapply` で復旧する
213
- - `layers.tsv` は**意志**。`snapshot` は書き換えず、観測は `layers.observed.tsv` に隔離される
214
- - `seed` 直後の初回 `plan` は、bucket5(EXEMPTED) を whitelist へ昇格させる一回性の
215
- 正規化を含む。適用後は 0 に収束する(実測: 116 cmd → 0)
216
- - 書き戻される個体は `QUIRKS.no_bucket_hold` に記録し、bucket の主張を諦める。
217
- SC-53F では93本を実測で特定した。諦めた分だけ `plan` は 0 に収束する
218
- - `verify` の『揮発で書き戻された』は異常ではない。`am set-standby-bucket` と
219
- `cmd appops set` は Android が書き戻す。`pm disable-user` と
220
- `deviceidle whitelist` は持続するので、こちらが残ったときだけ本当の失敗
221
- - 意志は端末固有。`plan` は installed で絞る(`diff` は未インストール分を別枠で件数出し)
222
-
223
- ## 実測で確定した地雷
224
-
225
- 実機で確定した地雷 — rish は `2>&1` と `</dev/null` が必須、`timeout` は `--foreground`、
226
- `dumpsys euicc` は `econtroller`、`enabled=4` への `pm enable` は monkey で `4→0` に落としてから。
227
- 全表は [docs/transport.md](docs/transport.md)。輸送層を触る前に一度読め。
228
-
229
- ## 移植
230
-
231
- 端末固有データは **`src/layerctl/profiles/` の1ファイルだけ**。`layerctl.tui` 本体は端末を知らず、輸送層も `layerctl.core.detect()` に閉じている。
232
- `generic.py` を雛形に固有値を埋めると `MATCH_MODEL` / `MATCH_PLATFORM` の一致で自動選択され、外れれば `generic` に落ちる。
233
- 手順と欄の意味は [docs/porting.md](docs/porting.md)。
234
-
235
- ~~~
236
- cp src/layerctl/profiles/generic.py src/layerctl/profiles/pixel9.py
237
- ~~~
238
-
239
- ## License
240
-
241
- MIT
layerctl-0.2.1/README.md DELETED
@@ -1,213 +0,0 @@
1
- # layerctl
2
-
3
- [English](README.en.md) | 日本語
4
-
5
- ![ci](https://github.com/tittiesmyluv/layerctl/actions/workflows/ci.yml/badge.svg)
6
-
7
- **layerctl** は、非 root の Android 端末の全パッケージを 7 つの待機層に分類し、
8
- 意志(`layers.tsv`)と観測(`layers.observed.tsv`)の**差分だけ**を適用する CLI だ。
9
- 層コマンドの効果と掃除(`am kill-all`)の効果を**分けて実測**し、数字で報告する。
10
-
11
- **誰向け**: バッテリ持ちは磨きたいが root は取らず、全面削除(Canta/UAD)にも預けたくない人。
12
- **何ではない**: root は要求しない。既存の su 環境を直す道具でもない。Canta/UAD の代替でも、
13
- 置き換えもしない — 個々の操作は既存ツールと重なる(内訳は「既存ツールとの関係」節)。
14
- D 層は root が要るので、非 root では表示だけになる。
15
-
16
- ![layerctl dashboard](assets/dashboard.svg)
17
-
18
- 同梱の `layers.tsv` は UAD 由来の汎用初期値で、**あなたの端末を知らない**。まず `snapshot` → `seed`
19
- で自分の端末の意志を作るのが正規の手順だ。他機種の意志で `apply` しても、意志に無いインストール済み
20
- アプリは差分に出続ける — `seed` で消える。`plan` は installed で絞るので実行は安全。
21
-
22
- 未 `seed` の状態で `diff` を打つと、意志に無い 372 本と未インストール 222 本が差分として並ぶ
23
- (2026-12-04 実測、計 598)。故障ではなく「意志が未定義」の表示で、`seed` 一発で 0 に収束する。
24
-
25
- ## 効果: 2段で測る
26
-
27
- 非root では `dmesg` も LMKD のログも読めない。プロセスが何MB解放されたかを知る手段が無い。
28
- **だから適用前後の差分が唯一の物証になる。** ただし `am kill-all` を同じバッチに混ぜると、
29
- 解放が層変更のせいなのか掃除のせいなのか区別できない。そこで `apply` は2段で測る:
30
-
31
- 1. 層コマンドだけを適用 → 計測(層変更そのものの効果)
32
- 2. `am kill-all` → 計測(掃除の効果)
33
-
34
- `--no-kill` で2段目を止められる。
35
-
36
- ### 実測: 層コマンドのみ — 小さく、向きも一定しない
37
-
38
- | 端末 | RAM | 空き | procs | 中身 | MemAvailable | SwapFree |
39
- |---|---|---|---|---|---|---|
40
- | Pixel 6 Pro | 12.0 GB | 68% | 700 | am 14 | −40.9 / −3.2 / −1.7 MB | ±0 |
41
- | AQUOS wish3 | 3.6 GB | 28% | 1257 | pm 167 他 | +70.4 MB | +316.3 MB |
42
- | Galaxy A25 | 3.5 GB | 25% | 827 | am 18 / pm 2 | +36.5 MB | −60.2 MB |
43
-
44
- `pm disable-user` が167本ある wish3 だけはっきりプラス(+70.4 MB)。だが A25 は `pm` が2本でも
45
- +36.5 MB、Pixel は `pm` ゼロで −40.9 MB。**±40 MB の範囲で、向きは安定しない。**
46
- 層コマンドを「解放装置」と呼ぶのは無理がある。
47
-
48
- `am kill-all` は別物で、初回だけ大きく効き、以降は減衰する。初回 **+1211.7 MB**(Pixel 6 Pro)に
49
- 対し、収束後の中央値は +1.6 MB、最小は −337.2 MB(wish3)まで振れる。全表・旧計測・読み方は
50
- [docs/measurements.md](docs/measurements.md)。
51
-
52
- ## アーキテクチャ
53
-
54
- ~~~mermaid
55
- flowchart LR
56
- subgraph host["ホスト: Termux / macOS / Linux"]
57
- TUI["layerctl.tui<br/>層スイッチボード"]
58
- STAT["layerctl.stat<br/>ライブダッシュボード"]
59
- CORE["layerctl.core<br/>detect / snapshot / rates"]
60
- PROF["layerctl.profiles/<br/>端末固有データ + QUIRKS"]
61
- end
62
- subgraph dev["Android 端末 (非root)"]
63
- RISH["rish (Shizuku)"]
64
- ADB["adbd (USB)"]
65
- SU["su (任意)"]
66
- SH["/system/bin/sh uid 2000"]
67
- end
68
- TUI --> CORE
69
- STAT --> CORE
70
- TUI --> PROF
71
- CORE -->|自動選択| RISH
72
- CORE -->|自動選択| ADB
73
- CORE -->|自動選択| SU
74
- RISH --> SH
75
- ADB --> SH
76
- SU --> SH
77
- SH --> API["pm / cmd appops / dumpsys / deviceidle"]
78
- ~~~
79
-
80
- 本体は端末を知らない。輸送層とプロファイルの両方が差し替え可能で、
81
- `layerctl.tui` と `layerctl.stat` は `layerctl.core` の口だけを見る。
82
-
83
- ## 必要環境
84
-
85
- - Android 11 以上
86
- - `python3`(標準ライブラリのみ。依存なし)
87
- - 輸送層のいずれか:
88
- - `rish`(Shizuku を起動し `~/rish` に配置 + `chmod +x`)— 端末上で完結
89
- - `adb`(USB デバッグ)— PC から。`ANDROID_SERIAL` でデバイスを固定
90
- - macOS: `brew install android-platform-tools` などで導入。初回は端末側で RSA 承認が要る
91
- - `su`(root 経由。adb があれば `adb -s <serial> exec-out "su -c '<cmd>'"`。Termux 同居で固定するなら `VENICE_SU_LOCAL=1`)
92
- - `su 0 id` は対話プロンプトに落ちる個体がある。`su -c` を使え
93
- - root 不要
94
-
95
- ## 層モデル
96
-
97
- | 層 | 名前 | 意味 | 適用コマンド | 持続性 |
98
- |---|---|---|---|---|
99
- | 0 | untouchable | 不可侵 / Doze 保護 | `dumpsys deviceidle whitelist +` | 持続 |
100
- | A | daily | 常用 / 制限を解除 | `appops allow` + bucket を `working_set` へ戻す | 揮発 |
101
- | B1 | throttled | 通知遅延可 | `appops ignore` + `bucket restricted` | 揮発 |
102
- | B2 | frequent | 通知維持 | `appops allow` + `bucket frequent` | 揮発 |
103
- | C1 | dead | 無効化 | `pm disable-user --user 0` | 持続 |
104
- | C2 | pinned | 殺せないので縛る | `appops ignore` + `bucket restricted` | 揮発 |
105
- | D | greyout | 手が届かない(root 必須) | — | 対象外 |
106
-
107
- `0` と `C1` は `pm disable-user` と `deviceidle whitelist` で書かれるため
108
- **OTA 以外で崩れない**。`A` `B1` `B2` `C2` は bucket 系で**揮発する**。
109
- だから `--reapply` は収束演算ではなく**再主張**であり、残差は常に数本残って振動する。
110
-
111
- `D` は root が要るため非rootでは1本もコマンドを出さない。**表示専用の層**として数え、
112
- `plan` の対象からは外れる。
113
-
114
- ## 既存ツールとの関係
115
-
116
- 正直に書く。個々の操作は既存ツールと重なっている — 対応表は [docs/comparison.md](docs/comparison.md)。
117
-
118
- **重なっていないのはモデルのほう:**
119
-
120
- | 性質 | 既存 | layerctl |
121
- |---|---|---|
122
- | 全パッケージを層に固定した「意志」を持つ | — | `layers.tsv` |
123
- | 意志と観測を分離する | — | `layers.observed.tsv` |
124
- | 差分だけを適用する | — | `plan` / `apply` |
125
- | 適用の効果を実測で報告する | — | `apply` の2段計測 |
126
- | 端末固有データをコードから追い出す | — | `layerctl.profiles/` + `QUIRKS` |
127
- | 輸送層を等価に抽象する | どれか1経路に固定 | rish / adb / su |
128
-
129
- 要するに **部品は既製品、組み立て方が新しい。** Greenify の代替ではなく
130
- 「Android のアプリ層を宣言的に管理する」道具として使え。
131
-
132
- ## 使い方
133
-
134
- ~~~
135
- git clone https://github.com/tittiesmyluv/layerctl && cd layerctl
136
- ./layers profile # 使用中のプロファイルと能力検出を表示
137
- ./layers snapshot # 現状を走査して layers.observed.tsv に記録(layers.tsv は不変)
138
- ./layers seed # 観測を layers.tsv(意志)へ昇格
139
- ./layers diff # 意志と観測のズレだけ表示
140
- ./layers plan # 差分コマンドだけ抽出。実行しない
141
- ./layers apply # 差分を適用。層コマンドのみ / kill-all 後の2段で計測
142
- ./layers verify # 適用結果を read-back 検証。永続の失敗と揮発の書き戻しを分ける
143
- ./layers reapply # 全件を再主張(OTA 後の復旧用)
144
- ./layers import f # 外部の debloat リストを取り込む(UAD JSON / TSV / プレーン)
145
- ./layers # TUI
146
- ~~~
147
-
148
- `apply` は適用後に read-back して検証する。**揮発コマンドが書き戻されたのか、
149
- 永続コマンドが本当に効かなかったのかを分けて報告する**(揮発は異常ではない)。
150
-
151
- ~~~sh
152
- ./layers plan --json # 差分を JSON で出す(他ツールから食える)
153
- ./layers apply --no-kill # 掃除を撃たず、層コマンドだけ
154
- ./layers apply --repeat 7 # 掃除を7回サンプルして中央値・最小・最大を出す
155
- ./layers import f --as C1 # verdict を無視して全部 C1 として取り込む
156
- ./layers import f --dry # プレビューのみ
157
- ~~~
158
-
159
- ライブダッシュボード:
160
-
161
- ~~~
162
- layerctl-stat # curses。メモリ / swap / CPU / RX / TX をスパークライン表示
163
- layerctl-stat --dump # 1フレームを素テキストで(CI / 検品用)
164
- ~~~
165
-
166
- TUI の操作:
167
-
168
- | キー | 動作 |
169
- |---|---|
170
- | `j` `k` | 上下移動 |
171
- | `tab` | 層パネル / パッケージパネルの切替 |
172
- | `space` | 層を巡回(0→A→B1→B2→C1→C2→D→0) |
173
- | `a` | 選択中の1本を適用(risk>=3 は `y` 確認) |
174
- | `A` | staged 全件を一括適用 |
175
- | `w` | layers.tsv に保存 |
176
- | `R` | 全件を再主張 |
177
- | `q` | 保存して終了 |
178
-
179
- ## 既知の限界
180
-
181
- - bucket 系の層は揮発する。システムが予測・時間切れ・利用検知で書き戻す
182
- - 保護パッケージ(fmm / kgclient / knox.cloudmdm)は `restricted` を保持しない
183
- - `EXEMPTED` は doze whitelist と同義ではない
184
- - OTA は `appops` をリセットする。`--reapply` で復旧する
185
- - `layers.tsv` は**意志**。`snapshot` は書き換えず、観測は `layers.observed.tsv` に隔離される
186
- - `seed` 直後の初回 `plan` は、bucket5(EXEMPTED) を whitelist へ昇格させる一回性の
187
- 正規化を含む。適用後は 0 に収束する(実測: 116 cmd → 0)
188
- - 書き戻される個体は `QUIRKS.no_bucket_hold` に記録し、bucket の主張を諦める。
189
- SC-53F では93本を実測で特定した。諦めた分だけ `plan` は 0 に収束する
190
- - `verify` の『揮発で書き戻された』は異常ではない。`am set-standby-bucket` と
191
- `cmd appops set` は Android が書き戻す。`pm disable-user` と
192
- `deviceidle whitelist` は持続するので、こちらが残ったときだけ本当の失敗
193
- - 意志は端末固有。`plan` は installed で絞る(`diff` は未インストール分を別枠で件数出し)
194
-
195
- ## 実測で確定した地雷
196
-
197
- 実機で確定した地雷 — rish は `2>&1` と `</dev/null` が必須、`timeout` は `--foreground`、
198
- `dumpsys euicc` は `econtroller`、`enabled=4` への `pm enable` は monkey で `4→0` に落としてから。
199
- 全表は [docs/transport.md](docs/transport.md)。輸送層を触る前に一度読め。
200
-
201
- ## 移植
202
-
203
- 端末固有データは **`src/layerctl/profiles/` の1ファイルだけ**。`layerctl.tui` 本体は端末を知らず、輸送層も `layerctl.core.detect()` に閉じている。
204
- `generic.py` を雛形に固有値を埋めると `MATCH_MODEL` / `MATCH_PLATFORM` の一致で自動選択され、外れれば `generic` に落ちる。
205
- 手順と欄の意味は [docs/porting.md](docs/porting.md)。
206
-
207
- ~~~
208
- cp src/layerctl/profiles/generic.py src/layerctl/profiles/pixel9.py
209
- ~~~
210
-
211
- ## License
212
-
213
- MIT
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes