[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
This commit is contained in:
Diego Mello 2019-09-02 13:15:56 -03:00 committed by GitHub
parent 94ede08c43
commit 48cdd3b511
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 40 additions and 4 deletions

View File

@ -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",

View File

@ -10,3 +10,39 @@ index 2d3568e..b093959 100644
api 'com.google.android.exoplayer:exoplayer:2.9.2'
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);
}

View File

@ -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==