Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TECH: add instruction to disable hidden API restrictions #514

Merged
merged 1 commit into from
Apr 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,23 @@ class SystemLanguage(
configuration.javaClass.getDeclaredField("locale").set(configuration, locale)
amService.javaClass.getMethod("updateConfiguration", Configuration::class.java).invoke(amService, configuration)
logger.i("SystemLanguage: Installing new system language=$locale completed")
} catch (ex: NoSuchMethodException) {
val message = """
Failed to change system locale due to API restrictions. To fix this execute one of the following commands.
For Android 10 (API level 29) or higher:
"adb shell settings put global hidden_api_policy 1"
For Android 9 (API level 28):
"adb shell settings put global hidden_api_policy_pre_p_apps 1"
"adb shell settings put global hidden_api_policy_p_apps 1"
To rollback these settings execute
For Android 10 (API level 29) or higher:
"adb shell settings delete global hidden_api_policy"
For Android 9 (API level 28):
"adb shell settings delete global hidden_api_policy_pre_p_apps"
"adb shell settings delete global hidden_api_policy_p_apps"
For more info refer to the https://developer.android.com/guide/app-compatibility/restrictions-non-sdk-interfaces
""".trimIndent()
throw RuntimeException(message)
} catch (error: Throwable) {
logger.e("SystemLanguage: Installing new system language=$locale failed with error=$error")
throw error
Expand Down