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

Commit 6117e3d9 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 6691283 from 9ee1333f to rvc-qpr1-release

Change-Id: I7287b224fb79232b41089799d64aa551de5f85e8
parents b8eeaa9d 9ee1333f
Loading
Loading
Loading
Loading
+20 −23
Original line number Original line Diff line number Diff line
@@ -1312,6 +1312,7 @@ CameraProviderManager::ProviderInfo::ProviderInfo(
status_t CameraProviderManager::ProviderInfo::initialize(
status_t CameraProviderManager::ProviderInfo::initialize(
        sp<provider::V2_4::ICameraProvider>& interface,
        sp<provider::V2_4::ICameraProvider>& interface,
        hardware::hidl_bitfield<provider::V2_5::DeviceState> currentDeviceState) {
        hardware::hidl_bitfield<provider::V2_5::DeviceState> currentDeviceState) {
    std::lock_guard<std::mutex> lock(mLock);
    status_t res = parseProviderName(mProviderName, &mType, &mId);
    status_t res = parseProviderName(mProviderName, &mType, &mId);
    if (res != OK) {
    if (res != OK) {
        ALOGE("%s: Invalid provider name, ignoring", __FUNCTION__);
        ALOGE("%s: Invalid provider name, ignoring", __FUNCTION__);
@@ -1344,6 +1345,20 @@ status_t CameraProviderManager::ProviderInfo::initialize(
        }
        }
    }
    }


    // cameraDeviceStatusChange callbacks may be called (and causing new devices added)
    // before setCallback returns
    hardware::Return<Status> status = interface->setCallback(this);
    if (!status.isOk()) {
        ALOGE("%s: Transaction error setting up callbacks with camera provider '%s': %s",
                __FUNCTION__, mProviderName.c_str(), status.description().c_str());
        return DEAD_OBJECT;
    }
    if (status != Status::OK) {
        ALOGE("%s: Unable to register callbacks with camera provider '%s'",
                __FUNCTION__, mProviderName.c_str());
        return mapToStatusT(status);
    }

    hardware::Return<bool> linked = interface->linkToDeath(this, /*cookie*/ mId);
    hardware::Return<bool> linked = interface->linkToDeath(this, /*cookie*/ mId);
    if (!linked.isOk()) {
    if (!linked.isOk()) {
        ALOGE("%s: Transaction error in linking to camera provider '%s' death: %s",
        ALOGE("%s: Transaction error in linking to camera provider '%s' death: %s",
@@ -1372,7 +1387,6 @@ status_t CameraProviderManager::ProviderInfo::initialize(
        return res;
        return res;
    }
    }


    Status status;
    // Get initial list of camera devices, if any
    // Get initial list of camera devices, if any
    std::vector<std::string> devices;
    std::vector<std::string> devices;
    hardware::Return<void> ret = interface->getCameraIdList([&status, this, &devices](
    hardware::Return<void> ret = interface->getCameraIdList([&status, this, &devices](
@@ -1437,22 +1451,6 @@ status_t CameraProviderManager::ProviderInfo::initialize(
        }
        }
    }
    }


    // cameraDeviceStatusChange callbacks may be called (and causing new devices added)
    // before setCallback returns. setCallback must be called after addDevice so that
    // the physical camera status callback can look up available regular
    // cameras.
    hardware::Return<Status> st = interface->setCallback(this);
    if (!st.isOk()) {
        ALOGE("%s: Transaction error setting up callbacks with camera provider '%s': %s",
                __FUNCTION__, mProviderName.c_str(), st.description().c_str());
        return DEAD_OBJECT;
    }
    if (st != Status::OK) {
        ALOGE("%s: Unable to register callbacks with camera provider '%s'",
                __FUNCTION__, mProviderName.c_str());
        return mapToStatusT(st);
    }

    ALOGI("Camera provider %s ready with %zu camera devices",
    ALOGI("Camera provider %s ready with %zu camera devices",
            mProviderName.c_str(), mDevices.size());
            mProviderName.c_str(), mDevices.size());


@@ -1783,9 +1781,10 @@ hardware::Return<void> CameraProviderManager::ProviderInfo::physicalCameraDevice
        CameraDeviceStatus newStatus) {
        CameraDeviceStatus newStatus) {
    sp<StatusListener> listener;
    sp<StatusListener> listener;
    std::string id;
    std::string id;
    bool initialized = false;
    {
    {
        std::lock_guard<std::mutex> lock(mLock);
        std::lock_guard<std::mutex> lock(mLock);
        if (!mInitialized) return hardware::Void();

        bool known = false;
        bool known = false;
        for (auto& deviceInfo : mDevices) {
        for (auto& deviceInfo : mDevices) {
            if (deviceInfo->mName == cameraDeviceName) {
            if (deviceInfo->mName == cameraDeviceName) {
@@ -1802,10 +1801,9 @@ hardware::Return<void> CameraProviderManager::ProviderInfo::physicalCameraDevice
                            __FUNCTION__, id.c_str(), physicalCameraDeviceName.c_str());
                            __FUNCTION__, id.c_str(), physicalCameraDeviceName.c_str());
                    return hardware::Void();
                    return hardware::Void();
                }
                }
                ALOGI("Camera device %s physical device %s status is now %s, was %s",
                ALOGI("Camera device %s physical device %s status is now %s",
                        cameraDeviceName.c_str(), physicalCameraDeviceName.c_str(),
                        cameraDeviceName.c_str(), physicalCameraDeviceName.c_str(),
                        deviceStatusToString(newStatus), deviceStatusToString(
                        deviceStatusToString(newStatus));
                        deviceInfo->mPhysicalStatus[physicalCameraDeviceName]));
                known = true;
                known = true;
                break;
                break;
            }
            }
@@ -1818,13 +1816,12 @@ hardware::Return<void> CameraProviderManager::ProviderInfo::physicalCameraDevice
            return hardware::Void();
            return hardware::Void();
        }
        }
        listener = mManager->getStatusListener();
        listener = mManager->getStatusListener();
        initialized = mInitialized;
    }
    }
    // Call without lock held to allow reentrancy into provider manager
    // Call without lock held to allow reentrancy into provider manager
    // Don't send the callback if providerInfo hasn't been initialized.
    // Don't send the callback if providerInfo hasn't been initialized.
    // CameraService will initialize device status after provider is
    // CameraService will initialize device status after provider is
    // initialized
    // initialized
    if (listener != nullptr && initialized) {
    if (listener != nullptr) {
        String8 physicalId(physicalCameraDeviceName.c_str());
        String8 physicalId(physicalCameraDeviceName.c_str());
        listener->onDeviceStatusChanged(String8(id.c_str()),
        listener->onDeviceStatusChanged(String8(id.c_str()),
                physicalId, newStatus);
                physicalId, newStatus);
+0 −2
Original line number Original line Diff line number Diff line
@@ -444,8 +444,6 @@ private:
            const hardware::camera::common::V1_0::CameraResourceCost mResourceCost;
            const hardware::camera::common::V1_0::CameraResourceCost mResourceCost;


            hardware::camera::common::V1_0::CameraDeviceStatus mStatus;
            hardware::camera::common::V1_0::CameraDeviceStatus mStatus;
            std::map<std::string, hardware::camera::common::V1_0::CameraDeviceStatus>
                    mPhysicalStatus;


            wp<ProviderInfo> mParentProvider;
            wp<ProviderInfo> mParentProvider;


+7 −2
Original line number Original line Diff line number Diff line
@@ -43,7 +43,7 @@ namespace android::mediametrics {
#endif
#endif


// Maximum length of a device name.
// Maximum length of a device name.
static constexpr size_t STATSD_DEVICE_NAME_MAX_LENGTH = 32;
// static constexpr size_t STATSD_DEVICE_NAME_MAX_LENGTH = 32; // unused since we suppress


// Transmit Enums to statsd in integer or strings  (this must match the atoms.proto)
// Transmit Enums to statsd in integer or strings  (this must match the atoms.proto)
static constexpr bool STATSD_USE_INT_FOR_ENUM = false;
static constexpr bool STATSD_USE_INT_FOR_ENUM = false;
@@ -66,6 +66,8 @@ static constexpr const auto LOG_LEVEL = android::base::VERBOSE;


static constexpr int PREVIOUS_STATE_EXPIRE_SEC = 60 * 60; // 1 hour.
static constexpr int PREVIOUS_STATE_EXPIRE_SEC = 60 * 60; // 1 hour.


static constexpr const char * SUPPRESSED = "SUPPRESSED";

/*
/*
 * For logging purposes, we list all of the MediaMetrics atom fields,
 * For logging purposes, we list all of the MediaMetrics atom fields,
 * which can then be associated with consecutive arguments to the statsd write.
 * which can then be associated with consecutive arguments to the statsd write.
@@ -448,6 +450,8 @@ void AudioAnalytics::DeviceUse::endAudioIntervalGroup(
    std::string outputDeviceNames;
    std::string outputDeviceNames;
    if (outputDevices.find("AUDIO_DEVICE_OUT_BLUETOOTH") != std::string::npos) {
    if (outputDevices.find("AUDIO_DEVICE_OUT_BLUETOOTH") != std::string::npos) {
        isBluetooth = true;
        isBluetooth = true;
        outputDeviceNames = SUPPRESSED;
#if 0   // TODO(b/161554630) sanitize name
        mAudioAnalytics.mAnalyticsState->timeMachine().get(
        mAudioAnalytics.mAnalyticsState->timeMachine().get(
            "audio.device.bt_a2dp", AMEDIAMETRICS_PROP_NAME, &outputDeviceNames);
            "audio.device.bt_a2dp", AMEDIAMETRICS_PROP_NAME, &outputDeviceNames);
        // Remove | if present
        // Remove | if present
@@ -455,6 +459,7 @@ void AudioAnalytics::DeviceUse::endAudioIntervalGroup(
        if (outputDeviceNames.size() > STATSD_DEVICE_NAME_MAX_LENGTH) {
        if (outputDeviceNames.size() > STATSD_DEVICE_NAME_MAX_LENGTH) {
            outputDeviceNames.resize(STATSD_DEVICE_NAME_MAX_LENGTH); // truncate
            outputDeviceNames.resize(STATSD_DEVICE_NAME_MAX_LENGTH); // truncate
        }
        }
#endif
    }
    }


    switch (itemType) {
    switch (itemType) {
@@ -775,7 +780,7 @@ void AudioAnalytics::DeviceConnection::postBluetoothA2dpDeviceConnectionStateSup
        std::lock_guard l(mLock);
        std::lock_guard l(mLock);
        mA2dpConnectionRequestNs = atNs;
        mA2dpConnectionRequestNs = atNs;
        ++mA2dpConnectionRequests;
        ++mA2dpConnectionRequests;
        mA2dpDeviceName = name;
        mA2dpDeviceName = SUPPRESSED; // TODO(b/161554630) sanitize name
    }
    }
    ALOGD("(key=%s) a2dp connection name:%s request atNs:%lld",
    ALOGD("(key=%s) a2dp connection name:%s request atNs:%lld",
            key.c_str(), name.c_str(), (long long)atNs);
            key.c_str(), name.c_str(), (long long)atNs);