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

Commit b9139ab0 authored by Xin Li's avatar Xin Li Committed by Gerrit Code Review
Browse files

Merge "Merge Android 14" into main

parents b2fdd755 f7fec4b2
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -47,7 +47,7 @@ cc_library_headers {
    name: "camera_headers",
    export_include_dirs: ["include"],
}
cc_library_shared {
cc_library {
    name: "libcamera_client",

    aidl: {
@@ -142,14 +142,15 @@ cc_library_host_static {
filegroup {
    name: "libcamera_client_aidl",
    srcs: [
        "aidl/android/hardware/CameraExtensionSessionStats.aidl",
        "aidl/android/hardware/ICameraService.aidl",
        "aidl/android/hardware/ICameraServiceListener.aidl",
        "aidl/android/hardware/ICameraServiceProxy.aidl",
        "aidl/android/hardware/camera2/ICameraDeviceCallbacks.aidl",
        "aidl/android/hardware/camera2/ICameraDeviceUser.aidl",
        "aidl/android/hardware/camera2/ICameraOfflineSession.aidl",
        "aidl/android/hardware/camera2/ICameraInjectionCallback.aidl",
        "aidl/android/hardware/camera2/ICameraInjectionSession.aidl",
        "aidl/android/hardware/camera2/ICameraOfflineSession.aidl",
    ],
    path: "aidl",
}
+58 −3
Original line number Diff line number Diff line
@@ -131,6 +131,12 @@ status_t CameraStreamStats::readFromParcel(const android::Parcel* parcel) {
        return err;
    }

    int32_t colorSpace = ANDROID_REQUEST_AVAILABLE_COLOR_SPACE_PROFILES_MAP_UNSPECIFIED;
    if ((err = parcel->readInt32(&colorSpace)) != OK) {
        ALOGE("%s: Failed to read color space from parcel", __FUNCTION__);
        return err;
    }

    mWidth = width;
    mHeight = height;
    mFormat = format;
@@ -147,6 +153,7 @@ status_t CameraStreamStats::readFromParcel(const android::Parcel* parcel) {
    mHistogramCounts = std::move(histogramCounts);
    mDynamicRangeProfile = dynamicRangeProfile;
    mStreamUseCase = streamUseCase;
    mColorSpace = colorSpace;

    return OK;
}
@@ -239,6 +246,11 @@ status_t CameraStreamStats::writeToParcel(android::Parcel* parcel) const {
        return err;
    }

    if ((err = parcel->writeInt32(mColorSpace)) != OK) {
        ALOGE("%s: Failed to write color space", __FUNCTION__);
        return err;
    }

    return OK;
}

@@ -260,17 +272,20 @@ CameraSessionStats::CameraSessionStats() :
        mApiLevel(0),
        mIsNdk(false),
        mLatencyMs(-1),
        mLogId(0),
        mMaxPreviewFps(0),
        mSessionType(0),
        mInternalReconfigure(0),
        mRequestCount(0),
        mResultErrorCount(0),
        mDeviceError(false),
        mVideoStabilizationMode(-1) {}
        mVideoStabilizationMode(-1),
        mSessionIndex(0),
        mCameraExtensionSessionStats() {}

CameraSessionStats::CameraSessionStats(const std::string& cameraId,
        int facing, int newCameraState, const std::string& clientName,
        int apiLevel, bool isNdk, int32_t latencyMs) :
        int apiLevel, bool isNdk, int32_t latencyMs, int64_t logId) :
                mCameraId(cameraId),
                mFacing(facing),
                mNewCameraState(newCameraState),
@@ -278,13 +293,16 @@ CameraSessionStats::CameraSessionStats(const std::string& cameraId,
                mApiLevel(apiLevel),
                mIsNdk(isNdk),
                mLatencyMs(latencyMs),
                mLogId(logId),
                mMaxPreviewFps(0),
                mSessionType(0),
                mInternalReconfigure(0),
                mRequestCount(0),
                mResultErrorCount(0),
                mDeviceError(0),
                mVideoStabilizationMode(-1) {}
                mVideoStabilizationMode(-1),
                mSessionIndex(0),
                mCameraExtensionSessionStats() {}

status_t CameraSessionStats::readFromParcel(const android::Parcel* parcel) {
    if (parcel == NULL) {
@@ -336,6 +354,12 @@ status_t CameraSessionStats::readFromParcel(const android::Parcel* parcel) {
        return err;
    }

    int64_t logId;
    if ((err = parcel->readInt64(&logId)) != OK) {
        ALOGE("%s: Failed to read log ID from parcel", __FUNCTION__);
        return err;
    }

    float maxPreviewFps;
    if ((err = parcel->readFloat(&maxPreviewFps)) != OK) {
        ALOGE("%s: Failed to read maxPreviewFps from parcel", __FUNCTION__);
@@ -390,6 +414,18 @@ status_t CameraSessionStats::readFromParcel(const android::Parcel* parcel) {
        return err;
    }

    int32_t sessionIdx;
    if ((err = parcel->readInt32(&sessionIdx)) != OK) {
        ALOGE("%s: Failed to read session index from parcel", __FUNCTION__);
        return err;
    }

    CameraExtensionSessionStats extStats{};
    if ((err = extStats.readFromParcel(parcel)) != OK) {
        ALOGE("%s: Failed to read extension session stats from parcel", __FUNCTION__);
        return err;
    }

    mCameraId = toStdString(id);
    mFacing = facing;
    mNewCameraState = newCameraState;
@@ -397,6 +433,7 @@ status_t CameraSessionStats::readFromParcel(const android::Parcel* parcel) {
    mApiLevel = apiLevel;
    mIsNdk = isNdk;
    mLatencyMs = latencyMs;
    mLogId = logId;
    mMaxPreviewFps = maxPreviewFps;
    mSessionType = sessionType;
    mInternalReconfigure = internalReconfigure;
@@ -406,6 +443,8 @@ status_t CameraSessionStats::readFromParcel(const android::Parcel* parcel) {
    mStreamStats = std::move(streamStats);
    mUserTag = toStdString(userTag);
    mVideoStabilizationMode = videoStabilizationMode;
    mSessionIndex = sessionIdx;
    mCameraExtensionSessionStats = extStats;

    return OK;
}
@@ -453,6 +492,11 @@ status_t CameraSessionStats::writeToParcel(android::Parcel* parcel) const {
        return err;
    }

    if ((err = parcel->writeInt64(mLogId)) != OK) {
        ALOGE("%s: Failed to write log ID!", __FUNCTION__);
        return err;
    }

    if ((err = parcel->writeFloat(mMaxPreviewFps)) != OK) {
        ALOGE("%s: Failed to write maxPreviewFps!", __FUNCTION__);
        return err;
@@ -497,6 +541,17 @@ status_t CameraSessionStats::writeToParcel(android::Parcel* parcel) const {
        ALOGE("%s: Failed to write video stabilization mode!", __FUNCTION__);
        return err;
    }

    if ((err = parcel->writeInt32(mSessionIndex)) != OK) {
        ALOGE("%s: Failed to write session index!", __FUNCTION__);
        return err;
    }

    if ((err = mCameraExtensionSessionStats.writeToParcel(parcel)) != OK) {
        ALOGE("%s: Failed to write extension sessions stats!", __FUNCTION__);
        return err;
    }

    return OK;
}

+6 −2
Original line number Diff line number Diff line
@@ -598,7 +598,6 @@ status_t VendorTagDescriptor::createDescriptorFromOps(const vendor_tag_ops_t* vO
status_t VendorTagDescriptor::setAsGlobalVendorTagDescriptor(const sp<VendorTagDescriptor>& desc) {
    status_t res = OK;
    Mutex::Autolock al(sLock);
    sGlobalVendorTagDescriptor = desc;

    vendor_tag_ops_t* opsPtr = NULL;
    if (desc != NULL) {
@@ -613,6 +612,9 @@ status_t VendorTagDescriptor::setAsGlobalVendorTagDescriptor(const sp<VendorTagD
        ALOGE("%s: Could not set vendor tag descriptor, received error %s (%d)."
                , __FUNCTION__, strerror(-res), res);
    }

    sGlobalVendorTagDescriptor = desc;

    return res;
}

@@ -631,7 +633,6 @@ status_t VendorTagDescriptorCache::setAsGlobalVendorTagCache(
        const sp<VendorTagDescriptorCache>& cache) {
    status_t res = OK;
    Mutex::Autolock al(sLock);
    sGlobalVendorTagDescriptorCache = cache;

    struct vendor_tag_cache_ops* opsPtr = NULL;
    if (cache != NULL) {
@@ -646,6 +647,9 @@ status_t VendorTagDescriptorCache::setAsGlobalVendorTagCache(
        ALOGE("%s: Could not set vendor tag cache, received error %s (%d)."
                , __FUNCTION__, strerror(-res), res);
    }

    sGlobalVendorTagDescriptorCache = cache;

    return res;
}

+69 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2023 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.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.hardware;

/**
 * Metrics specific to Extension Sessions (see CameraExtensionSession) for logging.
 *
 * Each Extension Session is mapped to one camera session internally, and will be sent to
 * CameraServiceProxy with IDLE/CLOSE calls.
 * @hide
 */
parcelable CameraExtensionSessionStats {
    /**
     * Value should match {@code CameraExtensionCharacteristics#EXTENSION_*}
     */
    @Backing(type="int")
    enum Type {
        EXTENSION_NONE = -1,
        EXTENSION_AUTOMATIC = 0,
        EXTENSION_FACE_RETOUCH = 1,
        EXTENSION_BOKEH = 2,
        EXTENSION_HDR = 3,
        EXTENSION_NIGHT = 4
    }

    /**
     * Key to uniquely identify the session this stat is associated with. The first call to
     * 'ICameraService.reportExtensionSessionStats' should set this to an empty string.
     * 'ICameraService.reportExtensionSessionStats' will return the key which should be used with
     * the next calls.
     */
    String key;

    /**
     * Camera ID for which the stats is being reported.
     */
    String cameraId;

    /**
     * Package name of the client using the camera
     */
    String clientName;


    /**
     * Type of extension session requested by the app. Note that EXTENSION_AUTOMATIC is reported
     * as such.
     */
    Type type = Type.EXTENSION_NONE;

    /**
     * true if advanced extensions are being used, false otherwise
     */
    boolean isAdvanced = false;
}
 No newline at end of file
+21 −0
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import android.hardware.camera2.impl.CameraMetadataNative;
import android.hardware.ICameraServiceListener;
import android.hardware.CameraInfo;
import android.hardware.CameraStatus;
import android.hardware.CameraExtensionSessionStats;

/**
 * Binder interface for the native camera service running in mediaserver.
@@ -214,6 +215,26 @@ interface ICameraService
     */
    oneway void notifyDeviceStateChange(long newState);

    /**
     * Report Extension specific metrics to camera service for logging. This should only be called
     * by CameraExtensionSession to log extension metrics. All calls after the first must set
     * CameraExtensionSessionStats.key to the value returned by this function.
     *
     * Each subsequent call fully overwrites the existing CameraExtensionSessionStats for the
     * current session, so the caller is responsible for keeping the stats complete.
     *
     * Due to cameraservice and cameraservice_proxy architecture, there is no guarantee that
     * {@code stats} will be logged immediately (or at all). CameraService will log whatever
     * extension stats it has at the time of camera session closing which may be before the app
     * process receives a session/device closed callback; so CameraExtensionSession
     * should send metrics to the cameraservice preriodically, and cameraservice must handle calls
     * to this function from sessions that have not been logged yet and from sessions that have
     * already been closed.
     *
     * @return the key that must be used to report updates to previously reported stats.
     */
    @utf8InCpp String reportExtensionSessionStats(in CameraExtensionSessionStats stats);

    // Bitfield constants for notifyDeviceStateChange
    // All bits >= 32 are for custom vendor states
    // Written as ints since AIDL does not support long constants.
Loading