diff --git a/app/src/main/java/org/thoughtcrime/securesms/service/WebRtcCallService.kt b/app/src/main/java/org/thoughtcrime/securesms/service/WebRtcCallService.kt index 9ade3eecfe..747df0751f 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/service/WebRtcCallService.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/service/WebRtcCallService.kt @@ -6,11 +6,16 @@ import android.content.Intent import android.os.IBinder import androidx.core.content.ContextCompat import dagger.hilt.android.AndroidEntryPoint +import org.thoughtcrime.securesms.webrtc.AudioManagerCommand +import org.thoughtcrime.securesms.webrtc.CallManager import java.util.* +import javax.inject.Inject @AndroidEntryPoint class WebRtcCallService: Service() { + @Inject lateinit var callManager: CallManager + companion object { private const val ACTION_UPDATE = "UPDATE" private const val ACTION_STOP = "STOP" @@ -18,6 +23,7 @@ class WebRtcCallService: Service() { private const val ACTION_LOCAL_HANGUP = "LOCAL_HANGUP" private const val ACTION_WANTS_BLUETOOTH = "WANTS_BLUETOOTH" private const val ACTION_CHANGE_POWER_BUTTON = "CHANGE_POWER_BUTTON" + private const val ACTION_SEND_AUDIO_COMMAND = "SEND_AUDIO_COMMAND" private const val EXTRA_UPDATE_TYPE = "UPDATE_TYPE" private const val EXTRA_RECIPIENT_ID = "RECIPIENT_ID" @@ -28,30 +34,34 @@ class WebRtcCallService: Service() { fun update(context: Context, type: Int, callId: UUID) { val intent = Intent(context, WebRtcCallService::class.java) - intent.setAction(ACTION_UPDATE) + .setAction(ACTION_UPDATE) .putExtra(EXTRA_RECIPIENT_ID, callId) .putExtra(EXTRA_UPDATE_TYPE, type) - ContextCompat.startForegroundService(context, intent) } fun stop(context: Context) { val intent = Intent(context, WebRtcCallService::class.java) - intent.action = ACTION_STOP - + .setAction(ACTION_STOP) ContextCompat.startForegroundService(context, intent) } - fun denyCallIntent(context: Context): Intent { - return Intent(context, WebRtcCallService::class.java).setAction(ACTION_DENY_CALL) - } + fun denyCallIntent(context: Context) = Intent(context, WebRtcCallService::class.java).setAction(ACTION_DENY_CALL) - fun hangupIntent(context: Context): Intent { - return Intent(context, WebRtcCallService::class.java).setAction(ACTION_LOCAL_HANGUP) - } + fun hangupIntent(context: Context) = Intent(context, WebRtcCallService::class.java).setAction(ACTION_LOCAL_HANGUP) fun sendAudioManagerCommand(context: Context, command: AudioManagerCommand) { + val intent = Intent(context, WebRtcCallService::class.java) + .setAction(ACTION_SEND_AUDIO_COMMAND) + .putExtra(EXTRA_AUDIO_COMMAND, command) + ContextCompat.startForegroundService(context, intent) + } + fun changePowerButtonReceiver(context: Context, register: Boolean) { + val intent = Intent(context, WebRtcCallService::class.java) + .setAction(ACTION_CHANGE_POWER_BUTTON) + .putExtra(EXTRA_ENABLED, register) + ContextCompat.startForegroundService(context, intent) } } diff --git a/app/src/main/java/org/thoughtcrime/securesms/webrtc/AudioManagerCommand.kt b/app/src/main/java/org/thoughtcrime/securesms/webrtc/AudioManagerCommand.kt index 0d4d15aef5..7b1d69a80d 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/webrtc/AudioManagerCommand.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/webrtc/AudioManagerCommand.kt @@ -4,6 +4,10 @@ import android.os.Parcelable import kotlinx.android.parcel.Parcelize @Parcelize -enum class AudioManagerCommand: Parcelable { - +sealed class AudioManagerCommand: Parcelable { + @Parcelize object StartOutgoingRinger: AudioManagerCommand() + @Parcelize object SilenceIncomingRinger: AudioManagerCommand() + @Parcelize object Start: AudioManagerCommand() + @Parcelize object Stop: AudioManagerCommand() + @Parcelize object SetUserDevice: AudioManagerCommand() } \ No newline at end of file diff --git a/app/src/main/java/org/thoughtcrime/securesms/webrtc/CallManager.kt b/app/src/main/java/org/thoughtcrime/securesms/webrtc/CallManager.kt new file mode 100644 index 0000000000..dde706a507 --- /dev/null +++ b/app/src/main/java/org/thoughtcrime/securesms/webrtc/CallManager.kt @@ -0,0 +1,4 @@ +package org.thoughtcrime.securesms.webrtc + +class CallManager { +} \ No newline at end of file