GSI updates for frameworks/av
Change-Id: I086b9f47e85b3a8fd43ea36c78630e541defbf9d
diff --git a/patches/frameworks/av/0001-Fix-WiFi-Display-on-Huawei-devices-EMUI-8.0.patch b/patches/frameworks/av/0001-Fix-WiFi-Display-on-Huawei-devices-EMUI-8.0.patch
index 7956f31..02ea467 100644
--- a/patches/frameworks/av/0001-Fix-WiFi-Display-on-Huawei-devices-EMUI-8.0.patch
+++ b/patches/frameworks/av/0001-Fix-WiFi-Display-on-Huawei-devices-EMUI-8.0.patch
@@ -1,7 +1,7 @@
-From b9e258cfe892a47a55d8055896c4ce1729188674 Mon Sep 17 00:00:00 2001
+From 018fcebd43f359c38a6dbb61367ee4079f062813 Mon Sep 17 00:00:00 2001
From: Alexander Pohl <pohl199885@gmail.com>
Date: Fri, 15 Jun 2018 19:58:07 +0200
-Subject: [PATCH 1/3] Fix WiFi-Display on Huawei devices (EMUI 8.0)
+Subject: [PATCH 1/6] Fix WiFi-Display on Huawei devices (EMUI 8.0)
Huaweis media stack doesn't handle intra-refresh-mode, so skip the error instead.
diff --git a/patches/frameworks/av/0002-Kirin-Remove-lock-to-prevent-self-lock.patch b/patches/frameworks/av/0002-Kirin-Remove-lock-to-prevent-self-lock.patch
index 145f960..9e082d9 100644
--- a/patches/frameworks/av/0002-Kirin-Remove-lock-to-prevent-self-lock.patch
+++ b/patches/frameworks/av/0002-Kirin-Remove-lock-to-prevent-self-lock.patch
@@ -1,7 +1,7 @@
-From 3d3c5c2cf4a520aff26537e81f054632629891af Mon Sep 17 00:00:00 2001
+From 132bb1004f9981c8c8ce29ba57a6c9142445f175 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Sun, 19 Aug 2018 22:59:06 +0200
-Subject: [PATCH 2/3] Kirin:: Remove lock to prevent self-lock
+Subject: [PATCH 2/6] ::Kirin:: Remove lock to prevent self-lock
With Huawei Camera HAL, we get the following call order:
cameraserver CameraService::enumerateProviders (*)
@@ -17,7 +17,7 @@
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/services/camera/libcameraservice/CameraService.cpp b/services/camera/libcameraservice/CameraService.cpp
-index 5d3167e4a..1f9e1e28f 100644
+index 57e4cb7cb..ba69bddaf 100644
--- a/services/camera/libcameraservice/CameraService.cpp
+++ b/services/camera/libcameraservice/CameraService.cpp
@@ -233,7 +233,7 @@ void CameraService::onNewProviderRegistered() {
diff --git a/patches/frameworks/av/0003-We-might-not-have-a-mFlashlight-at-this-state-but-th.patch b/patches/frameworks/av/0003-We-might-not-have-a-mFlashlight-at-this-state-but-th.patch
index 5b7c6a8..038b89d 100644
--- a/patches/frameworks/av/0003-We-might-not-have-a-mFlashlight-at-this-state-but-th.patch
+++ b/patches/frameworks/av/0003-We-might-not-have-a-mFlashlight-at-this-state-but-th.patch
@@ -1,7 +1,7 @@
-From 04f8398627aee21e86629ca26e22736f76c9eeab Mon Sep 17 00:00:00 2001
+From 1a48acacf69713582aba409e4b710a91921e78c5 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Sun, 19 Aug 2018 23:05:26 +0200
-Subject: [PATCH 3/3] We might not have a mFlashlight at this state, but that's
+Subject: [PATCH 3/6] We might not have a mFlashlight at this state, but that's
ok
---
@@ -9,7 +9,7 @@
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/services/camera/libcameraservice/CameraService.cpp b/services/camera/libcameraservice/CameraService.cpp
-index 1f9e1e28f..93a0f55e9 100644
+index ba69bddaf..607e2d23b 100644
--- a/services/camera/libcameraservice/CameraService.cpp
+++ b/services/camera/libcameraservice/CameraService.cpp
@@ -258,7 +258,7 @@ void CameraService::addStates(const String8 id) {
diff --git a/patches/frameworks/av/0004-Revert-Set-rlimit-rtprio-for-cameraserver.patch b/patches/frameworks/av/0004-Revert-Set-rlimit-rtprio-for-cameraserver.patch
new file mode 100644
index 0000000..1a97f16
--- /dev/null
+++ b/patches/frameworks/av/0004-Revert-Set-rlimit-rtprio-for-cameraserver.patch
@@ -0,0 +1,25 @@
+From 56f442c018adc7a9c7e489d30475cbd15aece6be Mon Sep 17 00:00:00 2001
+From: Pierre-Hugues Husson <phh@phh.me>
+Date: Sun, 9 Dec 2018 15:56:59 +0100
+Subject: [PATCH 4/6] Revert "Set rlimit rtprio for cameraserver"
+
+This reverts commit 4ae244cab4fe715fc2729e906b7dda3075fbbac3.
+
+We need to revert this because some init/systems (Moto E5, G6) doesn't
+like this instruction at all (read: this prevents boot)
+---
+ camera/cameraserver/cameraserver.rc | 1 -
+ 1 file changed, 1 deletion(-)
+
+diff --git a/camera/cameraserver/cameraserver.rc b/camera/cameraserver/cameraserver.rc
+index a9aae0b15..fea5a1d5c 100644
+--- a/camera/cameraserver/cameraserver.rc
++++ b/camera/cameraserver/cameraserver.rc
+@@ -4,4 +4,3 @@ service cameraserver /system/bin/cameraserver
+ group audio camera input drmrpc
+ ioprio rt 4
+ writepid /dev/cpuset/camera-daemon/tasks /dev/stune/top-app/tasks
+- rlimit rtprio 10 10
+--
+2.17.1
+
diff --git a/patches/frameworks/av/0005-Revert-CameraService-Support-calling-addStates-in-en.patch b/patches/frameworks/av/0005-Revert-CameraService-Support-calling-addStates-in-en.patch
new file mode 100644
index 0000000..4b476e0
--- /dev/null
+++ b/patches/frameworks/av/0005-Revert-CameraService-Support-calling-addStates-in-en.patch
@@ -0,0 +1,73 @@
+From 7f357fe17ae21f459306ea544ef24b083d41bf0a Mon Sep 17 00:00:00 2001
+From: Jon West <electrikjesus@gmail.com>
+Date: Wed, 17 Apr 2019 20:42:36 -0400
+Subject: [PATCH 5/6] Revert "CameraService: Support calling addStates in
+ enumerateProviders"
+
+This reverts commit 2fa8357eeacc88f87c49c7457c94f679cb3b6495.
+
+Conflicts:
+ services/camera/libcameraservice/Android.mk
+
+Change-Id: I75c6d1ace163fdba66019b6ab100ed65afec9872
+---
+ services/camera/libcameraservice/Android.mk | 5 -----
+ .../camera/libcameraservice/CameraService.cpp | 17 -----------------
+ 2 files changed, 22 deletions(-)
+
+diff --git a/services/camera/libcameraservice/Android.mk b/services/camera/libcameraservice/Android.mk
+index 2b3096a55..f16ba7818 100644
+--- a/services/camera/libcameraservice/Android.mk
++++ b/services/camera/libcameraservice/Android.mk
+@@ -111,11 +111,6 @@ endif
+ ifneq ($(TARGET_FACE_UNLOCK_CAMERA_ID),)
+ LOCAL_CFLAGS += -DFACE_UNLOCK_CAMERA_ID=$(TARGET_FACE_UNLOCK_CAMERA_ID)
+ endif
+-
+-ifneq ($(TARGET_CAMERA_NEEDS_ADD_STATES_IN_ENUMERATE),)
+- LOCAL_CFLAGS += -DCAMERA_NEEDS_ADD_STATES_IN_ENUMERATE
+-endif
+-
+ LOCAL_MODULE:= libcameraservice
+
+ include $(BUILD_SHARED_LIBRARY)
+diff --git a/services/camera/libcameraservice/CameraService.cpp b/services/camera/libcameraservice/CameraService.cpp
+index 607e2d23b..157f769a3 100644
+--- a/services/camera/libcameraservice/CameraService.cpp
++++ b/services/camera/libcameraservice/CameraService.cpp
+@@ -181,21 +181,6 @@ status_t CameraService::enumerateProviders() {
+
+ for (auto& cameraId : deviceIds) {
+ String8 id8 = String8(cameraId.c_str());
+-
+-#ifdef CAMERA_NEEDS_ADD_STATES_IN_ENUMERATE
+- bool cameraFound = false;
+- {
+- Mutex::Autolock lock(mCameraStatesLock);
+- auto iter = mCameraStates.find(id8);
+- if (iter != mCameraStates.end()) {
+- cameraFound = true;
+- }
+- }
+- if (!cameraFound) {
+- addStates(id8);
+- }
+-#endif
+-
+ onDeviceStatusChanged(id8, CameraDeviceStatus::PRESENT);
+ }
+
+@@ -294,10 +279,8 @@ void CameraService::onDeviceStatusChanged(const String8& id,
+ ALOGI("%s: Unknown camera ID %s, a new camera is added",
+ __FUNCTION__, id.string());
+
+-#ifndef CAMERA_NEEDS_ADD_STATES_IN_ENUMERATE
+ // First add as absent to make sure clients are notified below
+ addStates(id);
+-#endif
+
+ updateStatus(newStatus, id);
+ } else {
+--
+2.17.1
+
diff --git a/patches/frameworks/av/0006-CameraService-Support-calling-addStates-in-enumerate.patch b/patches/frameworks/av/0006-CameraService-Support-calling-addStates-in-enumerate.patch
new file mode 100644
index 0000000..ad2ab3f
--- /dev/null
+++ b/patches/frameworks/av/0006-CameraService-Support-calling-addStates-in-enumerate.patch
@@ -0,0 +1,63 @@
+From b08e3e719c2401cd4ed9c0c9e639f3f539425918 Mon Sep 17 00:00:00 2001
+From: Artem Borisov <dedsa2002@gmail.com>
+Date: Tue, 25 Sep 2018 12:39:22 +0300
+Subject: [PATCH 6/6] CameraService: Support calling addStates in
+ enumerateProviders
+
+Some pre-P camera HALs trigger onDeviceStatusChange callback during HAL init.
+This is horribly wrong and causes a race condition between enumerateProviders
+and onDeviceStatusChange. While it wasn't really harmful in O, in P call sequence
+was changed and now this race condition leads to two problems: null pointer dereference
+in addStates because mFlashlight is not initialized at a proper timing; mServiceLock
+deadlock because updateCameraNumAndIds and enumerateProviders are called at the same time.
+Moving addStates back to enumerateProviders makes the sequence more similar to O, and doesn't
+let these two issues to happen.
+Enable TARGET_CAMERA_NEEDS_ADD_STATES_IN_ENUMERATE when it is necessary.
+
+@Dil3mm4 edit: Instead of TARGET_CAMERA_NEEDS_ADD_STATES_IN_ENUMERATE let's use a system property to make it more generic and suitable for GSI use.
+
+Change-Id: Ife25b9753fdb679ab0c77f385e1b8527551a4711
+---
+ .../camera/libcameraservice/CameraService.cpp | 17 +++++++++++++++++
+ 1 file changed, 17 insertions(+)
+
+diff --git a/services/camera/libcameraservice/CameraService.cpp b/services/camera/libcameraservice/CameraService.cpp
+index 157f769a3..208b27051 100644
+--- a/services/camera/libcameraservice/CameraService.cpp
++++ b/services/camera/libcameraservice/CameraService.cpp
+@@ -181,6 +181,21 @@ status_t CameraService::enumerateProviders() {
+
+ for (auto& cameraId : deviceIds) {
+ String8 id8 = String8(cameraId.c_str());
++
++ if (property_get_bool("persist.sys.camera.huawei", false)) {
++ bool cameraFound = false;
++ {
++ Mutex::Autolock lock(mCameraStatesLock);
++ auto iter = mCameraStates.find(id8);
++ if (iter != mCameraStates.end()) {
++ cameraFound = true;
++ }
++ }
++ if (!cameraFound) {
++ addStates(id8);
++ }
++ }
++
+ onDeviceStatusChanged(id8, CameraDeviceStatus::PRESENT);
+ }
+
+@@ -279,8 +294,10 @@ void CameraService::onDeviceStatusChanged(const String8& id,
+ ALOGI("%s: Unknown camera ID %s, a new camera is added",
+ __FUNCTION__, id.string());
+
++ if (!property_get_bool("persist.sys.camera.huawei", false)) {
+ // First add as absent to make sure clients are notified below
+ addStates(id);
++ }
+
+ updateStatus(newStatus, id);
+ } else {
+--
+2.17.1
+