323 lines
10 KiB
TypeScript
323 lines
10 KiB
TypeScript
// Metro module 8831 (f8832).
|
|
import { useState, useCallback, useEffect } from "react";
|
|
import { NativeModules } from "react-native";
|
|
import ApplicationStreamingStore from "../../../stores/ApplicationStreamingStore";
|
|
import ChannelStore from "../../../stores/ChannelStore";
|
|
import MediaEngineStore from "../../../stores/MediaEngineStore";
|
|
import SelectedChannelStore from "../../../stores/SelectedChannelStore";
|
|
import VoiceStateStore from "../../../stores/VoiceStateStore";
|
|
import AudioRouteStore_native from "../AudioRouteStore.native";
|
|
import AudioManagerStore_android from "./AudioManagerStore.android";
|
|
import { NativePermissionTypes } from "../../native_permissions/NativePermissionConstants";
|
|
import { getChannelVideoLimit } from "../../video_calls/useChannelVideoLimit";
|
|
import AlertActionCreators from "../../../actions/native/AlertActionCreators";
|
|
import { intl, t } from "../../../intl/index.native";
|
|
import NativePermissionUtils from "../../native_permissions/NativePermissionUtils";
|
|
import AudioActionCreators from "../../../actions/AudioActionCreators";
|
|
import { getErrorInfo, AVError } from "../../errors/av_errors/AVError";
|
|
import { dismissGlobalKeyboard } from "../../../utils/native/KeyboardManagerUtils";
|
|
import { dismissVoiceChannelScreens } from "../../../utils/native/PrivateChannelCallUtils";
|
|
import SelectedChannelActionCreators from "../../../actions/SelectedChannelActionCreators";
|
|
import Module12 from "../../../_bundle/Module12";
|
|
import Module8853 from "../../../_bundle/Module8853";
|
|
import Module8854 from "../../../_bundle/Module8854";
|
|
import Module8855 from "../../../_bundle/Module8855";
|
|
import { isAndroid } from "../../../utils/PlatformUtils";
|
|
import { useStateFromStoresObject, useStateFromStores } from "../../../_bundle/Module589";
|
|
import { showAudioOutputSelector } from "./audio_output_selector/showAudioOutputSelector";
|
|
import { AudioDeviceType } from "../../../_bundle/Module8836";
|
|
import * as _useIsVideoMode from "../../video_calls/native/useIsVideoMode";
|
|
import useIsVideoMode from "../../video_calls/native/useIsVideoMode";
|
|
import { RouteTypes } from "../VoiceCallTypes";
|
|
let c5758_18, c5758_19, c5758_20;
|
|
let c5758_17 = Module12.debounce((a0) => {
|
|
const AudioRoutePicker = NativeModules.AudioRoutePicker;
|
|
if (AudioRoutePicker != null) {
|
|
AudioRoutePicker.handleAudioRoute(a0);
|
|
}
|
|
}, 250);
|
|
c5758_18 = Module12.debounce((a0) => {
|
|
a0();
|
|
}, 1);
|
|
c5758_19 = {
|
|
EARPIECE: Module8853,
|
|
BLUETOOTH_HEADSET: Module8854,
|
|
WIRED_HEADSET: Module8855,
|
|
SPEAKERPHONE: Module8855,
|
|
INVALID: Module8855
|
|
};
|
|
c5758_20 = {
|
|
TYPE_UNKNOWN: 0,
|
|
0: "TYPE_UNKNOWN",
|
|
TYPE_BUILTIN_EARPIECE: 1,
|
|
1: "TYPE_BUILTIN_EARPIECE",
|
|
TYPE_BUILTIN_SPEAKER: 2,
|
|
2: "TYPE_BUILTIN_SPEAKER",
|
|
TYPE_WIRED_HEADSET: 3,
|
|
3: "TYPE_WIRED_HEADSET",
|
|
TYPE_WIRED_HEADPHONES: 4,
|
|
4: "TYPE_WIRED_HEADPHONES",
|
|
TYPE_LINE_ANALOG: 5,
|
|
5: "TYPE_LINE_ANALOG",
|
|
TYPE_LINE_DIGITAL: 6,
|
|
6: "TYPE_LINE_DIGITAL",
|
|
TYPE_BLUETOOTH_SCO: 7,
|
|
7: "TYPE_BLUETOOTH_SCO",
|
|
TYPE_BLUETOOTH_A2DP: 8,
|
|
8: "TYPE_BLUETOOTH_A2DP",
|
|
TYPE_HDMI: 9,
|
|
9: "TYPE_HDMI",
|
|
TYPE_HDMI_ARC: 10,
|
|
10: "TYPE_HDMI_ARC",
|
|
TYPE_USB_DEVICE: 11,
|
|
11: "TYPE_USB_DEVICE",
|
|
TYPE_USB_ACCESSORY: 12,
|
|
12: "TYPE_USB_ACCESSORY",
|
|
TYPE_DOCK: 13,
|
|
13: "TYPE_DOCK",
|
|
TYPE_FM: 14,
|
|
14: "TYPE_FM",
|
|
TYPE_BUILTIN_MIC: 15,
|
|
15: "TYPE_BUILTIN_MIC",
|
|
TYPE_FM_TUNER: 16,
|
|
16: "TYPE_FM_TUNER",
|
|
TYPE_TV_TUNER: 17,
|
|
17: "TYPE_TV_TUNER",
|
|
TYPE_TELEPHONY: 18,
|
|
18: "TYPE_TELEPHONY",
|
|
TYPE_AUX_LINE: 19,
|
|
19: "TYPE_AUX_LINE",
|
|
TYPE_IP: 20,
|
|
20: "TYPE_IP",
|
|
TYPE_BUS: 21,
|
|
21: "TYPE_BUS",
|
|
TYPE_USB_HEADSET: 22,
|
|
22: "TYPE_USB_HEADSET",
|
|
TYPE_HEARING_AID: 23,
|
|
23: "TYPE_HEARING_AID",
|
|
TYPE_BUILTIN_SPEAKER_SAFE: 24,
|
|
24: "TYPE_BUILTIN_SPEAKER_SAFE",
|
|
TYPE_REMOTE_SUBMIX: 25,
|
|
25: "TYPE_REMOTE_SUBMIX",
|
|
TYPE_BLE_HEADSET: 26,
|
|
26: "TYPE_BLE_HEADSET",
|
|
TYPE_BLE_SPEAKER: 27,
|
|
27: "TYPE_BLE_SPEAKER",
|
|
TYPE_ECHO_REFERENCE: 28,
|
|
28: "TYPE_ECHO_REFERENCE",
|
|
TYPE_HDMI_EARC: 29,
|
|
29: "TYPE_HDMI_EARC",
|
|
TYPE_BLE_BROADCAST: 30,
|
|
30: "TYPE_BLE_BROADCAST",
|
|
TYPE_DOCK_ANALOG: 31,
|
|
31: "TYPE_DOCK_ANALOG"
|
|
};
|
|
const r131 = isAndroid() ? () => useStateFromStoresObject([AudioManagerStore_android], () => {
|
|
let r14 = AudioManagerStore_android.getActiveAudioDevice()?.simpleDeviceType;
|
|
if (r14 == null) {
|
|
r14 = AudioDeviceType.INVALID;
|
|
}
|
|
return {
|
|
isAudioRouteEnabled: true,
|
|
toggleAudio: showAudioOutputSelector,
|
|
routeSource: c5758_19[r14]
|
|
};
|
|
}, []) : () => {
|
|
let isEnabled, isVideoMode;
|
|
const stateFromStoresObject = useStateFromStoresObject([ChannelStore, SelectedChannelStore, ApplicationStreamingStore, VoiceStateStore, MediaEngineStore, AudioRouteStore_native], () => {
|
|
const isVideoMode2 = _useIsVideoMode.isVideoMode(ChannelStore, SelectedChannelStore, ApplicationStreamingStore, VoiceStateStore, MediaEngineStore);
|
|
const currentRouteType = AudioRouteStore_native.getCurrentRouteType();
|
|
let isEnabled2 = currentRouteType === RouteTypes.SPEAKER;
|
|
const isBluetoothRoute = currentRouteType === RouteTypes.BLUETOOTH;
|
|
if (!isEnabled2) {
|
|
isEnabled2 = isBluetoothRoute;
|
|
}
|
|
if (!isEnabled2) {
|
|
isEnabled2 = isVideoMode2;
|
|
}
|
|
return {
|
|
isEnabled: isEnabled2,
|
|
isVideoMode: isVideoMode2,
|
|
isBluetoothRoute
|
|
};
|
|
});
|
|
isEnabled = stateFromStoresObject.isEnabled;
|
|
isVideoMode = stateFromStoresObject.isVideoMode;
|
|
const isBluetoothRoute = stateFromStoresObject.isBluetoothRoute;
|
|
const [state, setState] = useState(isEnabled);
|
|
const callback = useCallback(() => {
|
|
if (!AudioRouteStore_native.getMultipleRoutesAvailable()) {
|
|
c5758_18.cancel();
|
|
if (!isVideoMode) {
|
|
setState(!state);
|
|
}
|
|
}
|
|
c5758_17(!state);
|
|
}, [state, isVideoMode]);
|
|
useEffect(() => {
|
|
if (!AudioRouteStore_native.getMultipleRoutesAvailable() && !isVideoMode) {
|
|
c5758_18(() => setState(isEnabled));
|
|
} else {
|
|
setState(isEnabled);
|
|
}
|
|
}, [isEnabled, isVideoMode]);
|
|
return {
|
|
isAudioRouteEnabled: state,
|
|
toggleAudio: callback,
|
|
routeSource: isBluetoothRoute ? Module8854 : Module8855
|
|
};
|
|
};
|
|
export async function handleToggleVideo(c26289_0, c26289_1) {
|
|
let c26289_3;
|
|
let c29982_1, c29982_2, c29982_3, c29982_4, c29982_5;
|
|
c26289_3 = void 0;
|
|
c29982_1 = void 0;
|
|
let c29982_0 = c26289_0;
|
|
if (c26289_1 !== void 0) {
|
|
c29982_1 = c26289_1;
|
|
c29982_2 = void 0;
|
|
c29982_3 = void 0;
|
|
c29982_4 = void 0;
|
|
c29982_5 = void 0;
|
|
} else {
|
|
c29982_1 = true;
|
|
c29982_2 = void 0;
|
|
c29982_3 = void 0;
|
|
c29982_4 = void 0;
|
|
c29982_5 = void 0;
|
|
}
|
|
await void 0;
|
|
c29982_2 = MediaEngineStore.isVideoEnabled();
|
|
c29982_3 = getChannelVideoLimit(c29982_0);
|
|
c29982_4 = c29982_3.reachedLimit;
|
|
c29982_5 = c29982_3.limit;
|
|
if (c29982_4) {
|
|
if (c29982_1) {
|
|
AlertActionCreators.show({
|
|
title: intl.string(t["3ffmE+"]),
|
|
body: intl.formatToPlainString(t.x9mtl4, {
|
|
limit: c29982_5.toString()
|
|
})
|
|
});
|
|
}
|
|
} else if (c29982_2) {
|
|
AudioActionCreators.setVideoEnabled(false);
|
|
} else if (await NativePermissionUtils.requestPermission(NativePermissionTypes.CAMERA)) {
|
|
AudioActionCreators.setVideoEnabled(true);
|
|
}
|
|
}
|
|
export function handleToggleSelfDeaf() {
|
|
AudioActionCreators.toggleSelfDeaf();
|
|
}
|
|
export function handleToggleSelfMute() {
|
|
NativePermissionUtils.requestPermission(NativePermissionTypes.AUDIO, {
|
|
showAuthorizationError: true
|
|
});
|
|
AudioActionCreators.toggleSelfMute();
|
|
}
|
|
export function showSuppressedAlert() {
|
|
AlertActionCreators.show({
|
|
title: intl.string(t.FJSZVM),
|
|
body: intl.string(t.etJjgW),
|
|
hideActionSheet: false
|
|
});
|
|
}
|
|
export function showServerMuteAlert() {
|
|
AlertActionCreators.show({
|
|
title: intl.string(t["+JQCa/"]),
|
|
body: intl.string(t.hsNm7d),
|
|
hideActionSheet: false
|
|
});
|
|
}
|
|
export function showServerDeafenAlert() {
|
|
AlertActionCreators.show({
|
|
title: intl.string(t.QZ7WSS),
|
|
body: intl.string(t.Tl9JpL),
|
|
hideActionSheet: false
|
|
});
|
|
}
|
|
export function showCameraDisabledAlert() {
|
|
AlertActionCreators.show({
|
|
title: intl.string(t.OYzPcW),
|
|
body: intl.string(t.oBH7Y2),
|
|
hideActionSheet: false
|
|
});
|
|
}
|
|
export function showScreenshareDisabledAlert() {
|
|
AlertActionCreators.show({
|
|
title: intl.string(t["/x4knx"]),
|
|
body: intl.string(t.PpfzUE),
|
|
hideActionSheet: false
|
|
});
|
|
}
|
|
export function showMinOSScreenshareRequirementAlert() {
|
|
const r24 = intl.formatToPlainString(t.ejOT95, {
|
|
errorCode: getErrorInfo(AVError.SCREENSHARE_OS_NOT_SUPPORTED)?.errorCode
|
|
});
|
|
AlertActionCreators.show({
|
|
title: intl.string(t.oblMYa),
|
|
body: `${intl.string(t.Wnhd3q)}
|
|
|
|
${r24}`,
|
|
hideActionSheet: false
|
|
});
|
|
}
|
|
export function showTabletRequirementAlert() {
|
|
AlertActionCreators.show({
|
|
title: intl.string(t["1N0dxa"]),
|
|
body: intl.string(t.qqDFVb),
|
|
hideActionSheet: false
|
|
});
|
|
}
|
|
export function handleDisconnect(a0) {
|
|
dismissGlobalKeyboard();
|
|
dismissVoiceChannelScreens(a0, () => {
|
|
SelectedChannelActionCreators.selectVoiceChannel(null);
|
|
});
|
|
}
|
|
export { c5758_19 as audioDeviceToIconMap };
|
|
export function getAudioDeviceToDisplayText(a0) {
|
|
const r3 = {
|
|
EARPIECE: intl.string(t.Ouoi6E),
|
|
BLUETOOTH_HEADSET: intl.string(t.i6eV3z),
|
|
WIRED_HEADSET: intl.string(t.Dluojr),
|
|
SPEAKERPHONE: intl.string(t.snEhlu),
|
|
INVALID: intl.string(t.kCBL6t)
|
|
};
|
|
return a0.deviceType === c5758_20.TYPE_BLE_HEADSET ? intl.string(t.BtXSp9) : r3[a0.simpleDeviceType];
|
|
}
|
|
export { r131 as useMaskedSpeakerStates };
|
|
export const useImmediateMaskedSpeakerStates = () => {
|
|
let c16819_0, c16819_1;
|
|
const stateFromStores = useStateFromStores([AudioRouteStore_native], () => AudioRouteStore_native.getCurrentRouteType());
|
|
const isVideoMode2 = useIsVideoMode();
|
|
c16819_0 = isVideoMode2;
|
|
let r12 = stateFromStores === RouteTypes.SPEAKER;
|
|
const r2 = stateFromStores === RouteTypes.BLUETOOTH;
|
|
if (!r12) {
|
|
r12 = r2;
|
|
}
|
|
if (!r12) {
|
|
r12 = isVideoMode2;
|
|
}
|
|
c16819_1 = r12;
|
|
const [state2, setState2] = useState(r12);
|
|
const callback = useCallback(() => {
|
|
if (!AudioRouteStore_native.getMultipleRoutesAvailable()) {
|
|
c5758_18.cancel();
|
|
if (!c16819_0) {
|
|
setState2(!state2);
|
|
}
|
|
}
|
|
c5758_17(!state2);
|
|
}, [state2, isVideoMode2]);
|
|
useEffect(() => {
|
|
setState2(c16819_1);
|
|
}, [r12, isVideoMode2]);
|
|
return {
|
|
isAudioRouteEnabled: state2,
|
|
toggleAudio: callback,
|
|
routeSource: r2 ? Module8854 : Module8855
|
|
};
|
|
};
|