1

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?

ישו אוהב אותך
  • 28,609
  • 11
  • 78
  • 96
Akshay Shah
  • 748
  • 1
  • 8
  • 23
  • DId you ask the permission on run ? I think this is a Runtime Permission from Android 6.0 : [Documentation](https://developer.android.com/guide/topics/security/permissions.html#normal-dangerous) – AxelH Nov 18 '16 at 07:24
  • Possible duplicate of [How do I implelment Android 6.0 Runtime Permissions On Existing App](http://stackoverflow.com/questions/34959229/how-do-i-implelment-android-6-0-runtime-permissions-on-existing-app) – AxelH Nov 18 '16 at 07:30
  • the app does not have a ui.. i do not want it to bombard the user with any permission dialog thats the only reason i have kept it in /system/priv-app/ so as it to behave like a system app with all permissions granted – Akshay Shah Nov 18 '16 at 07:38
  • The manifest is not used for this permission in Android 6.0, so if you never ask the permission to send SMS, you won't be able to, that's what the exception tells you! Easy, open the settings and find you app, you should see the Permission needed, you should be able to activate it by hand (might need to add a `permission-23` or to be list there). If it work with that, then you will need to ask permission. **Even the SMS App of Google asked for the permission on the first run !!!** – AxelH Nov 18 '16 at 07:42
  • So according to your comment without asking permission on runtime i wont be able to send sms even if i am a vendor who manufactures rom with privileged permissions or signing the apk with firmware key ? – Akshay Shah Nov 18 '16 at 07:48
  • Need confirmation from someone who actually write some code on a Rom but I would say yes ... – AxelH Nov 18 '16 at 07:54
  • Thanks for your comments would have to dig deeper into it. – Akshay Shah Nov 18 '16 at 08:01

0 Answers0