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

Search This thread

stepic

Senior Member
Nov 21, 2010
160
24
Messina
Hello,
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:

Code:
// 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:
Code:
adb shell am start -a android.settings.SETTINGS -e ":android:show_fragment" "com.android.settings.applications.AppOpsSummary"

From your app:
Code:
Intent intent = new Intent(Intent.ACTION_MAIN);
ComponentName cn = new ComponentName("com.android.settings", "com.android.settings.Settings");
intent.setComponent(cn);
intent.putExtra(":android:show_fragment", "com.android.settings.applications.AppOpsSummary");
startActivity(intent);

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: https://code.google.com/p/android/issues/detail?id=61684
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!
 

Goliath27

Senior Member
Nov 14, 2011
472
24
Cleveland
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
 
D

Deleted member 267841

Guest
How update this settings in my app if I have root privileges?
Thanks
 

Top Liked Posts

  • There are no posts matching your filters.
  • 12
    Hello,
    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:

    Code:
    // 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:
    Code:
    adb shell am start -a android.settings.SETTINGS -e ":android:show_fragment" "com.android.settings.applications.AppOpsSummary"

    From your app:
    Code:
    Intent intent = new Intent(Intent.ACTION_MAIN);
    ComponentName cn = new ComponentName("com.android.settings", "com.android.settings.Settings");
    intent.setComponent(cn);
    intent.putExtra(":android:show_fragment", "com.android.settings.applications.AppOpsSummary");
    startActivity(intent);

    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: https://code.google.com/p/android/issues/detail?id=61684
    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!