package com.humand.demo.modules.IncomingCallMessagingService.rn.callModule

import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.bridge.ReactContextBaseJavaModule
import com.facebook.react.bridge.ReactMethod
import com.facebook.react.bridge.Promise

class CallModule(private val reactContext: ReactApplicationContext) :
    ReactContextBaseJavaModule(reactContext) {

    override fun getName(): String {
        return "RNCallModule"
    }

    @ReactMethod
    fun onCallEnded(promise: Promise) {
        val activity = reactContext.currentActivity ?: run {
            promise.resolve("ok")
            return
        }

        activity.runOnUiThread {
            activity.apply {
                setShowWhenLocked(false)
                setTurnScreenOn(false)
            }

        }

        promise.resolve("ok")
    }
}
