package com.adealink.weparty.room.service

import android.Manifest
import android.content.Context
import android.content.pm.PackageManager
import androidx.core.content.ContextCompat
import com.adealink.weparty.foregroundservice.AbsAudioForegroundService
import com.adealink.weparty.foregroundservice.base.ServiceLauncher

class RoomAudioForegroundService : AbsAudioForegroundService(launcher) {

    override fun provideChannelId() = "rtc_uikit_audio_foreground_service"

    companion object {
        internal val launcher =
            ServiceLauncher(RoomAudioForegroundService::class.java, "RoomAudioForegroundService")

        @JvmStatic
        fun start(context: Context, title: String?, description: String?, icon: Int) {
            launcher.start(context, title, description, icon) {
                ContextCompat.checkSelfPermission(context, Manifest.permission.RECORD_AUDIO) == PackageManager.PERMISSION_GRANTED
            }
        }

        @JvmStatic
        fun stop(context: Context) = launcher.stop(context)
    }
}