实现短信查询sim卡信息

hdrplus
Matthew 11 months ago
parent 12731b466f
commit ed07a6f67f

@ -583,9 +583,9 @@ public class SimUtil {
if (pos != -1) { if (pos != -1) {
ss = ss.substring(0, pos); ss = ss.substring(0, pos);
result.append(",SS=" + ss); result.append(",SL=" + ss);
int ssVal = Integer.parseInt(ss); int ssVal = Integer.parseInt(ss);
result.append(",SL=" + Integer.toString(MpMasterService.getSignalLevel(ssVal, 5))); result.append("/" + Integer.toString(MpMasterService.getSignalLevel(ssVal, 5)));
} }
} }
@ -594,7 +594,7 @@ public class SimUtil {
// boolean b2 = tm.isDataCapable(); // boolean b2 = tm.isDataCapable();
boolean b3 = tm.isDataRoamingEnabled(); boolean b3 = tm.isDataRoamingEnabled();
result.append(isActiveSlot ? ",默认数据传输" : ",非默认数据传输"); result.append(isActiveSlot ? ",默认" : ",");
result.append(" "); result.append(" ");
} }
@ -603,7 +603,7 @@ public class SimUtil {
ex.printStackTrace(); ex.printStackTrace();
} }
return result.toString(); return result.toString().trim();
} }
public static String getSimStateName(int simState) { public static String getSimStateName(int simState) {
@ -653,7 +653,7 @@ public class SimUtil {
case TelephonyManager.NETWORK_TYPE_LTE: case TelephonyManager.NETWORK_TYPE_LTE:
return "4G"; return "4G";
default: default:
return "UNKNOWN"; return "未知";
} }
} }
@ -736,12 +736,10 @@ public class SimUtil {
SubscriptionInfo simInfoAnother = null; SubscriptionInfo simInfoAnother = null;
if (doubleSim) { if (doubleSim) {
if (localList != null && localList.size() > 1) { if (localList != null && localList.size() > 1) {
SubscriptionInfo simInfo1 = (SubscriptionInfo) localList.get(0);
SubscriptionInfo simInfo2 = (SubscriptionInfo) localList.get(1);
if (slot == 0) { if (slot == 0) {
simInfoAnother = simInfo1; simInfoAnother = (SubscriptionInfo) localList.get(0);
} else { } else {
simInfoAnother = simInfo2; simInfoAnother = (SubscriptionInfo) localList.get(1);
} }
} }
} }
@ -756,7 +754,18 @@ public class SimUtil {
//deliveryIntent参数为传送后接受的广播信息PendingIntent //deliveryIntent参数为传送后接受的广播信息PendingIntent
// PendingIntent deliverPI = PendingIntent.getBroadcast(mContext,0,itDeliver,0); // PendingIntent deliverPI = PendingIntent.getBroadcast(mContext,0,itDeliver,0);
if (simInfoAnother != null) { if (simInfoAnother != null) {
SmsManager.getSmsManagerForSubscriptionId(simInfoAnother.getSubscriptionId()).sendTextMessage(sender, null, message, sendPI, null); SmsManager smsManager = SmsManager.getSmsManagerForSubscriptionId(simInfoAnother.getSubscriptionId());
if (message.length() > 70) {
ArrayList<String> msgs = smsManager.divideMessage(message);
ArrayList<PendingIntent> sentIntents = new ArrayList<PendingIntent>();
for(int i = 0;i < msgs.size(); i++){
sentIntents.add(sendPI);
}
smsManager.sendMultipartTextMessage(sender, null, msgs, sentIntents, null);
} else {
smsManager.sendTextMessage(sender, null, message, sendPI, null);
}
} }
} }
} }

@ -1,9 +1,13 @@
package com.xypower.mpmaster.sms; package com.xypower.mpmaster.sms;
import android.app.Activity;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle;
import android.telephony.SmsManager;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log;
import com.dev.devapi.api.SysApi; import com.dev.devapi.api.SysApi;
import com.xypower.mpmaster.MpMasterService; import com.xypower.mpmaster.MpMasterService;
@ -18,6 +22,13 @@ public class SmsSendReceiver extends BroadcastReceiver {
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
final String action = intent.getAction(); final String action = intent.getAction();
int resultCode = getResultCode();
// String resultData = getResultData();
// Bundle resultExtras = getResultExtras(true);
if (resultCode != Activity.RESULT_OK) {
// Log.i("SMS", Integer.toString(resultCode));
}
if (SimUtil.SMS_SEND_ACTION.equals(action)) { if (SimUtil.SMS_SEND_ACTION.equals(action)) {
final String type = intent.getStringExtra(SimUtil.SMSTYPE); final String type = intent.getStringExtra(SimUtil.SMSTYPE);
if (TextUtils.isEmpty(type)) { if (TextUtils.isEmpty(type)) {

Loading…
Cancel
Save