添加关闭心跳的入口
authorTrillGates <williamtrillgates@gmail.com>
Mon, 1 Nov 2021 02:27:27 +0000 (10:27 +0800)
committerTrillGates <williamtrillgates@gmail.com>
Mon, 1 Nov 2021 02:27:27 +0000 (10:27 +0800)
app/release/ICProtocol81_V937_2110301130_release.apk [new file with mode: 0644]
app/release/output.json
app/src/main/java/com/ic/protocolSrv/CoreService.java
app/src/main/java/com/ic/protocolSrv/toolActivity.java
app/src/main/res/layout/activity_tool.xml
app/version_code.properties

diff --git a/app/release/ICProtocol81_V937_2110301130_release.apk b/app/release/ICProtocol81_V937_2110301130_release.apk
new file mode 100644 (file)
index 0000000..e809872
Binary files /dev/null and b/app/release/ICProtocol81_V937_2110301130_release.apk differ
index 5f7177c..c32ec75 100644 (file)
@@ -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
index 5ca2847..422b856 100644 (file)
@@ -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();
index fb71d5e..3c8e1da 100644 (file)
@@ -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);
+    }
 }
index a91af8c..1f2caf4 100644 (file)
     android:orientation="vertical"\r
     tools:context=".toolActivity">\r
 \r
-    <LinearLayout\r
+    <ScrollView\r
         android:layout_width="match_parent"\r
-        android:layout_height="wrap_content"\r
-        android:layout_weight="1"\r
-        android:orientation="horizontal">\r
+        android:layout_height="wrap_content">\r
 \r
-        <Button\r
-            android:id="@+id/btn_logctl"\r
-            android:layout_width="wrap_content"\r
+        <LinearLayout\r
+            android:layout_width="match_parent"\r
             android:layout_height="wrap_content"\r
-            android:layout_weight="1"\r
-            android:text="上传日志"\r
-            android:textSize="18sp" />\r
+            android:orientation="vertical">\r
 \r
-        <Button\r
-            android:id="@+id/btn_simReset"\r
-            android:layout_width="wrap_content"\r
-            android:layout_height="wrap_content"\r
-            android:layout_weight="1"\r
-            android:text="重置sim"\r
-            android:textSize="18sp" />\r
+            <Button\r
+                android:id="@+id/btn_logctl"\r
+                android:layout_width="match_parent"\r
+                android:layout_height="wrap_content"\r
+                android:text="上传日志"\r
+                android:textSize="18sp" />\r
 \r
-        <Button\r
-            android:id="@+id/btn_sim2"\r
-            android:layout_width="wrap_content"\r
-            android:layout_height="wrap_content"\r
-            android:layout_weight="1"\r
-            android:text="GPS"\r
-            android:textSize="18sp" />\r
-    </LinearLayout>\r
+            <Button\r
+                android:id="@+id/btn_simReset"\r
+                android:layout_width="match_parent"\r
+                android:layout_height="wrap_content"\r
+                android:text="重置sim"\r
+                android:textSize="18sp" />\r
 \r
-    <LinearLayout\r
-        android:layout_width="match_parent"\r
-        android:layout_height="wrap_content"\r
-        android:layout_weight="1"\r
-        android:orientation="horizontal">\r
+            <Button\r
+                android:id="@+id/btn_sim2"\r
+                android:layout_width="match_parent"\r
+                android:layout_height="wrap_content"\r
+                android:text="GPS"\r
+                android:textSize="18sp" />\r
 \r
-        <Button\r
-            android:id="@+id/btn_location3"\r
-            android:layout_width="wrap_content"\r
-            android:layout_height="wrap_content"\r
-            android:layout_weight="1"\r
-            android:text="模式3"\r
-            android:textSize="18sp" />\r
 \r
-        <Button\r
-            android:id="@+id/btn_location530"\r
-            android:layout_width="wrap_content"\r
-            android:layout_height="wrap_content"\r
-            android:layout_weight="1"\r
-            android:text="模式8"\r
-            android:textSize="18sp" />\r
+            <Button\r
+                android:id="@+id/btn_location3"\r
+                android:layout_width="match_parent"\r
+                android:layout_height="wrap_content"\r
+                android:text="模式3"\r
+                android:textSize="18sp" />\r
 \r
-        <Button\r
-            android:id="@+id/btn_location1"\r
-            android:layout_width="wrap_content"\r
-            android:layout_height="wrap_content"\r
-            android:layout_weight="1"\r
-            android:text="模式1"\r
-            android:textSize="18sp" />\r
-    </LinearLayout>\r
-    <LinearLayout\r
-        android:layout_width="match_parent"\r
-        android:layout_height="wrap_content"\r
-        android:layout_weight="1"\r
-        android:orientation="horizontal">\r
+            <Button\r
+                android:id="@+id/btn_location530"\r
+                android:layout_width="match_parent"\r
+                android:layout_height="wrap_content"\r
+                android:text="模式8"\r
+                android:textSize="18sp" />\r
 \r
-        <Button\r
-            android:id="@+id/btn_usb"\r
-            android:layout_width="wrap_content"\r
-            android:layout_height="wrap_content"\r
-            android:layout_weight="1"\r
-            android:text="MTP"\r
-            android:textSize="18sp" />\r
+            <Button\r
+                android:id="@+id/btn_location1"\r
+                android:layout_width="match_parent"\r
+                android:layout_height="wrap_content"\r
+                android:text="模式1"\r
+                android:textSize="18sp" />\r
 \r
-        <Button\r
-            android:id="@+id/btn_restartSrv"\r
-            android:layout_width="wrap_content"\r
-            android:layout_height="wrap_content"\r
-            android:layout_weight="1"\r
-            android:text="重启Srv"\r
-            android:textSize="18sp" />\r
+            <Button\r
+                android:id="@+id/btn_usb"\r
+                android:layout_width="match_parent"\r
+                android:layout_height="wrap_content"\r
+                android:text="MTP"\r
+                android:textSize="18sp" />\r
+\r
+            <Button\r
+                android:id="@+id/btn_restartSrv"\r
+                android:layout_width="match_parent"\r
+                android:layout_height="wrap_content"\r
+                android:text="重启Srv"\r
+                android:textSize="18sp" />\r
+\r
+            <Button\r
+                android:id="@+id/btn_cpslog"\r
+                android:layout_width="match_parent"\r
+                android:layout_height="wrap_content"\r
+                android:text="运动检测"\r
+                android:textSize="18sp" />\r
+\r
+\r
+            <TextView\r
+                android:layout_width="match_parent"\r
+                android:id="@+id/heart_beat_cycle_text"\r
+                android:layout_height="wrap_content"\r
+                android:gravity="center"\r
+                android:padding="10dp"\r
+                android:text="当前心跳周期:"\r
+                android:textSize="18sp" />\r
+\r
+\r
+            <Button\r
+                android:id="@+id/close_heart_beat"\r
+                android:onClick="closeHeartBeat"\r
+                android:layout_width="match_parent"\r
+                android:layout_height="wrap_content"\r
+                android:text="关闭心跳"\r
+                android:textSize="18sp" />\r
+\r
+            <Button\r
+                android:id="@+id/open_heart_beat"\r
+                android:layout_width="match_parent"\r
+                android:layout_height="wrap_content"\r
+                android:onClick="openHeartBeat"\r
+                android:text="打开心跳"\r
+                android:textSize="18sp" />\r
+\r
+\r
+        </LinearLayout>\r
+\r
+    </ScrollView>\r
 \r
-        <Button\r
-            android:id="@+id/btn_cpslog"\r
-            android:layout_width="wrap_content"\r
-            android:layout_height="wrap_content"\r
-            android:layout_weight="1"\r
-            android:text="运动检测"\r
-            android:textSize="18sp" />\r
-    </LinearLayout>\r
 </LinearLayout>
\ No newline at end of file
index ae78b94..c15a295 100644 (file)
@@ -1,2 +1,2 @@
-#Thu Oct 28 10:00:42 CST 2021\r
-VERSION_CODE=934\r
+#Sat Oct 30 11:30:20 CST 2021\r
+VERSION_CODE=937\r