Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.content.IntentFilter
import android.content.pm.PackageManager
import android.graphics.Bitmap
import android.media.AudioAttributes
import android.media.AudioFormat
Expand Down Expand Up @@ -333,6 +334,24 @@ class StreamVideoReactNativeModule(reactContext: ReactApplicationContext) :
}
}

@ReactMethod
fun hasAudioOutputHardware(promise: Promise) {
val hasAudioOutput = reactApplicationContext.packageManager.hasSystemFeature(PackageManager.FEATURE_AUDIO_OUTPUT)
promise.resolve(hasAudioOutput)
}

@ReactMethod
fun hasMicrophoneHardware(promise: Promise) {
val hasAudioInput = reactApplicationContext.packageManager.hasSystemFeature(PackageManager.FEATURE_MICROPHONE)
promise.resolve(hasAudioInput)
}

@ReactMethod
fun hasCameraHardware(promise: Promise) {
val hasCamera = reactApplicationContext.packageManager.hasSystemFeature(PackageManager.FEATURE_CAMERA_ANY)
promise.resolve(hasCamera)
}

private fun getBatteryStatusFromIntent(intent: Intent): WritableMap {
val status = intent.getIntExtra(BatteryManager.EXTRA_STATUS, -1)
val level = intent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1)
Expand Down
33 changes: 30 additions & 3 deletions packages/react-native-sdk/src/utils/StreamVideoRN/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import newNotificationCallbacks, {
} from '../internal/newNotificationCallbacks';
import { setupIosCallKeepEvents } from '../push/setupIosCallKeepEvents';
import { setupIosVoipPushEvents } from '../push/setupIosVoipPushEvents';
import { NativeModules } from 'react-native';
import { NativeModules, Platform } from 'react-native';

// Utility type for deep partial
type DeepPartial<T> = {
Expand Down Expand Up @@ -171,13 +171,40 @@ export class StreamVideoRN {
* Play native busy tone for call rejection
*/
static async playBusyTone() {
return NativeModules.StreamVideoReactNative?.playBusyTone();
return NativeModules.StreamVideoReactNative.playBusyTone();
}

/**
* Stop native busy tone
*/
static async stopBusyTone() {
return NativeModules.StreamVideoReactNative?.stopBusyTone();
return NativeModules.StreamVideoReactNative.stopBusyTone();
}

/**
* Check if the device has audio output hardware
* @returns True if the device has audio output hardware
*/
static async androidHasAudioOutputHardware(): Promise<boolean> {
if (Platform.OS !== 'android') return true;
return NativeModules.StreamVideoReactNative.hasAudioOutputHardware();
}

/**
* Check if the device has microphone hardware
* @returns True if the device has microphone hardware
*/
static async androidHasMicrophoneHardware(): Promise<boolean> {
if (Platform.OS !== 'android') return true;
return NativeModules.StreamVideoReactNative.hasMicrophoneHardware();
}

/**
* Check if the device has camera hardware
* @returns True if the device has camera hardware
*/
static async androidHasCameraHardware(): Promise<boolean> {
if (Platform.OS !== 'android') return true;
return NativeModules.StreamVideoReactNative.hasCameraHardware();
}
}
Loading