<action android:name="com.enqualcomm.support.ACTION_CHECK_LOCATION_RESULT" />
<action android:name= "com.ic.action.message_sent" />
<action android:name= "com.ic.action.temp_result" />
-
+ <action android:name= "com.ic.action.set_sit_range" />
<!-- <action android:name="com.eqc.heartrate.action.SILENT_START" /> -->
</intent-filter>
</receiver>
}else if ((custom_branch_name.equals("l004")) ) {\r
noPushTxtNotifyDialog=true;\r
noSMSNotifyDialog=true;\r
- noVoiceNotifyDialog=false;\r
+ noVoiceNotifyDialog=true;\r
needBroadcastAntiAlarm=true;\r
noPPGSensor=false;\r
noTempSensor=false;\r
public static void setSleepScore(Context context,int score){\r
SharPreferenceUtil.setPrefInt(context,Constants.SHAREKEY_SETTING_SLEEP_SCORE,score);\r
}\r
+\r
+ /**\r
+ * 参考数据,平均每分钟步数来判断,大于 KeepSitJudgementRefValue 认为没有坐着。小于等于这个值认为坐着。\r
+ */\r
+ public static int KeepSitJudgementRefValue=30;\r
}\r
\r
public static String KEY_SIT_RANGE = "sit_range";\r
\r
\r
+ /***\r
+ * 内部定时器用action alarm\r
+ */\r
+ public static String ACTION_SIT_ALARM = "com.ic.action.sit_alarm_local";\r
+\r
+ /**\r
+ * 发送给app做显示用\r
+ */\r
+ public static String ACTION_KEEPSIT_ALARM = "com.ic.action.keep_sit_alarm";\r
+\r
+\r
}\r
\r
CoreService.getInstance().connection.DeliverCMDMessageToSystem(cmd,"");\r
}\r
\r
+ public void checkKeepSitting(){\r
+ String dateyyyyMMDDhhmmss=TimeUtil.getSystemTime4();\r
+ String sleepdate=TimeUtil.getCurrentSleepRecordDate(dateyyyyMMDDhhmmss);\r
+ if(TimeUtil.isInSleepRange == false) { //不在睡眠时间就是久坐时间段。\r
+ if (Runtime.lastSitCheckStepCount == -1){\r
+ Runtime.lastSitCheckStepCount=runtime.getTotalStepCount();\r
+ Runtime.lastSitCheckTiimeyyyyMMddHHmmss=TimeUtil.getSystemTime3();\r
+ }\r
+ int minutes=(int)TimeUtil.diffBetween2DateInMinutes(Runtime.lastSitCheckTiimeyyyyMMddHHmmss,dateyyyyMMDDhhmmss);\r
+ if (minutes > Config.getKeepSitRangeInMinutes(this)){\r
+ if ( (runtime.getTotalStepCount() - Runtime.lastSitCheckStepCount)/minutes < Config.KeepSitJudgementRefValue){\r
+ //平均 每分钟活动数 小于参考久坐计步值,表示久坐\r
+ runtime.getContextProxy().sendBroadcastSitLongAlarm(); //广播久坐消息\r
+ }else{\r
+ //只要 平均每分钟活动数大于参考值,则重置 lastCheckSitTime 以及 lastSitCheckStepCount\r
+ Runtime.lastSitCheckStepCount=runtime.getTotalStepCount();\r
+ Runtime.lastSitCheckTiimeyyyyMMddHHmmss=TimeUtil.getSystemTime3();\r
+\r
+ }\r
+ }\r
+ }else{\r
+ Runtime.lastSitCheckStepCount=-1; //不在时间段就重置数据,以便下一次使用能过重新开始计数。\r
+ }\r
+\r
+\r
+ }\r
\r
public void updateSleepDate(){\r
String dateyyyyMMDDhhmmss=TimeUtil.getSystemTime4();\r
runtime.getDbHelper().insertSleepRecord(new SleepRecord(dateyyyyMMDDhhmmss,sleepdate,runtime.getTotalStepCount()));\r
runtime.sleepDataReported=false; //只要记录过数据 就证明有数据没有report\r
}else{\r
- if (runtime.sleepDataReported == false){\r
+ if (runtime.sleepDataReported == false) {\r
//calculate sleep data and report it randomly within 1 hour\r
- SleepInfo si=SleepInfo.getInstance();\r
- si.setDate(sleepdate);\r
- si.calculate_sleepInfo(runtime);\r
- runtime.getDbHelper().updateSleepInfo(si);\r
- runtime.sleepDataReported=true;\r
- Config.setSleepDate(this,sleepdate);\r
- Config.setSleepScore(this,si.getScore());\r
- Random r = new Random();\r
- int randomint = r.nextInt(30 - 1) + 1;\r
- ICLogger.i("Delayed " +randomint +" minutes , send sleep info " + si.getCurrentDate()\r
- +" deep "+ si.getDeepsleep_minutes()\r
- +" light "+ si.getLightsleep_minutes()\r
- +" score "+ si.getScore()\r
- );\r
- Observable.timer(randomint * 60 * 1000L, TimeUnit.MILLISECONDS).subscribe(new Action1<Long>() {\r
- public void call(Long param1Long) {\r
+ runtime.sleepDataReported = true;\r
+ int score = runtime.getDbHelper().querySleepScore(sleepdate);\r
+ if (score > 0) {\r
+ ICLogger.i("已经有"+sleepdate+"的睡眠数据!");\r
+ } else {\r
+ SleepInfo si = SleepInfo.getInstance();\r
+ si.setDate(sleepdate);\r
+ si.calculate_sleepInfo(runtime);\r
+\r
+ runtime.getDbHelper().updateSleepInfo(si);\r
+\r
+ Config.setSleepDate(this, sleepdate);\r
+ Config.setSleepScore(this, si.getScore());\r
+ Random r = new Random();\r
+ int randomint = r.nextInt(30 - 1) + 1;\r
+ ICLogger.i("Delayed " + randomint + " minutes , send sleep info " + si.getCurrentDate()\r
+ + " deep " + si.getDeepsleep_minutes()\r
+ + " light " + si.getLightsleep_minutes()\r
+ + " score " + si.getScore()\r
+ );\r
+ Observable.timer(randomint * 60 * 1000L, TimeUnit.MILLISECONDS).subscribe(new Action1<Long>() {\r
+ public void call(Long param1Long) {\r
// connection.send(protocolAPIHelper);\r
- ICLogger.i("Send sleep info " + si.getCurrentDate()\r
- +" deep "+ si.getDeepsleep_minutes()\r
- +" light "+ si.getLightsleep_minutes()\r
- +" score "+ si.getScore()\r
- );\r
- Deliver.sendLocationMSG(protocolAPIHelper.getSleepMSG(SleepInfo.getInstance()));\r
- }\r
- });\r
+ ICLogger.i("Send sleep info " + si.getCurrentDate()\r
+ + " deep " + si.getDeepsleep_minutes()\r
+ + " light " + si.getLightsleep_minutes()\r
+ + " score " + si.getScore()\r
+ );\r
+ Deliver.sendLocationMSG(protocolAPIHelper.getSleepMSG(SleepInfo.getInstance()));\r
+ }\r
+ });\r
\r
+ }\r
}\r
}\r
}\r
} else if (HEART_ALARM.equals(paramIntent.getAction())) {\r
\r
locationClient.updateStepCount();\r
- updateSleepDate();\r
+ updateSleepDate(); //检查睡眠\r
+ checkKeepSitting();//检查久坐\r
if (this.mKeepAlive != null) {\r
if (connection.isServerConnected() && runtime.isServerProtocolConnected()) {\r
this.mKeepAlive.onHeartAlarm(this.connection, this.runtime);\r
public boolean sleepDataReported=false;\r
\r
\r
+ public static String lastSitCheckTiimeyyyyMMddHHmmss="";\r
+ public static long lastSitCheckStepCount=0;\r
+\r
+\r
}\r
\r
\r
\r
import com.enqualcomm.support.Config;\r
+import com.enqualcomm.support.Constants;\r
import com.enqualcomm.support.ICContentProvider;\r
import com.enqualcomm.support.bean.Alarm;\r
import com.enqualcomm.support.bean.NoticeContent;\r
import static android.app.PendingIntent.FLAG_UPDATE_CURRENT;\r
import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;\r
import static com.enqualcomm.support.Constants.ACTION_ISCONNECTED;\r
+import static com.enqualcomm.support.Constants.ACTION_KEEPSIT_ALARM;\r
+import static com.enqualcomm.support.Constants.ACTION_SIT_ALARM;\r
import static com.enqualcomm.support.Constants.DIALOG_ACTION;\r
\r
public class ContextProxy {\r
intent.putExtra("stheartRateType", paramInt);\r
this.context.sendBroadcast(intent, "com.eqc.broadcast.permission");\r
}\r
+ public void sendBroadcastSitLongAlarm() {\r
+ Intent intent = new Intent();\r
+ intent.setAction(ACTION_KEEPSIT_ALARM);\r
+ this.context.sendBroadcast(intent);\r
+ }\r
\r
}\r
\r
import android.view.WindowManager;\r
\r
\r
+import com.enqualcomm.support.Config;\r
+import com.enqualcomm.support.Constants;\r
import com.enqualcomm.support.CoreService;\r
import com.enqualcomm.support.LocationClient;\r
import com.enqualcomm.support.R;\r
import static com.enqualcomm.support.Constants.ACTION_REMOTE_CAMERA;\r
import static com.enqualcomm.support.Constants.ACTION_SEND_EMEGENCY_LOCATION_START;\r
import static com.enqualcomm.support.Constants.ACTION_SEND_SOS_MSG;\r
+import static com.enqualcomm.support.Constants.ACTION_SET_SIT_RANGE;\r
import static com.enqualcomm.support.Constants.ACTION_SHUTDOWN;\r
import static com.enqualcomm.support.Constants.ACTION_TEMP_RESULT;\r
import static com.enqualcomm.support.Constants.DIALOG_ACTION;\r
this.screenOn(paramContext);\r
}\r
}else if (paramIntent.hasExtra("pushtxt")) {\r
- String sms = paramIntent.getStringExtra("pushtxt");\r
- SharPreferenceUtil.getPrefBoolean(paramContext, "key_is_resume", false);\r
- isSilence = SharPreferenceUtil.getPrefBoolean(paramContext, "KEY_ISSILENCE", false);\r
- if (sms != null && !isSilence) {\r
- if (!DeviceInfoUtil.isTopActivity(paramContext)) {\r
- this.initMyDialog(paramContext, null, 4,sms);\r
- this.playNotificationVoice(paramContext);\r
- VibrateUtil.getInstance(paramContext).VibrateOn(true);\r
+ String sms = paramIntent.getStringExtra("pushtxt");\r
+ SharPreferenceUtil.getPrefBoolean(paramContext, "key_is_resume", false);\r
+ isSilence = SharPreferenceUtil.getPrefBoolean(paramContext, "KEY_ISSILENCE", false);\r
+ if (sms != null && !isSilence) {\r
+ if (!DeviceInfoUtil.isTopActivity(paramContext)) {\r
+ this.initMyDialog(paramContext, null, 4, sms);\r
+ this.playNotificationVoice(paramContext);\r
+ VibrateUtil.getInstance(paramContext).VibrateOn(true);\r
+ }\r
+\r
+ this.screenOn(paramContext);\r
}\r
-\r
- this.screenOn(paramContext);\r
- }\r
}else if (paramIntent.hasExtra("findDev")) {\r
String finddevtxt = paramIntent.getStringExtra("findDev");\r
SharPreferenceUtil.getPrefBoolean(paramContext, "key_is_resume", false);\r
}\r
\r
}else if (ACTION_TEMP_RESULT.equals(str)) {\r
- double wrist_temp=paramIntent.getDoubleExtra(KEY_TEMP_WRIST,0.0f);\r
- double body_temp=paramIntent.getDoubleExtra(KEY_TEMP_BODY,0.0f);\r
- String temperatureMsg= protocolAPIHelper.getTemperatureMSG(wrist_temp,body_temp);\r
- ICLogger.i("发送体温测量值 "+temperatureMsg);\r
- Deliver.sendLocationMSG(temperatureMsg);\r
-\r
+ double wrist_temp = paramIntent.getDoubleExtra(KEY_TEMP_WRIST, 0.0f);\r
+ double body_temp = paramIntent.getDoubleExtra(KEY_TEMP_BODY, 0.0f);\r
+ String temperatureMsg = protocolAPIHelper.getTemperatureMSG(wrist_temp, body_temp);\r
+ ICLogger.i("发送体温测量值 " + temperatureMsg);\r
+ Deliver.sendLocationMSG(temperatureMsg);\r
+ }else if (ACTION_SET_SIT_RANGE.equals(str)) {\r
+ if (paramIntent.hasExtra( Constants.KEY_SIT_RANGE)){\r
+ int sitrange=paramIntent.getIntExtra(Constants.KEY_SIT_RANGE,0);\r
+ Config.setKeepSitRangeInMinutes(paramContext,sitrange);\r
+ ICLogger.i("set KeepSitRange int "+sitrange+" minutes!");\r
+ }\r
} else {\r
//如果来电了,还有未读的消息,干脆关掉,防止影响接电话。\r
if (mCustomDialog != null && mCustomDialog.isShowing()) {\r
this.mCustomNotification.dismiss();\r
}\r
}\r
-\r
-\r
}\r
\r
public void sendStheartRateBroadcast(Context paramContext, String actionStr, int paramInt) {\r