实现心跳时间和拍照时间对齐

serial
Matthew 1 year ago
parent 188fbd747c
commit cd35c7f05d

@ -383,11 +383,26 @@ public class MicroPhotoService extends Service {
// Will be called fron native
private void registerHeartbeatTimer(int duration, long nextPhotoTime) {
int orgHeartbeatDuration = mHeartbeatDuration;
mHeartbeatDuration = duration;
if (orgHeartbeatDuration == 0) {
registerHeartbeatTimer();
if (nextPhotoTime == 0) {
mHeartbeatDuration = duration;
registerHeartbeatTimer();
} else {
long ts = System.currentTimeMillis();
nextPhotoTime *= 1000;
if (nextPhotoTime > ts) {
mHeartbeatDuration = (int) ((nextPhotoTime - ts) % duration) + 999;
registerHeartbeatTimer();
mHeartbeatDuration = duration;
} else {
mHeartbeatDuration = duration;
registerHeartbeatTimer();
}
}
} else {
mHeartbeatDuration = duration;
}
}
private void registerHeartbeatTimer() {

Loading…
Cancel
Save