Calling stopSelf() could cause the service to be destroyed before calling setForeground() and lead to a RemoteException (cherry picked from commit 6be3523b)