正在查看: xDrip+ v04633772025.07.16 应用的 MissedReadingService.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: xDrip+ v04633772025.07.16 应用的 MissedReadingService.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.eveningoutpost.dexdrip.services;
import android.app.IntentService;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.PowerManager;
import android.preference.PreferenceManager;
import androidx.appcompat.R$styleable;
import com.eveningoutpost.dexdrip.Home;
import com.eveningoutpost.dexdrip.healthconnect.HealthConnectEntry;
import com.eveningoutpost.dexdrip.importedlibraries.usbserial.driver.UsbId;
import com.eveningoutpost.dexdrip.insulin.inpen.InPenEntry;
import com.eveningoutpost.dexdrip.models.AlertType;
import com.eveningoutpost.dexdrip.models.BgReading;
import com.eveningoutpost.dexdrip.models.DesertSync;
import com.eveningoutpost.dexdrip.models.JoH;
import com.eveningoutpost.dexdrip.models.Reminder;
import com.eveningoutpost.dexdrip.models.Sensor;
import com.eveningoutpost.dexdrip.models.UserError;
import com.eveningoutpost.dexdrip.models.UserNotification;
import com.eveningoutpost.dexdrip.services.broadcastservice.BroadcastEntry;
import com.eveningoutpost.dexdrip.ui.LockScreenWallPaper;
import com.eveningoutpost.dexdrip.utilitymodels.CollectionServiceStarter;
import com.eveningoutpost.dexdrip.utilitymodels.Inevitable;
import com.eveningoutpost.dexdrip.utilitymodels.NanoStatus;
import com.eveningoutpost.dexdrip.utilitymodels.Notifications;
import com.eveningoutpost.dexdrip.utilitymodels.Pref;
import com.eveningoutpost.dexdrip.utilitymodels.pebble.PebbleUtil;
import com.eveningoutpost.dexdrip.utilitymodels.pebble.PebbleWatchSync;
import com.eveningoutpost.dexdrip.utils.DexCollectionType;
import com.eveningoutpost.dexdrip.watch.lefun.LeFun;
import com.eveningoutpost.dexdrip.watch.lefun.LeFunEntry;
import com.eveningoutpost.dexdrip.wearintegration.WatchUpdaterService;
import com.eveningoutpost.dexdrip.webservices.XdripWebService;
import com.eveningoutpost.dexdrip.xdrip;
public class MissedReadingService extends IntentService {
private static final String TAG = "MissedReadingService";
private static int aggressive_backoff_timer = 120;
private static volatile PendingIntent serviceIntent;
public MissedReadingService() {
super(TAG);
}
@Override
protected void onHandleIntent(Intent intent) {
PowerManager.WakeLock wakeLock = JoH.getWakeLock("missed-reading-service", UsbId.SILABS_CP2102);
try {
boolean isActive = Sensor.isActive();
boolean z = DexCollectionType.getDexCollectionType() == DexCollectionType.Follower;
String str = TAG;
UserError.Log.d(str, "MissedReadingService onHandleIntent");
long stale_data_millis = Home.stale_data_millis();
if (Pref.getBoolean("broadcast_to_pebble", false) && PebbleUtil.getCurrentPebbleSyncType() != 1 && !BgReading.last_within_millis(stale_data_millis) && JoH.ratelimit("peb-miss", R$styleable.AppCompatTheme_windowFixedWidthMajor)) {
JoH.startService(PebbleWatchSync.class);
}
if (LeFunEntry.isEnabled() && !BgReading.last_within_millis(stale_data_millis)) {
LeFun.showLatestBG();
}
if (BroadcastEntry.isEnabled() && !BgReading.last_within_millis(stale_data_millis)) {
BroadcastEntry.sendLatestBG();
}
if ((Pref.getBoolean("aggressive_service_restart", false) || DexCollectionType.isFlakey()) && !BgReading.last_within_millis(stale_data_millis) && isActive && !DexCollectionType.getLocalServiceCollectingState()) {
if (JoH.ratelimit("aggressive-restart", aggressive_backoff_timer)) {
UserError.Log.e(str, "Aggressively restarting collector service due to lack of reception: backoff: " + aggressive_backoff_timer);
int i = aggressive_backoff_timer;
if (i < 1200) {
aggressive_backoff_timer = i + 60;
}
CollectionServiceStarter.restartCollectionServiceBackground();
} else {
aggressive_backoff_timer = R$styleable.AppCompatTheme_windowFixedWidthMajor;
}
}
Reminder.processAnyDueReminders();
BluetoothGlucoseMeter.immortality();
XdripWebService.immortality();
InPenEntry.immortality();
DesertSync.pullAsEnabled();
NanoStatus.keepFollowerUpdated();
LockScreenWallPaper.timerPoll();
HealthConnectEntry.ping();
if (Pref.getBoolean("bg_missed_alerts", false)) {
if (!isActive && !z) {
UserError.Log.d(str, "Not processing missed reading alert with no active sensor and not following");
return;
}
if (!JoH.upForAtLeastMins(15)) {
UserError.Log.d(str, "Uptime less than 15 minutes so not processing for missed reading");
return;
}
if (Home.get_forced_wear() && Pref.getBoolean("disable_wearG5_on_missedreadings", false)) {
if (BgReading.getTimeSinceLastReading().longValue() >= Pref.getStringToInt("disable_wearG5_on_missedreadings_level", 30) * 1000 * 60) {
UserError.Log.d(str, "Request WatchUpdaterService to disable force_wearG5 when wear is connected");
Home.startWatchUpdaterService(xdrip.getAppContext(), WatchUpdaterService.ACTION_DISABLE_FORCE_WEAR, str);
}
}
int stringToInt = Pref.getStringToInt("bg_missed_minutes", 30);
long tsl = JoH.tsl();
long j = stringToInt * 1000 * 60;
if (BgReading.getTimeSinceLastReading().longValue() < j || Pref.getLong("alerts_disabled_until", 0L) > tsl || BgReading.getTimeSinceLastReading().longValue() >= 21600000 || !inTimeFrame()) {
checkBackAfterMissedTime(Math.max(Pref.getLong("alerts_disabled_until", 0L) - tsl, j - BgReading.getTimeSinceLastReading().longValue()));
} else {
Notifications.bgMissedAlert(xdrip.getAppContext());
checkBackAfterSnoozeTime(xdrip.getAppContext(), tsl);
}
}
} finally {
JoH.releaseWakeLock(wakeLock);
}
}
private boolean inTimeFrame() {
return AlertType.s_in_time_frame(Pref.getBoolean("missed_readings_all_day", true), Pref.getInt("missed_readings_start", 0), Pref.getInt("missed_readings_end", 0));
}
private void checkBackAfterSnoozeTime(Context context, long j) {
UserNotification GetNotificationByType = UserNotification.GetNotificationByType("bg_missed_alerts");
if (GetNotificationByType == null) {
UserError.Log.wtf(TAG, "No active alert exists.");
setAlarm(getOtherAlertReraiseSec(context, "bg_missed_alerts") * 1000, false);
} else {
long j2 = ((long) GetNotificationByType.timestamp) - j;
if (j2 < 0) {
j2 = 0;
}
setAlarm(j2, true);
}
}
private void checkBackAfterMissedTime(long j) {
setAlarm(j, false);
}
public void setAlarm(long j, boolean z) {
if (!z && j < 300000) {
j = 300000;
}
long max = Math.max(j, 5000L);
UserError.Log.d(TAG, "Setting timer to " + (max / 60000) + " minutes from now");
initializeServiceIntent();
JoH.wakeUpIntent(this, max, serviceIntent);
}
private void initializeServiceIntent() {
if (serviceIntent == null) {
synchronized (this) {
if (serviceIntent == null) {
serviceIntent = PendingIntent.getService(this, 1006, new Intent(this, getClass()), 0);
}
}
}
}
public static long getOtherAlertReraiseSec(Context context, String str) {
if (Pref.getBoolean(str + "_enable_alerts_reraise", false)) {
return Pref.getStringToInt(str + "_reraise_sec", 60);
}
return getOtherAlertSnoozeMinutes(PreferenceManager.getDefaultSharedPreferences(context), str) * 60;
}
public static long getOtherAlertSnoozeMinutes(SharedPreferences sharedPreferences, String str) {
int stringToInt = Pref.getStringToInt("other_alerts_snooze", 20);
return Pref.getStringToInt(str + "_snooze", stringToInt);
}
public static void delayedLaunch() {
Inevitable.task("launch-missed-readings", 1000L, new Runnable() {
@Override
public final void run() {
JoH.startService(MissedReadingService.class);
}
});
}
}