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

View file

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

View file

@ -1,13 +1,10 @@
package info.nightscout.androidaps.services;
import android.content.Context;
import android.app.IntentService;
import android.content.Intent;
import android.os.Bundle;
import android.provider.Telephony;
import androidx.annotation.NonNull;
import androidx.core.app.JobIntentService;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
@ -19,16 +16,15 @@ import info.nightscout.androidaps.R;
import info.nightscout.androidaps.db.CareportalEvent;
import info.nightscout.androidaps.events.EventNsFood;
import info.nightscout.androidaps.events.EventNsTreatment;
import info.nightscout.androidaps.logging.BundleLogger;
import info.nightscout.androidaps.logging.L;
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.NSSettingsStatus;
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification;
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.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.SourceEversensePlugin;
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.SourceXdripPlugin;
import info.nightscout.androidaps.receivers.DataReceiver;
import info.nightscout.androidaps.logging.BundleLogger;
import info.nightscout.androidaps.utils.JsonHelper;
import info.nightscout.androidaps.utils.SP;
public class DataService extends JobIntentService {
public class DataService extends IntentService {
private Logger log = LoggerFactory.getLogger(L.DATASERVICE);
// Service unique ID
static final int SERVICE_JOB_ID = 4378;
// Enqueuing work in to this service.
public static void enqueueWork(Context context, Intent work) {
enqueueWork(context, DataService.class, SERVICE_JOB_ID, work);
public DataService() {
super("DataService");
registerBus();
}
@Override
public void onDestroy() {
super.onDestroy();
if (L.isEnabled(L.DATASERVICE))
log.debug("All work complete");
}
@Override
protected void onHandleWork(@NonNull Intent intent) {
protected void onHandleIntent(final Intent intent) {
if (L.isEnabled(L.DATASERVICE)) {
log.debug("onHandleIntent " + intent);
log.debug("onHandleIntent " + BundleLogger.log(intent.getExtras()));
@ -113,7 +100,7 @@ public class DataService extends JobIntentService {
Intents.ACTION_REMOVED_TREATMENT.equals(action) ||
Intents.ACTION_NEW_CAL.equals(action) ||
Intents.ACTION_NEW_MBG.equals(action))
) {
) {
handleNewDataFromNSClient(intent);
} else if (Telephony.Sms.Intents.SMS_RECEIVED_ACTION.equals(action)) {
SmsCommunicatorPlugin.getPlugin().handleNewData(intent);
@ -121,6 +108,22 @@ public class DataService extends JobIntentService {
if (L.isEnabled(L.DATASERVICE))
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) {