• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1  /*
2  * Copyright (c) 2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef METADATA_OUTPUT_FUZZER_H
17 #define METADATA_OUTPUT_FUZZER_H
18 
19 #include "metadata_common_utils.h"
20 #include "iservice_registry.h"
21 #include "system_ability_definition.h"
22 #include "deferred_processing_service.h"
23 #include "camera_log.h"
24 #include <fuzzer/FuzzedDataProvider.h>
25 
26 namespace OHOS {
27 namespace CameraStandard {
28 using namespace DeferredProcessing;
29 class IDeferredPhotoProcessingSessionCallbackFuzz : public IDeferredPhotoProcessingSessionCallback {
30 public:
31     explicit IDeferredPhotoProcessingSessionCallbackFuzz() = default;
32     virtual ~IDeferredPhotoProcessingSessionCallbackFuzz() = default;
OnProcessImageDone(const std::string & imageId,const sptr<IPCFileDescriptor> & ipcFd,int64_t bytes,uint32_t cloudImageEnhanceFlag)33     inline int32_t OnProcessImageDone(const std::string &imageId,
34         const sptr<IPCFileDescriptor>& ipcFd, int64_t bytes, uint32_t cloudImageEnhanceFlag) override
35     {
36         return 0;
37     }
OnProcessImageDone(const std::string & imageId,const std::shared_ptr<PictureIntf> & picture,uint32_t cloudImageEnhanceFlag)38     inline int32_t OnProcessImageDone(const std::string &imageId, const std::shared_ptr<PictureIntf>& picture,
39         uint32_t cloudImageEnhanceFlag) override
40     {
41         return 0;
42     }
OnDeliveryLowQualityImage(const std::string & imageId,const std::shared_ptr<PictureIntf> & picture)43     inline int32_t OnDeliveryLowQualityImage(const std::string &imageId,
44         const std::shared_ptr<PictureIntf>& picture) override
45     {
46         return 0;
47     }
OnError(const std::string & imageId,DeferredProcessing::ErrorCode errorCode)48     inline int32_t OnError(const std::string &imageId, DeferredProcessing::ErrorCode errorCode) override
49     {
50         return 0;
51     }
OnStateChanged(DeferredProcessing::StatusCode status)52     inline int32_t OnStateChanged(DeferredProcessing::StatusCode status) override
53     {
54         return 0;
55     }
AsObject()56     sptr<IRemoteObject> AsObject() override
57     {
58         auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
59         if (samgr == nullptr) {
60             return nullptr;
61         }
62         sptr<IRemoteObject> object = samgr->GetSystemAbility(CAMERA_SERVICE_ID);
63         return object;
64     }
65 };
66 
67 class AppMetadataCallback : public MetadataObjectCallback, public MetadataStateCallback {
68 public:
OnMetadataObjectsAvailable(std::vector<sptr<MetadataObject>> metaObjects)69     void OnMetadataObjectsAvailable(std::vector<sptr<MetadataObject>> metaObjects) const
70     {
71         MEDIA_INFO_LOG("AppMetadataCallback::OnMetadataObjectsAvailable received");
72     }
OnError(int32_t errorCode)73     void OnError(int32_t errorCode) const
74     {
75         MEDIA_INFO_LOG("AppMetadataCallback::OnError %{public}d", errorCode);
76     }
77 };
78 
79 class MetadataStateCallbackTest : public MetadataStateCallback {
80 public:
81     MetadataStateCallbackTest() = default;
82     virtual ~MetadataStateCallbackTest() = default;
OnError(int32_t errorCode)83     virtual void OnError(int32_t errorCode) const {};
84 };
85 
86 class MetadataOutputFuzzer {
87 public:
88 static std::shared_ptr<MetadataOutput> fuzz_;
89 static void MetadataOutputFuzzTest(FuzzedDataProvider& fdp);
90 static void MetadataOutputFuzzTest1(FuzzedDataProvider& fdp);
91 };
92 } //CameraStandard
93 } //OHOS
94 #endif //METADATA_OUTPUT_FUZZER_H