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

Commit cc3e12c3 authored by Jayant Chowdhary's avatar Jayant Chowdhary
Browse files

cameraserver: Plumb correct error code when openAidlSession fails.



Bug: 222683495

Test: atest MultiViewTest#testDualCameraPreview

Change-Id: I9c5221460e6509438720e7fe0b42e4cecb07675b
Signed-off-by: default avatarJayant Chowdhary <jchowdhary@google.com>
parent e526939d
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -642,7 +642,7 @@ status_t CameraProviderManager::openAidlSession(const std::string &id,
        removeRef(DeviceMode::CAMERA, id);
        ALOGE("%s: Transaction error opening a session for camera device %s: %s",
                __FUNCTION__, id.c_str(), ret.getMessage());
        return DEAD_OBJECT;
        return AidlProviderInfo::mapToStatusT(ret);
    }
    return OK;
}
+24 −2
Original line number Diff line number Diff line
/*
 * Copyright (C) 2021 The Android Open Source Project
 * Copyright (C) 2022 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
@@ -45,8 +45,30 @@ using HalDeviceStatusType = aidl::android::hardware::camera::common::CameraDevic
using ICameraProvider = aidl::android::hardware::camera::provider::ICameraProvider;
using StatusListener = CameraProviderManager::StatusListener;

static status_t mapExceptionCodeToStatusT(binder_exception_t binderException) {
    switch (binderException) {
        case EX_NONE:
            return OK;
        case EX_ILLEGAL_ARGUMENT:
        case EX_NULL_POINTER:
        case EX_BAD_PARCELABLE:
        case EX_ILLEGAL_STATE:
            return BAD_VALUE;
        case EX_UNSUPPORTED_OPERATION:
            return INVALID_OPERATION;
        case EX_TRANSACTION_FAILED:
            return DEAD_OBJECT;
        default:
            return UNKNOWN_ERROR;
    }
}

status_t AidlProviderInfo::mapToStatusT(const ndk::ScopedAStatus& s) {
    using Status = aidl::android::hardware::camera::common::Status;
    auto exceptionCode = s.getExceptionCode();
    if (exceptionCode != EX_SERVICE_SPECIFIC) {
        return mapExceptionCodeToStatusT(exceptionCode);
    }
    Status st = static_cast<Status>(s.getServiceSpecificError());
    switch (st) {
        case Status::OK: