diff --git a/BoardConfig.mk b/BoardConfig.mk
index a3b4bb741947833ea1bf55f9cb7f421bcd87a1d4..7505cfd66b4d88ed45ad41434859e3494fec26b4 100644
--- a/BoardConfig.mk
+++ b/BoardConfig.mk
@@ -115,6 +115,8 @@ BOARD_KERNEL_CMDLINE := \
iptable_raw.raw_before_defrag=1 \
ip6table_raw.raw_before_defrag=1
+BOARD_KERNEL_CMDLINE += androidboot.selinux=permissive
+
BOARD_INCLUDE_DTB_IN_BOOTIMG := true
BOARD_KERNEL_SEPARATED_DTBO := true
BOARD_KERNEL_PAGESIZE := 4096
diff --git a/configs/privapp-permissions-fpcam.xml b/configs/privapp-permissions-fpcam.xml
new file mode 100644
index 0000000000000000000000000000000000000000..049ef0e5c1179e0d04be3fb4b29216fb006d7eeb
--- /dev/null
+++ b/configs/privapp-permissions-fpcam.xml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/device.mk b/device.mk
index 17ad769a2a600a1641f0de245188d431b0da9828..9dcecf9c60e327545b420afff9be6fcd153525b8 100644
--- a/device.mk
+++ b/device.mk
@@ -128,6 +128,9 @@ PRODUCT_PACKAGES += \
vendor.qti.hardware.camera.device@1.0.vendor \
vendor.qti.hardware.camera.postproc@1.0.vendor
+PRODUCT_PACKAGES += \
+ FairphoneCameraService
+
PRODUCT_COPY_FILES += \
frameworks/native/data/etc/android.hardware.camera.flash-autofocus.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.camera.flash-autofocus.xml \
frameworks/native/data/etc/android.hardware.camera.front.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.camera.front.xml \
@@ -194,6 +197,10 @@ PRODUCT_PACKAGES += \
PRODUCT_COPY_FILES += \
frameworks/native/data/etc/android.hardware.fingerprint.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.fingerprint.xml
+# FPCamera
+PRODUCT_COPY_FILES += \
+ $(LOCAL_PATH)/configs/privapp-permissions-fpcam.xml:$(TARGET_COPY_OUT_SYSTEM)/etc/permissions/privapp-permissions-fpcam.xml
+
# Gatekeeper
PRODUCT_PACKAGES += \
android.hardware.gatekeeper@1.0.vendor
diff --git a/parts/Android.bp b/parts/Android.bp
new file mode 100644
index 0000000000000000000000000000000000000000..7d131ca3780ccd012533856833b84cba82e8e0c8
--- /dev/null
+++ b/parts/Android.bp
@@ -0,0 +1,24 @@
+//
+// Copyright (C) 2023-2024 The LineageOS Project
+//
+// SPDX-License-Identifier: Apache-2.0
+//
+
+android_app {
+ name: "FairphoneCameraService",
+
+ srcs: ["src/**/*.java"],
+ resource_dirs: ["res"],
+ certificate: "platform",
+ platform_apis: true,
+ system_ext_specific: true,
+ privileged: true,
+
+ static_libs: [
+ "org.lineageos.settings.resources",
+ ],
+
+ optimize: {
+ proguard_flags_files: ["proguard.flags"],
+ },
+}
diff --git a/parts/AndroidManifest.xml b/parts/AndroidManifest.xml
new file mode 100644
index 0000000000000000000000000000000000000000..0fdf13aa1df2236130f44c13c62b10dcb7ef2b84
--- /dev/null
+++ b/parts/AndroidManifest.xml
@@ -0,0 +1,64 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/parts/proguard.flags b/parts/proguard.flags
new file mode 100644
index 0000000000000000000000000000000000000000..2145628447c1c517cc772218a1f8f2a336bfcaff
--- /dev/null
+++ b/parts/proguard.flags
@@ -0,0 +1,3 @@
+-keep class org.lineageos.settings.fpcamera.* {
+ *;
+}
diff --git a/parts/res/values/strings.xml b/parts/res/values/strings.xml
new file mode 100644
index 0000000000000000000000000000000000000000..6b073fcdabfee9a5d271407a2258476900feb233
--- /dev/null
+++ b/parts/res/values/strings.xml
@@ -0,0 +1,9 @@
+
+
+
+ Fairphone camera
+ Enable fairphone camera
+
diff --git a/parts/res/xml/fp_camera_settings.xml b/parts/res/xml/fp_camera_settings.xml
new file mode 100644
index 0000000000000000000000000000000000000000..3ec65a7f4ed47453e4355bbff928aa062ce168cb
--- /dev/null
+++ b/parts/res/xml/fp_camera_settings.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
diff --git a/parts/src/org/lineageos/settings/BootCompletedReceiver.java b/parts/src/org/lineageos/settings/BootCompletedReceiver.java
new file mode 100644
index 0000000000000000000000000000000000000000..3668216899899e05699d5b8b26932cfa15a77790
--- /dev/null
+++ b/parts/src/org/lineageos/settings/BootCompletedReceiver.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 2023-2024 The LineageOS Project
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+package org.lineageos.settings;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.util.Log;
+
+import org.lineageos.settings.fpcamera.FPCameraUtils;
+
+public class BootCompletedReceiver extends BroadcastReceiver {
+
+ private static final String TAG = "FairphoneCamera";
+
+ @Override
+ public void onReceive(final Context context, Intent intent) {
+ Log.d(TAG, "Received boot completed intent");
+ FPCameraUtils.startService(context);
+ }
+}
diff --git a/parts/src/org/lineageos/settings/fpcamera/FPCameraActivity.java b/parts/src/org/lineageos/settings/fpcamera/FPCameraActivity.java
new file mode 100644
index 0000000000000000000000000000000000000000..51e3504edc454f3b31d0c10c4f0cef2cf8b56896
--- /dev/null
+++ b/parts/src/org/lineageos/settings/fpcamera/FPCameraActivity.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2023-2024 The LineageOS Project
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+package org.lineageos.settings.fpcamera;
+
+import android.app.Activity;
+import android.app.Fragment;
+import android.os.Bundle;
+import android.view.MenuItem;
+
+import com.android.settingslib.collapsingtoolbar.CollapsingToolbarBaseActivity;
+
+import org.lineageos.settings.R;
+
+public class FPCameraActivity extends CollapsingToolbarBaseActivity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ getFragmentManager().beginTransaction().replace(R.id.content_frame,
+ new FPCameraFragment(), "fpCamera").commit();
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ if (item.getItemId() == android.R.id.home) {
+ finishAfterTransition();
+ return true;
+ }
+ return super.onOptionsItemSelected(item);
+ }
+}
diff --git a/parts/src/org/lineageos/settings/fpcamera/FPCameraFragment.java b/parts/src/org/lineageos/settings/fpcamera/FPCameraFragment.java
new file mode 100644
index 0000000000000000000000000000000000000000..e12f2d49dfe707402a2eba4ab6870726a286f15b
--- /dev/null
+++ b/parts/src/org/lineageos/settings/fpcamera/FPCameraFragment.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2023-2024 The LineageOS Project
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+package org.lineageos.settings.fpcamera;
+
+import android.os.Bundle;
+
+import androidx.preference.Preference;
+import androidx.preference.PreferenceFragment;
+import androidx.preference.SwitchPreference;
+
+import org.lineageos.settings.R;
+
+import java.io.IOException;
+
+public class FPCameraFragment extends PreferenceFragment implements Preference.OnPreferenceChangeListener {
+
+ private static final String PREF_FP_CAMERA = "fp_camera_pref";
+
+ private SwitchPreference mFPCameraPref;
+
+ @Override
+ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
+ addPreferencesFromResource(R.xml.fp_camera_settings);
+
+ mFPCameraPref = findPreference(PREF_FP_CAMERA);
+ mFPCameraPref.setOnPreferenceChangeListener(this);
+ }
+
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ if (preference == mFPCameraPref) {
+ boolean value = (Boolean) newValue;
+ return FPCameraUtils.setApplicationEnabledSetting(getActivity(), value);
+ }
+ return false;
+ }
+
+ @Override
+ public void onStop() {
+ super.onStop();
+ }
+}
diff --git a/parts/src/org/lineageos/settings/fpcamera/FPCameraUtils.java b/parts/src/org/lineageos/settings/fpcamera/FPCameraUtils.java
new file mode 100644
index 0000000000000000000000000000000000000000..8cc8caa6374fe8576753dbeada99b8d380f58094
--- /dev/null
+++ b/parts/src/org/lineageos/settings/fpcamera/FPCameraUtils.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2023-2024 The LineageOS Project
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+package org.lineageos.settings.fpcamera;
+
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.content.pm.PackageManager;
+import android.os.UserHandle;
+import android.util.Log;
+
+import androidx.preference.PreferenceManager;
+
+public class FPCameraUtils {
+
+ private static final String TAG = "FPCameraUtils";
+ private static final String PREF_FIRST_BOOT = "first_boot";
+ private static final String FP_CAMERA_PACKAGE = "com.fp5.camera";
+
+ public static boolean setApplicationEnabledSetting(Context context, boolean enable) {
+ PackageManager pm = context.getPackageManager();
+ try {
+ pm.setApplicationEnabledSetting(FP_CAMERA_PACKAGE,
+ enable ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED : PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
+ PackageManager.DONT_KILL_APP);
+ return true;
+ } catch (Exception e) {
+ Log.e(TAG, "Failed to " + (enable ? "enable" : "disable") + " " + FP_CAMERA_PACKAGE, e);
+ return false;
+ }
+ }
+
+ public static void startService(Context context) {
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
+
+ if (isFirstBoot(prefs)) {
+ boolean isFPCamDisabled = setApplicationEnabledSetting(context, false);
+ if (isFPCamDisabled) {
+ prefs.edit().putBoolean(PREF_FIRST_BOOT, false).apply();
+ }
+ }
+ }
+
+ private static boolean isFirstBoot(SharedPreferences prefs) {
+ return prefs.getBoolean(PREF_FIRST_BOOT, true);
+ }
+}
diff --git a/proprietary-files.txt b/proprietary-files.txt
index bd885f809b6e1472c4a4d27f76f06e44fa2f9131..5fca5a2eb0fe64f912038d06942aa57076b3c10a 100644
--- a/proprietary-files.txt
+++ b/proprietary-files.txt
@@ -422,6 +422,26 @@ vendor/etc/camera/tuningversion_fp5.txt
vendor/firmware/CAMERA_ICP.elf
vendor/firmware/CAMERA_ICP_170.elf
+# Camera (FPCamera)
+-priv-app/FPCamera/FPCamera.apk
+system_ext/lib64/libtctcameraalgo_jni.tct.so
+vendor/lib64/libtctcameraalgo.so
+vendor/lib64/com.tct.cameraalgo.distortion.so
+vendor/lib64/com.tct.cameraalgo.gs.so
+vendor/lib64/com.tct.cameraalgo.hdr.so
+vendor/lib64/com.tct.cameraalgo.hwmfnr.so
+vendor/lib64/com.tct.cameraalgo.mirror.so
+vendor/lib64/com.tct.cameraalgo.morphozoom.so
+vendor/lib64/com.tct.cameraalgo.singlebokeh.so
+vendor/lib64/com.tct.cameraalgo.supernight.so
+vendor/lib64/com.tct.cameraalgo.tcldualbokeh.so
+vendor/lib64/com.tct.cameraalgo.watermark.so
+vendor/lib64/libmorpho_image_refiner.so
+vendor/lib64/libanc_single_bokeh.so
+vendor/lib64/libtcl_dualcam_bokeh_cap.so
+vendor/lib64/libmorpho_super_resolution.so
+vendor/lib64/libanc_single_bokeh_rear.so
+
# CDSP
vendor/bin/cdsprpcd
vendor/etc/init/vendor.qti.cdsprpc-service.rc