对齐的心跳不传心跳周期

TempBranch
Matthew 9 months ago
parent e3eccd603f
commit f8039312c5

@ -437,7 +437,7 @@ public class MicroPhotoService extends Service {
nextPhotoTime *= 1000; nextPhotoTime *= 1000;
if (nextPhotoTime > ts) { if (nextPhotoTime > ts) {
mHeartbeatDuration = (int) ((nextPhotoTime - ts) % duration) + 999; mHeartbeatDuration = (int) ((nextPhotoTime - ts) % duration) + 999;
registerHeartbeatTimer(); registerHeartbeatTimer(false);
mHeartbeatDuration = duration; mHeartbeatDuration = duration;
} else { } else {
mHeartbeatDuration = duration; mHeartbeatDuration = duration;
@ -448,13 +448,20 @@ public class MicroPhotoService extends Service {
mHeartbeatDuration = duration; mHeartbeatDuration = duration;
} }
} }
private void registerHeartbeatTimer() { private void registerHeartbeatTimer() {
registerHeartbeatTimer(true);
}
private void registerHeartbeatTimer(boolean normalDuration) {
// 创建延迟意图 // 创建延迟意图
long triggerTime = System.currentTimeMillis() + mHeartbeatDuration; long triggerTime = System.currentTimeMillis() + mHeartbeatDuration;
Intent alarmIntent = new Intent(); Intent alarmIntent = new Intent();
alarmIntent.setAction(ACTION_HEARTBEAT); alarmIntent.setAction(ACTION_HEARTBEAT);
alarmIntent.putExtra("HeartbeatDuration", mHeartbeatDuration); if (normalDuration) {
alarmIntent.putExtra("HeartbeatDuration", mHeartbeatDuration);
}
alarmIntent.putExtra("HeartbeatTime", triggerTime); alarmIntent.putExtra("HeartbeatTime", triggerTime);
PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, alarmIntent, PendingIntent.FLAG_UPDATE_CURRENT); PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, alarmIntent, PendingIntent.FLAG_UPDATE_CURRENT);

Loading…
Cancel
Save