feat(settings): set the locale on iOS simulators and Android

Merged
IM
1d ago
+747-17

Summary

Refs #5005. settings timezone moved to #5127; this PR covers settings locale only.

Adds settings locale <locale-id|reset> for iPhone and iPad simulators and Android devices and emulators, using the value settings catalog form. Locale ids accept - or _ in any casing, normalize to BCP 47 tags (en-IN, zh-Hans-CN), refuse extensions and variants before dispatch, and refuse --app with setting_app_not_consumed. Each response reports previousLocale.

  • iOS simulator: writes or deletes AppleLanguages and AppleLocale in the global domain via simctl spawn defaults. Running apps adopt the new locale on relaunch.
  • Android: works on emulators, physical devices, and Limrun Android over adb. Adds SystemLocaleCommand to the snapshot helper APK and runs it through app_process as the shell user so IActivityManager.updatePersistentConfiguration updates running apps and persists across reboots. reset applies ro.product.locale.
  • Other targets (including Limrun iOS, tvOS, macOS, and Revyl) refuse with UNSUPPORTED_OPERATION.

Before / after

 $ agent-device settings locale en_IN --platform android --json
-Error (INVALID_ARGS): settings requires <wifi|bluetooth|airplane|mobile-data|keep-awake|location|animations> <on|off>, …
+{"setting":"locale","state":"en-IN","locale":"en-IN","previousLocale":"en-US","message":"Locale set to en-IN"}
 $ agent-device settings locale reset --platform android --json
-Error (INVALID_ARGS): settings requires <wifi|bluetooth|airplane|mobile-data|keep-awake|location|animations> <on|off>, …
+{"setting":"locale","state":"reset","locale":"en-US","previousLocale":"en-IN","message":"Locale reset to the device default"}
 $ agent-device settings locale en_IN --platform ios --json
-Error (INVALID_ARGS): settings requires <wifi|bluetooth|airplane|mobile-data|keep-awake|location|animations> <on|off>, …
+{"setting":"locale","state":"en-IN","locale":"en-IN","previousLocale":"en-US","previousLanguages":["en-US","en-IN"],"warnings":["Running apps keep the old locale until they relaunch; run open <app> --relaunch."],"message":"Locale set to en-IN"}

Validation

  • Base 3e0814c574, head 489d001e08, rebased after #5127 merged.
  • Pixel 9 emulator (API 36) with the rebuilt snapshot helper APK: en_IN and reset verified with getprop persist.sys.locale; settings timezone still round-trips.
  • iPhone 17 Pro simulator (iOS 27.2): en_IN and reset verified with defaults read -g AppleLocale and AppleLanguages; settings timezone still round-trips.
  • Focused suites: 224 passed (contracts, command-surface, daemon handler, Apple, Android, Limrun); 17 mutants each fail a test, including physical Android admission.
  • Gate at 489d001e08: format, lint, typecheck, layering, fallow, native-dupes, build, provider-integration (324 passed), command-docs, docs-links, and docs-prose passed. In vitest-related, 4 provider-scenario tests timed out under host load; they pass in provider-integration.