chenxiaolong / BCR

A Basic Call Recorder for rooted Android devices
GNU General Public License v3.0
1.76k stars 113 forks source link

Work around READ_CALL_LOG being hard-restricted #308

Closed chenxiaolong closed 1 year ago

chenxiaolong commented 1 year ago

Since Android 10, READ_CALL_LOG has been marked as a hard-restricted permission, which prevents it from being granted by the user unless the app is given an exemption. There are three types of exemptions: system, upgrade, and installer.

System exemptions can be given by /system/etc/default-permissions (only on first boot) or via roles. Neither are usable for BCR. Upgrade exemptions are only given during Android OS upgrades that further restrict existing permissions. Installer exemptions are given by whichever app installs another app, but there's no installer when it comes to adding new system apps, like BCR.

Since AOSP has no sane built-in way to exempt BCR from the hard restriction, we'll do it ourselves. This commit introduces a new CLI utility baked in BCR that will talk to PermissionManager (Android 11+) or PackageManager (Android 10) to adjust its permission flags. This will unfortunately require two flashes (but only one reboot) for the initial install, because BCR must have already been loaded by the package manager for the flags to be changed. However, once the exemption has been granted, it persists across future upgrades.

Fixes: #304

chenxiaolong commented 1 year ago

Test build: BCR-1.40.r6.g62324b3-debug.zip