WRITE_SECURE_SETTINGS + root

2019-07-27 11:09发布

my application gives the user the option to grant root access to allow access to some system function (NFC). By default it never asks for root.

So, after permissions is granted, I figured it should work, but I am still getting the dreaded:

08-10 22:06:49.320: W/System.err(9421): Caused by: java.lang.SecurityException: WRITE_SECURE_SETTINGS permission required: Neither user 10174 nor current process has android.permission.WRITE_SECURE_SETTINGS.

error. Am I missing something? I am asking for the WRITE_SECURE_SETTINGS permission, so that can't be it.

The funny thing is I had NFC enable/ disable working, but after I installed a new Rom, I keep getting this error. It updated from 4.0.3 to 4.0.4, but no changes to the code in question as far as I can tell...any ideas?

标签: android root
2条回答
啃猪蹄的小仙女
2楼-- · 2019-07-27 11:12

It's possible you can get your app to run as root. For example, I got the WRITE_SECURE_SETTINGS permission required error when I ran:

String output = ProcessUtils.runProcess(MainService.this, "wm", "overscan", "0,0,10,10");

But I got around the issue (on a rooted device) via:

String output = ProcessUtils.runProcess(MainService.this, "su", "0", "sh", "-c", "wm overscan 0,0,10,10");
查看更多
beautiful°
3楼-- · 2019-07-27 11:35

Am I missing something?

You are missing the WRITE_SECURE_SETTINGS permission.

I am asking for the WRITE_SECURE_SETTINGS permission, so that can't be it.

AFAIK, being root has nothing to do with permissions, directly. To hold WRITE_SECURE_SETTINGS, your app must either be signed by the same signing certificate that signed the firmware or be installed on the system partition. Being root is neither of those things.

查看更多
登录 后发表回答