From 91f8fcdaccac882e437267005a9a1f64f8674f83 Mon Sep 17 00:00:00 2001 From: Rafael da Veiga Cabral Date: Fri, 29 May 2020 09:19:54 -0300 Subject: [PATCH] NY-9867: [AN]: android.app.RemoteServiceException (did not then call Service.startForeground()) Note: This complements same issue found in the Download Service (NY-9844) --- .../data/sdk/calls/ConferenceSDKModule.java | 4 ++-- .../data/sdk/calls/ConferenceService.java | 16 ++++++---------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/com/nynja/mobile/communicator/data/sdk/calls/ConferenceSDKModule.java b/app/src/main/java/com/nynja/mobile/communicator/data/sdk/calls/ConferenceSDKModule.java index b00746dd83..61d8b06193 100644 --- a/app/src/main/java/com/nynja/mobile/communicator/data/sdk/calls/ConferenceSDKModule.java +++ b/app/src/main/java/com/nynja/mobile/communicator/data/sdk/calls/ConferenceSDKModule.java @@ -414,7 +414,7 @@ public class ConferenceSDKModule extends BaseSDKModule { } private void stopCallService() { - getContext().startService(ConferenceService.getStopIntent(getContext())); + getContext().stopService(ConferenceService.getStopIntent(getContext())); } public void togleFullScreen() { @@ -3212,7 +3212,7 @@ public class ConferenceSDKModule extends BaseSDKModule { conferenceSDKListener.onConferenceFailed(reason); } } - getContext().startService(ConferenceService.getStopIntent(getContext())); + getContext().stopService(ConferenceService.getStopIntent(getContext())); }, Consts.DELAY_50); } diff --git a/app/src/main/java/com/nynja/mobile/communicator/data/sdk/calls/ConferenceService.java b/app/src/main/java/com/nynja/mobile/communicator/data/sdk/calls/ConferenceService.java index 125887423e..67abe8e9b6 100644 --- a/app/src/main/java/com/nynja/mobile/communicator/data/sdk/calls/ConferenceService.java +++ b/app/src/main/java/com/nynja/mobile/communicator/data/sdk/calls/ConferenceService.java @@ -95,8 +95,6 @@ public class ConferenceService extends Service implements SensorEventListener { boolean tryWakeLock = (intent.hasExtra(START_CONFERENCE_WAKE_LOCK_ACTION) && intent.getBooleanExtra(START_CONFERENCE_WAKE_LOCK_ACTION, false)); startForeground(intent.getAction(), tryWakeLock); - } else if (intent != null && STOP_CONFERENCE_FOREGROUND_ACTION.equalsIgnoreCase(intent.getAction())) { - stopForeground(STOP_CONFERENCE_FOREGROUND_ACTION); } else if (intent != null && START_CONFERENCE_WAKE_LOCK_ACTION.equalsIgnoreCase(intent.getAction())) { tryStartyWakeLock(); } @@ -168,14 +166,9 @@ public class ConferenceService extends Service implements SensorEventListener { } } - @Synchronized - private void stopForeground(@Nullable String action) { - if (action != null && STOP_CONFERENCE_FOREGROUND_ACTION.equalsIgnoreCase(action)) { - stopForeground(true); - stopSelf(); - mForegroundStarted = false; - mNotificationHelper.clearCallPush(ActiveConferenceCall.ANDROID_10_PUSH_CALL_NTFN_ID); - } + private void clearConferenceCall() { + stopForeground(true); + mNotificationHelper.clearCallPush(ActiveConferenceCall.ANDROID_10_PUSH_CALL_NTFN_ID); } private void safetyProximityWakeLockRelease() { @@ -209,6 +202,9 @@ public class ConferenceService extends Service implements SensorEventListener { @Override public void onDestroy() { Timber.d("onDestroy"); + mForegroundStarted = false; + clearConferenceCall(); + if (!mCommunication.isBinded()) mDataManager.disconnectConference(); if (mProximity != null) { -- GitLab