diff --git a/mpmaster/src/main/java/com/xypower/mpmaster/sms/SmsSendReceiver.java b/mpmaster/src/main/java/com/xypower/mpmaster/sms/SmsSendReceiver.java index dae0519f..466b01bf 100644 --- a/mpmaster/src/main/java/com/xypower/mpmaster/sms/SmsSendReceiver.java +++ b/mpmaster/src/main/java/com/xypower/mpmaster/sms/SmsSendReceiver.java @@ -3,6 +3,7 @@ package com.xypower.mpmaster.sms; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; +import android.text.TextUtils; import com.dev.devapi.api.SysApi; @@ -15,36 +16,55 @@ import com.dev.devapi.api.SysApi; public class SmsSendReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { - String action = intent.getAction(); + final String action = intent.getAction(); if (SimUtil.SMS_SEND_ACTION.equals(action)) { - String type = intent.getStringExtra(SimUtil.SMSTYPE); - if (type.contains(SmsTypeEnum.REBOOT1.value())) { - SysApi.reboot(context); - } else if (type.contains(SmsTypeEnum.REBOOT2.value())) { - SysApi.reboot(context); - } else if (type.contains(SmsTypeEnum.SET_YW_SCHEDULE.value())) { - UpdateSysConfigUtil.restartMasterApp(context); - } else if (type.contains(SmsTypeEnum.SET_OPERATE.value())) { - UpdateSysConfigUtil.restartMasterApp(context); - } else if (type.contains(SmsTypeEnum.SET_OPERATE_URL.value())) { - UpdateSysConfigUtil.restartMasterApp(context); - } else if (type.contains(SmsTypeEnum.SET_CMDID.value())) { - UpdateSysConfigUtil.restartApp(context); - } else if (type.contains(SmsTypeEnum.SET_IP.value())) { - UpdateSysConfigUtil.restartApp(context); - } else if (type.contains(SmsTypeEnum.SET_OSD.value())) { - UpdateSysConfigUtil.restartApp(context); - } else if (type.contains(SmsTypeEnum.SET_PHOTO_SCHEDULE_LIST.value())) { - UpdateSysConfigUtil.restartApp(context); - } else if (type.contains(SmsTypeEnum.SET_RESOLUTION.value())) { - UpdateSysConfigUtil.restartApp(context); - } else if (type.contains(SmsTypeEnum.SET_HEART.value())) { - UpdateSysConfigUtil.restartApp(context); - } else if (type.contains(SmsTypeEnum.SET_TP.value())) { - UpdateSysConfigUtil.restartApp(context); - } else if (type.contains(SmsTypeEnum.SET_PACKAGE.value())) { - UpdateSysConfigUtil.restartApp(context); + final String type = intent.getStringExtra(SimUtil.SMSTYPE); + if (TextUtils.isEmpty(type)) { + return; } + + Thread th = new Thread(new Runnable() { + @Override + public void run() { + try { + processSms(context, intent, action, type); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + }); + + th.start(); + } + } + + public void processSms(final Context context, Intent intent, final String action, final String type) { + if (type.contains(SmsTypeEnum.REBOOT1.value())) { + SysApi.reboot(context); + } else if (type.contains(SmsTypeEnum.REBOOT2.value())) { + SysApi.reboot(context); + } else if (type.contains(SmsTypeEnum.SET_YW_SCHEDULE.value())) { + UpdateSysConfigUtil.restartMasterApp(context); + } else if (type.contains(SmsTypeEnum.SET_OPERATE.value())) { + UpdateSysConfigUtil.restartMasterApp(context); + } else if (type.contains(SmsTypeEnum.SET_OPERATE_URL.value())) { + UpdateSysConfigUtil.restartMasterApp(context); + } else if (type.contains(SmsTypeEnum.SET_CMDID.value())) { + UpdateSysConfigUtil.restartApp(context); + } else if (type.contains(SmsTypeEnum.SET_IP.value())) { + UpdateSysConfigUtil.restartApp(context); + } else if (type.contains(SmsTypeEnum.SET_OSD.value())) { + UpdateSysConfigUtil.restartApp(context); + } else if (type.contains(SmsTypeEnum.SET_PHOTO_SCHEDULE_LIST.value())) { + UpdateSysConfigUtil.restartApp(context); + } else if (type.contains(SmsTypeEnum.SET_RESOLUTION.value())) { + UpdateSysConfigUtil.restartApp(context); + } else if (type.contains(SmsTypeEnum.SET_HEART.value())) { + UpdateSysConfigUtil.restartApp(context); + } else if (type.contains(SmsTypeEnum.SET_TP.value())) { + UpdateSysConfigUtil.restartApp(context); + } else if (type.contains(SmsTypeEnum.SET_PACKAGE.value())) { + UpdateSysConfigUtil.restartApp(context); } } } \ No newline at end of file