From 8b011a16cde06aac66e9de469082195ef5e8caf7 Mon Sep 17 00:00:00 2001 From: Ergyun Syuleyman Date: Fri, 19 Jun 2020 12:12:14 +0300 Subject: [PATCH] NY-10745: [AN] Android 7 notifications change crash --- .../communicator/data/sdk/calls/ConferenceSDKModule.java | 3 +++ .../mobile/communicator/utils/NotificationHelper.java | 9 +++++++-- 2 files changed, 10 insertions(+), 2 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 c7eacc2658..05fe2941ca 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 @@ -3954,6 +3954,9 @@ public class ConferenceSDKModule extends BaseSDKModule { public boolean onMediaButtonsLocalEvent(Context context, LocalEvent event) { if (event instanceof HeadphoneState) { HeadphoneState hs = (HeadphoneState)event; + Timber.d("ConferenceSDKModule::onMediaButtonsLocalEvent(): " + + "local event headphoneState=%s", hs.getState().toString()); + switch (hs.getState()) { case Connected: switchToBTDevice(); diff --git a/app/src/main/java/com/nynja/mobile/communicator/utils/NotificationHelper.java b/app/src/main/java/com/nynja/mobile/communicator/utils/NotificationHelper.java index 5891213277..3f918e6b1b 100644 --- a/app/src/main/java/com/nynja/mobile/communicator/utils/NotificationHelper.java +++ b/app/src/main/java/com/nynja/mobile/communicator/utils/NotificationHelper.java @@ -98,6 +98,7 @@ public class NotificationHelper extends ContextWrapper { mNynjaSoundManager = soundManager; } + @TargetApi(Build.VERSION_CODES.O) public void setupNotifications(SettingNotifications settingNotifications, boolean force) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) return; if (force) { @@ -115,6 +116,7 @@ public class NotificationHelper extends ContextWrapper { initChannels(settingNotifications); } + @TargetApi(Build.VERSION_CODES.O) private void onUpgrade(SettingNotifications settingNotifications, long oldVersion, long newVersion) { if (oldVersion == 0) { @@ -279,7 +281,8 @@ public class NotificationHelper extends ContextWrapper { return channel; } - public void updateRingerSoundAndCreateChannel(SettingNotifications settingNotifications) { + @TargetApi(Build.VERSION_CODES.O) + private void updateRingerSoundAndCreateChannel(SettingNotifications settingNotifications) { Timber.d("updateRingerSoundAndCreateChannel()"); deleteRingingChannel(settingNotifications); settingNotifications.setRingerSoundIndex(settingNotifications.getRingerSoundIndex() + 1); @@ -294,7 +297,9 @@ public class NotificationHelper extends ContextWrapper { Timber.d("ringerSoundChange(): check 2: channel old_id=%d", settingNotifications.getRingerSoundIndex()); settingNotifications.setRingerSound(ringerSound); - updateRingerSoundAndCreateChannel(settingNotifications); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + updateRingerSoundAndCreateChannel(settingNotifications); + } return true; } return false; -- GitLab