-[{"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
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);
}
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);
}
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");
// 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) {
@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...");
}
@Override
public void setUpEnvState(int state) {
-
ICLogger.d("update bairui env state..." + state);
protocolAPIHelper.updateEnvState(runtime, state);
//交朋友的话是根据配置去走蓝牙交友
//还是位置交友
//目前先实现位置交友的功能
- StringMessage makeFriends = protocolAPIHelper.makeFriendsByPosition(runtime);
- connection.send(makeFriends);
+ //根据协议开启对应的服务
+ //结果上传
+ protocolAPIHelper.doMakeFriend(runtime);
}
@Override
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;
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("未搜到蓝牙设备!");
}
}
});
}
public void triggerSOSLocationProcess() {
-
mhandler.sendEmptyMessage(msgWhat_StartSOSLocationProcess);
-
}
private static int checktimes = 0;
}
}
}
-
-
-//
// startSOSLocation=true;//启动SOS定位,为了快速响应,只要wifi定位即可。
// forceLocation=1;
// if (runtime.bleInfo.btMacList.size() > 0) {
timeout = true;
}
- if (NoMoveTimeout == true && (timeout == true || gps_nosignal == true)) {
+ if (NoMoveTimeout && (timeout || gps_nosignal)) {
//没有移动,GPS超时或者没信号都会给 计数 加 1
gpsTimeoutCountOnNoMove++;
}
}
// 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)
) {
// 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";
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);
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;
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++;
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) {
callback=ier;
ThreadPool.getInstance().submitThreadPool(antiEventThread);
ThreadPool.getInstance().submitThreadPool(cutEventThread);
-
}
public interface InputEventReceiver{
--- /dev/null
+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());
+ }
+ };
+
+}
--- /dev/null
+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);
+ }
+
+}
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;
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) {
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();
return genFZDCMD(cmdMap.get(CMD_TYPE.AGREG));
}
- public void getServerReady(){
+ public void getServerReady() {
serverReady();
}
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 编码
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);
}
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;
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;
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;
.append(",packetCount = ").append(packetCount)
.append(",currentId = ").append(currentId)
.append(",packetLen = ").append(packetLen);
-
-
log(stringBuffer.toString());
return packetLen;
} catch (Exception e) {
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;
}
//类型 "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("没有有效定位信息");
-#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