展讯芯片组.双SIM卡应用程序,用于从指定的SIM卡插槽发送短信.(<22)



我正在尝试为展讯芯片组智能手机开发安卓应用程序。此应用需要指定要发送短信或执行电话呼叫的 SIM 卡(sim1 或 sim2)。

我能够在这里找到联发科API的API,它在android工作室中用作插件。

我尝试使用本文中提到的 adb shell。这不起作用,两个命令都通过sim1发送短信。两个命令:

1. service call isms 5 s16 "PhoneNumber" i32 0 i32 0 s16 "BodyText" 2. service call isms2 5 s16 "PhoneNumber" i32 0 i32 0 s16 "BodyText"

当我列出服务调用时,有 telephony.registry0 和 telephony.registry1。

我尝试使用本文中提到的反射。 短信仅从 sim1 发送。

难道没有任何API或插件可用于展讯吗

注意:我知道这不是棒棒糖和更高版本的Android的困境。但我正在尝试为 KitKat 版本构建此应用程序。

附言我甚至尝试联系芯片组公司。但遗憾的是没有回应。

为此,您需要使用反射。以下代码对我有用:

public class SimUtil {
public static boolean sendSMS(Context ctx, int simID, String toNum, String centerNum, String smsText, PendingIntent sentIntent, PendingIntent deliveryIntent) {
String name;
try {
    if (simID == 0) {
        name = "isms0";
    } else if (simID == 1) {
        name = "isms1";
    } else {
        throw new Exception("can not get service which for sim '" + simID + "', only 0,1 accepted as values");
    }
    try
    {
        Method method = Class.forName("android.os.ServiceManager").getDeclaredMethod("getService", new Class[]{String.class});
        method.setAccessible(true);
        Object param = method.invoke(null, new Object[]{name});
        if (param == null)
        {
            throw new RuntimeException("can not get service which is named '" + name + "'");
        }
        method = Class.forName("com.android.internal.telephony.ISms$Stub").getDeclaredMethod("asInterface", new Class[]{IBinder.class});
        method.setAccessible(true);
        Object stubObj = method.invoke(null, new Object[]{param});
        method = stubObj.getClass().getMethod("sendText", String.class, String.class, String.class, String.class, PendingIntent.class, PendingIntent.class);
        method.invoke(stubObj, ctx.getPackageName(), toNum, centerNum, smsText, sentIntent, deliveryIntent);
    } catch (ClassNotFoundException e)
    {
        throw new RuntimeException(e);
    } catch (NoSuchMethodException e)
    {
        throw new RuntimeException(e);
    } catch (InvocationTargetException e)
    {
        throw new RuntimeException(e);
    } catch (IllegalAccessException e)
    {
        throw new RuntimeException(e);
    }
    return true;
} catch (ClassNotFoundException e) {
    Log.e("Exception", "ClassNotFoundException:" + e.getMessage());
} catch (NoSuchMethodException e) {
    Log.e("Exception", "NoSuchMethodException:" + e.getMessage());
} catch (InvocationTargetException e) {
    Log.e("Exception", "InvocationTargetException:" + e.getMessage());
} catch (IllegalAccessException e) {
    Log.e("Exception", "IllegalAccessException:" + e.getMessage());
} catch (Exception e) {
    Log.e("Exception", "Exception:" + e);
}
return false;
}
}

要确定您的SIM卡插槽承载哪些ism值,请查看此评论。

有关更多详细信息,请查看此帖子。

最新更新