feat: support locale when launching apps#181
Conversation
WalkthroughThis pull request adds locale support for app launches across the CLI and device implementations. A new 🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@devices/android.go`:
- Around line 268-280: LaunchApp attempts to call "cmd locale set-app-locales"
without checking Android API level; add an API-level check in
AndroidDevice.LaunchApp before calling d.runAdbCommand to ensure the device SDK
>= 33, and if not either skip setting locales gracefully or return a clear error
stating the command requires Android 13/API 33+. Implement this by querying the
device SDK (e.g., via adb:
d.runAdbCommand("shell","getprop","ro.build.version.sdk") or an existing helper
like a GetAPILevel/GetSdk method), parse the integer, compare against 33, and
only call set-app-locales when the check passes; keep the existing locale
validation (validLocaleTag) and preserve the original error formatting when the
adb call is performed.
ℹ️ Review info
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge base: Disabled due to data retention organization setting
📒 Files selected for processing (8)
cli/apps.gocli/flags.gocommands/apps.godevices/android.godevices/common.godevices/ios.godevices/remote.godevices/simulator.go
| func (d *AndroidDevice) LaunchApp(bundleID string, locales []string) error { | ||
| if len(locales) > 0 { | ||
| for _, l := range locales { | ||
| if !validLocaleTag.MatchString(l) { | ||
| return fmt.Errorf("invalid locale tag: %q", l) | ||
| } | ||
| } | ||
| localeArg := strings.Join(locales, ",") | ||
| output, err := d.runAdbCommand("shell", "cmd", "locale", "set-app-locales", bundleID, "--locales", localeArg) | ||
| if err != nil { | ||
| return fmt.Errorf("failed to set app locales for %s: %v\nOutput: %s", bundleID, err, string(output)) | ||
| } | ||
| } |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Check for version handling in android.go and devices/
echo "=== Checking for version/API level handling ==="
rg -n "getprop.*version|API|api.*level|android.*13|android.*33" devices/android.go
echo ""
echo "=== Broader search in devices directory ==="
rg -n "API|api.*level|version.*check" devices/ -A 2 -B 2Repository: mobile-next/mobilecli
Length of output: 2509
🌐 Web query:
Android cmd locale set-app-locales minimum API level requirement
💡 Result:
adb shell cmd locale set-app-locales ... requires Android 13 (API level 33) or higher, because it’s implemented by the platform LocaleManager service/API (added in API 33). On Android 12L / 12 / earlier (API ≤ 32), the command isn’t available. [1], [2]
If you need similar behavior on older versions, you must use the AndroidX/AppCompat per-app language APIs (backport) instead. [3]
Sources: [1], [2], [3]
🏁 Script executed:
#!/bin/bash
# Get full context around LaunchApp function
sed -n '260,290p' devices/android.goRepository: mobile-next/mobilecli
Length of output: 1095
Add Android API level check before calling set-app-locales command.
The cmd locale set-app-locales command requires Android 13 (API level 33) or higher. The current implementation will fail silently on older Android versions with an unclear error message from adb. Add a version check before executing this command, either to skip locale setting gracefully or provide a more informative error message explaining the Android version requirement.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@devices/android.go` around lines 268 - 280, LaunchApp attempts to call "cmd
locale set-app-locales" without checking Android API level; add an API-level
check in AndroidDevice.LaunchApp before calling d.runAdbCommand to ensure the
device SDK >= 33, and if not either skip setting locales gracefully or return a
clear error stating the command requires Android 13/API 33+. Implement this by
querying the device SDK (e.g., via adb:
d.runAdbCommand("shell","getprop","ro.build.version.sdk") or an existing helper
like a GetAPILevel/GetSdk method), parse the integer, compare against 33, and
only call set-app-locales when the check passes; keep the existing locale
validation (validLocaleTag) and preserve the original error formatting when the
adb call is performed.
No description provided.