DataService refactor
This commit is contained in:
parent
51d363d467
commit
533433afd8
3 changed files with 25 additions and 26 deletions
|
@ -3,6 +3,7 @@ package info.nightscout.androidaps.dependencyInjection
|
|||
import dagger.Module
|
||||
import dagger.android.ContributesAndroidInjector
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.RileyLinkBluetoothStateReceiver
|
||||
import info.nightscout.androidaps.receivers.DataReceiver
|
||||
import info.nightscout.androidaps.receivers.KeepAliveReceiver
|
||||
import info.nightscout.androidaps.receivers.NetworkChangeReceiver
|
||||
import info.nightscout.androidaps.receivers.TimeDateOrTZChangeReceiver
|
||||
|
@ -11,8 +12,9 @@ import info.nightscout.androidaps.receivers.TimeDateOrTZChangeReceiver
|
|||
@Suppress("unused")
|
||||
abstract class ReceiversModule {
|
||||
|
||||
@ContributesAndroidInjector abstract fun contributesDataReceiver(): DataReceiver
|
||||
@ContributesAndroidInjector abstract fun contributesKeepAliveReceiver(): KeepAliveReceiver
|
||||
@ContributesAndroidInjector abstract fun contributesNetworkChangeReceiver(): NetworkChangeReceiver
|
||||
@ContributesAndroidInjector abstract fun contributesTimeDateOrTZChangeReceiver(): TimeDateOrTZChangeReceiver
|
||||
@ContributesAndroidInjector abstract fun contributesRileyLinkBluetoothStateReceiver(): RileyLinkBluetoothStateReceiver
|
||||
@ContributesAndroidInjector abstract fun contributesTimeDateOrTZChangeReceiver(): TimeDateOrTZChangeReceiver
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
package info.nightscout.androidaps.receivers;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import androidx.legacy.content.WakefulBroadcastReceiver;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
||||
import info.nightscout.androidaps.services.DataService;
|
||||
|
||||
public class DataReceiver extends WakefulBroadcastReceiver {
|
||||
private static Logger log = StacktraceLoggerWrapper.getLogger(L.DATASERVICE);
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (L.isEnabled(L.DATASERVICE))
|
||||
log.debug("onReceive " + intent);
|
||||
startWakefulService(context, new Intent(context, DataService.class)
|
||||
.setAction(intent.getAction())
|
||||
.putExtras(intent));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package info.nightscout.androidaps.receivers
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import androidx.legacy.content.WakefulBroadcastReceiver
|
||||
import dagger.android.AndroidInjection
|
||||
import info.nightscout.androidaps.logging.AAPSLogger
|
||||
import info.nightscout.androidaps.logging.LTag
|
||||
import info.nightscout.androidaps.services.DataService
|
||||
import javax.inject.Inject
|
||||
|
||||
open class DataReceiver : WakefulBroadcastReceiver() {
|
||||
@Inject lateinit var aapsLogger: AAPSLogger
|
||||
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
AndroidInjection.inject(this, context)
|
||||
aapsLogger.debug(LTag.DATASERVICE, "onReceive $intent")
|
||||
startWakefulService(context, Intent(context, DataService::class.java)
|
||||
.setAction(intent.action)
|
||||
.putExtras(intent))
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue