WRITE_SECURE_SETTINGS permission error even when added in Manifest

前端 未结 6 1060
南方客
南方客 2020-11-28 14:28

I have added \"android.permission.WRITE_SECURE_SETTINGS\" in the Manifest. But still i get an error message saying - required \"WRITE_SECURE_SETTINGS\".

I have seen

相关标签:
6条回答
  • 2020-11-28 14:59

    Firstly, as you have read before, WRITE_SECURE_SETTINGS is NOT available to applications! So you cannot use this permission regardless whether you are on rooted or production builds.

    So, if you wish to enable this setting, create your own firmware that does what you need and load that firmware on whatever devices you wish. Or, contribute your changes to existing firmware mods (e.g., Cyanogen).

    Some other applications use techniques like Reflection using Java to gain access to functions not exposed via API, you can probably try the same.

    Secondly, adb remount does not work as is with production builds unless the phone is rooted or firmware enables it by default.

    0 讨论(0)
  • 2020-11-28 15:00

    For the api that I used, which required WRITE_SECURE_SETTINGS privileges, I had to include this in the manifest:

    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
    ...
    coreApp="true"
    android:sharedUserId="android.uid.system">
    
    <uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS"/>
    ...
    

    ref: https://github.com/android/platform_packages_apps_settings/blob/master/AndroidManifest.xml

    I also had to run the application as a system app (under: /system/app). Here is an how to: http://www.addictivetips.com/mobile/how-to-install-any-app-as-system-app-on-android/

    0 讨论(0)
  • 2020-11-28 15:01

    I would like to add that WRITE_SECURE_SETTINGS permission can be granted over adb and this approach does NOT require root. Here is a command:

    adb shell pm grant your.package.name android.permission.WRITE_SECURE_SETTINGS
    
    0 讨论(0)
  • 2020-11-28 15:03

    I recently struggled with this very thing. My client wanted an app that would turn NFC off when the device was charging (wireless charger) and then on when it was removed from the charger. I was running KitKat on my Nexus 7, and even though I had WRITE_SECURE_SETTINGS in the Manifest, and the app in /system/app/, it would not work.

    Turns out, that in 4.4 they added additional security. In 4.3 however, it works if three things are true:

    1. Manifest has WRITE_SECURE_SETTINGS
    2. App is in /system/app/
    3. The package is signed by a key (any key)

    I rooted the device using the awesome Nexus Root Toolkit (NRT) from http://www.wugfresh.com/nrt/ then installed BusyBox and system app mover from:

    https://play.google.com/store/apps/details?id=stericson.busybox https://play.google.com/store/apps/details?id=de.j4velin.systemappmover

    I installed my custom signed APK and moved it into place using system app mover, which then restarted the device. It worked perfectly. Hope this helps.

    0 讨论(0)
  • 2020-11-28 15:05

    I was able to fix this problem by enabling notification access.

    go to settings
    click on sound and notification
    scroll down
    click on notification access
    
    0 讨论(0)
  • 2020-11-28 15:25

    I met this situation too,and then i follow the rules below: 1.add WRITE_SECURE_SETTINGS in manifest 2.make my own firmware 3.add LOCAL_CERTIRICATE := platform

    0 讨论(0)
提交回复
热议问题