|
|
@ -7,12 +7,16 @@ import android.app.PendingIntent;
|
|
|
|
import android.content.Context;
|
|
|
|
import android.content.Context;
|
|
|
|
import android.content.Intent;
|
|
|
|
import android.content.Intent;
|
|
|
|
import android.content.pm.PackageManager;
|
|
|
|
import android.content.pm.PackageManager;
|
|
|
|
|
|
|
|
import android.net.ConnectivityManager;
|
|
|
|
|
|
|
|
import android.net.Network;
|
|
|
|
|
|
|
|
import android.net.NetworkInfo;
|
|
|
|
import android.os.Build;
|
|
|
|
import android.os.Build;
|
|
|
|
import android.os.Bundle;
|
|
|
|
import android.os.Bundle;
|
|
|
|
import android.telephony.SmsManager;
|
|
|
|
import android.telephony.SmsManager;
|
|
|
|
import android.telephony.SmsMessage;
|
|
|
|
import android.telephony.SmsMessage;
|
|
|
|
import android.telephony.SubscriptionInfo;
|
|
|
|
import android.telephony.SubscriptionInfo;
|
|
|
|
import android.telephony.SubscriptionManager;
|
|
|
|
import android.telephony.SubscriptionManager;
|
|
|
|
|
|
|
|
import android.telephony.TelephonyManager;
|
|
|
|
import android.text.TextUtils;
|
|
|
|
import android.text.TextUtils;
|
|
|
|
|
|
|
|
|
|
|
|
import androidx.core.app.ActivityCompat;
|
|
|
|
import androidx.core.app.ActivityCompat;
|
|
|
@ -20,9 +24,11 @@ import androidx.core.app.ActivityCompat;
|
|
|
|
import com.dev.devapi.api.SysApi;
|
|
|
|
import com.dev.devapi.api.SysApi;
|
|
|
|
import com.xypower.common.MicroPhotoContext;
|
|
|
|
import com.xypower.common.MicroPhotoContext;
|
|
|
|
import com.xypower.common.RegexUtil;
|
|
|
|
import com.xypower.common.RegexUtil;
|
|
|
|
|
|
|
|
import com.xypower.mpmaster.MpMasterService;
|
|
|
|
|
|
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
import java.util.Base64;
|
|
|
|
import java.util.Base64;
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.HashMap;
|
|
|
@ -425,6 +431,10 @@ public class SimUtil {
|
|
|
|
ifmessageCorrect = true;
|
|
|
|
ifmessageCorrect = true;
|
|
|
|
int hb = UpdateSysConfigUtil.getHB(context);
|
|
|
|
int hb = UpdateSysConfigUtil.getHB(context);
|
|
|
|
sendmessage = SmsTypeEnum.GET_HEART.value() + "=" + hb;
|
|
|
|
sendmessage = SmsTypeEnum.GET_HEART.value() + "=" + hb;
|
|
|
|
|
|
|
|
} else if (content.contains(SmsTypeEnum.SIMCARD.value())) {
|
|
|
|
|
|
|
|
sendtype = SmsTypeEnum.SIMCARD.value();
|
|
|
|
|
|
|
|
ifmessageCorrect = true;
|
|
|
|
|
|
|
|
sendmessage = getSimcardInfo(context);
|
|
|
|
} else if (content.contains(SmsTypeEnum.SET_TP.value())) {
|
|
|
|
} else if (content.contains(SmsTypeEnum.SET_TP.value())) {
|
|
|
|
sendtype = SmsTypeEnum.SET_TP.value();
|
|
|
|
sendtype = SmsTypeEnum.SET_TP.value();
|
|
|
|
String[] split1 = StringUtils.splitString1(content);
|
|
|
|
String[] split1 = StringUtils.splitString1(content);
|
|
|
@ -519,6 +529,134 @@ public class SimUtil {
|
|
|
|
return sendmessage;
|
|
|
|
return sendmessage;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static String getSimcardInfo(Context context) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
StringBuilder result = new StringBuilder();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SubscriptionManager subscriptionManager = (SubscriptionManager) context.getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE);
|
|
|
|
|
|
|
|
ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
|
|
|
|
|
|
|
TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int activeSubscriptionInfoCount = subscriptionManager.getActiveSubscriptionInfoCountMax();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int activeSubId = SubscriptionManager.getActiveDataSubscriptionId();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (int slotIdx = 0; slotIdx < activeSubscriptionInfoCount; slotIdx++) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// SIM1:网络类型(2G/3G/4G)、信号强度、信号等级、网络状态(开启/关闭)、IP地址
|
|
|
|
|
|
|
|
// SIM2:网络类型(2G/3G/4G)、信号强度、信号等级、网络状态(开启/关闭)、IP地址
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
result.append("SIM" + Integer.toString(slotIdx + 1) + "=");
|
|
|
|
|
|
|
|
int subIds[] = subscriptionManager.getSubscriptionIds(slotIdx);
|
|
|
|
|
|
|
|
if (subIds == null || subIds.length == 0) {
|
|
|
|
|
|
|
|
result.append("未激活 ");
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
boolean isActiveSlot = false;
|
|
|
|
|
|
|
|
for (int subId : subIds) {
|
|
|
|
|
|
|
|
if (subId == activeSubId) {
|
|
|
|
|
|
|
|
isActiveSlot = true;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TelephonyManager tm = telephonyManager.createForSubscriptionId(subIds[0]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SubscriptionInfo subscriptionInfo = subscriptionManager.getActiveSubscriptionInfo(subIds[0]);
|
|
|
|
|
|
|
|
if (subscriptionInfo == null) {
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int simState = telephonyManager.getSimState(slotIdx);
|
|
|
|
|
|
|
|
result.append(subscriptionInfo.getCarrierName());
|
|
|
|
|
|
|
|
int networkType = tm.getDataNetworkType();
|
|
|
|
|
|
|
|
result.append("," + getNetworkName(networkType));
|
|
|
|
|
|
|
|
result.append("," + getSimStateName(simState));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String ss = MpMasterService.getSystemProperty("vendor.ril.nw.signalstrength.lte." + Integer.toString(slotIdx + 1));
|
|
|
|
|
|
|
|
if (!TextUtils.isEmpty(ss)) {
|
|
|
|
|
|
|
|
int pos = ss.indexOf(',');
|
|
|
|
|
|
|
|
if (pos != -1) {
|
|
|
|
|
|
|
|
ss = ss.substring(0, pos);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
result.append(",SS=" + ss);
|
|
|
|
|
|
|
|
int ssVal = Integer.parseInt(ss);
|
|
|
|
|
|
|
|
result.append(",SL=" + Integer.toString(MpMasterService.getSignalLevel(ssVal, 5)));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
boolean b1 = tm.isDataConnectionAllowed();
|
|
|
|
|
|
|
|
// boolean b2 = tm.isDataCapable();
|
|
|
|
|
|
|
|
boolean b3 = tm.isDataRoamingEnabled();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
result.append(isActiveSlot ? ",默认数据传输" : ",非默认数据传输");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
result.append(" ");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
|
|
|
ex.printStackTrace();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return result.toString();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static String getSimStateName(int simState) {
|
|
|
|
|
|
|
|
switch (simState) {
|
|
|
|
|
|
|
|
case TelephonyManager.SIM_STATE_UNKNOWN:
|
|
|
|
|
|
|
|
return "未知";
|
|
|
|
|
|
|
|
case TelephonyManager.SIM_STATE_ABSENT:
|
|
|
|
|
|
|
|
return "无卡";
|
|
|
|
|
|
|
|
case TelephonyManager.SIM_STATE_PIN_REQUIRED:
|
|
|
|
|
|
|
|
return "PIN解锁";
|
|
|
|
|
|
|
|
case TelephonyManager.SIM_STATE_PUK_REQUIRED:
|
|
|
|
|
|
|
|
return "PUK解锁";
|
|
|
|
|
|
|
|
case TelephonyManager.SIM_STATE_NETWORK_LOCKED:
|
|
|
|
|
|
|
|
return "锁定";
|
|
|
|
|
|
|
|
case TelephonyManager.SIM_STATE_READY:
|
|
|
|
|
|
|
|
return "就绪";
|
|
|
|
|
|
|
|
case TelephonyManager.SIM_STATE_NOT_READY:
|
|
|
|
|
|
|
|
return "未就绪";
|
|
|
|
|
|
|
|
case TelephonyManager.SIM_STATE_PERM_DISABLED:
|
|
|
|
|
|
|
|
return "";
|
|
|
|
|
|
|
|
case TelephonyManager.SIM_STATE_CARD_IO_ERROR:
|
|
|
|
|
|
|
|
return "错误";
|
|
|
|
|
|
|
|
case TelephonyManager.SIM_STATE_CARD_RESTRICTED:
|
|
|
|
|
|
|
|
return "限制";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return "";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static String getNetworkName(int networkType) {
|
|
|
|
|
|
|
|
switch (networkType) {
|
|
|
|
|
|
|
|
case TelephonyManager.NETWORK_TYPE_GPRS:
|
|
|
|
|
|
|
|
case TelephonyManager.NETWORK_TYPE_EDGE:
|
|
|
|
|
|
|
|
case TelephonyManager.NETWORK_TYPE_CDMA:
|
|
|
|
|
|
|
|
case TelephonyManager.NETWORK_TYPE_1xRTT:
|
|
|
|
|
|
|
|
case TelephonyManager.NETWORK_TYPE_IDEN:
|
|
|
|
|
|
|
|
return "2G";
|
|
|
|
|
|
|
|
case TelephonyManager.NETWORK_TYPE_UMTS:
|
|
|
|
|
|
|
|
case TelephonyManager.NETWORK_TYPE_EVDO_0:
|
|
|
|
|
|
|
|
case TelephonyManager.NETWORK_TYPE_EVDO_A:
|
|
|
|
|
|
|
|
case TelephonyManager.NETWORK_TYPE_HSDPA:
|
|
|
|
|
|
|
|
case TelephonyManager.NETWORK_TYPE_HSUPA:
|
|
|
|
|
|
|
|
case TelephonyManager.NETWORK_TYPE_HSPA:
|
|
|
|
|
|
|
|
case TelephonyManager.NETWORK_TYPE_EVDO_B:
|
|
|
|
|
|
|
|
case TelephonyManager.NETWORK_TYPE_EHRPD:
|
|
|
|
|
|
|
|
case TelephonyManager.NETWORK_TYPE_HSPAP:
|
|
|
|
|
|
|
|
return "3G";
|
|
|
|
|
|
|
|
case TelephonyManager.NETWORK_TYPE_LTE:
|
|
|
|
|
|
|
|
return "4G";
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
return "UNKNOWN";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//短信解析
|
|
|
|
//短信解析
|
|
|
|
public static SmsMessageModel getSMSInfo(Intent intent) {
|
|
|
|
public static SmsMessageModel getSMSInfo(Intent intent) {
|
|
|
|
SmsMessageModel smsMessageModel = new SmsMessageModel();
|
|
|
|
SmsMessageModel smsMessageModel = new SmsMessageModel();
|
|
|
|