basic screening service watch unknown number call

This commit is contained in:
nganhkhoa 2024-07-16 21:34:37 +07:00
parent c452c04931
commit 59bf1ade88

View File

@ -0,0 +1,29 @@
package com.bshield.caller
import android.telecom.Call
import android.telecom.CallScreeningService
import android.util.Log
class ScreeningService : CallScreeningService() {
fun isBlocked(phone: String): Boolean {
Log.d("scamblock", "check phone " + phone);
return false;
}
override fun onScreenCall(callDetails: Call.Details) {
val callResponseBuilder = CallResponse.Builder()
// Make sure to remove the tel prefix and extract the phone number
val phoneNumber = callDetails.handle.toString()
if (isBlocked(phoneNumber)) {
callResponseBuilder.apply {
setRejectCall(true)
setDisallowCall(true)
setSkipCallLog(false)
}
}
respondToCall(callDetails, CallResponse.Builder().build())
}
}