import android.content.BroadcastReceiver;
import android.content.ComponentName;
+import android.content.ContentResolver;
+import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.ServiceConnection;
+import android.net.Uri;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import com.enqualcomm.support.CoreService;
import com.enqualcomm.support.ICApplication;
import com.enqualcomm.support.LocationClient;
+import com.enqualcomm.support.R;
import com.enqualcomm.support.bean.Runtime;
import com.enqualcomm.support.bean.StringMessage;
import com.enqualcomm.support.bean.heartRateStatus;
+import com.enqualcomm.support.provider.ICDatabaseHelper;
+import com.enqualcomm.support.provider.ICNotificationProvider;
import com.enqualcomm.support.service.base.AbstractInvokeHandlerService;
import com.enqualcomm.support.utils.Connection;
import com.enqualcomm.support.utils.HeartRateOxygenTestType;
int heartRateValue = heartRate.getHeartRate();
int bloodHeightValue = heartRate.getBloodHeight();
int bloodLowValue = heartRate.getBloodLow();
- //TODO:
+ Context context = runtime.getContextProxy().context;
+ if (oxygenValue != 0 && Config.LIMIT_VALUE_OXYGEN != 0 && oxygenValue < Config.LIMIT_VALUE_OXYGEN) {
+ //发出警告
+ createWarningNotification(context.getString(R.string.oxygen_exception_tips_text) + oxygenValue + "%)",
+ NOTIFICATION_TYPE_BLOOD_OXYGEN);
+ }
+ if (heartRateValue != 0 && Config.LIMIT_VALUE_PPGH != 0 && heartRateValue > Config.LIMIT_VALUE_PPGH) {
+ //判断是否超出阀值,上限
+ createWarningNotification(context.getString(R.string.heart_rate_exception_tips_text) + heartRateValue + ")",
+ NOTIFICATION_TYPE_HEART_RATE);
+ }
+
+ if (heartRateValue != 0 && Config.LIMIT_VALUE_PPGH != 0 && heartRateValue < Config.LIMIT_VALUE_PPGL) {
+ //判断是否超出阀值,下限
+ createWarningNotification(context.getString(R.string.heart_rate_exception_tips_text) + heartRateValue + ")",
+ NOTIFICATION_TYPE_HEART_RATE);
+ }
+
+ if (bloodHeightValue != 0 && Config.LIMIT_VALUE_BPH_H != 0 && Config.LIMIT_VALUE_BPH_L != 0) {
+ //如果不在这两个范围内,那么就警报
+ if (bloodHeightValue > Config.LIMIT_VALUE_BPH_H || bloodHeightValue < Config.LIMIT_VALUE_BPH_L) {
+ //警报,血压高值超出范围
+ createWarningNotification(context.getString(R.string.blood_presure_exception_tips_text) + bloodHeightValue + "/100mmHg)",
+ NOTIFICATION_TYPE_BLOOD_PRESSURE);
+ }
+ }
+
+ if (bloodLowValue != 0 && Config.LIMIT_VALUE_BPL_H != 0 && Config.LIMIT_VALUE_BPL_L != 0) {
+ //如果不在这两个范围内,那么就警报
+ if (bloodHeightValue > Config.LIMIT_VALUE_BPL_H || bloodHeightValue < Config.LIMIT_VALUE_BPL_L) {
+ //警报,血压低值超出范围
+ createWarningNotification(context.getString(R.string.blood_presure_exception_tips_text) + bloodHeightValue + "/100mmHg)",
+ NOTIFICATION_TYPE_BLOOD_PRESSURE);
+ }
+ }
+ }
+ public static final String NOTIFICATION_TYPE_HEART_RATE = "heart_rate";
+ public static final String NOTIFICATION_TYPE_BLOOD_PRESSURE = "blood_pressure";
+ public static final String NOTIFICATION_TYPE_BLOOD_OXYGEN = "blood_oxygen";
+
+ private void createWarningNotification(String title, String type) {
+ ContentValues contentValues = new ContentValues();
+ //分类是心率的包名
+ contentValues.put(ICDatabaseHelper.notification_category, "com.ic.blood");
+ contentValues.put(ICDatabaseHelper.notification_title, title);
+ contentValues.put(ICDatabaseHelper.notification_type, type);
+ contentValues.put(ICDatabaseHelper.notification_date, System.currentTimeMillis());
+ contentValues.put(ICDatabaseHelper.notification_order, 0);
+ contentValues.put(ICDatabaseHelper.notification_create_time, System.currentTimeMillis());
+ ContentResolver resolver = runtime.getContextProxy().getResolver();
+ resolver.insert(Uri.parse(ICNotificationProvider.NOTIFICATIONS), contentValues);
}