实现快心跳周期的设置

hdrplus
Matthew 1 year ago
parent b1bc061f8b
commit 6b2b9df376

@ -36,6 +36,7 @@ public class MicroPhotoContext {
public final static int DEFAULT_PROTOCOL = 0xFF00;
public final static int DEFAULT_HEARTBEAT_TIME_FOR_SEPARATE_NW = 575; // 9:35
public final static int DEFAULT_HEARTBEAT_FOR_SHARED_NW = 10; // minutes
public final static int DEFAULT_QUICK_HEARTBEAT = 60; // second
public static class AppConfig {
@ -58,6 +59,7 @@ public class MicroPhotoContext {
public int quickHbMode;
public int usingAbsHbTime;
public int heartbeat; // Unit minute
public int quickHeartbeat; // Unit second
public int[] absHeartbeats; // second
public int separateNetwork;
public int mpappMonitorTimeout = 30 * 60000; // 30 minutes
@ -302,6 +304,7 @@ public class MicroPhotoContext {
// long defaultHearbeat = masterConfig.separateNetwork == 0 ? DEFAULT_HEARTBEAT_FOR_SHARED_NW : DEFAULT_HEARTBEAT_FOR_SEPARATE_NW;
masterConfig.heartbeat = jsonObject.optInt("heartbeat", DEFAULT_HEARTBEAT_FOR_SHARED_NW);
masterConfig.quickHeartbeat = jsonObject.optInt("quickHeartbeat", DEFAULT_QUICK_HEARTBEAT);
if (jsonObject.has("absHeartbeats")) {
JSONArray jsonHbs = jsonObject.getJSONArray("absHeartbeats");
masterConfig.absHeartbeats = new int[jsonHbs.length()];

@ -98,14 +98,14 @@ public class MpMasterService extends Service {
private boolean mUsingAbsHbTime = false;
private String mCmdid = "";
private NotificationManager mNotificationManager;
private int mQuickHeartbeatDuration = 60; // 1m = 60 s
private int mQuickHeartbeatDuration = 60; // Unit: second
private int mHeartbeatDuration = 600; // 10m = 10 * 60s
private AlarmReceiver mAlarmReceiver = null;
private ScreenActionReceiver mScreenaAtionReceiver = null;
private UpdateReceiver mUpdateReceiver = null;
private ServiceHandler mHander = null;
private Handler mHander = null;
private String mModelName = null;
@ -202,7 +202,7 @@ public class MpMasterService extends Service {
logger.info("MpMaster started version=" + mMpMasterVersion);
mHander = new ServiceHandler();
mHander = new Handler();
mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
mStateService = STATE_SERVICE.NOT_CONNECTED;
@ -213,9 +213,6 @@ public class MpMasterService extends Service {
{
mAlarmReceiver = new AlarmReceiver(this);
IntentFilter intentFilter = new IntentFilter(ACTION_HEARTBEAT);
// intentFilter.addAction(ACTION_TAKE_PHOTO);
// intentFilter.addAction(ACTION_TIMEOUT);
// intentFilter.addAction(ACTION_TAKE_PHOTO_MANUALLY);
intentFilter.addAction(ACTION_MSG_BROADCAST);
intentFilter.addAction(ACTION_UPDATE_CONFIGS);
intentFilter.addAction(ACTION_UPD_OTA);
@ -236,7 +233,7 @@ public class MpMasterService extends Service {
registerReceiver(mUpdateReceiver, intentFilter);
}
//自定义发送短信广播接收器
// SMS broadcast receiver
mSmsSnedReceiver = new SmsSendReceiver();
IntentFilter intentFilter;
intentFilter = new IntentFilter(SimUtil.SMS_SEND_ACTION);
@ -273,27 +270,13 @@ public class MpMasterService extends Service {
super.onDestroy();
}
public static class ServiceHandler extends Handler {
@Override
public void dispatchMessage(Message msg) {
super.dispatchMessage(msg);
// Log.i("life", "MyHandler----dispatchMessage");
// Log.i("life", Thread.currentThread().getName());
}
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
// Log.i("life", "MyHandler----handleMessage");
}
}
protected void loadConfig() {
MicroPhotoContext.MasterConfig masterConfig = MicroPhotoContext.getMasterConfig(getApplicationContext());
mMntnMode = masterConfig.mntnMode != 0;
mQuickHbMode = masterConfig.quickHbMode != 0;
mUsingAbsHbTime = masterConfig.usingAbsHbTime != 0;
mHeartbeatDuration = masterConfig.heartbeat * 60; // minute to second
mQuickHeartbeatDuration = masterConfig.quickHeartbeat;
mAbsHeartbeatTimes = masterConfig.absHeartbeats;
if (mAbsHeartbeatTimes != null && mAbsHeartbeatTimes.length > 0) {
Arrays.sort(mAbsHeartbeatTimes);

Loading…
Cancel
Save