feat(settings): add Android mobile-data on|off

MI
7h ago
+752-44

Summary

Adds settings mobile-data on|off for Android, so a run on a streaming app can move from Wi-Fi to cellular and back and check the "streaming on mobile data" warnings.

agent-device settings wifi off
agent-device settings mobile-data on   # mobileData: enabled

Node: client.settings.update({ setting: 'mobile-data', state: 'off' })

  • Picks the stored row before changing anything: mobile_data<subId> with more than one active modem (persist.radio.multisim.config), otherwise mobile_data. Then runs svc data enable|disable and polls that row for up to 2 s.
  • No match fails with mobile-data-not-applied or mobile-data-unreadable, and says whether the switch was dispatched.
  • Every non-Android target refuses up front with UNSUPPORTED_OPERATION (setting-unsupported-on-leaf). --app is refused with setting_app_not_consumed.
  • 19 files, +752/−44, including help, docs and CHANGELOG.

Test plan

Use an Android emulator or phone with a SIM. S is its adb serial.

  1. pnpm build && pnpm build:android && pnpm clean:daemon
  2. pnpm ad settings mobile-data off --platform android --serial $S --json returns mobileData: disabled, and adb -s $S shell settings get global mobile_data prints 0. on returns enabled and 1.
  3. Run settings wifi off, then mobile-data on. adb -s $S shell ping -c 2 8.8.8.8 gets replies. After mobile-data off it loses every packet.
  4. mobile-data off --app com.example.app fails with INVALID_ARGS and setting_app_not_consumed. The row stays 1.
  5. Restore with settings wifi on and mobile-data on.

Validation

pnpm check:affected --run passed at 6b94f115. Steps 2 to 4 ran at 124d05f5 (same tree) on an Android 37 emulator with a SIM and an empty multisim config. All passed, and the emulator was restored.

Not covered: the multi-modem row choice. It follows AOSP GlobalSettingsHelper and needs a dual-SIM phone.