import com.ic.s123.IS123WeatherCallback;
import com.ic.s123.IS123WeatherService;
+import org.apache.harmony.misc.SystemUtils;
+
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.List;
ICLogger.i(stringBuilder2.toString());
if (ACTION_SEND_EMEGENCY_LOCATION_START.equals(param1Intent.getAction())) {
- if(runtime.getLocationInstance().getWorkingMod()!=EMERGNECY_MOD) {
+ if (runtime.getLocationInstance().getWorkingMod() != EMERGNECY_MOD) {
//先保存需要恢复的模式, 并且防止出现多次进入紧急模式造成的无法恢复以往状态问题
runtime.getLocationInstance().setLastWorkingMode(runtime.getLocationInstance().getWorkingMod());
}
// Deliver.sendLocationMSG(protocolAPIHelper.getWarningMSG(runtime));
//开启紧急定位模式,GPS 优先1分钟一次定位,持续5分钟
- if(runtime.getLocationInstance().getWorkingMod()!=EMERGNECY_MOD) {
+ if (runtime.getLocationInstance().getWorkingMod() != EMERGNECY_MOD) {
//先保存需要恢复的模式, 并且防止出现多次进入紧急模式造成的无法恢复以往状态问题
runtime.getLocationInstance().setLastWorkingMode(runtime.getLocationInstance().getWorkingMod());
}
Deliver.resetCMDReocrdsDB();
- if(Config.custom_name.equals("l004pt")||Config.custom_name.equals("l004")||Config.custom_name.equals("l005"))
- {
+ if (Config.custom_name.equals("l004pt") || Config.custom_name.equals("l004") || Config.custom_name.equals("l005")) {
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
//L004PT ,L005 默认开启roaming以及默认使用以下apn
// APNUtil.addVPN("Test","tapn","460","04","","",CoreService.getInstance());
- APNUtil.selectAPN("334","020","ctm-mobile",CoreService.getInstance());
+ APNUtil.selectAPN("334", "020", "ctm-mobile", CoreService.getInstance());
}
- },5000);
+ }, 5000);
}
ReConnectToServer();
ICLogger.d("is open by user == > " + isUserOpen);
if ("false".equals(isUserOpen)) {
//用户手动打开的,那么就不关闭wifi了
- Util.turnOffWifiForSleep((this.runtime.getContextProxy()).context, this.runtime);
+ Util.turnOffWifiForSleep(this.runtime);
}
}
// setAlarm(alarmCycle);
stopConnectionRetryTimer();
}
if (no_network_Heartbeats_Count > 12) {
+ //如果WIFI打开的,但是还是12次链接不上了,那么就开关一下WIFI,重新连接WIFI
+ //如果没有打开WIFI的,那么就控制Sim卡的开关
ICLogger.i("当前第" + no_network_Heartbeats_Count + "次心跳都没有连接服务器成功 > 10 ,重置SIM卡尝试重新注册网络!");
- SimSignalUtil.send_at_to_reset_simcard(runtime); //直接下此命令不能实现断网重连,所以干脆采用关闭网络再打开的方式。
+ String isUserOpenWifi = Util.getSystemProperties("persist.sys.ic.wifi_enable");
+ ICLogger.d("isUserOpenWifi ==> " + isUserOpenWifi);
+ if ("true".equals(isUserOpenWifi)) {
+ //先关闭,然后再打开
+ Util.turnOffWifiForSleep(runtime);
+ ICLogger.d("tun off wifi...");
+ mHandler.postDelayed(() -> {
+ Util.turnOnWifiForConnect(runtime);
+ ICLogger.d("tun on wifi...");
+ }, 1000);
+ } else {
+ SimSignalUtil.send_at_to_reset_simcard(runtime); //直接下此命令不能实现断网重连,所以干脆采用关闭网络再打开的方式。
+ }
no_network_Heartbeats_Count = 0;//重置Sim卡后重置计数。防止后面多次重置Sim卡。
}
}
public void getContacts() {
//获取联系人
StringMessage cmdmMembers = protocolAPIHelper.requestVideoCallContact(runtime);
- //获取佰锐ID
+ //获取佰锐ID
connection.send(cmdmMembers);
ICLogger.d("get contacts...");
}
@Override
public void rejectCallInCome(String remoteId, int type) {
//拒绝来电
- StringMessage rejectMsg = protocolAPIHelper.rejectVideoCall(runtime,remoteId, type);
+ StringMessage rejectMsg = protocolAPIHelper.rejectVideoCall(runtime, remoteId, type);
connection.send(rejectMsg);
ICLogger.d("reject remote call request..." + remoteId + "..." + type);
}
@Override
public void requireCall(int type, int remoteUserId) {
//请求与对方通话
- StringMessage talk = protocolAPIHelper.dialVideoCall(runtime,type, remoteUserId);
+ StringMessage talk = protocolAPIHelper.dialVideoCall(runtime, type, remoteUserId);
connection.send(talk);
ICLogger.d("require call == > type is " + type + " remote user id is == > " + remoteUserId);
}
public void setUpEnvState(int state) {
ICLogger.d("update bairui env state..." + state);
- protocolAPIHelper.updateEnvState(runtime,state);
+ protocolAPIHelper.updateEnvState(runtime, state);
}
@Override
public void unbindFriends(String remoteFriendId) {
ICLogger.d("unbindFriends == > " + remoteFriendId);
- StringMessage ppr = protocolAPIHelper.unbindFriends(runtime,remoteFriendId);
+ StringMessage ppr = protocolAPIHelper.unbindFriends(runtime, remoteFriendId);
//解除朋友
connection.send(ppr);
}
} else if (tmp[1].startsWith("switch,")) {
String tmplist[] = tmp[1].split(",");
if (tmplist.length == 2) {
- if(tmplist[1].trim().equalsIgnoreCase("on") || tmplist[1].trim().equalsIgnoreCase("1")) {
- Util.turnOnWifiForConnect(mContext,runtime);
+ if (tmplist[1].trim().equalsIgnoreCase("on") || tmplist[1].trim().equalsIgnoreCase("1")) {
+ Util.turnOnWifiForConnect(runtime);
Util.setSystemProperties("persist.sys.ic.wifi_enable", "true");
sendSMS(phonenumber, "WiFi Switch On !");
- }else if(tmplist[1].trim().equalsIgnoreCase("off") || tmplist[1].trim().equalsIgnoreCase("0")){
- Util.turnOffWifiForSleep(mContext,runtime);
+ } else if (tmplist[1].trim().equalsIgnoreCase("off") || tmplist[1].trim().equalsIgnoreCase("0")) {
+ Util.turnOffWifiForSleep(runtime);
Util.setSystemProperties("persist.sys.ic.wifi_enable", "false");
sendSMS(phonenumber, "WiFi Switch Off !");
- }else{
- sendSMS(phonenumber, "WiFi Switch Control "+tmplist[1].trim()+" format error!");
+ } else {
+ sendSMS(phonenumber, "WiFi Switch Control " + tmplist[1].trim() + " format error!");
}
- }else{
+ } else {
sendSMS(phonenumber, "WiFi Switch Control format error!");
}
runtime.setNoTurnOffOnScreenOff(isenabled);
StringBuilder sb = new StringBuilder();
if (isenabled && !Util.isWifiIsOpen(runtime.getContextProxy().context, runtime)) {
- Util.turnOnWifiForConnect(runtime.getContextProxy().context, runtime);
+ Util.turnOnWifiForConnect(runtime);
sb.append(" Turn On Wifi first and ");
}
sb.append("set noTurnOffWhenScreenOff " + enabled);
/* #setLogSrv#=http://icfota.snicker.com.cn:8089/UploadFile.jsp*/
Config.setHttpLogServerUrl(mContext, strtmp);
sendSMS(phonenumber, "set setLogSrv to " + strtmp + "!");
- }else {
+ } else {
sendSMS(phonenumber, " setLogSrv cmd Format error!");
}
runtime.setNoTurnOffOnScreenOff(true);
StringBuilder sb = new StringBuilder();
if (!Util.isWifiIsOpen(runtime.getContextProxy().context, runtime)) {
- Util.turnOnWifiForConnect(runtime.getContextProxy().context, runtime);
+ Util.turnOnWifiForConnect(runtime);
}
sb.append("connect to Wifi SSID " + Config.getWiFiSSID(mContext) + ", WiFiPassword " + Config.getWiFiPasswd(mContext) + ", encryptType " + encyptType + "!");
sb.append(" And start to Update");
cell_number_to_reply = phonenumber;
sendSMS(phonenumber, sb.toString());
//connect to wifi
- mHandler.postDelayed(new Runnable() {
- @Override
- public void run() {
- Deliver.connectToWifi(SSID, PWD, encyptType);
- broadCastStartFotaUpdate(mContext);
- }
+ mHandler.postDelayed(() -> {
+ Deliver.connectToWifi(SSID, PWD, encyptType);
+ broadCastStartFotaUpdate(mContext);
}, 500);
} else {
sendSMS(phonenumber, "FotaUpdateWiFi Control format error!");
}
public static void send_at_to_reset_simcard(Runtime runtime) {
-
Intent intent = new Intent("com.eqc.intent.action.getTelephony.lbs");
intent.putExtra("command", "AT+SFUN=2"); //重新初始化sim卡
intent.putExtra("arg2", "");
wifimanagerMethods = wifiManager.getClass().getDeclaredMethods();
methods_count = wifimanagerMethods.length;
last_method = null;
- for (i = 0; i < methods_count;++i) {
+ for (i = 0; i < methods_count; ++i) {
method_connect = wifimanagerMethods[i];
if ("connect".equalsIgnoreCase(method_connect.getName())) {
parameterTypes = method_connect.getParameterTypes();
return arrayOfByte;
}
- public static void turnOffWifiForSleep(Context paramContext, Runtime paramRuntime) {
+ public static void turnOffWifiForSleep(Runtime paramRuntime) {
paramRuntime.getContextProxy().getWifiManager().setWifiEnabled(false);
}
- public static void turnOnWifiForConnect(Context paramContext, Runtime paramRuntime) {
+ public static void turnOnWifiForConnect(Runtime paramRuntime) {
paramRuntime.getContextProxy().getWifiManager().setWifiEnabled(true);
}
}
}
- public static boolean parseToVoicePacketSent(VoiceContent voiceContent,int packetSize) {
+ public static boolean parseToVoicePacketSent(VoiceContent voiceContent, int packetSize) {
long filesize;
File voicefile = new File(voiceContent.content);
fis.close();
voicePacket.getInstanceSent().setCurrentIndexToSent(0);
voicePacket.getInstanceSent().setPacketTime(TimeUtil.getSystemTime3());
- if( voiceContent.filetype==1) //* 1 语音—— 1.监听语音 * 2.SOS语音 * 3.扩展
+ if (voiceContent.filetype == 1) //* 1 语音—— 1.监听语音 * 2.SOS语音 * 3.扩展
{
- int duration=Util.getDuration(voiceContent.content);
- voicePacket.getInstanceSent().setDurationHex(String.format("%04X",duration));
- }else{
+ int duration = Util.getDuration(voiceContent.content);
+ voicePacket.getInstanceSent().setDurationHex(String.format("%04X", duration));
+ } else {
voicePacket.getInstanceSent().setDurationHex("0000");
}
return true;
}
return ret;
}
+
public static String UrlGB2312ToUTF8(String url) {
String ret = "";
String src = url;