Revert "DataService as JobIntentService"

This reverts commit e0c2e7d579.
This commit is contained in:
Milos Kozak 2019-08-26 15:06:34 +02:00
parent c653a95912
commit b04641e466
3 changed files with 35 additions and 35 deletions

View file

@ -153,8 +153,7 @@
<!-- Service processing incomming data --> <!-- Service processing incomming data -->
<service <service
android:name=".services.DataService" android:name=".services.DataService"
android:exported="false" android:exported="false" />
android:permission="android.permission.BIND_JOB_SERVICE"/>
<service <service
android:name=".services.LocationService" android:name=".services.LocationService"
android:exported="false" /> android:exported="false" />
@ -173,7 +172,7 @@
<service <service
android:name=".plugins.pump.danaRS.services.DanaRSService" android:name=".plugins.pump.danaRS.services.DanaRSService"
android:enabled="true" android:enabled="true"
android:exported="false" /> android:exported="true" />
<service <service
android:name=".plugins.general.wear.wearintegration.WatchUpdaterService" android:name=".plugins.general.wear.wearintegration.WatchUpdaterService"
android:exported="true"> android:exported="true">
@ -240,11 +239,11 @@
<service <service
android:name=".plugins.general.nsclient.services.NSClientService" android:name=".plugins.general.nsclient.services.NSClientService"
android:enabled="true" android:enabled="true"
android:exported="false" /> android:exported="true" />
<service <service
android:name=".services.AlarmSoundService" android:name=".services.AlarmSoundService"
android:enabled="true" android:enabled="true"
android:exported="false" /> android:exported="true" />
<service <service
android:name=".plugins.general.overview.notifications.DismissNotificationService" android:name=".plugins.general.overview.notifications.DismissNotificationService"
android:exported="false" /> android:exported="false" />
@ -285,7 +284,7 @@
<service <service
android:name=".plugins.pump.medtronic.service.RileyLinkMedtronicService" android:name=".plugins.pump.medtronic.service.RileyLinkMedtronicService"
android:enabled="true" android:enabled="true"
android:exported="false" /> android:exported="true" />
<activity android:name=".plugins.pump.common.dialog.RileyLinkBLEScanActivity"> <activity android:name=".plugins.pump.common.dialog.RileyLinkBLEScanActivity">
<intent-filter> <intent-filter>
<action android:name="info.nightscout.androidaps.plugins.PumpCommon.dialog.RileyLinkBLEScanActivity" /> <action android:name="info.nightscout.androidaps.plugins.PumpCommon.dialog.RileyLinkBLEScanActivity" />

View file

@ -1,9 +1,8 @@
package info.nightscout.androidaps.receivers; package info.nightscout.androidaps.receivers;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import androidx.legacy.content.WakefulBroadcastReceiver;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -11,16 +10,15 @@ import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.services.DataService; import info.nightscout.androidaps.services.DataService;
public class DataReceiver extends BroadcastReceiver { public class DataReceiver extends WakefulBroadcastReceiver {
private static Logger log = LoggerFactory.getLogger(L.DATASERVICE); private static Logger log = LoggerFactory.getLogger(L.DATASERVICE);
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
if (L.isEnabled(L.DATASERVICE)) if (L.isEnabled(L.DATASERVICE))
log.debug("onReceive " + intent); log.debug("onReceive " + intent);
// Explicitly specify that GcmIntentService will handle the intent. startWakefulService(context, new Intent(context, DataService.class)
ComponentName comp = new ComponentName(context.getPackageName(), .setAction(intent.getAction())
DataService.class.getName()); .putExtras(intent));
DataService.enqueueWork(context, intent.setComponent(comp));
} }
} }

View file

@ -1,13 +1,10 @@
package info.nightscout.androidaps.services; package info.nightscout.androidaps.services;
import android.content.Context; import android.app.IntentService;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.provider.Telephony; import android.provider.Telephony;
import androidx.annotation.NonNull;
import androidx.core.app.JobIntentService;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
@ -19,16 +16,15 @@ import info.nightscout.androidaps.R;
import info.nightscout.androidaps.db.CareportalEvent; import info.nightscout.androidaps.db.CareportalEvent;
import info.nightscout.androidaps.events.EventNsFood; import info.nightscout.androidaps.events.EventNsFood;
import info.nightscout.androidaps.events.EventNsTreatment; import info.nightscout.androidaps.events.EventNsTreatment;
import info.nightscout.androidaps.logging.BundleLogger;
import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.general.nsclient.data.NSDeviceStatus; import info.nightscout.androidaps.plugins.general.nsclient.data.NSDeviceStatus;
import info.nightscout.androidaps.plugins.general.nsclient.data.NSMbg; import info.nightscout.androidaps.plugins.general.nsclient.data.NSMbg;
import info.nightscout.androidaps.plugins.general.nsclient.data.NSSettingsStatus; import info.nightscout.androidaps.plugins.general.nsclient.data.NSSettingsStatus;
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification; import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification;
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification; import info.nightscout.androidaps.plugins.general.overview.notifications.Notification;
import info.nightscout.androidaps.plugins.general.smsCommunicator.SmsCommunicatorPlugin;
import info.nightscout.androidaps.plugins.profile.ns.NSProfilePlugin; import info.nightscout.androidaps.plugins.profile.ns.NSProfilePlugin;
import info.nightscout.androidaps.plugins.pump.danaR.activities.DanaRNSHistorySync; import info.nightscout.androidaps.plugins.pump.danaR.activities.DanaRNSHistorySync;
import info.nightscout.androidaps.plugins.general.smsCommunicator.SmsCommunicatorPlugin;
import info.nightscout.androidaps.plugins.source.SourceDexcomPlugin; import info.nightscout.androidaps.plugins.source.SourceDexcomPlugin;
import info.nightscout.androidaps.plugins.source.SourceEversensePlugin; import info.nightscout.androidaps.plugins.source.SourceEversensePlugin;
import info.nightscout.androidaps.plugins.source.SourceGlimpPlugin; import info.nightscout.androidaps.plugins.source.SourceGlimpPlugin;
@ -38,30 +34,21 @@ import info.nightscout.androidaps.plugins.source.SourcePoctechPlugin;
import info.nightscout.androidaps.plugins.source.SourceTomatoPlugin; import info.nightscout.androidaps.plugins.source.SourceTomatoPlugin;
import info.nightscout.androidaps.plugins.source.SourceXdripPlugin; import info.nightscout.androidaps.plugins.source.SourceXdripPlugin;
import info.nightscout.androidaps.receivers.DataReceiver; import info.nightscout.androidaps.receivers.DataReceiver;
import info.nightscout.androidaps.logging.BundleLogger;
import info.nightscout.androidaps.utils.JsonHelper; import info.nightscout.androidaps.utils.JsonHelper;
import info.nightscout.androidaps.utils.SP; import info.nightscout.androidaps.utils.SP;
public class DataService extends JobIntentService { public class DataService extends IntentService {
private Logger log = LoggerFactory.getLogger(L.DATASERVICE); private Logger log = LoggerFactory.getLogger(L.DATASERVICE);
// Service unique ID public DataService() {
static final int SERVICE_JOB_ID = 4378; super("DataService");
registerBus();
// Enqueuing work in to this service.
public static void enqueueWork(Context context, Intent work) {
enqueueWork(context, DataService.class, SERVICE_JOB_ID, work);
} }
@Override @Override
public void onDestroy() { protected void onHandleIntent(final Intent intent) {
super.onDestroy();
if (L.isEnabled(L.DATASERVICE))
log.debug("All work complete");
}
@Override
protected void onHandleWork(@NonNull Intent intent) {
if (L.isEnabled(L.DATASERVICE)) { if (L.isEnabled(L.DATASERVICE)) {
log.debug("onHandleIntent " + intent); log.debug("onHandleIntent " + intent);
log.debug("onHandleIntent " + BundleLogger.log(intent.getExtras())); log.debug("onHandleIntent " + BundleLogger.log(intent.getExtras()));
@ -121,6 +108,22 @@ public class DataService extends JobIntentService {
if (L.isEnabled(L.DATASERVICE)) if (L.isEnabled(L.DATASERVICE))
log.debug("onHandleIntent exit " + intent); log.debug("onHandleIntent exit " + intent);
DataReceiver.completeWakefulIntent(intent);
}
@Override
public void onDestroy() {
super.onDestroy();
MainApp.bus().unregister(this);
}
private void registerBus() {
try {
MainApp.bus().unregister(this);
} catch (RuntimeException x) {
// Ignore
}
MainApp.bus().register(this);
} }
private void handleNewDataFromNSClient(Intent intent) { private void handleNewDataFromNSClient(Intent intent) {