@Override public Integer receive(Context context, Intent intent, Integer tmpWakeLockId) { if (K9.DEBUG) Log.i(K9.LOG_TAG, "BootReceiver.onReceive" + intent); final String action = intent.getAction(); if (Intent.ACTION_BOOT_COMPLETED.equals(action)) { // K9.setServicesEnabled(context, tmpWakeLockId); // tmpWakeLockId = null; } else if (Intent.ACTION_DEVICE_STORAGE_LOW.equals(action)) { MailService.actionCancel(context, tmpWakeLockId); tmpWakeLockId = null; } else if (Intent.ACTION_DEVICE_STORAGE_OK.equals(action)) { MailService.actionReset(context, tmpWakeLockId); tmpWakeLockId = null; } else if (ConnectivityManager.CONNECTIVITY_ACTION.equals(action)) { MailService.connectivityChange(context, tmpWakeLockId); tmpWakeLockId = null; } else if ("com.android.sync.SYNC_CONN_STATUS_CHANGED".equals(action)) { K9.BACKGROUND_OPS bOps = K9.getBackgroundOps(); if (bOps == K9.BACKGROUND_OPS.WHEN_CHECKED_AUTO_SYNC) { MailService.actionReset(context, tmpWakeLockId); tmpWakeLockId = null; } } else if (FIRE_INTENT.equals(action)) { Intent alarmedIntent = intent.getParcelableExtra(ALARMED_INTENT); String alarmedAction = alarmedIntent.getAction(); if (K9.DEBUG) Log.i(K9.LOG_TAG, "BootReceiver Got alarm to fire alarmedIntent " + alarmedAction); alarmedIntent.putExtra(WAKE_LOCK_ID, tmpWakeLockId); tmpWakeLockId = null; context.startService(alarmedIntent); } else if (SCHEDULE_INTENT.equals(action)) { long atTime = intent.getLongExtra(AT_TIME, -1); Intent alarmedIntent = intent.getParcelableExtra(ALARMED_INTENT); if (K9.DEBUG) Log.i( K9.LOG_TAG, "BootReceiver Scheduling intent " + alarmedIntent + " for " + new Date(atTime)); PendingIntent pi = buildPendingIntent(context, intent); K9AlarmManager alarmMgr = K9AlarmManager.getAlarmManager(context); alarmMgr.set(AlarmManager.RTC_WAKEUP, atTime, pi); } else if (CANCEL_INTENT.equals(action)) { Intent alarmedIntent = intent.getParcelableExtra(ALARMED_INTENT); if (K9.DEBUG) Log.i(K9.LOG_TAG, "BootReceiver Canceling alarmedIntent " + alarmedIntent); PendingIntent pi = buildPendingIntent(context, intent); K9AlarmManager alarmMgr = K9AlarmManager.getAlarmManager(context); alarmMgr.cancel(pi); } return tmpWakeLockId; }
@Override public void onReceive(Context context, Intent intent) { if (intent != null && mSession != null) { final String action = intent.getAction(); if (Intent.ACTION_DEVICE_STORAGE_LOW.equals(action)) { Log.d(TAG, " Memory Full "); sendMnsEventMemory(MEMORY_FULL); } else if (Intent.ACTION_DEVICE_STORAGE_OK.equals(action)) { Log.d(TAG, " Memory Available "); sendMnsEventMemory(MEMORY_AVAILABLE); } } }