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

Commit 281bd529 authored by Ravneet Dhanjal's avatar Ravneet Dhanjal Committed by Android (Google) Code Review
Browse files

Merge "Camera: Add metrics for extension capture format" into main

parents 46393b9a f1246151
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -200,6 +200,8 @@ public final class CameraAdvancedExtensionSessionImpl extends CameraExtensionSes
                supportedCaptureSizes.put(format, supportedSizes);
            }
        }

        int captureFormat = ImageFormat.UNKNOWN;
        Surface burstCaptureSurface = CameraExtensionUtils.getBurstCaptureSurface(
                config.getOutputConfigurations(), supportedCaptureSizes);
        OutputConfiguration burstCaptureOutputConfig = null;
@@ -210,6 +212,12 @@ public final class CameraAdvancedExtensionSessionImpl extends CameraExtensionSes
                }
            }
            suitableSurfaceCount++;

            if (Flags.analytics24q3()) {
                CameraExtensionUtils.SurfaceInfo burstCaptureSurfaceInfo =
                        CameraExtensionUtils.querySurface(burstCaptureSurface);
                captureFormat = burstCaptureSurfaceInfo.mFormat;
            }
        }

        if (suitableSurfaceCount != config.getOutputConfigurations().size()) {
@@ -249,6 +257,9 @@ public final class CameraAdvancedExtensionSessionImpl extends CameraExtensionSes
                burstCaptureOutputConfig, postviewOutputConfig, config.getStateCallback(),
                config.getExecutor(), sessionId, token, config.getExtension());

        if (Flags.analytics24q3()) {
            ret.mStatsAggregator.setCaptureFormat(captureFormat);
        }
        ret.mStatsAggregator.setClientName(ctx.getOpPackageName());
        ret.mStatsAggregator.setExtensionType(config.getExtension());

+11 −0
Original line number Diff line number Diff line
@@ -200,10 +200,18 @@ public final class CameraExtensionSessionImpl extends CameraExtensionSession {
                supportedCaptureSizes.put(format, supportedSizes);
            }
        }

        int captureFormat = ImageFormat.UNKNOWN;
        Surface burstCaptureSurface = CameraExtensionUtils.getBurstCaptureSurface(
                config.getOutputConfigurations(), supportedCaptureSizes);
        if (burstCaptureSurface != null) {
            suitableSurfaceCount++;

            if (Flags.analytics24q3()) {
                CameraExtensionUtils.SurfaceInfo burstCaptureSurfaceInfo =
                        CameraExtensionUtils.querySurface(burstCaptureSurface);
                captureFormat = burstCaptureSurfaceInfo.mFormat;
            }
        }

        if (suitableSurfaceCount != config.getOutputConfigurations().size()) {
@@ -258,6 +266,9 @@ public final class CameraExtensionSessionImpl extends CameraExtensionSession {
                extensionChars.getAvailableCaptureResultKeys(config.getExtension()),
                config.getExtension());

        if (Flags.analytics24q3()) {
            session.mStatsAggregator.setCaptureFormat(captureFormat);
        }
        session.mStatsAggregator.setClientName(ctx.getOpPackageName());
        session.mStatsAggregator.setExtensionType(config.getExtension());

+19 −1
Original line number Diff line number Diff line
@@ -69,6 +69,23 @@ public class ExtensionSessionStatsAggregator {
        }
    }

    /**
     * Set the capture format.
     *
     * @param format Format of requested capture.
     */
    public void setCaptureFormat(int format) {
        synchronized (mLock) {
            if (mIsDone) {
                return;
            }
            if (DEBUG) {
                Log.v(TAG, "Setting capture format: " + format);
            }
            mStats.captureFormat = format;
        }
    }

    /**
     * Set extension type.
     *
@@ -116,7 +133,8 @@ public class ExtensionSessionStatsAggregator {
                + "  cameraId: '" + stats.cameraId + "'\n"
                + "  clientName: '" + stats.clientName + "'\n"
                + "  type: '" + stats.type + "'\n"
                + "  isAdvanced: '" + stats.isAdvanced + "'\n";
                + "  isAdvanced: '" + stats.isAdvanced + "'\n"
                + "  captureFormat: '" + stats.captureFormat + "'\n";
    }

    /**
+14 −3
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.pm.ParceledListSlice;
import android.content.res.Configuration;
import android.graphics.ImageFormat;
import android.graphics.Rect;
import android.hardware.CameraExtensionSessionStats;
import android.hardware.CameraSessionStats;
@@ -906,6 +907,7 @@ public class CameraServiceProxy extends SystemService

            int extensionType = FrameworkStatsLog.CAMERA_ACTION_EVENT__EXT_TYPE__EXTENSION_NONE;
            boolean extensionIsAdvanced = false;
            int extensionCaptureFormat = ImageFormat.UNKNOWN;
            if (e.mExtSessionStats != null) {
                switch (e.mExtSessionStats.type) {
                    case CameraExtensionSessionStats.Type.EXTENSION_AUTOMATIC:
@@ -932,6 +934,9 @@ public class CameraServiceProxy extends SystemService
                        Slog.w(TAG, "Unknown extension type: " + e.mExtSessionStats.type);
                }
                extensionIsAdvanced = e.mExtSessionStats.isAdvanced;
                if (Flags.analytics24q3()) {
                    extensionCaptureFormat = e.mExtSessionStats.captureFormat;
                }
            }

            int streamCount = 0;
@@ -945,10 +950,13 @@ public class CameraServiceProxy extends SystemService
                String zoomOverrideDebug = Flags.logZoomOverrideUsage()
                        ? ", zoomOverrideUsage " + e.mUsedZoomOverride
                        : "";

                String mostRequestedFpsRangeDebug = Flags.analytics24q3()
                        ? ", mostRequestedFpsRange " + e.mMostRequestedFpsRange
                        : "";
                String extensionCaptureFormatDebug = Flags.analytics24q3()
                        ? " extensionCaptureFormat " + e.mExtSessionStats.captureFormat
                        : "";

                Slog.v(TAG, "CAMERA_ACTION_EVENT: action " + e.mAction
                        + " clientName " + e.mClientName
                        + ", duration " + e.getDuration()
@@ -971,8 +979,10 @@ public class CameraServiceProxy extends SystemService
                        + ", logId " + e.mLogId
                        + ", sessionIndex " + e.mSessionIndex
                        + ", mExtSessionStats {type " + extensionType
                        + " isAdvanced " + extensionIsAdvanced + "}");
                        + " isAdvanced " + extensionIsAdvanced
                        + extensionCaptureFormatDebug + "}");
            }

            // Convert from CameraStreamStats to CameraStreamProto
            CameraStreamProto[] streamProtos = new CameraStreamProto[MAX_STREAM_STATISTICS];
            for (int i = 0; i < MAX_STREAM_STATISTICS; i++) {
@@ -1035,7 +1045,8 @@ public class CameraServiceProxy extends SystemService
                    e.mLogId, e.mSessionIndex,
                    extensionType, extensionIsAdvanced, e.mUsedUltraWide,
                    e.mUsedZoomOverride,
                    e.mMostRequestedFpsRange.getLower(), e.mMostRequestedFpsRange.getUpper());
                    e.mMostRequestedFpsRange.getLower(), e.mMostRequestedFpsRange.getUpper(),
                    extensionCaptureFormat);
        }
    }