Wakeful receivers only handle non-null intents

This commit is contained in:
Marvin W 2021-03-09 22:21:25 +01:00
parent 87465cd1dd
commit ecfe3da3f7
No known key found for this signature in database
GPG Key ID: 072E9235DB996F2A
3 changed files with 10 additions and 7 deletions

View File

@ -95,7 +95,9 @@ public class CheckinService extends IntentService {
} catch (Exception e) { } catch (Exception e) {
Log.w(TAG, e); Log.w(TAG, e);
} finally { } finally {
WakefulBroadcastReceiver.completeWakefulIntent(intent); if (intent != null) {
WakefulBroadcastReceiver.completeWakefulIntent(intent);
}
schedule(this); schedule(this);
stopSelf(); stopSelf();
} }

View File

@ -320,7 +320,7 @@ public class McsService extends Service implements Handler.Callback {
WakefulBroadcastReceiver.completeWakefulIntent(intent); WakefulBroadcastReceiver.completeWakefulIntent(intent);
} else if (connectIntent == null) { } else if (connectIntent == null) {
connectIntent = intent; connectIntent = intent;
} else { } else if (intent != null) {
WakefulBroadcastReceiver.completeWakefulIntent(intent); WakefulBroadcastReceiver.completeWakefulIntent(intent);
} }
} }

View File

@ -112,11 +112,12 @@ class PushRegisterService : LifecycleService() {
} }
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int { override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
WakefulBroadcastReceiver.completeWakefulIntent(intent) if (intent != null) {
Log.d(TAG, "onStartCommand: $intent") WakefulBroadcastReceiver.completeWakefulIntent(intent)
lifecycleScope.launchWhenStarted { Log.d(TAG, "onStartCommand: $intent")
if (intent == null) return@launchWhenStarted lifecycleScope.launchWhenStarted {
handleIntent(intent) handleIntent(intent)
}
} }
return super.onStartCommand(intent, flags, startId) return super.onStartCommand(intent, flags, startId)
} }