From 87e38894b5aab70de647a8ccc94b3566801219dc Mon Sep 17 00:00:00 2001 From: Natan Votre Date: Thu, 28 May 2020 13:13:18 -0300 Subject: [PATCH 1/2] [NY-9867]: [AN]: Use stopService at MainActivity --- .../nynja/mobile/communicator/ui/activities/MainActivity.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/com/nynja/mobile/communicator/ui/activities/MainActivity.java b/app/src/main/java/com/nynja/mobile/communicator/ui/activities/MainActivity.java index d3ec2a1c17..67ad0d61eb 100644 --- a/app/src/main/java/com/nynja/mobile/communicator/ui/activities/MainActivity.java +++ b/app/src/main/java/com/nynja/mobile/communicator/ui/activities/MainActivity.java @@ -694,7 +694,7 @@ public class MainActivity extends BaseActivity implements MainActivityView, @Override public void stopActiveCallNotification() { - startService(ConferenceService.getStopIntent(this)); + stopService(ConferenceService.getStopIntent(this)); Toast.makeText(this, R.string.call_not_found, Toast.LENGTH_SHORT).show(); } -- GitLab From a85b35deab5beb5d5fe26f9d8e70ba6ee38deeaf Mon Sep 17 00:00:00 2001 From: Natan Votre Date: Fri, 29 May 2020 18:06:40 -0300 Subject: [PATCH 2/2] [NY-9867]: [AN]: Clear the ConferenceService.java removing useless code --- .../data/sdk/calls/ConferenceSDKModule.java | 4 +-- .../data/sdk/calls/ConferenceService.java | 30 ++++--------------- 2 files changed, 7 insertions(+), 27 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 e3a1aa8694..ea5b83a9ae 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 @@ -3128,9 +3128,9 @@ public class ConferenceSDKModule extends BaseSDKModule { conferenceSDKListener.onConferenceConnected(mActiveConference); startTimer(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - getContext().startForegroundService(ConferenceService.getStartIntent(getContext(), true)); + getContext().startForegroundService(ConferenceService.getStartIntent(getContext())); } else { - getContext().startService(ConferenceService.getStartIntent(getContext(), true)); + getContext().startService(ConferenceService.getStartIntent(getContext())); } if (enterWaitingRoom) { onConferenceMembersSucceedResponse("", callId, true); 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 67abe8e9b6..3eb8178a77 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 @@ -61,24 +61,10 @@ public class ConferenceService extends Service implements SensorEventListener { public static Intent getStartIntent(Context context) { Intent startIntent = new Intent(context, ConferenceService.class); startIntent.setAction(START_CONFERENCE_FOREGROUND_ACTION); + startIntent.putExtra(START_CONFERENCE_WAKE_LOCK_ACTION, true); return startIntent; } - public static Intent getStartIntent(Context context, boolean withWakeLock) { - Intent startIntent = new Intent(context, ConferenceService.class); - startIntent.setAction(START_CONFERENCE_FOREGROUND_ACTION); - if (withWakeLock) { - startIntent.putExtra(START_CONFERENCE_WAKE_LOCK_ACTION, withWakeLock); - } - return startIntent; - } - - public static Intent getStartWakeLockIntent(Context context) { - Intent startWLIntent = new Intent(context, ConferenceService.class); - startWLIntent.setAction(START_CONFERENCE_WAKE_LOCK_ACTION); - return startWLIntent; - } - public static Intent getStopIntent(Context context) { Intent stopIntent = new Intent(context, ConferenceService.class); stopIntent.setAction(STOP_CONFERENCE_FOREGROUND_ACTION); @@ -92,11 +78,7 @@ public class ConferenceService extends Service implements SensorEventListener { @Override public int onStartCommand(@Nullable Intent intent, int flags, int startId) { if (intent != null && START_CONFERENCE_FOREGROUND_ACTION.equalsIgnoreCase(intent.getAction())) { - 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 && START_CONFERENCE_WAKE_LOCK_ACTION.equalsIgnoreCase(intent.getAction())) { - tryStartyWakeLock(); + startForeground(intent.getAction()); } return START_NOT_STICKY; } @@ -128,11 +110,11 @@ public class ConferenceService extends Service implements SensorEventListener { } catch (Exception e) { Timber.e(e); } - startForeground(START_CONFERENCE_FOREGROUND_ACTION, true); + startForeground(START_CONFERENCE_FOREGROUND_ACTION); } @Synchronized - private void startForeground(@Nullable String action, boolean tryWakeLock) { + private void startForeground(@Nullable String action) { if (action != null && START_CONFERENCE_FOREGROUND_ACTION.equalsIgnoreCase(action) && !mForegroundStarted) { final String anotherUsername = mDataManager.getConferenceSDK().getAnotherUsername(); @@ -160,9 +142,7 @@ public class ConferenceService extends Service implements SensorEventListener { mForegroundStarted = true; mNotificationHelper.clearCallPush(ActiveConferenceCall.ANDROID_10_PUSH_CALL_NTFN_ID); - if (tryWakeLock) { - tryStartyWakeLock(); - } + tryStartyWakeLock(); } } -- GitLab