basic screening service watch unknown number call
This commit is contained in:
parent
c452c04931
commit
59bf1ade88
29
app/src/main/java/com/bshield/caller/ScreeningService.kt
Normal file
29
app/src/main/java/com/bshield/caller/ScreeningService.kt
Normal 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())
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user