Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 03d3d20d authored by Simon Shields's avatar Simon Shields Committed by Michael Bestas
Browse files

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, android.hardware.camera.common@1.0
    and android.hardware.camera.provider@2.4 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: default avatarAdrian DC <radian.dc@gmail.com>
parent 8ae9636f
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -11,6 +11,9 @@ cc_library_static {

cc_binary {
    name: "mediaserver",
    defaults: [
        "camera_in_mediaserver_defaults",
    ],

    srcs: ["main_mediaserver.cpp"],

+12 −0
Original line number Diff line number Diff line
@@ -27,6 +27,10 @@
#include "RegisterExtensions.h"

// from LOCAL_C_INCLUDES
#ifdef NO_CAMERA_SERVER
#include "CameraService.h"
#include <hidl/HidlTransportSupport.h>
#endif
#include "MediaPlayerService.h"
#include "ResourceManagerService.h"

@@ -36,12 +40,20 @@ int main(int argc __unused, char **argv __unused)
{
    signal(SIGPIPE, SIG_IGN);

#ifdef NO_CAMERA_SERVER
    // Set 3 threads for HIDL calls
    hardware::configureRpcThreadpool(3, /*willjoin*/ false);
#endif

    sp<ProcessState> proc(ProcessState::self());
    sp<IServiceManager> sm(defaultServiceManager());
    ALOGI("ServiceManager: %p", sm.get());
    AIcu_initializeIcuOrDie();
    MediaPlayerService::instantiate();
    ResourceManagerService::instantiate();
#ifdef NO_CAMERA_SERVER
    CameraService::instantiate();
#endif
    registerExtensions();
    ::android::hardware::configureRpcThreadpool(16, false);
    ProcessState::self()->startThreadPool();
+4 −1
Original line number Diff line number Diff line
@@ -18,7 +18,10 @@

cc_library_shared {
    name: "libcameraservice",
    defaults: ["qti_camera_device_defaults"],
    defaults: [
        "no_cameraserver_defaults",
        "qti_camera_device_defaults",
    ],

    // Camera service source

+8 −0
Original line number Diff line number Diff line
@@ -951,7 +951,11 @@ int32_t CameraService::mapToInterface(StatusInternal status) {
Status CameraService::initializeShimMetadata(int cameraId) {
    int uid = CameraThreadState::getCallingUid();

#ifdef NO_CAMERA_SERVER
    String16 internalPackageName("media");
#else
    String16 internalPackageName("cameraserver");
#endif
    String8 id = String8::format("%d", cameraId);
    Status ret = Status::ok();
    sp<Client> tmp = nullptr;
@@ -1032,7 +1036,9 @@ Status CameraService::getLegacyParametersLazy(int cameraId,
static bool isTrustedCallingUid(uid_t uid) {
    switch (uid) {
        case AID_MEDIA:        // mediaserver
#ifndef NO_CAMERA_SERVER
        case AID_CAMERASERVER: // cameraserver
#endif
        case AID_RADIO:        // telephony
            return true;
        default:
@@ -1165,6 +1171,7 @@ Status CameraService::validateClientPermissionsLocked(const String8& cameraId,
                clientName8.string(), clientUid, clientPid, cameraId.string());
    }

#ifndef NO_CAMERA_SERVER
    // Make sure the UID is in an active state to use the camera
    if (!mUidPolicy->isUidActive(callingUid, String16(clientName8))) {
        int32_t procState = mUidPolicy->getProcState(callingUid);
@@ -1176,6 +1183,7 @@ Status CameraService::validateClientPermissionsLocked(const String8& cameraId,
                clientName8.string(), clientUid, clientPid, cameraId.string(),
                callingUid, procState);
    }
#endif

    // If sensor privacy is enabled then prevent access to the camera
    if (mSensorPrivacyPolicy->isSensorPrivacyEnabled()) {