NY-9867: [AN]: android.app.RemoteServiceException (did not then call …
Created by: rvc-brickabode
…Service.startForeground())
Note: This complements same issue found in the Download Service (NY-9844)
From our internal process of review there are items to review in another PR but which shall not affect the current PR:
- the condition for
startWakeLockintoonStartCommand
else if (intent != null && START_CONFERENCE_WAKE_LOCK_ACTION.equalsIgnoreCase(intent.getAction())) {
tryStartyWakeLock();
}
- the intent for StartWakeLock (unused)
public static Intent getStartWakeLockIntent(Context context) {
Intent startWLIntent = new Intent(context, ConferenceService.class);
startWLIntent.setAction(START_CONFERENCE_WAKE_LOCK_ACTION);
return startWLIntent;
}
-
also, the class has been redundant regarding the startWakeLock, look:
- They always start using a StartIntent with WakeLock:
getContext().startForegroundService(ConferenceService.getStartIntent(getContext(), withWakeLock: true));- After that, it calls automatically
onCreateand henceonStartCommand. - Inside onCreate, it always run:
startForeground(START_CONFERENCE_FOREGROUND_ACTION, tryWakeLock: true)-
Regardless the value of
withWakeLockinto thestartIntentshouted -
Then, at
onStartCommandmethod, it catches thestartIntentand thewithWakeLockflag, and runs thestartForegroundagain. -
Although, the last
startForegroundis called with action equals to null, which does not execute anything, making sense, since the Service was already started with theonCreatemethod.