adjust code style.
authorTrillGates <williamtrillgates@gmail.com>
Tue, 3 Aug 2021 02:46:40 +0000 (10:46 +0800)
committerTrillGates <williamtrillgates@gmail.com>
Tue, 3 Aug 2021 02:46:40 +0000 (10:46 +0800)
13 files changed:
app/release/ICSer_V904_2107301549_release.apk [moved from app/release/ICSer_V902_2107291726_release.apk with 77% similarity]
app/release/output.json
app/src/main/java/com/enqualcomm/support/Config.java
app/src/main/java/com/enqualcomm/support/CoreService.java
app/src/main/java/com/enqualcomm/support/LocationClient.java
app/src/main/java/com/enqualcomm/support/service/AntiMonitorService.java
app/src/main/java/com/enqualcomm/support/service/InputEventReader.java
app/src/main/java/com/enqualcomm/support/utils/MakeFriendsBtHelper.java [new file with mode: 0644]
app/src/main/java/com/enqualcomm/support/utils/MakeFriendsLocationHelper.java [new file with mode: 0644]
app/src/main/java/com/ic/protocols/protocolAPIHelper.java
app/src/main/java/com/ic/protocols/protocol_fzd.java
app/src/main/java/com/ic/protocols/protocol_gator.java
app/version_code.properties

similarity index 77%
rename from app/release/ICSer_V902_2107291726_release.apk
rename to app/release/ICSer_V904_2107301549_release.apk
index 2fa9a57..cd9e534 100644 (file)
Binary files a/app/release/ICSer_V902_2107291726_release.apk and b/app/release/ICSer_V904_2107301549_release.apk differ
index 970d188..235c840 100644 (file)
@@ -1 +1 @@
-[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":902,"versionName":"2107291726","enabled":true,"outputFile":"ICSer_V902_2107291726_release.apk","fullName":"release","baseName":"release"},"path":"ICSer_V902_2107291726_release.apk","properties":{}}]
\ No newline at end of file
+[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":904,"versionName":"2107301549","enabled":true,"outputFile":"ICSer_V904_2107301549_release.apk","fullName":"release","baseName":"release"},"path":"ICSer_V904_2107301549_release.apk","properties":{}}]
\ No newline at end of file
index 9f0b00b..3abcf41 100644 (file)
@@ -629,12 +629,10 @@ public class Config {
         return ret;
     }
 
-
     public static void setPPGAdjust(Context context, int adjust) {
         SharePreferenceUtil.setPrefInt(context, KeyPPGadust, adjust);
     }
 
-
     public static int getPPGAdjust(Context context) {
         return SharePreferenceUtil.getPrefInt(context, KeyPPGadust, 0);
     }
@@ -643,12 +641,10 @@ public class Config {
         SharePreferenceUtil.setPrefInt(context, KeyBPHadust, adjust);
     }
 
-
     public static int getBPHAdjust(Context context) {
         return SharePreferenceUtil.getPrefInt(context, KeyBPHadust, 0);
     }
 
-
     public static int getBPLAdjust(Context context) {
         return SharePreferenceUtil.getPrefInt(context, KeyBPLadust, 0);
     }
@@ -675,7 +671,6 @@ public class Config {
         ICLogger.i("Load Health adjust value  ppg " + ppgadj + ", bph " + bphadj + ", bpl " + bpladj + ", spo2 " + spo2adj);
     }
 
-
     //心率血压血氧校准值
     public static String getPPG_ECG_adjustValue() {
         return Util.getSystemProperties("persist.sys." + Constants.SHAREKEY_SETTING_PPG_ECG_ADJUST, "0,0,0,0");
@@ -702,21 +697,17 @@ public class Config {
 //    SharPreferenceUtil.setPrefStringPublic(context,Constants.SHAREKEY_SETTING_SLEEP_SCORE_DATE,dateyyyyMMddHHmmss);
     }
 
-
     public static void setSleepScore(Context context, int score) {
 //    SharPreferenceUtil.setPrefIntPublic(context,Constants.SHAREKEY_SETTING_SLEEP_SCORE,score);
         Util.setSystemProperties("persist.sys." + Constants.SHAREKEY_SETTING_SLEEP_SCORE, score);
-
     }
 
     public static String getSleepDate(Context context) {
         return Util.getSystemProperties("persist.sys." + Constants.SHAREKEY_SETTING_SLEEP_SCORE_DATE, "");
     }
 
-
     public static int getSleepScore(Context context) {
         return Util.getSystemPropertiesInt("persist.sys." + Constants.SHAREKEY_SETTING_SLEEP_SCORE, 0);
-
     }
 
     public static void setNeedCutOff(Context context, boolean enAnti) {
index 0e326dd..5ec9daf 100644 (file)
@@ -1892,9 +1892,9 @@ public class CoreService extends Service {
         @Override
         public void getContacts() {
             //获取联系人
-            StringMessage cmdmMembers = protocolAPIHelper.requestVideoCallContact(runtime);
+            StringMessage cmdMembers = protocolAPIHelper.requestVideoCallContact(runtime);
             //获取佰锐ID
-            connection.send(cmdmMembers);
+            connection.send(cmdMembers);
             ICLogger.d("get contacts...");
         }
 
@@ -1936,7 +1936,6 @@ public class CoreService extends Service {
 
         @Override
         public void setUpEnvState(int state) {
-
             ICLogger.d("update bairui env state..." + state);
             protocolAPIHelper.updateEnvState(runtime, state);
 
@@ -1948,8 +1947,9 @@ public class CoreService extends Service {
             //交朋友的话是根据配置去走蓝牙交友
             //还是位置交友
             //目前先实现位置交友的功能
-            StringMessage makeFriends = protocolAPIHelper.makeFriendsByPosition(runtime);
-            connection.send(makeFriends);
+            //根据协议开启对应的服务
+            //结果上传
+            protocolAPIHelper.doMakeFriend(runtime);
         }
 
         @Override
index bc30bd8..97db6a6 100644 (file)
@@ -28,7 +28,6 @@ import com.enqualcomm.support.utils.TimeUtil;
 import com.enqualcomm.support.utils.Util;
 import com.ic.protocols.protocolAPIHelper;
 
-import java.util.ArrayList;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 
@@ -143,167 +142,158 @@ public class LocationClient {
     public LocationClient(Connection paramNettyConnection, Runtime paramRuntime) {
         connection = paramNettyConnection;
         runtime = paramRuntime;
-        btHelper = BTHelper.CreateInstance(paramRuntime, new BTHelper.BTScanCallback() {
-            @Override
-            public void OnScanFinished(ArrayList<IBeaconUtil.iBeacon> btBeaconScanResult, ArrayList<String> btNewScanResult) {
-                if (Config.BLEScanProtocol == 0) { //扫描并判定是否在区域内。
-                    if (btNewScanResult != null && btNewScanResult.size() > 0) {
-                        StringBuilder sb = new StringBuilder();
-                        sb.append("found bt mac ").append(btNewScanResult.size());
-                        sb.append(" bounding BeaconMacList ").append(runtime.bleInfo.btMacList.size());
-                        runtime.bleInfo.btScanResult.clear();
-                        for (String mac : runtime.bleInfo.btMacList) {
-                            sb.append(" ").append(mac);
-                        }
-                        ICLogger.i(sb.toString());
-
-
-                        boolean in_area = false;
-                        try {
-                            for (String mac : btNewScanResult) {
-                                ICLogger.i("bt mac " + mac.replace(":", "").toLowerCase() + "  " + mac.toLowerCase());
-                                String tmp = mac.replace(":", "").toLowerCase();
-                                tmp = tmp.substring(0, tmp.indexOf(","));
-                                if (runtime.bleInfo.btMacList.contains(tmp)) {
-                                    in_area = true;
-                                    break;
-                                }
-                            }
-                            if (in_area == false && ScanBLERetryCount-- > 0) {
-                                //如果没有扫描到,且扫描次数没有超限,则重新扫描一次。注意要delay 5秒
-                                Util.mSleep(5000);
-                                //Do retry Scan
-                                ICLogger.i("BT BLE not found retry Scan " + ScanBLERetryCount);
-                                btHelper.scanBLE();
-                                return;
-                            } else {
-                                runtime.bleInfo.is_in_area = in_area;
-                                ScanBLERetryCount = maxBLEScanTime;
+        btHelper = BTHelper.CreateInstance(paramRuntime, (btBeaconScanResult, btNewScanResult) -> {
+            if (Config.BLEScanProtocol == 0) { //扫描并判定是否在区域内。
+                if (btNewScanResult != null && btNewScanResult.size() > 0) {
+                    StringBuilder sb = new StringBuilder();
+                    sb.append("found bt mac ").append(btNewScanResult.size());
+                    sb.append(" bounding BeaconMacList ").append(runtime.bleInfo.btMacList.size());
+                    runtime.bleInfo.btScanResult.clear();
+                    for (String mac : runtime.bleInfo.btMacList) {
+                        sb.append(" ").append(mac);
+                    }
+                    ICLogger.i(sb.toString());
+                    boolean in_area = false;
+                    try {
+                        for (String mac : btNewScanResult) {
+                            ICLogger.i("bt mac " + mac.replace(":", "").toLowerCase() + "  " + mac.toLowerCase());
+                            String tmp = mac.replace(":", "").toLowerCase();
+                            tmp = tmp.substring(0, tmp.indexOf(","));
+                            if (runtime.bleInfo.btMacList.contains(tmp)) {
+                                in_area = true;
+                                break;
                             }
-
-                        } catch (Exception e) {//如果出错,原来的状态不要变。防止误报,最多延迟一个周期报。
-                            e.printStackTrace();
-                            ICLogger.i(e.getMessage());
                         }
-
-
-                    } else {
-                        runtime.bleInfo.is_in_area = false;
-                        ScanBLERetryCount = maxBLEScanTime;
+                        if (!in_area && ScanBLERetryCount-- > 0) {
+                            //如果没有扫描到,且扫描次数没有超限,则重新扫描一次。注意要delay 5秒
+                            Util.mSleep(5000);
+                            //Do retry Scan
+                            ICLogger.i("BT BLE not found retry Scan " + ScanBLERetryCount);
+                            btHelper.scanBLE();
+                            return;
+                        } else {
+                            runtime.bleInfo.is_in_area = in_area;
+                            ScanBLERetryCount = maxBLEScanTime;
+                        }
+                    } catch (Exception e) {//如果出错,原来的状态不要变。防止误报,最多延迟一个周期报。
+                        e.printStackTrace();
+                        ICLogger.i(e.getMessage());
                     }
-                    ICLogger.i("Bt Dev Is in Area " + runtime.bleInfo.is_in_area);
-
-                    if (scanBLEOnly) {
-                        //只扫描蓝牙,不做定位
-                        if (!runtime.bleInfo.is_in_area) {
-                            runtime.updateFZDDevStatusEscape(true);
-                            ICLogger.i("BT 不在区域内");
-                            if (runtime.bleInfo.last_is_in_area) {
-                                //只有上一次在区域内,这次出区域才需要报警
-                                ICLogger.i("BT 不在区域内,且上次在区域内,报警!");
+                } else {
+                    runtime.bleInfo.is_in_area = false;
+                    ScanBLERetryCount = maxBLEScanTime;
+                }
+                ICLogger.i("Bt Dev Is in Area " + runtime.bleInfo.is_in_area);
+
+                if (scanBLEOnly) {
+                    //只扫描蓝牙,不做定位
+                    if (!runtime.bleInfo.is_in_area) {
+                        runtime.updateFZDDevStatusEscape(true);
+                        ICLogger.i("BT 不在区域内");
+                        if (runtime.bleInfo.last_is_in_area) {
+                            //只有上一次在区域内,这次出区域才需要报警
+                            ICLogger.i("BT 不在区域内,且上次在区域内,报警!");
+                            //如果需要报警定位,则强制进行sos定位,不能通过triggerSOS,因为函数中调用了BLEScan会造成循环调用
+                            StringMessage AL_CMD = protocolAPIHelper.getWarningMSG(runtime);
+                            DeliverMessage(AL_CMD);
+                        }
+                    } else {
+                        ICLogger.i("BT 在区域内!");
+                        runtime.updateFZDDevStatusEscape(false);
+                        if (!runtime.bleInfo.last_is_in_area) {
+                            //上一次不在区域内,这次进区域要报警
+                            ICLogger.i("BT 进入区域内,且上次不在区域内,报警!");
+                            if (!Config.noBLE_RelaseEscapeAlarm) {
                                 //如果需要报警定位,则强制进行sos定位,不能通过triggerSOS,因为函数中调用了BLEScan会造成循环调用
                                 StringMessage AL_CMD = protocolAPIHelper.getWarningMSG(runtime);
                                 DeliverMessage(AL_CMD);
                             }
-                        } else {
-                            ICLogger.i("BT 在区域内!");
-                            runtime.updateFZDDevStatusEscape(false);
-                            if (!runtime.bleInfo.last_is_in_area) {
-                                //上一次不在区域内,这次进区域要报警
-                                ICLogger.i("BT 进入区域内,且上次不在区域内,报警!");
-                                if (!Config.noBLE_RelaseEscapeAlarm) {
-                                    //如果需要报警定位,则强制进行sos定位,不能通过triggerSOS,因为函数中调用了BLEScan会造成循环调用
-                                    StringMessage AL_CMD = protocolAPIHelper.getWarningMSG(runtime);
-                                    DeliverMessage(AL_CMD);
-                                }
-                            }
                         }
-                    } else {
-                        //定位前的蓝牙扫描
-                        if (runtime.bleInfo.is_in_area == false) {
-                            ICLogger.i("BT 不在区域内,开启定位流程");
-                            runtime.updateFZDDevStatusEscape(true);
-                            if (runtime.bleInfo.last_is_in_area == true) {
-                                //只有上一次在区域内,这次出区域才需要报警
-                                ICLogger.i("BT 不在区域内,且上次在区域内,报警!");
+                    }
+                } else {
+                    //定位前的蓝牙扫描
+                    if (!runtime.bleInfo.is_in_area) {
+                        ICLogger.i("BT 不在区域内,开启定位流程");
+                        runtime.updateFZDDevStatusEscape(true);
+                        if (runtime.bleInfo.last_is_in_area) {
+                            //只有上一次在区域内,这次出区域才需要报警
+                            ICLogger.i("BT 不在区域内,且上次在区域内,报警!");
+                            StringMessage AL_CMD = protocolAPIHelper.getWarningMSG(runtime);
+                            DeliverMessage(AL_CMD);
+                            runtime.setAlarmType(Runtime.AlarmType.ALARM_REMOVE_SOS);
+                            startSOSLocation = false; //如果已经报警,后面就不用再报了
+                        }
 
-                                StringMessage AL_CMD = protocolAPIHelper.getWarningMSG(runtime);
-                                DeliverMessage(AL_CMD);
-                                runtime.setAlarmType(Runtime.AlarmType.ALARM_REMOVE_SOS);
-                                startSOSLocation = false; //如果已经报警,后面就不用再报了
-                            }
+                        if (startSOSLocation) {
+                            StringMessage AL_CMD = protocolAPIHelper.getWarningMSG(runtime);
+                            DeliverMessage(AL_CMD);
+                            runtime.setAlarmType(Runtime.AlarmType.ALARM_REMOVE_SOS);
+                            startSOSLocation = false;
+                        }
+                        if (startNomalLocation) {
+                            startLocationProcess(runtime.getLocationInstance().getWorkingMod());
+                        }
 
-                            if (startSOSLocation) {
+                    } else {
+                        ICLogger.i("BT 在区域内,直接发送区域坐标即可!");
+                        runtime.updateFZDDevStatusEscape(false);
+                        if (!runtime.bleInfo.last_is_in_area) {
+                            //上一次不在区域内,这次进区域要报警
+                            ICLogger.i("BT 进入区域内,且上次不在区域内,报警!");
+
+                            if (!Config.noBLE_RelaseEscapeAlarm) {
+                                //如果需要报警定位,则强制进行sos定位,不能通过triggerSOS,因为函数中调用了BLEScan会造成循环调用
                                 StringMessage AL_CMD = protocolAPIHelper.getWarningMSG(runtime);
                                 DeliverMessage(AL_CMD);
                                 runtime.setAlarmType(Runtime.AlarmType.ALARM_REMOVE_SOS);
-                                startSOSLocation = false;
-                            }
-                            if (startNomalLocation) {
-                                startLocationProcess(runtime.getLocationInstance().getWorkingMod());
-                            }
-
-                        } else {
-                            ICLogger.i("BT 在区域内,直接发送区域坐标即可!");
-                            runtime.updateFZDDevStatusEscape(false);
-                            if (!runtime.bleInfo.last_is_in_area) {
-                                //上一次不在区域内,这次进区域要报警
-                                ICLogger.i("BT 进入区域内,且上次不在区域内,报警!");
-
-                                if (!Config.noBLE_RelaseEscapeAlarm) {
-                                    //如果需要报警定位,则强制进行sos定位,不能通过triggerSOS,因为函数中调用了BLEScan会造成循环调用
-                                    StringMessage AL_CMD = protocolAPIHelper.getWarningMSG(runtime);
-                                    DeliverMessage(AL_CMD);
-                                    runtime.setAlarmType(Runtime.AlarmType.ALARM_REMOVE_SOS);
-                                    startSOSLocation = false;//如果已经报警,后面就不用再报了
-                                }
+                                startSOSLocation = false;//如果已经报警,后面就不用再报了
                             }
+                        }
 
-                            if (startSOSLocation) {
-                                StringMessage AP01_CMD = protocolAPIHelper.getWarningMSG(runtime);
+                        if (startSOSLocation) {
+                            StringMessage AP01_CMD = protocolAPIHelper.getWarningMSG(runtime);
+                            DeliverMessage(AP01_CMD);
+                            runtime.setAlarmType(Runtime.AlarmType.ALARM_REMOVE_SOS);
+                            startSOSLocation = false;
+                        }
+                        if (startNomalLocation) {
+                            //已经通过蓝牙定位,则清除 forceLocation=0
+                            forceLocation = 0;
+                            startNomalLocation = false; //蓝牙定位,直接发GPS坐标
+                            if (!TextUtils.isEmpty(runtime.getWifiInfo())) {
+                                StringMessage AP01_CMD = protocolAPIHelper.getGPSLocationMSG(runtime);
                                 DeliverMessage(AP01_CMD);
-                                runtime.setAlarmType(Runtime.AlarmType.ALARM_REMOVE_SOS);
-                                startSOSLocation = false;
-                            }
-                            if (startNomalLocation) {
-                                //已经通过蓝牙定位,则清除 forceLocation=0
-                                forceLocation = 0;
-                                startNomalLocation = false; //蓝牙定位,直接发GPS坐标
-                                if (!TextUtils.isEmpty(runtime.getWifiInfo())) {
-                                    StringMessage AP01_CMD = protocolAPIHelper.getGPSLocationMSG(runtime);
-                                    DeliverMessage(AP01_CMD);
-                                }
                             }
                         }
                     }
-                    //处理过此次数据后,把当前状态赋值给上次检测状态
-                    runtime.bleInfo.last_is_in_area = runtime.bleInfo.is_in_area;
-                    //扫描结束就清掉scanBLEOnly,保证下次不会被误操作。
-                    scanBLEOnly = false;
-                } else {
-                    //Config.BLEScanProtocol == 1
-                    if (btBeaconScanResult != null && btBeaconScanResult.size() > 0) {
-                        StringBuilder sb = new StringBuilder();
-                        sb.append("found bt mac ").append(btBeaconScanResult.size());
-                        runtime.bleInfo.btScanResult.clear();
-                        for (IBeaconUtil.iBeacon beacon : btBeaconScanResult) {
-                            sb.append("\n").append(beacon.toString());
-                            if (runtime.bleInfo.btMajorList.size() > 0) {
-                                if (runtime.bleInfo.btMajorList.contains(String.valueOf(beacon.major))) {
-                                    runtime.bleInfo.btScanResult.add(beacon.toString());
-                                    sb.append(" in list!");
-                                } else {
-                                    sb.append(" not in!");
-                                }
-                            } else {
+                }
+                //处理过此次数据后,把当前状态赋值给上次检测状态
+                runtime.bleInfo.last_is_in_area = runtime.bleInfo.is_in_area;
+                //扫描结束就清掉scanBLEOnly,保证下次不会被误操作。
+                scanBLEOnly = false;
+            } else {
+                //Config.BLEScanProtocol == 1
+                if (btBeaconScanResult != null && btBeaconScanResult.size() > 0) {
+                    StringBuilder sb = new StringBuilder();
+                    sb.append("found bt mac ").append(btBeaconScanResult.size());
+                    runtime.bleInfo.btScanResult.clear();
+                    for (IBeaconUtil.iBeacon beacon : btBeaconScanResult) {
+                        sb.append("\n").append(beacon.toString());
+                        if (runtime.bleInfo.btMajorList.size() > 0) {
+                            if (runtime.bleInfo.btMajorList.contains(String.valueOf(beacon.major))) {
                                 runtime.bleInfo.btScanResult.add(beacon.toString());
+                                sb.append(" in list!");
+                            } else {
+                                sb.append(" not in!");
                             }
+                        } else {
+                            runtime.bleInfo.btScanResult.add(beacon.toString());
                         }
-                        ICLogger.i(sb.toString());
-                        Deliver.sendLocationMSG(protocolAPIHelper.getBLEScanResult(runtime));
-                    } else {
-                        ICLogger.i("未搜到蓝牙设备!");
                     }
+                    ICLogger.i(sb.toString());
+                    Deliver.sendLocationMSG(protocolAPIHelper.getBLEScanResult(runtime));
+                } else {
+                    ICLogger.i("未搜到蓝牙设备!");
                 }
             }
         });
@@ -390,9 +380,7 @@ public class LocationClient {
     }
 
     public void triggerSOSLocationProcess() {
-
         mhandler.sendEmptyMessage(msgWhat_StartSOSLocationProcess);
-
     }
 
     private static int checktimes = 0;
@@ -571,9 +559,6 @@ public class LocationClient {
                         }
                     }
                 }
-
-
-//
 //            startSOSLocation=true;//启动SOS定位,为了快速响应,只要wifi定位即可。
 //            forceLocation=1;
 //            if (runtime.bleInfo.btMacList.size() > 0) {
@@ -635,7 +620,7 @@ public class LocationClient {
                     timeout = true;
 
                 }
-                if (NoMoveTimeout == true && (timeout == true || gps_nosignal == true)) {
+                if (NoMoveTimeout && (timeout || gps_nosignal)) {
                     //没有移动,GPS超时或者没信号都会给 计数 加 1
                     gpsTimeoutCountOnNoMove++;
                 }
@@ -647,10 +632,10 @@ public class LocationClient {
                 }
 
                 // lbs only +timeout, lbs+wifi+gpsNosignal, libs+ , lbs+gps+wifi, Timeout can override wifi and gps
-                if ((lbs_ok && timeout == true)
+                if ((lbs_ok && timeout)
                         || (gps_ok)
-                        || (lbs_ok && (gps_ok || startSOSLocation == true))
-                        || (lbs_ok && (gps_ok || startSOSLocation == true) && wifi_ok)
+                        || (lbs_ok && (gps_ok || startSOSLocation))
+                        || (lbs_ok && (gps_ok || startSOSLocation) && wifi_ok)
                         || (lbs_ok && gps_nosignal && wifi_ok)
                 ) {
 
@@ -730,9 +715,7 @@ public class LocationClient {
                     // timeout=true;
                 }
 
-                if ((lbs_ok && timeout == true) || (lbs_ok && wifi_ok)) {
-
-
+                if ((lbs_ok && timeout) || (lbs_ok && wifi_ok)) {
                     String locationtype = "LBS";
                     if (wifi_ok) {
                         locationtype = "WiFi";
@@ -740,7 +723,7 @@ public class LocationClient {
                     runtime.getLocationInstance().setLocationType(locationtype);
                     runtime.getLocationInstance().setLocationTime(TimeUtil.getSystemTime3());
 
-                    if (startSOSLocation == true) {
+                    if (startSOSLocation) {
                         StringMessage AP10_CMD = protocolAPIHelper.getWarningMSG(runtime);
                         DeliverMessage(AP10_CMD);
                         runtime.setAlarmType(Runtime.AlarmType.ALARM_REMOVE_SOS);
index 49673d4..51b66ba 100644 (file)
@@ -39,7 +39,8 @@ import static com.enqualcomm.support.service.InputEventReader.EVENT_TYPE_CUT;
 import static java.lang.Thread.sleep;
 
 
-public class AntiMonitorService extends AbstractInvokeHandlerService implements InputEventReader.InputEventReceiver{
+public class AntiMonitorService extends AbstractInvokeHandlerService
+        implements InputEventReader.InputEventReceiver{
 
 
     private InputEventReader m_inputEventReader=null;
@@ -77,7 +78,6 @@ public class AntiMonitorService extends AbstractInvokeHandlerService implements
             ICLogger.i("近距离 " + current_cut_status + " input event " + cut_status_event_reported + " times !");
             cut_event_receivedTime = System.currentTimeMillis();
             reset_timer_cut();
-
         }else if (type==EVENT_TYPE_ANTI && event >0){
             current_anti_status = event;
             ant_status_event_reported++;
@@ -418,7 +418,7 @@ public class AntiMonitorService extends AbstractInvokeHandlerService implements
         if (cutoff == 0) {
 
             if (Config.A9_noBroadCastActionStrip) {
-                if (mRuntime.needReportCutoff() == true) {
+                if (mRuntime.needReportCutoff()) {
                     Util.ShowToast(mRuntime, mContext.getResources().getString(R.string.alarm_lock_success));
                 }
             } else if (Config.L004_BroadCastActionStrip) {
index 5cb33f3..f89e56c 100644 (file)
@@ -240,7 +240,6 @@ public class InputEventReader {
         callback=ier;
         ThreadPool.getInstance().submitThreadPool(antiEventThread);
         ThreadPool.getInstance().submitThreadPool(cutEventThread);
-
     }
 
     public interface InputEventReceiver{
diff --git a/app/src/main/java/com/enqualcomm/support/utils/MakeFriendsBtHelper.java b/app/src/main/java/com/enqualcomm/support/utils/MakeFriendsBtHelper.java
new file mode 100644 (file)
index 0000000..c81015d
--- /dev/null
@@ -0,0 +1,99 @@
+package com.enqualcomm.support.utils;
+
+import android.bluetooth.BluetoothAdapter;
+import android.os.Handler;
+import android.os.HandlerThread;
+
+import com.enqualcomm.support.bean.Runtime;
+import com.enqualcomm.support.bean.StringMessage;
+import com.enqualcomm.support.service.Deliver;
+import com.ic.protocols.protocolAPIHelper;
+
+import java.util.ArrayList;
+
+
+/**
+ * 交好友的蓝牙辅助类
+ */
+public class MakeFriendsBtHelper {
+
+
+    private final Runtime mRuntime;
+    private final BluetoothAdapter defaultAdapter;
+    private boolean defaultEnable;
+    private final Handler handler;
+    private static String selfAddress;
+
+    public static String getSelfAddress() {
+        return selfAddress;
+    }
+
+    private MakeFriendsBtHelper(Runtime runtime) {
+        this.mRuntime = runtime;
+        defaultAdapter = BluetoothAdapter.getDefaultAdapter();
+        HandlerThread handlerThread = new HandlerThread("ic:make-friend-bt");
+        handlerThread.start();
+        handler = new Handler(handlerThread.getLooper());
+    }
+
+    private static MakeFriendsBtHelper friendsBtHelper;
+
+    public static MakeFriendsBtHelper getInstance(Runtime runtime) {
+        if (friendsBtHelper == null) {
+            friendsBtHelper = new MakeFriendsBtHelper(runtime);
+        }
+        return friendsBtHelper;
+    }
+
+    public void startScanBle(int timeOut) {
+        handler.post(() -> {
+            //结束的时候要重置原来的状态
+            defaultEnable = defaultAdapter.isEnabled();
+            if (!defaultEnable) {
+                defaultAdapter.enable();
+            }
+            mNewDevicesArray.clear();
+            selfAddress = defaultAdapter.getAddress();
+            defaultAdapter.startLeScan(callback);
+        });
+
+        handler.postDelayed(() -> {
+            //停止扫描
+            defaultAdapter.stopLeScan(callback);
+            //构造消息
+            StringBuilder stringBuilder = new StringBuilder();
+            for (int i = 0; i < mNewDevicesArray.size(); i++) {
+                stringBuilder.append(mNewDevicesArray.get(i));
+                if (i != mNewDevicesArray.size() - 1) {
+                    stringBuilder.append(",");
+                }
+            }
+            String s = stringBuilder.toString();
+            ICLogger.d("stringBuilder===> " + s);
+            StringMessage makeFriendMsg = protocolAPIHelper.createMakeFriendMsg(mRuntime, s, null);
+            Deliver.sendLocationMSG(makeFriendMsg);
+            //如果原来是关闭的,就关闭吧,如果原来是打开的,就不关闭了
+            if (!defaultEnable) {
+                defaultAdapter.disable();
+            }
+        }, timeOut * 1000);
+    }
+
+    private static final ArrayList<String> mNewDevicesArray = new ArrayList<>();
+
+    private final BluetoothAdapter.LeScanCallback callback = (device, rssi, scanRecord) -> {
+        //发送交友数据
+        boolean found = false;
+        for (String dev : mNewDevicesArray) {
+            if (dev.contains(device.getAddress())) {
+                found = true;
+                break;
+            }
+        }
+        ICLogger.d("device==> " + device.getAddress() + " rssi===> " + rssi);
+        if (!found) {
+            mNewDevicesArray.add(device.getAddress());
+        }
+    };
+
+}
diff --git a/app/src/main/java/com/enqualcomm/support/utils/MakeFriendsLocationHelper.java b/app/src/main/java/com/enqualcomm/support/utils/MakeFriendsLocationHelper.java
new file mode 100644 (file)
index 0000000..c510a10
--- /dev/null
@@ -0,0 +1,46 @@
+package com.enqualcomm.support.utils;
+
+import com.enqualcomm.support.bean.Runtime;
+import com.enqualcomm.support.bean.StringMessage;
+import com.enqualcomm.support.service.Deliver;
+import com.ic.protocols.protocolAPIHelper;
+
+/**
+ * 以定位的方式去加好友
+ */
+public class MakeFriendsLocationHelper {
+
+    private MakeFriendsLocationHelper() {
+
+    }
+
+    private static MakeFriendsLocationHelper friendsBtHelper;
+
+    public static MakeFriendsLocationHelper getInstance() {
+        if (friendsBtHelper == null) {
+            friendsBtHelper = new MakeFriendsLocationHelper();
+        }
+        return friendsBtHelper;
+    }
+
+    private static final String CMD_SPLIT = ",";
+
+    public void doLocation(Runtime runtime) {
+        StringBuilder sb = new StringBuilder();
+        sb.append(TimeUtil.getSystemDateYYMMDD()).append(CMD_SPLIT)
+                .append(TimeUtil.getSystemTimeHHmmss()).append(CMD_SPLIT)
+                .append(runtime.getFZDGPSData()).append(CMD_SPLIT)
+                .append(String.format("%03d", Math.abs(runtime.getSignalStrength()))).append(CMD_SPLIT)
+                .append(runtime.getBattery()).append(CMD_SPLIT)
+                .append(runtime.getTotalStepCount()).append(CMD_SPLIT)
+                .append(runtime.getRolltimes()).append(CMD_SPLIT)
+                .append(runtime.getFZDDevStatus(runtime)).append(CMD_SPLIT)
+                .append(runtime.getFZDLBSMultiStationData()).append(CMD_SPLIT)
+                .append(runtime.getFZDWifiData());
+        String s = sb.toString();
+        ICLogger.d("location info==> " + s);
+        StringMessage makeFriendMsg = protocolAPIHelper.createMakeFriendMsg(runtime, null, s);
+        Deliver.sendLocationMSG(makeFriendMsg);
+    }
+
+}
index 4882ccd..20d2f9a 100644 (file)
@@ -8,6 +8,8 @@ import com.enqualcomm.support.bean.StringMessage;
 import com.enqualcomm.support.utils.AESCipher;
 import com.enqualcomm.support.utils.Connection;
 import com.enqualcomm.support.utils.ICLogger;
+import com.enqualcomm.support.utils.MakeFriendsBtHelper;
+import com.enqualcomm.support.utils.MakeFriendsLocationHelper;
 
 import static com.enqualcomm.support.Config.PROTOCOL_ANAN;
 
@@ -1310,36 +1312,64 @@ public class protocolAPIHelper {
         return ret;
     }
 
-    public static StringMessage makeFriendsByPosition(Runtime runtime) {
-        if (is_protocol_not_Initialled()) return null;
-        StringMessage ret = null;
+    /**
+     * @param btAddress    蓝牙地址,已经拼接好的
+     * @param locationData 定位数据,已经是字符串了,直接可以使用
+     *                     这两个数据根据类型去发送即可,有可能是没有数据的。
+     * @return
+     */
+    public static StringMessage createMakeFriendMsg(Runtime runtime, String btAddress, String locationData) {
+        if (is_protocol_not_Initialled()) {
+            return null;
+        }
         switch (Config.protocol_no) {
             case Config.PROTOCOL_JIAI:
-                ret = null;
                 break;
             case Config.PROTOCOL_BEEHOME:
-                ret = null;
                 break;
             case Config.PROTOCOL_IC:
-                ret = null;
                 break;
             case Config.PROTOCOL_FZD:
-                ret = protocolfzd_handler.PP(runtime);
+                return protocol_fzd.PP(runtime, locationData);
+            case Config.PROTOCOL_MQTT:
+                break;
+            case PROTOCOL_ANAN:
+                break;
+            case Config.PROTOCOL_S123:
+                break;
+            case Config.PROTOCOL_GATOR:
+                //交朋友,当联系人重新下发的时候,就表示加载成功.
+                return protocol_gator.makeFriend(runtime, btAddress);
+        }
+        return null;
+    }
+
+    public static void doMakeFriend(Runtime runtime) {
+        if (is_protocol_not_Initialled()) {
+            return;
+        }
+        switch (Config.protocol_no) {
+            case Config.PROTOCOL_JIAI:
+                break;
+            case Config.PROTOCOL_BEEHOME:
+                break;
+            case Config.PROTOCOL_IC:
+                break;
+            case Config.PROTOCOL_FZD:
+                MakeFriendsLocationHelper.getInstance().doLocation(runtime);
                 break;
             case Config.PROTOCOL_MQTT:
-                ret = null;
                 break;
             case PROTOCOL_ANAN:
-                ret = null;
                 break;
             case Config.PROTOCOL_S123:
-                ret = null;
                 break;
             case Config.PROTOCOL_GATOR:
-                ret = null;
+                //交朋友,当联系人重新下发的时候,就表示加载成功.
+                MakeFriendsBtHelper.getInstance(runtime).startScanBle(30);
                 break;
         }
-        return ret;
+        return;
     }
 
     public static StringMessage unbindFriends(Runtime runtime, String remoteFriendId) {
index c189128..bb25171 100644 (file)
@@ -1152,11 +1152,11 @@ public class protocol_fzd {
             ICLogger.i("LGZONE Format Error!");
         }
         isServerReady = true;
-        ICLogger.i("isServerReady = "+isServerReady);
+        ICLogger.i("isServerReady = " + isServerReady);
         serverReady();
     }
 
-    private void serverReady(){
+    private void serverReady() {
         //收到服务器时间消息的时候认为服务器已经准备好了
         RemoteCallbackList<IFZDCallback> fzdCallback = mRuntime.getFZDCallback();
         int i = fzdCallback.beginBroadcast();
@@ -1434,7 +1434,7 @@ public class protocol_fzd {
         return genFZDCMD(cmdMap.get(CMD_TYPE.AGREG));
     }
 
-    public void getServerReady(){
+    public void getServerReady() {
         serverReady();
     }
 
@@ -1442,21 +1442,12 @@ public class protocol_fzd {
         return genFZDCMD(cmdMap.get(CMD_TYPE.PHL));
     }
 
-    public static StringMessage PP(Runtime runtime) {
+    public static StringMessage PP(Runtime runtime, String locationData) {
         //地理位置数据
-        String locationData = getLocationData(runtime);
         return genFZDCMD(cmdMap.get(CMD_TYPE.PP), locationData);
     }
 
 
-    /**
-     * 根据位置交朋友
-     */
-    public static void makeFriendsByPosition(Connection connection, Runtime runtime) {
-        StringMessage pp = PP(runtime);
-        connection.send(pp);
-    }
-
     /***
      * [IC*334588000000156*len*PHL,号码,名字,号码,名字,号码,名字,号码,名字,号码,名字] len:发送长度 16 进制表示 占用 2 个字节
      * 号码:ascii 字符 名字:Unicode 编码
@@ -2875,7 +2866,7 @@ public class protocol_fzd {
             ICLogger.d("members result == > " + str);
             //对数据进行切割
             String[] split = str.split(CMD_SPLIT);
-            if(split != null && split.length % 3 != 0){
+            if (split != null && split.length % 3 != 0) {
                 str = str + "0";
                 split = str.split(CMD_SPLIT);
             }
index 521e95e..e673235 100644 (file)
@@ -7,6 +7,7 @@ import android.net.Uri;
 import android.os.Environment;
 import android.os.Handler;
 import android.os.HandlerThread;
+import android.text.TextUtils;
 import android.util.Log;
 
 import com.enqualcomm.support.Config;
@@ -28,6 +29,7 @@ import com.enqualcomm.support.utils.DeviceInfoUtil;
 import com.enqualcomm.support.utils.ICAudioManager;
 import com.enqualcomm.support.utils.ICLogger;
 import com.enqualcomm.support.utils.LanguageUtils;
+import com.enqualcomm.support.utils.MakeFriendsBtHelper;
 import com.enqualcomm.support.utils.TimeUtil;
 import com.enqualcomm.support.utils.Util;
 import com.enqualcomm.support.utils.regexUtil;
@@ -63,6 +65,7 @@ public class protocol_gator {
     private static final String CMDSPLIT = ",";
     public static final String defaultServerIP = "watch.gatorcn.com";
     public static final int defaultServerPort = 27015;
+
     // public static final String defaultServerIP = "snickersun.oicp.net";
     // public static final int defaultServerPort = 54944;
 
@@ -385,8 +388,6 @@ public class protocol_gator {
                         .append(",packetCount = ").append(packetCount)
                         .append(",currentId = ").append(currentId)
                         .append(",packetLen = ").append(packetLen);
-
-
                 log(stringBuffer.toString());
                 return packetLen;
             } catch (Exception e) {
@@ -400,6 +401,33 @@ public class protocol_gator {
         return -1;
     }
 
+    /**
+     * 返回加好码的消息
+     *
+     * @param runtime
+     * @param btAddress
+     * @return
+     */
+    public static StringMessage makeFriend(Runtime runtime, String btAddress) {
+        //交朋友
+        //返回空即可,打开蓝牙,扫描附近的蓝牙设备,拼接数据
+        String[] split = btAddress.split(CMDSPLIT);
+        ICLogger.d("split size===> " + split.length);
+        StringBuilder sb = new StringBuilder(cmdMap.get(CMD_TYPE.BP35));
+        sb.append(CMDSPLIT);
+        sb.append(TimeUtil.getSystemDateYYMMDD() + CMDSPLIT +
+                TimeUtil.getSystemTimeHHmmss() + CMDSPLIT +
+                MakeFriendsBtHelper.getSelfAddress() + CMDSPLIT +
+                split.length + CMDSPLIT + btAddress);
+        String msg = AddHeader(runtime,
+                sb.toString()
+        );
+        StringMessage stringMessage = genStringMessage(cmdMap.get(CMD_TYPE.BP35), msg);
+        ICLogger.d("stringMessage==> " + msg);
+        //发送交好友请求
+        return stringMessage;
+    }
+
     //回复服务器专用通用接口
     public StringMessage BPXX_REPLY(Runtime ds, CMD_TYPE type, String index, boolean success) {
         StringMessage ret = null;
@@ -1003,8 +1031,12 @@ public class protocol_gator {
         }
         //类型    "LBS"   "GPS"  "WiFi"
         String LocationType = ds.getLocationInstance().getLocationType();
-        if (LocationType.equals("LBS")) {
+        if (TextUtils.isEmpty(LocationType)) {
+            ICLogger.e("没有有效定位信息");
+            return null;
+        }
 
+        if (LocationType.equals("LBS")) {
             if (ds.getGatorLBSMultiStationData().isEmpty()) {
                 //no available data
                 ICLogger.e("没有有效定位信息");
index f29a9ea..e6f1f18 100644 (file)
@@ -1,2 +1,2 @@
-#Thu Jul 29 17:26:00 CST 2021\r
-VERSION_CODE=902\r
+#Fri Jul 30 15:49:03 CST 2021\r
+VERSION_CODE=904\r