Fairphone 4: Stock camera on LineageOS

I bought a used Fairphone 4 and installed LineageOS with MicroG on it after unlocking the bootloader. One of the original Fairphone apps I wanted to use was the stock camera app "FPCamera.apk" (com.fp.camera). At first I extracted it from the official firmware download FP4-TP1V-factory.zip with the help of simg2img (from android-sdk-libsparse-utils) and lpunpack:

$ unzip FP4-TP1V-factory.zip images/super.img
$ file super.img
super.img: Android sparse image, version: 1.0, Total of 1572864 4096-byte output blocks in 226 input chunks.
$ simg2img super.img super.nonsparse.img
$ file super.nonsparse.img
super.nonsparse.img: data
$ binwalk super.nonsparse.img
1048576       0x100000        Linux EXT filesystem, blocks count: 277, image size: 283648, rev 1.0, ext2 filesystem data, UUID=f9a4283a-08b7-55e3-b63b-e404b5acb5ac, volume name "odm"
$ lpunpack super.nonsparse.img extracted
Extracting partition [odm_a] .... [ok]
Extracting partition [odm_b] .... [ok]
Extracting partition [product_a] .... [ok]
Extracting partition [product_b] .... [ok]
Extracting partition [system_a] .... [ok]
Extracting partition [system_b] .... [ok]
Extracting partition [system_ext_a] .... [ok]
Extracting partition [system_ext_b] .... [ok]
Extracting partition [vendor_a] .... [ok]
Extracting partition [vendor_b] .... [ok]
$ cd extracted
$ file system_a.img
system_a.img: Linux rev 1.0 ext2 filesystem data, UUID=2aa70c42-cce6-5610-9956-5fcc24a421ec (extents) (large files) (huge files)
$ mkdir system_a
$ sudo mount -o ro system_a.img system_a
$ cp system_a/system/priv-app/FPCamera/FPCamera.apk .

Then I installed FPCamera.apk onto the LineageOS Fairphone with adb install. Upon starting the camera app, I asked for some permissions and then said:

Permissions denied. You can change them in Settings > Apps.

I already had given it all permissions it asked for and that were selectable: Camera, Microphone, Location.

adb logcat showed that it asks for another permission WRITE_EXTERNAL_STORAGE:

CAM_PermissionUtils: checkPermissions, [android.permission.WRITE_EXTERNAL_STORAGE]
ActivityTaskManager: START u0 {act=android.content.pm.action.REQUEST_PERMISSIONS pkg=com.android.permissioncontroller cmp=com.android.permissioncontroller/.permission.ui.GrantPermissionsActivity (has extras)} from uid 10190
CompatibilityChangeReporter: Compat change id reported: 174042980; UID 10190; state: DISABLED
CAM_QuickActivity: onCreate return,  by permission check!

It turns out that Android 13 does not allow apps to ask for that permission anymore as described in Android Developers: Granular media permissions and WRITE_EXTERNAL_STORAGE:

Note: If your app targets Build.VERSION_CODES.R (Android 11) or higher, this permission has no effect.

So the Fairphone camera app has a higher target but the code was not adjusted - on the Fairphone OS, this is not needed because Camera is a system app with pre-allowed permissions in system/etc/permissions/privapp-permissions-platform.xml.

The solution is to manually give the permission via adb:

$ adb shell pm grant com.fp.camera android.permission.WRITE_EXTERNAL_STORAGE

The Fairphone Camera app expects "Google Photos" to be installed, otherwise you cannot view the taken photos. Installing the camera proxy app solved that problem.

Screenshot of the Fairphone 4 stock camera app

Written by Christian Weiske.

Comments? Please send an e-mail.