Skip to content

Commit 1b24192

Browse files
aleastomikeNG
authored andcommitted
camera/media: Support legacy HALv1 camera in mediaserver
Pre 7.0 camera HALv1 can not share its video buffers across different processes, which requires us to disable this security feature. This change allows devices to re-integrate cameraserver and mediaserver which is the first step to support older prebuilt camera HALs. A follow-up change will add back support for legacy buffer handling. To enable: TARGET_HAS_LEGACY_CAMERA_HAL1 := true media.stagefright.legacyencoder=true media.stagefright.less-secure=true Change-Id: I4fcc8907ea235b7e83af26122b4da97ca5117816 mediaserver: Update HALv1 dependencies for 8.1.0 * Add libcameraservice shared library dependency * Add new libgui, [email protected] and [email protected] shared libraries and exported headers HAL dependencies * Match cameraserver HIDL additions and dependencies * When TARGET_HAS_LEGACY_CAMERA_HAL1 is set, the mediaserver includes CameraService.h but exported headers are missing * Error upon build due to missing libcameraservice linkage: fatal error: 'android/hardware/BnCameraService.h' file not found mediaserver: Update HALv1 dependencies for 9.0.0 * Disable active state UID validation for HAL1 devices Change-Id: Ib6bb8a4e9ef18606c64e2dff13504d2eeaac13b1 Signed-off-by: Adrian DC <[email protected]>
1 parent d27ee4e commit 1b24192

File tree

4 files changed

+46
-0
lines changed

4 files changed

+46
-0
lines changed

media/mediaserver/Android.bp

+18
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,23 @@ cc_binary {
4343
"-Wall",
4444
],
4545

46+
product_variables: {
47+
lineage: {
48+
has_legacy_camera_hal1: {
49+
overrides: ["cameraserver"],
50+
cflags: ["-DNO_CAMERA_SERVER"],
51+
shared_libs: [
52+
"libcameraservice",
53+
"libgui",
54+
"libhidlbase",
55+
"libhidltransport",
56+
57+
58+
59+
],
60+
},
61+
},
62+
},
63+
4664
vintf_fragments: ["manifest_media_c2_software.xml"],
4765
}

media/mediaserver/main_mediaserver.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@
2626
#include "RegisterExtensions.h"
2727

2828
// from LOCAL_C_INCLUDES
29+
#ifdef NO_CAMERA_SERVER
30+
#include "CameraService.h"
31+
#include <hidl/HidlTransportSupport.h>
32+
#endif
2933
#include "MediaPlayerService.h"
3034
#include "ResourceManagerService.h"
3135

@@ -35,12 +39,20 @@ int main(int argc __unused, char **argv __unused)
3539
{
3640
signal(SIGPIPE, SIG_IGN);
3741

42+
#ifdef NO_CAMERA_SERVER
43+
// Set 3 threads for HIDL calls
44+
hardware::configureRpcThreadpool(3, /*willjoin*/ false);
45+
#endif
46+
3847
sp<ProcessState> proc(ProcessState::self());
3948
sp<IServiceManager> sm(defaultServiceManager());
4049
ALOGI("ServiceManager: %p", sm.get());
4150
AIcu_initializeIcuOrDie();
4251
MediaPlayerService::instantiate();
4352
ResourceManagerService::instantiate();
53+
#ifdef NO_CAMERA_SERVER
54+
CameraService::instantiate();
55+
#endif
4456
registerExtensions();
4557
ProcessState::self()->startThreadPool();
4658
IPCThreadState::self()->joinThreadPool();

services/camera/libcameraservice/Android.bp

+8
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,14 @@ cc_library_shared {
133133
"-Wno-ignored-qualifiers",
134134
],
135135

136+
product_variables: {
137+
lineage: {
138+
has_legacy_camera_hal1: {
139+
cflags: ["-DNO_CAMERA_SERVER"],
140+
},
141+
},
142+
},
143+
136144
}
137145

138146
cc_library_shared {

services/camera/libcameraservice/CameraService.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -784,7 +784,11 @@ int32_t CameraService::mapToInterface(StatusInternal status) {
784784
Status CameraService::initializeShimMetadata(int cameraId) {
785785
int uid = CameraThreadState::getCallingUid();
786786

787+
#ifdef NO_CAMERA_SERVER
788+
String16 internalPackageName("media");
789+
#else
787790
String16 internalPackageName("cameraserver");
791+
#endif
788792
String8 id = String8::format("%d", cameraId);
789793
Status ret = Status::ok();
790794
sp<Client> tmp = nullptr;
@@ -865,7 +869,9 @@ Status CameraService::getLegacyParametersLazy(int cameraId,
865869
static bool isTrustedCallingUid(uid_t uid) {
866870
switch (uid) {
867871
case AID_MEDIA: // mediaserver
872+
#ifndef NO_CAMERA_SERVER
868873
case AID_CAMERASERVER: // cameraserver
874+
#endif
869875
case AID_RADIO: // telephony
870876
return true;
871877
default:
@@ -981,6 +987,7 @@ Status CameraService::validateClientPermissionsLocked(const String8& cameraId,
981987
clientName8.string(), clientUid, clientPid, cameraId.string());
982988
}
983989

990+
#ifndef NO_CAMERA_SERVER
984991
// Make sure the UID is in an active state to use the camera
985992
if (!mUidPolicy->isUidActive(callingUid, String16(clientName8))) {
986993
int32_t procState = mUidPolicy->getProcState(callingUid);
@@ -1000,6 +1007,7 @@ Status CameraService::validateClientPermissionsLocked(const String8& cameraId,
10001007
"Caller \"%s\" (PID %d, UID %d) cannot open camera \"%s\" when sensor privacy "
10011008
"is enabled", clientName8.string(), clientUid, clientPid, cameraId.string());
10021009
}
1010+
#endif
10031011

10041012
// Only use passed in clientPid to check permission. Use calling PID as the client PID that's
10051013
// connected to camera service directly.

0 commit comments

Comments
 (0)