Android 5.1 for the Nvidia Shield Tablet is Out!

Nvidia is quite good at delivering updates in a timely fashion. The producer of famous … more

Other than XDA (of Course), What’s Your Favorite Site That Covers Android?

There is a number of other great sites that cover … more

Introducing Voices of XDA: Have Your Ideas Heard

By far the greatest assets we have at XDA-Developers are you, the developers, the eager … more

Unofficial Xposed For Lollipop Touchwiz With Flashable Zip

XDA Recognized Developer arter97 has released an unofficial build … more
Post Reply Subscribe to Thread Email Thread

How to write to SMS Content Provider in Android KitKat WITHOUT being default SMS app

1st December 2013, 05:09 PM |#1  
stepic's Avatar
OP Senior Member
Flag Messina
Thanks Meter: 23
Donate to Me
we know that Google made huge changes on SMS management with the release of Android 4.4 KitKat.
In summary:
1) the user can choose a default SMS application and only this app can write to SMS content provider.
2) now there are two broadcast SMS_RECEIVED_ACTION (for all apps) and SMS_DELIVER_ACTION (only for the default app). You will get notified about an incoming SMS with both, but you cannot abort the broadcast anymore
If you want to delete (or to restore) an SMS, you have to become default app temporarily, annoying the user with two mandatory prompts.

Looking in Android sources we can find out that the default SMS app gets a special permission to write SMS with App Ops:

// Allow OP_WRITE_SMS for the newly configured default SMS app.
appOps.setMode(AppOpsManager.OP_WRITE_SMS, applicationData.mUid,
applicationData.mPackageName, AppOpsManager.MODE_ALLOWED);
and we also know that there is still a way to access App Ops in Android 4.4 KitKat:

From shell:
adb shell am start -a android.settings.SETTINGS -e ":android:show_fragment" ""
From your app:
Intent intent = new Intent(Intent.ACTION_MAIN);
ComponentName cn = new ComponentName("", "");
intent.putExtra(":android:show_fragment", "");
If you go to Messaging tab and look into permissions, you will find out that your non-default SMS app has WRITE SMS OFF. But you can also turn that ON because it isn't mutually exclusive with the default app.
You still require user interaction (but not root) or root access to write this secure setting.
I hope that some developer can benefit of this before Google lock down definitively App Ops access. Sorry, but it doesn't solve abort broadcast issue.

I found this issue on AOSP:
I also think that Google should change something with SMS. Why not let the user choose not one but more apps as "default" (like notification listener for example) and restore the ability to abort broadcast?

Best regards!
The Following 12 Users Say Thank You to stepic For This Useful Post: [ View ]
15th December 2013, 07:43 AM |#2  
Thanks Meter: 19
This has stopped working in 4.4.2.

Do anyone have an work around?
31st January 2014, 03:48 AM |#3  
Goliath27's Avatar
Senior Member
Thanks Meter: 21
Bump - need a way to fix the problem with SMS filtering. Numbers I've blocked with another app still get into my inbox defeating the purpose.

Sent from my i337 on Roids using xda premium
31st January 2014, 04:22 AM |#4  
chico260's Avatar
Senior Member
Thanks Meter: 134
Originally Posted by Goliath27

Bump - need a way to fix the problem with SMS filtering. Numbers I've blocked with another app still get into my inbox defeating the purpose.

Sent from my i337 on Roids using xda premium


Sent from my EVO using Tapatalk
22nd August 2014, 11:59 AM |#5  
Senior Member
Thanks Meter: 20
Edit : Answer Deleted
Last edited by celb; 22nd August 2014 at 12:13 PM.
29th January 2015, 11:30 PM |#6  
bartito's Avatar
Recognized Developer
Thanks Meter: 1,350
Donate to Me
How update this settings in my app if I have root privileges?
Post Reply Subscribe to Thread

app ops, sms
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes