From 5d36470e506144f55e8560327d122f177e6f07ee Mon Sep 17 00:00:00 2001 From: Eric House Date: Tue, 29 Jan 2019 11:15:46 -0800 Subject: [PATCH] add some logging around RelayService lifecycle --- .../eehouse/android/xw4/RelayReceiver.java | 2 ++ .../org/eehouse/android/xw4/RelayService.java | 34 +++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/RelayReceiver.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/RelayReceiver.java index 8367f9789..9768f1786 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/RelayReceiver.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/RelayReceiver.java @@ -28,10 +28,12 @@ import android.content.Intent; import android.os.SystemClock; public class RelayReceiver extends BroadcastReceiver { + private static final String TAG = RelayReceiver.class.getSimpleName(); @Override public void onReceive( Context context, Intent intent ) { + Log.d( TAG, "onReceive(intent=%s)", intent ); RelayService.timerFired( context ); } diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/RelayService.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/RelayService.java index ecd37e431..dbd854184 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/RelayService.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/RelayService.java @@ -25,6 +25,7 @@ import android.content.Context; import android.content.Intent; import android.os.Build; import android.os.Handler; +import android.support.annotation.Nullable; import android.support.v4.app.JobIntentService; import android.text.TextUtils; @@ -205,6 +206,7 @@ public class RelayService extends JobIntentService Log.d( TAG, "calling enqueueWork(id=%d, cmd=%s)", sJobID, cmdFrom( intent ) ); enqueueWork( context, RelayService.class, sJobID, intent ); + Log.d( TAG, "enqueueWork() returned" ); } private static MsgCmds cmdFrom( Intent intent ) @@ -375,11 +377,13 @@ public class RelayService extends JobIntentService Log.d( TAG, "%s.onHandleWork(cmd=%s)", this, cmdFrom( intent ) ); handleCommand( intent ); resetExitTimer(); + Log.d( TAG, "%s.onHandleWork(cmd=%s) DONE", this, cmdFrom( intent ) ); } @Override public void onDestroy() { + Log.d( TAG, "onDestroy() called" ); if ( shouldMaintainConnection() ) { long interval_millis = getMaxIntervalSeconds() * 1000; RelayReceiver.setTimer( this, interval_millis ); @@ -391,6 +395,36 @@ public class RelayService extends JobIntentService Log.d( TAG, "%s.onDestroy() DONE", this ); } + @Override + public boolean onStopCurrentWork() { + Log.d( TAG, "onStopCurrentWork() called"); + boolean result = super.onStopCurrentWork(); + Log.d( TAG, "onStopCurrentWork() => %b", result); + return result; + } + + @Override + public void onTaskRemoved(Intent rootIntent) { + Log.d( TAG, "onTaskRemoved() called"); + super.onTaskRemoved(rootIntent); + Log.d( TAG, "onTaskRemoved() => (void)"); + } + + @Override + public int onStartCommand(@Nullable Intent intent, int flags, int startId) { + Log.d( TAG, "onStartCommand(%s) called", intent ); + int result = super.onStartCommand(intent, flags, startId ); + Log.d( TAG, "onStartCommand() => %d", result ); + return result; + } + + @Override + public void onLowMemory() { + Log.d( TAG, "onLowMemory() called" ); + super.onLowMemory(); + Log.d( TAG, "onLowMemory() => void" ); + } + // NetStateCache.StateChangedIf interface @Override public void onNetAvail( boolean nowAvailable )