导航菜单

页面标题

页面副标题

xDrip+ v04633772025.07.16 - SnoozeOnNotificationDismissService.java 源代码

正在查看: xDrip+ v04633772025.07.16 应用的 SnoozeOnNotificationDismissService.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.eveningoutpost.dexdrip.services;

import android.app.IntentService;
import android.content.Intent;
import android.preference.PreferenceManager;
import com.eveningoutpost.dexdrip.Home;
import com.eveningoutpost.dexdrip.SnoozeActivity;
import com.eveningoutpost.dexdrip.models.ActiveBgAlert;
import com.eveningoutpost.dexdrip.models.AlertType;
import com.eveningoutpost.dexdrip.models.JoH;
import com.eveningoutpost.dexdrip.models.UserError;
import com.eveningoutpost.dexdrip.models.UserNotification;
import com.eveningoutpost.dexdrip.utilitymodels.AlertPlayer;
import com.eveningoutpost.dexdrip.utilitymodels.Pref;
import com.eveningoutpost.dexdrip.wearintegration.Amazfitservice;
import com.eveningoutpost.dexdrip.xdrip;

public class SnoozeOnNotificationDismissService extends IntentService {
    private static final String TAG = AlertPlayer.class.getSimpleName();

    public SnoozeOnNotificationDismissService() {
        super("SnoozeOnNotificationDismissService");
    }

    @Override
    protected void onHandleIntent(Intent intent) {
        String stringExtra = intent != null ? intent.getStringExtra("alertType") : "null intent";
        if (stringExtra == null) {
            stringExtra = "null";
        }
        long msSince = intent != null ? JoH.msSince(intent.getLongExtra("raisedTimeStamp", JoH.tsl() - 600000)) : 600000L;
        if (msSince <= 2000) {
            UserError.Log.wtf(TAG, "Attempt to cancel alert (" + stringExtra + ") within minimum limit of: " + JoH.niceTimeScalar(2000L));
            Home.startHomeWithExtra(xdrip.getAppContext(), "confirmsnooze", "simpleconfirm");
        }
        String str = TAG;
        UserError.Log.e(str, "SnoozeOnNotificationDismissService called source = " + stringExtra + " shown for: " + JoH.niceTimeScalar(msSince));
        if (stringExtra.equals("bg_alerts") && msSince > 2000) {
            snoozeBgAlert();
            return;
        }
        if (stringExtra.equals("bg_unclear_readings_alert") || stringExtra.equals("bg_missed_alerts")) {
            if (!PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getBoolean(stringExtra + "_enable_alerts_reraise", false) || msSince <= 2000) {
                return;
            }
            snoozeOtherAlert(stringExtra);
            return;
        }
        if (stringExtra.equals("bg_predict_alert") || stringExtra.equals("persistent_high_alert")) {
            UserError.Log.wtf(str, "SnoozeOnNotificationDismissService called for unsupported type!!! source = " + stringExtra);
        }
        UserError.Log.e(str, "SnoozeOnNotificationDismissService called for unknown source = " + stringExtra);
    }

    private void snoozeBgAlert() {
        int i;
        AlertType alertTypegetOnly = ActiveBgAlert.alertTypegetOnly();
        if (alertTypegetOnly != null) {
            i = alertTypegetOnly.default_snooze;
            if (i == 0) {
                i = SnoozeActivity.getDefaultSnooze(alertTypegetOnly.above);
            }
        } else {
            i = 30;
        }
        AlertPlayer.getPlayer().Snooze(getApplicationContext(), i);
    }

    private void snoozeOtherAlert(String str) {
        long otherAlertSnoozeMinutes = MissedReadingService.getOtherAlertSnoozeMinutes(PreferenceManager.getDefaultSharedPreferences(getApplicationContext()), str);
        UserError.Log.i(TAG, "snoozeOtherAlert calling snooze alert alert = " + str + " snoozeMinutes = " + otherAlertSnoozeMinutes);
        UserNotification.snoozeAlert(str, otherAlertSnoozeMinutes);
        if (Pref.getBooleanDefaultFalse("pref_amazfit_enable_key") && Pref.getBooleanDefaultFalse("pref_amazfit_BG_alert_enable_key")) {
            Amazfitservice.start("xDrip_AlarmCancel");
        }
    }
}