Android java.lang.SecurityException for system app

2019-08-06 04:09发布

I installed an app as a system app.

This is the manifest file of the app:

<manifest android:versionCode="1" android:versionName="1.0" package="com.myapp">
  <uses-sdk android:minSdkVersion="3"/>
  <uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS"/>
  <uses-permission android:name="android.permission.WRITE_SETTINGS"/>
  <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
  <application android:label="@id/0x7F030001" android:icon="@id/0x7F020000" android:debuggable="true">
    <receiver android:name=".MyReceiver">
      <intent-filter>
        <action android:name="com.myapp.MyReceiver"/>
      </intent-filter>
    </receiver>
  </application>
</manifest>

now in my app I get an exception with this message:

java.lang.SecurityException: Permission denial: writing to secure settings requires android.permission.WRITE_SECURE_SETTINGS

but as you can see my app does request the permission and is installed in /system/app folder

Can someone help me understand what's wrong and why I get the exception

Thanks

EDIT:

I think the problem is connected to something that has changed in android 4.4 version (API 19) because in older versions of android it does work!

2条回答
贪生不怕死
2楼-- · 2019-08-06 04:19

You need to move your application from /system/app to /system/priv-app

Your app should be privileged app to access android.permission.WRITE_SECURE_SETTINGS

查看更多
够拽才男人
3楼-- · 2019-08-06 04:28

plz be sure the Android.mk is correct, I got the same problem just because the Android.mk, I got a mistake at LOCAL_CERTIFICATE := platform

查看更多
登录 后发表回答