-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Every call is always recorded initially and the rules determine if the recording should be deleted at the end of the call. The user can override the rules during the middle of a call by using the Delete and Restore buttons in BCR's notification. This allows the user to decide to keep the recording later in the call, even if auto-record was disabled for the caller. The supported rule types are: * Specific contact * Unknown calls * All other calls If BCR is not granted the Contacts permission, then only "All other calls" will be available. For simplicity of implementation, there is no way to add rules for specific phone numbers--only contacts. This way Android can do the hard work of performing phone number comparisons. Rules are processed in order and while the rule matching mechanism can handle an arbitrary rule order, the configuration interface enforces that all the contact rules come first in sorted order, followed by "Unknown calls" and "All other calls". This is again done for simplicity of implementation. This should be sufficient for most use cases, with the caveat that conference calls will follow whichever rule matches first for any of the participants in the call. This rule mechanism replaces the old "initially paused" setting. Pausing and unpausing no longer has any relation to whether a recording is kept. The old setting will be migrated to the new "Unknown calls" and "All other calls" rules. Fixes: #320 Signed-off-by: Andrew Gunnerson <[email protected]>
- Loading branch information
1 parent
718ac05
commit 0a169a9
Showing
30 changed files
with
1,049 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package com.chiller3.bcr | ||
|
||
import android.Manifest | ||
import android.content.Context | ||
import android.net.Uri | ||
import android.provider.ContactsContract | ||
import androidx.annotation.RequiresPermission | ||
|
||
private val PROJECTION = arrayOf( | ||
ContactsContract.PhoneLookup.LOOKUP_KEY, | ||
ContactsContract.PhoneLookup.DISPLAY_NAME, | ||
) | ||
|
||
data class ContactInfo( | ||
val lookupKey: String, | ||
val displayName: String, | ||
) | ||
|
||
@RequiresPermission(Manifest.permission.READ_CONTACTS) | ||
fun findContactsByPhoneNumber(context: Context, number: String) = iterator { | ||
// Same heuristic as InCallUI's PhoneNumberHelper.isUriNumber() | ||
val numberIsSip = number.contains("@") || number.contains("%40") | ||
|
||
val uri = ContactsContract.PhoneLookup.ENTERPRISE_CONTENT_FILTER_URI.buildUpon() | ||
.appendPath(number) | ||
.appendQueryParameter( | ||
ContactsContract.PhoneLookup.QUERY_PARAMETER_SIP_ADDRESS, | ||
numberIsSip.toString()) | ||
.build() | ||
|
||
context.contentResolver.query(uri, PROJECTION, null, null, null)?.use { cursor -> | ||
val indexLookupKey = cursor.getColumnIndexOrThrow(ContactsContract.PhoneLookup.LOOKUP_KEY) | ||
val indexName = cursor.getColumnIndexOrThrow(ContactsContract.PhoneLookup.DISPLAY_NAME) | ||
|
||
if (cursor.moveToFirst()) { | ||
yield(ContactInfo(cursor.getString(indexLookupKey), cursor.getString(indexName))) | ||
|
||
while (cursor.moveToNext()) { | ||
yield(ContactInfo(cursor.getString(indexLookupKey), cursor.getString(indexName))) | ||
} | ||
} | ||
} | ||
} | ||
|
||
@RequiresPermission(Manifest.permission.READ_CONTACTS) | ||
fun findContactByLookupKey(context: Context, lookupKey: String): ContactInfo? { | ||
val uri = ContactsContract.Contacts.CONTENT_LOOKUP_URI.buildUpon() | ||
.appendPath(lookupKey) | ||
.build() | ||
|
||
context.contentResolver.query(uri, PROJECTION, null, null, null)?.use { cursor -> | ||
val indexLookupKey = cursor.getColumnIndexOrThrow(ContactsContract.PhoneLookup.LOOKUP_KEY) | ||
val indexName = cursor.getColumnIndexOrThrow(ContactsContract.PhoneLookup.DISPLAY_NAME) | ||
|
||
if (cursor.moveToFirst()) { | ||
return ContactInfo(cursor.getString(indexLookupKey), cursor.getString(indexName)) | ||
} | ||
} | ||
|
||
return null | ||
} | ||
|
||
fun getContactByUri(context: Context, uri: Uri): ContactInfo? { | ||
context.contentResolver.query(uri, PROJECTION, null, null, null)?.use { cursor -> | ||
val indexLookupKey = cursor.getColumnIndexOrThrow(ContactsContract.PhoneLookup.LOOKUP_KEY) | ||
val indexName = cursor.getColumnIndexOrThrow(ContactsContract.PhoneLookup.DISPLAY_NAME) | ||
|
||
if (cursor.moveToFirst()) { | ||
return ContactInfo(cursor.getString(indexLookupKey), cursor.getString(indexName)) | ||
} | ||
} | ||
|
||
return null | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.