Closed KazuCocoa closed 3 months ago
The described behaviour makes a lot of sense to me as the current method for changing language calls private system APIs
Hm, this was not clear. A fresh emulator did not require any changes to change the language via the LocaleSettingReceiver. But I saw no-update behavior as this description as well.
One interesting thing was the relaxing hidden policy command needed to run before the app installation. This could be weird tho.
Actually the logcat had:
2024-06-08 18:54:30.655 9092-9092 LocaleSettingReceiver io.appium.settings I Obtained locale: ja_JP
2024-06-08 18:54:30.676 9092-9092 appium.settings io.appium.settings W Accessing hidden method Landroid/app/ActivityManagerNative;->getDefault()Landroid/app/IActivityManager; (unsupported, reflection, allowed)
2024-06-08 18:54:30.677 9092-9092 appium.settings io.appium.settings W Accessing hidden method Landroid/app/IActivityManager$Stub$Proxy;->getConfiguration()Landroid/content/res/Configuration; (unsupported, reflection, allowed)
2024-06-08 18:54:30.678 9092-9092 appium.settings io.appium.settings W Accessing hidden field Landroid/content/res/Configuration;->userSetLocale:Z (unsupported, reflection, allowed)
2024-06-08 18:54:30.681 9092-9092 appium.settings io.appium.settings W Accessing hidden method Landroid/app/IActivityManager$Stub$Proxy;->updateConfiguration(Landroid/content/res/Configuration;)Z (max-target-o, reflection, denied)
2024-06-08 18:54:30.681 9092-9092 appium.settings io.appium.settings W Accessing hidden method Landroid/app/IActivityManager;->updateConfiguration(Landroid/content/res/Configuration;)Z (max-target-r, reflection, allowed)
2024-06-08 18:54:30.897 9092-9092 LocaleSettingReceiver io.appium.settings I Set locale: ja_JP
targetSdkVersion 33
gradle config requires this relaxing hidden policy. So it would be nice to address this hidden api policy at least
Exception example via adb logcat with the denied behavior
2024-06-08 19:34:13.195 3567-3567 appium.settings io.appium.settings W Accessing hidden method Landroid/app/IActivityManager$Stub$Proxy;->updateConfiguration(Landroid/content/res/Configuration;)Z (max-target-o, reflection, denied)
2024-06-08 19:34:13.195 3567-3567 appium.settings io.appium.settings W Accessing hidden method Landroid/app/IActivityManager;->updateConfiguration(Landroid/content/res/Configuration;)Z (max-target-r, reflection, denied)
2024-06-08 19:34:13.196 3567-3567 APPIUM SETTINGS(LOCALE) io.appium.settings E Failed to set locale
java.lang.NoSuchMethodException: android.app.IActivityManager$Stub$Proxy.updateConfiguration [class android.content.res.Configuration]
at java.lang.Class.getMethod(Class.java:2937)
at java.lang.Class.getMethod(Class.java:2449)
at io.appium.settings.handlers.LocaleSettingHandler.setLocaleWith(LocaleSettingHandler.java:72)
at io.appium.settings.handlers.LocaleSettingHandler.setLocale(LocaleSettingHandler.java:40)
at io.appium.settings.receivers.LocaleSettingReceiver.onReceive(LocaleSettingReceiver.java:97)
at android.app.ActivityThread.handleReceiver(ActivityThread.java:4449)
at android.app.ActivityThread.-$$Nest$mhandleReceiver(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2256)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:205)
at android.os.Looper.loop(Looper.java:294)
at android.app.ActivityThread.main(ActivityThread.java:8177)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)
2024-06-08 19:34:13.196 3567-3567 LocaleSettingReceiver io.appium.settings I Set locale: en_US
This is allowed behavior:
2024-06-08 19:36:08.603 2321-2321 LocaleSettingReceiver io.appium.settings I Obtained locale: ja_JP
2024-06-08 19:36:08.658 2321-2321 appium.settings io.appium.settings W Accessing hidden method Landroid/app/ActivityManagerNative;->getDefault()Landroid/app/IActivityManager; (unsupported, reflection, allowed)
2024-06-08 19:36:08.658 2321-2321 appium.settings io.appium.settings W Accessing hidden method Landroid/app/IActivityManager$Stub$Proxy;->getConfiguration()Landroid/content/res/Configuration; (unsupported, reflection, allowed)
2024-06-08 19:36:08.662 2321-2321 appium.settings io.appium.settings W Accessing hidden field Landroid/content/res/Configuration;->userSetLocale:Z (unsupported, reflection, allowed)
2024-06-08 19:36:08.662 2321-2321 appium.settings io.appium.settings W Accessing hidden method Landroid/app/IActivityManager$Stub$Proxy;->updateConfiguration(Landroid/content/res/Configuration;)Z (max-target-o, reflection, allowed)
2024-06-08 19:36:09.083 2321-2321 LocaleSettingReceiver io.appium.settings I Set locale: ja_JP
:tada: This issue has been resolved in version 5.12.0 :tada:
The release is available on:
Your semantic-release bot :package::rocket:
It looks like we need to call hidden policy to modify the location as well?
I saw via Appium worked but once I uninstall the settings app and install again, below command did not change the language.
When I run the app installation after relaxing hidden API policy, it worked. I'll investigate a bit further. We may need to:
The emulator version was API level 34.