Added "Block Hidden" account setting
This commit is contained in:
@@ -960,6 +960,8 @@ class BaresipService: Service() {
|
||||
getString(R.string.call_blocked),
|
||||
Utils.friendlyUri(this, peerUri, ua.account)
|
||||
)
|
||||
else if (ua.account.blockHidden && peerUri.contains("anonymous"))
|
||||
getString(R.string.hidden_call_blocked)
|
||||
else if (!Utils.checkPermissions(this, arrayOf(RECORD_AUDIO)))
|
||||
getString(R.string.no_calls)
|
||||
else
|
||||
@@ -969,7 +971,8 @@ class BaresipService: Service() {
|
||||
Api.sip_treply(callp, 486, "Busy Here")
|
||||
Api.bevent_stop(ev[2].toLong())
|
||||
toast(toastMsg)
|
||||
if (toastMsg.contains(getString(R.string.call_blocked))) {
|
||||
if (toastMsg.contains(getString(R.string.call_blocked)) ||
|
||||
toastMsg.contains(getString(R.string.hidden_call_blocked))) {
|
||||
if (ua.account.callHistory)
|
||||
Blocked(
|
||||
ua.account.aor,
|
||||
@@ -1372,7 +1375,10 @@ class BaresipService: Service() {
|
||||
return
|
||||
}
|
||||
|
||||
if (ua.account.blockUnknown && Contact.contactName(peerUri) == peerUri) {
|
||||
val blockedHidden = ua.account.blockHidden && peerUri.contains("anonymous")
|
||||
val blockedUnknown = ua.account.blockUnknown && Contact.contactName(peerUri) == peerUri
|
||||
|
||||
if (blockedHidden || blockedUnknown) {
|
||||
Log.d(TAG, "Auto-rejecting incoming message by $uap from $peerUri")
|
||||
Blocked(
|
||||
ua.account.aor,
|
||||
@@ -1380,13 +1386,14 @@ class BaresipService: Service() {
|
||||
"message",
|
||||
GregorianCalendar().timeInMillis
|
||||
).add()
|
||||
toast(String.format(
|
||||
toast(if (blockedHidden)
|
||||
getString(R.string.hidden_message_blocked)
|
||||
else
|
||||
String.format(
|
||||
getString(R.string.message_blocked),
|
||||
Utils.friendlyUri(this, peerUri, ua.account)
|
||||
)
|
||||
)
|
||||
// Api.sip_treply(callp, 486, "Busy Here")
|
||||
// Api.bevent_stop(bevent)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1968,6 +1975,23 @@ class BaresipService: Service() {
|
||||
|
||||
if (isIncoming) {
|
||||
val e164Uri = e164Uri(uri, ua.account.countryCode)
|
||||
val presentation = telecomCall.details.handlePresentation
|
||||
if (ua.account.blockHidden &&
|
||||
(presentation == TelecomManager.PRESENTATION_RESTRICTED ||
|
||||
presentation == TelecomManager.PRESENTATION_UNKNOWN)) {
|
||||
Log.d(TAG, "Auto-rejecting incoming PSTN hidden call")
|
||||
telecomCall.disconnect()
|
||||
toast(getString(R.string.hidden_call_blocked))
|
||||
if (ua.account.callHistory) {
|
||||
Blocked(
|
||||
ua.account.aor,
|
||||
uri,
|
||||
"invite",
|
||||
GregorianCalendar().timeInMillis
|
||||
).add()
|
||||
}
|
||||
return
|
||||
}
|
||||
if (ua.account.blockUnknown && Contact.contactName(e164Uri) == e164Uri) {
|
||||
Log.d(TAG, "Auto-rejecting incoming PSTN call from $uri")
|
||||
telecomCall.disconnect()
|
||||
|
||||
Reference in New Issue
Block a user