Skip to content

Commit

Permalink
Improve naming, inline docs and comments
Browse files Browse the repository at this point in the history
  • Loading branch information
liviu-timar committed Oct 8, 2024
1 parent 59dab6b commit c78cdb7
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 28 deletions.
22 changes: 9 additions & 13 deletions stream-video-android-core/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,35 +26,31 @@

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />

<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />

<uses-permission android:name="android.permission.VIBRATE" />

<!-- Call service permission -->
<!-- Call foreground service permission -->
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />

<!-- Optional, if incoming / outgoing calls feature is used -->
<!-- Required if incoming & outgoing calls are used -->
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.USE_FULL_SCREEN_INTENT" />

<!-- If the app is only livestream host -->
<!-- Required for calls involving microphone usage -->
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MICROPHONE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<!-- Required for calls involving camera usage -->
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_CAMERA" />
<uses-permission android:name="android.permission.CAMERA" />

<!-- If the app is only livestream viewer/guest type -->
<!-- Required for viewer/listener-only calls -->
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" />

<!-- If the calls support screensharing -->
<!-- Required if calls support screensharing -->
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PROJECTION"/>


<application>

<provider
android:name="io.getstream.android.push.delegate.PushDelegateProvider"
android:authorities="${applicationId}.io.getstream.android.push"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import io.getstream.video.android.core.logging.LoggingLevel
import io.getstream.video.android.core.notifications.NotificationConfig
import io.getstream.video.android.core.notifications.internal.StreamNotificationManager
import io.getstream.video.android.core.notifications.internal.service.CallServiceConfig
import io.getstream.video.android.core.notifications.internal.service.callServiceConfig
import io.getstream.video.android.core.notifications.internal.service.defaultCallServiceConfig
import io.getstream.video.android.core.notifications.internal.storage.DeviceTokenStorage
import io.getstream.video.android.core.permission.android.DefaultStreamPermissionCheck
import io.getstream.video.android.core.permission.android.StreamPermissionCheck
Expand Down Expand Up @@ -74,6 +74,7 @@ import java.net.ConnectException
* @property ensureSingleInstance Verify that only 1 version of the video client exists. Prevents integration mistakes.
* @property videoDomain URL overwrite to allow for testing against a local instance of video.
* @property runForegroundServiceForCalls If set to true, when there is an active call the SDK will run a foreground service to keep the process alive. (default: true)
* @property callServiceConfig Configuration for the call foreground service. See [CallServiceConfig].
* @property localSfuAddress Local SFU address (IP:port) to be used for testing. Leave null if not needed.
* @property sounds Overwrite the default SDK sounds. See [Sounds].
* @property permissionCheck Used to check for system permission based on call capabilities. See [StreamPermissionCheck].
Expand Down Expand Up @@ -194,7 +195,7 @@ public class StreamVideoBuilder @JvmOverloads constructor(
connectionModule = connectionModule,
streamNotificationManager = streamNotificationManager,
callServiceConfig = callServiceConfig
?: callServiceConfig().copy(
?: defaultCallServiceConfig().copy(
runCallServiceInForeground = runForegroundServiceForCalls,
audioUsage = audioUsage,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import io.getstream.video.android.core.notifications.NotificationHandler
import io.getstream.video.android.core.notifications.internal.StreamNotificationManager
import io.getstream.video.android.core.notifications.internal.service.CallService
import io.getstream.video.android.core.notifications.internal.service.CallServiceConfig
import io.getstream.video.android.core.notifications.internal.service.callServiceConfig
import io.getstream.video.android.core.notifications.internal.service.defaultCallServiceConfig
import io.getstream.video.android.core.permission.android.DefaultStreamPermissionCheck
import io.getstream.video.android.core.permission.android.StreamPermissionCheck
import io.getstream.video.android.core.socket.ErrorResponse
Expand Down Expand Up @@ -149,7 +149,7 @@ internal class StreamVideoImpl internal constructor(
internal val connectionModule: ConnectionModule,
internal val tokenProvider: (suspend (error: Throwable?) -> String)?,
internal val streamNotificationManager: StreamNotificationManager,
internal val callServiceConfig: CallServiceConfig = callServiceConfig(),
internal val callServiceConfig: CallServiceConfig = defaultCallServiceConfig(),
internal val testSfuAddress: String? = null,
internal val sounds: Sounds,
internal val permissionCheck: StreamPermissionCheck = DefaultStreamPermissionCheck(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ internal open class CallService : Service() {
callId: StreamCallId,
trigger: String,
callDisplayName: String? = null,
callServiceConfiguration: CallServiceConfig = callServiceConfig(),
callServiceConfiguration: CallServiceConfig = defaultCallServiceConfig(),
): Intent {
val serviceClass = resolveServiceClass(callId, callServiceConfiguration)
StreamLog.i(TAG) { "Resolved service class: $serviceClass" }
Expand Down Expand Up @@ -152,7 +152,7 @@ internal open class CallService : Service() {
*/
fun buildStopIntent(
context: Context,
callServiceConfiguration: CallServiceConfig = callServiceConfig(),
callServiceConfiguration: CallServiceConfig = defaultCallServiceConfig(),
) = safeCall(Intent(context, CallService::class.java)) {
val intent = callServiceConfiguration.callServicePerType.firstNotNullOfOrNull {
val serviceClass = it.value
Expand All @@ -165,7 +165,7 @@ internal open class CallService : Service() {
intent ?: Intent(context, CallService::class.java)
}

fun showIncomingCall(context: Context, callId: StreamCallId, callDisplayName: String?, callServiceConfiguration: CallServiceConfig = callServiceConfig()) {
fun showIncomingCall(context: Context, callId: StreamCallId, callDisplayName: String?, callServiceConfiguration: CallServiceConfig = defaultCallServiceConfig()) {
val hasActiveCall = StreamVideo.instanceOrNull()?.state?.activeCall?.value != null

if (!hasActiveCall) {
Expand All @@ -192,7 +192,7 @@ internal open class CallService : Service() {
}
}

fun removeIncomingCall(context: Context, callId: StreamCallId, config: CallServiceConfig = callServiceConfig()) {
fun removeIncomingCall(context: Context, callId: StreamCallId, config: CallServiceConfig = defaultCallServiceConfig()) {
context.startService(
buildStartIntent(
context,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,15 @@ internal const val ANY_MARKER = "ALL_CALL_TYPES"

// API
/**
* Configuration class for the call service.
* Configuration class for the call foreground service.
* @param runCallServiceInForeground If the call service should run in the foreground.
* @param callServicePerType A map of call service per type.
*
* @see defaultCallServiceConfig
* @see livestreamCallServiceConfig
* @see livestreamAudioCallServiceConfig
* @see livestreamGuestCallServiceConfig
* @see audioCallServiceConfig
*/
public data class CallServiceConfig(
val runCallServiceInForeground: Boolean = true,
Expand All @@ -38,9 +44,9 @@ public data class CallServiceConfig(
)

/**
* Return a default configuration for the call service configuration.
* Returns a default call foreground service configuration.
*/
public fun callServiceConfig(): CallServiceConfig {
public fun defaultCallServiceConfig(): CallServiceConfig {
return CallServiceConfig(
runCallServiceInForeground = true,
callServicePerType = mapOf(
Expand All @@ -50,7 +56,8 @@ public fun callServiceConfig(): CallServiceConfig {
}

/**
* Return a default configuration for the call service configuration.
* Returns a foreground service configuration appropriate for livestream hosts.
* Uses: `FOREGROUND_SERVICE_TYPE_CAMERA` and `FOREGROUND_SERVICE_TYPE_MICROPHONE`.
*/
public fun livestreamCallServiceConfig(): CallServiceConfig {
return CallServiceConfig(
Expand All @@ -63,7 +70,8 @@ public fun livestreamCallServiceConfig(): CallServiceConfig {
}

/**
* Return a default configuration for the call service configuration for livestream which has no camera
* Returns a foreground service configuration appropriate for audio-only livestream hosts.
* Uses: `FOREGROUND_SERVICE_TYPE_MICROPHONE`.
*/
public fun livestreamAudioCallServiceConfig(): CallServiceConfig {
return CallServiceConfig(
Expand All @@ -76,7 +84,8 @@ public fun livestreamAudioCallServiceConfig(): CallServiceConfig {
}

/**
* Return a default configuration for the call service configuration.
* Returns a foreground service configuration appropriate for livestream viewers.
* Uses: `FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK`.
*/
public fun livestreamGuestCallServiceConfig(): CallServiceConfig {
return CallServiceConfig(
Expand All @@ -89,6 +98,10 @@ public fun livestreamGuestCallServiceConfig(): CallServiceConfig {
)
}

/**
* Returns a foreground service configuration appropriate for audio-only calls.
* Uses: `FOREGROUND_SERVICE_TYPE_MICROPHONE`.
*/
public fun audioCallServiceConfig(): CallServiceConfig {
return CallServiceConfig(
runCallServiceInForeground = true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class CallServiceConfigTest {
@Test
fun `callServiceConfig should return correct default configuration`() {
// Given
val config = callServiceConfig()
val config = defaultCallServiceConfig()

// When
val runInForeground = config.runCallServiceInForeground
Expand Down

0 comments on commit c78cdb7

Please sign in to comment.