76 lines
2.6 KiB
TypeScript
76 lines
2.6 KiB
TypeScript
// Metro module 8832 (f8833).
|
|
import { NativeModules, NativeEventEmitter } from "react-native";
|
|
import RTCConnectionStore from "../../stores/RTCConnectionStore";
|
|
import { RouteTypes } from "./VoiceCallTypes";
|
|
import { isAndroid } from "../../utils/PlatformUtils";
|
|
import Module8834 from "../../_bundle/Module8834";
|
|
import Module589 from "../../_bundle/Module589";
|
|
import Dispatcher from "../../Dispatcher";
|
|
let UNKNOWN, c5759_6, c5759_7, c5759_8, c5759_10;
|
|
const handleAudioRouteChanged = function handleAudioRouteChanged(routeType, r2 = c5759_6) {
|
|
let BLUETOOTH;
|
|
L15: {
|
|
if (routeType != null && routeType !== "") {
|
|
if (routeType.includes("Bluetooth")) {
|
|
BLUETOOTH = RouteTypes.BLUETOOTH;
|
|
break L15;
|
|
}
|
|
if (routeType.includes("Speaker")) {
|
|
BLUETOOTH = RouteTypes.SPEAKER;
|
|
break L15;
|
|
}
|
|
if (routeType.includes("Receiver")) {
|
|
BLUETOOTH = RouteTypes.RECEIVER;
|
|
break L15;
|
|
}
|
|
BLUETOOTH = RouteTypes.UNKNOWN;
|
|
} else {
|
|
BLUETOOTH = RouteTypes.UNKNOWN;
|
|
}
|
|
}
|
|
UNKNOWN = BLUETOOTH;
|
|
c5759_6 = r2;
|
|
};
|
|
UNKNOWN = RouteTypes.UNKNOWN;
|
|
c5759_6 = false;
|
|
c5759_7 = null;
|
|
c5759_8 = new NativeEventEmitter(NativeModules.AudioRouteEmitter);
|
|
class AudioRouteStoreClass extends Module589.Store {
|
|
static displayName = "AudioRouteStore";
|
|
initialize() {
|
|
this.waitFor(RTCConnectionStore);
|
|
}
|
|
getCurrentRouteType() {
|
|
return UNKNOWN;
|
|
}
|
|
getMultipleRoutesAvailable() {
|
|
return c5759_6;
|
|
}
|
|
}
|
|
c5759_10 = new AudioRouteStoreClass(Dispatcher, {
|
|
RTC_CONNECTION_STATE: function handleConnectionStatusChanged() {
|
|
const isConnected = RTCConnectionStore.isConnected();
|
|
const r12 = c5759_7;
|
|
if (r12 === null && isConnected) {
|
|
UNKNOWN = RouteTypes.UNKNOWN;
|
|
c5759_7 = c5759_8 == null ? void 0 : c5759_8.addListener("audio-route-changed", (a0) => {
|
|
handleAudioRouteChanged(a0.routeType, a0.multipleRoutesAvailable);
|
|
c5759_10.emitChange();
|
|
});
|
|
(isAndroid() ? Module8834 == null ? void 0 : Module8834.getCurrentRoute() : NativeModules.AudioRouteEmitter.getCurrentRoute()).then((result) => {
|
|
handleAudioRouteChanged(result.routeType, result.multipleRoutesAvailable);
|
|
}).then(() => c5759_10 == null ? void 0 : c5759_10.emitChange()).catch(() => {});
|
|
} else if (!(r12 == null || isConnected)) {
|
|
const AudioRoutePicker = NativeModules.AudioRoutePicker;
|
|
if (AudioRoutePicker != null) {
|
|
AudioRoutePicker.resetPortOverride();
|
|
}
|
|
UNKNOWN = RouteTypes.UNKNOWN;
|
|
c5759_7.remove();
|
|
c5759_7 = null;
|
|
}
|
|
return false;
|
|
}
|
|
});
|
|
export default c5759_10;
|