Everything I changed on my Pixel 7 from the PC in one evening, using wireless ADB: web pages forced dark in Brave and Chrome, Walmart links opening in the browser instead of the Walmart app, the ntfy listener kept off, home screen icons for my Mail Reader and Dictate web apps, and a battery check. Each change has the command to redo it and the command to undo it.
How it works
- The phone has Wireless debugging switched on (Settings → System → Developer options → Wireless debugging).
- The PC runs
adbfrom Google's platform-tools. It pairs once with a 6-digit code, then connects over Wi-Fi. - Settings that have an ADB command are changed directly. Settings that only exist in an app's own screens are changed by reading the screen (
uiautomator dump) and tapping (input tap).
Where to run each command
- PC: a PowerShell window in the platform-tools folder (for me
C:\Users\Dietrich\Downloads\platform-tools). Everyadbcommand below runs there. - Phone: where a step says "on the phone", you tap it yourself.
Rebuild, step by step
1. Connect the PC to the phone
On the phone: Wireless debugging → Pair device with pairing code. Leave that box open.
PC, to find the phone's pairing and connect ports:
.\adb.exe mdns services
Two lines show up: _adb-tls-pairing._tcp and _adb-tls-connect._tcp, each with the phone's address and a port. Pair, with the pairing port and the 6-digit code from the phone:
.\adb.exe pair PHONE-ADDRESS:PAIRING-PORT 123456
Then connect with the connect port:
.\adb.exe connect PHONE-ADDRESS:CONNECT-PORT
Pairing only happens once. After the phone changes networks, Android switches Wireless debugging off by itself: switch it back on, run mdns services again (the connect port changes) and connect again.
2. Force web pages dark in Brave and Chrome
Neither browser has a "darken websites" option in its settings any more; both only darken their own menus. The hidden flag still works.
On the phone, in each browser, type this in the address bar (Brave accepts brave:// too):
chrome://flags/#enable-force-dark
Set Auto Dark Mode for Web Contents to Enabled, then tap Relaunch at the bottom. Test with example.com, which is normally a white page. Brave already had it on; Chrome needed it.
Firefox has no such flag. It needs the Dark Reader add-on (from addons.mozilla.org, by Dark Reader Ltd, Recommended). Still to do.
3. Open Walmart links in the browser, not the Walmart app
The Walmart app claims every walmart.com link and opens it in an app that works badly with dark mode and screen readers. This turns that off (the same as Settings → Apps → Walmart → Open by default → Open supported links: off). PC:
.\adb.exe shell pm set-app-links-allowed --user 0 --package com.walmart.android false
Test: this should open Brave (or your default browser), not the Walmart app.
.\adb.exe shell am start -a android.intent.action.VIEW -c android.intent.category.BROWSABLE -d https://www.walmart.com/
Undo:
.\adb.exe shell pm set-app-links-allowed --user 0 --package com.walmart.android true
The same works for any app that grabs links: swap in its package name (.\adb.exe shell pm list packages lists them).
4. Keep the ntfy listener off
The ntfy app holds a connection to my push server all day for creator-chat alerts. This stops it and sets its battery use to Restricted, so it can't start in the background or at boot. PC:
.\adb.exe shell cmd appops set io.heckel.ntfy RUN_ANY_IN_BACKGROUND ignore
.\adb.exe shell am force-stop io.heckel.ntfy
Undo (or Settings → Apps → ntfy → App battery usage → Optimized):
.\adb.exe shell cmd appops set io.heckel.ntfy RUN_ANY_IN_BACKGROUND allow
5. Home screen icons for the Mail Reader and Dictate web apps
On the phone, in Brave, open the web app (my Mail Reader and Dictate pages), then menu ⋮ → scroll down → Install and create shortcut → Install → Install → Add to home screen.
Install makes it open in its own window without the address bar. Create shortcut opens it as a normal Brave tab.
The launcher puts the icon on the first page with room, which may be a new last page. To move it: touch and hold the icon, drag it to the screen edge and hold until the page flips, then let go where you want it. To delete an extra copy: touch and hold, drag it to Remove at the top.
6. Check what is draining the battery
PC. This prints the "Estimated power use" table since the last full charge:
.\adb.exe shell dumpsys batterystats --charged
- Estimated power use (mAh): the top lines split the drain by part (screen, cpu, mobile_radio, phone, wifi, audio, video). Further down, each
UID u0aNNN:line is one app. - To turn a UID into an app name, add 10000 to the number after
u0aand look it up:
.\adb.exe shell cmd package list packages -U
- Cellular Rx signal strength (RSRP): time spent at each signal level. Lots of "poor" and "very poor" means the phone radio is burning battery.
- All partial wake locks: what kept the phone awake with the screen off.
What I found: about 61% of the battery used in 17 hours, and half of it with the screen off. The main cause was weak cell signal (more than half the day "poor" or "very poor"). The fix is Wi-Fi on at home plus Wi-Fi calling (Settings → Network and internet → SIMs → Wi-Fi calling). Next were YouTube, almost 2 hours of audio, and the Ookla Speedtest app running background reports.
Troubleshooting
adb says device offline or finds nothing
- Where: the PC.
- Look for: an empty list under
mdns servicesmeans Wireless debugging is off (it switches itself off after a network change) or the phone isn't on the same Wi-Fi. Switch it on and connect again.offlineon an old address means the connect port changed: disconnect and connect to the new port.
.\adb.exe disconnect
A tap does nothing or hits the wrong place
- The phone rotates. Read the screen again before tapping by position. A taller-than-wide screenshot means portrait.
.\adb.exe shell uiautomator dump /sdcard/ui.xml
- A locked phone shows only the lock screen. Unlock it yourself; the PIN is never typed over ADB.
Android's "Connection request" or permission boxes
- VPN permission, add-on permissions and similar boxes are tapped on the phone by you, not from the PC.
Notes
- Drag and drop on the home screen over ADB:
input swipeis too quick to pick up an icon. Useinput motionevent DOWN x y, wait about 1.2 seconds, send severalMOVEsteps, thenUP. A drag shorter than about 100 pixels opens the long-press menu (App info / Pause app / Widgets) instead. - Tapping "Add to home screen" in Brave's install box put the icon on a brand-new last page every time, so I ended up with three copies. Look on the last page before trying again.
- Firefox opens with a "make Firefox your default browser" prompt the first time. Cancel keeps Brave as the default.
- To do another day: Dark Reader in Firefox (and maybe in all three browsers instead of the flag).