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

Commit 97c1dfe9 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Added fuzz targets for libcamera_client"

parents 9abb810c d16f5df8
Loading
Loading
Loading
Loading
+141 −0
Original line number Diff line number Diff line
/*
 * 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.
 * 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.
 */
cc_defaults {
    name: "camera_defaults",
    static_libs: [
        "libcamera_client",
    ],
    shared_libs: [
        "libbase",
        "libcutils",
        "libutils",
        "liblog",
        "libbinder",
        "libgui",
        "libcamera_metadata",
        "libnativewindow",
    ],
    fuzz_config: {
        cc: [
            "android-media-fuzzing-reports@google.com",
        ],
        componentid: 155276,
    },
}

cc_fuzz {
    name: "camera_fuzzer",
    srcs: [
        "camera_fuzzer.cpp",
    ],
    defaults: [
        "camera_defaults",
    ],
}

cc_fuzz {
    name: "camera_c2CaptureRequest_fuzzer",
    srcs: [
        "camera_c2CaptureRequest_fuzzer.cpp",
    ],
    defaults: [
        "camera_defaults",
    ],
}

cc_fuzz {
    name: "camera_c2ConcurrentCamera_fuzzer",
    srcs: [
        "camera_c2ConcurrentCamera_fuzzer.cpp",
    ],
    defaults: [
        "camera_defaults",
    ],
}

cc_fuzz {
    name: "camera_c2SubmitInfo_fuzzer",
    srcs: [
        "camera_c2SubmitInfo_fuzzer.cpp",
    ],
    defaults: [
        "camera_defaults",
    ],
}

cc_fuzz {
    name: "camera_c2SessionConfiguration_fuzzer",
    srcs: [
        "camera_c2SessionConfiguration_fuzzer.cpp",
    ],
    defaults: [
        "camera_defaults",
    ],
}

cc_fuzz {
    name: "camera_c2OutputConfiguration_fuzzer",
    srcs: [
        "camera_c2OutputConfiguration_fuzzer.cpp",
    ],
    defaults: [
        "camera_defaults",
    ],
}

cc_fuzz {
    name: "camera_vendorTagDescriptor_fuzzer",
    srcs: [
        "camera_vendorTagDescriptor_fuzzer.cpp",
    ],
    defaults: [
        "camera_defaults",
    ],
    include_dirs: [
        "system/media/camera/tests",
        "system/media/private/camera/include",
    ],
}

cc_fuzz {
    name: "camera_Parameters_fuzzer",
    srcs: [
        "camera_Parameters_fuzzer.cpp",
    ],
    defaults: [
        "camera_defaults",
    ],
}

cc_fuzz {
    name: "camera_SessionStats_fuzzer",
    srcs: [
        "camera_SessionStats_fuzzer.cpp",
    ],
    defaults: [
        "camera_defaults",
    ],
}

cc_fuzz {
    name: "camera_captureResult_fuzzer",
    srcs: [
        "camera_captureResult_fuzzer.cpp",
    ],
    defaults: [
        "camera_defaults",
    ],
}
+74 −0
Original line number Diff line number Diff line
# Fuzzers for libcamera_client

## Plugin Design Considerations
The fuzzer plugins for libcamera_client are designed based on the understanding of the
source code and try to achieve the following:

##### Maximize code coverage
The configuration parameters are not hardcoded, but instead selected based on
incoming data. This ensures more code paths are reached by the fuzzers.

libcamera_client supports the following parameters:
1. Command (parameter name: `cmd`)
2. Video Buffer Mode (parameter name: `videoBufferMode`)
3. Preview Callback Flag (parameter name: `previewCallbackFlag`)
4. Facing (parameter name: `facing`)
5. Orientation (parameter name: `orientation`)
6. Format (parameter name: `format`)

| Parameter| Valid Values| Configured Value|
|------------- |-------------| ----- |
| `cmd` | 0.`CAMERA_CMD_START_SMOOTH_ZOOM` 1.`CAMERA_CMD_STOP_SMOOTH_ZOOM` 3.`CAMERA_CMD_SET_DISPLAY_ORIENTATION` 4.`CAMERA_CMD_ENABLE_SHUTTER_SOUND` 5.`CAMERA_CMD_PLAY_RECORDING_SOUND` 6.`CAMERA_CMD_START_FACE_DETECTION` 7.`CAMERA_CMD_STOP_FACE_DETECTION` 8.`CAMERA_CMD_ENABLE_FOCUS_MOVE_MSG` 9.`CAMERA_CMD_PING` 10.`CAMERA_CMD_SET_VIDEO_BUFFER_COUNT` 11.`CAMERA_CMD_SET_VIDEO_FORMAT`| Value obtained from FuzzedDataProvider|
| `videoBufferMode` |0. `ICamera::VIDEO_BUFFER_MODE_DATA_CALLBACK_YUV` 1.`ICamera::VIDEO_BUFFER_MODE_DATA_CALLBACK_METADATA` 2.`ICamera::VIDEO_BUFFER_MODE_BUFFER_QUEUE`| Value obtained from FuzzedDataProvider|
| `previewCallbackFlag` | 0. `CAMERA_FRAME_CALLBACK_FLAG_ENABLE_MASK` 1.`CAMERA_FRAME_CALLBACK_FLAG_ONE_SHOT_MASK` 2.`CAMERA_FRAME_CALLBACK_FLAG_COPY_OUT_MASK` 3.`CAMERA_FRAME_CALLBACK_FLAG_NOOP` 4.`CAMERA_FRAME_CALLBACK_FLAG_CAMCORDER` 5.`CAMERA_FRAME_CALLBACK_FLAG_CAMERA` 6.`CAMERA_FRAME_CALLBACK_FLAG_BARCODE_SCANNER`| Value obtained from FuzzedDataProvider|
| `facing` | 0.`android::hardware::CAMERA_FACING_BACK` 1.`android::hardware::CAMERA_FACING_FRONT`| Value obtained from FuzzedDataProvider|
| `orientation` | 0.`0` 1.`90` 2.`180`3.`270`| Value obtained from FuzzedDataProvider|
| `format` | 0.`CameraParameters::PIXEL_FORMAT_YUV422SP` 1.`CameraParameters::PIXEL_FORMAT_YUV420SP` 2.`CameraParameters::PIXEL_FORMAT_YUV422I` 3.`CameraParameters::PIXEL_FORMAT_YUV420P` 4.`CameraParameters::PIXEL_FORMAT_RGB565` 5.`CameraParameters::PIXEL_FORMAT_RGBA8888` 6.`CameraParameters::PIXEL_FORMAT_JPEG` 7.`CameraParameters::PIXEL_FORMAT_BAYER_RGGB` 8.`CameraParameters::PIXEL_FORMAT_ANDROID_OPAQUE`| Value obtained from FuzzedDataProvider|

This also ensures that the plugins are always deterministic for any given input.

##### Maximize utilization of input data
The plugins feed the entire input data to the module.
This ensures that the plugins tolerate any kind of input (empty, huge,
malformed, etc) and dont `exit()` on any input and thereby increasing the
chance of identifying vulnerabilities.

## Build

This describes steps to build camera_fuzzer, camera2CaptureRequest_fuzzer, camera2ConcurrentCamera_fuzzer, camera2SubmitInfo_fuzzer, camera2SessionConfiguration_fuzzer, camera2OutputConfiguration_fuzzer, vendorTagDescriptor_fuzzer, cameraParameters_fuzzer, cameraSessionStats_fuzzer and captureResult_fuzzer binaries

### Android

#### Steps to build
Build the fuzzer
```
  $ mm -j$(nproc) camera_fuzzer
  $ mm -j$(nproc) camera_c2CaptureRequest_fuzzer
  $ mm -j$(nproc) camera_c2ConcurrentCamera_fuzzer
  $ mm -j$(nproc) camera_c2SubmitInfo_fuzzer
  $ mm -j$(nproc) camera_c2SessionConfiguration_fuzzer
  $ mm -j$(nproc) camera_c2OutputConfiguration_fuzzer
  $ mm -j$(nproc) camera_vendorTagDescriptor_fuzzer
  $ mm -j$(nproc) camera_Parameters_fuzzer
  $ mm -j$(nproc) camera_SessionStats_fuzzer
  $ mm -j$(nproc) camera_captureResult_fuzzer
```
#### Steps to run
To run on device
```
  $ adb sync data
  $ adb shell /data/fuzz/${TARGET_ARCH}/camera_fuzzer/camera_fuzzer
  $ adb shell /data/fuzz/${TARGET_ARCH}/camera_c2CaptureRequest_fuzzer/camera_c2CaptureRequest_fuzzer
  $ adb shell /data/fuzz/${TARGET_ARCH}/camera_c2ConcurrentCamera_fuzzer/camera_c2ConcurrentCamera_fuzzer
  $ adb shell /data/fuzz/${TARGET_ARCH}/camera_c2SubmitInfo_fuzzer/camera_c2SubmitInfo_fuzzer
  $ adb shell /data/fuzz/${TARGET_ARCH}/camera_c2SessionConfiguration_fuzzer/camera_c2SessionConfiguration_fuzzer
  $ adb shell /data/fuzz/${TARGET_ARCH}/camera_c2OutputConfiguration_fuzzer/camera_c2OutputConfiguration_fuzzer
  $ adb shell /data/fuzz/${TARGET_ARCH}/camera_vendorTagDescriptor_fuzzer/camera_vendorTagDescriptor_fuzzer
  $ adb shell /data/fuzz/${TARGET_ARCH}/camera_Parameters_fuzzer/camera_Parameters_fuzzer
  $ adb shell /data/fuzz/${TARGET_ARCH}/camera_SessionStats_fuzzer/camera_SessionStats_fuzzer
  $ adb shell /data/fuzz/${TARGET_ARCH}/camera_captureResult_fuzzer/camera_captureResult_fuzzer
```

## References:
 * http://llvm.org/docs/LibFuzzer.html
 * https://github.com/google/oss-fuzz
+55 −0
Original line number Diff line number Diff line
/*
 * 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.
 * 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.
 */
#ifndef CAMERA2COMMON_H
#define CAMERA2COMMON_H

#include <binder/Parcel.h>

using namespace android;

template <class type>
void invokeReadWriteNullParcel(type* obj) {
    Parcel* parcelNull = nullptr;
    obj->writeToParcel(parcelNull);
    obj->readFromParcel(parcelNull);
}

template <class type>
void invokeReadWriteNullParcelsp(sp<type> obj) {
    Parcel* parcelNull = nullptr;
    obj->writeToParcel(parcelNull);
    obj->readFromParcel(parcelNull);
}

template <class type>
void invokeReadWriteParcel(type* obj) {
    Parcel* parcel = new Parcel();
    obj->writeToParcel(parcel);
    parcel->setDataPosition(0);
    obj->readFromParcel(parcel);
    delete parcel;
}

template <class type>
void invokeReadWriteParcelsp(sp<type> obj) {
    Parcel* parcel = new Parcel();
    obj->writeToParcel(parcel);
    parcel->setDataPosition(0);
    obj->readFromParcel(parcel);
    delete parcel;
}

#endif  // CAMERA2COMMON_H
+163 −0
Original line number Diff line number Diff line
/*
 * 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.
 * 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.
 */

#include <CameraParameters.h>
#include <CameraParameters2.h>
#include <fcntl.h>
#include <fuzzer/FuzzedDataProvider.h>
#include <utils/String16.h>

using namespace std;
using namespace android;

string kValidFormats[] = {
        CameraParameters::PIXEL_FORMAT_YUV422SP,      CameraParameters::PIXEL_FORMAT_YUV420SP,
        CameraParameters::PIXEL_FORMAT_YUV422I,       CameraParameters::PIXEL_FORMAT_YUV420P,
        CameraParameters::PIXEL_FORMAT_RGB565,        CameraParameters::PIXEL_FORMAT_RGBA8888,
        CameraParameters::PIXEL_FORMAT_JPEG,          CameraParameters::PIXEL_FORMAT_BAYER_RGGB,
        CameraParameters::PIXEL_FORMAT_ANDROID_OPAQUE};

class CameraParametersFuzzer {
  public:
    void process(const uint8_t* data, size_t size);
    ~CameraParametersFuzzer() {
        delete mCameraParameters;
        delete mCameraParameters2;
    }

  private:
    void invokeCameraParameters();
    template <class type>
    void initCameraParameters(type** obj);
    template <class type>
    void cameraParametersCommon(type* obj);
    CameraParameters* mCameraParameters = nullptr;
    CameraParameters2* mCameraParameters2 = nullptr;
    FuzzedDataProvider* mFDP = nullptr;
};

template <class type>
void CameraParametersFuzzer::initCameraParameters(type** obj) {
    if (mFDP->ConsumeBool()) {
        *obj = new type();
    } else {
        string params;
        if (mFDP->ConsumeBool()) {
            int32_t width = mFDP->ConsumeIntegral<int32_t>();
            int32_t height = mFDP->ConsumeIntegral<int32_t>();
            int32_t minFps = mFDP->ConsumeIntegral<int32_t>();
            int32_t maxFps = mFDP->ConsumeIntegral<int32_t>();
            params = CameraParameters::KEY_SUPPORTED_VIDEO_SIZES;
            params += '=' + to_string(width) + 'x' + to_string(height) + ';';
            if (mFDP->ConsumeBool()) {
                params += CameraParameters::KEY_PREVIEW_FPS_RANGE;
                params += '=' + to_string(minFps) + ',' + to_string(maxFps) + ';';
            }
            if (mFDP->ConsumeBool()) {
                params += CameraParameters::KEY_SUPPORTED_PICTURE_SIZES;
                params += '=' + to_string(width) + 'x' + to_string(height) + ';';
            }
            if (mFDP->ConsumeBool()) {
                params += CameraParameters::KEY_SUPPORTED_PREVIEW_FORMATS;
                params += '=' + mFDP->PickValueInArray(kValidFormats) + ';';
            }
        } else {
            params = mFDP->ConsumeRandomLengthString();
        }
        *obj = new type(String8(params.c_str()));
    }
}

template <class type>
void CameraParametersFuzzer::cameraParametersCommon(type* obj) {
    Vector<Size> supportedPreviewSizes;
    obj->getSupportedPreviewSizes(supportedPreviewSizes);
    int32_t previewWidth = mFDP->ConsumeIntegral<int32_t>();
    int32_t previewHeight = mFDP->ConsumeIntegral<int32_t>();
    obj->setPreviewSize(previewWidth, previewHeight);
    obj->getPreviewSize(&previewWidth, &previewHeight);

    Vector<Size> supportedVideoSizes;
    obj->getSupportedVideoSizes(supportedVideoSizes);
    if (supportedVideoSizes.size() != 0) {
        int32_t videoWidth, videoHeight, preferredVideoWidth, preferredVideoHeight;
        if (mFDP->ConsumeBool()) {
            int32_t idx = mFDP->ConsumeIntegralInRange<int32_t>(0, supportedVideoSizes.size() - 1);
            obj->setVideoSize(supportedVideoSizes[idx].width, supportedVideoSizes[idx].height);
        } else {
            videoWidth = mFDP->ConsumeIntegral<int32_t>();
            videoHeight = mFDP->ConsumeIntegral<int32_t>();
            obj->setVideoSize(videoWidth, videoHeight);
        }
        obj->getVideoSize(&videoWidth, &videoHeight);
        obj->getPreferredPreviewSizeForVideo(&preferredVideoWidth, &preferredVideoHeight);
    }

    int32_t fps = mFDP->ConsumeIntegral<int32_t>();
    obj->setPreviewFrameRate(fps);
    obj->getPreviewFrameRate();
    string previewFormat = mFDP->ConsumeBool() ? mFDP->PickValueInArray(kValidFormats)
                                               : mFDP->ConsumeRandomLengthString();
    obj->setPreviewFormat(previewFormat.c_str());

    int32_t pictureWidth = mFDP->ConsumeIntegral<int32_t>();
    int32_t pictureHeight = mFDP->ConsumeIntegral<int32_t>();
    Vector<Size> supportedPictureSizes;
    obj->setPictureSize(pictureWidth, pictureHeight);
    obj->getPictureSize(&pictureWidth, &pictureHeight);
    obj->getSupportedPictureSizes(supportedPictureSizes);
    string pictureFormat = mFDP->ConsumeBool() ? mFDP->PickValueInArray(kValidFormats)
                                               : mFDP->ConsumeRandomLengthString();
    obj->setPictureFormat(pictureFormat.c_str());
    obj->getPictureFormat();

    if (mFDP->ConsumeBool()) {
        obj->dump();
    } else {
        int32_t fd = open("/dev/null", O_CLOEXEC | O_RDWR | O_CREAT);
        Vector<String16> args = {};
        obj->dump(fd, args);
        close(fd);
    }
}

void CameraParametersFuzzer::invokeCameraParameters() {
    initCameraParameters<CameraParameters>(&mCameraParameters);
    cameraParametersCommon<CameraParameters>(mCameraParameters);
    initCameraParameters<CameraParameters2>(&mCameraParameters2);
    cameraParametersCommon<CameraParameters2>(mCameraParameters2);

    int32_t minFPS, maxFPS;
    mCameraParameters->getPreviewFpsRange(&minFPS, &maxFPS);
    string format = mFDP->ConsumeBool() ? mFDP->PickValueInArray(kValidFormats)
                                        : mFDP->ConsumeRandomLengthString();
    mCameraParameters->previewFormatToEnum(format.c_str());
    mCameraParameters->isEmpty();
    Vector<int32_t> formats;
    mCameraParameters->getSupportedPreviewFormats(formats);
}

void CameraParametersFuzzer::process(const uint8_t* data, size_t size) {
    mFDP = new FuzzedDataProvider(data, size);
    invokeCameraParameters();
    delete mFDP;
}

extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
    CameraParametersFuzzer cameraParametersFuzzer;
    cameraParametersFuzzer.process(data, size);
    return 0;
}
+162 −0
Original line number Diff line number Diff line
/*
 * 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.
 * 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.
 */

#include <CameraSessionStats.h>
#include <binder/Parcel.h>
#include <fuzzer/FuzzedDataProvider.h>
#include "camera2common.h"

using namespace std;
using namespace android;
using namespace android::hardware;

extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
    FuzzedDataProvider fdp = FuzzedDataProvider(data, size);
    CameraStreamStats* cameraStreamStats = nullptr;
    Parcel parcelCamStreamStats;

    if (fdp.ConsumeBool()) {
        cameraStreamStats = new CameraStreamStats();
    } else {
        int32_t width = fdp.ConsumeIntegral<int32_t>();
        if (fdp.ConsumeBool()) {
            parcelCamStreamStats.writeInt32(width);
        }
        int32_t height = fdp.ConsumeIntegral<int32_t>();
        if (fdp.ConsumeBool()) {
            parcelCamStreamStats.writeInt32(height);
        }
        int32_t format = fdp.ConsumeIntegral<int32_t>();
        if (fdp.ConsumeBool()) {
            parcelCamStreamStats.writeInt32(format);
        }
        float maxPreviewFps = fdp.ConsumeFloatingPoint<float>();
        if (fdp.ConsumeBool()) {
            parcelCamStreamStats.writeFloat(maxPreviewFps);
        }
        int32_t dataSpace = fdp.ConsumeIntegral<int32_t>();
        if (fdp.ConsumeBool()) {
            parcelCamStreamStats.writeInt32(dataSpace);
        }
        int64_t usage = fdp.ConsumeIntegral<int64_t>();
        if (fdp.ConsumeBool()) {
            parcelCamStreamStats.writeInt64(usage);
        }
        int64_t requestCount = fdp.ConsumeIntegral<int64_t>();
        if (fdp.ConsumeBool()) {
            parcelCamStreamStats.writeInt64(requestCount);
        }
        int64_t errorCount = fdp.ConsumeIntegral<int64_t>();
        if (fdp.ConsumeBool()) {
            parcelCamStreamStats.writeInt64(errorCount);
        }
        int32_t maxHalBuffers = fdp.ConsumeIntegral<int32_t>();
        if (fdp.ConsumeBool()) {
            parcelCamStreamStats.writeInt32(maxHalBuffers);
        }
        int32_t maxAppBuffers = fdp.ConsumeIntegral<int32_t>();
        if (fdp.ConsumeBool()) {
            parcelCamStreamStats.writeInt32(maxAppBuffers);
        }
        int32_t dynamicRangeProfile = fdp.ConsumeIntegral<int32_t>();
        if (fdp.ConsumeBool()) {
            parcelCamStreamStats.writeInt32(dynamicRangeProfile);
        }
        int32_t streamUseCase = fdp.ConsumeIntegral<int32_t>();
        if (fdp.ConsumeBool()) {
            parcelCamStreamStats.writeInt32(streamUseCase);
        }

        cameraStreamStats = new CameraStreamStats(width, height, format, maxPreviewFps, dataSpace,
                                                  usage, maxHalBuffers, maxAppBuffers,
                                                  dynamicRangeProfile, streamUseCase);
    }

    parcelCamStreamStats.setDataPosition(0);
    cameraStreamStats->readFromParcel(&parcelCamStreamStats);
    invokeReadWriteNullParcel<CameraStreamStats>(cameraStreamStats);
    invokeReadWriteParcel<CameraStreamStats>(cameraStreamStats);

    CameraSessionStats* cameraSessionStats = nullptr;
    Parcel parcelCamSessionStats;

    if (fdp.ConsumeBool()) {
        cameraSessionStats = new CameraSessionStats();
    } else {
        string camId = fdp.ConsumeRandomLengthString();
        String16 cameraId(camId.c_str());
        if (fdp.ConsumeBool()) {
            parcelCamSessionStats.writeString16(cameraId);
        }
        int32_t facing = fdp.ConsumeIntegral<int32_t>();
        if (fdp.ConsumeBool()) {
            parcelCamSessionStats.writeInt32(facing);
        }
        int32_t newCameraState = fdp.ConsumeIntegral<int32_t>();
        if (fdp.ConsumeBool()) {
            parcelCamSessionStats.writeInt32(newCameraState);
        }
        string name = fdp.ConsumeRandomLengthString();
        String16 clientName(name.c_str());
        if (fdp.ConsumeBool()) {
            parcelCamSessionStats.writeString16(clientName);
        }
        int32_t apiLevel = fdp.ConsumeIntegral<int32_t>();
        if (fdp.ConsumeBool()) {
            parcelCamSessionStats.writeInt32(apiLevel);
        }
        bool isNdk = fdp.ConsumeBool();
        if (fdp.ConsumeBool()) {
            parcelCamSessionStats.writeBool(isNdk);
        }
        int32_t latencyMs = fdp.ConsumeIntegral<int32_t>();
        if (fdp.ConsumeBool()) {
            parcelCamSessionStats.writeInt32(latencyMs);
        }

        cameraSessionStats = new CameraSessionStats(cameraId, facing, newCameraState, clientName,
                                                    apiLevel, isNdk, latencyMs);
    }

    if (fdp.ConsumeBool()) {
        int32_t internalReconfigure = fdp.ConsumeIntegral<int32_t>();
        parcelCamSessionStats.writeInt32(internalReconfigure);
    }

    if (fdp.ConsumeBool()) {
        int64_t requestCount = fdp.ConsumeIntegral<int64_t>();
        parcelCamSessionStats.writeInt64(requestCount);
    }

    if (fdp.ConsumeBool()) {
        int64_t resultErrorCount = fdp.ConsumeIntegral<int64_t>();
        parcelCamSessionStats.writeInt64(resultErrorCount);
    }

    if (fdp.ConsumeBool()) {
        bool deviceError = fdp.ConsumeBool();
        parcelCamSessionStats.writeBool(deviceError);
    }

    parcelCamSessionStats.setDataPosition(0);
    cameraSessionStats->readFromParcel(&parcelCamSessionStats);
    invokeReadWriteNullParcel<CameraSessionStats>(cameraSessionStats);
    invokeReadWriteParcel<CameraSessionStats>(cameraSessionStats);

    delete cameraStreamStats;
    delete cameraSessionStats;
    return 0;
}
Loading