--- /dev/null
+{
+ "version": 1,
+ "artifactType": {
+ "type": "APK",
+ "kind": "Directory"
+ },
+ "applicationId": "com.ic.work",
+ "variantName": "IcA9WorkServiceRelease",
+ "elements": [
+ {
+ "type": "SINGLE",
+ "filters": [],
+ "properties": [],
+ "versionCode": 1,
+ "versionName": "5.0",
+ "enabled": true,
+ "outputFile": "IcA9WorkService_V54_202008131857_release.apk"
+ }
+ ]
+}
\ No newline at end of file
apply plugin: 'com.android.application'
-static def getL02ApkBaseName() {
- return "ICL02WorkService"
-}
android {
def currentVersionCode = getVersionCode()
- def currentVersionName = releaseTime()
compileSdkVersion 29
buildToolsVersion "29.0.2"
minSdkVersion 19
targetSdkVersion 29
versionCode currentVersionCode
- versionName "${currentVersionName}"
+ versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
}
}
+ productFlavors{
+
+ IcA9WorkService{
+ flavorDimensions "IcA9WorkService"
+ versionCode 1
+ versionName "5.0"
+ buildConfigField "int", "productType", "1002"
+
+ }
+
+ IcAkWorkService{
+ flavorDimensions "IcAkWorkService"
+ versionCode 1
+ versionName "1.0"
+ buildConfigField "int", "productType", "1001"
+ }
+
+ IcL02WorkService{
+ flavorDimensions "IcAkWorkService"
+ versionCode 1
+ versionName "1.0"
+ buildConfigField "int", "productType", "1003"
+ }
+ }
+
android.applicationVariants.all { variant ->
variant.outputs.all {
if (variant.buildType.name == "release") {
- outputFileName = "${getL02ApkBaseName()}_V${currentVersionCode}_${currentVersionName}_release.apk"
+ outputFileName = "${variant.getFlavorName()}_V${currentVersionCode}_${releaseTime()}_release.apk"
} else {
- outputFileName = "${getL02ApkBaseName()}_V${currentVersionCode}_${currentVersionName}_debug.apk"
+ outputFileName = "${variant.getFlavorName()}_V${currentVersionCode}_${releaseTime()}_debug.apk"
}
}
}
}
}
-def releaseTime() {
+static def releaseTime() {
return new Date().format("yyyyMMddHHmm", TimeZone.getTimeZone("GMT+08:00"))
}
--- /dev/null
+package com.ic.aidl.ak;
+
+public class BloodState {
+
+ public static final int BLOOD_NULL_TIPS = -1;
+ public static final int BLOOD_NOT_DEVICE = 1001;
+
+ public static final int BLOOD_PLEASE_QUIET = 1002;
+ public static final int BLOOD_START_CHECK= 1003;
+
+ public static final int BLOOD_NOT_WEAR=1004;
+ public static final int BLOOD_ING_CHECK=1005;
+
+ public static final int BLOOD_STOP_CHECK=1006;
+ public static final int BLOOD_NOT_DATA_CHECK=1007;
+}
--- /dev/null
+// ITempAidlInterface.aidl
+package com.ic.aidl.ak;
+
+// Declare any non-default types here with import statements
+
+interface IAkAidlInterface {
+ /**
+ * Demonstrates some basic types that you can use as parameters
+ * and return values in AIDL.
+ */
+ void updateBloodCheckResult(int high,int low,int heart,int oxygen);
+ void updateBloodCheckTips(int top,int bottom);
+ void updatePedCount(int count);
+ void updateCurrTempValue(double value,double animal);
+ void updateResultTempValue(double value,double animal);
+}
--- /dev/null
+// ITempRemoteService.aidl
+package com.ic.aidl.ak;
+
+// Declare any non-default types here with import statements
+
+import com.ic.aidl.ak.IAkAidlInterface;
+
+interface IAkRemoteService {
+ /**
+ * Demonstrates some basic types that you can use as parameters
+ * and return values in AIDL.
+ */
+ void registerCallback(IAkAidlInterface cb);
+ void unregisterCallback(IAkAidlInterface cb);
+
+ void startCheckBlood();
+ void stopCheckBlood();
+ void queryPedCount();
+
+ void onStartQueryTemp();
+ void onStopQueryTemp();
+}
-// IWeatherAidlInterface.aidl
+// ITempAidlInterface.aidl
package com.ic.aidl.blood;
// Declare any non-default types here with import statements
* Demonstrates some basic types that you can use as parameters
* and return values in AIDL.
*/
-
+ void updateBloodCheckTemp(int high,int low,int heart);
void updateBloodCheckResult(int high,int low,int heart);
void updateBloodCheckTips(int top,int bottom);
}
-// IWeatherRemoteService.aidl
+// ITempRemoteService.aidl
package com.ic.aidl.blood;
// Declare any non-default types here with import statements
-// IWeatherAidlInterface.aidl
+// ITempAidlInterface.aidl
package com.ic.aidl.ped;
// Declare any non-default types here with import statements
-// IWeatherRemoteService.aidl
+// ITempRemoteService.aidl
package com.ic.aidl.ped;
// Declare any non-default types here with import statements
--- /dev/null
+// ITempAidlInterface.aidl
+package com.ic.aidl.temp;
+
+interface ITempAidlInterface {
+ /**
+ * Demonstrates some basic types that you can use as parameters
+ * and return values in AIDL.
+ */
+ void updateCurrTempValue(double value,double animal);
+ void updateResultTempValue(double value,double animal);
+}
--- /dev/null
+// ITempRemoteService.aidl
+package com.ic.aidl.temp;
+
+// Declare any non-default types here with import statements
+
+import com.ic.aidl.temp.ITempAidlInterface;
+
+interface ITempRemoteService {
+ /**
+ * Demonstrates some basic types that you can use as parameters
+ * and return values in AIDL.
+ */
+ void registerCallback(ITempAidlInterface cb);
+ void unregisterCallback(ITempAidlInterface cb);
+
+ void onStartQueryTemp();
+ void onStopQueryTemp();
+}
-// IWeatherAidlInterface.aidl
+// ITempAidlInterface.aidl
package com.ic.aidl.weather;
// Declare any non-default types here with import statements
-// IWeatherRemoteService.aidl
+// ITempRemoteService.aidl
package com.ic.aidl.weather;
// Declare any non-default types here with import statements
package com.ic.jni;
-
public class ICJniUtils {
+ public enum GSensorType
+ {
+ GSENSOR_TYPE_NONE,
+ GSENSOR_TYPE_QMA7981,
+ GSENSOR_TYPE_SC7A21,
+ GSENSOR_TYPE_MAX
+ };
+
+ public enum TempSensorType
+ {
+ TEMPSENSOR_TYPE_NONE,
+ TEMPSENSOR_TYPE_NST175,
+ TEMPSENSOR_TYPE_IC68,
+ TEMPSENSOR_TYPE_EM7068,
+ TEMPSENSOR_TYPE_MAX
+ };
+
+ public enum PPG_EGC_SensorType
+ {
+ PPG_EGC_TYPE_NONE,
+ PPG_EGC_TYPE_EM7028,
+ PPG_EGC_TYPE_EM7068,
+ PPG_EGC_TYPE_HRS3313,
+ PPG_EGC_TYPE_HRS3301,
+ PPG_EGC_TYPE_IC66,
+ PPG_EGC_TYPE_PAH8002,
+ PPG_EGC_TYPE_MAX
+ };
+
public ICJniUtils(){
}
-
static {
+ // build.gradle里面 android\defaultConfig\ndk\moduleName 的名称
+ // Android.mk, LOCAL_MODULE 的名称
System.loadLibrary("ICJniUtils");
}
/***************计步控制************************************/
- /*运行此函数清除 系统计步为0*/
+ /***
+ * 运行此函数清除 系统计步为0,一版在午夜执行
+ * @return
+ */
public static native int resetStepCount();
- /*获取当前步数*/
+ /***
+ * 获取当前步数
+ * @return
+ */
public static native int getStepCount();
- /*开启计步 不必判断返回值*/
+
+ /***
+ * 开启计步 不必判断返回值
+ * @return
+ */
public static native int enablePedometer();
- /*停止计步 不必判断返回值*/
+
+ /***
+ * 停止计步 不必判断返回值
+ * @return
+ */
public static native int disablePedometer();
- /*检测计步当前是否开启 1开启,0 关闭*/
+ /***
+ * 检测计步当前是否开启
+ * @return
+ * 1开启,0 关闭
+ */
public static native int isPedometerEnabled();
- /*保存当前步数(getStepCount取得的值)到磁盘 不必判断返回值*/
+ /***
+ * 获取当前计步器(GSensor)类型 GSensorType
+ * @return
+ * 不存在返回 GSENSOR_TYPE_NONE,否则返回Gsensor类型
+ * 理论上此设备必选,一定存在。
+ */
+ public static native int getGsensorType();
+
+ /*保存当前步数(getStepCount取得的值)到磁盘 不必判断返回值
+ * 为了兼容,已经不再使用
+ * */
public static native int saveStepCount();
- /*恢复保存时的步数数据,下次getStepCount会在恢复的值上增加 不必判断返回值*/
+ /*恢复保存时的步数数据,下次getStepCount会在恢复的值上增加 不必判断返回值
+ * * 为了兼容,已经不再使用
+ * */
public static native int recoverStepCount();
-
/******心率,血压****************************************/
- /*检查 PPG硬件是否存在,返回 1 存在,0 不存在*/
+ /***
+ * 检查 PPG硬件是否存在,返回PPG_EGC_SensorType
+ * @return
+ * 返回PPG_EGC_TYPE_NONE代表不存在,否则返回 传感器类型
+ */
public static native int isPPGavailable();
- /*开启心率血压检测*/
+ /**
+ * 开启心率血压检测
+ * @return
+ */
public static native int enablePPG();
- /*停止心率血压检测*/
+ /***
+ * 停止心率血压检测
+ * @return
+ */
public static native int disablePPG();
- /*返回 心率值 每分钟跳动次数, 通过这个心率>0 判断是否已经有检测结果,
- 有就可以直接通过getHighBloodPressure 和 getLowBloodPressure 获取血压高压低压值*/
- public static native int getPPG();
- /* 返回PPG 运行状态, 0 停止, 1,运行中*/
+
+
+ /***
+ * 返回PPG 运行状态, 0 停止, 1,运行中
+ * @return
+ */
public static native int isPPGStarted();
- /*返回是否佩戴 0 未佩戴,1 佩戴*/
+
+ /***
+ * 返回 心率值 每分钟跳动次数, 通过这个心率>0 判断是否已经有检测结果,
+ * 有就可以直接通过getHighBloodPressure 和 getLowBloodPressure 获取血压高压低压值
+ * @return
+ */
+ public static native int getPPG();
+
+ /***
+ * 返回是否佩戴 0 未佩戴,1 佩戴 。
+ * 请注意,此数据必须在执行 getPPG() 后才有效,否则一直为上一次的值。
+ * @return
+ */
public static native int isWeared();
- /*获取血压高压值*/
+ /***
+ * 获取血压高压值
+ * 请注意,此数据必须在执行 getPPG() 后才有效,否则一直为上一次的值。
+ * @return
+ */
public static native int getHighBloodPressure();
- /*获取血压低压值*/
+ /***
+ * 获取血压低压值
+ * 请注意,此数据必须在执行 getPPG() 后才有效,否则一直为上一次的值。
+ * @return
+ */
public static native int getLowBloodPressure();
- /*获取血氧值*/
+ /***
+ * 获取血氧值
+ * 请注意,此数据必须在执行 getPPG() 后才有效,否则一直为上一次的值。
+ * @return
+ */
public static native int getSPO2();
+
+
+ /***
+ * 开始温度检测,有些sensor不需要,为了兼容,请开始前执行一次,并且sleep 1秒钟
+ * @return
+ */
+ public static native int enableTemperature();
+
+ /***
+ * 停止温度检测,有些sensor不需要,为了兼容请结束后还是要执行一次。
+ * @return 返回值<0 表示失败 =>0表示成功
+ */
+ public static native int disableTemperature();
+
+ /***
+ * 检查体温检测设备是否开启
+ * @return 返回0 未开启 1 开启
+ */
+ public static native int isTemperatureDevOpened();
+ /***
+ * 执行温度校准操作,一版在整机生产时的恒温箱中执行
+ * @param refTemp 恒温箱的温度
+ * @return 返回值<0 表示失败 =>0表示成功
+ */
+ public static native int doTempCalibration(double refTemp);
+
+ /***
+ * 获取温度 校准后数据 单位摄氏度
+ * @return 返回值<=0 表示失败 >0表示成功
+ */
+ public static native double getTemperature();
+
+ /***
+ * 设置当前温度标志位,
+ * @param flag
+ * 实际上就是按照二进制位来定义的。
+ * 0、可以测温
+ * 第一位为1,0x1、充电超过2分钟或者充电超过2分钟后拔除5分钟内 0001
+ * 第二位为1,0x2、亮屏超过5分钟或者亮屏超过5分钟后灭屏5分钟内 0010
+ * 第三位为1,0x4、通话超过2分钟或者通话超过2分钟后挂断5分钟内 0100
+ * 所有大于0的都不能测温
+ * 注:暂时未启用,预留
+ * @return
+ */
+ public static native int setTemperatureValidFlag(int flag);
+
+ /***
+ * 此操作仅仅为了检查标志状态设置成功与否,标志已经在内部被使用
+ * 注:暂时未启用,预留
+ * @return
+ */
+ public static native int getTemperatureValidFlag();
+
+ /***
+ * 根据环境参考温度和腕温换算 体温
+ * ic66可以直接输出体温,不需要这个公式。
+ * @param wrist_temp
+ * 腕温
+ * @param ref_temp
+ * 室外参考温度
+ * @return 返回值<=0 表示失败 >0表示成功
+ */
+ public static native double getBodyTempFromWristTemp(double wrist_temp,double ref_temp);
+
+
+ /***
+ * 有体温检测功能则返回 TempSensorType
+ * TempSensor_NONE 就表示没有体温检测功能,否则返回温度传感器类型
+ * @return
+ */
+ public static native int isTemperatureDevAvailable();
+
+
+ /*获取温度校准前
+ * 为了兼容已经不用
+ * */
+ public static native double getTemperatureOrigin();
+
+ /*设置校准参数
+ * * 为了兼容已经不用
+ * */
+ public static native int setTemperatureAdjustValue(double value);
+
+ /*设置校准参数
+ * * 为了兼容已经不用
+ * */
+ public static native double getTemperatureAdjustValue();
}
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
+import android.content.SharedPreferences;
+import android.content.pm.PackageManager;
import android.os.Build;
import android.os.IBinder;
import android.text.TextUtils;
import androidx.annotation.RequiresApi;
+import com.ic.work.event.AkBloodCheckResultEvent;
import com.ic.work.event.BloodCheckResultEvent;
+import com.ic.work.event.BloodCheckTempEvent;
import com.ic.work.event.BloodCheckTipsEvent;
+import com.ic.work.event.BloodSensorEvent;
import com.ic.work.event.LocationResultEvent;
import com.ic.work.event.PedCountEvent;
import com.ic.work.event.PedRecordResultEvent;
import com.ic.work.event.PedSettingEvent;
+import com.ic.work.event.TemperatureResultCompleteEvent;
+import com.ic.work.event.TemperatureResultEvent;
import com.ic.work.event.ThreadPoolEvent;
import com.ic.work.event.WeatherAgainEvent;
import com.ic.work.event.WeatherResultEvent;
+import com.ic.work.hardware.A9BloodRunnable;
+import com.ic.work.hardware.AkBloodRunnable;
import com.ic.work.hardware.BeforeDawnRunnable;
import com.ic.work.hardware.BloodRunnable;
+import com.ic.work.hardware.BloodSensorManager;
import com.ic.work.hardware.MessengerCoreService;
import com.ic.work.hardware.PedRecordRunnable;
import com.ic.work.hardware.PedRunnable;
+import com.ic.work.hardware.TemperatureRunnable;
+import com.ic.work.process.AkProcess;
import com.ic.work.process.BloodProcess;
import com.ic.work.process.PedProcess;
+import com.ic.work.process.TempProcess;
import com.ic.work.process.WeatherProcess;
import com.ic.work.utils.IcLog;
+import com.ic.work.utils.IcSystemProperty;
import com.ic.work.utils.SPUtils;
import com.ic.work.weather.WeatherDBRun;
import com.ic.work.weather.WeatherHelper;
private static final String PED_TOTAL_KEY = "PED_TOTAL";
private static final String PED_FINISH_ACTION = "com.ic.action.PED_FINISH";
+ public static final String ACTION_TEMP_RESULT = "com.ic.action.temp_result";
+ public static final String KEY_TEMP_BODY = "body"; // double 体温
+ public static final String KEY_TEMP_WRIST = "wrist"; // double 腕温
+
+ private static final String TXT_ACTION = "action.ic.srvPushTxt";
+ private static final String TYPE_KEY = "msgType";
+ private static final String MSG_KEY = "txtMsg";
+
private WeatherProcess weatherProcess;
private BloodProcess bloodProcess;
private PedProcess pedProcess;
+ private TempProcess tempProcess;
+ private AkProcess akProcess;
private WeatherHelper mWeatherHelper;
private LocalDateTime mFinishTime;
+ private BloodSensorManager bloodSensorManager;
+
@Override
public IBinder onBind(Intent intent) {
if (intent != null) {
case "com.ic.hardware":
//计步
return pedProcess.getPedBinder();
+ case "com.ic.temp":
+ //计步
+ return tempProcess.getTempBinder();
+ case "com.ic.ak":
+ //计步
+ return akProcess.getAkBinder();
default:
return null;
}
weatherProcess = new WeatherProcess();
bloodProcess = new BloodProcess();
pedProcess = new PedProcess();
+ tempProcess = new TempProcess();
+ akProcess = new AkProcess();
mWeatherHelper = new WeatherHelper();
bloodProcess.sendBloodCheckTips(event.getTopTips(),
event.getBottomTips());
}
+
+ if (akProcess != null) {
+ akProcess.sendBloodCheckTips(event.getTopTips(), event.getBottomTips());
+ }
+ }
+
+ @Subscribe(threadMode = ThreadMode.MAIN)
+ public void onMessageEvent(BloodCheckTempEvent event) {
+ if (bloodProcess != null) {
+ bloodProcess.sendBloodCheckTemp(event.getHigh(),
+ event.getLow(), event.getHeart());
+ }
}
@Subscribe(threadMode = ThreadMode.MAIN)
}
if (coreService != null) {
- coreService.sendBloodValueMessage(event.getHigh(), event.getLow(), event.getHeart());
+ coreService.sendBloodValueMessage(event.getHigh(), event.getLow(), event.getHeart(), 0);
}
//发送一次广播给 心率 launcher
pedProcess.sendPedCount(event.getPedCount());
}
+ if (akProcess != null) {
+ akProcess.sendPedCount(event.getPedCount());
+ }
//发送一次广播给launcher
sendPedCountBroadcast(event.getPedCount());
}
}
}
+ @Subscribe(threadMode = ThreadMode.MAIN)
+ public void onMessageEvent(TemperatureResultEvent event) {
+ if (tempProcess != null) {
+ tempProcess.sendCurrTempValue(event.value, event.animal);
+ }
+
+ if (akProcess != null) {
+ akProcess.sendCurrTempValue(event.value, event.animal);
+ }
+ }
+
+ @Subscribe(threadMode = ThreadMode.MAIN)
+ public void onMessageEvent(TemperatureResultCompleteEvent event) {
+ sendTempBroadcast(event.value, event.animal);
+ if (tempProcess != null) {
+ tempProcess.sendResultTempValue(event.value, event.animal);
+ }
+
+ if (akProcess != null) {
+ akProcess.sendResultTempValue(event.value, event.animal);
+ }
+
+ }
+
+ @Subscribe(threadMode = ThreadMode.MAIN)
+ public void onMessageEvent(AkBloodCheckResultEvent event) {
+ int[] deviation = getPPG_ECG_adjustValue(this);
+ event.heart = event.heart + deviation[0];
+ event.high = event.high + deviation[1];
+ event.low = event.low + deviation[2];
+ event.oxygen = event.oxygen + deviation[3];
+
+ if (akProcess != null) {
+ akProcess.sendBloodCheckResult(event.high, event.low, event.heart, event.oxygen);
+ }
+
+ if (coreService != null) {
+ coreService.sendBloodValueMessage(event.high, event.low, event.heart, event.oxygen);
+ }
+ }
+
+ @Subscribe(threadMode = ThreadMode.MAIN)
+ public void onMessageEvent(BloodSensorEvent event) {
+ switch (event.type) {
+ case 1:
+ if (bloodSensorManager == null) {
+ bloodSensorManager = new BloodSensorManager();
+ }
+ bloodSensorManager.createSensorManager(this);
+ break;
+ case 2:
+ bloodSensorManager.unregisterSensorListener();
+ break;
+ }
+ }
+
+
@Subscribe(threadMode = ThreadMode.MAIN)
public void onMessageEvent(ThreadPoolEvent event) {
switch (event.getEventType()) {
case 1:
- ThreadPoolManager.getInstance().execute(new PedRunnable(mApp.getApplicationContext(),mApp.getRepository()));
+ ThreadPoolManager.getInstance().execute(new PedRunnable(mApp.getApplicationContext(), mApp.getRepository()));
break;
case 2:
ThreadPoolManager.getInstance().execute(new PedRecordRunnable(mApp.getRepository()));
case 5:
ThreadPoolManager.getInstance().execute(new WeatherDBRun(mApp.getWeatherRepository()));
break;
+ case 6:
+ ThreadPoolManager.getInstance().execute(new TemperatureRunnable());
+ break;
+ case 7:
+ ThreadPoolManager.getInstance().execute(new A9BloodRunnable());
+ break;
+ case 8:
+ ThreadPoolManager.getInstance().execute(new AkBloodRunnable());
+ break;
}
}
pedIntent.setAction(PED_ACTION);
pedIntent.putExtra("PED_COUNT", count);
sendBroadcast(pedIntent);
+
+ //testBatteryBroadcast(this,"ddddddddddddtttttttttttttttttttttttt");
}
private void sendHeartBroadcast(int count) {
sendBroadcast(pedIntent);
}
+ private void sendTempBroadcast(double value, double animal) {
+ Intent pedIntent = new Intent();
+ pedIntent.setAction(ACTION_TEMP_RESULT);
+ pedIntent.putExtra(KEY_TEMP_WRIST, value);
+ pedIntent.putExtra(KEY_TEMP_BODY, animal);
+ sendBroadcast(pedIntent);
+ }
+
private BroadcastReceiver mIntentReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
}
switch (acyion) {
case GET_PED_ACTION:
- ThreadPoolManager.getInstance().execute(new PedRunnable(mApp.getApplicationContext(),mApp.getRepository()));
+ ThreadPoolManager.getInstance().execute(new PedRunnable(mApp.getApplicationContext(), mApp.getRepository()));
break;
case Intent.ACTION_TIMEZONE_CHANGED:
mWeatherHelper.startLocation(getApplicationContext());
break;
case PED_FINISH_ACTION:
- IcLog.i(TAG,"PED_FINISH_ACTION");
everyDayFinish(intent);
break;
}
}
};
- private void everyDayFinish(Intent intent){
- if(mFinishTime != null){
+ private void everyDayFinish(Intent intent) {
+ if (mFinishTime != null) {
LocalDateTime time = LocalDateTime.now(ZoneId.systemDefault());
- if(Duration.between(time,mFinishTime).toDays() < 1){
+ if (Duration.between(time, mFinishTime).toDays() < 1) {
return;
}
}
- IcLog.i(TAG,"everyDayFinish");
+ IcLog.i(TAG, "everyDayFinish");
mFinishTime = LocalDateTime.now(ZoneId.systemDefault());
//完成,需要把所有的今天的数据全部写入到数据中
ThreadPoolManager.getInstance().execute(new BeforeDawnRunnable(
mApp.getRepository(),
intent.getIntExtra(PED_TOTAL_KEY, 0)));
}
+
+
+ public int[] getPPG_ECG_adjustValue(Context context) {
+
+ String value = IcSystemProperty.getSystemProperties("persist.sys.PpgEcgAdjust", "0,0,0,0");
+ IcLog.i(TAG,"getPPG_ECG_adjustValue:"+value);
+ String[] result = value.split(",");
+ if (result.length == 4) {
+ int[] res = new int[4];
+ for (int i = 0; i < result.length; i++) {
+ res[i] = Integer.parseInt(result[i]);
+ }
+ return res;
+ }
+
+ return null;
+ }
+
+ public static void testBatteryBroadcast(Context context, String messgae) {
+ Intent intent = new Intent("com.ic.action.keep_sit_alarm");
+ //intent.putExtra(MSG_KEY,messgae);
+ context.sendBroadcast(intent);
+ }
}
--- /dev/null
+package com.ic.work.event;
+
+public class AkBloodCheckResultEvent {
+ public int high;
+ public int low;
+ public int heart;
+ public int oxygen;
+
+ public AkBloodCheckResultEvent(int high, int low, int heart, int oxygen) {
+ this.high = high;
+ this.low = low;
+ this.heart = heart;
+ this.oxygen = oxygen;
+ }
+}
--- /dev/null
+package com.ic.work.event;
+
+public class BloodCheckTempEvent {
+ private int high;
+ private int low;
+ private int heart;
+
+
+ public BloodCheckTempEvent(int high, int low, int heart) {
+ this.high = high;
+ this.low = low;
+ this.heart = heart;
+ }
+
+ public int getHigh() {
+ return high;
+ }
+
+ public int getLow() {
+ return low;
+ }
+
+ public int getHeart() {
+ return heart;
+ }
+}
--- /dev/null
+package com.ic.work.event;
+
+public class BloodSensorEvent {
+ public int type;
+
+ public BloodSensorEvent(int type) {
+ this.type = type;
+ }
+}
--- /dev/null
+package com.ic.work.event;
+
+public class TemperatureResultCompleteEvent {
+ public double value;
+ public double animal;
+
+ public TemperatureResultCompleteEvent(double value, double animal) {
+ this.value = value;
+ this.animal = animal;
+ }
+}
--- /dev/null
+package com.ic.work.event;
+
+public class TemperatureResultEvent {
+ public double value;
+ public double animal;
+
+ public TemperatureResultEvent(double value, double animal) {
+ this.value = value;
+ this.animal = animal;
+ }
+}
--- /dev/null
+package com.ic.work.hardware;
+
+import android.content.Context;
+import android.hardware.Sensor;
+import android.hardware.SensorEvent;
+import android.hardware.SensorEventListener;
+import android.hardware.SensorManager;
+
+import com.ic.work.event.AkBloodCheckResultEvent;
+import com.ic.work.event.BloodCheckTipsEvent;
+import com.ic.work.event.BloodSensorEvent;
+import com.ic.work.utils.HardwareUtils;
+import com.ic.work.utils.IcLog;
+
+import org.greenrobot.eventbus.EventBus;
+
+import java.util.Random;
+
+import static android.content.Context.SENSOR_SERVICE;
+import static com.ic.aidl.blood.BloodState.BLOOD_ING_CHECK;
+import static com.ic.aidl.blood.BloodState.BLOOD_NOT_DATA_CHECK;
+import static com.ic.aidl.blood.BloodState.BLOOD_NOT_DEVICE;
+import static com.ic.aidl.blood.BloodState.BLOOD_NOT_WEAR;
+import static com.ic.aidl.blood.BloodState.BLOOD_NULL_TIPS;
+import static com.ic.aidl.blood.BloodState.BLOOD_PLEASE_QUIET;
+import static com.ic.aidl.blood.BloodState.BLOOD_START_CHECK;
+import static com.ic.aidl.blood.BloodState.BLOOD_STOP_CHECK;
+
+public class A9BloodRunnable implements Runnable {
+
+ private static final String TAG = "BloodRunnable";
+
+ @Override
+ public void run() {
+
+
+ boolean[] deviceState = HardwareUtils.isPPGavailableIc66();
+
+ if (!deviceState[0]) {
+ sendTipsEventBus(BLOOD_NULL_TIPS, BLOOD_NOT_DEVICE);
+ return;
+ }
+
+ if (deviceState[1]) {
+ sendTipsEventBus(BLOOD_PLEASE_QUIET, BLOOD_START_CHECK);
+ EventBus.getDefault().post(new BloodSensorEvent(1));
+ } else {
+ checkBloodOther();
+ }
+ }
+
+ private void sendTipsEventBus(int top, int bottom) {
+ EventBus.getDefault().post(new BloodCheckTipsEvent(top, bottom));
+ }
+
+
+ private void checkBloodOther() {
+ int ndkHeart = 0;
+ int ndkHigh = 0;
+ int ndkLow = 0;
+ int oxygen = 0;
+
+ boolean isWeared = false;
+
+ int checkCount = 0;
+ boolean isSendCheckTips = false;
+
+ //开启
+ HardwareUtils.onNdkEnablePPG();
+
+ sendTipsEventBus(BLOOD_PLEASE_QUIET, BLOOD_START_CHECK);
+
+ try {
+ while (!Thread.currentThread().isInterrupted()) {
+
+ if (checkCount >= 25) {
+ break;
+ }
+
+ ndkHeart = HardwareUtils.getNdkPPGValue();
+ isWeared = HardwareUtils.isWeared();
+
+ IcLog.i(TAG, "Get Heart Value:" + isWeared + ",ndkHeart:" + ndkHeart);
+
+ if (!isWeared) {
+ break;
+ }
+
+ if (ndkHeart > 0) {
+ ndkHigh = HardwareUtils.getNdkHighBloodValue();
+ ndkLow = HardwareUtils.getNdkLowBloodValue();
+ oxygen = HardwareUtils.getNdkOxygenValue();
+ break;
+ }
+
+ if (!isSendCheckTips) {
+ //正在测量中,请稍等
+ sendTipsEventBus(BLOOD_PLEASE_QUIET, BLOOD_ING_CHECK);
+ isSendCheckTips = true;
+ }
+
+ checkCount++;
+
+ Thread.sleep(1000);
+ }
+
+ if (!isWeared) {
+ sendTipsEventBus(BLOOD_NULL_TIPS, BLOOD_NOT_WEAR);
+ } else if (ndkHeart == 0) {
+ sendTipsEventBus(BLOOD_STOP_CHECK, BLOOD_NOT_DATA_CHECK);
+ } else {
+ EventBus.getDefault().post(new AkBloodCheckResultEvent(ndkHigh, ndkLow, ndkHeart, oxygen));
+ }
+
+ HardwareUtils.onNdkDisablePPG();
+
+ } catch (InterruptedException e) {
+ IcLog.e(TAG, "Stop Get Heart Value", e);
+ } catch (Exception ee) {
+ } finally {
+ HardwareUtils.onNdkDisablePPG();
+ }
+ }
+}
--- /dev/null
+package com.ic.work.hardware;
+
+import com.ic.work.event.AkBloodCheckResultEvent;
+import com.ic.work.event.BloodCheckResultEvent;
+import com.ic.work.event.BloodCheckTempEvent;
+import com.ic.work.event.BloodCheckTipsEvent;
+import com.ic.work.utils.HardwareUtils;
+import com.ic.work.utils.IcLog;
+
+import org.greenrobot.eventbus.EventBus;
+
+import java.util.Random;
+
+import static com.ic.aidl.blood.BloodState.BLOOD_ING_CHECK;
+import static com.ic.aidl.blood.BloodState.BLOOD_NOT_DATA_CHECK;
+import static com.ic.aidl.blood.BloodState.BLOOD_NOT_DEVICE;
+import static com.ic.aidl.blood.BloodState.BLOOD_NOT_WEAR;
+import static com.ic.aidl.blood.BloodState.BLOOD_NULL_TIPS;
+import static com.ic.aidl.blood.BloodState.BLOOD_PLEASE_QUIET;
+import static com.ic.aidl.blood.BloodState.BLOOD_START_CHECK;
+import static com.ic.aidl.blood.BloodState.BLOOD_STOP_CHECK;
+
+public class AkBloodRunnable implements Runnable {
+
+ private static final String TAG = "BloodRunnable";
+
+ @Override
+ public void run() {
+ int ndkHeart = 0;
+ int ndkHigh = 0;
+ int ndkLow = 0;
+ int count = 0;
+ boolean isSendCheckTips = false;
+
+ if (HardwareUtils.isPPGavailable()) {
+ sendTipsEventBus(BLOOD_NULL_TIPS, BLOOD_NOT_DEVICE);
+ return;
+ }
+
+ //开启
+ HardwareUtils.onNdkEnablePPG();
+
+ sendTipsEventBus(BLOOD_PLEASE_QUIET, BLOOD_ING_CHECK);
+
+ try {
+ while (!Thread.currentThread().isInterrupted()) {
+ ndkHeart = HardwareUtils.getNdkPPGValue();
+ if (HardwareUtils.isWeared()) {
+ //未佩戴
+ if (count > 15) break;
+ count++;
+ } else {
+ if (ndkHeart > 0) {
+ //佩戴好,并且已经或到心率的值,则获取低压和高压的值
+ ndkHigh = HardwareUtils.getNdkHighBloodValue();
+ ndkLow = HardwareUtils.getNdkLowBloodValue();
+ //跳出循环,不在获取
+ break;
+ } else {
+ if (!isSendCheckTips) {
+ //正在测量中,请稍等
+ //sendTipsEventBus(BLOOD_PLEASE_QUIET, BLOOD_ING_CHECK);
+ isSendCheckTips = true;
+ }
+ }
+ }
+ Thread.sleep(1000);
+ }
+
+ if(count >=10){
+ sendTipsEventBus(BLOOD_NULL_TIPS, BLOOD_NOT_WEAR);
+ } else if (ndkHeart == 0) {
+ sendTipsEventBus(BLOOD_STOP_CHECK, BLOOD_NOT_DATA_CHECK);
+ } else {
+ EventBus.getDefault().post(new AkBloodCheckResultEvent(ndkHigh, ndkLow, ndkHeart, randomOxygenValue()));
+ }
+
+ HardwareUtils.onNdkDisablePPG();
+
+ } catch (InterruptedException e) {
+ IcLog.e(TAG, "Stop Get Heart Value", e);
+ } catch (Exception ee) {
+ } finally {
+ HardwareUtils.onNdkDisablePPG();
+ }
+ }
+
+ public int randomOxygenValue() throws Exception {
+ int min = 94;
+ int max = 100;
+ return min + ((int) (new Random().nextFloat() * (max - min)));
+ }
+
+
+ private void sendTipsEventBus(int top, int bottom) {
+ EventBus.getDefault().post(new BloodCheckTipsEvent(top, bottom));
+ }
+}
package com.ic.work.hardware;
import com.ic.work.event.BloodCheckResultEvent;
+import com.ic.work.event.BloodCheckTempEvent;
import com.ic.work.event.BloodCheckTipsEvent;
import com.ic.work.utils.HardwareUtils;
import com.ic.work.utils.IcLog;
import org.greenrobot.eventbus.EventBus;
+import java.util.Random;
+
import static com.ic.aidl.blood.BloodState.BLOOD_ING_CHECK;
import static com.ic.aidl.blood.BloodState.BLOOD_NOT_DATA_CHECK;
import static com.ic.aidl.blood.BloodState.BLOOD_NOT_DEVICE;
import static com.ic.aidl.blood.BloodState.BLOOD_START_CHECK;
import static com.ic.aidl.blood.BloodState.BLOOD_STOP_CHECK;
-public class BloodRunnable implements Runnable{
+public class BloodRunnable implements Runnable {
- private static final String TAG="BloodRunnable";
+ private static final String TAG = "BloodRunnable";
@Override
public void run() {
int ndkHigh = 0;
int ndkLow = 0;
int count = 0;
+ int checkCount = 0;
if (HardwareUtils.isPPGavailable()) {
- sendTipsEventBus(BLOOD_NULL_TIPS,BLOOD_NOT_DEVICE);
+ sendTipsEventBus(BLOOD_NULL_TIPS, BLOOD_NOT_DEVICE);
return;
}
//开启
HardwareUtils.onNdkEnablePPG();
- sendTipsEventBus(BLOOD_PLEASE_QUIET,BLOOD_START_CHECK);
+ sendTipsEventBus(BLOOD_PLEASE_QUIET, BLOOD_START_CHECK);
try {
while (!Thread.currentThread().isInterrupted()) {
ndkHeart = HardwareUtils.getNdkPPGValue();
+ IcLog.i("BOLLTTTT","ndkHeart:"+ndkHeart);
if (HardwareUtils.isWeared()) {
//未佩戴
- sendTipsEventBus(BLOOD_NULL_TIPS,BLOOD_NOT_WEAR);
+ sendTipsEventBus(BLOOD_NULL_TIPS, BLOOD_NOT_WEAR);
if (count > 15) break;
count++;
} else {
ndkHigh = HardwareUtils.getNdkHighBloodValue();
ndkLow = HardwareUtils.getNdkLowBloodValue();
//跳出循环,不在获取
- break;
+ if (checkCount > 8) {
+ break;
+ }
+ EventBus.getDefault().post(new BloodCheckTempEvent(ndkHigh, ndkLow, ndkHeart));
+ checkCount++;
} else {
//正在测量中,请稍等
- sendTipsEventBus(BLOOD_PLEASE_QUIET,BLOOD_ING_CHECK);
+ sendTipsEventBus(BLOOD_PLEASE_QUIET, BLOOD_ING_CHECK);
}
}
Thread.sleep(1000);
}
+ IcLog.i("BOLLTTTT","ndkHearteeeeeeeee:"+ndkHeart);
+
if (count > 15 || ndkHeart == 0) {
sendTipsEventBus(BLOOD_STOP_CHECK, BLOOD_NOT_DATA_CHECK);
} else {
- EventBus.getDefault().post(new BloodCheckResultEvent(ndkHigh,ndkLow,ndkHeart));
+ EventBus.getDefault().post(new BloodCheckResultEvent(ndkHigh, ndkLow, ndkHeart));
}
HardwareUtils.onNdkDisablePPG();
} catch (InterruptedException e) {
- IcLog.e(TAG, "Stop Get Heart Value",e);
+ IcLog.e(TAG, "Stop Get Heart Value", e);
+ } catch (Exception ee){
+ IcLog.i("BOLLTTTT", "Exception:"+ee.getMessage());
}finally {
+ IcLog.i("BOLLTTTT", "Stop Get Heart Value");
HardwareUtils.onNdkDisablePPG();
}
}
- private void sendTipsEventBus(int top,int bottom){
+
+ private void sendTipsEventBus(int top, int bottom) {
EventBus.getDefault().post(new BloodCheckTipsEvent(top, bottom));
}
}
--- /dev/null
+package com.ic.work.hardware;
+
+import android.content.Context;
+import android.hardware.Sensor;
+import android.hardware.SensorEvent;
+import android.hardware.SensorEventListener;
+import android.hardware.SensorManager;
+
+import com.ic.work.event.AkBloodCheckResultEvent;
+import com.ic.work.event.BloodCheckTipsEvent;
+import com.ic.work.event.BloodSensorEvent;
+import com.ic.work.utils.IcLog;
+
+import org.greenrobot.eventbus.EventBus;
+
+import static android.content.Context.SENSOR_SERVICE;
+import static com.ic.aidl.blood.BloodState.BLOOD_ING_CHECK;
+import static com.ic.aidl.blood.BloodState.BLOOD_NOT_WEAR;
+import static com.ic.aidl.blood.BloodState.BLOOD_NULL_TIPS;
+import static com.ic.aidl.blood.BloodState.BLOOD_PLEASE_QUIET;
+
+public class BloodSensorManager {
+
+ private static final String TAG ="BloodSensorManager";
+
+ private SensorManager sensorManager;
+
+ public void createSensorManager(Context context){
+ if(sensorManager == null){
+ sensorManager = (SensorManager) context.getSystemService(SENSOR_SERVICE);
+ }
+ Sensor mHeartRate = sensorManager.getDefaultSensor(Sensor.TYPE_HEART_RATE);
+ sensorManager.registerListener(sensorEventListener, mHeartRate, SensorManager.SENSOR_DELAY_UI);
+
+ EventBus.getDefault().post(new BloodCheckTipsEvent(BLOOD_PLEASE_QUIET, BLOOD_ING_CHECK));
+ }
+
+ public void unregisterSensorListener(){
+ sensorManager.unregisterListener(sensorEventListener);
+ }
+
+ private final SensorEventListener sensorEventListener = new SensorEventListener() {
+
+ @Override
+ public void onSensorChanged(SensorEvent sensorEvent) {
+ float values[] = sensorEvent.values;
+ /*[0]---心率;[1]---血压高压;[2]---血压低压;[3]---血氧;[4]---佩戴检测(1--脱手,2--上手);*/
+ IcLog.i(TAG, "Weared= " + values[4] + " ,BPH= " + values[1] + " ,BPL= " + values[2] + " ,PPG= " + values[0] + ", spo2= " + values[3]);
+
+ if (values[4] == 2 && values[0] > 0) {
+ //结果检测出来后停止检测
+ EventBus.getDefault().post(new AkBloodCheckResultEvent(
+ (int) values[1],
+ (int) values[2],
+ (int) values[0],
+ (int) values[3]));
+
+ EventBus.getDefault().post(new BloodSensorEvent(2));
+ }else if(values[4] == 1){
+ sendTipsEventBus(BLOOD_NULL_TIPS, BLOOD_NOT_WEAR);
+ EventBus.getDefault().post(new BloodSensorEvent(2));
+ }
+ }
+
+ @Override
+ public void onAccuracyChanged(Sensor sensor, int i) {
+ }
+ };
+
+ private void sendTipsEventBus(int top, int bottom) {
+ EventBus.getDefault().post(new BloodCheckTipsEvent(top, bottom));
+ }
+}
private final static String key_ppg = "ppg";
private final static String key_bph = "bph";
private final static String key_bpl = "bpl";
+ public static final String key_spo2="sp02";
private Messenger mGetReplyMessenger;
private Messenger mService = null;
}
};
- public void sendBloodValueMessage(int high, int low, int heart) {
+ public void sendBloodValueMessage(int high, int low, int heart,int oxygen) {
Bundle data = new Bundle();
data.putString(key_ppg, String.valueOf(heart));
data.putString(key_bph, String.valueOf(high));
data.putString(key_bpl, String.valueOf(low));
+ data.putString(key_spo2, String.valueOf(oxygen));
Message msg = Message.obtain(null, MSG_WHAT_PPG);
msg.setData(data);
--- /dev/null
+package com.ic.work.hardware;
+
+import com.ic.work.event.TemperatureResultCompleteEvent;
+import com.ic.work.event.TemperatureResultEvent;
+import com.ic.work.utils.HardwareUtils;
+import com.ic.work.utils.IcLog;
+
+import org.greenrobot.eventbus.EventBus;
+
+import java.math.BigDecimal;
+
+public class TemperatureRunnable implements Runnable {
+ private static final String TAG = "TemperatureRunnable";
+ private final static double room_temperature = 26.0;
+
+ @Override
+ public void run() {
+ double testValue = 0.0;
+ double animal = 0.0;
+
+ boolean[] state = HardwareUtils.isTemperatureDevAvailable();
+ IcLog.i(TAG, "TemperatureRunnable :"+state[0]+"state[1]:"+state[1]);
+ if(state[0]){
+ if(state[1]){
+ try {
+ //if(HardwareUtils.isTemperatureDevOpened()){
+ if(HardwareUtils.enableTemperature()){
+ Thread.sleep(1000);
+ }
+ //}
+ while (true){
+ testValue = HardwareUtils.getNdkTemperatureValue();
+ animal = HardwareUtils.getBodyTempFromWristTemp(testValue, room_temperature);
+ IcLog.i(TAG, "getNdkTemperatureValue Value:" + testValue);
+ EventBus.getDefault().post(new TemperatureResultEvent(testValue, animal));
+ try {
+ Thread.sleep(1000);
+ }catch (InterruptedException e){
+ break;
+ }
+ }
+ HardwareUtils.disableTemperature();
+ }catch (InterruptedException e) {
+ IcLog.e(TAG, "TemperatureRunnable :", e);
+ }finally {
+ HardwareUtils.disableTemperature();
+ }
+ }
+ }else{
+ while (true) {
+ try {
+ testValue = HardwareUtils.getNdkTemperatureValue();
+ animal = HardwareUtils.getBodyTempFromWristTemp(testValue, room_temperature);
+ EventBus.getDefault().post(new TemperatureResultEvent(testValue, animal));
+ Thread.sleep(2000);
+ }catch (InterruptedException e){
+ break;
+ }
+ }
+ }
+
+ //EventBus.getDefault().post(new TemperatureResultCompleteEvent(testValue, animal));
+ }
+
+ public static double div(double value1, int value2, int scale) {
+ //如果精确范围小于0,抛出异常信息
+ if (scale < 0) {
+ return room_temperature;
+ }
+ BigDecimal b1 = BigDecimal.valueOf(value1);
+ BigDecimal b2 = BigDecimal.valueOf(value2);
+ return b1.divide(b2, scale).doubleValue();
+ }
+}
--- /dev/null
+package com.ic.work.process;
+
+import android.os.IBinder;
+import android.os.RemoteCallbackList;
+import android.os.RemoteException;
+
+import com.ic.aidl.ak.IAkAidlInterface;
+import com.ic.aidl.ak.IAkRemoteService;
+import com.ic.work.BuildConfig;
+import com.ic.work.event.ThreadPoolEvent;
+import com.ic.work.utils.IcLog;
+
+import org.greenrobot.eventbus.EventBus;
+
+
+public class AkProcess {
+ private static final String TAG = "BloodProcess";
+
+ private RemoteCallbackList<IAkAidlInterface> mCallbacks = new RemoteCallbackList<>();
+
+ public IBinder getAkBinder() {
+ return akBinder;
+ }
+
+ private IAkRemoteService.Stub akBinder = new IAkRemoteService.Stub() {
+ @Override
+ public void registerCallback(IAkAidlInterface cb) throws RemoteException {
+ if (cb != null) {
+ mCallbacks.register(cb);
+ }
+ }
+
+ @Override
+ public void unregisterCallback(IAkAidlInterface cb) throws RemoteException {
+ if (cb != null) {
+ mCallbacks.unregister(cb);
+ }
+ }
+
+ @Override
+ public void startCheckBlood() throws RemoteException {
+ int type = BuildConfig.productType;
+ switch (type){
+ case 1001:
+ //ak
+ EventBus.getDefault().post(new ThreadPoolEvent(8));
+ break;
+ case 1002:
+ //a9
+ EventBus.getDefault().post(new ThreadPoolEvent(7));
+ break;
+ }
+ }
+
+ @Override
+ public void stopCheckBlood() throws RemoteException {
+ EventBus.getDefault().post(new ThreadPoolEvent(4));
+ }
+
+ @Override
+ public void queryPedCount() throws RemoteException {
+ EventBus.getDefault().post(new ThreadPoolEvent(1));
+ }
+
+ @Override
+ public void onStartQueryTemp() throws RemoteException {
+ EventBus.getDefault().post(new ThreadPoolEvent(6));
+ }
+
+ @Override
+ public void onStopQueryTemp() throws RemoteException {
+ EventBus.getDefault().post(new ThreadPoolEvent(4));
+ }
+ };
+
+ public void sendBloodCheckResult(int heih, int low, int heart,int oxygen) {
+ int N = 0;
+ try {
+ N = mCallbacks.beginBroadcast();
+ for (int i = 0; i < N; i++) {
+ mCallbacks.getBroadcastItem(i).updateBloodCheckResult(heih, low, heart,oxygen);
+ }
+ } catch (NullPointerException e) {
+ IcLog.e(TAG, "",e);
+ } catch (RemoteException er) {
+ IcLog.e(TAG, "",er);
+ } finally {
+ try {
+ if (N > 0) {
+ mCallbacks.finishBroadcast();
+ }
+ } catch (IllegalArgumentException ll) {
+ IcLog.e(TAG, "",ll);
+ }
+ }
+ }
+
+ public void sendBloodCheckTips(int top, int bottom) {
+ int N = 0;
+ try {
+ N = mCallbacks.beginBroadcast();
+ for (int i = 0; i < N; i++) {
+ mCallbacks.getBroadcastItem(i).updateBloodCheckTips(top, bottom);
+ }
+ } catch (NullPointerException e) {
+ IcLog.e(TAG, "",e);
+ } catch (RemoteException er) {
+ IcLog.e(TAG, "",er);
+ } finally {
+ try {
+ if (N > 0) {
+ mCallbacks.finishBroadcast();
+ }
+ } catch (IllegalArgumentException ll) {
+ IcLog.e(TAG, "",ll);
+ }
+ }
+ }
+
+ public void sendPedCount(int count) {
+ int N = 0;
+ try {
+ N = mCallbacks.beginBroadcast();
+ for (int i = 0; i < N; i++) {
+ mCallbacks.getBroadcastItem(i).updatePedCount(count);
+ }
+ } catch (NullPointerException e) {
+ IcLog.e(TAG, "",e);
+ } catch (RemoteException er) {
+ IcLog.e(TAG, "",er);
+ } finally {
+ try {
+ if (N > 0) {
+ mCallbacks.finishBroadcast();
+ }
+ } catch (IllegalArgumentException ll) {
+ IcLog.e(TAG, "",ll);
+ }
+ }
+ }
+
+ public void sendCurrTempValue(double value,double animal) {
+ int N = 0;
+ try {
+ N = mCallbacks.beginBroadcast();
+ for (int i = 0; i < N; i++) {
+ mCallbacks.getBroadcastItem(i).updateCurrTempValue(value,animal);
+ }
+ } catch (NullPointerException e) {
+ IcLog.e(TAG, "",e);
+ } catch (RemoteException er) {
+ IcLog.e(TAG, "",er);
+ } finally {
+ try {
+ if (N > 0) {
+ mCallbacks.finishBroadcast();
+ }
+ } catch (IllegalArgumentException ll) {
+ IcLog.e(TAG, "",ll);
+ }
+ }
+ }
+
+ public void sendResultTempValue(double value,double animal) {
+ int N = 0;
+ try {
+ N = mCallbacks.beginBroadcast();
+ for (int i = 0; i < N; i++) {
+ mCallbacks.getBroadcastItem(i).updateResultTempValue(value,animal);
+ }
+ } catch (NullPointerException e) {
+ IcLog.e(TAG, "",e);
+ } catch (RemoteException er) {
+ IcLog.e(TAG, "",er);
+ } finally {
+ try {
+ if (N > 0) {
+ mCallbacks.finishBroadcast();
+ }
+ } catch (IllegalArgumentException ll) {
+ IcLog.e(TAG, "",ll);
+ }
+ }
+ }
+
+}
}
}
+ public void sendBloodCheckTemp(int heih, int low, int heart) {
+ int N = 0;
+ try {
+ N = mCallbacks.beginBroadcast();
+ for (int i = 0; i < N; i++) {
+ mCallbacks.getBroadcastItem(i).updateBloodCheckTemp(heih, low, heart);
+ }
+ } catch (NullPointerException e) {
+ IcLog.e(TAG, "",e);
+ } catch (RemoteException er) {
+ IcLog.e(TAG, "",er);
+ } finally {
+ try {
+ if (N > 0) {
+ mCallbacks.finishBroadcast();
+ }
+ } catch (IllegalArgumentException ll) {
+ IcLog.e(TAG, "",ll);
+ }
+ }
+ }
+
public void sendBloodCheckTips(int top, int bottom) {
int N = 0;
try {
--- /dev/null
+package com.ic.work.process;
+
+import android.os.IBinder;
+import android.os.RemoteCallbackList;
+import android.os.RemoteException;
+
+import com.ic.aidl.temp.ITempAidlInterface;
+import com.ic.aidl.temp.ITempRemoteService;
+import com.ic.aidl.weather.IWeatherAidlInterface;
+import com.ic.aidl.weather.IWeatherRemoteService;
+import com.ic.aidl.weather.WeatherParcelable;
+import com.ic.work.event.ThreadPoolEvent;
+import com.ic.work.utils.IcLog;
+
+import org.greenrobot.eventbus.EventBus;
+
+import java.util.List;
+
+public class TempProcess {
+
+ private static final String TAG = "WeatherProcess";
+
+ private RemoteCallbackList<ITempAidlInterface> mCallbacks = new RemoteCallbackList<>();
+
+ public IBinder getTempBinder(){
+ return tempBinder;
+ }
+
+ private ITempRemoteService.Stub tempBinder = new ITempRemoteService.Stub() {
+ @Override
+ public void registerCallback(ITempAidlInterface cb) throws RemoteException {
+ if (cb != null) {
+ mCallbacks.register(cb);
+ }
+ }
+
+ @Override
+ public void unregisterCallback(ITempAidlInterface cb) throws RemoteException {
+ if (cb != null) {
+ mCallbacks.unregister(cb);
+ }
+ }
+
+ @Override
+ public void onStartQueryTemp() throws RemoteException {
+ EventBus.getDefault().post(new ThreadPoolEvent(6));
+ }
+
+ @Override
+ public void onStopQueryTemp() throws RemoteException {
+ IcLog.i(TAG,"onStopQueryTemp");
+ EventBus.getDefault().post(new ThreadPoolEvent(4));
+ }
+ };
+
+ public void sendCurrTempValue(double value,double animal) {
+ int N = 0;
+ try {
+ N = mCallbacks.beginBroadcast();
+ for (int i = 0; i < N; i++) {
+ mCallbacks.getBroadcastItem(i).updateCurrTempValue(value,animal);
+ }
+ } catch (NullPointerException e) {
+ IcLog.e(TAG, "",e);
+ } catch (RemoteException er) {
+ IcLog.e(TAG, "",er);
+ } finally {
+ try {
+ if (N > 0) {
+ mCallbacks.finishBroadcast();
+ }
+ } catch (IllegalArgumentException ll) {
+ IcLog.e(TAG, "",ll);
+ }
+ }
+ }
+
+ public void sendResultTempValue(double value,double animal) {
+ int N = 0;
+ try {
+ N = mCallbacks.beginBroadcast();
+ for (int i = 0; i < N; i++) {
+ mCallbacks.getBroadcastItem(i).updateResultTempValue(value,animal);
+ }
+ } catch (NullPointerException e) {
+ IcLog.e(TAG, "",e);
+ } catch (RemoteException er) {
+ IcLog.e(TAG, "",er);
+ } finally {
+ try {
+ if (N > 0) {
+ mCallbacks.finishBroadcast();
+ }
+ } catch (IllegalArgumentException ll) {
+ IcLog.e(TAG, "",ll);
+ }
+ }
+ }
+}
package com.ic.work.utils;
import com.ic.jni.ICJniUtils;
+import com.ic.work.BuildConfig;
public class HardwareUtils {
private static final String TAG = "HardwareUtils";
+ public static boolean[] isPPGavailableIc66(){
+ try {
+ int value = ICJniUtils.isPPGavailable();
+ return new boolean[]{
+ value > ICJniUtils.PPG_EGC_SensorType.PPG_EGC_TYPE_NONE.ordinal(),
+ value == ICJniUtils.PPG_EGC_SensorType.PPG_EGC_TYPE_IC66.ordinal()
+ };
+ }catch (Exception e) {
+ IcLog.e(TAG, "",e);
+ return new boolean[]{false,false};
+ }
+ }
+
public static boolean isPPGavailable() {
try {
- return ICJniUtils.isPPGavailable() == 0;
+ int value = ICJniUtils.isPPGavailable();
+ return value == 0;
} catch (Exception e) {
IcLog.e(TAG, "",e);
return true;
public static boolean isWeared() {
try {
- return ICJniUtils.isWeared() == 0;
+ int value = ICJniUtils.isWeared();
+ if(BuildConfig.productType == 1002){
+ return value == 1;
+ }else{
+ return value == 0;
+ }
+
} catch (Exception e) {
IcLog.e(TAG, "",e);
return true;
}
}
+ public static int getNdkOxygenValue() {
+ try {
+ return ICJniUtils.getSPO2();
+ } catch (Exception e) {
+ IcLog.e(TAG,"",e);
+ return 0;
+ }
+ }
+
public static int getNdkStepCountValue() {
try {
return ICJniUtils.getStepCount();
return 0;
}
}
+
+ public static boolean[] isTemperatureDevAvailable() {
+
+ boolean[] temp = new boolean[]{false,false};
+ try {
+ int type = ICJniUtils.isTemperatureDevAvailable();
+ temp[0] = type > ICJniUtils.TempSensorType.TEMPSENSOR_TYPE_NONE.ordinal();
+ if(temp[0]){
+ temp[1] = type == ICJniUtils.TempSensorType.TEMPSENSOR_TYPE_IC68.ordinal();
+ }
+ return temp;
+ } catch (Exception e) {
+ IcLog.e(TAG, "",e);
+ return temp;
+ }
+ }
+
+ public static double getNdkTemperatureValue() {
+ try {
+ return ICJniUtils.getTemperature();
+ } catch (Exception e) {
+ IcLog.e(TAG, "",e);
+ return 0;
+ }
+ }
+
+ public static double getBodyTempFromWristTemp(double wrist_temp,double ref_temp) {
+ try {
+ return ICJniUtils.getBodyTempFromWristTemp(wrist_temp,ref_temp);
+ } catch (Exception e) {
+ IcLog.e(TAG, "",e);
+ return 0;
+ }
+ }
+
+ public static boolean isTemperatureDevOpened() {
+ try {
+ return ICJniUtils.isTemperatureDevOpened() == 0;
+ } catch (Exception e) {
+ IcLog.e(TAG, "",e);
+ return false;
+ }
+ }
+
+ public static boolean enableTemperature() {
+ try {
+ return ICJniUtils.enableTemperature()>= 0;
+ } catch (Exception e) {
+ IcLog.e(TAG, "",e);
+ return false;
+ }
+ }
+
+ public static void disableTemperature() {
+ try {
+ ICJniUtils.disableTemperature();
+ } catch (Exception e) {
+ IcLog.e(TAG, "",e);
+ }
+ }
+
+
+
}
--- /dev/null
+package com.ic.work.utils;
+
+import java.lang.reflect.Method;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class IcSystemProperty {
+
+ public static String getSystemProperties(String prop){
+
+ String str ="";
+ Class clazz = null;
+ try {
+ clazz = Class.forName("android.os.SystemProperties");
+ Method get=clazz.getMethod("get", new Class[] { String.class });
+ str = (String)get.invoke(clazz, new Object[] { prop });
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return str;
+ }
+ public static String getSystemProperties(String prop,String defaultValue){
+
+ String str =defaultValue;
+ Class clazz = null;
+ try {
+ clazz = Class.forName("android.os.SystemProperties");
+ Method get=clazz.getMethod("get", new Class[] { String.class });
+ str = (String)get.invoke(clazz, new Object[] { prop });
+ if ((str==null)||(str!=null&& str.trim().isEmpty())){
+ str=defaultValue;
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return str;
+ }
+ public static int getSystemPropertiesInt(String prop,int defaultValue){
+
+ int ret=defaultValue;
+ String str ="";
+ Class clazz = null;
+ try {
+ clazz = Class.forName("android.os.SystemProperties");
+ Method get=clazz.getMethod("get", new Class[] { String.class });
+ str = (String)get.invoke(clazz, new Object[] { prop });
+ if (str!=null && str.trim().length()>0 && isNumeric(str)){
+ ret=Integer.parseInt(str);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return ret;
+ }
+ public static boolean isNumeric(String str){
+ Pattern pattern = Pattern.compile("[0-9]*");
+ Matcher isNum = pattern.matcher(str);
+ if( !isNum.matches() ){
+ return false;
+ }
+ return true;
+ }
+ static public void setSystemProperties(String key, int defaultValue) {
+
+ String value = String.valueOf(defaultValue);
+
+ try {
+
+ Class<?> c = Class.forName("android.os.SystemProperties");
+
+ Method set = c.getMethod("set", String.class, String.class );
+
+ set.invoke(c, key, value );
+
+ } catch (Exception e) {
+
+ e.printStackTrace();
+
+ }
+ }
+ static public void setSystemProperties(String key, String defaultValue) {
+
+ String value = defaultValue;
+
+ try {
+
+ Class<?> c = Class.forName("android.os.SystemProperties");
+
+ Method set = c.getMethod("set", String.class, String.class );
+
+ set.invoke(c, key, value );
+
+ } catch (Exception e) {
+
+ e.printStackTrace();
+
+ }
+ }
+}
-#Sat Apr 11 17:08:31 CST 2020
-VERSION_CODE=32
+#Thu Jul 16 16:46:05 CST 2020
+VERSION_CODE=54