From c8abe84a8289b1f810070fb04507c6afc01df898 Mon Sep 17 00:00:00 2001 From: Aleksander Nowakowski Date: Fri, 17 Nov 2017 15:50:46 +0100 Subject: [PATCH] Logging improved --- .../main/java/no/nordicsemi/android/dfu/DfuBaseService.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/dfu/src/main/java/no/nordicsemi/android/dfu/DfuBaseService.java b/dfu/src/main/java/no/nordicsemi/android/dfu/DfuBaseService.java index af46b1a..d16fccd 100644 --- a/dfu/src/main/java/no/nordicsemi/android/dfu/DfuBaseService.java +++ b/dfu/src/main/java/no/nordicsemi/android/dfu/DfuBaseService.java @@ -839,8 +839,8 @@ public abstract class DfuBaseService extends IntentService implements DfuProgres public void onCreate() { super.onCreate(); - Log.i(TAG, "DFU version: " + BuildConfig.VERSION_NAME); DEBUG = isDebug(); + logi("DFU service created. Version: " + BuildConfig.VERSION_NAME); initialize(); final LocalBroadcastManager manager = LocalBroadcastManager.getInstance(this); @@ -932,6 +932,10 @@ public abstract class DfuBaseService extends IntentService implements DfuProgres // This would eventually crash later... throw new NullPointerException("getNotificationTarget() must not return null if notifications are enabled"); } + if (!foregroundService && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + logw("Foreground service disabled. Android Oreo or newer may kill a background service few moments after user closes the application.\n" + + "Consider enabling foreground service using DfuServiceInitiator#setForeground(boolean)"); + } UuidHelper.assignCustomUuids(intent); mDeviceAddress = deviceAddress;