Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SettingsActivity: Prompt for optional contacts permission on first enable #84

Merged
merged 2 commits into from
Jun 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ As the name alludes, BCR intends to be a basic as possible. The project will hav

4. Enable call recording and pick an output directory. If no output directory is selected or if the output directory is no longer accessible, then recordings will be saved to `/sdcard/Android/data/com.chiller3.bcr/files`.

When enabling call recording the first time, BCR will prompt for microphone, notification (Android 13+), and contacts permissions. Microphone and notification permissions are required for BCR to be able to record phone calls in the background.

The contacts permission is optional, but if allowed, contact names will be added to the recordings' filenames. BCR never sends contact information anywhere. In fact, it does not even have the `INTERNET` permission. However, other third party applications may be able to see the contact names if they can access the output directory.

5. To install future updates, there are a couple methods:

* If installed via Magisk, the module can be updated right from Magisk Manager's modules tab. Flashing the new version in Magisk manually also works just as well.
Expand Down
1 change: 1 addition & 0 deletions app/src/main/java/com/chiller3/bcr/Permissions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ object Permissions {
}

val REQUIRED: Array<String> = arrayOf(Manifest.permission.RECORD_AUDIO) + NOTIFICATION
val OPTIONAL: Array<String> = arrayOf(Manifest.permission.READ_CONTACTS)

private fun isGranted(context: Context, permission: String) =
ContextCompat.checkSelfPermission(context, permission) == PackageManager.PERMISSION_GRANTED
Expand Down
6 changes: 4 additions & 2 deletions app/src/main/java/com/chiller3/bcr/SettingsActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ class SettingsActivity : AppCompatActivity() {

private val requestPermissionRequired =
registerForActivityResult(ActivityResultContracts.RequestMultiplePermissions()) { granted ->
if (granted.all { it.value }) {
// Call recording can still be enabled if optional permissions were not granted
if (granted.all { it.key !in Permissions.REQUIRED || it.value }) {
prefCallRecording.isChecked = true
} else {
startActivity(Permissions.getAppInfoIntent(requireContext()))
Expand Down Expand Up @@ -174,7 +175,8 @@ class SettingsActivity : AppCompatActivity() {
prefCallRecording -> if (Permissions.haveRequired(context)) {
return true
} else {
requestPermissionRequired.launch(Permissions.REQUIRED)
// Ask for optional permissions the first time only
requestPermissionRequired.launch(Permissions.REQUIRED + Permissions.OPTIONAL)
}
// This is only reachable if battery optimization is not already inhibited
prefInhibitBatteryOpt -> requestInhibitBatteryOpt.launch(
Expand Down