Skip to content

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

Merged
thymikee merged 5 commits into
callstack:mainfrom
imranbarbhuiya:feat/settings-locale-timezone
Nov 27, 2026
Merged

thymikee merged 5 commits into
callstack:mainfrom
imranbarbhuiya:feat/settings-locale-timezone

Conversation

@imranbarbhuiya

@imranbarbhuiya imranbarbhuiya commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

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 feat(settings): set the time zone on iOS simulators and Android #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.

@thymikee

Copy link
Copy Markdown
Member

Thanks for adding locale and time zone settings for local simulators and emulators.

The code at d6d508a has no blocking problems, but the change is not ready to merge because the new device paths have no recorded evidence. This is a device-facing change, and CI smoke does not run these paths. The PR body describes live runs only as prose. Before merge, please attach JSON output from a local iOS simulator and an Android emulator for settings locale en_IN, settings locale reset, settings timezone Asia/Kolkata and settings timezone reset, showing locale, previousLocale, timeZone and previousTimeZone. For Android, please also include adb shell getprop persist.sys.timezone and the helper's current= line. The full-tier android/ios live lifecycle scenario log with assertLocaleAndTimeZoneRoundTrip passing is an acceptable substitute.

Not blocking, and you can take or leave these: (1) parseTimeZoneId fixes casing only for names that Intl.supportedValuesOf('timeZone') lists, so asia/kolkata passes validation and reaches Android's case-sensitive cmd alarm set-timezone in lowercase. The parser should return the id in the casing the tz database spells, or refuse it. (2) setAndroidTimeZone turns auto time zone off before set-timezone. On failure the device keeps auto time zone off, so restore the value read before the write, or report it in the error details. (3) On iOS, previousLocale can be a Foundation string such as en_US@rg=inzzzz that settings locale refuses, so reset cannot be undone from the reported value. Report a value the command accepts, or also report the previous languages. (4) readInstalledApkPath repeats the base.apk selection that readBaseApkPath in helper-package-install.ts already owns, so it could reuse that. (5) The four set functions starting at settings-locale.ts re-check the reset state and re-parse a value the daemon already parsed, so they could take the parsed value directly. (6) The iOS time zone is set with launchctl setenv TZ, which a simulator reboot clears, so the help text and docs should say it lasts until the simulator reboots.

CI is likely unrelated to this change. Smoke Tests (ios) failed in smoke:automation-input at back (BACK_SWIPE_UNVERIFIED), and the umbrella Smoke Tests job failed only on that missing back coverage. The diff does not touch back or navigation, and its iOS e2e additions do not run in the smoke selection. The two Body rules jobs were cancelled by newer runs, not failed. Unit and lint jobs are green. No conflicts.

Not verified here: any device run, the iOS reset result, Android applying the locale at once, TZ inheritance by apps launched from SpringBoard, and the case-sensitivity of cmd alarm set-timezone. These come from code reading and platform knowledge. The focused tests and mutation claims were also not re-run.

Before merge, please attach the live iOS and Android output above and re-run the iOS smoke job until back passes.

@imranbarbhuiya
imranbarbhuiya force-pushed the feat/settings-locale-timezone branch from d6d508a to 2f72203 Compare November 24, 2026 04:08
@imranbarbhuiya

Copy link
Copy Markdown
Contributor Author

All six notes are handled in 2f72203:

  1. parseTimeZoneId matches a name the host lists in any casing and returns the listed spelling. An alias the host does not list, such as Asia/Kolkata on ICU that lists Asia/Calcutta, is sent as written only when every word starts with a capital. Otherwise it is refused before dispatch. On the emulator, cmd alarm set-timezone asia/kolkata and america/new_york both exit 0 and leave persist.sys.timezone unchanged. Without this check, the read-back would report time-zone-not-applied.
  2. setAndroidTimeZone reads auto_time_zone before turning it off. If set-timezone fails or the read-back differs, it writes the old value back and reports it as autoTimeZone in the error details.
  3. On iOS, previousLocale is now a tag settings locale accepts: Foundation keywords are dropped, so en_US@rg=inzzzz becomes en-US, and a value it can't take is null. previousLanguages lists every preferred language.
  4. readInstalledApkPath reuses readBaseApkPath from helper-package-install.ts.
  5. The four set functions take the parsed value from the daemon and no longer re-parse it.
  6. The help and docs say the iOS time zone lasts until the simulator reboots.

Android emulator (Pixel 9, API 36), at 2f72203:

settings locale / timezone JSON, getprop, and the helper's current= line
$ agent-device settings locale en_IN --platform android
{
  "success": true,
  "data": {
    "setting": "locale",
    "state": "en-IN",
    "locale": "en-IN",
    "previousLocale": "en-US",
    "message": "Locale set to en-IN"
  }
}
$ adb shell getprop persist.sys.locale
en-IN
$ adb shell env CLASSPATH=<helper base.apk> app_process /system/bin ...SystemLocaleCommand en-IN
previous=en-IN
current=en-IN
$ agent-device settings locale reset --platform android
{
  "success": true,
  "data": {
    "setting": "locale",
    "state": "reset",
    "locale": "en-US",
    "previousLocale": "en-IN",
    "message": "Locale reset to the device default"
  }
}
$ adb shell getprop persist.sys.locale
en-US
$ agent-device settings timezone Asia/Kolkata --platform android
{
  "success": true,
  "data": {
    "setting": "timezone",
    "state": "Asia/Kolkata",
    "timeZone": "Asia/Kolkata",
    "previousTimeZone": "Asia/Kolkata",
    "autoTimeZone": false,
    "message": "Time zone set to Asia/Kolkata"
  }
}
$ adb shell getprop persist.sys.timezone
Asia/Kolkata
$ agent-device settings timezone Asia/Calcutta --platform android
{
  "success": true,
  "data": {
    "setting": "timezone",
    "state": "Asia/Calcutta",
    "timeZone": "Asia/Calcutta",
    "previousTimeZone": "Asia/Kolkata",
    "autoTimeZone": false,
    "message": "Time zone set to Asia/Calcutta"
  }
}
$ adb shell getprop persist.sys.timezone
Asia/Calcutta
$ agent-device settings timezone asia/kolkata --platform android
{
  "success": false,
  "error": {
    "code": "INVALID_ARGS",
    "message": "Invalid time zone: asia/kolkata. The host does not list this alias, so write it with the IANA database's capitals, such as Asia/Kolkata or US/Pacific.",
    "hint": "Fix the command arguments; run help <command> for usage.",
    "diagnosticId": "mwu5tkwa-cf6a5f4e"
  }
}
$ adb shell getprop persist.sys.timezone
Asia/Calcutta
$ agent-device settings timezone reset --platform android
{
  "success": true,
  "data": {
    "setting": "timezone",
    "state": "reset",
    "timeZone": null,
    "previousTimeZone": "Asia/Calcutta",
    "autoTimeZone": true,
    "message": "Time zone reset to the device default"
  }
}
$ adb shell getprop persist.sys.timezone
Asia/Kolkata
$ adb shell settings get global auto_time_zone
1

iOS simulator (iPhone 17 Pro, iOS 27.2), at 2f72203:

settings locale / timezone JSON
$ agent-device settings locale en_IN --platform ios --json
{
  "success": true,
  "data": {
    "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"
  }
}
$ xcrun simctl spawn <udid> defaults read -g AppleLocale; defaults read -g AppleLanguages
en_IN
(
    "en-IN"
)
$ agent-device settings locale reset --platform ios --json
{
  "success": true,
  "data": {
    "setting": "locale",
    "state": "reset",
    "locale": null,
    "previousLocale": "en-IN",
    "previousLanguages": [
      "en-IN"
    ],
    "warnings": [
      "Running apps keep the old locale until they relaunch; run open <app> --relaunch."
    ],
    "message": "Locale reset to the device default"
  }
}
$ xcrun simctl spawn <udid> defaults read -g AppleLocale; defaults read -g AppleLanguages
Error: Could not find key 'AppleLocale' in domain 'kCFPreferencesAnyApplication'.
Error: Could not find key 'AppleLanguages' in domain 'kCFPreferencesAnyApplication'.
$ agent-device settings timezone Asia/Kolkata --platform ios --json
{
  "success": true,
  "data": {
    "setting": "timezone",
    "state": "Asia/Kolkata",
    "timeZone": "Asia/Kolkata",
    "previousTimeZone": null,
    "warnings": [
      "Running apps keep the old time zone until they relaunch; run open <app> --relaunch."
    ],
    "message": "Time zone set to Asia/Kolkata"
  }
}
$ xcrun simctl spawn <udid> launchctl getenv TZ
[Asia/Kolkata]
$ agent-device settings timezone reset --platform ios --json
{
  "success": true,
  "data": {
    "setting": "timezone",
    "state": "reset",
    "timeZone": null,
    "previousTimeZone": "Asia/Kolkata",
    "warnings": [
      "Running apps keep the old time zone until they relaunch; run open <app> --relaunch."
    ],
    "message": "Time zone reset to the device default"
  }
}
$ xcrun simctl spawn <udid> launchctl getenv TZ
[]
$ agent-device settings timezone asia/kolkata --platform ios --json
{
  "success": false,
  "error": {
    "code": "INVALID_ARGS",
    "message": "Invalid time zone: asia/kolkata. The host does not list this alias, so write it with the IANA database's capitals, such as Asia/Kolkata or US/Pacific.",
    "hint": "Fix the command arguments; run help <command> for usage.",
    "diagnosticId": "mwu6b3zb-659e926d"
  }
}
$ xcrun simctl spawn <udid> launchctl getenv TZ
[]

@thymikee

Copy link
Copy Markdown
Member

Thanks for the update. The code in 2f72203 is fine, and the earlier evidence request is now met by the pasted live output for the locale and time zone settings. Repo Guards & Compatibility failed in the check-affected SIGTERM test (scripts/check-affected/command-execution.test.ts, Unexpected end of JSON input), which looks unrelated because this diff touches no scripts or check-affected code. Body rules was cancelled by a newer run. Not verified here: the live transcript on a device, iOS time zone persistence across a simulator reboot, time zone inheritance by apps launched from SpringBoard, and the focused tests and mutation claims. Before merge, re-run Repo Guards & Compatibility and Body rules until both are green.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 24, 2026
@thymikee

Copy link
Copy Markdown
Member

This branch now conflicts with main at 2f72203. Please rebase onto current main; the review at 2f72203 was clean, so only a check that the rebase keeps the same behavior is needed.

@imranbarbhuiya
imranbarbhuiya force-pushed the feat/settings-locale-timezone branch from 2f72203 to 95a1522 Compare November 24, 2026 09:04
@imranbarbhuiya

Copy link
Copy Markdown
Contributor Author

Rebased onto main at 63fe1b6 (after #4290); the head is now 95a1522. Both features are kept:

  • The --app field text and the app-refusal tests now list keep-awake alongside locale and timezone.
  • commands.md and error-reasons.md are regenerated, not hand-merged.
  • No change to the locale and time zone behaviour.

On a Pixel 9 emulator (API 36) at 95a1522:

$ agent-device settings locale en_IN --platform android --json
{"setting": "locale", "state": "en-IN", "locale": "en-IN", "previousLocale": "en-US", "message": "Locale set to en-IN"}
  getprop persist.sys.locale = en-IN
$ agent-device settings locale reset --platform android --json
{"setting": "locale", "state": "reset", "locale": "en-US", "previousLocale": "en-IN", "message": "Locale reset to the device default"}
  getprop persist.sys.locale = en-US
$ agent-device settings timezone Asia/Kolkata --platform android --json
{"setting": "timezone", "state": "Asia/Kolkata", "timeZone": "Asia/Kolkata", "previousTimeZone": "Asia/Kolkata", "autoTimeZone": false, "message": "Time zone set to Asia/Kolkata"}
  getprop persist.sys.timezone = Asia/Kolkata
  settings get global auto_time_zone = 0
$ agent-device settings timezone reset --platform android --json
{"setting": "timezone", "state": "reset", "timeZone": null, "previousTimeZone": "Asia/Kolkata", "autoTimeZone": true, "message": "Time zone reset to the device default"}
  settings get global auto_time_zone = 1
$ agent-device settings keep-awake on --platform android --json
{"setting": "keep-awake", "state": "on", "keepAwake": "enabled", "message": "Updated setting: keep-awake"}
  settings get global stay_on_while_plugged_in = 15
$ agent-device settings keep-awake off --platform android --json
{"setting": "keep-awake", "state": "off", "keepAwake": "disabled", "message": "Updated setting: keep-awake"}
  settings get global stay_on_while_plugged_in = 0

@thymikee thymikee removed the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 24, 2026
@thymikee

Copy link
Copy Markdown
Member

Thanks for the update. The earlier conflict from 2f72203 is resolved, and the locale and time zone changes at 95a1522 have no problems found in review. The Pixel 9 run at this commit is the author's pasted output, and the iOS patch is unchanged from the version reviewed earlier, so its earlier evidence still applies. Not verified here: the docs generator and the tests were not run, so generated-doc parity and test results rest on reading the head files and on the 16 passing checks. The only check not passing is Body rules, which was cancelled when a newer run replaced it. It validates the PR body and metadata, not any route this diff changes. No conflicts remain. Before merge, the cancelled Body rules check needs a green re-run.

@thymikee thymikee added ready-for-human Valid work that needs human implementation, judgment, or maintainer merge and removed ready-for-human Valid work that needs human implementation, judgment, or maintainer merge labels Nov 24, 2026
@thymikee

Copy link
Copy Markdown
Member

Thanks for the settings work. The catalog value form is the right extension point, but please reduce this before it moves forward:

  • Split settings timezone into its own PR so it can land without the helper change. settings locale carries a new mechanism, running a helper-APK class through app_process, which needs its own decision.
  • Drop the alias-casing rule in parseTimeZoneId. Android already reads persist.sys.timezone back and fails with time-zone-not-applied, so host-side validation can be just "Intl knows this zone".
  • Admit Android physical devices, or state why they cannot work: cmd alarm set-timezone and a shell-user app_process call should both run on a physical device, and remote device farms are the main audience for this.
  • On iOS, launchctl setenv TZ reaches only newly launched apps and is lost on reboot. Either document that limit in the help, or keep timezone Android-only for now.

@thymikee

Copy link
Copy Markdown
Member

This branch now conflicts with main. Please rebase onto current main together with the requested changes above.

@imranbarbhuiya
imranbarbhuiya force-pushed the feat/settings-locale-timezone branch from 95a1522 to 165f7af Compare November 26, 2026 16:27
@imranbarbhuiya imranbarbhuiya changed the title feat(settings): set the locale and time zone on local simulators and emulators feat(settings): set the locale on iOS simulators and Android Nov 26, 2026
@imranbarbhuiya

Copy link
Copy Markdown
Contributor Author

Updated per review:

@thymikee

Copy link
Copy Markdown
Member

Thanks for the rework. The code at 165f7af has no blocking problems. The conflict reported at 95a1522 is resolved, and no conflicts are known now. settings timezone is now split out into #5127, and this change admits physical Android devices and Limrun Android for settings locale. The required evidence is in place; the live emulator and simulator results are the author's pasted output at 165f7af. Not verified here: tests, the docs generator and live runs were not executed. No live run exists on a physical Android device or on Limrun Android for the newly admitted kinds.

CI shows 16 passing checks. The only check not passing is Body rules, which was cancelled by a newer run and is likely unrelated: it validates the PR body and metadata, and the diff changes no route it exercises. Before merge, a maintainer needs to decide on running a helper-APK class through app_process, and Body rules needs a green re-run.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 26, 2026
@thymikee

Copy link
Copy Markdown
Member

This branch now conflicts with main. Please rebase onto current main; the next review only checks that the rebase keeps the reviewed change intact.

@thymikee thymikee removed the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 26, 2026
@imranbarbhuiya
imranbarbhuiya force-pushed the feat/settings-locale-timezone branch from 165f7af to 489d001 Compare November 27, 2026 03:42
@imranbarbhuiya

Copy link
Copy Markdown
Contributor Author

Rebased onto 3e0814c574; head is now 489d001e08.

  • The catalog value-form commit dropped: it was byte-identical to the one feat(settings): set the time zone on iOS simulators and Android #5127 merged.
  • Conflicts were all locale and timezone landing in the same lists, unions and docs. Each now carries both: catalog, parsers, runtime facts, Limrun facts, refusal lists, the Android --app refusal table, commands.md and error-reasons.md (regenerated), limrun.md, revyl.md, and the live scenarios, which now round-trip both settings.
  • The reviewed locale code itself is unchanged.

Rerun at 489d001e08: settings locale en_IN / reset and settings timezone set / reset on an iPhone 17 Pro simulator (iOS 27.2) and a Pixel 9 emulator (API 36), checked with defaults read -g and getprop. The gate passed. In vitest-related, 4 provider-scenario tests timed out under host load; they pass in the provider-integration stage (324 passed).

@thymikee

Copy link
Copy Markdown
Member

Thanks for the rebase. The code at 489d001 has no blocking problems, and the reviewed locale code is unchanged.
The conflict reported at 165f7af is resolved, and the shared settings lists checked now carry both locale and timezone.
The required evidence is in place; the live simulator and emulator rerun at this commit is the author's pasted report.
Not verified here: tests, the docs generator and live devices were not run, and generated-doc parity was checked only by reading the files at this commit.

CI is green, with all 17 checks passing.
No conflicts are known.
Before merge, a maintainer still needs to decide on running a helper-APK class through app_process to set the Android locale.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 27, 2026
@thymikee
thymikee merged commit a964f3d into callstack:main Nov 27, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-human Valid work that needs human implementation, judgment, or maintainer merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants