So I have a rooted One plus one and I have my apk which is to be included as a system app. I have kept my apk in /system/priv-app/
which should give the app all required permission to work as a system app.
But I am getting the following error:
11-18 12:23:59.928 4470-4511/com.justswipe.service E/AndroidRuntime: FATAL EXCEPTION: Thread-2
Process: com.justswipe.service, PID: 4470
java.lang.SecurityException: Sending SMS message: uid 10111 does not have android.permission.SEND_SMS.
at android.os.Parcel.readException(Parcel.java:1684)
at android.os.Parcel.readException(Parcel.java:1637)
at com.android.internal.telephony.ISms$Stub$Proxy.sendTextForSubscriber(ISms.java:770)
at android.telephony.SmsManager.sendTextMessageInternal(SmsManager.java:318)
at android.telephony.SmsManager.sendTextMessage(SmsManager.java:301)
at com.justswipe.service.MainActivity$2.run(MainActivity.java:127)
at java.lang.Thread.run(Thread.java:761)
Following is the code I use to send sms:
SmsManager sm = SmsManager.getDefault();
sm.sendTextMessage("My_Phone_Number", null, message.toString(), sentPendingIntent, null);
Following are the permissions which I have used in Manifest:
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.RECEIVE_SMS"/>
<uses-permission android:name="android.permission.READ_SMS"/>
<uses-permission android:name="android.permission.SEND_SMS_NO_CONFIRMATION"/>
MyApp is a system app with no UI it runs on boot complete as a service.
Now the problem I am facing is that if I go to Settings->Apps->MyApp->Permissions Granted
and from there if I turn on the SMS permission and then if I reboot it sends the SMS.
Why is it that I need to turn on the SMS permission from settings, when I have already given it all the privileged permissions it must need?