Settings Mutation¶
Programmatically change device state: brightness, ringer, airplane mode, bluetooth, any setting Android exposes.
High-Level Actions¶
adb(action="set_brightness", value=128) # 0-255
adb(action="set_ringer", mode="silent") # silent | vibrate | normal
adb(action="set_airplane_mode", enabled=True)
adb(action="set_bluetooth", enabled=False)
Low-Level Settings API¶
Android stores settings in three namespaces:
| Namespace | Purpose |
|---|---|
global |
Device-wide (wifi, airplane, time) |
system |
User prefs (brightness, volume, ringtone) |
secure |
Security-sensitive (location, accessibility) |
Get / Put / Delete¶
adb(action="setting_get", namespace="global", key="airplane_mode_on")
adb(action="setting_put", namespace="system", key="screen_brightness", value="128")
adb(action="setting_delete", namespace="secure", key="my_key")
List All in Namespace¶
Dump¶
Common Keys¶
| Key | Namespace | Values |
|---|---|---|
airplane_mode_on |
global | 0 / 1 |
wifi_on |
global | 0 / 1 |
bluetooth_on |
global | 0 / 1 |
auto_time |
global | 0 / 1 |
screen_brightness |
system | 0–255 |
screen_brightness_mode |
system | 0 manual, 1 auto |
screen_off_timeout |
system | milliseconds |
vibrate_on |
system | 0 / 1 |
notification_sound |
system | URI |
location_mode |
secure | 0 off, 3 high accuracy |
accessibility_enabled |
secure | 0 / 1 |
Agent Recipes¶
"Going to sleep"¶
agent("""
airplane mode on, ringer silent, brightness 10%,
screen timeout 30s. I'm going to bed.
""")
"Meeting mode"¶
"Travel mode"¶
"Dark room adaptation"¶
Permission Caveats¶
Some settings require extra permissions:
securenamespace may needWRITE_SECURE_SETTINGSgranted via adb:Do Not Disturbrequires a notification policy exception.- Default SMS/Dialer changes need user confirmation.
Most toggles in global and system work out of the box.
Safety¶
Settings mutation can soft-brick UX in rare cases (e.g. brightness=0 + auto-mode off = black screen). strands-adb ships:
- Dry-run mode via
dry_run=Trueon destructive actions - Reverse snapshots —
setting_dumpbefore + apply + diff after
# Snapshot
before = adb(action="setting_dump", namespace="system")
# Mutate
adb(action="set_brightness", value=10)
# Restore later
for key, value in before["settings"].items():
adb(action="setting_put", namespace="system", key=key, value=value)
What's Next¶
- Sensors — read state, then mutate
- Accessibility — a11y-specific settings
- Safety — allowlists, dry-run, reverse ops