public static void scheduleNotification(Context context, String title, String body, int delaySeconds, int notification_id) { final Intent notificationIntent = new Intent(context, Home.class).putExtra(Home.SHOW_NOTIFICATION, title).putExtra("notification_body", body).putExtra("notification_id", notification_id); final PendingIntent pendingIntent = PendingIntent.getActivity(context, notification_id, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT); Log.d(TAG, "Scheduling notification: " + title + " / " + body); wakeUpIntent(context, delaySeconds * 1000, pendingIntent); }
public static void scheduleNotification(Context context, String title, String body, int delaySeconds, int notification_id) { final Intent notificationIntent = new Intent(context, Home.class).putExtra(Home.SHOW_NOTIFICATION, title).putExtra("notification_body", body).putExtra("notification_id", notification_id); final PendingIntent pendingIntent = PendingIntent.getActivity(context, notification_id, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT); Log.d(TAG, "Scheduling notification: " + title + " / " + body); wakeUpIntent(context, delaySeconds * 1000, pendingIntent); }
public static void scheduleNotification(Context context, String title, String body, int delaySeconds, int notification_id) { final Intent notificationIntent = new Intent(context, Home.class).putExtra(Home.SHOW_NOTIFICATION, title).putExtra("notification_body", body).putExtra("notification_id", notification_id); final PendingIntent pendingIntent = PendingIntent.getActivity(context, notification_id, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT); Log.d(TAG, "Scheduling notification: " + title + " / " + body); wakeUpIntent(context, delaySeconds * 1000, pendingIntent); }
public void setAlarm(long alarmIn, boolean force) { if (!force && (alarmIn < 5 * 60 * 1000)) { // No need to check more than once every 5 minutes alarmIn = 5 * 60 * 1000; } alarmIn = Math.max(alarmIn, 5000); // don't try to set less than 5 seconds in the future Log.d(TAG, "Setting timer to " + alarmIn / 60000 + " minutes from now"); initializeServiceIntent(); JoH.wakeUpIntent(this, alarmIn, serviceIntent); }
public void setAlarm(long alarmIn, boolean force) { if (!force && (alarmIn < 5 * 60 * 1000)) { // No need to check more than once every 5 minutes alarmIn = 5 * 60 * 1000; } alarmIn = Math.max(alarmIn, 5000); // don't try to set less than 5 seconds in the future Log.d(TAG, "Setting timer to " + alarmIn / 60000 + " minutes from now"); initializeServiceIntent(); JoH.wakeUpIntent(this, alarmIn, serviceIntent); }
public void setRetryTimer() { mStaticState = mConnectionState; if (shouldServiceRun()) { //final long retry_in = (Constants.SECOND_IN_MS * 25); final long retry_in = whenToRetryNext(); Log.d(TAG, "setRetryTimer: Restarting in: " + (retry_in / Constants.SECOND_IN_MS) + " seconds"); serviceIntent = PendingIntent.getService(this, Constants.DEX_COLLECTION_SERVICE_RETRY_ID, new Intent(this, this.getClass()), 0); retry_time = JoH.wakeUpIntent(this, retry_in, serviceIntent); } else { Log.d(TAG, "Not setting retry timer as service should not be running"); } }
public synchronized void setFailoverTimer() { if (shouldServiceRun()) { final long retry_in = use_polling ? whenToPollNext() : (Constants.MINUTE_IN_MS * 6); Log.d(TAG, "setFailoverTimer: Fallover Restarting in: " + (retry_in / (Constants.MINUTE_IN_MS)) + " minutes"); serviceFailoverIntent = PendingIntent.getService(this, Constants.DEX_COLLECTION_SERVICE_FAILOVER_ID, new Intent(this, this.getClass()), 0); failover_time = JoH.wakeUpIntent(this, retry_in, serviceFailoverIntent); retry_time = 0; // only one alarm will run } else { stopSelf(); } }
public static void startSyncService(long delay) { Log.d("SyncService", "static starting Sync service delay: " + delay); if (delay == 0) { xdrip.getAppContext().startService(new Intent(xdrip.getAppContext(), SyncService.class)); } else { final PendingIntent serviceIntent = PendingIntent.getService(xdrip.getAppContext(), SYNC_QUEUE_RETRY_ID, new Intent(xdrip.getAppContext(), SyncService.class), PendingIntent.FLAG_CANCEL_CURRENT); JoH.wakeUpIntent(xdrip.getAppContext(), delay, serviceIntent); } } }
public static void startSyncService(long delay) { Log.d("SyncService", "static starting Sync service delay: " + delay); if (delay == 0) { xdrip.getAppContext().startService(new Intent(xdrip.getAppContext(), SyncService.class)); } else { final PendingIntent serviceIntent = PendingIntent.getService(xdrip.getAppContext(), SYNC_QUEUE_RETRY_ID, new Intent(xdrip.getAppContext(), SyncService.class), PendingIntent.FLAG_CANCEL_CURRENT); JoH.wakeUpIntent(xdrip.getAppContext(), delay, serviceIntent); } } }
public static void hardReset() { JoH.wakeUpIntent(xdrip.getAppContext(), 1000, Home.getHomePendingIntent()); hardReset_orig(); }
public synchronized void setFailoverTimer() { if (shouldServiceRun()) { final long retry_in = use_polling ? whenToPollNext() : (Constants.MINUTE_IN_MS * 6); Log.d(TAG, "setFailoverTimer: Fallover Restarting in: " + (retry_in / (Constants.MINUTE_IN_MS)) + " minutes"); //serviceFailoverIntent = PendingIntent.getService(this, Constants.DEX_COLLECTION_SERVICE_FAILOVER_ID, new Intent(this, this.getClass()), 0); serviceFailoverIntent = WakeLockTrampoline.getPendingIntent(this.getClass(), Constants.DEX_COLLECTION_SERVICE_FAILOVER_ID); failover_time = JoH.wakeUpIntent(this, retry_in, serviceFailoverIntent); retry_time = 0; // only one alarm will run } else { stopSelf(); } }
private void scheduleWakeUp(long future, final String info) { if (future <= 0) future = 5000; UserError.Log.d(TAG, "Scheduling wakeup @ " + JoH.dateTimeText(JoH.tsl() + future) + " (" + info + ")"); if (pendingIntent == null) //pendingIntent = PendingIntent.getService(this, 0, new Intent(this, this.getClass()), 0); pendingIntent = WakeLockTrampoline.getPendingIntent(this.getClass()); wakeup_time = JoH.tsl() + future; JoH.wakeUpIntent(this, future, pendingIntent); }
public synchronized void setFailoverTimer() { if (shouldServiceRun()) { final long retry_in = use_polling ? whenToPollNext() : (Constants.MINUTE_IN_MS * 6); Log.d(TAG, "setFailoverTimer: Fallover Restarting in: " + (retry_in / (Constants.MINUTE_IN_MS)) + " minutes"); //serviceFailoverIntent = PendingIntent.getService(this, Constants.DEX_COLLECTION_SERVICE_FAILOVER_ID, new Intent(this, this.getClass()), 0); serviceFailoverIntent = WakeLockTrampoline.getPendingIntent(this.getClass(), Constants.DEX_COLLECTION_SERVICE_FAILOVER_ID); failover_time = JoH.wakeUpIntent(this, retry_in, serviceFailoverIntent); retry_time = 0; // only one alarm will run } else { stopSelf(); } }
private void setFailOverTimer() { if (Home.get_follower()) { final long retry_in = (5 * 60 * 1000); UserError.Log.d(TAG, "setFailoverTimer: Restarting in: " + (retry_in / (60 * 1000)) + " minutes"); nextWakeUpTime = JoH.tsl() + retry_in; //final PendingIntent wakeIntent = PendingIntent.getService(this, 0, new Intent(this, this.getClass()), 0); final PendingIntent wakeIntent = WakeLockTrampoline.getPendingIntent(this.getClass()); JoH.wakeUpIntent(this, retry_in, wakeIntent); } else { stopSelf(); } }
private void scheduleWakeUp(long future, final String info) { if (future <= 0) future = 5000; UserError.Log.d(TAG, "Scheduling wakeup @ " + JoH.dateTimeText(JoH.tsl() + future) + " (" + info + ")"); if (pendingIntent == null) //pendingIntent = PendingIntent.getService(this, 0, new Intent(this, this.getClass()), 0); pendingIntent = WakeLockTrampoline.getPendingIntent(this.getClass()); wakeup_time = JoH.tsl() + future; JoH.wakeUpIntent(this, future, pendingIntent); }
private void setFailOverTimer() { if (Home.get_follower()) { final long retry_in = (5 * 60 * 1000); UserError.Log.d(TAG, "setFailoverTimer: Restarting in: " + (retry_in / (60 * 1000)) + " minutes"); nextWakeUpTime = JoH.tsl() + retry_in; //final PendingIntent wakeIntent = PendingIntent.getService(this, 0, new Intent(this, this.getClass()), 0); final PendingIntent wakeIntent = WakeLockTrampoline.getPendingIntent(this.getClass()); JoH.wakeUpIntent(this, retry_in, wakeIntent); } else { stopSelf(); } }
private void scheduleWakeUp(long future, final String info) { if (future <= 0) future = 5000; UserError.Log.d(TAG, "Scheduling wakeup @ " + JoH.dateTimeText(JoH.tsl() + future) + " (" + info + ")"); if (pendingIntent == null) //pendingIntent = PendingIntent.getService(this, 0, new Intent(this, this.getClass()), 0); pendingIntent = WakeLockTrampoline.getPendingIntent(this.getClass()); wakeup_time = JoH.tsl() + future; JoH.wakeUpIntent(this, future, pendingIntent); }
@Override protected void setRetryTimerReal() { if (shouldServiceRun()) { final long retry_in = whenToRetryNext(); UserError.Log.d(TAG, "setRetryTimer: Restarting in: " + (retry_in / Constants.SECOND_IN_MS) + " seconds"); I.serviceIntent = WakeLockTrampoline.getPendingIntent(this.getClass(), Constants.LEFUN_SERVICE_RETRY_ID); //PendingIntent.getService(xdrip.getAppContext(), Constants.LEFUN_SERVICE_RETRY_ID, // new Intent(xdrip.getAppContext(), this.getClass()), 0); I.retry_time = JoH.wakeUpIntent(xdrip.getAppContext(), retry_in, I.serviceIntent); I.wakeup_time = JoH.tsl() + retry_in; } else { UserError.Log.d(TAG, "Not setting retry timer as service should not be running"); } }
static void scheduleWakeUp() { final BgReading lastBg = BgReading.lastNoSenssor(); final long last = lastBg != null ? lastBg.timestamp : 0; final long grace = Constants.SECOND_IN_MS * 10; final long next = Anticipate.next(JoH.tsl(), last, SAMPLE_PERIOD, grace) + grace; UserError.Log.d(TAG, "Anticipate next: " + JoH.dateTimeText(next) + " last: " + JoH.dateTimeText(last)); JoH.wakeUpIntent(xdrip.getAppContext(), JoH.msTill(next), WakeLockTrampoline.getPendingIntent(NightscoutFollowService.class, Constants.NSFOLLOW_SERVICE_FAILOVER_ID)); }
static void scheduleWakeUp() { final BgReading lastBg = BgReading.lastNoSenssor(); final long last = lastBg != null ? lastBg.timestamp : 0; final long grace = Constants.SECOND_IN_MS * 10; final long next = Anticipate.next(JoH.tsl(), last, SAMPLE_PERIOD, grace) + grace; UserError.Log.d(TAG, "Anticipate next: " + JoH.dateTimeText(next) + " last: " + JoH.dateTimeText(last)); JoH.wakeUpIntent(xdrip.getAppContext(), JoH.msTill(next), WakeLockTrampoline.getPendingIntent(NightscoutFollowService.class, Constants.NSFOLLOW_SERVICE_FAILOVER_ID)); }