|
|
@ -15,7 +15,6 @@ import android.telephony.SubscriptionInfo;
|
|
|
|
import android.telephony.SubscriptionManager;
|
|
|
|
import android.telephony.SubscriptionManager;
|
|
|
|
import android.text.TextUtils;
|
|
|
|
import android.text.TextUtils;
|
|
|
|
|
|
|
|
|
|
|
|
import androidx.annotation.NonNull;
|
|
|
|
|
|
|
|
import androidx.core.app.ActivityCompat;
|
|
|
|
import androidx.core.app.ActivityCompat;
|
|
|
|
|
|
|
|
|
|
|
|
import com.xypower.common.RegexUtil;
|
|
|
|
import com.xypower.common.RegexUtil;
|
|
|
@ -40,6 +39,7 @@ public class SimUtil {
|
|
|
|
//自定义ACTION常数 作为广播的IntentFilter识别常数
|
|
|
|
//自定义ACTION常数 作为广播的IntentFilter识别常数
|
|
|
|
public static String SMS_SEND_ACTION = "com.xypower.mpmaster.SMS_SEND_ACTION";
|
|
|
|
public static String SMS_SEND_ACTION = "com.xypower.mpmaster.SMS_SEND_ACTION";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static String SMSTYPE = "smstype";
|
|
|
|
public static String SMSTYPE = "smstype";
|
|
|
|
|
|
|
|
|
|
|
|
public static String SMSIFCORRECT = "smsifcorrect";
|
|
|
|
public static String SMSIFCORRECT = "smsifcorrect";
|
|
|
@ -61,12 +61,12 @@ public class SimUtil {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (content.contains(SmsTypeEnum.REBOOT1.value())) {
|
|
|
|
if (content.contains(SmsTypeEnum.REBOOT1.value())) {
|
|
|
|
ifmessageCorrect = true;
|
|
|
|
ifmessageCorrect = true;
|
|
|
|
sendmessage = content + " OK";
|
|
|
|
|
|
|
|
sendtype = SmsTypeEnum.REBOOT1.value();
|
|
|
|
sendtype = SmsTypeEnum.REBOOT1.value();
|
|
|
|
|
|
|
|
sendmessage = content + " OK";
|
|
|
|
} else if (content.contains(SmsTypeEnum.REBOOT2.value())) {
|
|
|
|
} else if (content.contains(SmsTypeEnum.REBOOT2.value())) {
|
|
|
|
ifmessageCorrect = true;
|
|
|
|
ifmessageCorrect = true;
|
|
|
|
sendmessage = content + " OK";
|
|
|
|
|
|
|
|
sendtype = SmsTypeEnum.REBOOT2.value();
|
|
|
|
sendtype = SmsTypeEnum.REBOOT2.value();
|
|
|
|
|
|
|
|
sendmessage = content + " OK";
|
|
|
|
} else if (content.contains(SmsTypeEnum.SET_YW_SCHEDULE.value())) {
|
|
|
|
} else if (content.contains(SmsTypeEnum.SET_YW_SCHEDULE.value())) {
|
|
|
|
ifmessageCorrect = true;
|
|
|
|
ifmessageCorrect = true;
|
|
|
|
String[] split1 = StringUtils.splitString1(content);
|
|
|
|
String[] split1 = StringUtils.splitString1(content);
|
|
|
@ -408,8 +408,22 @@ public class SimUtil {
|
|
|
|
sendtype = SmsTypeEnum.TAKE_PHOTO.value();
|
|
|
|
sendtype = SmsTypeEnum.TAKE_PHOTO.value();
|
|
|
|
ifmessageCorrect = true;
|
|
|
|
ifmessageCorrect = true;
|
|
|
|
String[] split = StringUtils.splitString1(content);
|
|
|
|
String[] split = StringUtils.splitString1(content);
|
|
|
|
Integer channel = StringUtils.convert2Int(split[0]);
|
|
|
|
if (split != null && split.length == 3) {
|
|
|
|
sendmessage = getSendString(content, ifmessageCorrect);
|
|
|
|
ifmessageCorrect = true;
|
|
|
|
|
|
|
|
Integer channel = StringUtils.convert2Int(split[0]);
|
|
|
|
|
|
|
|
Integer preset = StringUtils.convert2Int(split[1]);
|
|
|
|
|
|
|
|
Integer type = StringUtils.convert2Int(split[2]);
|
|
|
|
|
|
|
|
if (channel != null) {
|
|
|
|
|
|
|
|
boolean photoOrVideo;
|
|
|
|
|
|
|
|
if (type == 0) {
|
|
|
|
|
|
|
|
photoOrVideo = true;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
photoOrVideo = false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
UpdateSysConfigUtil.takePhotoOrVideo(context, channel, preset, photoOrVideo);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
sendmessage = getSendString(content, ifmessageCorrect);
|
|
|
|
|
|
|
|
}
|
|
|
|
} else if (content.contains(SmsTypeEnum.SET_HEART.value())) {
|
|
|
|
} else if (content.contains(SmsTypeEnum.SET_HEART.value())) {
|
|
|
|
sendtype = SmsTypeEnum.SET_HEART.value();
|
|
|
|
sendtype = SmsTypeEnum.SET_HEART.value();
|
|
|
|
String[] split1 = StringUtils.splitString1(content);
|
|
|
|
String[] split1 = StringUtils.splitString1(content);
|
|
|
@ -438,7 +452,6 @@ public class SimUtil {
|
|
|
|
} else if (content.contains(SmsTypeEnum.GET_TP.value())) {
|
|
|
|
} else if (content.contains(SmsTypeEnum.GET_TP.value())) {
|
|
|
|
sendtype = SmsTypeEnum.GET_TP.value();
|
|
|
|
sendtype = SmsTypeEnum.GET_TP.value();
|
|
|
|
ifmessageCorrect = true;
|
|
|
|
ifmessageCorrect = true;
|
|
|
|
String[] split = StringUtils.splitString1(content);
|
|
|
|
|
|
|
|
int tb = UpdateSysConfigUtil.getTB(context);
|
|
|
|
int tb = UpdateSysConfigUtil.getTB(context);
|
|
|
|
sendmessage = SmsTypeEnum.GET_TP.value() + "=" + tb;
|
|
|
|
sendmessage = SmsTypeEnum.GET_TP.value() + "=" + tb;
|
|
|
|
} else if (content.contains(SmsTypeEnum.SET_PACKAGE.value())) {
|
|
|
|
} else if (content.contains(SmsTypeEnum.SET_PACKAGE.value())) {
|
|
|
@ -496,6 +509,7 @@ public class SimUtil {
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static String getSendString(String content, boolean ifmessageCorrect) {
|
|
|
|
private static String getSendString(String content, boolean ifmessageCorrect) {
|
|
|
|
String sendmessage;
|
|
|
|
String sendmessage;
|
|
|
|
String menssageBack = "";
|
|
|
|
String menssageBack = "";
|
|
|
@ -588,7 +602,8 @@ public class SimUtil {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//指定sim卡位置发送短信
|
|
|
|
//指定sim卡位置发送短信
|
|
|
|
public static void sendSms(Context mContext, int slot, String sender, String message, String value, boolean ifmessageCorrect) {
|
|
|
|
public static void sendSms(Context mContext, int slot, String sender, String message, String
|
|
|
|
|
|
|
|
value, boolean ifmessageCorrect) {
|
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
|
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
|
|
|
|
SubscriptionManager localSubscriptionManager = SubscriptionManager.from(mContext);
|
|
|
|
SubscriptionManager localSubscriptionManager = SubscriptionManager.from(mContext);
|
|
|
|
if (ActivityCompat.checkSelfPermission(mContext, Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED) {
|
|
|
|
if (ActivityCompat.checkSelfPermission(mContext, Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED) {
|
|
|
@ -686,7 +701,8 @@ public class SimUtil {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//申请该权限
|
|
|
|
//申请该权限
|
|
|
|
public static void requestOnePermission(Activity activity, String permission, int permissionCode) {
|
|
|
|
public static void requestOnePermission(Activity activity, String permission,
|
|
|
|
|
|
|
|
int permissionCode) {
|
|
|
|
if (activity != null) {
|
|
|
|
if (activity != null) {
|
|
|
|
activity.requestPermissions(new String[]{permission}, permissionCode);
|
|
|
|
activity.requestPermissions(new String[]{permission}, permissionCode);
|
|
|
|
}
|
|
|
|
}
|
|
|
|