Permission denial: writing to settings requires:android.permission.WRITE_SECURE_SETTINGS on Xiaomi device

I have the similar issue mentioned here I am getting following error while executing appium java script, the difference is my device is Xiaomi Redmi Note 7, and I am unable to find the setting that is the solution for that problem

I’m trying to connect Appium Inspector to my device, with capabilities below:

{
“deviceName”: “Mimi”,
“udid”: “d01916e”,
“platformName”: “Android”,
“platformVersion”: “9 PKQ1.180904.001”,
“appPackage”: “com.miui.calculator”,
“appActivity”: “com.miui.calculator.cal.CalculatorActivity”
}

but i got an error

[MJSONWP] Encountered internal error running command: Error executing adbExec. Original error: ‘Command ‘C:\Users\faria\Documents\Kaddra\Automation\Android\platform-tools\adb.exe -P 5037 -s d01916e shell ‘settings delete global hidden_api_policy_pre_p_apps;settings delete global hidden_api_policy_p_apps;settings delete global hidden_api_policy’’ exited with code 255’; Stderr: 'Security exception: Permission denial: writing to settings requires:android.permission.WRITE_SECURE_SETTINGS

Does anyone know how to disable of fix this permission issue?

Any help is greatly appreciated, thank you

1 Like

I am also stuck here.

if you find any solution please let me know also

Yes i did find a solution for this, basically there’s an extra setting for chinese phones,

In developer options, enable "USB Debugging (Security settings)

Detail in here https://forum.xda-developers.com/t/i-cant-enable-write_secure_settings-for-an-app-over-adb.3855596/

Hope it helps!