Java Code Examples for com.eveningoutpost.dexdrip.Home#get_forced_wear()
The following examples show how to use
com.eveningoutpost.dexdrip.Home#get_forced_wear() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Ob1G5CollectionService.java From xDrip with GNU General Public License v3.0 | 6 votes |
private static boolean shouldServiceRun() { if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) return false; if (!Pref.getBooleanDefaultFalse(OB1G5_PREFS)) return false; if (!(DexCollectionType.getDexCollectionType() == DexcomG5)) return false; if (!android_wear) { if (Home.get_forced_wear()) { if (JoH.quietratelimit("forced-wear-notice", 3)) UserError.Log.d(TAG, "Not running due to forced wear"); return false; } if (BlueJayEntry.isPhoneCollectorDisabled()) { UserError.Log.d(TAG,"Not running as BlueJay is collector"); return false; } } else { // android wear code if (!PersistentStore.getBoolean(CollectionServiceStarter.pref_run_wear_collector)) return false; } return true; }
Example 2
Source File: Ob1G5CollectionService.java From xDrip-plus with GNU General Public License v3.0 | 6 votes |
private static boolean shouldServiceRun() { if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) return false; if (!Pref.getBooleanDefaultFalse(OB1G5_PREFS)) return false; if (!(DexCollectionType.getDexCollectionType() == DexcomG5)) return false; if (!android_wear) { if (Home.get_forced_wear()) { if (JoH.quietratelimit("forced-wear-notice", 3)) UserError.Log.d(TAG, "Not running due to forced wear"); return false; } if (BlueJayEntry.isPhoneCollectorDisabled()) { UserError.Log.d(TAG,"Not running as BlueJay is collector"); return false; } } else { // android wear code if (!PersistentStore.getBoolean(CollectionServiceStarter.pref_run_wear_collector)) return false; } return true; }
Example 3
Source File: Ob1G5CollectionService.java From xDrip-plus with GNU General Public License v3.0 | 6 votes |
private static boolean shouldServiceRun() { if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) return false; if (!Pref.getBooleanDefaultFalse(OB1G5_PREFS)) return false; if (!(DexCollectionType.getDexCollectionType() == DexcomG5)) return false; if (!android_wear) { if (Home.get_forced_wear()) { if (JoH.quietratelimit("forced-wear-notice", 3)) UserError.Log.d(TAG, "Not running due to forced wear"); return false; } } else { // android wear code if (!PersistentStore.getBoolean(CollectionServiceStarter.pref_run_wear_collector)) return false; } return true; }
Example 4
Source File: AlertPlayer.java From xDrip with GNU General Public License v3.0 | 5 votes |
private void Vibrate(Context ctx, AlertType alert, String bgValue, Boolean overrideSilent, int timeFromStartPlaying) { //KS Watch currently only supports Vibration, no audio; Use VibrateAudio to support audio String title = bgValue + " " + alert.name; String content = "BG LEVEL ALERT: " + bgValue + " (@" + JoH.hourMinuteString() + ")"; Intent intent = new Intent(ctx, SnoozeActivity.class); boolean localOnly = (Home.get_forced_wear() && Pref.getBooleanDefaultFalse("bg_notifications"));//KS Log.d(TAG, "NotificationCompat.Builder localOnly=" + localOnly); NotificationCompat.Builder builder = new NotificationCompat.Builder(ctx)//KS Notification .setSmallIcon(R.drawable.ic_launcher)//KS ic_action_communication_invert_colors_on .setContentTitle(title) .setContentText(content) .setContentIntent(notificationIntent(ctx, intent)) .setLocalOnly(localOnly)//KS .setDeleteIntent(snoozeIntent(ctx)); builder.setVibrate(Notifications.vibratePattern); Log.ueh("Alerting",content); NotificationManager mNotifyMgr = (NotificationManager) ctx.getSystemService(Context.NOTIFICATION_SERVICE); //mNotifyMgr.cancel(Notifications.exportAlertNotificationId); // this appears to confuse android wear version 2.0.0.141773014.gms even though it shouldn't - can we survive without this? mNotifyMgr.notify(Notifications.exportAlertNotificationId, builder.build()); if (Pref.getBooleanDefaultFalse("alert_use_sounds")) { try { if (JoH.ratelimit("wear-alert-sound", 10)) { JoH.playResourceAudio(R.raw.warning); } } catch (Exception e) { // } } }
Example 5
Source File: DexCollectionService.java From xDrip-plus with GNU General Public License v3.0 | 5 votes |
@SuppressLint("ObsoleteSdkInt") private static boolean shouldServiceRun() { if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) return false; final boolean result = (DexCollectionType.hasXbridgeWixel() || DexCollectionType.hasBtWixel()) && ((!Home.get_forced_wear() && (((UiModeManager) xdrip.getAppContext().getSystemService(UI_MODE_SERVICE)).getCurrentModeType() != Configuration.UI_MODE_TYPE_WATCH)) || PersistentStore.getBoolean(CollectionServiceStarter.pref_run_wear_collector)); if (d) Log.d(TAG, "shouldServiceRun() returning: " + result); return result; }
Example 6
Source File: DexCollectionService.java From xDrip with GNU General Public License v3.0 | 5 votes |
@SuppressLint("ObsoleteSdkInt") private static boolean shouldServiceRun() { if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) return false; final boolean result = (DexCollectionType.hasXbridgeWixel() || DexCollectionType.hasBtWixel()) && ((!Home.get_forced_wear() && (((UiModeManager) xdrip.getAppContext().getSystemService(UI_MODE_SERVICE)).getCurrentModeType() != Configuration.UI_MODE_TYPE_WATCH)) || PersistentStore.getBoolean(CollectionServiceStarter.pref_run_wear_collector)); if (d) Log.d(TAG, "shouldServiceRun() returning: " + result); return result; }
Example 7
Source File: Telemetry.java From xDrip with GNU General Public License v3.0 | 4 votes |
public static void sendCaptureReport() { try { if (JoH.ratelimit("capture-report", 50000)) { Log.d(TAG, "SEND EVENT START"); if (Pref.getBooleanDefaultFalse("enable_crashlytics") && Pref.getBooleanDefaultFalse("enable_telemetry")) { final Sensor sensor = Sensor.currentSensor(); if (sensor != null) { if (JoH.msSince(sensor.started_at) > 86400000) { final StatsResult statsResult = new StatsResult(PreferenceManager.getDefaultSharedPreferences(xdrip.getAppContext()), true); final int capture_percentage = statsResult.getCapturePercentage(); final int capture_set = (capture_percentage / 10) * 10; if (capture_set > 60) { final boolean use_transmiter_pl_bluetooth = Pref.getBooleanDefaultFalse("use_transmiter_pl_bluetooth"); final boolean use_rfduino_bluetooth = Pref.getBooleanDefaultFalse("use_rfduino_bluetooth"); final String subtype = (use_transmiter_pl_bluetooth ? "TR" : "") + (use_rfduino_bluetooth ? "RF" : "") + (Home.get_forced_wear() ? "W" : "") + (NFCReaderX.used_nfc_successfully ? "N" : ""); final String capture_id = DexCollectionType.getDexCollectionType().toString() + subtype + " Captured " + capture_set; Log.d(TAG, "SEND CAPTURE EVENT PROCESS: " + capture_id); String watch_model = ""; if (Home.get_forced_wear()) { // anonymize watch model final String wear_node = Pref.getStringDefaultBlank("node_wearG5"); if (wear_node.length() > 0) { final String[] wear_array = wear_node.split(" "); for (String ii : wear_array) { if (!ii.contains("|")) watch_model = watch_model + ii; } } } if (watch_model.length() > 0) { Answers.getInstance().logCustom(new CustomEvent(capture_id) .putCustomAttribute("Model", Build.MODEL + " " + Build.VERSION.RELEASE) .putCustomAttribute("Manufacturer", Build.MANUFACTURER) .putCustomAttribute("Version", Build.VERSION.RELEASE) .putCustomAttribute("xDrip", getVersionDetails()) .putCustomAttribute("Watch", watch_model) .putCustomAttribute("Percentage", capture_percentage)); } else { Answers.getInstance().logCustom(new CustomEvent(capture_id) .putCustomAttribute("Model", Build.MODEL + " " + Build.VERSION.RELEASE) .putCustomAttribute("Manufacturer", Build.MANUFACTURER) .putCustomAttribute("Version", Build.VERSION.RELEASE) .putCustomAttribute("xDrip", getVersionDetails()) .putCustomAttribute("Percentage", capture_percentage)); } } } else { Log.d(TAG, "Sensor not running for more than 24 hours yet"); } } else { Log.d(TAG, "No sensor active"); } Log.d(TAG, "SEND EVENT DONE"); } } } catch (Exception e) { Log.e(TAG, "Got exception sending Capture Report"); } }
Example 8
Source File: DexShareCollectionService.java From xDrip-plus with GNU General Public License v3.0 | 4 votes |
private static boolean shouldServiceRun(Context context) { if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) return false; final boolean result = CollectionServiceStarter.isBTShare(context) && !Home.get_forced_wear(); Log.d(TAG, "shouldServiceRun() returning: " + result); return result; }
Example 9
Source File: Notifications.java From xDrip-plus with GNU General Public License v3.0 | 4 votes |
private static void OtherAlert(Context context, String type, String message, int notificatioId, boolean addDeleteIntent, long reraiseSec) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); String otherAlertsSound = prefs.getString(type+"_sound",prefs.getString("other_alerts_sound", "content://settings/system/notification_sound")); Boolean otherAlertsOverrideSilent = prefs.getBoolean("other_alerts_override_silent", false); Log.d(TAG,"OtherAlert called " + type + " " + message + " reraiseSec = " + reraiseSec); UserNotification userNotification = UserNotification.GetNotificationByType(type); //"bg_unclear_readings_alert" if ((userNotification == null) || userNotification.timestamp <= new Date().getTime() ) { if (userNotification != null) { try { userNotification.delete(); } catch (NullPointerException e) { // ignore null pointer exception during delete as we emulate database records } Log.d(TAG, "Delete"); } UserNotification.create(message, type, new Date().getTime() + reraiseSec * 1000); boolean localOnly =false;//KS if (notificatioId == persistentHighAlertNotificationId) { localOnly = (Home.get_forced_wear() && bg_notifications && bg_persistent_high_alert_enabled); } Log.d(TAG,"OtherAlert forced_wear localOnly=" + localOnly); Intent intent = new Intent(context, Home.class); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context) .setSmallIcon(R.drawable.ic_launcher)//KS ic_action_communication_invert_colors_on .setContentTitle(message) .setContentText(message) .setLocalOnly(localOnly)//KS .setContentIntent(PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT)); if (addDeleteIntent) { Intent deleteIntent = new Intent(context, SnoozeOnNotificationDismissService.class); deleteIntent.putExtra("alertType", type); mBuilder.setDeleteIntent(PendingIntent.getService(context, 0, deleteIntent, PendingIntent.FLAG_UPDATE_CURRENT)); } mBuilder.setVibrate(vibratePattern); mBuilder.setLights(0xff00ff00, 300, 1000); if (AlertPlayer.notSilencedDueToCall()) { if (otherAlertsOverrideSilent) { mBuilder.setSound(Uri.parse(otherAlertsSound), AudioAttributes.USAGE_ALARM); } else { mBuilder.setSound(Uri.parse(otherAlertsSound)); } } NotificationManager mNotifyMgr = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); //mNotifyMgr.cancel(notificatioId); //Log.d(TAG, "Notify"); Log.ueh("Other Alert",message); mNotifyMgr.notify(notificatioId, mBuilder.build()); } }
Example 10
Source File: Telemetry.java From xDrip-plus with GNU General Public License v3.0 | 4 votes |
public static void sendCaptureReport() { try { if (JoH.ratelimit("capture-report", 50000)) { Log.d(TAG, "SEND EVENT START"); if (Pref.getBooleanDefaultFalse("enable_crashlytics") && Pref.getBooleanDefaultFalse("enable_telemetry")) { final Sensor sensor = Sensor.currentSensor(); if (sensor != null) { if (JoH.msSince(sensor.started_at) > 86400000) { final StatsResult statsResult = new StatsResult(PreferenceManager.getDefaultSharedPreferences(xdrip.getAppContext()), true); final int capture_percentage = statsResult.getCapturePercentage(); final int capture_set = (capture_percentage / 10) * 10; if (capture_set > 60) { final boolean use_transmiter_pl_bluetooth = Pref.getBooleanDefaultFalse("use_transmiter_pl_bluetooth"); final boolean use_rfduino_bluetooth = Pref.getBooleanDefaultFalse("use_rfduino_bluetooth"); final String subtype = (use_transmiter_pl_bluetooth ? "TR" : "") + (use_rfduino_bluetooth ? "RF" : "") + (Home.get_forced_wear() ? "W" : "") + (NFCReaderX.used_nfc_successfully ? "N" : ""); final String capture_id = DexCollectionType.getDexCollectionType().toString() + subtype + " Captured " + capture_set; Log.d(TAG, "SEND CAPTURE EVENT PROCESS: " + capture_id); String watch_model = ""; if (Home.get_forced_wear()) { // anonymize watch model final String wear_node = Pref.getStringDefaultBlank("node_wearG5"); if (wear_node.length() > 0) { final String[] wear_array = wear_node.split(" "); for (String ii : wear_array) { if (!ii.contains("|")) watch_model = watch_model + ii; } } } if (watch_model.length() > 0) { Answers.getInstance().logCustom(new CustomEvent(capture_id) .putCustomAttribute("Model", Build.MODEL + " " + Build.VERSION.RELEASE) .putCustomAttribute("Manufacturer", Build.MANUFACTURER) .putCustomAttribute("Version", Build.VERSION.RELEASE) .putCustomAttribute("xDrip", getVersionDetails()) .putCustomAttribute("Watch", watch_model) .putCustomAttribute("Percentage", capture_percentage)); } else { Answers.getInstance().logCustom(new CustomEvent(capture_id) .putCustomAttribute("Model", Build.MODEL + " " + Build.VERSION.RELEASE) .putCustomAttribute("Manufacturer", Build.MANUFACTURER) .putCustomAttribute("Version", Build.VERSION.RELEASE) .putCustomAttribute("xDrip", getVersionDetails()) .putCustomAttribute("Percentage", capture_percentage)); } } } else { Log.d(TAG, "Sensor not running for more than 24 hours yet"); } } else { Log.d(TAG, "No sensor active"); } Log.d(TAG, "SEND EVENT DONE"); } } } catch (Exception e) { Log.e(TAG, "Got exception sending Capture Report"); } }
Example 11
Source File: AlertPlayer.java From xDrip-plus with GNU General Public License v3.0 | 4 votes |
private void VibrateNotifyMakeNoise(Context context, AlertType alert, String bgValue, int minsFromStartPlaying) { Log.d(TAG, "VibrateNotifyMakeNoise called minsFromStartedPlaying = " + minsFromStartPlaying); Log.d("ALARM", "setting vibrate alarm"); int profile = getAlertProfile(context); if (alert.uuid.equals(AlertType.LOW_ALERT_55)) { // boost alerts... if (profile == ALERT_PROFILE_VIBRATE_ONLY) { profile = ALERT_PROFILE_ASCENDING; } } // We use timeFromStartPlaying as a way to force vibrating/ non vibrating... if (profile != ALERT_PROFILE_ASCENDING) { // We start from the non ascending part... minsFromStartPlaying = MAX_ASCENDING_MINUTES; } final String highlow = (alert.above ? context.getString(R.string.high) : context.getString(R.string.low)).toUpperCase(); String title = bgValue + " " + alert.name; String content = "BG " + highlow + " ALERT: " + bgValue + " (@" + JoH.hourMinuteString() + ")"; final Intent intent = new Intent(context, SnoozeActivity.class); boolean localOnly = (Home.get_forced_wear() && PersistentStore.getBoolean("bg_notifications_watch")); Log.d(TAG, "NotificationCompat.Builder localOnly=" + localOnly); NotificationCompat.Builder builder = new NotificationCompat.Builder(context, NotificationChannels.BG_ALERT_CHANNEL)//KS Notification .setSmallIcon(R.drawable.ic_action_communication_invert_colors_on) .setContentTitle(title) .setContentText(content) //.addAction(R.drawable.ic_action_communication_invert_colors_on, "SNOOZE", notificationIntent(context, intent)) .setContentIntent(notificationIntent(context, intent)) .setLocalOnly(localOnly) .setGroup("xDrip level alert") .setPriority(Pref.getBooleanDefaultFalse("high_priority_notifications") ? Notification.PRIORITY_MAX : Notification.PRIORITY_HIGH) .setDeleteIntent(snoozeIntent(context, minsFromStartPlaying)); if (profile != ALERT_PROFILE_VIBRATE_ONLY && profile != ALERT_PROFILE_SILENT) { if (minsFromStartPlaying >= MAX_VIBRATING_MINUTES) { // Before this, we only vibrate... float volumeFrac = (float) (minsFromStartPlaying - MAX_VIBRATING_MINUTES) / (MAX_ASCENDING_MINUTES - MAX_VIBRATING_MINUTES); volumeFrac = Math.min(volumeFrac, 1); if (profile == ALERT_PROFILE_MEDIUM) { volumeFrac = (float) 0.7; } Log.d(TAG, "VibrateNotifyMakeNoise volumeFrac = " + volumeFrac); boolean overrideSilent = alert.override_silent_mode; boolean forceSpeaker = alert.force_speaker; if (notSilencedDueToCall()) { if (overrideSilent || isLoudPhone(context)) { playFile(context, alert.mp3_file, volumeFrac, forceSpeaker, overrideSilent); } } else { Log.i(TAG, "Silenced Alert Noise due to ongoing call"); } } } if (profile != ALERT_PROFILE_SILENT && alert.vibrate) { if (notSilencedDueToCall()) { builder.setVibrate(Notifications.vibratePattern); } else { Log.i(TAG, "Vibration silenced due to ongoing call"); } } else { // In order to still show on all android wear watches, either a sound or a vibrate pattern // seems to be needed. This pattern basically does not vibrate: builder.setVibrate(new long[]{1, 0}); } Log.ueh("Alerting", content); final NotificationManager mNotifyMgr = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); //mNotifyMgr.cancel(Notifications.exportAlertNotificationId); // this appears to confuse android wear version 2.0.0.141773014.gms even though it shouldn't - can we survive without this? mNotifyMgr.notify(Notifications.exportAlertNotificationId, XdripNotificationCompat.build(builder)); // send to bluejay BlueJayEntry.sendAlertIfEnabled((alert.above ? "High" : "Low") + " Alert " + bgValue + " " + alert.name); // string text is used to determine alert type // send alert to pebble if (Pref.getBooleanDefaultFalse("broadcast_to_pebble") && (Pref.getBooleanDefaultFalse("pebble_vibe_alerts"))) { if (JoH.ratelimit("pebble_vibe_start", 59)) { JoH.startService(PebbleWatchSync.class); } } //send alert to amazfit if (Pref.getBooleanDefaultFalse("pref_amazfit_enable_key") && Pref.getBooleanDefaultFalse("pref_amazfit_BG_alert_enable_key")) { Amazfitservice.start("xDrip_Alarm", alert.name, alert.default_snooze); } if (LeFunEntry.areAlertsEnabled() && ActiveBgAlert.currentlyAlerting()) { LeFun.sendAlert(highlow, bgValue); } if (MiBandEntry.areAlertsEnabled() && ActiveBgAlert.currentlyAlerting()) { MiBand.sendAlert(alert.name, highlow + " " + bgValue, alert.default_snooze); } // speak alert if (Pref.getBooleanDefaultFalse("speak_alerts")) { SpeechUtil.say(highlow + ", " + bgValue, 3000); } }
Example 12
Source File: NightscoutUploader.java From xDrip-plus with GNU General Public License v3.0 | 4 votes |
private void postDeviceStatus(NightscoutService nightscoutService, String apiSecret) throws Exception { // TODO optimize based on changes avoiding stale marker issues final boolean always_send_battery = true; // nightscout doesn't currently display device device status if it thinks its stale final List<String> batteries = new ArrayList<>(); batteries.add("Phone"); if ((DexCollectionType.hasBattery() && (Pref.getBoolean("send_bridge_battery_to_nightscout", true))) || (Home.get_forced_wear() && DexCollectionType.getDexCollectionType().equals(DexCollectionType.DexcomG5))) { batteries.add("Bridge"); } if (DexCollectionType.hasWifi()) batteries.add("Parakeet"); for (String battery : batteries) { int battery_level; String battery_name = ""; switch (battery) { case "Phone": battery_level = getBatteryLevel(); battery_name = Build.MANUFACTURER + " " + Build.MODEL; break; case "Bridge": battery_level = Pref.getInt("bridge_battery", -1); battery_name = DexCollectionService.getBestLimitterHardwareName(); break; case "Parakeet": battery_level = Pref.getInt("parakeet_battery", -1); battery_name = "Parakeet"; break; default: battery_level = -1; break; } final long last_battery_level = PersistentStore.getLong(LAST_NIGHTSCOUT_BATTERY_LEVEL); final JSONArray array = new JSONArray(); final JSONObject json = new JSONObject(); final JSONObject uploader = new JSONObject(); if ((battery_level > 0) && (battery_level != last_battery_level || always_send_battery)) { PersistentStore.setLong(LAST_NIGHTSCOUT_BATTERY_LEVEL, battery_level); // UserError.Log.d(TAG, "Uploading battery detail: " + battery_level); // json.put("uploaderBattery", battery_level); // old style uploader.put("battery", battery_level); json.put("device", battery_name); json.put("uploader", uploader); array.put(json); // example //{ // "device": "openaps://ediscout2.local", // "uploader": { // "battery": 60, // "batteryVoltage": 3783, // "temperature": "+51.0°C" //} //} final RequestBody body = RequestBody.create(MediaType.parse("application/json"), json.toString()); Response<ResponseBody> r; if (apiSecret != null) { r = nightscoutService.uploadDeviceStatus(apiSecret, body).execute(); } else r = nightscoutService.uploadDeviceStatus(body).execute(); if (!r.isSuccessful()) throw new UploaderException(r.message(), r.code()); // } else { // UserError.Log.d(TAG, "Battery level is same as previous - not uploading: " + battery_level); checkGzipSupport(r); } } }
Example 13
Source File: NightscoutUploader.java From xDrip with GNU General Public License v3.0 | 4 votes |
private void postDeviceStatus(NightscoutService nightscoutService, String apiSecret) throws Exception { // TODO optimize based on changes avoiding stale marker issues final boolean always_send_battery = true; // nightscout doesn't currently display device device status if it thinks its stale final List<String> batteries = new ArrayList<>(); batteries.add("Phone"); if ((DexCollectionType.hasBattery() && (Pref.getBoolean("send_bridge_battery_to_nightscout", true))) || (Home.get_forced_wear() && DexCollectionType.getDexCollectionType().equals(DexCollectionType.DexcomG5))) { batteries.add("Bridge"); } if (DexCollectionType.hasWifi()) batteries.add("Parakeet"); for (String battery : batteries) { int battery_level; String battery_name = ""; switch (battery) { case "Phone": battery_level = getBatteryLevel(); battery_name = Build.MANUFACTURER + " " + Build.MODEL; break; case "Bridge": battery_level = Pref.getInt("bridge_battery", -1); battery_name = DexCollectionService.getBestLimitterHardwareName(); break; case "Parakeet": battery_level = Pref.getInt("parakeet_battery", -1); battery_name = "Parakeet"; break; default: battery_level = -1; break; } final long last_battery_level = PersistentStore.getLong(LAST_NIGHTSCOUT_BATTERY_LEVEL); final JSONArray array = new JSONArray(); final JSONObject json = new JSONObject(); final JSONObject uploader = new JSONObject(); if ((battery_level > 0) && (battery_level != last_battery_level || always_send_battery)) { PersistentStore.setLong(LAST_NIGHTSCOUT_BATTERY_LEVEL, battery_level); // UserError.Log.d(TAG, "Uploading battery detail: " + battery_level); // json.put("uploaderBattery", battery_level); // old style uploader.put("battery", battery_level); json.put("device", battery_name); json.put("uploader", uploader); array.put(json); // example //{ // "device": "openaps://ediscout2.local", // "uploader": { // "battery": 60, // "batteryVoltage": 3783, // "temperature": "+51.0°C" //} //} final RequestBody body = RequestBody.create(MediaType.parse("application/json"), json.toString()); Response<ResponseBody> r; if (apiSecret != null) { r = nightscoutService.uploadDeviceStatus(apiSecret, body).execute(); } else r = nightscoutService.uploadDeviceStatus(body).execute(); if (!r.isSuccessful()) throw new UploaderException(r.message(), r.code()); // } else { // UserError.Log.d(TAG, "Battery level is same as previous - not uploading: " + battery_level); checkGzipSupport(r); } } }
Example 14
Source File: AlertPlayer.java From xDrip with GNU General Public License v3.0 | 4 votes |
private void VibrateNotifyMakeNoise(Context context, AlertType alert, String bgValue, int minsFromStartPlaying) { Log.d(TAG, "VibrateNotifyMakeNoise called minsFromStartedPlaying = " + minsFromStartPlaying); Log.d("ALARM", "setting vibrate alarm"); int profile = getAlertProfile(context); if (alert.uuid.equals(AlertType.LOW_ALERT_55)) { // boost alerts... if (profile == ALERT_PROFILE_VIBRATE_ONLY) { profile = ALERT_PROFILE_ASCENDING; } } // We use timeFromStartPlaying as a way to force vibrating/ non vibrating... if (profile != ALERT_PROFILE_ASCENDING) { // We start from the non ascending part... minsFromStartPlaying = MAX_ASCENDING_MINUTES; } final String highlow = (alert.above ? context.getString(R.string.high) : context.getString(R.string.low)).toUpperCase(); String title = bgValue + " " + alert.name; String content = "BG " + highlow + " ALERT: " + bgValue + " (@" + JoH.hourMinuteString() + ")"; final Intent intent = new Intent(context, SnoozeActivity.class); boolean localOnly = (Home.get_forced_wear() && PersistentStore.getBoolean("bg_notifications_watch")); Log.d(TAG, "NotificationCompat.Builder localOnly=" + localOnly); NotificationCompat.Builder builder = new NotificationCompat.Builder(context, NotificationChannels.BG_ALERT_CHANNEL)//KS Notification .setSmallIcon(R.drawable.ic_action_communication_invert_colors_on) .setContentTitle(title) .setContentText(content) //.addAction(R.drawable.ic_action_communication_invert_colors_on, "SNOOZE", notificationIntent(context, intent)) .setContentIntent(notificationIntent(context, intent)) .setLocalOnly(localOnly) .setGroup("xDrip level alert") .setPriority(Pref.getBooleanDefaultFalse("high_priority_notifications") ? Notification.PRIORITY_MAX : Notification.PRIORITY_HIGH) .setDeleteIntent(snoozeIntent(context, minsFromStartPlaying)); if (profile != ALERT_PROFILE_VIBRATE_ONLY && profile != ALERT_PROFILE_SILENT) { if (minsFromStartPlaying >= MAX_VIBRATING_MINUTES) { // Before this, we only vibrate... float volumeFrac = (float) (minsFromStartPlaying - MAX_VIBRATING_MINUTES) / (MAX_ASCENDING_MINUTES - MAX_VIBRATING_MINUTES); volumeFrac = Math.min(volumeFrac, 1); if (profile == ALERT_PROFILE_MEDIUM) { volumeFrac = (float) 0.7; } Log.d(TAG, "VibrateNotifyMakeNoise volumeFrac = " + volumeFrac); boolean overrideSilent = alert.override_silent_mode; boolean forceSpeaker = alert.force_speaker; if (notSilencedDueToCall()) { if (overrideSilent || isLoudPhone(context)) { playFile(context, alert.mp3_file, volumeFrac, forceSpeaker, overrideSilent); } } else { Log.i(TAG, "Silenced Alert Noise due to ongoing call"); } } } if (profile != ALERT_PROFILE_SILENT && alert.vibrate) { if (notSilencedDueToCall()) { builder.setVibrate(Notifications.vibratePattern); } else { Log.i(TAG, "Vibration silenced due to ongoing call"); } } else { // In order to still show on all android wear watches, either a sound or a vibrate pattern // seems to be needed. This pattern basically does not vibrate: builder.setVibrate(new long[]{1, 0}); } Log.ueh("Alerting", content); final NotificationManager mNotifyMgr = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); //mNotifyMgr.cancel(Notifications.exportAlertNotificationId); // this appears to confuse android wear version 2.0.0.141773014.gms even though it shouldn't - can we survive without this? mNotifyMgr.notify(Notifications.exportAlertNotificationId, XdripNotificationCompat.build(builder)); // send to bluejay BlueJayEntry.sendAlertIfEnabled((alert.above ? "High" : "Low") + " Alert " + bgValue + " " + alert.name); // string text is used to determine alert type // send alert to pebble if (Pref.getBooleanDefaultFalse("broadcast_to_pebble") && (Pref.getBooleanDefaultFalse("pebble_vibe_alerts"))) { if (JoH.ratelimit("pebble_vibe_start", 59)) { JoH.startService(PebbleWatchSync.class); } } //send alert to amazfit if (Pref.getBooleanDefaultFalse("pref_amazfit_enable_key") && Pref.getBooleanDefaultFalse("pref_amazfit_BG_alert_enable_key")) { Amazfitservice.start("xDrip_Alarm", alert.name, alert.default_snooze); } if (LeFunEntry.areAlertsEnabled() && ActiveBgAlert.currentlyAlerting()) { LeFun.sendAlert(highlow, bgValue); } if (MiBandEntry.areAlertsEnabled() && ActiveBgAlert.currentlyAlerting()) { MiBand.sendAlert(alert.name, highlow + " " + bgValue, alert.default_snooze); } // speak alert if (Pref.getBooleanDefaultFalse("speak_alerts")) { SpeechUtil.say(highlow + ", " + bgValue, 3000); } }
Example 15
Source File: Notifications.java From xDrip-plus with GNU General Public License v3.0 | 4 votes |
private static void OtherAlert(Context context, String type, String title, String message, int notificatioId, String channelId, boolean addDeleteIntent, long reraiseSec) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); String otherAlertsSound = prefs.getString(type+"_sound",prefs.getString("other_alerts_sound", "content://settings/system/notification_sound")); Boolean otherAlertsOverrideSilent = prefs.getBoolean("other_alerts_override_silent", false); Log.d(TAG,"OtherAlert called " + type + " " + message + " reraiseSec = " + reraiseSec); UserNotification userNotification = UserNotification.GetNotificationByType(type); //"bg_unclear_readings_alert" if ((userNotification == null) || userNotification.timestamp <= new Date().getTime() ) { if (userNotification != null) { try { userNotification.delete(); } catch (NullPointerException e) { // ignore null pointer exception during delete as we emulate database records } Log.d(TAG, "Delete"); } UserNotification.create(message, type, new Date().getTime() + reraiseSec * 1000); boolean localOnly =false; if (notificatioId == persistentHighAlertNotificationId) { localOnly = (Home.get_forced_wear() && bg_notifications_watch && bg_persistent_high_alert_enabled_watch); } Log.d(TAG,"OtherAlert forced_wear localOnly=" + localOnly); Intent intent = new Intent(context, Home.class); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context, channelId) .setVisibility(Pref.getBooleanDefaultFalse("public_notifications") ? Notification.VISIBILITY_PUBLIC : Notification.VISIBILITY_PRIVATE) .setSmallIcon(R.drawable.ic_action_communication_invert_colors_on) .setContentTitle(title) .setContentText(message) .setLocalOnly(localOnly) .setStyle(new NotificationCompat.BigTextStyle().bigText(message)) .setContentIntent(PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT)); if (addDeleteIntent) { Intent deleteIntent = new Intent(context, SnoozeOnNotificationDismissService.class); deleteIntent.putExtra("alertType", type); deleteIntent.putExtra("raisedTimeStamp", JoH.tsl()); mBuilder.setDeleteIntent(PendingIntent.getService(context, 0, deleteIntent, PendingIntent.FLAG_UPDATE_CURRENT)); } mBuilder.setVibrate(vibratePattern); mBuilder.setLights(0xff00ff00, 300, 1000); if (AlertPlayer.notSilencedDueToCall()) { if (otherAlertsOverrideSilent && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { mBuilder.setSound(Uri.parse(otherAlertsSound), AudioAttributes.USAGE_ALARM); } else { mBuilder.setSound(Uri.parse(otherAlertsSound)); } } NotificationManager mNotifyMgr = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); //mNotifyMgr.cancel(notificatioId); //Log.d(TAG, "Notify"); Log.ueh("Other Alert",message); mNotifyMgr.notify(notificatioId, XdripNotificationCompat.build(mBuilder)); if (Pref.getBooleanDefaultFalse("pref_amazfit_enable_key") && Pref.getBooleanDefaultFalse("pref_amazfit_other_alert_enable_key")) { Amazfitservice.start("xDrip_Otheralert", message, 30); } } }
Example 16
Source File: MissedReadingService.java From xDrip with GNU General Public License v3.0 | 4 votes |
@Override protected void onHandleIntent(Intent intent) { final boolean bg_missed_alerts; final PowerManager.WakeLock wl = JoH.getWakeLock("missed-reading-service", 60000); try { final boolean sensorActive = Sensor.isActive(); Log.d(TAG, "MissedReadingService onHandleIntent"); // test debug log final long stale_millis = Home.stale_data_millis(); // send to pebble if (Pref.getBoolean("broadcast_to_pebble", false) && (PebbleUtil.getCurrentPebbleSyncType() != 1) && !BgReading.last_within_millis(stale_millis)) { if (JoH.ratelimit("peb-miss", 120)) { // TODO replace ratelimit with Inevitable.task? JoH.startService(PebbleWatchSync.class); } // update pebble even when we don't have data to ensure missed readings show } if (LeFunEntry.isEnabled() && (!BgReading.last_within_millis(stale_millis))) { LeFun.showLatestBG(); } if ((Pref.getBoolean("aggressive_service_restart", false) || DexCollectionType.isFlakey())) {//!Home.get_enable_wear() && if (!BgReading.last_within_millis(stale_millis) && sensorActive && (!getLocalServiceCollectingState())) { if (JoH.ratelimit("aggressive-restart", aggressive_backoff_timer)) { Log.e(TAG, "Aggressively restarting collector service due to lack of reception: backoff: " + aggressive_backoff_timer); if (aggressive_backoff_timer < 1200) aggressive_backoff_timer += 60; CollectionServiceStarter.restartCollectionServiceBackground(); } else { aggressive_backoff_timer = 120; // reset } } } Reminder.processAnyDueReminders(); BluetoothGlucoseMeter.immortality(); XdripWebService.immortality(); // InPenEntry.immortality(); DesertSync.pullAsEnabled(); NanoStatus.keepFollowerUpdated(); LockScreenWallPaper.timerPoll(); // TODO functionalize the actual checking bg_missed_alerts = Pref.getBoolean("bg_missed_alerts", false); if (!bg_missed_alerts) { // we should not do anything in this case. if the ui, changes will be called again return; } if (!sensorActive) { // sensor not running we should return return; } if (!JoH.upForAtLeastMins(15)) { Log.d(TAG, "Uptime less than 15 minutes so not processing for missed reading"); return; } if ((Home.get_forced_wear()) && Pref.getBoolean("disable_wearG5_on_missedreadings", false)) { int bg_wear_missed_minutes = Pref.getStringToInt("disable_wearG5_on_missedreadings_level", 30); if (BgReading.getTimeSinceLastReading() >= (bg_wear_missed_minutes * 1000 * 60)) { Log.d(TAG, "Request WatchUpdaterService to disable force_wearG5 when wear is connected"); startWatchUpdaterService(xdrip.getAppContext(), WatchUpdaterService.ACTION_DISABLE_FORCE_WEAR, TAG); } } final int bg_missed_minutes = Pref.getStringToInt("bg_missed_minutes", 30); final long now = JoH.tsl(); // check if readings have been missed if (BgReading.getTimeSinceLastReading() >= (bg_missed_minutes * 1000 * 60) && Pref.getLong("alerts_disabled_until", 0) <= now && (BgReading.getTimeSinceLastReading() < (Constants.HOUR_IN_MS * 6)) && inTimeFrame()) { Notifications.bgMissedAlert(xdrip.getAppContext()); checkBackAfterSnoozeTime(xdrip.getAppContext(), now); } else { long disabletime = Pref.getLong("alerts_disabled_until", 0) - now; long missedTime = bg_missed_minutes * 1000 * 60 - BgReading.getTimeSinceLastReading(); long alarmIn = Math.max(disabletime, missedTime); checkBackAfterMissedTime(alarmIn); } } finally { JoH.releaseWakeLock(wl); } }
Example 17
Source File: DexShareCollectionService.java From xDrip with GNU General Public License v3.0 | 4 votes |
private static boolean shouldServiceRun(Context context) { if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) return false; final boolean result = CollectionServiceStarter.isBTShare(context) && !Home.get_forced_wear(); Log.d(TAG, "shouldServiceRun() returning: " + result); return result; }
Example 18
Source File: Notifications.java From xDrip with GNU General Public License v3.0 | 4 votes |
private static void OtherAlert(Context context, String type, String message, int notificatioId, boolean addDeleteIntent, long reraiseSec) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); String otherAlertsSound = prefs.getString(type+"_sound",prefs.getString("other_alerts_sound", "content://settings/system/notification_sound")); Boolean otherAlertsOverrideSilent = prefs.getBoolean("other_alerts_override_silent", false); Log.d(TAG,"OtherAlert called " + type + " " + message + " reraiseSec = " + reraiseSec); UserNotification userNotification = UserNotification.GetNotificationByType(type); //"bg_unclear_readings_alert" if ((userNotification == null) || userNotification.timestamp <= new Date().getTime() ) { if (userNotification != null) { try { userNotification.delete(); } catch (NullPointerException e) { // ignore null pointer exception during delete as we emulate database records } Log.d(TAG, "Delete"); } UserNotification.create(message, type, new Date().getTime() + reraiseSec * 1000); boolean localOnly =false;//KS if (notificatioId == persistentHighAlertNotificationId) { localOnly = (Home.get_forced_wear() && bg_notifications && bg_persistent_high_alert_enabled); } Log.d(TAG,"OtherAlert forced_wear localOnly=" + localOnly); Intent intent = new Intent(context, Home.class); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context) .setSmallIcon(R.drawable.ic_launcher)//KS ic_action_communication_invert_colors_on .setContentTitle(message) .setContentText(message) .setLocalOnly(localOnly)//KS .setContentIntent(PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT)); if (addDeleteIntent) { Intent deleteIntent = new Intent(context, SnoozeOnNotificationDismissService.class); deleteIntent.putExtra("alertType", type); mBuilder.setDeleteIntent(PendingIntent.getService(context, 0, deleteIntent, PendingIntent.FLAG_UPDATE_CURRENT)); } mBuilder.setVibrate(vibratePattern); mBuilder.setLights(0xff00ff00, 300, 1000); if (AlertPlayer.notSilencedDueToCall()) { if (otherAlertsOverrideSilent) { mBuilder.setSound(Uri.parse(otherAlertsSound), AudioAttributes.USAGE_ALARM); } else { mBuilder.setSound(Uri.parse(otherAlertsSound)); } } NotificationManager mNotifyMgr = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); //mNotifyMgr.cancel(notificatioId); //Log.d(TAG, "Notify"); Log.ueh("Other Alert",message); mNotifyMgr.notify(notificatioId, mBuilder.build()); } }
Example 19
Source File: AlertPlayer.java From xDrip with GNU General Public License v3.0 | 4 votes |
private void VibrateAudio(Context ctx, AlertType alert, String bgValue, Boolean overrideSilent, int timeFromStartPlaying) { Log.d(TAG, "Vibrate called timeFromStartPlaying = " + timeFromStartPlaying); Log.d("ALARM", "setting vibrate alarm"); int profile = getAlertProfile(ctx); if(alert.uuid.equals(AlertType.LOW_ALERT_55)) { // boost alerts... if(profile == ALERT_PROFILE_VIBRATE_ONLY) { profile = ALERT_PROFILE_ASCENDING; } } // We use timeFromStartPlaying as a way to force vibrating/ non vibrating... if (profile != ALERT_PROFILE_ASCENDING) { // We start from the non ascending part... timeFromStartPlaying = MAX_ASCENDING; } String title = bgValue + " " + alert.name; String content = "BG LEVEL ALERT: " + bgValue + " (@" + JoH.hourMinuteString() + ")"; Intent intent = new Intent(ctx, SnoozeActivity.class); boolean localOnly = (Home.get_forced_wear() && Pref.getBooleanDefaultFalse("bg_notifications"));//KS Log.d(TAG, "NotificationCompat.Builder localOnly=" + localOnly); NotificationCompat.Builder builder = new NotificationCompat.Builder(ctx)//KS Notification .setSmallIcon(R.drawable.ic_launcher)//KS ic_action_communication_invert_colors_on .setContentTitle(title) .setContentText(content) .setContentIntent(notificationIntent(ctx, intent)) .setLocalOnly(localOnly)//KS .setDeleteIntent(snoozeIntent(ctx)); if (profile != ALERT_PROFILE_VIBRATE_ONLY && profile != ALERT_PROFILE_SILENT) { if (timeFromStartPlaying >= MAX_VIBRATING) { // Before this, we only vibrate... float volumeFrac = (float)(timeFromStartPlaying - MAX_VIBRATING) / (MAX_ASCENDING - MAX_VIBRATING); volumeFrac = Math.min(volumeFrac, 1); if(profile == ALERT_PROFILE_MEDIUM) { volumeFrac = (float)0.7; } Log.d(TAG, "Vibrate volumeFrac = " + volumeFrac); boolean isRingTone = true;//KS TODO EditAlertActivity.isPathRingtone(ctx, alert.mp3_file); if (notSilencedDueToCall()) { if (isRingTone && !overrideSilent) { builder.setSound(Uri.parse(alert.mp3_file)); } else { if (overrideSilent || isLoudPhone(ctx)) { PlayFile(ctx, alert.mp3_file, volumeFrac); } } } else { Log.i(TAG,"Silenced Alert Noise due to ongoing call"); } } } if (profile != ALERT_PROFILE_SILENT && alert.vibrate) { if (notSilencedDueToCall()) { builder.setVibrate(Notifications.vibratePattern); } else { Log.i(TAG, "Vibration silenced due to ongoing call"); } } else { // In order to still show on all android wear watches, either a sound or a vibrate pattern // seems to be needed. This pattern basically does not vibrate: //KS ADD: // This code snippet will cause the phone to vibrate "SOS" in Morse Code // In Morse Code, "s" = "dot-dot-dot", "o" = "dash-dash-dash" // There are pauses to separate dots/dashes, letters, and words // The following numbers represent millisecond lengths int dot = 200; // Length of a Morse Code "dot" in milliseconds int dash = 500; // Length of a Morse Code "dash" in milliseconds int short_gap = 200; // Length of Gap Between dots/dashes int medium_gap = 500; // Length of Gap Between Letters int long_gap = 1000; // Length of Gap Between Words long[] pattern = { 0, // Start immediately dot, short_gap, dot, short_gap, dot, // s medium_gap, dash, short_gap, dash, short_gap, dash, // o medium_gap, dot, short_gap, dot, short_gap, dot, // s long_gap }; // Only perform this pattern one time (-1 means "do not repeat") //mVibrator.vibrate(pattern, -1); builder.setVibrate(pattern); //builder.setVibrate(new long[]{1, 0}); } Log.ueh("Alerting",content); NotificationManager mNotifyMgr = (NotificationManager) ctx.getSystemService(Context.NOTIFICATION_SERVICE); //mNotifyMgr.cancel(Notifications.exportAlertNotificationId); // this appears to confuse android wear version 2.0.0.141773014.gms even though it shouldn't - can we survive without this? mNotifyMgr.notify(Notifications.exportAlertNotificationId, builder.build()); /* //KS not used on watch if (Pref.getBooleanDefaultFalse("broadcast_to_pebble") && (Pref.getBooleanDefaultFalse("pebble_vibe_alerts"))) { if (JoH.ratelimit("pebble_vibe_start", 59)) { ctx.startService(new Intent(ctx, PebbleWatchSync.class)); } }*/ }
Example 20
Source File: MissedReadingService.java From xDrip-plus with GNU General Public License v3.0 | 4 votes |
@Override protected void onHandleIntent(Intent intent) { final boolean bg_missed_alerts; final PowerManager.WakeLock wl = JoH.getWakeLock("missed-reading-service", 60000); try { final boolean sensorActive = Sensor.isActive(); Log.d(TAG, "MissedReadingService onHandleIntent"); // test debug log final long stale_millis = Home.stale_data_millis(); // send to pebble if (Pref.getBoolean("broadcast_to_pebble", false) && (PebbleUtil.getCurrentPebbleSyncType() != 1) && !BgReading.last_within_millis(stale_millis)) { if (JoH.ratelimit("peb-miss", 120)) { // TODO replace ratelimit with Inevitable.task? JoH.startService(PebbleWatchSync.class); } // update pebble even when we don't have data to ensure missed readings show } if (LeFunEntry.isEnabled() && (!BgReading.last_within_millis(stale_millis))) { LeFun.showLatestBG(); } if ((Pref.getBoolean("aggressive_service_restart", false) || DexCollectionType.isFlakey())) {//!Home.get_enable_wear() && if (!BgReading.last_within_millis(stale_millis) && sensorActive && (!getLocalServiceCollectingState())) { if (JoH.ratelimit("aggressive-restart", aggressive_backoff_timer)) { Log.e(TAG, "Aggressively restarting collector service due to lack of reception: backoff: " + aggressive_backoff_timer); if (aggressive_backoff_timer < 1200) aggressive_backoff_timer += 60; CollectionServiceStarter.restartCollectionServiceBackground(); } else { aggressive_backoff_timer = 120; // reset } } } Reminder.processAnyDueReminders(); BluetoothGlucoseMeter.immortality(); XdripWebService.immortality(); // InPenEntry.immortality(); DesertSync.pullAsEnabled(); NanoStatus.keepFollowerUpdated(); LockScreenWallPaper.timerPoll(); // TODO functionalize the actual checking bg_missed_alerts = Pref.getBoolean("bg_missed_alerts", false); if (!bg_missed_alerts) { // we should not do anything in this case. if the ui, changes will be called again return; } if (!sensorActive) { // sensor not running we should return return; } if (!JoH.upForAtLeastMins(15)) { Log.d(TAG, "Uptime less than 15 minutes so not processing for missed reading"); return; } if ((Home.get_forced_wear()) && Pref.getBoolean("disable_wearG5_on_missedreadings", false)) { int bg_wear_missed_minutes = Pref.getStringToInt("disable_wearG5_on_missedreadings_level", 30); if (BgReading.getTimeSinceLastReading() >= (bg_wear_missed_minutes * 1000 * 60)) { Log.d(TAG, "Request WatchUpdaterService to disable force_wearG5 when wear is connected"); startWatchUpdaterService(xdrip.getAppContext(), WatchUpdaterService.ACTION_DISABLE_FORCE_WEAR, TAG); } } final int bg_missed_minutes = Pref.getStringToInt("bg_missed_minutes", 30); final long now = JoH.tsl(); // check if readings have been missed if (BgReading.getTimeSinceLastReading() >= (bg_missed_minutes * 1000 * 60) && Pref.getLong("alerts_disabled_until", 0) <= now && (BgReading.getTimeSinceLastReading() < (Constants.HOUR_IN_MS * 6)) && inTimeFrame()) { Notifications.bgMissedAlert(xdrip.getAppContext()); checkBackAfterSnoozeTime(xdrip.getAppContext(), now); } else { long disabletime = Pref.getLong("alerts_disabled_until", 0) - now; long missedTime = bg_missed_minutes * 1000 * 60 - BgReading.getTimeSinceLastReading(); long alarmIn = Math.max(disabletime, missedTime); checkBackAfterMissedTime(alarmIn); } } finally { JoH.releaseWakeLock(wl); } }