From: TrillGates Date: Mon, 1 Nov 2021 02:27:27 +0000 (+0800) Subject: 添加关闭心跳的入口 X-Git-Url: http://git.snicker.com.cn/Users/apple/Desktop/static/gitweb.css?a=commitdiff_plain;h=644f964a8a22fc75e56f3dd9532375c313931f09;p=protocol_srv.git 添加关闭心跳的入口 --- diff --git a/app/release/ICProtocol81_V937_2110301130_release.apk b/app/release/ICProtocol81_V937_2110301130_release.apk new file mode 100644 index 00000000..e8098724 Binary files /dev/null and b/app/release/ICProtocol81_V937_2110301130_release.apk differ diff --git a/app/release/output.json b/app/release/output.json index 5f7177cc..c32ec75b 100644 --- a/app/release/output.json +++ b/app/release/output.json @@ -1 +1 @@ -[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":934,"versionName":"2110281000","enabled":true,"outputFile":"ICProtocol81_V934_2110281000_release.apk","fullName":"release","baseName":"release"},"path":"ICProtocol81_V934_2110281000_release.apk","properties":{}}] \ No newline at end of file +[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":937,"versionName":"2110301130","enabled":true,"outputFile":"ICProtocol81_V937_2110301130_release.apk","fullName":"release","baseName":"release"},"path":"ICProtocol81_V937_2110301130_release.apk","properties":{}}] \ No newline at end of file diff --git a/app/src/main/java/com/ic/protocolSrv/CoreService.java b/app/src/main/java/com/ic/protocolSrv/CoreService.java index 5ca28473..422b856e 100644 --- a/app/src/main/java/com/ic/protocolSrv/CoreService.java +++ b/app/src/main/java/com/ic/protocolSrv/CoreService.java @@ -30,6 +30,7 @@ import android.text.TextUtils; import android.util.Log; import android.widget.Toast; + import com.ic.jni.ICJniUtils; import com.ic.protocolSrv.adapter.LBSHelper; import com.ic.protocolSrv.bean.Contact; @@ -256,8 +257,8 @@ public class CoreService extends Service { if (query != null) { if (query.moveToNext()) { String value = query.getString(0); - disableSos = "0".equals(value); - ICLogger.d("sos on value ==> " + value+" "+disableSos); + disableSos = "0".equals(value); + ICLogger.d("sos on value ==> " + value + " " + disableSos); } query.close(); } @@ -292,8 +293,19 @@ public class CoreService extends Service { //拨打电话走流程 //只要判断是否需要发短信即可 ICLogger.d("start check need SOS SMS..."); - checkSendSMS(resolver); + //是否需要拨号 + boolean needCall = checkSendSMS(resolver); + //需要拨号再拨号 + if (needCall) { + //50ms后开始拨打电话 + mHandler.postDelayed(mTriggerSOSCALLThread, 1000); + } }); + } else { + if (!Config.SOSNoNeedDial) { + //50ms后开始拨打电话 + mHandler.postDelayed(mTriggerSOSCALLThread, 1000); + } } //add by TrillGates=====end runtime.setAlarmType(Runtime.AlarmType.ALARM_SOS); @@ -312,10 +324,6 @@ public class CoreService extends Service { } //设置5分钟后结束紧急定位模式 setEmegencyLocationSTOPAlarm(5); - if (!Config.SOSNoNeedDial) { - //50ms后开始拨打电话 - mHandler.postDelayed(mTriggerSOSCALLThread, 500); - } } else if (ACTION_QUERY_WEATHER.equals(param1Intent.getAction())) { ICLogger.i("ACTION_QUERY_WEATHER "); connection.send(protocolAPIHelper.getWeatherMSG(runtime)); @@ -330,7 +338,7 @@ public class CoreService extends Service { * * @param resolver */ - private void checkSendSMS(ContentResolver resolver) { + private boolean checkSendSMS(ContentResolver resolver) { Cursor query = resolver.query(Uri.parse(SETTINGS), new String[]{"s_value"}, "s_key=?", new String[]{"sos_notify_type"}, null); if (query != null) { @@ -353,7 +361,7 @@ public class CoreService extends Service { } if (sosNumbers.size() == 0) { ICLogger.d("no sos number..."); - return; + return value == 3; } //发送短信 //获取短信内容 @@ -372,11 +380,16 @@ public class CoreService extends Service { smsManager.sendSMS(sosNumber, smsContent); } } + // public static final int TYPE_CHECK_PHONE = 1; + // public static final int TYPE_CHECK_SMS = 2; + // public static final int TYPE_CHECK_PHONE_AND_SMS = 3; + return value == 1 || value == 3; } else { ICLogger.d("no sos settings value..."); } query.close(); } + return true; } private TriggerSOSCALLThread mTriggerSOSCALLThread = new TriggerSOSCALLThread(); @@ -773,6 +786,7 @@ public class CoreService extends Service { @Override public void onCreate() { + ICJniUtils.enablePedometer(); if (mHandler == null) { HandlerThread handlerThread = new HandlerThread("ic:core-thread"); handlerThread.start(); diff --git a/app/src/main/java/com/ic/protocolSrv/toolActivity.java b/app/src/main/java/com/ic/protocolSrv/toolActivity.java index fb71d5eb..3c8e1da7 100644 --- a/app/src/main/java/com/ic/protocolSrv/toolActivity.java +++ b/app/src/main/java/com/ic/protocolSrv/toolActivity.java @@ -4,11 +4,13 @@ import android.app.Activity; import android.content.ComponentName; import android.content.Intent; import android.os.Bundle; +import android.support.v4.app.INotificationSideChannel; import android.view.Display; import android.view.View; import android.view.ViewGroup; import android.view.Window; import android.widget.Button; +import android.widget.TextView; import com.ic.protocolSrv.utils.ICLogger; import com.ic.protocolSrv.utils.SimSignalUtil; @@ -18,35 +20,36 @@ import com.ic.protocolSrv.utils.Util; import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK; public class toolActivity extends Activity { - private static boolean usbstat=true; + private static boolean usbstat = true; - void resizeSquare(){ - if (Util.needResizeSquare()){ + void resizeSquare() { + if (Util.needResizeSquare()) { Display display = getWindowManager().getDefaultDisplay(); // 为获取屏幕宽、高 Window window = getWindow(); ViewGroup.LayoutParams windowLayoutParams = window.getAttributes(); // 获取对话框当前的参数值 int width = display.getWidth(); int height = display.getHeight(); - windowLayoutParams.width = (int)(width*0.8);//(int) (display.getWidth() * 0.7); // 宽度设置为屏幕的0.95 - windowLayoutParams.height = (int)(height*0.8);//(int) (display.getHeight() * 0.6); // 高度设置为屏幕的0.6 - ICLogger.d("Resize to " + windowLayoutParams.width +"X" + windowLayoutParams.height); + windowLayoutParams.width = (int) (width * 0.8);//(int) (display.getWidth() * 0.7); // 宽度设置为屏幕的0.95 + windowLayoutParams.height = (int) (height * 0.8);//(int) (display.getHeight() * 0.6); // 高度设置为屏幕的0.6 + ICLogger.d("Resize to " + windowLayoutParams.width + "X" + windowLayoutParams.height); } } + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_tool); - Button btnSim=(Button)findViewById(R.id.btn_simReset); - Button btnSimReload=(Button)findViewById(R.id.btn_sim2); - Button btnLogctl=(Button)findViewById(R.id.btn_logctl); - Button btnmod1=(Button)findViewById(R.id.btn_location1); - Button btnmod3=(Button)findViewById(R.id.btn_location3); - Button btnmod530=(Button)findViewById(R.id.btn_location530); + Button btnSim = (Button) findViewById(R.id.btn_simReset); + Button btnSimReload = (Button) findViewById(R.id.btn_sim2); + Button btnLogctl = (Button) findViewById(R.id.btn_logctl); + Button btnmod1 = (Button) findViewById(R.id.btn_location1); + Button btnmod3 = (Button) findViewById(R.id.btn_location3); + Button btnmod530 = (Button) findViewById(R.id.btn_location530); - Button btnRestSrv=(Button)findViewById(R.id.btn_restartSrv); - Button btnUsbEnable=(Button)findViewById(R.id.btn_usb); - Button btnSlog=(Button)findViewById(R.id.btn_cpslog); + Button btnRestSrv = (Button) findViewById(R.id.btn_restartSrv); + Button btnUsbEnable = (Button) findViewById(R.id.btn_usb); + Button btnSlog = (Button) findViewById(R.id.btn_cpslog); // protocol_mqtt_client mqttClient=new protocol_mqtt_client(toolActivity.this); // mqttClient.connectservice(); @@ -55,20 +58,20 @@ public class toolActivity extends Activity { public void onClick(View view) { // protocol_mqtt.handleLGZONE(null,CoreService.getInstance().runtime,"001D,-8,08:00:00,2016-01-12"); - Intent intent=new Intent(); - intent.putExtra("smsCmd","#setlocation#=1,30#"); - CoreService.getInstance().runtime.getContextProxy().sendBroadcast("com.ic.protocolSrv.SMSCMD",intent); - Util.ShowToast(CoreService.getInstance().runtime,"设置模式1 , 间隔900秒定位。"); + Intent intent = new Intent(); + intent.putExtra("smsCmd", "#setlocation#=1,30#"); + CoreService.getInstance().runtime.getContextProxy().sendBroadcast("com.ic.protocolSrv.SMSCMD", intent); + Util.ShowToast(CoreService.getInstance().runtime, "设置模式1 , 间隔900秒定位。"); } }); btnmod3.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - Intent intent=new Intent(); - intent.putExtra("smsCmd","#setlocation#=3,30#"); - CoreService.getInstance().runtime.getContextProxy().sendBroadcast("com.ic.protocolSrv.SMSCMD",intent); - Util.ShowToast(CoreService.getInstance().runtime,"设置模式3 , 间隔60秒定位。"); + Intent intent = new Intent(); + intent.putExtra("smsCmd", "#setlocation#=3,30#"); + CoreService.getInstance().runtime.getContextProxy().sendBroadcast("com.ic.protocolSrv.SMSCMD", intent); + Util.ShowToast(CoreService.getInstance().runtime, "设置模式3 , 间隔60秒定位。"); // mqttClient.attemptConnectMqtt(protocol_mqtt.defaultServerIP,"IC_H88_1063",60); } @@ -76,24 +79,23 @@ public class toolActivity extends Activity { btnmod530.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - Intent intent=new Intent(); - intent.putExtra("smsCmd","#setlocation#=8,300#"); - CoreService.getInstance().runtime.getContextProxy().sendBroadcast("com.ic.protocolSrv.SMSCMD",intent); - Util.ShowToast(CoreService.getInstance().runtime,"设置模式8, 间隔300秒定位。"); + Intent intent = new Intent(); + intent.putExtra("smsCmd", "#setlocation#=8,300#"); + CoreService.getInstance().runtime.getContextProxy().sendBroadcast("com.ic.protocolSrv.SMSCMD", intent); + Util.ShowToast(CoreService.getInstance().runtime, "设置模式8, 间隔300秒定位。"); // mqttClient.sendMessage("WBG100/v1/BREQ/1","[0016,QWER15WTF156OQRT1230]"); // mqttClient.sendMessage("WBG100/v1/KA/1","[001B,120414,50,100,100, 123456789]"); - } }); btnSim.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { SimSignalUtil.send_at_to_reset_simcard(CoreService.getInstance().runtime); - Util.ShowToast(CoreService.getInstance().runtime,"Reset SimCard!"); + Util.ShowToast(CoreService.getInstance().runtime, "Reset SimCard!"); } }); @@ -101,7 +103,7 @@ public class toolActivity extends Activity { @Override public void onClick(View view) { - Intent intent=new Intent(); + Intent intent = new Intent(); ComponentName var3 = new ComponentName("com.ic.protocolSrv", "com.ic.protocolSrv.GPSActivity"); intent.addFlags(FLAG_ACTIVITY_NEW_TASK); intent.setComponent(var3); @@ -112,27 +114,26 @@ public class toolActivity extends Activity { btnLogctl.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - Intent intent=new Intent(); - intent.putExtra("smsCmd","#logctl#=upload,SDLogInfo:Android/V20"); - CoreService.getInstance().runtime.getContextProxy().sendBroadcast("com.ic.protocolSrv.SMSCMD",intent); + Intent intent = new Intent(); + intent.putExtra("smsCmd", "#logctl#=upload,SDLogInfo:Android/V20"); + CoreService.getInstance().runtime.getContextProxy().sendBroadcast("com.ic.protocolSrv.SMSCMD", intent); } }); - btnUsbEnable.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - if(usbstat) { - Intent intent=new Intent(); + if (usbstat) { + Intent intent = new Intent(); intent.putExtra("smsCmd", "#USB#=mtp"); - CoreService.getInstance().runtime.getContextProxy().sendBroadcast("com.ic.protocolSrv.SMSCMD",intent); - Util.ShowToast(CoreService.getInstance().runtime,"Enable MTP"); - }else{ - Intent intent=new Intent(); + CoreService.getInstance().runtime.getContextProxy().sendBroadcast("com.ic.protocolSrv.SMSCMD", intent); + Util.ShowToast(CoreService.getInstance().runtime, "Enable MTP"); + } else { + Intent intent = new Intent(); intent.putExtra("smsCmd", "#USB#=none"); - CoreService.getInstance().runtime.getContextProxy().sendBroadcast("com.ic.protocolSrv.SMSCMD",intent); - Util.ShowToast(CoreService.getInstance().runtime,"Diable MTP"); + CoreService.getInstance().runtime.getContextProxy().sendBroadcast("com.ic.protocolSrv.SMSCMD", intent); + Util.ShowToast(CoreService.getInstance().runtime, "Diable MTP"); } } @@ -141,29 +142,58 @@ public class toolActivity extends Activity { @Override public void onClick(View view) { - if (CoreService.getInstance()!=null) + if (CoreService.getInstance() != null) Util.ShowToast(CoreService.getInstance().runtime, "Stop ProtocolService!"); - stopService(new Intent(toolActivity.this, CoreService.class));// protocol service + stopService(new Intent(toolActivity.this, CoreService.class));// protocol service Util.mSleep(3000); - if (CoreService.getInstance()!=null) - Util.ShowToast(CoreService.getInstance().runtime, "Start ProtocolService!"); - startService(new Intent(toolActivity.this, CoreService.class));// protocol service + if (CoreService.getInstance() != null) + Util.ShowToast(CoreService.getInstance().runtime, "Start ProtocolService!"); + startService(new Intent(toolActivity.this, CoreService.class));// protocol service } }); btnSlog.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - if(Config.forceGPSMoveCheck) - { - Config.forceGPSMoveCheck=false; - }else{ - Config.forceGPSMoveCheck=true; + if (Config.forceGPSMoveCheck) { + Config.forceGPSMoveCheck = false; + } else { + Config.forceGPSMoveCheck = true; } - Util.ShowToast(CoreService.getInstance().runtime,"Set forceGPSMoveCheck "+ Config.forceGPSMoveCheck); + Util.ShowToast(CoreService.getInstance().runtime, "Set forceGPSMoveCheck " + Config.forceGPSMoveCheck); } }); resizeSquare(); } + + /** + * 打开心跳 + * + * @param view + */ + public void openHeartBeat(View view) { + setUpHeartBeanAlarm(Config.getHeartBeatCycle(this)); + } + + private void setUpHeartBeanAlarm(int targetCycle) { + CoreService instance = CoreService.getInstance(); + instance.runtime.setHeartBeatCycle(targetCycle); + //默认时间为5分钟 + instance.setHeartBeatAlarm(); + //设置UI上的时间 + int cycle = instance.runtime.getHeartBeatCycle(); + ICLogger.d("cycle ==> " + cycle); + TextView heartBeatTv = (TextView) findViewById(R.id.heart_beat_cycle_text); + heartBeatTv.setText("当前心跳周期:" + cycle); + } + + /** + * 关闭心跳 + * + * @param view + */ + public void closeHeartBeat(View view) { + setUpHeartBeanAlarm(65535); + } } diff --git a/app/src/main/res/layout/activity_tool.xml b/app/src/main/res/layout/activity_tool.xml index a91af8c3..1f2caf4f 100644 --- a/app/src/main/res/layout/activity_tool.xml +++ b/app/src/main/res/layout/activity_tool.xml @@ -7,95 +7,109 @@ android:orientation="vertical" tools:context=".toolActivity"> - + android:layout_height="wrap_content"> -