From 48cdd3b511c9660082570ecec86ea8701831fe0d Mon Sep 17 00:00:00 2001 From: Diego Mello Date: Mon, 2 Sep 2019 13:15:56 -0300 Subject: [PATCH] [FIX] Patch expo-av crashing with java.lang.IllegalArgumentException: Receiver not registered (#1161) * [FIX] Patch expo-av crashing with java.lang.IllegalArgumentException: Receiver not registered * Fix ci cache * Try if condition --- package.json | 4 ++-- patches/expo-av+6.0.0.patch | 38 ++++++++++++++++++++++++++++++++++++- yarn.lock | 2 +- 3 files changed, 40 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index ee4f5cf50..f9216c95d 100644 --- a/package.json +++ b/package.json @@ -24,13 +24,13 @@ }, "dependencies": { "@rocket.chat/sdk": "1.0.0-alpha.30", + "bugsnag-react-native": "^2.22.3", "commonmark": "git+https://github.com/RocketChat/commonmark.js.git", "commonmark-react-renderer": "git+https://github.com/RocketChat/commonmark-react-renderer.git", - "bugsnag-react-native": "^2.22.3", "deep-equal": "^1.0.1", "ejson": "2.2.0", "expo-av": "^6.0.0", - "expo-haptics": "^6.0.0", + "expo-haptics": "6.0.0", "expo-web-browser": "^6.0.0", "i18n-js": "^3.3.0", "js-base64": "^2.5.1", diff --git a/patches/expo-av+6.0.0.patch b/patches/expo-av+6.0.0.patch index 2dad60ef1..a13895c2b 100644 --- a/patches/expo-av+6.0.0.patch +++ b/patches/expo-av+6.0.0.patch @@ -9,4 +9,40 @@ index 2d3568e..b093959 100644 + implementation 'androidx.annotation:annotation:1.1.0' api 'com.google.android.exoplayer:exoplayer:2.9.2' - api 'com.google.android.exoplayer:extension-okhttp:2.9.2' \ No newline at end of file + api 'com.google.android.exoplayer:extension-okhttp:2.9.2' +diff --git a/node_modules/expo-av/android/src/main/java/expo/modules/av/AVManager.java b/node_modules/expo-av/android/src/main/java/expo/modules/av/AVManager.java +index 048afaf..1ef9728 100644 +--- a/node_modules/expo-av/android/src/main/java/expo/modules/av/AVManager.java ++++ b/node_modules/expo-av/android/src/main/java/expo/modules/av/AVManager.java +@@ -89,6 +89,7 @@ public class AVManager implements LifecycleEventListener, AudioManager.OnAudioFo + private long mAudioRecorderDurationAlreadyRecorded = 0L; + private boolean mAudioRecorderIsRecording = false; + private boolean mAudioRecorderIsPaused = false; ++ private boolean isRegistered = false; + + private ModuleRegistry mModuleRegistry; + +@@ -108,6 +109,7 @@ public class AVManager implements LifecycleEventListener, AudioManager.OnAudioFo + }; + mContext.registerReceiver(mNoisyAudioStreamReceiver, + new IntentFilter(AudioManager.ACTION_AUDIO_BECOMING_NOISY)); ++ isRegistered = true; + } + + @Override +@@ -181,7 +183,14 @@ public class AVManager implements LifecycleEventListener, AudioManager.OnAudioFo + + @Override + public void onHostDestroy() { +- mContext.unregisterReceiver(mNoisyAudioStreamReceiver); ++ try { ++ if (isRegistered) { ++ mContext.unregisterReceiver(mNoisyAudioStreamReceiver); ++ isRegistered = false; ++ } ++ } catch (final Exception exception) { ++ // Do nothing ++ } + for (final Integer key : mSoundMap.keySet()) { + removeSoundForKey(key); + } \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index 043cfb60a..a54a5551b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4440,7 +4440,7 @@ expo-file-system@~6.0.1: dependencies: uuid-js "^0.7.5" -expo-haptics@^6.0.0: +expo-haptics@6.0.0: version "6.0.0" resolved "https://registry.yarnpkg.com/expo-haptics/-/expo-haptics-6.0.0.tgz#dd0b8390564b3ba398a3f6d726ce5ad99a892ddc" integrity sha512-Xn+u5Gqp0/aLipKUMhPgZrccTO9uSV5FSM9u6bkMhV/zfjZqQMWpm0NqL24OBBXy5wPmF3g6Hev5YyDUd0Jj9Q==