3

Is it possible to change default sms application on Android 4.4 without user knowledge? I'm trying to do it on a ROOTED Galaxy S5 using reflection and invoking system methods, so here is what I done so far:

Created small app that implements all things needed for app to be a SMS manager (as per http://android-developers.blogspot.in/2013/10/getting-your-sms-apps-ready-for-kitkat.html) and I can make it default sms app but Android asks me to confirm that in dialog. Now I'm exploring android source code and I found something in this class:

https://github.com/android/platform_packages_apps_settings/blob/2abbacb7d46657e5863eb2ef0035521ffc41a0a8/src/com/android/settings/SmsDefaultDialog.java

So I'm trying to invoke internal method:

SmsApplication.setDefaultApplication(mNewSmsApplicationData.mPackageName, this);

via reflection and here is how I done it so far:

Class[] params = new Class[2];
    params[0]=String.class;
    params[1]=Context.class;
    Class cls = null;
    try {
        cls = Class.forName("com.android.internal.telephony.SmsApplication");
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    }
    Method method = null;
    try {
        method = cls.getDeclaredMethod("getSmsApplicationData", params);
    } catch (NoSuchMethodException e) {
        e.printStackTrace();
    }
    try {
        Object[] params2 = new Object[2];
        params2[0]=getPackageName();
        params2[1]=getApplicationContext();
        Log.d("Current package", getPackageName());
        method.invoke(null, params2);
    } catch (InvocationTargetException e) {
        e.printStackTrace();
    }

And I made this app system app and put it into folder /system/priv-app, rebooted phone and started it successfully with adb, but when I click on the button that executes code above, nothing happens. No errors, no log output, but default app is still Messaging (com.android.mms).

Is there any way to do this?

Test User
  • 125
  • 2
  • 12

1 Answers1

0

This information contained in file /data/system/users/0/settings_secure.xml. For example, default application for SMS stored by key sms_default_application.

 <setting id="85" name="sms_default_application" value="com.google.android.talk" package="com.android.settings" />

More info you can find in this class: https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/provider/Settings.java#6067

Accordingly, if you have ROOT permissions, you can edit this file.

ragmon
  • 101
  • 1
  • 3
  • 7