已开启
fix fuzz part02 #4781
zhangchunrui创建于 21 天前
fix fuzz part02 #4781
已开启
共 25 个文件变更+1062-269
| @@ -44,10 +44,11 @@ ohos_fuzztest("CaptureSessionAddFuzzTest") { | |||
| 44 | defines += [ "CAMERA_MOVING_PHOTO" ] | 44 | defines += [ "CAMERA_MOVING_PHOTO" ] |
| 45 | } | 45 | } |
| 46 | 46 | ||
| 47 | - deps = [ | 47 | + deps = [ |
| 48 | "${multimedia_camera_framework_path}/frameworks/native/camera/base:camera_framework", | 48 | "${multimedia_camera_framework_path}/frameworks/native/camera/base:camera_framework", |
| 49 | "${multimedia_camera_framework_path}/frameworks/native/camera/extension:camera_framework_ex", | 49 | "${multimedia_camera_framework_path}/frameworks/native/camera/extension:camera_framework_ex", |
| 50 | "${multimedia_camera_framework_path}/test/test_common:test_common", | 50 | "${multimedia_camera_framework_path}/test/test_common:test_common", |
| 51 | + "${multimedia_camera_framework_path}/common:camera_utils", | ||
| 51 | ] | 52 | ] |
| 52 | external_deps = [ | 53 | external_deps = [ |
| 53 | "ability_base:want", | 54 | "ability_base:want", |
| @@ -18,7 +18,7 @@ | |||
| 18 | 18 | ||
| 19 | 19 | ||
| 20 | 20 | ||
| 21 | -#include "capture_output.h" | 21 | +#include "capture_output.h" |
| 22 | 22 | ||
| 23 | 23 | ||
| 24 | 24 | ||
| @@ -37,6 +37,8 @@ | |||
| 37 | 37 | ||
| 38 | 38 | ||
| 39 | 39 | ||
| 40 | + | ||
| 41 | + | ||
| 40 | 42 | ||
| 41 | namespace OHOS { | 43 | namespace OHOS { |
| 42 | namespace CameraStandard { | 44 | namespace CameraStandard { |
| @@ -117,6 +119,19 @@ void Test(uint8_t* data, size_t size) | |||
| 117 | TestAdd(session, fdp); | 119 | TestAdd(session, fdp); |
| 118 | TestSession(session, fdp); | 120 | TestSession(session, fdp); |
| 119 | TestOther2(session, fdp); | 121 | TestOther2(session, fdp); |
| 122 | + TestZoomPointInfos(session, fdp); | ||
| 123 | + TestFocusDistance(session, fdp); | ||
| 124 | + TestDepthFusion(session, fdp); | ||
| 125 | + TestStageBoost(session, fdp); | ||
| 126 | + TestLcdFlash(session, fdp); | ||
| 127 | + TestTripodDetection(session, fdp); | ||
| 128 | + TestConstellationDrawing(session, fdp); | ||
| 129 | + TestImageStabilizationGuide(session, fdp); | ||
| 130 | + TestSuperMoon(session, fdp); | ||
| 131 | + TestImagingMode(session, fdp); | ||
| 132 | + TestCallbacks(session, fdp); | ||
| 133 | + TestSetUsageBranch(session, fdp); | ||
| 134 | + TestSetEffectSuggestionStatusBranch(session, fdp); | ||
| 120 | session->Release(); | 135 | session->Release(); |
| 121 | session->Stop(); | 136 | session->Stop(); |
| 122 | } | 137 | } |
| @@ -293,7 +308,11 @@ void TestOther2(sptr<CaptureSessionForSys> session, FuzzedDataProvider& fdp) | |||
| 293 | session->IsColorStyleSupported(isSupported); | 308 | session->IsColorStyleSupported(isSupported); |
| 294 | std::vector<ColorStyleSetting> defaultColorStyles; | 309 | std::vector<ColorStyleSetting> defaultColorStyles; |
| 295 | session->GetDefaultColorStyleSettings(defaultColorStyles); | 310 | session->GetDefaultColorStyleSettings(defaultColorStyles); |
| 296 | - ColorStyleSetting styleSetting = {static_cast<ColorStyleType>(1), 1, 1, 1}; | 311 | + ColorStyleSetting styleSetting; |
| 312 | + styleSetting.type = static_cast<ColorStyleType>(1); | ||
| 313 | + styleSetting.hue = 1; | ||
| 314 | + styleSetting.saturation = 1; | ||
| 315 | + styleSetting.tone = 1; | ||
| 297 | session->SetColorStyleSetting(styleSetting); | 316 | session->SetColorStyleSetting(styleSetting); |
| 298 | session->UnlockForControl(); | 317 | session->UnlockForControl(); |
| 299 | } | 318 | } |
| @@ -378,7 +397,7 @@ void TestOther3(sptr<CaptureSessionForSys> session, FuzzedDataProvider& fdp) | |||
| 378 | fdp.ConsumeIntegral<int32_t>() % (QualityPrioritization::HIGH_QUALITY + NUM_TWO)); | 397 | fdp.ConsumeIntegral<int32_t>() % (QualityPrioritization::HIGH_QUALITY + NUM_TWO)); |
| 379 | session->LockForControl(); | 398 | session->LockForControl(); |
| 380 | session->SetQualityPrioritization(qualityPrioritization); | 399 | session->SetQualityPrioritization(qualityPrioritization); |
| 381 | - | 400 | + |
| 382 | session->ProcessProfilesAbilityId(g_sceneMode); | 401 | session->ProcessProfilesAbilityId(g_sceneMode); |
| 383 | Point point; | 402 | Point point; |
| 384 | session->CoordinateTransform(point); | 403 | session->CoordinateTransform(point); |
| @@ -421,6 +440,130 @@ void TestOther3(sptr<CaptureSessionForSys> session, FuzzedDataProvider& fdp) | |||
| 421 | session->EnableAutoMotionBoostDelivery(fdp.ConsumeBool()); | 440 | session->EnableAutoMotionBoostDelivery(fdp.ConsumeBool()); |
| 422 | session->EnableAutoBokehDataDelivery(fdp.ConsumeBool()); | 441 | session->EnableAutoBokehDataDelivery(fdp.ConsumeBool()); |
| 423 | } | 442 | } |
| 443 | + | ||
| 444 | +void TestZoomPointInfos(sptr<CaptureSessionForSys> session, FuzzedDataProvider& fdp) | ||
| 445 | +{ | ||
| 446 | + MEDIA_INFO_LOG("CaptureSessionFuzzer: ENTER"); | ||
| 447 | + std::vector<ZoomPointInfo> zoomPointInfoList; | ||
| 448 | + session->GetZoomPointInfos(zoomPointInfoList); | ||
| 449 | +} | ||
| 450 | + | ||
| 451 | +void TestFocusDistance(sptr<CaptureSessionForSys> session, FuzzedDataProvider& fdp) | ||
| 452 | +{ | ||
| 453 | + MEDIA_INFO_LOG("CaptureSessionFuzzer: ENTER"); | ||
| 454 | + float focusDistance = 0.0f; | ||
| 455 | + session->GetFocusDistance(focusDistance); | ||
| 456 | +} | ||
| 457 | + | ||
| 458 | +void TestDepthFusion(sptr<CaptureSessionForSys> session, FuzzedDataProvider& fdp) | ||
| 459 | +{ | ||
| 460 | + MEDIA_INFO_LOG("CaptureSessionFuzzer: ENTER"); | ||
| 461 | + std::vector<float> depthFusionThreshold; | ||
| 462 | + session->GetDepthFusionThreshold(depthFusionThreshold); | ||
| 463 | + session->IsDepthFusionSupported(); | ||
| 464 | + session->IsDepthFusionEnabled(); | ||
| 465 | + session->LockForControl(); | ||
| 466 | + session->EnableDepthFusion(fdp.ConsumeBool()); | ||
| 467 | + session->UnlockForControl(); | ||
| 468 | +} | ||
| 469 | + | ||
| 470 | +void TestStageBoost(sptr<CaptureSessionForSys> session, FuzzedDataProvider& fdp) | ||
| 471 | +{ | ||
| 472 | + MEDIA_INFO_LOG("CaptureSessionFuzzer: ENTER"); | ||
| 473 | + session->IsStageBoostSupported(); | ||
| 474 | + session->LockForControl(); | ||
| 475 | + session->EnableStageBoost(fdp.ConsumeBool()); | ||
| 476 | + session->UnlockForControl(); | ||
| 477 | +} | ||
| 478 | + | ||
| 479 | +void TestLcdFlash(sptr<CaptureSessionForSys> session, FuzzedDataProvider& fdp) | ||
| 480 | +{ | ||
| 481 | + MEDIA_INFO_LOG("CaptureSessionFuzzer: ENTER"); | ||
| 482 | + session->IsLcdFlashSupported(); | ||
| 483 | + session->LockForControl(); | ||
| 484 | + session->EnableLcdFlashDetection(fdp.ConsumeBool()); | ||
| 485 | + session->EnableLcdFlash(fdp.ConsumeBool()); | ||
| 486 | + session->UnlockForControl(); | ||
| 487 | +} | ||
| 488 | + | ||
| 489 | +void TestTripodDetection(sptr<CaptureSessionForSys> session, FuzzedDataProvider& fdp) | ||
| 490 | +{ | ||
| 491 | + MEDIA_INFO_LOG("CaptureSessionFuzzer: ENTER"); | ||
| 492 | + session->IsTripodDetectionSupported(); | ||
| 493 | + session->LockForControl(); | ||
| 494 | + session->EnableTripodDetection(fdp.ConsumeBool()); | ||
| 495 | + session->UnlockForControl(); | ||
| 496 | +} | ||
| 497 | + | ||
| 498 | +void TestConstellationDrawing(sptr<CaptureSessionForSys> session, FuzzedDataProvider& fdp) | ||
| 499 | +{ | ||
| 500 | + MEDIA_INFO_LOG("CaptureSessionFuzzer: ENTER"); | ||
| 501 | + session->LockForControl(); | ||
| 502 | + session->EnableConstellationDrawingDetection(fdp.ConsumeBool()); | ||
| 503 | + session->UnlockForControl(); | ||
| 504 | +} | ||
| 505 | + | ||
| 506 | +void TestImageStabilizationGuide(sptr<CaptureSessionForSys> session, FuzzedDataProvider& fdp) | ||
| 507 | +{ | ||
| 508 | + MEDIA_INFO_LOG("CaptureSessionFuzzer: ENTER"); | ||
| 509 | + session->GetImageStabilizationGuideCallback(); | ||
| 510 | +} | ||
| 511 | + | ||
| 512 | +void TestSuperMoon(sptr<CaptureSessionForSys> session, FuzzedDataProvider& fdp) | ||
| 513 | +{ | ||
| 514 | + MEDIA_INFO_LOG("CaptureSessionFuzzer: ENTER"); | ||
| 515 | + session->EnableSuperMoonFeature(fdp.ConsumeBool()); | ||
| 516 | +} | ||
| 517 | + | ||
| 518 | +void TestImagingMode(sptr<CaptureSessionForSys> session, FuzzedDataProvider& fdp) | ||
| 519 | +{ | ||
| 520 | + MEDIA_INFO_LOG("CaptureSessionFuzzer: ENTER"); | ||
| 521 | + ImagingMode imagingMode = ImagingMode::IMAGING_MODE_AUTO; | ||
| 522 | + session->GetImagingMode(imagingMode); | ||
| 523 | + std::vector<ImagingMode> imagingModes; | ||
| 524 | + session->GetSupportedImagingMode(imagingModes); | ||
| 525 | + bool isSupported = false; | ||
| 526 | + session->IsImagingModeSupported(imagingMode, isSupported); | ||
| 527 | + session->SetImagingMode(imagingMode); | ||
| 528 | +} | ||
| 529 | + | ||
| 530 | +void TestCallbacks(sptr<CaptureSessionForSys> session, FuzzedDataProvider& fdp) | ||
| 531 | +{ | ||
| 532 | + MEDIA_INFO_LOG("CaptureSessionFuzzer: ENTER"); | ||
| 533 | + std::shared_ptr<FeatureDetectionStatusCallback> featureDetectionCallback = | ||
| 534 | + std::make_shared<FeatureDetectionStatusCallbackMock>(true); | ||
| 535 | + session->SetFeatureDetectionStatusCallback(featureDetectionCallback); | ||
| 536 | + std::shared_ptr<EffectSuggestionCallback> effectSuggestionCallback = | ||
| 537 | + std::make_shared<EffectSuggestionCallbackMock>(); | ||
| 538 | + session->SetEffectSuggestionCallback(effectSuggestionCallback); | ||
| 539 | + std::shared_ptr<LcdFlashStatusCallback> lcdFlashStatusCallback = | ||
| 540 | + std::make_shared<LcdFlashStatusCallbackMock>(); | ||
| 541 | + session->SetLcdFlashStatusCallback(lcdFlashStatusCallback); | ||
| 542 | +} | ||
| 543 | + | ||
| 544 | +void TestSetUsageBranch(sptr<CaptureSessionForSys> session, FuzzedDataProvider& fdp) | ||
| 545 | +{ | ||
| 546 | + MEDIA_INFO_LOG("CaptureSessionFuzzer: ENTER"); | ||
| 547 | + session->LockForControl(); | ||
| 548 | + session->SetUsage(UsageType::BOKEH, fdp.ConsumeBool()); | ||
| 549 | + session->UnlockForControl(); | ||
| 550 | +} | ||
| 551 | + | ||
| 552 | +void TestSetEffectSuggestionStatusBranch(sptr<CaptureSessionForSys> session, FuzzedDataProvider& fdp) | ||
| 553 | +{ | ||
| 554 | + MEDIA_INFO_LOG("CaptureSessionFuzzer: ENTER"); | ||
| 555 | + std::vector<EffectSuggestionStatus> effectSuggestionStatusList; | ||
| 556 | + EffectSuggestionType type = static_cast<EffectSuggestionType>( | ||
| 557 | + fdp.ConsumeIntegral<int32_t>() % (EffectSuggestionType::EFFECT_SUGGESTION_SUNRISE_SUNSET + NUM_TWO)); | ||
| 558 | + EffectSuggestionStatus status = { | ||
| 559 | + type, | ||
| 560 | + fdp.ConsumeBool(), | ||
| 561 | + }; | ||
| 562 | + effectSuggestionStatusList.push_back(status); | ||
| 563 | + session->LockForControl(); | ||
| 564 | + session->SetEffectSuggestionStatus(effectSuggestionStatusList); | ||
| 565 | + session->UnlockForControl(); | ||
| 566 | +} | ||
| 424 | } // namespace StreamRepeatStubFuzzer | 567 | } // namespace StreamRepeatStubFuzzer |
| 425 | } // namespace CameraStandard | 568 | } // namespace CameraStandard |
| 426 | } // namespace OHOS | 569 | } // namespace OHOS |
| @@ -41,6 +41,19 @@ void TestOther(sptr<CaptureSessionForSys> session, FuzzedDataProvider& fdp); | |||
| 41 | void TestOther2(sptr<CaptureSessionForSys> session, FuzzedDataProvider& fdp); | 41 | void TestOther2(sptr<CaptureSessionForSys> session, FuzzedDataProvider& fdp); |
| 42 | void TestOther3(sptr<CaptureSessionForSys> session, FuzzedDataProvider& fdp); | 42 | void TestOther3(sptr<CaptureSessionForSys> session, FuzzedDataProvider& fdp); |
| 43 | void TestAdd(sptr<CaptureSessionForSys> session, FuzzedDataProvider& fdp); | 43 | void TestAdd(sptr<CaptureSessionForSys> session, FuzzedDataProvider& fdp); |
| 44 | +void TestZoomPointInfos(sptr<CaptureSessionForSys> session, FuzzedDataProvider& fdp); | ||
| 45 | +void TestFocusDistance(sptr<CaptureSessionForSys> session, FuzzedDataProvider& fdp); | ||
| 46 | +void TestDepthFusion(sptr<CaptureSessionForSys> session, FuzzedDataProvider& fdp); | ||
| 47 | +void TestStageBoost(sptr<CaptureSessionForSys> session, FuzzedDataProvider& fdp); | ||
| 48 | +void TestLcdFlash(sptr<CaptureSessionForSys> session, FuzzedDataProvider& fdp); | ||
| 49 | +void TestTripodDetection(sptr<CaptureSessionForSys> session, FuzzedDataProvider& fdp); | ||
| 50 | +void TestConstellationDrawing(sptr<CaptureSessionForSys> session, FuzzedDataProvider& fdp); | ||
| 51 | +void TestImageStabilizationGuide(sptr<CaptureSessionForSys> session, FuzzedDataProvider& fdp); | ||
| 52 | +void TestSuperMoon(sptr<CaptureSessionForSys> session, FuzzedDataProvider& fdp); | ||
| 53 | +void TestImagingMode(sptr<CaptureSessionForSys> session, FuzzedDataProvider& fdp); | ||
| 54 | +void TestCallbacks(sptr<CaptureSessionForSys> session, FuzzedDataProvider& fdp); | ||
| 55 | +void TestSetUsageBranch(sptr<CaptureSessionForSys> session, FuzzedDataProvider& fdp); | ||
| 56 | +void TestSetEffectSuggestionStatusBranch(sptr<CaptureSessionForSys> session, FuzzedDataProvider& fdp); | ||
| 44 | 57 | ||
| 45 | class SessionCallbackMock : public SessionCallback { | 58 | class SessionCallbackMock : public SessionCallback { |
| 46 | public: | 59 | public: |
| @@ -84,6 +97,11 @@ public: | |||
| 84 | void OnEffectSuggestionChange(EffectSuggestionType effectSuggestionType) override {} | 97 | void OnEffectSuggestionChange(EffectSuggestionType effectSuggestionType) override {} |
| 85 | }; | 98 | }; |
| 86 | 99 | ||
| 100 | +class LcdFlashStatusCallbackMock : public LcdFlashStatusCallback { | ||
| 101 | +public: | ||
| 102 | + void OnLcdFlashStatusChanged(LcdFlashStatusInfo status) override {} | ||
| 103 | +}; | ||
| 104 | + | ||
| 87 | class ARCallbackMock : public ARCallback { | 105 | class ARCallbackMock : public ARCallback { |
| 88 | public: | 106 | public: |
| 89 | void OnResult(const ARStatusInfo &arStatusInfo) const override {} | 107 | void OnResult(const ARStatusInfo &arStatusInfo) const override {} |
| @@ -145,6 +145,127 @@ void CaptureSessionProxyFuzz::CaptureSessionProxyFuzzTest9(FuzzedDataProvider &f | |||
| 145 | fuzz_->EnableKeyFrameReport(isKeyFrameReportEnabled); | 145 | fuzz_->EnableKeyFrameReport(isKeyFrameReportEnabled); |
| 146 | } | 146 | } |
| 147 | 147 | ||
| 148 | +void CaptureSessionProxyFuzz::CaptureSessionProxyTestWithMock(FuzzedDataProvider &fdp) | ||
| 149 | +{ | ||
| 150 | + sptr<MockIRemoteObject> mockRemote = new MockIRemoteObject(); | ||
| 151 | + fuzz_ = std::make_shared<CaptureSessionProxy>(mockRemote); | ||
| 152 | + | ||
| 153 | + fuzz_->BeginConfig(); | ||
| 154 | + fuzz_->CommitConfig(); | ||
| 155 | + fuzz_->Start(); | ||
| 156 | + fuzz_->Stop(); | ||
| 157 | + fuzz_->Release(); | ||
| 158 | + | ||
| 159 | + bool results = false; | ||
| 160 | + fuzz_->CanAddInput(nullptr, results); | ||
| 161 | + | ||
| 162 | + CaptureSessionState sessionState = CaptureSessionState::SESSION_INIT; | ||
| 163 | + fuzz_->GetSessionState(sessionState); | ||
| 164 | + | ||
| 165 | + int32_t featureMode = fdp.ConsumeIntegral<int32_t>(); | ||
| 166 | + fuzz_->SetFeatureMode(featureMode); | ||
| 167 | + | ||
| 168 | + bool isNeedCommitting = fdp.ConsumeBool(); | ||
| 169 | + fuzz_->SetCommitConfigFlag(isNeedCommitting); | ||
| 170 | + | ||
| 171 | + bool isKeyFrameReportEnabled = fdp.ConsumeBool(); | ||
| 172 | + fuzz_->EnableKeyFrameReport(isKeyFrameReportEnabled); | ||
| 173 | +} | ||
| 174 | + | ||
| 175 | +void CaptureSessionProxyFuzz::CaptureSessionProxyTestUncoveredMethods(FuzzedDataProvider &fdp) | ||
| 176 | +{ | ||
| 177 | + sptr<MockIRemoteObject> mockRemote = new MockIRemoteObject(); | ||
| 178 | + fuzz_ = std::make_shared<CaptureSessionProxy>(mockRemote); | ||
| 179 | + | ||
| 180 | + bool status = fdp.ConsumeBool(); | ||
| 181 | + fuzz_->SetXtStyleStatus(status); | ||
| 182 | + | ||
| 183 | + sptr<ICameraSwitchSessionCallback> callbackFunc = new CameraSwitchSessionCallbackMock(); | ||
| 184 | + fuzz_->SetCameraSwitchRequestCallback(callbackFunc); | ||
| 185 | + fuzz_->UnSetCameraSwitchRequestCallback(); | ||
| 186 | + | ||
| 187 | + sptr<IRemoteObject> compositionStreamRemote = nullptr; | ||
| 188 | + fuzz_->GetCompositionStream(compositionStreamRemote); | ||
| 189 | + | ||
| 190 | + int32_t sensorRotation = 0; | ||
| 191 | + fuzz_->GetSensorRotationOnce(sensorRotation); | ||
| 192 | + | ||
| 193 | + bool value = false; | ||
| 194 | + fuzz_->IsAutoFramingSupported(value); | ||
| 195 | + fuzz_->GetAutoFramingStatus(value); | ||
| 196 | + | ||
| 197 | + bool needPersist = fdp.ConsumeBool(); | ||
| 198 | + fuzz_->EnableAutoFraming(value, needPersist); | ||
| 199 | + | ||
| 200 | + std::vector<int32_t> colorEffectMetadata; | ||
| 201 | + uint8_t vectorSize = fdp.ConsumeIntegralInRange<uint8_t>(0, MAX_BUFFER_SIZE); | ||
| 202 | + for (int i = 0; i < vectorSize; ++i) { | ||
| 203 | + colorEffectMetadata.push_back(fdp.ConsumeIntegral<int32_t>()); | ||
| 204 | + } | ||
| 205 | + fuzz_->GetColorEffectsMetadata(colorEffectMetadata); | ||
| 206 | + | ||
| 207 | + int32_t colourEffect = fdp.ConsumeIntegral<int32_t>(); | ||
| 208 | + fuzz_->GetColorEffect(colourEffect); | ||
| 209 | + fuzz_->SetColorEffect(colourEffect); | ||
| 210 | +} | ||
| 211 | + | ||
| 212 | +void CaptureSessionProxyFuzz::CaptureSessionProxyTestErrorBranches(FuzzedDataProvider &fdp) | ||
| 213 | +{ | ||
| 214 | + sptr<MockIRemoteObject> mockRemote = new MockIRemoteObject(); | ||
| 215 | + mockRemote->shouldFail = true; | ||
| 216 | + mockRemote->errorCode = -1; | ||
| 217 | + fuzz_ = std::make_shared<CaptureSessionProxy>(mockRemote); | ||
| 218 | + | ||
| 219 | + fuzz_->BeginConfig(); | ||
| 220 | + fuzz_->AddInput(nullptr); | ||
| 221 | + fuzz_->RemoveInput(nullptr); | ||
| 222 | + fuzz_->CommitConfig(); | ||
| 223 | + fuzz_->Start(); | ||
| 224 | + fuzz_->Stop(); | ||
| 225 | + fuzz_->Release(); | ||
| 226 | + | ||
| 227 | + sptr<ICaptureSessionCallback> captureSessionCallback = new CaptureSessionCallback(); | ||
| 228 | + fuzz_->SetCallback(captureSessionCallback); | ||
| 229 | + captureSessionCallback = nullptr; | ||
| 230 | + fuzz_->SetCallback(captureSessionCallback); | ||
| 231 | + | ||
| 232 | + sptr<IPressureStatusCallback> pressureStatusCallback = new PressureStatusCallback(); | ||
| 233 | + fuzz_->SetPressureCallback(pressureStatusCallback); | ||
| 234 | + | ||
| 235 | + bool isNeedCommitting = fdp.ConsumeBool(); | ||
| 236 | + fuzz_->SetCommitConfigFlag(isNeedCommitting); | ||
| 237 | + | ||
| 238 | + bool isHasFitedRotation = fdp.ConsumeBool(); | ||
| 239 | + fuzz_->SetHasFitedRotation(isHasFitedRotation); | ||
| 240 | + | ||
| 241 | + sptr<IRemoteObject> remote = nullptr; | ||
| 242 | + sptr<ICameraRecorder> recorder = nullptr; | ||
| 243 | + fuzz_->CreateRecorder(remote, recorder); | ||
| 244 | + | ||
| 245 | + int32_t opMode = fdp.ConsumeIntegral<int32_t>(); | ||
| 246 | + fuzz_->AddMultiStreamOutput(remote, opMode); | ||
| 247 | + fuzz_->RemoveMultiStreamOutput(remote); | ||
| 248 | + | ||
| 249 | + int32_t type = fdp.ConsumeIntegral<int32_t>(); | ||
| 250 | + std::vector<int32_t> range; | ||
| 251 | + fuzz_->GetBeautyRange(range, type); | ||
| 252 | + | ||
| 253 | + int32_t beautyValue = fdp.ConsumeIntegral<int32_t>(); | ||
| 254 | + fuzz_->GetBeautyValue(type, beautyValue); | ||
| 255 | + | ||
| 256 | + int32_t value = fdp.ConsumeIntegral<int32_t>(); | ||
| 257 | + bool needPersist = fdp.ConsumeBool(); | ||
| 258 | + fuzz_->SetBeautyValue(type, value, needPersist); | ||
| 259 | + | ||
| 260 | + sptr<IControlCenterEffectStatusCallback> callbackFunc = new ControlCenterEffectStatusCallback(); | ||
| 261 | + fuzz_->SetControlCenterEffectStatusCallback(callbackFunc); | ||
| 262 | + callbackFunc = nullptr; | ||
| 263 | + fuzz_->SetControlCenterEffectStatusCallback(callbackFunc); | ||
| 264 | + | ||
| 265 | + bool isKeyFrameReportEnabled = fdp.ConsumeBool(); | ||
| 266 | + fuzz_->EnableKeyFrameReport(isKeyFrameReportEnabled); | ||
| 267 | +} | ||
| 268 | + | ||
| 148 | void FuzzTest(const uint8_t *rawData, size_t size) | 269 | void FuzzTest(const uint8_t *rawData, size_t size) |
| 149 | { | 270 | { |
| 150 | FuzzedDataProvider fdp(rawData, size); | 271 | FuzzedDataProvider fdp(rawData, size); |
| @@ -168,6 +289,9 @@ void FuzzTest(const uint8_t *rawData, size_t size) | |||
| 168 | captureSessionProxy->CaptureSessionProxyFuzzTest7(fdp); | 289 | captureSessionProxy->CaptureSessionProxyFuzzTest7(fdp); |
| 169 | captureSessionProxy->CaptureSessionProxyFuzzTest8(fdp); | 290 | captureSessionProxy->CaptureSessionProxyFuzzTest8(fdp); |
| 170 | captureSessionProxy->CaptureSessionProxyFuzzTest9(fdp); | 291 | captureSessionProxy->CaptureSessionProxyFuzzTest9(fdp); |
| 292 | + captureSessionProxy->CaptureSessionProxyTestWithMock(fdp); | ||
| 293 | + captureSessionProxy->CaptureSessionProxyTestUncoveredMethods(fdp); | ||
| 294 | + captureSessionProxy->CaptureSessionProxyTestErrorBranches(fdp); | ||
| 171 | } | 295 | } |
| 172 | } // namespace CameraStandard | 296 | } // namespace CameraStandard |
| 173 | } // namespace OHOS | 297 | } // namespace OHOS |
| @@ -18,9 +18,54 @@ | |||
| 18 | 18 | ||
| 19 | 19 | ||
| 20 | 20 | ||
| 21 | + | ||
| 22 | + | ||
| 21 | 23 | ||
| 22 | namespace OHOS { | 24 | namespace OHOS { |
| 23 | namespace CameraStandard { | 25 | namespace CameraStandard { |
| 26 | +class MockIRemoteObject : public IPCObjectStub { | ||
| 27 | +public: | ||
| 28 | + MockIRemoteObject() : IPCObjectStub(u"mock_i_remote_object") { | ||
| 29 | + member_descriptor = u"mock_i_remote_object"; | ||
| 30 | + shouldFail = false; | ||
| 31 | + errorCode = 0; | ||
| 32 | + } | ||
| 33 | + | ||
| 34 | + bool shouldFail; | ||
| 35 | + int32_t errorCode; | ||
| 36 | + std::u16string member_descriptor; | ||
| 37 | + int OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) override { | ||
| 38 | + if (shouldFail) { | ||
| 39 | + return errorCode; | ||
| 40 | + } | ||
| 41 | + reply.WriteInt32(0); | ||
| 42 | + return 0; | ||
| 43 | + } | ||
| 44 | +}; | ||
| 45 | + | ||
| 46 | +class CameraSwitchSessionCallbackMock : public ICameraSwitchSessionCallback { | ||
| 47 | +public: | ||
| 48 | + sptr<IRemoteObject> AsObject() override | ||
| 49 | + { | ||
| 50 | + return nullptr; | ||
| 51 | + } | ||
| 52 | + ErrCode OnCameraActive(const std::string& cameraId, bool isRegisterCameraSwitchCallback, | ||
| 53 | + const CaptureSessionInfo& sessionInfo) override | ||
| 54 | + { | ||
| 55 | + return 0; | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + ErrCode OnCameraUnactive(const std::string& cameraId) override | ||
| 59 | + { | ||
| 60 | + return 0; | ||
| 61 | + } | ||
| 62 | + | ||
| 63 | + ErrCode OnCameraSwitch(const std::string& oriCameraId, const std::string& destCameraId, bool status) override | ||
| 64 | + { | ||
| 65 | + return 0; | ||
| 66 | + } | ||
| 67 | +}; | ||
| 68 | + | ||
| 24 | class CaptureSessionProxyFuzz { | 69 | class CaptureSessionProxyFuzz { |
| 25 | public: | 70 | public: |
| 26 | static std::shared_ptr<CaptureSessionProxy> fuzz_; | 71 | static std::shared_ptr<CaptureSessionProxy> fuzz_; |
| @@ -33,6 +78,9 @@ public: | |||
| 33 | static void CaptureSessionProxyFuzzTest7(FuzzedDataProvider &fdp); | 78 | static void CaptureSessionProxyFuzzTest7(FuzzedDataProvider &fdp); |
| 34 | static void CaptureSessionProxyFuzzTest8(FuzzedDataProvider &fdp); | 79 | static void CaptureSessionProxyFuzzTest8(FuzzedDataProvider &fdp); |
| 35 | static void CaptureSessionProxyFuzzTest9(FuzzedDataProvider &fdp); | 80 | static void CaptureSessionProxyFuzzTest9(FuzzedDataProvider &fdp); |
| 81 | + static void CaptureSessionProxyTestWithMock(FuzzedDataProvider &fdp); | ||
| 82 | + static void CaptureSessionProxyTestUncoveredMethods(FuzzedDataProvider &fdp); | ||
| 83 | + static void CaptureSessionProxyTestErrorBranches(FuzzedDataProvider &fdp); | ||
| 36 | }; | 84 | }; |
| 37 | } // namespace CameraStandard | 85 | } // namespace CameraStandard |
| 38 | } // namespace OHOS | 86 | } // namespace OHOS |
| @@ -99,12 +99,34 @@ void CompositionEffectListenerTest(FuzzedDataProvider& fdp) | |||
| 99 | 99 | ||
| 100 | } | 100 | } |
| 101 | 101 | ||
| 102 | +void CompositionFeatureDirectTest(FuzzedDataProvider& fdp) | ||
| 103 | +{ | ||
| 104 | + auto feature = std::make_shared<CompositionFeature>(nullptr); | ||
| 105 | + bool isSupported = false; | ||
| 106 | + feature->IsCompositionEffectPreviewSupported(isSupported); | ||
| 107 | + feature->EnableCompositionEffectPreview(fdp.ConsumeBool()); | ||
| 108 | + std::vector<std::string> supportedLanguages; | ||
| 109 | + feature->GetSupportedRecommendedInfoLanguage(supportedLanguages); | ||
| 110 | + feature->SetRecommendedInfoLanguage(fdp.ConsumeRandomLengthString(MAX_STR_LEN)); | ||
| 111 | + feature->CheckMode(); | ||
| 112 | + feature->CheckCommonPreconditions(); | ||
| 113 | + feature->StartCompositionStream(); | ||
| 114 | + feature->StopCompositionStream(); | ||
| 115 | + sptr<SurfaceBuffer> nullBuffer; | ||
| 116 | + CompositionEffectListener::Buffer2PixelMap(nullBuffer); | ||
| 117 | + | ||
| 118 | + sptr<IConsumerSurface> nullSurface; | ||
| 119 | + auto nullSurfaceListener = sptr<CompositionEffectListener>::MakeSptr(feature, nullSurface); | ||
| 120 | + nullSurfaceListener->OnBufferAvailable(); | ||
| 121 | +} | ||
| 122 | + | ||
| 102 | void Test(uint8_t* data, size_t size) | 123 | void Test(uint8_t* data, size_t size) |
| 103 | { | 124 | { |
| 104 | FuzzedDataProvider fdp(data, size); | 125 | FuzzedDataProvider fdp(data, size); |
| 105 | CHECK_RETURN_ELOG(!TestToken().GetAllCameraPermission(), "GetPermission error"); | 126 | CHECK_RETURN_ELOG(!TestToken().GetAllCameraPermission(), "GetPermission error"); |
| 106 | CompositionFeatureUnitTest(fdp); | 127 | CompositionFeatureUnitTest(fdp); |
| 107 | CompositionEffectListenerTest(fdp); | 128 | CompositionEffectListenerTest(fdp); |
| 129 | + CompositionFeatureDirectTest(fdp); | ||
| 108 | } | 130 | } |
| 109 | 131 | ||
| 110 | } // namespace CameraStandard | 132 | } // namespace CameraStandard |
| @@ -60,14 +60,14 @@ ohos_fuzztest("HCameraDeviceFuzzTest") { | |||
| 60 | "-fno-access-control", | 60 | "-fno-access-control", |
| 61 | ] | 61 | ] |
| 62 | 62 | ||
| 63 | - sources = [ "hcamera_device_fuzzer.cpp" ] | ||
| 64 | - | ||
| 65 | defines = [] | 63 | defines = [] |
| 66 | 64 | ||
| 67 | if (camera_framework_feature_moving_photo) { | 65 | if (camera_framework_feature_moving_photo) { |
| 68 | defines += [ "CAMERA_MOVING_PHOTO" ] | 66 | defines += [ "CAMERA_MOVING_PHOTO" ] |
| 69 | } | 67 | } |
| 70 | 68 | ||
| 69 | + sources = [ "hcamera_device_fuzzer.cpp" ] | ||
| 70 | + | ||
| 71 | deps = [ | 71 | deps = [ |
| 72 | "${multimedia_camera_framework_path}/common:camera_utils", | 72 | "${multimedia_camera_framework_path}/common:camera_utils", |
| 73 | "${multimedia_camera_framework_path}/frameworks/native/camera/base:camera_framework", | 73 | "${multimedia_camera_framework_path}/frameworks/native/camera/base:camera_framework", |
| @@ -196,9 +196,6 @@ void HCameraDeviceFuzzTest3(FuzzedDataProvider& fdp) | |||
| 196 | g_hCameraDevice->GetCameraType(); | 196 | g_hCameraDevice->GetCameraType(); |
| 197 | g_hCameraDevice->IsOpenedCameraDevice(); | 197 | g_hCameraDevice->IsOpenedCameraDevice(); |
| 198 | bool isMoving = fdp.ConsumeIntegral<int32_t>() % 2; | 198 | bool isMoving = fdp.ConsumeIntegral<int32_t>() % 2; |
| 199 | - | ||
| 200 | - g_hCameraDevice->EnableMovingPhoto(isMoving); | ||
| 201 | - | ||
| 202 | g_hCameraDevice->SetDeviceMuteMode(isMoving); | 199 | g_hCameraDevice->SetDeviceMuteMode(isMoving); |
| 203 | g_hCameraDevice->ResetDeviceSettings(); | 200 | g_hCameraDevice->ResetDeviceSettings(); |
| 204 | g_hCameraDevice->DispatchDefaultSettingToHdi(); | 201 | g_hCameraDevice->DispatchDefaultSettingToHdi(); |
| @@ -217,6 +214,7 @@ void HCameraDeviceFuzzTest3(FuzzedDataProvider& fdp) | |||
| 217 | g_hCameraDevice->OpenDevice(true); | 214 | g_hCameraDevice->OpenDevice(true); |
| 218 | g_hCameraDevice->CloseDevice(); | 215 | g_hCameraDevice->CloseDevice(); |
| 219 | 216 | ||
| 217 | + g_hCameraDevice->EnableMovingPhoto(isMoving); | ||
| 220 | int32_t mode = fdp.ConsumeIntegral<int32_t>(); | 218 | int32_t mode = fdp.ConsumeIntegral<int32_t>(); |
| 221 | g_hCameraDevice->CheckMovingPhotoSupported(mode); | 219 | g_hCameraDevice->CheckMovingPhotoSupported(mode); |
| 222 | 220 | ||
| @@ -246,7 +244,7 @@ void HCameraDeviceFuzzTest4(FuzzedDataProvider& fdp) | |||
| 246 | std::shared_ptr<OHOS::Camera::CameraMetadata> cameraResult; | 244 | std::shared_ptr<OHOS::Camera::CameraMetadata> cameraResult; |
| 247 | cameraResult = std::make_shared<OHOS::Camera::CameraMetadata>(NUM_10, NUM_100); | 245 | cameraResult = std::make_shared<OHOS::Camera::CameraMetadata>(NUM_10, NUM_100); |
| 248 | std::function<void(int64_t, int64_t)> callback = [](int64_t start, int64_t end) { | 246 | std::function<void(int64_t, int64_t)> callback = [](int64_t start, int64_t end) { |
| 249 | - MEDIA_INFO_LOG("Start: %ld, End: %ld\n", start, end); | 247 | + MEDIA_INFO_LOG("Start: %lld, End: %lld\n", start, end); |
| 250 | }; | 248 | }; |
| 251 | g_hCameraDevice->SetMovingPhotoStartTimeCallback(callback); | 249 | g_hCameraDevice->SetMovingPhotoStartTimeCallback(callback); |
| 252 | g_hCameraDevice->SetMovingPhotoEndTimeCallback(callback); | 250 | g_hCameraDevice->SetMovingPhotoEndTimeCallback(callback); |
| @@ -258,6 +256,43 @@ void HCameraDeviceFuzzTest4(FuzzedDataProvider& fdp) | |||
| 258 | g_hCameraDevice->NotifyCameraStatus(state); | 256 | g_hCameraDevice->NotifyCameraStatus(state); |
| 259 | } | 257 | } |
| 260 | 258 | ||
| 259 | +void HCameraDeviceFuzzTest5(FuzzedDataProvider& fdp) | ||
| 260 | +{ | ||
| 261 | + auto settings = std::make_shared<OHOS::Camera::CameraMetadata>(NUM_10, NUM_100); | ||
| 262 | + g_hCameraDevice->UpdateCameraSwitchCameraId(fdp.ConsumeRandomLengthString(MAX_LENGTH_STRING)); | ||
| 263 | + g_hCameraDevice->SetFrameRateRange(ConsumeRandomVector<int32_t>(fdp)); | ||
| 264 | + g_hCameraDevice->SetIsHasFitedRotation(fdp.ConsumeBool()); | ||
| 265 | + g_hCameraDevice->SetLastDisplayMode(fdp.ConsumeIntegral<int32_t>()); | ||
| 266 | + g_hCameraDevice->SetCameraIdTransform(fdp.ConsumeRandomLengthString(MAX_LENGTH_STRING)); | ||
| 267 | + g_hCameraDevice->SetFirstCallerTokenID(fdp.ConsumeIntegral<uint32_t>()); | ||
| 268 | + g_hCameraDevice->SetConcurrentCaptureTag(fdp.ConsumeBool()); | ||
| 269 | + g_hCameraDevice->EnableKeyFrameReport(fdp.ConsumeBool()); | ||
| 270 | + g_hCameraDevice->SetMechMetadataCallback([](std::shared_ptr<OHOS::Camera::CameraMetadata>) {}); | ||
| 271 | + g_hCameraDevice->CheckFocusChange(settings); | ||
| 272 | + g_hCameraDevice->CheckVideoStabilizationChange(settings); | ||
| 273 | + g_hCameraDevice->ReportMechMetadata(settings); | ||
| 274 | + g_hCameraDevice->ReportZoomInfos(settings); | ||
| 275 | + g_hCameraDevice->CanReportDeviceProtectionStatus(fdp.ConsumeIntegral<int32_t>()); | ||
| 276 | + g_hCameraDevice->GetKeyFrameInfoBuffer(fdp.ConsumeIntegral<int64_t>()); | ||
| 277 | + g_hCameraDevice->GetUseLogicCamera(fdp.ConsumeIntegral<int32_t>()); | ||
| 278 | + auto frameRateRange = ConsumeRandomVector<int32_t>(fdp); | ||
| 279 | + g_hCameraDevice->UpdateCameraRotateAngleAndZoom(frameRateRange, fdp.ConsumeBool()); | ||
| 280 | + g_hCameraDevice->UpdateRotateAngleJudge(fdp.ConsumeIntegral<int32_t>()); | ||
| 281 | + g_hCameraDevice->UpdateCameraRotateAngle(); | ||
| 282 | + g_hCameraDevice->DebugLogTag(settings, fdp.ConsumeIntegral<uint32_t>(), | ||
| 283 | + fdp.ConsumeRandomLengthString(MAX_LENGTH_STRING), fdp.ConsumeRandomLengthString(MAX_LENGTH_STRING)); | ||
| 284 | + g_hCameraDevice->DebugLogForTargetSmoothZoom(settings, fdp.ConsumeIntegral<uint32_t>()); | ||
| 285 | + g_hCameraDevice->GetZoomRatio(); | ||
| 286 | + g_hCameraDevice->GetFocusMode(); | ||
| 287 | + g_hCameraDevice->GetVideoStabilizationMode(); | ||
| 288 | + g_hCameraDevice->GetFrameRateRange(); | ||
| 289 | + g_hCameraDevice->GetIsHasFitedRotation(); | ||
| 290 | + g_hCameraDevice->GetCameraOrientation(); | ||
| 291 | + g_hCameraDevice->GetOriginalCameraOrientation(); | ||
| 292 | + g_hCameraDevice->GetScanScene(); | ||
| 293 | + g_hCameraDevice->GetCameraRotateStrategyInfos(); | ||
| 294 | +} | ||
| 295 | + | ||
| 261 | void Init() | 296 | void Init() |
| 262 | { | 297 | { |
| 263 | CHECK_RETURN_ELOG(!TestToken().GetAllCameraPermission(), "Get permission fail"); | 298 | CHECK_RETURN_ELOG(!TestToken().GetAllCameraPermission(), "Get permission fail"); |
| @@ -296,6 +331,7 @@ void Test(FuzzedDataProvider& fdp) | |||
| 296 | HCameraDeviceFuzzTest2, | 331 | HCameraDeviceFuzzTest2, |
| 297 | HCameraDeviceFuzzTest3, | 332 | HCameraDeviceFuzzTest3, |
| 298 | HCameraDeviceFuzzTest4, | 333 | HCameraDeviceFuzzTest4, |
| 334 | + HCameraDeviceFuzzTest5, | ||
| 299 | }); | 335 | }); |
| 300 | func(fdp); | 336 | func(fdp); |
| 301 | } | 337 | } |
| @@ -16,7 +16,7 @@ | |||
| 16 | <fuzz_config> | 16 | <fuzz_config> |
| 17 | <fuzztest> | 17 | <fuzztest> |
| 18 | <!-- maximum length of a test input --> | 18 | <!-- maximum length of a test input --> |
| 19 | - <max_len>1000</max_len> | 19 | + <max_len>2048</max_len> |
| 20 | <!-- maximum total time in seconds to run the fuzzer --> | 20 | <!-- maximum total time in seconds to run the fuzzer --> |
| 21 | <max_total_time>3</max_total_time> | 21 | <max_total_time>3</max_total_time> |
| 22 | <!-- memory usage limit in Mb --> | 22 | <!-- memory usage limit in Mb --> |
| @@ -59,6 +59,9 @@ ohos_fuzztest("HCameraHostManagerFuzzTest") { | |||
| 59 | "${multimedia_camera_framework_path}/dynamic_libs/moving_photo/include/avcodec", | 59 | "${multimedia_camera_framework_path}/dynamic_libs/moving_photo/include/avcodec", |
| 60 | "${multimedia_camera_framework_path}/dynamic_libs/moving_photo/include/common", | 60 | "${multimedia_camera_framework_path}/dynamic_libs/moving_photo/include/common", |
| 61 | "${multimedia_camera_framework_path}/services/camera_service/include/recorder", | 61 | "${multimedia_camera_framework_path}/services/camera_service/include/recorder", |
| 62 | + "${multimedia_camera_framework_path}/services/camera_service/include/kingkong", | ||
| 63 | + "${multimedia_camera_framework_path}/services/camera_service/include/resource_manager_utils/", | ||
| 64 | + "${multimedia_camera_framework_path}/services/camera_service/include/network_client", | ||
| 62 | ] | 65 | ] |
| 63 | 66 | ||
| 64 | cflags = [ | 67 | cflags = [ |
| @@ -29,6 +29,8 @@ class StatusCallbackDemo : public HCameraHostManager::StatusCallback { | |||
| 29 | CallbackInvoker invoker = CallbackInvoker::CAMERA_HOST) {} | 29 | CallbackInvoker invoker = CallbackInvoker::CAMERA_HOST) {} |
| 30 | virtual void OnFlashlightStatus(const std::string& cameraId, FlashStatus status) {} | 30 | virtual void OnFlashlightStatus(const std::string& cameraId, FlashStatus status) {} |
| 31 | virtual void OnTorchStatus(TorchStatus status) {} | 31 | virtual void OnTorchStatus(TorchStatus status) {} |
| 32 | + virtual void OnAbilityReady() {} | ||
| 33 | + virtual void clearPreScanConfig() {} | ||
| 32 | }; | 34 | }; |
| 33 | 35 | ||
| 34 | class HCameraHostManagerFuzzer { | 36 | class HCameraHostManagerFuzzer { |
| @@ -70,6 +70,8 @@ class StatusCallbackDemo : public HCameraHostManager::StatusCallback { | |||
| 70 | CallbackInvoker invoker = CallbackInvoker::CAMERA_HOST) {} | 70 | CallbackInvoker invoker = CallbackInvoker::CAMERA_HOST) {} |
| 71 | virtual void OnFlashlightStatus(const std::string& cameraId, FlashStatus status) {} | 71 | virtual void OnFlashlightStatus(const std::string& cameraId, FlashStatus status) {} |
| 72 | virtual void OnTorchStatus(TorchStatus status) {} | 72 | virtual void OnTorchStatus(TorchStatus status) {} |
| 73 | + virtual void OnAbilityReady() {} | ||
| 74 | + virtual void clearPreScanConfig() {} | ||
| 73 | }; | 75 | }; |
| 74 | 76 | ||
| 75 | void HCameraPreconfigFuzzer::HCameraPreconfigFuzzTest1() | 77 | void HCameraPreconfigFuzzer::HCameraPreconfigFuzzTest1() |
| @@ -77,6 +77,9 @@ ohos_fuzztest("HCameraServiceFuzzTest") { | |||
| 77 | "${multimedia_camera_framework_path}/mediastream/include/filter", | 77 | "${multimedia_camera_framework_path}/mediastream/include/filter", |
| 78 | "${multimedia_camera_framework_path}/mediastream/include/util", | 78 | "${multimedia_camera_framework_path}/mediastream/include/util", |
| 79 | "${multimedia_camera_framework_path}/mediastream/include/buffer", | 79 | "${multimedia_camera_framework_path}/mediastream/include/buffer", |
| 80 | + "${multimedia_camera_framework_path}/services/camera_service/include/kingkong", | ||
| 81 | + "${multimedia_camera_framework_path}/services/camera_service/include/resource_manager_utils/", | ||
| 82 | + "${multimedia_camera_framework_path}/services/camera_service/include/network_client", | ||
| 80 | ] | 83 | ] |
| 81 | 84 | ||
| 82 | cflags = [ | 85 | cflags = [ |
| @@ -160,7 +163,7 @@ ohos_fuzztest("HCameraServiceFuzzTest") { | |||
| 160 | "os_account:os_account_innerkits", | 163 | "os_account:os_account_innerkits", |
| 161 | "resource_schedule_service:ressched_client", | 164 | "resource_schedule_service:ressched_client", |
| 162 | "safwk:system_ability_fwk", | 165 | "safwk:system_ability_fwk", |
| 163 | - "samgr:samgr_proxy" | 166 | + "samgr:samgr_proxy", |
| 164 | ] | 167 | ] |
| 165 | } | 168 | } |
| 166 | 169 | ||
| @@ -64,7 +64,12 @@ using namespace OHOS::Camera; | |||
| 64 | using namespace OHOS::CameraStandard; | 64 | using namespace OHOS::CameraStandard; |
| 65 | using namespace OHOS::CameraStandard::DeferredProcessing; | 65 | using namespace OHOS::CameraStandard::DeferredProcessing; |
| 66 | sptr<HCameraHostManager> g_hCameraHostManager = nullptr; | 66 | sptr<HCameraHostManager> g_hCameraHostManager = nullptr; |
| 67 | -sptr<HCameraService> g_hCameraService = nullptr; | 67 | + |
| 68 | +HCameraService& GetService() | ||
| 69 | +{ | ||
| 70 | + static HCameraService hCameraService = HCameraService(g_hCameraHostManager); | ||
| 71 | + return hCameraService; | ||
| 72 | +} | ||
| 68 | 73 | ||
| 69 | sptr<IBufferProducer> GetMockBufferProducer() | 74 | sptr<IBufferProducer> GetMockBufferProducer() |
| 70 | { | 75 | { |
| @@ -89,39 +94,39 @@ void CreateCameraDevice(FuzzedDataProvider& provider) | |||
| 89 | { | 94 | { |
| 90 | std::string cameraId = provider.ConsumeRandomLengthString(); | 95 | std::string cameraId = provider.ConsumeRandomLengthString(); |
| 91 | sptr<ICameraDeviceService> device; | 96 | sptr<ICameraDeviceService> device; |
| 92 | - g_hCameraService->CreateCameraDevice(cameraId, device); | 97 | + GetService().CreateCameraDevice(cameraId, device); |
| 93 | } | 98 | } |
| 94 | 99 | ||
| 95 | void SetCameraCallback(FuzzedDataProvider& provider) | 100 | void SetCameraCallback(FuzzedDataProvider& provider) |
| 96 | { | 101 | { |
| 97 | auto cb = sptr<MockCameraServiceCallback>::MakeSptr(); | 102 | auto cb = sptr<MockCameraServiceCallback>::MakeSptr(); |
| 98 | - g_hCameraService->SetCameraCallback(cb, true); | 103 | + GetService().SetCameraCallback(cb, true); |
| 99 | } | 104 | } |
| 100 | 105 | ||
| 101 | void SetMuteCallback(FuzzedDataProvider& provider) | 106 | void SetMuteCallback(FuzzedDataProvider& provider) |
| 102 | { | 107 | { |
| 103 | auto cb = sptr<MockCameraMuteServiceCallback>::MakeSptr(); | 108 | auto cb = sptr<MockCameraMuteServiceCallback>::MakeSptr(); |
| 104 | - g_hCameraService->SetMuteCallback(cb); | 109 | + GetService().SetMuteCallback(cb); |
| 105 | } | 110 | } |
| 106 | 111 | ||
| 107 | void SetTorchCallback(FuzzedDataProvider& provider) | 112 | void SetTorchCallback(FuzzedDataProvider& provider) |
| 108 | { | 113 | { |
| 109 | auto cb = sptr<MockTorchServiceCallback>::MakeSptr(); | 114 | auto cb = sptr<MockTorchServiceCallback>::MakeSptr(); |
| 110 | - g_hCameraService->SetTorchCallback(cb); | 115 | + GetService().SetTorchCallback(cb); |
| 111 | } | 116 | } |
| 112 | 117 | ||
| 113 | void GetCameras(FuzzedDataProvider& provider) | 118 | void GetCameras(FuzzedDataProvider& provider) |
| 114 | { | 119 | { |
| 115 | std::vector<std::string> cameraIds; | 120 | std::vector<std::string> cameraIds; |
| 116 | std::vector<std::shared_ptr<CameraMetadata>> cameraAbilityList; | 121 | std::vector<std::shared_ptr<CameraMetadata>> cameraAbilityList; |
| 117 | - g_hCameraService->GetCameras(cameraIds, cameraAbilityList); | 122 | + GetService().GetCameras(cameraIds, cameraAbilityList); |
| 118 | } | 123 | } |
| 119 | 124 | ||
| 120 | void CreateCaptureSession(FuzzedDataProvider& provider) | 125 | void CreateCaptureSession(FuzzedDataProvider& provider) |
| 121 | { | 126 | { |
| 122 | sptr<ICaptureSession> session; | 127 | sptr<ICaptureSession> session; |
| 123 | int32_t operationMode = provider.ConsumeIntegral<int32_t>(); | 128 | int32_t operationMode = provider.ConsumeIntegral<int32_t>(); |
| 124 | - g_hCameraService->CreateCaptureSession(session, operationMode); | 129 | + GetService().CreateCaptureSession(session, operationMode); |
| 125 | } | 130 | } |
| 126 | 131 | ||
| 127 | void CreatePhotoOutput(FuzzedDataProvider& provider) | 132 | void CreatePhotoOutput(FuzzedDataProvider& provider) |
| @@ -131,7 +136,7 @@ void CreatePhotoOutput(FuzzedDataProvider& provider) | |||
| 131 | int32_t width = provider.ConsumeIntegral<int32_t>(); | 136 | int32_t width = provider.ConsumeIntegral<int32_t>(); |
| 132 | int32_t height = provider.ConsumeIntegral<int32_t>(); | 137 | int32_t height = provider.ConsumeIntegral<int32_t>(); |
| 133 | sptr<IStreamCapture> photoOutput; | 138 | sptr<IStreamCapture> photoOutput; |
| 134 | - g_hCameraService->CreatePhotoOutput(producer, format, width, height, photoOutput); | 139 | + GetService().CreatePhotoOutput(producer, format, width, height, photoOutput); |
| 135 | } | 140 | } |
| 136 | 141 | ||
| 137 | void CreateDeferredPreviewOutput(FuzzedDataProvider& provider) | 142 | void CreateDeferredPreviewOutput(FuzzedDataProvider& provider) |
| @@ -140,7 +145,7 @@ void CreateDeferredPreviewOutput(FuzzedDataProvider& provider) | |||
| 140 | int32_t width = provider.ConsumeIntegral<int32_t>(); | 145 | int32_t width = provider.ConsumeIntegral<int32_t>(); |
| 141 | int32_t height = provider.ConsumeIntegral<int32_t>(); | 146 | int32_t height = provider.ConsumeIntegral<int32_t>(); |
| 142 | sptr<IStreamRepeat> previewOutput; | 147 | sptr<IStreamRepeat> previewOutput; |
| 143 | - g_hCameraService->CreateDeferredPreviewOutput(format, width, height, previewOutput); | 148 | + GetService().CreateDeferredPreviewOutput(format, width, height, previewOutput); |
| 144 | } | 149 | } |
| 145 | 150 | ||
| 146 | void CreateVideoOutput(FuzzedDataProvider& provider) | 151 | void CreateVideoOutput(FuzzedDataProvider& provider) |
| @@ -150,13 +155,13 @@ void CreateVideoOutput(FuzzedDataProvider& provider) | |||
| 150 | int32_t width = provider.ConsumeIntegral<int32_t>(); | 155 | int32_t width = provider.ConsumeIntegral<int32_t>(); |
| 151 | int32_t height = provider.ConsumeIntegral<int32_t>(); | 156 | int32_t height = provider.ConsumeIntegral<int32_t>(); |
| 152 | sptr<IStreamRepeat> videoOutput; | 157 | sptr<IStreamRepeat> videoOutput; |
| 153 | - g_hCameraService->CreateVideoOutput(producer, format, width, height, videoOutput); | 158 | + GetService().CreateVideoOutput(producer, format, width, height, videoOutput); |
| 154 | } | 159 | } |
| 155 | 160 | ||
| 156 | void SetListenerObject(FuzzedDataProvider& provider) | 161 | void SetListenerObject(FuzzedDataProvider& provider) |
| 157 | { | 162 | { |
| 158 | auto remote = sptr<MockIRemoteObject>::MakeSptr(); | 163 | auto remote = sptr<MockIRemoteObject>::MakeSptr(); |
| 159 | - g_hCameraService->SetListenerObject(remote); | 164 | + GetService().SetListenerObject(remote); |
| 160 | } | 165 | } |
| 161 | 166 | ||
| 162 | void CreateMetadataOutput(FuzzedDataProvider& provider) | 167 | void CreateMetadataOutput(FuzzedDataProvider& provider) |
| @@ -165,42 +170,42 @@ void CreateMetadataOutput(FuzzedDataProvider& provider) | |||
| 165 | int32_t format = provider.ConsumeIntegral<int32_t>(); | 170 | int32_t format = provider.ConsumeIntegral<int32_t>(); |
| 166 | std::vector<int32_t> metadataTypes = ConsumeIntList(provider); | 171 | std::vector<int32_t> metadataTypes = ConsumeIntList(provider); |
| 167 | sptr<IStreamMetadata> metadataOutput; | 172 | sptr<IStreamMetadata> metadataOutput; |
| 168 | - g_hCameraService->CreateMetadataOutput(producer, format, metadataTypes, metadataOutput); | 173 | + GetService().CreateMetadataOutput(producer, format, metadataTypes, metadataOutput); |
| 169 | } | 174 | } |
| 170 | 175 | ||
| 171 | void MuteCamera(FuzzedDataProvider& provider) | 176 | void MuteCamera(FuzzedDataProvider& provider) |
| 172 | { | 177 | { |
| 173 | bool muteMode = provider.ConsumeBool(); | 178 | bool muteMode = provider.ConsumeBool(); |
| 174 | - g_hCameraService->MuteCamera(muteMode); | 179 | + GetService().MuteCamera(muteMode); |
| 175 | } | 180 | } |
| 176 | 181 | ||
| 177 | void IsCameraMuted(FuzzedDataProvider& provider) | 182 | void IsCameraMuted(FuzzedDataProvider& provider) |
| 178 | { | 183 | { |
| 179 | bool muteMode; | 184 | bool muteMode; |
| 180 | - g_hCameraService->IsCameraMuted(muteMode); | 185 | + GetService().IsCameraMuted(muteMode); |
| 181 | } | 186 | } |
| 182 | 187 | ||
| 183 | void IsTorchSupported(FuzzedDataProvider& provider) | 188 | void IsTorchSupported(FuzzedDataProvider& provider) |
| 184 | { | 189 | { |
| 185 | bool isTorchSupported; | 190 | bool isTorchSupported; |
| 186 | - g_hCameraService->IsTorchSupported(isTorchSupported); | 191 | + GetService().IsTorchSupported(isTorchSupported); |
| 187 | } | 192 | } |
| 188 | 193 | ||
| 189 | void IsCameraMuteSupported(FuzzedDataProvider& provider) | 194 | void IsCameraMuteSupported(FuzzedDataProvider& provider) |
| 190 | { | 195 | { |
| 191 | bool isCameraMuteSupported; | 196 | bool isCameraMuteSupported; |
| 192 | - g_hCameraService->IsCameraMuteSupported(isCameraMuteSupported); | 197 | + GetService().IsCameraMuteSupported(isCameraMuteSupported); |
| 193 | } | 198 | } |
| 194 | 199 | ||
| 195 | void PrelaunchCamera(FuzzedDataProvider& provider) | 200 | void PrelaunchCamera(FuzzedDataProvider& provider) |
| 196 | { | 201 | { |
| 197 | int32_t flag = provider.ConsumeIntegral<int32_t>(); | 202 | int32_t flag = provider.ConsumeIntegral<int32_t>(); |
| 198 | - g_hCameraService->PrelaunchCamera(flag); | 203 | + GetService().PrelaunchCamera(flag); |
| 199 | } | 204 | } |
| 200 | 205 | ||
| 201 | void ResetRssPriority(FuzzedDataProvider& provider) | 206 | void ResetRssPriority(FuzzedDataProvider& provider) |
| 202 | { | 207 | { |
| 203 | - g_hCameraService->ResetRssPriority(); | 208 | + GetService().ResetRssPriority(); |
| 204 | } | 209 | } |
| 205 | 210 | ||
| 206 | void SetPrelaunchConfig(FuzzedDataProvider& provider) | 211 | void SetPrelaunchConfig(FuzzedDataProvider& provider) |
| @@ -219,20 +224,20 @@ void SetPrelaunchConfig(FuzzedDataProvider& provider) | |||
| 219 | effectParam.faceMakeUp = provider.ConsumeIntegral<int32_t>(); | 224 | effectParam.faceMakeUp = provider.ConsumeIntegral<int32_t>(); |
| 220 | effectParam.headShrink = provider.ConsumeIntegral<int32_t>(); | 225 | effectParam.headShrink = provider.ConsumeIntegral<int32_t>(); |
| 221 | effectParam.noseSlender = provider.ConsumeIntegral<int32_t>(); | 226 | effectParam.noseSlender = provider.ConsumeIntegral<int32_t>(); |
| 222 | - g_hCameraService->SetPrelaunchConfig( | 227 | + GetService().SetPrelaunchConfig( |
| 223 | cameraId, static_cast<RestoreParamTypeOhos>(restoreParamType), activeTime, effectParam); | 228 | cameraId, static_cast<RestoreParamTypeOhos>(restoreParamType), activeTime, effectParam); |
| 224 | } | 229 | } |
| 225 | 230 | ||
| 226 | void SetTorchLevel(FuzzedDataProvider& provider) | 231 | void SetTorchLevel(FuzzedDataProvider& provider) |
| 227 | { | 232 | { |
| 228 | float level = provider.ConsumeFloatingPoint<float>(); | 233 | float level = provider.ConsumeFloatingPoint<float>(); |
| 229 | - g_hCameraService->SetTorchLevel(level); | 234 | + GetService().SetTorchLevel(level); |
| 230 | } | 235 | } |
| 231 | 236 | ||
| 232 | void PreSwitchCamera(FuzzedDataProvider& provider) | 237 | void PreSwitchCamera(FuzzedDataProvider& provider) |
| 233 | { | 238 | { |
| 234 | std::string cameraId = provider.ConsumeRandomLengthString(); | 239 | std::string cameraId = provider.ConsumeRandomLengthString(); |
| 235 | - g_hCameraService->PreSwitchCamera(cameraId); | 240 | + GetService().PreSwitchCamera(cameraId); |
| 236 | } | 241 | } |
| 237 | 242 | ||
| 238 | void CreateDeferredPhotoProcessingSession(FuzzedDataProvider& provider) | 243 | void CreateDeferredPhotoProcessingSession(FuzzedDataProvider& provider) |
| @@ -240,32 +245,32 @@ void CreateDeferredPhotoProcessingSession(FuzzedDataProvider& provider) | |||
| 240 | int32_t userId = provider.ConsumeIntegral<int32_t>(); | 245 | int32_t userId = provider.ConsumeIntegral<int32_t>(); |
| 241 | auto cb = sptr<MockDeferredPhotoProcessingSessionCallback>::MakeSptr(); | 246 | auto cb = sptr<MockDeferredPhotoProcessingSessionCallback>::MakeSptr(); |
| 242 | sptr<IDeferredPhotoProcessingSession> session; | 247 | sptr<IDeferredPhotoProcessingSession> session; |
| 243 | - g_hCameraService->CreateDeferredPhotoProcessingSession(userId, cb, session); | 248 | + GetService().CreateDeferredPhotoProcessingSession(userId, cb, session); |
| 244 | } | 249 | } |
| 245 | 250 | ||
| 246 | void GetCameraIds(FuzzedDataProvider& provider) | 251 | void GetCameraIds(FuzzedDataProvider& provider) |
| 247 | { | 252 | { |
| 248 | std::vector<std::string> cameraIds; | 253 | std::vector<std::string> cameraIds; |
| 249 | - g_hCameraService->GetCameraIds(cameraIds); | 254 | + GetService().GetCameraIds(cameraIds); |
| 250 | } | 255 | } |
| 251 | 256 | ||
| 252 | void GetCameraAbility(FuzzedDataProvider& provider) | 257 | void GetCameraAbility(FuzzedDataProvider& provider) |
| 253 | { | 258 | { |
| 254 | std::string cameraId = provider.ConsumeRandomLengthString(); | 259 | std::string cameraId = provider.ConsumeRandomLengthString(); |
| 255 | std::shared_ptr<CameraMetadata> cameraAbility; | 260 | std::shared_ptr<CameraMetadata> cameraAbility; |
| 256 | - g_hCameraService->GetCameraAbility(cameraId, cameraAbility); | 261 | + GetService().GetCameraAbility(cameraId, cameraAbility); |
| 257 | } | 262 | } |
| 258 | 263 | ||
| 259 | void DestroyStubObj(FuzzedDataProvider& provider) | 264 | void DestroyStubObj(FuzzedDataProvider& provider) |
| 260 | { | 265 | { |
| 261 | - g_hCameraService->DestroyStubObj(); | 266 | + GetService().DestroyStubObj(); |
| 262 | } | 267 | } |
| 263 | 268 | ||
| 264 | void MuteCameraPersist(FuzzedDataProvider& provider) | 269 | void MuteCameraPersist(FuzzedDataProvider& provider) |
| 265 | { | 270 | { |
| 266 | int32_t policyType = provider.ConsumeIntegral<int32_t>(); | 271 | int32_t policyType = provider.ConsumeIntegral<int32_t>(); |
| 267 | bool isMute = provider.ConsumeBool(); | 272 | bool isMute = provider.ConsumeBool(); |
| 268 | - g_hCameraService->MuteCameraPersist(static_cast<OHOS::CameraStandard::PolicyType>(policyType), isMute); | 273 | + GetService().MuteCameraPersist(static_cast<OHOS::CameraStandard::PolicyType>(policyType), isMute); |
| 269 | } | 274 | } |
| 270 | 275 | ||
| 271 | void ProxyForFreeze(FuzzedDataProvider& provider) | 276 | void ProxyForFreeze(FuzzedDataProvider& provider) |
| @@ -276,32 +281,32 @@ void ProxyForFreeze(FuzzedDataProvider& provider) | |||
| 276 | pidList.insert(provider.ConsumeIntegral<int32_t>()); | 281 | pidList.insert(provider.ConsumeIntegral<int32_t>()); |
| 277 | } | 282 | } |
| 278 | bool isProxy = provider.ConsumeBool(); | 283 | bool isProxy = provider.ConsumeBool(); |
| 279 | - g_hCameraService->ProxyForFreeze(pidList, isProxy); | 284 | + GetService().ProxyForFreeze(pidList, isProxy); |
| 280 | } | 285 | } |
| 281 | 286 | ||
| 282 | void ResetAllFreezeStatus(FuzzedDataProvider& provider) | 287 | void ResetAllFreezeStatus(FuzzedDataProvider& provider) |
| 283 | { | 288 | { |
| 284 | - g_hCameraService->ResetAllFreezeStatus(); | 289 | + GetService().ResetAllFreezeStatus(); |
| 285 | } | 290 | } |
| 286 | 291 | ||
| 287 | void GetDmDeviceInfo(FuzzedDataProvider& provider) | 292 | void GetDmDeviceInfo(FuzzedDataProvider& provider) |
| 288 | { | 293 | { |
| 289 | std::vector<dmDeviceInfo> deviceInfos; | 294 | std::vector<dmDeviceInfo> deviceInfos; |
| 290 | - g_hCameraService->GetDmDeviceInfo(deviceInfos); | 295 | + GetService().GetDmDeviceInfo(deviceInfos); |
| 291 | } | 296 | } |
| 292 | 297 | ||
| 293 | void SetFoldStatusCallback(FuzzedDataProvider& provider) | 298 | void SetFoldStatusCallback(FuzzedDataProvider& provider) |
| 294 | { | 299 | { |
| 295 | auto cb = sptr<MockFoldServiceCallback>::MakeSptr(); | 300 | auto cb = sptr<MockFoldServiceCallback>::MakeSptr(); |
| 296 | bool isInnerCallback = provider.ConsumeBool(); | 301 | bool isInnerCallback = provider.ConsumeBool(); |
| 297 | - g_hCameraService->SetFoldStatusCallback(cb, isInnerCallback); | 302 | + GetService().SetFoldStatusCallback(cb, isInnerCallback); |
| 298 | } | 303 | } |
| 299 | 304 | ||
| 300 | void GetCameraOutputStatus(FuzzedDataProvider& provider) | 305 | void GetCameraOutputStatus(FuzzedDataProvider& provider) |
| 301 | { | 306 | { |
| 302 | int32_t pid = provider.ConsumeIntegral<int32_t>(); | 307 | int32_t pid = provider.ConsumeIntegral<int32_t>(); |
| 303 | int32_t status; | 308 | int32_t status; |
| 304 | - g_hCameraService->GetCameraOutputStatus(pid, status); | 309 | + GetService().GetCameraOutputStatus(pid, status); |
| 305 | } | 310 | } |
| 306 | 311 | ||
| 307 | void CreateDepthDataOutput(FuzzedDataProvider& provider) | 312 | void CreateDepthDataOutput(FuzzedDataProvider& provider) |
| @@ -311,7 +316,7 @@ void CreateDepthDataOutput(FuzzedDataProvider& provider) | |||
| 311 | int32_t width = provider.ConsumeIntegral<int32_t>(); | 316 | int32_t width = provider.ConsumeIntegral<int32_t>(); |
| 312 | int32_t height = provider.ConsumeIntegral<int32_t>(); | 317 | int32_t height = provider.ConsumeIntegral<int32_t>(); |
| 313 | sptr<IStreamDepthData> depthDataOutput; | 318 | sptr<IStreamDepthData> depthDataOutput; |
| 314 | - g_hCameraService->CreateDepthDataOutput(producer, format, width, height, depthDataOutput); | 319 | + GetService().CreateDepthDataOutput(producer, format, width, height, depthDataOutput); |
| 315 | } | 320 | } |
| 316 | 321 | ||
| 317 | void CreateDeferredVideoProcessingSession(FuzzedDataProvider& provider) | 322 | void CreateDeferredVideoProcessingSession(FuzzedDataProvider& provider) |
| @@ -319,78 +324,78 @@ void CreateDeferredVideoProcessingSession(FuzzedDataProvider& provider) | |||
| 319 | int32_t userId = provider.ConsumeIntegral<int32_t>(); | 324 | int32_t userId = provider.ConsumeIntegral<int32_t>(); |
| 320 | auto cb = sptr<MockDeferredVideoProcessingSessionCallback>::MakeSptr(); | 325 | auto cb = sptr<MockDeferredVideoProcessingSessionCallback>::MakeSptr(); |
| 321 | sptr<IDeferredVideoProcessingSession> session; | 326 | sptr<IDeferredVideoProcessingSession> session; |
| 322 | - g_hCameraService->CreateDeferredVideoProcessingSession(userId, cb, session); | 327 | + GetService().CreateDeferredVideoProcessingSession(userId, cb, session); |
| 323 | } | 328 | } |
| 324 | 329 | ||
| 325 | void RequireMemorySize(FuzzedDataProvider& provider) | 330 | void RequireMemorySize(FuzzedDataProvider& provider) |
| 326 | { | 331 | { |
| 327 | int32_t memSize = provider.ConsumeIntegral<int32_t>(); | 332 | int32_t memSize = provider.ConsumeIntegral<int32_t>(); |
| 328 | - g_hCameraService->RequireMemorySize(memSize); | 333 | + GetService().RequireMemorySize(memSize); |
| 329 | } | 334 | } |
| 330 | 335 | ||
| 331 | void GetIdforCameraConcurrentType(FuzzedDataProvider& provider) | 336 | void GetIdforCameraConcurrentType(FuzzedDataProvider& provider) |
| 332 | { | 337 | { |
| 333 | int32_t cameraPosition = provider.ConsumeIntegral<int32_t>(); | 338 | int32_t cameraPosition = provider.ConsumeIntegral<int32_t>(); |
| 334 | std::string cameraId; | 339 | std::string cameraId; |
| 335 | - g_hCameraService->GetIdforCameraConcurrentType(cameraPosition, cameraId); | 340 | + GetService().GetIdforCameraConcurrentType(cameraPosition, cameraId); |
| 336 | } | 341 | } |
| 337 | 342 | ||
| 338 | void GetConcurrentCameraAbility(FuzzedDataProvider& provider) | 343 | void GetConcurrentCameraAbility(FuzzedDataProvider& provider) |
| 339 | { | 344 | { |
| 340 | std::string cameraId = provider.ConsumeRandomLengthString(); | 345 | std::string cameraId = provider.ConsumeRandomLengthString(); |
| 341 | std::shared_ptr<CameraMetadata> cameraAbility; | 346 | std::shared_ptr<CameraMetadata> cameraAbility; |
| 342 | - g_hCameraService->GetConcurrentCameraAbility(cameraId, cameraAbility); | 347 | + GetService().GetConcurrentCameraAbility(cameraId, cameraAbility); |
| 343 | } | 348 | } |
| 344 | 349 | ||
| 345 | void GetTorchStatus(FuzzedDataProvider& provider) | 350 | void GetTorchStatus(FuzzedDataProvider& provider) |
| 346 | { | 351 | { |
| 347 | int32_t status; | 352 | int32_t status; |
| 348 | - g_hCameraService->GetTorchStatus(status); | 353 | + GetService().GetTorchStatus(status); |
| 349 | } | 354 | } |
| 350 | 355 | ||
| 351 | void UnSetCameraCallback(FuzzedDataProvider& provider) | 356 | void UnSetCameraCallback(FuzzedDataProvider& provider) |
| 352 | { | 357 | { |
| 353 | - g_hCameraService->UnSetCameraCallback(); | 358 | + GetService().UnSetCameraCallback(); |
| 354 | } | 359 | } |
| 355 | 360 | ||
| 356 | void UnSetMuteCallback(FuzzedDataProvider& provider) | 361 | void UnSetMuteCallback(FuzzedDataProvider& provider) |
| 357 | { | 362 | { |
| 358 | - g_hCameraService->UnSetMuteCallback(); | 363 | + GetService().UnSetMuteCallback(); |
| 359 | } | 364 | } |
| 360 | 365 | ||
| 361 | void UnSetTorchCallback(FuzzedDataProvider& provider) | 366 | void UnSetTorchCallback(FuzzedDataProvider& provider) |
| 362 | { | 367 | { |
| 363 | - g_hCameraService->UnSetTorchCallback(); | 368 | + GetService().UnSetTorchCallback(); |
| 364 | } | 369 | } |
| 365 | 370 | ||
| 366 | void UnSetFoldStatusCallback(FuzzedDataProvider& provider) | 371 | void UnSetFoldStatusCallback(FuzzedDataProvider& provider) |
| 367 | { | 372 | { |
| 368 | - g_hCameraService->UnSetFoldStatusCallback(); | 373 | + GetService().UnSetFoldStatusCallback(); |
| 369 | } | 374 | } |
| 370 | 375 | ||
| 371 | void CheckWhiteList(FuzzedDataProvider& provider) | 376 | void CheckWhiteList(FuzzedDataProvider& provider) |
| 372 | { | 377 | { |
| 373 | bool isInWhiteList = provider.ConsumeBool(); | 378 | bool isInWhiteList = provider.ConsumeBool(); |
| 374 | - g_hCameraService->CheckWhiteList(isInWhiteList); | 379 | + GetService().CheckWhiteList(isInWhiteList); |
| 375 | } | 380 | } |
| 376 | 381 | ||
| 377 | void CreateMechSession(FuzzedDataProvider& provider) | 382 | void CreateMechSession(FuzzedDataProvider& provider) |
| 378 | { | 383 | { |
| 379 | int32_t userId = provider.ConsumeIntegral<int32_t>(); | 384 | int32_t userId = provider.ConsumeIntegral<int32_t>(); |
| 380 | sptr<IMechSession> session; | 385 | sptr<IMechSession> session; |
| 381 | - g_hCameraService->CreateMechSession(userId, session); | 386 | + GetService().CreateMechSession(userId, session); |
| 382 | } | 387 | } |
| 383 | 388 | ||
| 384 | void IsMechSupported(FuzzedDataProvider& provider) | 389 | void IsMechSupported(FuzzedDataProvider& provider) |
| 385 | { | 390 | { |
| 386 | bool isMechSupported; | 391 | bool isMechSupported; |
| 387 | - g_hCameraService->IsMechSupported(isMechSupported); | 392 | + GetService().IsMechSupported(isMechSupported); |
| 388 | } | 393 | } |
| 389 | 394 | ||
| 390 | void GetCameraStorageSize(FuzzedDataProvider& provider) | 395 | void GetCameraStorageSize(FuzzedDataProvider& provider) |
| 391 | { | 396 | { |
| 392 | - long size; | 397 | + int64_t size; |
| 393 | - g_hCameraService->GetCameraStorageSize(size); | 398 | + GetService().GetCameraStorageSize(size); |
| 394 | } | 399 | } |
| 395 | 400 | ||
| 396 | void CreatePhotoOutputOverride(FuzzedDataProvider& provider) | 401 | void CreatePhotoOutputOverride(FuzzedDataProvider& provider) |
| @@ -399,55 +404,49 @@ void CreatePhotoOutputOverride(FuzzedDataProvider& provider) | |||
| 399 | int32_t width = provider.ConsumeIntegral<int32_t>(); | 404 | int32_t width = provider.ConsumeIntegral<int32_t>(); |
| 400 | int32_t height = provider.ConsumeIntegral<int32_t>(); | 405 | int32_t height = provider.ConsumeIntegral<int32_t>(); |
| 401 | sptr<IStreamCapture> photoOutput; | 406 | sptr<IStreamCapture> photoOutput; |
| 402 | - g_hCameraService->CreatePhotoOutput(format, width, height, photoOutput); | 407 | + GetService().CreatePhotoOutput(format, width, height, photoOutput); |
| 403 | } | 408 | } |
| 404 | 409 | ||
| 405 | void GetVideoSessionForControlCenter(FuzzedDataProvider& provider) | 410 | void GetVideoSessionForControlCenter(FuzzedDataProvider& provider) |
| 406 | { | 411 | { |
| 407 | sptr<ICaptureSession> session; | 412 | sptr<ICaptureSession> session; |
| 408 | - g_hCameraService->GetVideoSessionForControlCenter(session); | 413 | + GetService().GetVideoSessionForControlCenter(session); |
| 409 | } | 414 | } |
| 410 | 415 | ||
| 411 | void SetControlCenterCallback(FuzzedDataProvider& provider) | 416 | void SetControlCenterCallback(FuzzedDataProvider& provider) |
| 412 | { | 417 | { |
| 413 | auto cb = sptr<MockControlCenterStatusCallbackStub>::MakeSptr(); | 418 | auto cb = sptr<MockControlCenterStatusCallbackStub>::MakeSptr(); |
| 414 | 419 | ||
| 415 | - g_hCameraService->SetControlCenterCallback(cb); | 420 | + GetService().SetControlCenterCallback(cb); |
| 416 | } | 421 | } |
| 417 | 422 | ||
| 418 | void UnSetControlCenterStatusCallback(FuzzedDataProvider& provider) | 423 | void UnSetControlCenterStatusCallback(FuzzedDataProvider& provider) |
| 419 | { | 424 | { |
| 420 | - g_hCameraService->UnSetControlCenterStatusCallback(); | 425 | + GetService().UnSetControlCenterStatusCallback(); |
| 421 | } | 426 | } |
| 422 | 427 | ||
| 423 | void EnableControlCenter(FuzzedDataProvider& provider) | 428 | void EnableControlCenter(FuzzedDataProvider& provider) |
| 424 | { | 429 | { |
| 425 | bool status = provider.ConsumeBool(); | 430 | bool status = provider.ConsumeBool(); |
| 426 | bool needPersistEnable = provider.ConsumeBool(); | 431 | bool needPersistEnable = provider.ConsumeBool(); |
| 427 | - g_hCameraService->EnableControlCenter(status, needPersistEnable); | 432 | + GetService().EnableControlCenter(status, needPersistEnable); |
| 428 | } | 433 | } |
| 429 | 434 | ||
| 430 | void SetControlCenterPrecondition(FuzzedDataProvider& provider) | 435 | void SetControlCenterPrecondition(FuzzedDataProvider& provider) |
| 431 | { | 436 | { |
| 432 | bool condition = provider.ConsumeBool(); | 437 | bool condition = provider.ConsumeBool(); |
| 433 | - g_hCameraService->SetControlCenterPrecondition(condition); | 438 | + GetService().SetControlCenterPrecondition(condition); |
| 434 | -} | ||
| 435 | - | ||
| 436 | -void SetDeviceControlCenterAbility(FuzzedDataProvider& provider) | ||
| 437 | -{ | ||
| 438 | - bool ability = provider.ConsumeBool(); | ||
| 439 | - g_hCameraService->SetDeviceControlCenterAbility(ability); | ||
| 440 | } | 439 | } |
| 441 | 440 | ||
| 442 | void GetControlCenterStatus(FuzzedDataProvider& provider) | 441 | void GetControlCenterStatus(FuzzedDataProvider& provider) |
| 443 | { | 442 | { |
| 444 | bool status; | 443 | bool status; |
| 445 | - g_hCameraService->GetControlCenterStatus(status); | 444 | + GetService().GetControlCenterStatus(status); |
| 446 | } | 445 | } |
| 447 | 446 | ||
| 448 | void CheckControlCenterPermission(FuzzedDataProvider& provider) | 447 | void CheckControlCenterPermission(FuzzedDataProvider& provider) |
| 449 | { | 448 | { |
| 450 | - g_hCameraService->CheckControlCenterPermission(); | 449 | + GetService().CheckControlCenterPermission(); |
| 451 | } | 450 | } |
| 452 | 451 | ||
| 453 | void AllowOpenByOHSide(FuzzedDataProvider& provider) | 452 | void AllowOpenByOHSide(FuzzedDataProvider& provider) |
| @@ -455,35 +454,25 @@ void AllowOpenByOHSide(FuzzedDataProvider& provider) | |||
| 455 | std::string cameraId = provider.ConsumeRandomLengthString(); | 454 | std::string cameraId = provider.ConsumeRandomLengthString(); |
| 456 | int32_t state = provider.ConsumeIntegral<int32_t>(); | 455 | int32_t state = provider.ConsumeIntegral<int32_t>(); |
| 457 | bool canOpenCamera = provider.ConsumeBool(); | 456 | bool canOpenCamera = provider.ConsumeBool(); |
| 458 | - g_hCameraService->AllowOpenByOHSide(cameraId, state, canOpenCamera); | 457 | + GetService().AllowOpenByOHSide(cameraId, state, canOpenCamera); |
| 459 | } | 458 | } |
| 460 | 459 | ||
| 461 | void NotifyCameraState(FuzzedDataProvider& provider) | 460 | void NotifyCameraState(FuzzedDataProvider& provider) |
| 462 | { | 461 | { |
| 463 | std::string cameraId = provider.ConsumeRandomLengthString(); | 462 | std::string cameraId = provider.ConsumeRandomLengthString(); |
| 464 | int32_t state = provider.ConsumeIntegral<int32_t>(); | 463 | int32_t state = provider.ConsumeIntegral<int32_t>(); |
| 465 | - g_hCameraService->NotifyCameraState(cameraId, state); | 464 | + GetService().NotifyCameraState(cameraId, state); |
| 466 | } | 465 | } |
| 467 | 466 | ||
| 468 | void SetPeerCallback(FuzzedDataProvider& provider) | 467 | void SetPeerCallback(FuzzedDataProvider& provider) |
| 469 | { | 468 | { |
| 470 | auto cb = sptr<MockCameraBroker>::MakeSptr(); | 469 | auto cb = sptr<MockCameraBroker>::MakeSptr(); |
| 471 | - g_hCameraService->SetPeerCallback(cb); | 470 | + GetService().SetPeerCallback(cb); |
| 472 | } | 471 | } |
| 473 | 472 | ||
| 474 | void UnsetPeerCallback(FuzzedDataProvider& provider) | 473 | void UnsetPeerCallback(FuzzedDataProvider& provider) |
| 475 | { | 474 | { |
| 476 | - g_hCameraService->UnsetPeerCallback(); | 475 | + GetService().UnsetPeerCallback(); |
| 477 | -} | ||
| 478 | - | ||
| 479 | -void PrelaunchScanCamera(FuzzedDataProvider& provider) | ||
| 480 | -{ | ||
| 481 | - int32_t maxLength = 30; | ||
| 482 | - std::string bundleName = provider.ConsumeRandomLengthString().substr(0, maxLength); | ||
| 483 | - std::string pageName = provider.ConsumeRandomLengthString().substr(0, maxLength); | ||
| 484 | - int32_t preScanMode = provider.ConsumeIntegralInRange<int32_t>(0, 2); | ||
| 485 | - GetInstance().PrelaunchScanCamera(bundleName, pageName, | ||
| 486 | - static_cast<PrelaunchScanModeOhos>(preScanMode)); | ||
| 487 | } | 476 | } |
| 488 | 477 | ||
| 489 | void Init() | 478 | void Init() |
| @@ -493,7 +482,7 @@ void Init() | |||
| 493 | if (g_hCameraHostManager) { | 482 | if (g_hCameraHostManager) { |
| 494 | sptr<HCameraService> g_hCameraService = new (std::nothrow) HCameraService(g_hCameraHostManager); | 483 | sptr<HCameraService> g_hCameraService = new (std::nothrow) HCameraService(g_hCameraHostManager); |
| 495 | if (g_hCameraService) { | 484 | if (g_hCameraService) { |
| 496 | - g_hCameraService->serviceStatus_ = CameraServiceStatus::SERVICE_NOT_READY; | 485 | + GetService().serviceStatus_ = CameraServiceStatus::SERVICE_NOT_READY; |
| 497 | } | 486 | } |
| 498 | } | 487 | } |
| 499 | } | 488 | } |
| @@ -501,11 +490,8 @@ void Init() | |||
| 501 | void Test(FuzzedDataProvider& fdp) | 490 | void Test(FuzzedDataProvider& fdp) |
| 502 | { | 491 | { |
| 503 | CHECK_RETURN_ELOG(!g_hCameraHostManager, "g_hCameraHostManager is nullptr"); | 492 | CHECK_RETURN_ELOG(!g_hCameraHostManager, "g_hCameraHostManager is nullptr"); |
| 504 | - CHECK_RETURN_ELOG(!g_hCameraService, "g_hCameraService is nullptr"); | ||
| 505 | auto func = fdp.PickValueInArray({ | 493 | auto func = fdp.PickValueInArray({ |
| 506 | - CreateCaptureSession, | ||
| 507 | CreatePhotoOutput, | 494 | CreatePhotoOutput, |
| 508 | - CreateDeferredPreviewOutput, | ||
| 509 | CreateVideoOutput, | 495 | CreateVideoOutput, |
| 510 | SetListenerObject, | 496 | SetListenerObject, |
| 511 | CreateMetadataOutput, | 497 | CreateMetadataOutput, |
| @@ -548,14 +534,12 @@ void Test(FuzzedDataProvider& fdp) | |||
| 548 | UnSetControlCenterStatusCallback, | 534 | UnSetControlCenterStatusCallback, |
| 549 | EnableControlCenter, | 535 | EnableControlCenter, |
| 550 | SetControlCenterPrecondition, | 536 | SetControlCenterPrecondition, |
| 551 | - SetDeviceControlCenterAbility, | ||
| 552 | GetControlCenterStatus, | 537 | GetControlCenterStatus, |
| 553 | CheckControlCenterPermission, | 538 | CheckControlCenterPermission, |
| 554 | AllowOpenByOHSide, | 539 | AllowOpenByOHSide, |
| 555 | NotifyCameraState, | 540 | NotifyCameraState, |
| 556 | SetPeerCallback, | 541 | SetPeerCallback, |
| 557 | UnsetPeerCallback, | 542 | UnsetPeerCallback, |
| 558 | - PrelaunchScanCamera, | ||
| 559 | }); | 543 | }); |
| 560 | func(fdp); | 544 | func(fdp); |
| 561 | } | 545 | } |
| @@ -61,6 +61,9 @@ ohos_fuzztest("HCaptureSessionFuzzTest") { | |||
| 61 | "${multimedia_camera_framework_path}/services/camera_service/include/smooth_zoom", | 61 | "${multimedia_camera_framework_path}/services/camera_service/include/smooth_zoom", |
| 62 | "${multimedia_camera_framework_path}/services/camera_service/include/recorder", | 62 | "${multimedia_camera_framework_path}/services/camera_service/include/recorder", |
| 63 | "${multimedia_camera_framework_path}/interfaces/kits/js/camera_napi/include", | 63 | "${multimedia_camera_framework_path}/interfaces/kits/js/camera_napi/include", |
| 64 | + "${multimedia_camera_framework_path}/services/camera_service/include/kingkong", | ||
| 65 | + "${multimedia_camera_framework_path}/services/camera_service/include/resource_manager_utils/", | ||
| 66 | + "${multimedia_camera_framework_path}/services/camera_service/include/network_client" | ||
| 64 | ] | 67 | ] |
| 65 | 68 | ||
| 66 | cflags = [ | 69 | cflags = [ |
| @@ -45,8 +45,21 @@ static const int NUM_10 = 10; | |||
| 45 | static const int NUM_100 = 100; | 45 | static const int NUM_100 = 100; |
| 46 | static const int32_t OP_MODE = 0; | 46 | static const int32_t OP_MODE = 0; |
| 47 | 47 | ||
| 48 | -sptr<HCameraService> g_cameraService; | 48 | +std::vector<sptr<HCaptureSession>>& GetSessions() |
| 49 | -std::vector<sptr<HCaptureSession>> g_sessions; | 49 | +{ |
| 50 | + static std::vector<sptr<HCaptureSession>> sessions; | ||
| 51 | + return sessions; | ||
| 52 | +} | ||
| 53 | + | ||
| 54 | +sptr<ICameraService> GetService() | ||
| 55 | +{ | ||
| 56 | + auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); | ||
| 57 | + CHECK_RETURN_RET_ELOG(!samgr, nullptr, "samgr is nullptr"); | ||
| 58 | + auto object = samgr->GetSystemAbility(CAMERA_SERVICE_ID); | ||
| 59 | + CHECK_RETURN_RET_ELOG(!object, nullptr, "object is nullptr"); | ||
| 60 | + sptr<ICameraService> serviceProxy = iface_cast<ICameraService>(object); | ||
| 61 | + return serviceProxy; | ||
| 62 | +} | ||
| 50 | void HCaptureSessionFuzzTest1(FuzzedDataProvider& fdp, sptr<HCaptureSession>& session) | 63 | void HCaptureSessionFuzzTest1(FuzzedDataProvider& fdp, sptr<HCaptureSession>& session) |
| 51 | { | 64 | { |
| 52 | uint32_t callerToken = IPCSkeleton::GetCallingTokenID(); | 65 | uint32_t callerToken = IPCSkeleton::GetCallingTokenID(); |
| @@ -67,8 +80,8 @@ void HCaptureSessionFuzzTest1(FuzzedDataProvider& fdp, sptr<HCaptureSession>& se | |||
| 67 | session->EnableMovingPhotoMirror(fdp.ConsumeBool(), fdp.ConsumeBool()); | 80 | session->EnableMovingPhotoMirror(fdp.ConsumeBool(), fdp.ConsumeBool()); |
| 68 | int32_t getColorSpace; | 81 | int32_t getColorSpace; |
| 69 | session->GetActiveColorSpace(getColorSpace); | 82 | session->GetActiveColorSpace(getColorSpace); |
| 70 | - constexpr int32_t executionModeCount = static_cast<int32_t>(ColorSpace::P3_PQ_LIMIT) + NUM_1; | 83 | + constexpr int32_t executionModeCount = static_cast<int32_t>(OHOS::CameraStandard::ColorSpace::P3_PQ_LIMIT) + NUM_1; |
| 71 | - ColorSpace colorSpace = static_cast<ColorSpace>(fdp.ConsumeIntegral<uint8_t>() % executionModeCount); | 84 | + OHOS::CameraStandard::ColorSpace colorSpace = static_cast<OHOS::CameraStandard::ColorSpace>(fdp.ConsumeIntegral<uint8_t>() % executionModeCount); |
| 72 | session->SetColorSpace(static_cast<int32_t>(colorSpace), fdp.ConsumeBool()); | 85 | session->SetColorSpace(static_cast<int32_t>(colorSpace), fdp.ConsumeBool()); |
| 73 | session->GetopMode(); | 86 | session->GetopMode(); |
| 74 | std::vector<StreamInfo_V1_5> streamInfos; | 87 | std::vector<StreamInfo_V1_5> streamInfos; |
| @@ -171,7 +184,9 @@ sptr<ICameraDeviceService> GetDevice(FuzzedDataProvider& fdp) | |||
| 171 | std::lock_guard<std::mutex> lock(mutex); | 184 | std::lock_guard<std::mutex> lock(mutex); |
| 172 | static sptr<ICameraDeviceService> device; | 185 | static sptr<ICameraDeviceService> device; |
| 173 | if (device == nullptr) { | 186 | if (device == nullptr) { |
| 174 | - g_cameraService->CreateCameraDevice(fdp.ConsumeRandomLengthString(MAX_STR_LEN), device); | 187 | + auto service = GetService(); |
| 188 | + CHECK_RETURN_RET_ELOG(!service, nullptr, "service is nullptr"); | ||
| 189 | + service->CreateCameraDevice(fdp.ConsumeRandomLengthString(MAX_STR_LEN), device); | ||
| 175 | } | 190 | } |
| 176 | return device; | 191 | return device; |
| 177 | } | 192 | } |
| @@ -194,7 +209,9 @@ sptr<IStreamCapture> GetPhotoOutput(FuzzedDataProvider& fdp) | |||
| 194 | int32_t width = fdp.ConsumeIntegral<int32_t>() % MAX_W_H; | 209 | int32_t width = fdp.ConsumeIntegral<int32_t>() % MAX_W_H; |
| 195 | int32_t height = fdp.ConsumeIntegral<int32_t>() % MAX_W_H; | 210 | int32_t height = fdp.ConsumeIntegral<int32_t>() % MAX_W_H; |
| 196 | sptr<IStreamCapture> photoOutput; | 211 | sptr<IStreamCapture> photoOutput; |
| 197 | - g_cameraService->CreatePhotoOutput(format, width, height, photoOutput); | 212 | + auto service = GetService(); |
| 213 | + CHECK_RETURN_RET_ELOG(!service, nullptr, "service is nullptr"); | ||
| 214 | + service->CreatePhotoOutput(format, width, height, photoOutput); | ||
| 198 | return photoOutput; | 215 | return photoOutput; |
| 199 | } | 216 | } |
| 200 | 217 | ||
| @@ -573,21 +590,16 @@ void GetCompositionStream(FuzzedDataProvider& fdp, sptr<HCaptureSession>& sessio | |||
| 573 | void Init() | 590 | void Init() |
| 574 | { | 591 | { |
| 575 | CHECK_RETURN_ELOG(!TestToken().GetAllCameraPermission(), "Get permission fail"); | 592 | CHECK_RETURN_ELOG(!TestToken().GetAllCameraPermission(), "Get permission fail"); |
| 576 | - const int32_t CAMERA_SERVICE_ID = 3008; | ||
| 577 | - g_cameraService = new (std::nothrow) HCameraService(CAMERA_SERVICE_ID, true); | ||
| 578 | - CHECK_RETURN_ELOG(!g_cameraService, "g_cameraService is nullptr"); | ||
| 579 | - g_cameraService->OnStart(); | ||
| 580 | uint32_t callerToken = IPCSkeleton::GetCallingTokenID(); | 593 | uint32_t callerToken = IPCSkeleton::GetCallingTokenID(); |
| 581 | for (int32_t mode = 0; mode <= 2; ++mode) { | 594 | for (int32_t mode = 0; mode <= 2; ++mode) { |
| 582 | sptr<HCaptureSession> session; | 595 | sptr<HCaptureSession> session; |
| 583 | HCaptureSession::NewInstance(callerToken, mode, session); | 596 | HCaptureSession::NewInstance(callerToken, mode, session); |
| 584 | - g_sessions.push_back(session); | 597 | + GetSessions().push_back(session); |
| 585 | } | 598 | } |
| 586 | } | 599 | } |
| 587 | 600 | ||
| 588 | void Test(FuzzedDataProvider& fdp) | 601 | void Test(FuzzedDataProvider& fdp) |
| 589 | { | 602 | { |
| 590 | - CHECK_RETURN_ELOG(g_cameraService == nullptr, "g_cameraService is nullptr"); | ||
| 591 | auto func = fdp.PickValueInArray({ | 603 | auto func = fdp.PickValueInArray({ |
| 592 | HCaptureSessionFuzzTest1, | 604 | HCaptureSessionFuzzTest1, |
| 593 | HCaptureSessionFuzzTest2, | 605 | HCaptureSessionFuzzTest2, |
| @@ -657,9 +669,10 @@ void Test(FuzzedDataProvider& fdp) | |||
| 657 | GetBeautyRange, | 669 | GetBeautyRange, |
| 658 | GetBeautyValue, | 670 | GetBeautyValue, |
| 659 | SetBeautyValue, | 671 | SetBeautyValue, |
| 660 | - GetCompositionStream, | 672 | + GetCompositionStream |
| 661 | }); | 673 | }); |
| 662 | - auto& session = g_sessions[fdp.ConsumeIntegral<uint8_t>() % g_sessions.size()]; | 674 | + auto& sessions = GetSessions(); |
| 675 | + auto& session = sessions[fdp.ConsumeIntegral<uint8_t>() % sessions.size()]; | ||
| 663 | CHECK_RETURN_ELOG(session == nullptr, "session is nullptr"); | 676 | CHECK_RETURN_ELOG(session == nullptr, "session is nullptr"); |
| 664 | func(fdp, session); | 677 | func(fdp, session); |
| 665 | } | 678 | } |
| @@ -57,6 +57,7 @@ ohos_fuzztest("HStreamOperatorFuzzTest") { | |||
| 57 | "${multimedia_camera_framework_path}/services/deferred_processing_service/include/utils", | 57 | "${multimedia_camera_framework_path}/services/deferred_processing_service/include/utils", |
| 58 | "${multimedia_camera_framework_path}/services/camera_service/src", | 58 | "${multimedia_camera_framework_path}/services/camera_service/src", |
| 59 | "${multimedia_camera_framework_path}/services/camera_service/binder", | 59 | "${multimedia_camera_framework_path}/services/camera_service/binder", |
| 60 | + "${multimedia_camera_framework_path}/test/test_common/include", | ||
| 60 | ] | 61 | ] |
| 61 | 62 | ||
| 62 | cflags = [ | 63 | cflags = [ |
| @@ -75,6 +76,7 @@ ohos_fuzztest("HStreamOperatorFuzzTest") { | |||
| 75 | "${multimedia_camera_framework_path}/services/camera_service:camera_service", | 76 | "${multimedia_camera_framework_path}/services/camera_service:camera_service", |
| 76 | "${multimedia_camera_framework_path}/mediastream:media_stream", | 77 | "${multimedia_camera_framework_path}/mediastream:media_stream", |
| 77 | "${multimedia_camera_framework_path}/dynamic_libs:camera_dynamic_moving_photo", | 78 | "${multimedia_camera_framework_path}/dynamic_libs:camera_dynamic_moving_photo", |
| 79 | + "${multimedia_camera_framework_path}/test/test_common:test_common", | ||
| 78 | ] | 80 | ] |
| 79 | 81 | ||
| 80 | external_deps = [ | 82 | external_deps = [ |
| @@ -121,6 +123,7 @@ ohos_fuzztest("HStreamOperatorFuzzTest") { | |||
| 121 | "media_foundation:native_media_core", | 123 | "media_foundation:native_media_core", |
| 122 | "media_library:media_library", | 124 | "media_library:media_library", |
| 123 | "media_library:media_library_manager", | 125 | "media_library:media_library_manager", |
| 126 | + "media_library:media_library_camera_helper", | ||
| 124 | "memmgr:memmgrclient", | 127 | "memmgr:memmgrclient", |
| 125 | "os_account:libaccountkits", | 128 | "os_account:libaccountkits", |
| 126 | "os_account:os_account_innerkits", | 129 | "os_account:os_account_innerkits", |
| @@ -17,93 +17,417 @@ | |||
| 17 | 17 | ||
| 18 | 18 | ||
| 19 | 19 | ||
| 20 | + | ||
| 20 | 21 | ||
| 21 | -#include "message_parcel.h" | 22 | +#include "iconsumer_surface.h" |
| 23 | + | ||
| 24 | + | ||
| 22 | 25 | ||
| 23 | 26 | ||
| 24 | 27 | ||
| 25 | -#include "system_ability_definition.h" | 28 | +#include "camera_server_photo_proxy.h" |
| 26 | -#include "iservice_registry.h" | 29 | +#include "picture_interface.h" |
| 27 | -#include "ipc_skeleton.h" | 30 | +#include "metadata_utils.h" |
| 28 | -#include "buffer_extra_data_impl.h" | 31 | +#include "test_token.h" |
| 29 | -#include "moving_photo_proxy.h" | 32 | +#include "fuzz_util.h" |
| 30 | - | ||
| 31 | 33 | ||
| 32 | -namespace OHOS { | 34 | +using namespace OHOS; |
| 33 | -namespace CameraStandard { | 35 | +using namespace OHOS::CameraStandard; |
| 34 | -static constexpr int32_t MIN_SIZE_NUM = 64; | 36 | +using namespace OHOS::HDI::Camera::V1_0; |
| 35 | -static constexpr int32_t NUM_1 = 1; | ||
| 36 | 37 | ||
| 37 | -sptr<HStreamOperator> HStreamOperatorFuzzer::fuzz_{nullptr}; | 38 | +namespace { |
| 39 | +const int32_t PHOTO_WIDTH = 1280; | ||
| 40 | +const int32_t PHOTO_HEIGHT = 960; | ||
| 41 | +const int32_t PHOTO_FORMAT = 2000; | ||
| 42 | +const int32_t META_FORMAT = 2003; | ||
| 43 | +const int32_t DEPTH_FORMAT = 2004; | ||
| 44 | +const int32_t ITEMCOUNT = 10; | ||
| 45 | +const int32_t DATASIZE = 100; | ||
| 46 | +const int32_t HDI_STREAM_ID_CAPTURE = 101; | ||
| 47 | +const int32_t HDI_STREAM_ID_PREVIEW = 102; | ||
| 48 | +const int32_t HDI_STREAM_ID_VIDEO = 103; | ||
| 49 | +const int32_t HDI_STREAM_ID_META = 104; | ||
| 50 | +const int32_t HDI_STREAM_ID_DEPTH = 105; | ||
| 51 | +const int32_t FWK_STREAM_ID_CAPTURE = 11; | ||
| 52 | +const int32_t FWK_STREAM_ID_PREVIEW = 12; | ||
| 53 | +const int32_t FWK_STREAM_ID_VIDEO = 13; | ||
| 54 | +const int32_t FWK_STREAM_ID_META = 14; | ||
| 55 | +const int32_t FWK_STREAM_ID_DEPTH = 15; | ||
| 56 | +const int32_t COLOR_SPACE_COUNT = static_cast<int32_t>(OHOS::CameraStandard::ColorSpace::H_LOG) + 1; | ||
| 57 | +const int32_t ROTATION_360 = 360; | ||
| 38 | 58 | ||
| 39 | -void HStreamOperatorFuzzer::HStreamOperatorFuzzTest(FuzzedDataProvider& fdp) | 59 | +sptr<HStreamOperator> g_fuzz; |
| 60 | +sptr<HStreamOperator> g_fuzzBare; | ||
| 61 | +sptr<IStreamOperatorMock> g_mockOperator; | ||
| 62 | +sptr<HCameraDevice> g_cameraDevice; | ||
| 63 | +sptr<HStreamCapture> g_capture; | ||
| 64 | +sptr<HStreamRepeat> g_repeatPreview; | ||
| 65 | +sptr<HStreamRepeat> g_repeatVideo; | ||
| 66 | +sptr<HStreamMetadata> g_metadata; | ||
| 67 | +sptr<HStreamDepthData> g_depth; | ||
| 68 | + | ||
| 69 | +sptr<OHOS::IBufferProducer> CreateProducer() | ||
| 40 | { | 70 | { |
| 41 | - if (fdp.remaining_bytes() < MIN_SIZE_NUM) { | 71 | + sptr<IConsumerSurface> surface = IConsumerSurface::Create(); |
| 42 | - return; | 72 | + if (surface == nullptr) { |
| 73 | + return nullptr; | ||
| 43 | } | 74 | } |
| 44 | - fuzz_ = HStreamOperator::NewInstance(0, 0); | 75 | + return surface->GetProducer(); |
| 45 | - CHECK_RETURN_ELOG(!fuzz_, "NewInstance Error"); | ||
| 46 | - int32_t streamId = fdp.ConsumeIntegral<int32_t>(); | ||
| 47 | - fuzz_->GetStreamByStreamID(streamId); | ||
| 48 | - int32_t captureId = fdp.ConsumeIntegral<int32_t>(); | ||
| 49 | - int64_t timestamp = fdp.ConsumeIntegral<int64_t>(); | ||
| 50 | - | ||
| 51 | - int32_t rotation = fdp.ConsumeIntegral<int32_t>(); | ||
| 52 | - int32_t format = fdp.ConsumeIntegral<int32_t>(); | ||
| 53 | - fuzz_->StartMovingPhotoEncode(rotation, timestamp, format, captureId); | ||
| 54 | - fuzz_->EnableMovingPhotoMirror(fdp.ConsumeBool(), fdp.ConsumeBool()); | ||
| 55 | - | ||
| 56 | - fuzz_->GetHdiStreamByStreamID(streamId); | ||
| 57 | - ColorSpace getColorSpace; | ||
| 58 | - fuzz_->GetActiveColorSpace(getColorSpace); | ||
| 59 | - constexpr int32_t executionModeCount = static_cast<int32_t>(ColorSpace::P3_PQ_LIMIT) + NUM_1; | ||
| 60 | - ColorSpace colorSpace = static_cast<ColorSpace>(fdp.ConsumeIntegral<uint8_t>() % executionModeCount); | ||
| 61 | - fuzz_->SetColorSpace(colorSpace, fdp.ConsumeBool()); | ||
| 62 | - fuzz_->GetStreamOperator(); | ||
| 63 | - std::vector<int32_t> results = {fdp.ConsumeIntegral<uint32_t>()}; | ||
| 64 | - fuzz_->ReleaseStreams(); | ||
| 65 | - std::vector<HDI::Camera::V1_5::StreamInfo_V1_5> streamInfos; | ||
| 66 | - fuzz_->CreateStreams(streamInfos); | ||
| 67 | - std::shared_ptr<OHOS::Camera::CameraMetadata> settings; | ||
| 68 | - const int32_t NUM_10 = 10; | ||
| 69 | - const int32_t NUM_100 = 100; | ||
| 70 | - settings = std::make_shared<OHOS::Camera::CameraMetadata>(NUM_10, NUM_100); | ||
| 71 | - int32_t operationMode = fdp.ConsumeIntegral<int32_t>(); | ||
| 72 | - fuzz_->CommitStreams(settings, operationMode); | ||
| 73 | - fuzz_->UpdateStreams(streamInfos); | ||
| 74 | - fuzz_->CreateAndCommitStreams(streamInfos, settings, operationMode); | ||
| 75 | - const std::vector<int32_t> streamIds; | ||
| 76 | - fuzz_->OnCaptureStarted(captureId, streamIds); | ||
| 77 | - const std::vector<OHOS::HDI::Camera::V1_2::CaptureStartedInfo> infos; | ||
| 78 | - fuzz_->OnCaptureStarted_V1_2(captureId, infos); | ||
| 79 | - const std::vector<CaptureEndedInfo> infos_OnCaptureEnded; | ||
| 80 | - fuzz_->OnCaptureEnded(captureId, infos_OnCaptureEnded); | ||
| 81 | - const std::vector<OHOS::HDI::Camera::V1_3::CaptureEndedInfoExt> infos_OnCaptureEndedExt; | ||
| 82 | - fuzz_->OnCaptureEndedExt(captureId, infos_OnCaptureEndedExt); | ||
| 83 | - const std::vector<CaptureErrorInfo> infos_OnCaptureError; | ||
| 84 | - fuzz_->OnCaptureError(captureId, infos_OnCaptureError); | ||
| 85 | - fuzz_->OnFrameShutter(captureId, results, timestamp); | ||
| 86 | - fuzz_->OnFrameShutterEnd(captureId, results, timestamp); | ||
| 87 | - fuzz_->OnCaptureReady(captureId, results, timestamp); | ||
| 88 | } | 76 | } |
| 89 | 77 | ||
| 90 | -void Test(uint8_t* data, size_t size) | 78 | +std::shared_ptr<OHOS::Camera::CameraMetadata> MakeSettings(FuzzedDataProvider& fdp) |
| 79 | +{ | ||
| 80 | + return std::make_shared<OHOS::Camera::CameraMetadata>( | ||
| 81 | + fdp.ConsumeIntegralInRange<int32_t>(0, ITEMCOUNT), fdp.ConsumeIntegralInRange<int32_t>(0, DATASIZE)); | ||
| 82 | +} | ||
| 83 | + | ||
| 84 | +OHOS::CameraStandard::ColorSpace PickColorSpace(FuzzedDataProvider& fdp) | ||
| 85 | +{ | ||
| 86 | + return static_cast<OHOS::CameraStandard::ColorSpace>(fdp.ConsumeIntegral<uint8_t>() % COLOR_SPACE_COUNT); | ||
| 87 | +} | ||
| 88 | + | ||
| 89 | +void InitStreamIds() | ||
| 90 | +{ | ||
| 91 | + g_capture->fwkStreamId_ = FWK_STREAM_ID_CAPTURE; | ||
| 92 | + g_capture->SetHdiStreamId(HDI_STREAM_ID_CAPTURE); | ||
| 93 | + g_repeatPreview->fwkStreamId_ = FWK_STREAM_ID_PREVIEW; | ||
| 94 | + g_repeatPreview->SetHdiStreamId(HDI_STREAM_ID_PREVIEW); | ||
| 95 | + g_repeatVideo->fwkStreamId_ = FWK_STREAM_ID_VIDEO; | ||
| 96 | + g_repeatVideo->SetHdiStreamId(HDI_STREAM_ID_VIDEO); | ||
| 97 | + g_metadata->fwkStreamId_ = FWK_STREAM_ID_META; | ||
| 98 | + g_metadata->SetHdiStreamId(HDI_STREAM_ID_META); | ||
| 99 | + g_depth->fwkStreamId_ = FWK_STREAM_ID_DEPTH; | ||
| 100 | + g_depth->SetHdiStreamId(HDI_STREAM_ID_DEPTH); | ||
| 101 | +} | ||
| 102 | + | ||
| 103 | +void SetupRichOperator() | ||
| 104 | +{ | ||
| 105 | + uint32_t callerToken = 0; | ||
| 106 | + g_fuzz = HStreamOperator::NewInstance(callerToken, 0); | ||
| 107 | + if (g_fuzz == nullptr) { | ||
| 108 | + MEDIA_ERR_LOG("HStreamOperator NewInstance failed"); | ||
| 109 | + return; | ||
| 110 | + } | ||
| 111 | + sptr<OHOS::IBufferProducer> producer = CreateProducer(); | ||
| 112 | + g_capture = sptr<HStreamCapture>::MakeSptr(producer, PHOTO_FORMAT, PHOTO_WIDTH, PHOTO_HEIGHT); | ||
| 113 | + g_repeatPreview = | ||
| 114 | + sptr<HStreamRepeat>::MakeSptr(producer, PHOTO_FORMAT, PHOTO_WIDTH, PHOTO_HEIGHT, RepeatStreamType::PREVIEW); | ||
| 115 | + g_repeatVideo = | ||
| 116 | + sptr<HStreamRepeat>::MakeSptr(producer, PHOTO_FORMAT, PHOTO_WIDTH, PHOTO_HEIGHT, RepeatStreamType::VIDEO); | ||
| 117 | + std::vector<int32_t> metaTypes = {static_cast<int32_t>(MetadataObjectType::FACE)}; | ||
| 118 | + g_metadata = sptr<HStreamMetadata>::MakeSptr(producer, META_FORMAT, metaTypes); | ||
| 119 | + g_depth = sptr<HStreamDepthData>::MakeSptr(producer, DEPTH_FORMAT, PHOTO_WIDTH, PHOTO_HEIGHT); | ||
| 120 | + InitStreamIds(); | ||
| 121 | + g_fuzz->AddOutput(StreamType::CAPTURE, g_capture); | ||
| 122 | + g_fuzz->AddOutput(StreamType::REPEAT, g_repeatPreview); | ||
| 123 | + g_fuzz->AddOutput(StreamType::REPEAT, g_repeatVideo); | ||
| 124 | + g_fuzz->AddOutput(StreamType::METADATA, g_metadata); | ||
| 125 | + g_fuzz->AddOutput(StreamType::DEPTH, g_depth); | ||
| 126 | + int32_t operatorId = 1; | ||
| 127 | + g_fuzz->SetStreamOperatorId(operatorId); | ||
| 128 | + sptr<HCameraHostManager> cameraHostManager = new HCameraHostManager(nullptr); | ||
| 129 | + g_cameraDevice = new HCameraDevice(cameraHostManager, "0", callerToken); | ||
| 130 | + g_fuzz->SetCameraDevice(g_cameraDevice); | ||
| 131 | + g_mockOperator = sptr<IStreamOperatorMock>::MakeSptr(); | ||
| 132 | + g_fuzz->streamOperator_ = g_mockOperator; | ||
| 133 | + g_fuzzBare = HStreamOperator::NewInstance(callerToken, 0); | ||
| 134 | +} | ||
| 135 | +} // namespace | ||
| 136 | + | ||
| 137 | +void StreamManagementFuzz(FuzzedDataProvider& fdp) | ||
| 138 | +{ | ||
| 139 | + CHECK_RETURN_ELOG(g_fuzz == nullptr, "g_fuzz is null"); | ||
| 140 | + int32_t streamId = fdp.ConsumeIntegral<int32_t>(); | ||
| 141 | + g_fuzz->GetStreamByStreamID(streamId); | ||
| 142 | + g_fuzz->GetHdiStreamByStreamID(fdp.ConsumeIntegral<int32_t>()); | ||
| 143 | + g_fuzz->GetStreamsSize(); | ||
| 144 | + auto allStreams = g_fuzz->GetAllStreams(); | ||
| 145 | + std::vector<StreamInfo_V1_5> streamInfos; | ||
| 146 | + g_fuzz->GetCurrentStreamInfos(streamInfos); | ||
| 147 | + int32_t status = 0; | ||
| 148 | + g_fuzz->GetOutputStatus(status); | ||
| 149 | + g_fuzz->IsCaptureStreamExist(); | ||
| 150 | + g_fuzz->IsOfflineCapture(); | ||
| 151 | + g_fuzz->GetOfflineOutptSize(); | ||
| 152 | + sptr<HStreamCommon> found = g_fuzz->GetStreamByStreamID(FWK_STREAM_ID_CAPTURE); | ||
| 153 | + g_fuzz->AddOutputStream(found); | ||
| 154 | + sptr<OHOS::IBufferProducer> producer = CreateProducer(); | ||
| 155 | + auto disposable = sptr<HStreamCapture>::MakeSptr(producer, PHOTO_FORMAT, PHOTO_WIDTH, PHOTO_HEIGHT); | ||
| 156 | + disposable->fwkStreamId_ = fdp.ConsumeIntegral<int32_t>(); | ||
| 157 | + g_fuzz->AddOutputStream(disposable); | ||
| 158 | + g_fuzz->RemoveOutputStream(disposable); | ||
| 159 | + g_fuzz->RemoveOutput(StreamType::CAPTURE, disposable); | ||
| 160 | +} | ||
| 161 | + | ||
| 162 | +void ColorSpaceFuzz(FuzzedDataProvider& fdp) | ||
| 163 | +{ | ||
| 164 | + CHECK_RETURN_ELOG(g_fuzz == nullptr, "g_fuzz is null"); | ||
| 165 | + OHOS::CameraStandard::ColorSpace colorSpace = PickColorSpace(fdp); | ||
| 166 | + OHOS::CameraStandard::ColorSpace getColorSpace; | ||
| 167 | + g_fuzz->GetActiveColorSpace(getColorSpace); | ||
| 168 | + g_fuzz->SetColorSpace(colorSpace, fdp.ConsumeBool()); | ||
| 169 | + g_fuzz->SetColorSpaceForStreams(); | ||
| 170 | + g_fuzz->VerifyCaptureModeColorSpace(PickColorSpace(fdp)); | ||
| 171 | + g_fuzz->CheckIfColorSpaceMatchesFormat(PickColorSpace(fdp)); | ||
| 172 | + IsHdr(PickColorSpace(fdp)); | ||
| 173 | +} | ||
| 174 | + | ||
| 175 | +void StreamLifecycleFuzz(FuzzedDataProvider& fdp) | ||
| 176 | +{ | ||
| 177 | + CHECK_RETURN_ELOG(g_fuzz == nullptr, "g_fuzz is null"); | ||
| 178 | + auto settings = MakeSettings(fdp); | ||
| 179 | + int32_t opMode = fdp.ConsumeIntegral<int32_t>(); | ||
| 180 | + std::vector<StreamInfo_V1_5> streamInfos; | ||
| 181 | + g_fuzz->CreateStreams(streamInfos); | ||
| 182 | + g_fuzz->CommitStreams(settings, opMode); | ||
| 183 | + g_fuzz->UpdateStreams(streamInfos); | ||
| 184 | + g_fuzz->CreateAndCommitStreams(streamInfos, settings, opMode); | ||
| 185 | + g_fuzz->UpdateStreamInfos(settings); | ||
| 186 | + std::vector<int32_t> releaseIds = {fdp.ConsumeIntegral<int32_t>(), fdp.ConsumeIntegral<int32_t>()}; | ||
| 187 | + g_fuzz->ReleaseStreams(releaseIds); | ||
| 188 | + g_fuzz->UnlinkInputAndOutputs(); | ||
| 189 | + g_fuzz->UnlinkOfflineInputAndOutputs(); | ||
| 190 | + g_fuzz->LinkInputAndOutputs(settings, opMode); | ||
| 191 | + g_fuzz->GetHDIStreamOperator(); | ||
| 192 | + g_fuzz->ResetHDIStreamOperator(); | ||
| 193 | + g_fuzz->GetStreamOperator(); | ||
| 194 | + g_fuzz->streamOperator_ = g_mockOperator; | ||
| 195 | + g_fuzz->ResetHdiStreamId(); | ||
| 196 | + sptr<HStreamOperator> disposable = HStreamOperator::NewInstance(0, 0); | ||
| 197 | + if (disposable != nullptr) { | ||
| 198 | + sptr<OHOS::IBufferProducer> producer = CreateProducer(); | ||
| 199 | + auto capStream = sptr<HStreamCapture>::MakeSptr(producer, PHOTO_FORMAT, PHOTO_WIDTH, PHOTO_HEIGHT); | ||
| 200 | + capStream->fwkStreamId_ = fdp.ConsumeIntegral<int32_t>(); | ||
| 201 | + capStream->SetHdiStreamId(fdp.ConsumeIntegral<int32_t>()); | ||
| 202 | + disposable->AddOutput(StreamType::CAPTURE, capStream); | ||
| 203 | + disposable->streamOperator_ = g_mockOperator; | ||
| 204 | + disposable->ReleaseStreams(); | ||
| 205 | + disposable->Stop(); | ||
| 206 | + } | ||
| 207 | +} | ||
| 208 | + | ||
| 209 | +void CallbackFuzz(FuzzedDataProvider& fdp) | ||
| 210 | +{ | ||
| 211 | + CHECK_RETURN_ELOG(g_fuzz == nullptr, "g_fuzz is null"); | ||
| 212 | + int32_t captureId = fdp.ConsumeIntegral<int32_t>(); | ||
| 213 | + uint64_t timestamp = fdp.ConsumeIntegral<uint64_t>(); | ||
| 214 | + int32_t repHdiId = g_repeatPreview->GetHdiStreamId(); | ||
| 215 | + int32_t capHdiId = g_capture->GetHdiStreamId(); | ||
| 216 | + int32_t vidHdiId = g_repeatVideo->GetHdiStreamId(); | ||
| 217 | + std::vector<int32_t> streamIds = {repHdiId, capHdiId, fdp.ConsumeIntegral<int32_t>()}; | ||
| 218 | + g_fuzz->OnCaptureStarted(captureId, streamIds); | ||
| 219 | + std::vector<OHOS::HDI::Camera::V1_2::CaptureStartedInfo> startedInfos; | ||
| 220 | + OHOS::HDI::Camera::V1_2::CaptureStartedInfo startedInfo; | ||
| 221 | + startedInfo.streamId_ = capHdiId; | ||
| 222 | + startedInfo.exposureTime_ = fdp.ConsumeIntegral<int32_t>(); | ||
| 223 | + startedInfos.emplace_back(startedInfo); | ||
| 224 | + g_fuzz->OnCaptureStarted_V1_2(fdp.ConsumeIntegral<int32_t>(), startedInfos); | ||
| 225 | + std::vector<CaptureEndedInfo> endedInfos; | ||
| 226 | + CaptureEndedInfo endedRep; | ||
| 227 | + endedRep.streamId_ = repHdiId; | ||
| 228 | + endedRep.frameCount_ = fdp.ConsumeIntegral<int32_t>(); | ||
| 229 | + endedInfos.emplace_back(endedRep); | ||
| 230 | + CaptureEndedInfo endedCap; | ||
| 231 | + endedCap.streamId_ = capHdiId; | ||
| 232 | + endedCap.frameCount_ = fdp.ConsumeIntegral<int32_t>(); | ||
| 233 | + endedInfos.emplace_back(endedCap); | ||
| 234 | + g_fuzz->OnCaptureEnded(fdp.ConsumeIntegral<int32_t>(), endedInfos); | ||
| 235 | + std::vector<OHOS::HDI::Camera::V1_3::CaptureEndedInfoExt> endedExtInfos; | ||
| 236 | + OHOS::HDI::Camera::V1_3::CaptureEndedInfoExt endedExt; | ||
| 237 | + endedExt.streamId_ = vidHdiId; | ||
| 238 | + endedExt.frameCount_ = fdp.ConsumeIntegral<int32_t>(); | ||
| 239 | + endedExt.isDeferredVideoEnhancementAvailable_ = fdp.ConsumeBool(); | ||
| 240 | + endedExt.videoId_ = fdp.ConsumeRandomLengthString(); | ||
| 241 | + endedExtInfos.emplace_back(endedExt); | ||
| 242 | + g_fuzz->OnCaptureEndedExt(fdp.ConsumeIntegral<int32_t>(), endedExtInfos); | ||
| 243 | + std::vector<CaptureErrorInfo> errInfos; | ||
| 244 | + CaptureErrorInfo errRep; | ||
| 245 | + errRep.streamId_ = repHdiId; | ||
| 246 | + errRep.error_ = static_cast<OHOS::HDI::Camera::V1_0::StreamError>(fdp.ConsumeIntegral<int32_t>()); | ||
| 247 | + errInfos.emplace_back(errRep); | ||
| 248 | + CaptureErrorInfo errCap; | ||
| 249 | + errCap.streamId_ = capHdiId; | ||
| 250 | + errCap.error_ = static_cast<OHOS::HDI::Camera::V1_0::StreamError>(fdp.ConsumeIntegral<int32_t>()); | ||
| 251 | + errInfos.emplace_back(errCap); | ||
| 252 | + g_fuzz->OnCaptureError(fdp.ConsumeIntegral<int32_t>(), errInfos); | ||
| 253 | + g_fuzz->OnFrameShutter(captureId, {capHdiId}, timestamp); | ||
| 254 | + g_fuzz->OnFrameShutterEnd(fdp.ConsumeIntegral<int32_t>(), {capHdiId}, fdp.ConsumeIntegral<uint64_t>()); | ||
| 255 | + g_fuzz->OnCaptureReady(fdp.ConsumeIntegral<int32_t>(), {capHdiId}, fdp.ConsumeIntegral<uint64_t>()); | ||
| 256 | + std::vector<uint8_t> resultData = ConsumeRandomVector<uint8_t>(fdp); | ||
| 257 | + g_fuzz->OnResult(HDI_STREAM_ID_META, resultData); | ||
| 258 | + g_fuzz->OnResult(-1, resultData); | ||
| 259 | + g_fuzz->OnCapturePaused(fdp.ConsumeIntegral<int32_t>(), {repHdiId, vidHdiId}); | ||
| 260 | + g_fuzz->OnCaptureResumed(fdp.ConsumeIntegral<int32_t>(), {repHdiId}); | ||
| 261 | +} | ||
| 262 | + | ||
| 263 | +void PreviewFrameRateFuzz(FuzzedDataProvider& fdp) | ||
| 264 | +{ | ||
| 265 | + CHECK_RETURN_ELOG(g_fuzz == nullptr, "g_fuzz is null"); | ||
| 266 | + auto settings = MakeSettings(fdp); | ||
| 267 | + camera_position_enum_t cameraPosition = | ||
| 268 | + static_cast<camera_position_enum_t>(fdp.ConsumeIntegral<uint8_t>() % (OHOS_CAMERA_POSITION_OTHER + 1)); | ||
| 269 | + g_fuzz->SetPreviewRotation(fdp.ConsumeRandomLengthString()); | ||
| 270 | + g_fuzz->StartPreviewStream(settings, cameraPosition); | ||
| 271 | + g_fuzz->GetFrameRateRange(); | ||
| 272 | + g_fuzz->UpdateSettingForFocusTrackingMech(fdp.ConsumeBool()); | ||
| 273 | + g_fuzz->Stop(); | ||
| 274 | +} | ||
| 275 | + | ||
| 276 | +void CompositionSketchFuzz(FuzzedDataProvider& fdp) | ||
| 277 | +{ | ||
| 278 | + CHECK_RETURN_ELOG(g_fuzz == nullptr, "g_fuzz is null"); | ||
| 279 | + g_fuzz->ExpandSketchRepeatStream(); | ||
| 280 | + g_fuzz->ExpandCompositionRepeatStream(); | ||
| 281 | + g_fuzz->ClearSketchRepeatStream(); | ||
| 282 | + g_fuzz->ClearCompositionRepeatStream(); | ||
| 283 | + g_fuzz->GetCompositionStreams(); | ||
| 284 | + g_fuzz->FindPreviewStreamRepeat(); | ||
| 285 | +} | ||
| 286 | + | ||
| 287 | + | ||
| 288 | +void MovingPhotoFuzz(FuzzedDataProvider& fdp) | ||
| 289 | +{ | ||
| 290 | + CHECK_RETURN_ELOG(g_fuzz == nullptr, "g_fuzz is null"); | ||
| 291 | + auto settings = MakeSettings(fdp); | ||
| 292 | + g_fuzz->EnableMovingPhoto(settings, fdp.ConsumeBool(), fdp.ConsumeIntegral<int32_t>()); | ||
| 293 | + g_fuzz->EnableMovingPhotoMirror(fdp.ConsumeBool(), fdp.ConsumeBool()); | ||
| 294 | + g_fuzz->StartMovingPhotoEncode( | ||
| 295 | + fdp.ConsumeIntegral<int32_t>(), fdp.ConsumeIntegral<uint64_t>(), fdp.ConsumeIntegral<int32_t>(), | ||
| 296 | + fdp.ConsumeIntegral<int32_t>()); | ||
| 297 | + OHOS::CameraStandard::VideoType videoType = static_cast<OHOS::CameraStandard::VideoType> | ||
| 298 | + (fdp.ConsumeIntegral<uint8_t>() % (OHOS::CameraStandard::VideoType::XT_ORIGIN_VIDEO + 1)); | ||
| 299 | + g_fuzz->StopMovingPhoto(videoType); | ||
| 300 | + g_fuzz->ClearMovingPhotoRepeatStream(videoType); | ||
| 301 | + g_fuzz->ReleaseTargetMovingphotoStream(videoType); | ||
| 302 | + g_fuzz->ReleaseMovingphotoStreams(); | ||
| 303 | + g_fuzz->ExpandMovingPhotoRepeatStream(videoType); | ||
| 304 | + g_fuzz->ExpandXtStyleMovingPhotoRepeatStream(); | ||
| 305 | + g_fuzz->StartMovingPhotoStream(settings); | ||
| 306 | + g_fuzz->IsLivephotoStreamExist(); | ||
| 307 | + g_fuzz->SetDeferredVideoEnhanceFlag( | ||
| 308 | + fdp.ConsumeIntegral<int32_t>(), fdp.ConsumeIntegral<uint32_t>(), fdp.ConsumeRandomLengthString()); | ||
| 309 | + g_fuzz->ChangeListenerXtstyleType(); | ||
| 310 | +} | ||
| 311 | + | ||
| 312 | + | ||
| 313 | +void UtilityInlineFuzz(FuzzedDataProvider& fdp) | ||
| 314 | +{ | ||
| 315 | + CHECK_RETURN_ELOG(g_fuzz == nullptr, "g_fuzz is null"); | ||
| 316 | + g_fuzz->GetPid(); | ||
| 317 | + g_fuzz->SetXtStyleStatus(fdp.ConsumeBool()); | ||
| 318 | + g_fuzz->GetXtStyleStatus(); | ||
| 319 | + std::vector<int32_t> highRes = {fdp.ConsumeIntegral<int32_t>()}; | ||
| 320 | + g_fuzz->GetDeferredImageDeliveryEnabled(); | ||
| 321 | + camera_metadata_item_t item; | ||
| 322 | + g_fuzz->GetDeviceAbilityByMeta(fdp.ConsumeIntegral<uint32_t>(), &item); | ||
| 323 | + g_fuzz->GetSupportRedoXtStyle(); | ||
| 324 | + g_fuzz->SetMechCallback(nullptr); | ||
| 325 | + int32_t rotation = 0; | ||
| 326 | + g_fuzz->UpdateOrientationBaseGravity(fdp.ConsumeIntegral<int32_t>(), | ||
| 327 | + ((fdp.ConsumeIntegral<int32_t>() % ROTATION_360) + ROTATION_360) % ROTATION_360, | ||
| 328 | + fdp.ConsumeIntegral<int32_t>(), rotation); | ||
| 329 | + g_fuzz->GetSensorRotation(); | ||
| 330 | + g_fuzz->IsIpsRotateSupported(); | ||
| 331 | + | ||
| 332 | + g_fuzz->RegisterSensorCallback(); | ||
| 333 | + | ||
| 334 | + auto listener = new HStreamOperator::DisplayRotationListener(); | ||
| 335 | + listener->AddHstreamRepeatForListener(g_repeatPreview); | ||
| 336 | + listener->OnChange(0); | ||
| 337 | + listener->RemoveHstreamRepeatForListener(g_repeatPreview); | ||
| 338 | + sptr<HStreamOperator> releaseTarget = HStreamOperator::NewInstance(0, 0); | ||
| 339 | + if (releaseTarget != nullptr) { | ||
| 340 | + releaseTarget->Release(); | ||
| 341 | + } | ||
| 342 | +} | ||
| 343 | + | ||
| 344 | +void MediaLibraryFuzz(FuzzedDataProvider& fdp) | ||
| 345 | +{ | ||
| 346 | + CHECK_RETURN_ELOG(g_fuzz == nullptr, "g_fuzz is null"); | ||
| 347 | + sptr<CameraServerPhotoProxy> photoProxy = sptr<CameraServerPhotoProxy>::MakeSptr(); | ||
| 348 | + std::string uri = fdp.ConsumeRandomLengthString(); | ||
| 349 | + int32_t cameraShotType = 0; | ||
| 350 | + std::string burstKey = fdp.ConsumeRandomLengthString(); | ||
| 351 | + int64_t timestamp = fdp.ConsumeIntegral<int64_t>(); | ||
| 352 | + g_fuzz->CreateMediaLibrary(photoProxy, uri, cameraShotType, burstKey, timestamp); | ||
| 353 | + int32_t shotType2 = 0; | ||
| 354 | + std::string burstKey2 = fdp.ConsumeRandomLengthString(); | ||
| 355 | + std::string uri2 = fdp.ConsumeRandomLengthString(); | ||
| 356 | + g_fuzz->CreateMediaLibrary(nullptr, photoProxy, uri2, shotType2, burstKey2, timestamp); | ||
| 357 | + bool isBursting = false; | ||
| 358 | + std::string burstKey3 = fdp.ConsumeRandomLengthString(); | ||
| 359 | + int32_t shotType3 = 0; | ||
| 360 | + g_fuzz->SetCameraPhotoProxyInfo(photoProxy, shotType3, isBursting, burstKey3); | ||
| 361 | +} | ||
| 362 | + | ||
| 363 | +void NullDepFuzz(FuzzedDataProvider& fdp) | ||
| 364 | +{ | ||
| 365 | + CHECK_RETURN_ELOG(g_fuzzBare == nullptr, "g_fuzzBare is null"); | ||
| 366 | + auto settings = MakeSettings(fdp); | ||
| 367 | + int32_t opMode = fdp.ConsumeIntegral<int32_t>(); | ||
| 368 | + std::vector<StreamInfo_V1_5> streamInfos; | ||
| 369 | + g_fuzzBare->CreateStreams(streamInfos); | ||
| 370 | + g_fuzzBare->CommitStreams(settings, opMode); | ||
| 371 | + g_fuzzBare->UpdateStreams(streamInfos); | ||
| 372 | + g_fuzzBare->GetStreamOperator(); | ||
| 373 | + camera_metadata_item_t item; | ||
| 374 | + g_fuzzBare->GetDeviceAbilityByMeta(fdp.ConsumeIntegral<uint32_t>(), &item); | ||
| 375 | + g_fuzzBare->GetSupportRedoXtStyle(); | ||
| 376 | + g_fuzzBare->GetDeferredImageDeliveryEnabled(); | ||
| 377 | + g_fuzzBare->UpdateSettingForFocusTrackingMech(fdp.ConsumeBool()); | ||
| 378 | + g_fuzzBare->StartPreviewStream(settings, OHOS_CAMERA_POSITION_BACK); | ||
| 379 | + g_fuzzBare->IsOfflineCapture(); | ||
| 380 | + g_fuzzBare->IsCaptureStreamExist(); | ||
| 381 | + g_fuzzBare->GetOfflineOutptSize(); | ||
| 382 | + g_fuzzBare->SetColorSpace(PickColorSpace(fdp), fdp.ConsumeBool()); | ||
| 383 | + g_fuzzBare->Stop(); | ||
| 384 | + g_fuzzBare->ReleaseStreams(); | ||
| 385 | + g_fuzzBare->UnlinkInputAndOutputs(); | ||
| 386 | + g_fuzzBare->UnlinkOfflineInputAndOutputs(); | ||
| 387 | + g_fuzzBare->LinkInputAndOutputs(settings, opMode); | ||
| 388 | + int32_t status = 0; | ||
| 389 | + g_fuzzBare->GetOutputStatus(status); | ||
| 390 | + g_fuzzBare->GetFrameRateRange(); | ||
| 391 | +} | ||
| 392 | + | ||
| 393 | +void Test(FuzzedDataProvider& fdp) | ||
| 394 | +{ | ||
| 395 | + CHECK_RETURN_ELOG(g_fuzz == nullptr, "g_fuzz is null"); | ||
| 396 | + auto func = fdp.PickValueInArray({ | ||
| 397 | + StreamManagementFuzz, | ||
| 398 | + ColorSpaceFuzz, | ||
| 399 | + StreamLifecycleFuzz, | ||
| 400 | + CallbackFuzz, | ||
| 401 | + PreviewFrameRateFuzz, | ||
| 402 | + CompositionSketchFuzz, | ||
| 403 | + UtilityInlineFuzz, | ||
| 404 | + MediaLibraryFuzz, | ||
| 405 | + NullDepFuzz, | ||
| 406 | + | ||
| 407 | + MovingPhotoFuzz, | ||
| 408 | + | ||
| 409 | + }); | ||
| 410 | + func(fdp); | ||
| 411 | +} | ||
| 412 | + | ||
| 413 | +void Init() | ||
| 414 | +{ | ||
| 415 | + CHECK_RETURN_ELOG(!TestToken().GetAllCameraPermission(), "Get permission fail"); | ||
| 416 | + SetupRichOperator(); | ||
| 417 | +} | ||
| 418 | + | ||
| 419 | +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) | ||
| 91 | { | 420 | { |
| 92 | FuzzedDataProvider fdp(data, size); | 421 | FuzzedDataProvider fdp(data, size); |
| 93 | - auto HStreamOperator = std::make_unique<HStreamOperatorFuzzer>(); | 422 | + Test(fdp); |
| 94 | - if (HStreamOperator == nullptr) { | 423 | + return 0; |
| 95 | - MEDIA_INFO_LOG("HStreamOperator is null"); | ||
| 96 | - return; | ||
| 97 | - } | ||
| 98 | - HStreamOperator->HStreamOperatorFuzzTest(fdp); | ||
| 99 | } | 424 | } |
| 100 | 425 | ||
| 101 | -} // namespace CameraStandard | 426 | +extern "C" int LLVMFuzzerInitialize(int* argc, char*** argv) |
| 102 | -} // namespace OHOS | ||
| 103 | - | ||
| 104 | -/* Fuzzer entry point */ | ||
| 105 | -extern "C" int LLVMFuzzerTestOneInput(uint8_t* data, size_t size) | ||
| 106 | { | 427 | { |
| 107 | - OHOS::CameraStandard::Test(data, size); | 428 | + if (SetSelfTokenID(718336240ull | (1ull << 32)) < 0) { |
| 429 | + return -1; | ||
| 430 | + } | ||
| 431 | + Init(); | ||
| 108 | return 0; | 432 | return 0; |
| 109 | -} | 433 | +} |
| @@ -17,17 +17,87 @@ | |||
| 17 | 17 | ||
| 18 | 18 | ||
| 19 | 19 | ||
| 20 | + | ||
| 21 | + | ||
| 22 | + | ||
| 23 | + | ||
| 24 | + | ||
| 25 | + | ||
| 20 | 26 | ||
| 21 | 27 | ||
| 22 | namespace OHOS { | 28 | namespace OHOS { |
| 23 | namespace CameraStandard { | 29 | namespace CameraStandard { |
| 24 | 30 | ||
| 25 | -class HStreamOperatorFuzzer { | 31 | +class IStreamOperatorMock : public OHOS::HDI::Camera::V1_0::IStreamOperator { |
| 26 | public: | 32 | public: |
| 27 | -static sptr<HStreamOperator> fuzz_; | 33 | + IStreamOperatorMock() = default; |
| 28 | -static void HStreamOperatorFuzzTest(FuzzedDataProvider& fdp); | 34 | + ~IStreamOperatorMock() override = default; |
| 35 | + int32_t IsStreamsSupported(OHOS::HDI::Camera::V1_0::OperationMode mode, | ||
| 36 | + const std::vector<uint8_t>& modeSetting, const std::vector<OHOS::HDI::Camera::V1_0::StreamInfo>& infos, | ||
| 37 | + OHOS::HDI::Camera::V1_0::StreamSupportType& type) override | ||
| 38 | + { | ||
| 39 | + return HDF_SUCCESS; | ||
| 40 | + } | ||
| 41 | + int32_t CreateStreams(const std::vector<OHOS::HDI::Camera::V1_0::StreamInfo>& streamInfos) override | ||
| 42 | + { | ||
| 43 | + return HDF_SUCCESS; | ||
| 44 | + } | ||
| 45 | + int32_t ReleaseStreams(const std::vector<int32_t>& streamIds) override | ||
| 46 | + { | ||
| 47 | + return HDF_SUCCESS; | ||
| 48 | + } | ||
| 49 | + int32_t CommitStreams( | ||
| 50 | + OHOS::HDI::Camera::V1_0::OperationMode mode, const std::vector<uint8_t>& modeSetting) override | ||
| 51 | + { | ||
| 52 | + return HDF_SUCCESS; | ||
| 53 | + } | ||
| 54 | + int32_t GetStreamAttributes(std::vector<OHOS::HDI::Camera::V1_0::StreamAttribute>& attributes) override | ||
| 55 | + { | ||
| 56 | + return HDF_SUCCESS; | ||
| 57 | + } | ||
| 58 | + int32_t AttachBufferQueue( | ||
| 59 | + int32_t streamId, const sptr<OHOS::HDI::Camera::V1_0::BufferProducerSequenceable>& bufferProducer) override | ||
| 60 | + { | ||
| 61 | + return HDF_SUCCESS; | ||
| 62 | + } | ||
| 63 | + int32_t DetachBufferQueue(int32_t streamId) override | ||
| 64 | + { | ||
| 65 | + return HDF_SUCCESS; | ||
| 66 | + } | ||
| 67 | + int32_t Capture( | ||
| 68 | + int32_t captureId, const OHOS::HDI::Camera::V1_0::CaptureInfo& info, bool isStreaming) override | ||
| 69 | + { | ||
| 70 | + return HDF_SUCCESS; | ||
| 71 | + } | ||
| 72 | + int32_t CancelCapture(int32_t captureId) override | ||
| 73 | + { | ||
| 74 | + return HDF_SUCCESS; | ||
| 75 | + } | ||
| 76 | + int32_t ChangeToOfflineStream(const std::vector<int32_t>& streamIds, | ||
| 77 | + const sptr<OHOS::HDI::Camera::V1_0::IStreamOperatorCallback>& callbackObj, | ||
| 78 | + sptr<OHOS::HDI::Camera::V1_0::IOfflineStreamOperator>& offlineOperator) override | ||
| 79 | + { | ||
| 80 | + return HDF_SUCCESS; | ||
| 81 | + } | ||
| 82 | + int32_t GetVersion(uint32_t& majorVer, uint32_t& minorVer) override | ||
| 83 | + { | ||
| 84 | + majorVer = 1; | ||
| 85 | + minorVer = 0; | ||
| 86 | + return HDF_SUCCESS; | ||
| 87 | + } | ||
| 88 | + bool IsProxy() override | ||
| 89 | + { | ||
| 90 | + return false; | ||
| 91 | + } | ||
| 92 | + const std::u16string GetDesc() override | ||
| 93 | + { | ||
| 94 | + return metaDescriptor_; | ||
| 95 | + } | ||
| 96 | + | ||
| 97 | +private: | ||
| 98 | + std::u16string metaDescriptor_ = u"mock_i_stream_operator"; | ||
| 29 | }; | 99 | }; |
| 30 | 100 | ||
| 31 | -} //CameraStandard | 101 | +} // namespace CameraStandard |
| 32 | -} //CameraStandard | 102 | +} // namespace OHOS |
| 33 | -#endif //HSTREAM_OPERATOR_FUZZER_H | 103 | +#endif // HSTREAM_OPERATOR_FUZZER_H |
| @@ -16,9 +16,9 @@ | |||
| 16 | <fuzz_config> | 16 | <fuzz_config> |
| 17 | <fuzztest> | 17 | <fuzztest> |
| 18 | <!-- maximum length of a test input --> | 18 | <!-- maximum length of a test input --> |
| 19 | - <max_len>1000</max_len> | 19 | + <max_len>4096</max_len> |
| 20 | <!-- maximum total time in seconds to run the fuzzer --> | 20 | <!-- maximum total time in seconds to run the fuzzer --> |
| 21 | - <max_total_time>3</max_total_time> | 21 | + <max_total_time>5</max_total_time> |
| 22 | <!-- memory usage limit in Mb --> | 22 | <!-- memory usage limit in Mb --> |
| 23 | <rss_limit_mb>4096</rss_limit_mb> | 23 | <rss_limit_mb>4096</rss_limit_mb> |
| 24 | </fuzztest> | 24 | </fuzztest> |
| @@ -46,99 +46,97 @@ const int32_t PHOTO_HEIGHT = 960; | |||
| 46 | const int32_t PHOTO_FORMAT = 2000; | 46 | const int32_t PHOTO_FORMAT = 2000; |
| 47 | const int32_t ROTATION_360 = 360; | 47 | const int32_t ROTATION_360 = 360; |
| 48 | 48 | ||
| 49 | -sptr<HStreamRepeat> g_hStreamRepeat; | 49 | +sptr<IBufferProducer> g_producer; |
| 50 | + | ||
| 51 | +HStreamRepeat& GetHStreamRepeat(){ | ||
| 52 | + static HStreamRepeat hstreamRepeat(g_producer, PHOTO_FORMAT, PHOTO_WIDTH, PHOTO_HEIGHT, RepeatStreamType::PREVIEW); | ||
| 53 | + return hstreamRepeat; | ||
| 54 | +} | ||
| 50 | 55 | ||
| 51 | void Start(FuzzedDataProvider& fdp) | 56 | void Start(FuzzedDataProvider& fdp) |
| 52 | { | 57 | { |
| 53 | - g_hStreamRepeat->Start(); | 58 | + GetHStreamRepeat().Start(); |
| 54 | } | 59 | } |
| 55 | 60 | ||
| 56 | void Stop(FuzzedDataProvider& fdp) | 61 | void Stop(FuzzedDataProvider& fdp) |
| 57 | { | 62 | { |
| 58 | - g_hStreamRepeat->Stop(); | 63 | + GetHStreamRepeat().Stop(); |
| 59 | } | 64 | } |
| 60 | 65 | ||
| 61 | void Release(FuzzedDataProvider& fdp) | 66 | void Release(FuzzedDataProvider& fdp) |
| 62 | { | 67 | { |
| 63 | - g_hStreamRepeat->Release(); | 68 | + GetHStreamRepeat().Release(); |
| 64 | } | 69 | } |
| 65 | 70 | ||
| 66 | void SetCallback(FuzzedDataProvider& fdp) | 71 | void SetCallback(FuzzedDataProvider& fdp) |
| 67 | { | 72 | { |
| 68 | sptr<MockStreamRepeatCallback> cb = new (std::nothrow) MockStreamRepeatCallback(); | 73 | sptr<MockStreamRepeatCallback> cb = new (std::nothrow) MockStreamRepeatCallback(); |
| 69 | - g_hStreamRepeat->SetCallback(cb); | 74 | + GetHStreamRepeat().SetCallback(cb); |
| 70 | } | 75 | } |
| 71 | 76 | ||
| 72 | void AddDeferredSurface(FuzzedDataProvider& fdp) | 77 | void AddDeferredSurface(FuzzedDataProvider& fdp) |
| 73 | { | 78 | { |
| 74 | sptr<IConsumerSurface> photoSurface = IConsumerSurface::Create(); | 79 | sptr<IConsumerSurface> photoSurface = IConsumerSurface::Create(); |
| 75 | sptr<IBufferProducer> producer = photoSurface->GetProducer(); | 80 | sptr<IBufferProducer> producer = photoSurface->GetProducer(); |
| 76 | - g_hStreamRepeat->AddDeferredSurface(producer); | 81 | + GetHStreamRepeat().AddDeferredSurface(producer); |
| 77 | -} | ||
| 78 | - | ||
| 79 | -void ForkSketchStreamRepeat(FuzzedDataProvider& fdp) | ||
| 80 | -{ | ||
| 81 | - sptr<IRemoteObject> remote = new (std::nothrow) MockIRemoteObject(); | ||
| 82 | - g_hStreamRepeat->ForkSketchStreamRepeat( | ||
| 83 | - fdp.ConsumeIntegral<int32_t>(), fdp.ConsumeIntegral<int32_t>(), remote, fdp.ConsumeFloatingPoint<float>()); | ||
| 84 | } | 82 | } |
| 85 | 83 | ||
| 86 | void RemoveSketchStreamRepeat(FuzzedDataProvider& fdp) | 84 | void RemoveSketchStreamRepeat(FuzzedDataProvider& fdp) |
| 87 | { | 85 | { |
| 88 | - g_hStreamRepeat->RemoveSketchStreamRepeat(); | 86 | + GetHStreamRepeat().RemoveSketchStreamRepeat(); |
| 89 | } | 87 | } |
| 90 | 88 | ||
| 91 | void UpdateSketchRatio(FuzzedDataProvider& fdp) | 89 | void UpdateSketchRatio(FuzzedDataProvider& fdp) |
| 92 | { | 90 | { |
| 93 | - g_hStreamRepeat->UpdateSketchRatio(fdp.ConsumeFloatingPoint<float>()); | 91 | + GetHStreamRepeat().UpdateSketchRatio(fdp.ConsumeFloatingPoint<float>()); |
| 94 | } | 92 | } |
| 95 | 93 | ||
| 96 | void SetFrameRate(FuzzedDataProvider& fdp) | 94 | void SetFrameRate(FuzzedDataProvider& fdp) |
| 97 | { | 95 | { |
| 98 | - g_hStreamRepeat->SetFrameRate(fdp.ConsumeIntegral<int32_t>(), fdp.ConsumeIntegral<int32_t>()); | 96 | + GetHStreamRepeat().SetFrameRate(fdp.ConsumeIntegral<int32_t>(), fdp.ConsumeIntegral<int32_t>()); |
| 99 | } | 97 | } |
| 100 | 98 | ||
| 101 | void EnableSecure(FuzzedDataProvider& fdp) | 99 | void EnableSecure(FuzzedDataProvider& fdp) |
| 102 | { | 100 | { |
| 103 | - g_hStreamRepeat->EnableSecure(fdp.ConsumeBool()); | 101 | + GetHStreamRepeat().EnableSecure(fdp.ConsumeBool()); |
| 104 | } | 102 | } |
| 105 | 103 | ||
| 106 | void EnableStitching(FuzzedDataProvider& fdp) | 104 | void EnableStitching(FuzzedDataProvider& fdp) |
| 107 | { | 105 | { |
| 108 | - g_hStreamRepeat->EnableStitching(fdp.ConsumeBool()); | 106 | + GetHStreamRepeat().EnableStitching(fdp.ConsumeBool()); |
| 109 | } | 107 | } |
| 110 | 108 | ||
| 111 | void SetMirror(FuzzedDataProvider& fdp) | 109 | void SetMirror(FuzzedDataProvider& fdp) |
| 112 | { | 110 | { |
| 113 | - g_hStreamRepeat->SetMirror(fdp.ConsumeBool()); | 111 | + GetHStreamRepeat().SetMirror(fdp.ConsumeBool()); |
| 114 | } | 112 | } |
| 115 | 113 | ||
| 116 | void AttachMetaSurface(FuzzedDataProvider& fdp) | 114 | void AttachMetaSurface(FuzzedDataProvider& fdp) |
| 117 | { | 115 | { |
| 118 | sptr<IConsumerSurface> photoSurface = IConsumerSurface::Create(); | 116 | sptr<IConsumerSurface> photoSurface = IConsumerSurface::Create(); |
| 119 | sptr<IBufferProducer> producer = photoSurface->GetProducer(); | 117 | sptr<IBufferProducer> producer = photoSurface->GetProducer(); |
| 120 | - g_hStreamRepeat->AttachMetaSurface(producer, fdp.ConsumeIntegral<int32_t>()); | 118 | + GetHStreamRepeat().AttachMetaSurface(producer, fdp.ConsumeIntegral<int32_t>()); |
| 121 | } | 119 | } |
| 122 | 120 | ||
| 123 | void SetCameraRotation(FuzzedDataProvider& fdp) | 121 | void SetCameraRotation(FuzzedDataProvider& fdp) |
| 124 | { | 122 | { |
| 125 | - g_hStreamRepeat->SetCameraRotation(fdp.ConsumeBool(), fdp.ConsumeIntegral<int32_t>()); | 123 | + GetHStreamRepeat().SetCameraRotation(fdp.ConsumeBool(), fdp.ConsumeIntegral<int32_t>()); |
| 126 | } | 124 | } |
| 127 | 125 | ||
| 128 | void SetCameraApi(FuzzedDataProvider& fdp) | 126 | void SetCameraApi(FuzzedDataProvider& fdp) |
| 129 | { | 127 | { |
| 130 | - g_hStreamRepeat->SetCameraApi(fdp.ConsumeIntegral<uint32_t>()); | 128 | + GetHStreamRepeat().SetCameraApi(fdp.ConsumeIntegral<uint32_t>()); |
| 131 | } | 129 | } |
| 132 | 130 | ||
| 133 | void GetMirror(FuzzedDataProvider& fdp) | 131 | void GetMirror(FuzzedDataProvider& fdp) |
| 134 | { | 132 | { |
| 135 | bool isEnable; | 133 | bool isEnable; |
| 136 | - g_hStreamRepeat->GetMirror(isEnable); | 134 | + GetHStreamRepeat().GetMirror(isEnable); |
| 137 | } | 135 | } |
| 138 | 136 | ||
| 139 | void UnSetCallback(FuzzedDataProvider& fdp) | 137 | void UnSetCallback(FuzzedDataProvider& fdp) |
| 140 | { | 138 | { |
| 141 | - g_hStreamRepeat->UnSetCallback(); | 139 | + GetHStreamRepeat().UnSetCallback(); |
| 142 | } | 140 | } |
| 143 | 141 | ||
| 144 | void SetOutputSettings(FuzzedDataProvider& fdp) | 142 | void SetOutputSettings(FuzzedDataProvider& fdp) |
| @@ -147,53 +145,53 @@ void SetOutputSettings(FuzzedDataProvider& fdp) | |||
| 147 | fdp.ConsumeIntegral<int32_t>(), fdp.ConsumeBool(), | 145 | fdp.ConsumeIntegral<int32_t>(), fdp.ConsumeBool(), |
| 148 | { fdp.ConsumeFloatingPoint<float>(), fdp.ConsumeFloatingPoint<float>(), fdp.ConsumeFloatingPoint<float>() }, | 146 | { fdp.ConsumeFloatingPoint<float>(), fdp.ConsumeFloatingPoint<float>(), fdp.ConsumeFloatingPoint<float>() }, |
| 149 | fdp.ConsumeBool(), fdp.ConsumeIntegral<int32_t>() }; | 147 | fdp.ConsumeBool(), fdp.ConsumeIntegral<int32_t>() }; |
| 150 | - g_hStreamRepeat->SetOutputSettings(setting); | 148 | + GetHStreamRepeat().SetOutputSettings(setting); |
| 151 | } | 149 | } |
| 152 | 150 | ||
| 153 | void GetSupportedVideoCodecTypes(FuzzedDataProvider& fdp) | 151 | void GetSupportedVideoCodecTypes(FuzzedDataProvider& fdp) |
| 154 | { | 152 | { |
| 155 | std::vector<int32_t> supportedTypes; | 153 | std::vector<int32_t> supportedTypes; |
| 156 | - g_hStreamRepeat->GetSupportedVideoCodecTypes(supportedTypes); | 154 | + GetHStreamRepeat().GetSupportedVideoCodecTypes(supportedTypes); |
| 157 | } | 155 | } |
| 158 | 156 | ||
| 159 | void SetBandwidthCompression(FuzzedDataProvider& fdp) | 157 | void SetBandwidthCompression(FuzzedDataProvider& fdp) |
| 160 | { | 158 | { |
| 161 | - g_hStreamRepeat->SetBandwidthCompression(fdp.ConsumeBool()); | 159 | + GetHStreamRepeat().SetBandwidthCompression(fdp.ConsumeBool()); |
| 162 | } | 160 | } |
| 163 | 161 | ||
| 164 | void RemoveDeferredSurface(FuzzedDataProvider& fdp) | 162 | void RemoveDeferredSurface(FuzzedDataProvider& fdp) |
| 165 | { | 163 | { |
| 166 | - g_hStreamRepeat->RemoveDeferredSurface(); | 164 | + GetHStreamRepeat().RemoveDeferredSurface(); |
| 167 | } | 165 | } |
| 168 | 166 | ||
| 169 | void HStreamRepeatFuzzTest1(FuzzedDataProvider& fdp) | 167 | void HStreamRepeatFuzzTest1(FuzzedDataProvider& fdp) |
| 170 | { | 168 | { |
| 171 | std::shared_ptr<OHOS::Camera::CameraMetadata> cameraAbility; | 169 | std::shared_ptr<OHOS::Camera::CameraMetadata> cameraAbility; |
| 172 | sptr<OHOS::HDI::Camera::V1_0::IStreamOperator> streamOperator; | 170 | sptr<OHOS::HDI::Camera::V1_0::IStreamOperator> streamOperator; |
| 173 | - g_hStreamRepeat->LinkInput(streamOperator, cameraAbility); | 171 | + GetHStreamRepeat().LinkInput(streamOperator, cameraAbility); |
| 174 | StreamInfo_V1_5 streamInfo; | 172 | StreamInfo_V1_5 streamInfo; |
| 175 | - g_hStreamRepeat->SetVideoStreamInfo(streamInfo); | 173 | + GetHStreamRepeat().SetVideoStreamInfo(streamInfo); |
| 176 | - g_hStreamRepeat->SetStreamInfo(streamInfo); | 174 | + GetHStreamRepeat().SetStreamInfo(streamInfo); |
| 177 | sptr<OHOS::IBufferProducer> metaProducer; | 175 | sptr<OHOS::IBufferProducer> metaProducer; |
| 178 | - g_hStreamRepeat->SetMetaProducer(metaProducer); | 176 | + GetHStreamRepeat().SetMetaProducer(metaProducer); |
| 179 | SketchStatus status = SketchStatus::STOPED; | 177 | SketchStatus status = SketchStatus::STOPED; |
| 180 | - g_hStreamRepeat->UpdateSketchStatus(status); | 178 | + GetHStreamRepeat().UpdateSketchStatus(status); |
| 181 | std::shared_ptr<OHOS::Camera::CameraMetadata> settings; | 179 | std::shared_ptr<OHOS::Camera::CameraMetadata> settings; |
| 182 | settings = std::make_shared<OHOS::Camera::CameraMetadata>(ITEMCOUNT, DATASIZE); | 180 | settings = std::make_shared<OHOS::Camera::CameraMetadata>(ITEMCOUNT, DATASIZE); |
| 183 | - g_hStreamRepeat->StartSketchStream(settings); | 181 | + GetHStreamRepeat().StartSketchStream(settings); |
| 184 | camera_position_enum_t cameraPosition = OHOS_CAMERA_POSITION_FRONT; | 182 | camera_position_enum_t cameraPosition = OHOS_CAMERA_POSITION_FRONT; |
| 185 | - g_hStreamRepeat->SetUsedAsPosition(cameraPosition); | 183 | + GetHStreamRepeat().SetUsedAsPosition(cameraPosition); |
| 186 | - g_hStreamRepeat->Start(settings, fdp.ConsumeBool()); | 184 | + GetHStreamRepeat().Start(settings, fdp.ConsumeBool()); |
| 187 | - g_hStreamRepeat->Start(); | 185 | + GetHStreamRepeat().Start(); |
| 188 | - g_hStreamRepeat->OnFrameStarted(); | 186 | + GetHStreamRepeat().OnFrameStarted(); |
| 189 | - g_hStreamRepeat->OnFrameEnded(fdp.ConsumeIntegral<int32_t>()); | 187 | + GetHStreamRepeat().OnFrameEnded(fdp.ConsumeIntegral<int32_t>()); |
| 190 | CaptureEndedInfoExt captureEndedInfo = { 1, 100, true, "video123" }; | 188 | CaptureEndedInfoExt captureEndedInfo = { 1, 100, true, "video123" }; |
| 191 | - g_hStreamRepeat->OnDeferredVideoEnhancementInfo(captureEndedInfo); | 189 | + GetHStreamRepeat().OnDeferredVideoEnhancementInfo(captureEndedInfo); |
| 192 | - g_hStreamRepeat->OnFrameError(fdp.ConsumeIntegral<int32_t>()); | 190 | + GetHStreamRepeat().OnFrameError(fdp.ConsumeIntegral<int32_t>()); |
| 193 | - g_hStreamRepeat->OnSketchStatusChanged(status); | 191 | + GetHStreamRepeat().OnSketchStatusChanged(status); |
| 194 | - g_hStreamRepeat->Stop(); | 192 | + GetHStreamRepeat().Stop(); |
| 195 | - g_hStreamRepeat->Release(); | 193 | + GetHStreamRepeat().Release(); |
| 196 | - g_hStreamRepeat->ReleaseStream(fdp.ConsumeBool()); | 194 | + GetHStreamRepeat().ReleaseStream(fdp.ConsumeBool()); |
| 197 | } | 195 | } |
| 198 | 196 | ||
| 199 | void HStreamRepeatFuzzTest2(FuzzedDataProvider& fdp) | 197 | void HStreamRepeatFuzzTest2(FuzzedDataProvider& fdp) |
| @@ -201,38 +199,38 @@ void HStreamRepeatFuzzTest2(FuzzedDataProvider& fdp) | |||
| 201 | sptr<Surface> photoSurface = Surface::CreateSurfaceAsConsumer("hstreamrepeat"); | 199 | sptr<Surface> photoSurface = Surface::CreateSurfaceAsConsumer("hstreamrepeat"); |
| 202 | CHECK_RETURN_ELOG(!photoSurface, "CreateSurfaceAsConsumer Error"); | 200 | CHECK_RETURN_ELOG(!photoSurface, "CreateSurfaceAsConsumer Error"); |
| 203 | sptr<IBufferProducer> producer = photoSurface->GetProducer(); | 201 | sptr<IBufferProducer> producer = photoSurface->GetProducer(); |
| 204 | - g_hStreamRepeat->AddDeferredSurface(producer); | 202 | + GetHStreamRepeat().AddDeferredSurface(producer); |
| 205 | - g_hStreamRepeat->SetFrameRate(fdp.ConsumeIntegral<int32_t>(), fdp.ConsumeIntegral<int32_t>()); | 203 | + GetHStreamRepeat().SetFrameRate(fdp.ConsumeIntegral<int32_t>(), fdp.ConsumeIntegral<int32_t>()); |
| 206 | - g_hStreamRepeat->SetMirror(fdp.ConsumeBool()); | 204 | + GetHStreamRepeat().SetMirror(fdp.ConsumeBool()); |
| 207 | - g_hStreamRepeat->SetMirrorForLivePhoto(fdp.ConsumeBool(), fdp.ConsumeIntegral<int32_t>()); | 205 | + GetHStreamRepeat().SetMirrorForLivePhoto(fdp.ConsumeBool(), fdp.ConsumeIntegral<int32_t>()); |
| 208 | uint8_t randomNum = fdp.ConsumeIntegral<uint8_t>(); | 206 | uint8_t randomNum = fdp.ConsumeIntegral<uint8_t>(); |
| 209 | std::vector<std::int32_t> test = { 0, 90, 180, 270, 360 }; | 207 | std::vector<std::int32_t> test = { 0, 90, 180, 270, 360 }; |
| 210 | std::int32_t rotation(test[randomNum % test.size()]); | 208 | std::int32_t rotation(test[randomNum % test.size()]); |
| 211 | - g_hStreamRepeat->SetCameraRotation(fdp.ConsumeBool(), rotation); | 209 | + GetHStreamRepeat().SetCameraRotation(fdp.ConsumeBool(), rotation); |
| 212 | - g_hStreamRepeat->SetCameraApi(fdp.ConsumeIntegral<uint32_t>()); | 210 | + GetHStreamRepeat().SetCameraApi(fdp.ConsumeIntegral<uint32_t>()); |
| 213 | std::string deviceClass; | 211 | std::string deviceClass; |
| 214 | - g_hStreamRepeat->SetPreviewRotation(deviceClass); | 212 | + GetHStreamRepeat().SetPreviewRotation(deviceClass); |
| 215 | - g_hStreamRepeat->UpdateSketchRatio(fdp.ConsumeBool()); | 213 | + GetHStreamRepeat().UpdateSketchRatio(fdp.ConsumeBool()); |
| 216 | - g_hStreamRepeat->GetSketchStream(); | 214 | + GetHStreamRepeat().GetSketchStream(); |
| 217 | - g_hStreamRepeat->GetRepeatStreamType(); | 215 | + GetHStreamRepeat().GetRepeatStreamType(); |
| 218 | - g_hStreamRepeat->SyncTransformToSketch(); | 216 | + GetHStreamRepeat().SyncTransformToSketch(); |
| 219 | - g_hStreamRepeat->SetStreamTransform(fdp.ConsumeIntegral<int>()); | 217 | + GetHStreamRepeat().SetStreamTransform(fdp.ConsumeIntegral<int>()); |
| 220 | camera_position_enum_t cameraPosition = OHOS_CAMERA_POSITION_FRONT; | 218 | camera_position_enum_t cameraPosition = OHOS_CAMERA_POSITION_FRONT; |
| 221 | int32_t sensorOrientation = ((fdp.ConsumeIntegral<int32_t>() % ROTATION_360) + ROTATION_360) % ROTATION_360; | 219 | int32_t sensorOrientation = ((fdp.ConsumeIntegral<int32_t>() % ROTATION_360) + ROTATION_360) % ROTATION_360; |
| 222 | - g_hStreamRepeat->ProcessVerticalCameraPosition(sensorOrientation, cameraPosition); | 220 | + GetHStreamRepeat().ProcessVerticalCameraPosition(sensorOrientation, cameraPosition); |
| 223 | int32_t streamRotation = fdp.ConsumeIntegral<int32_t>(); | 221 | int32_t streamRotation = fdp.ConsumeIntegral<int32_t>(); |
| 224 | - g_hStreamRepeat->ProcessCameraPosition(streamRotation, cameraPosition); | 222 | + GetHStreamRepeat().ProcessCameraPosition(streamRotation, cameraPosition); |
| 225 | - g_hStreamRepeat->ProcessFixedTransform(sensorOrientation, cameraPosition); | 223 | + GetHStreamRepeat().ProcessFixedTransform(sensorOrientation, cameraPosition); |
| 226 | - g_hStreamRepeat->ProcessFixedDiffDeviceTransform(sensorOrientation, cameraPosition); | 224 | + GetHStreamRepeat().ProcessFixedDiffDeviceTransform(sensorOrientation, cameraPosition); |
| 227 | - g_hStreamRepeat->ProcessCameraSetRotation(sensorOrientation); | 225 | + GetHStreamRepeat().ProcessCameraSetRotation(sensorOrientation); |
| 228 | camera_position_enum_t cameraPosition1 = OHOS_CAMERA_POSITION_BACK; | 226 | camera_position_enum_t cameraPosition1 = OHOS_CAMERA_POSITION_BACK; |
| 229 | int32_t sensorOrientation1 = ((fdp.ConsumeIntegral<int32_t>() % ROTATION_360) + ROTATION_360) % ROTATION_360; | 227 | int32_t sensorOrientation1 = ((fdp.ConsumeIntegral<int32_t>() % ROTATION_360) + ROTATION_360) % ROTATION_360; |
| 230 | - g_hStreamRepeat->ProcessVerticalCameraPosition(sensorOrientation1, cameraPosition1); | 228 | + GetHStreamRepeat().ProcessVerticalCameraPosition(sensorOrientation1, cameraPosition1); |
| 231 | int32_t streamRotation1 = fdp.ConsumeIntegral<int32_t>(); | 229 | int32_t streamRotation1 = fdp.ConsumeIntegral<int32_t>(); |
| 232 | - g_hStreamRepeat->ProcessCameraPosition(streamRotation1, cameraPosition1); | 230 | + GetHStreamRepeat().ProcessCameraPosition(streamRotation1, cameraPosition1); |
| 233 | - g_hStreamRepeat->ProcessFixedTransform(sensorOrientation1, cameraPosition1); | 231 | + GetHStreamRepeat().ProcessFixedTransform(sensorOrientation1, cameraPosition1); |
| 234 | - g_hStreamRepeat->ProcessFixedDiffDeviceTransform(sensorOrientation1, cameraPosition1); | 232 | + GetHStreamRepeat().ProcessFixedDiffDeviceTransform(sensorOrientation1, cameraPosition1); |
| 235 | - g_hStreamRepeat->ProcessCameraSetRotation(sensorOrientation1); | 233 | + GetHStreamRepeat().ProcessCameraSetRotation(sensorOrientation1); |
| 236 | } | 234 | } |
| 237 | 235 | ||
| 238 | void HStreamRepeatFuzzTest3(FuzzedDataProvider& fdp) | 236 | void HStreamRepeatFuzzTest3(FuzzedDataProvider& fdp) |
| @@ -242,20 +240,20 @@ void HStreamRepeatFuzzTest3(FuzzedDataProvider& fdp) | |||
| 242 | sptr<IBufferProducer> producer = photoSurface->GetProducer(); | 240 | sptr<IBufferProducer> producer = photoSurface->GetProducer(); |
| 243 | std::shared_ptr<OHOS::Camera::CameraMetadata> settings; | 241 | std::shared_ptr<OHOS::Camera::CameraMetadata> settings; |
| 244 | settings = std::make_shared<OHOS::Camera::CameraMetadata>(ITEMCOUNT, DATASIZE); | 242 | settings = std::make_shared<OHOS::Camera::CameraMetadata>(ITEMCOUNT, DATASIZE); |
| 245 | - g_hStreamRepeat->OperatePermissionCheck(fdp.ConsumeIntegral<int>()); | 243 | + GetHStreamRepeat().OperatePermissionCheck(fdp.ConsumeIntegral<int>()); |
| 246 | - g_hStreamRepeat->OpenVideoDfxSwitch(settings); | 244 | + GetHStreamRepeat().OpenVideoDfxSwitch(settings); |
| 247 | - g_hStreamRepeat->EnableSecure(fdp.ConsumeBool()); | 245 | + GetHStreamRepeat().EnableSecure(fdp.ConsumeBool()); |
| 248 | - g_hStreamRepeat->UpdateVideoSettings(settings); | 246 | + GetHStreamRepeat().UpdateVideoSettings(settings); |
| 249 | - g_hStreamRepeat->UpdateFrameRateSettings(settings); | 247 | + GetHStreamRepeat().UpdateFrameRateSettings(settings); |
| 250 | std::shared_ptr<OHOS::Camera::CameraMetadata> dynamicSetting; | 248 | std::shared_ptr<OHOS::Camera::CameraMetadata> dynamicSetting; |
| 251 | - g_hStreamRepeat->UpdateFrameMuteSettings(settings, dynamicSetting); | 249 | + GetHStreamRepeat().UpdateFrameMuteSettings(settings, dynamicSetting); |
| 252 | 250 | ||
| 253 | - g_hStreamRepeat->UpdateBeautySettings(settings); | 251 | + GetHStreamRepeat().UpdateBeautySettings(settings); |
| 254 | - g_hStreamRepeat->CancelNotification(); | 252 | + GetHStreamRepeat().CancelNotification(); |
| 255 | - g_hStreamRepeat->IsNeedBeautyNotification(); | 253 | + GetHStreamRepeat().IsNeedBeautyNotification(); |
| 256 | 254 | ||
| 257 | sptr<IStreamCapture> photoOutput = nullptr; | 255 | sptr<IStreamCapture> photoOutput = nullptr; |
| 258 | - g_hStreamRepeat->AttachMetaSurface(producer, fdp.ConsumeIntegral<int32_t>()); | 256 | + GetHStreamRepeat().AttachMetaSurface(producer, fdp.ConsumeIntegral<int32_t>()); |
| 259 | std::shared_ptr<StreamRepeatCallbackStub> callback = std::make_shared<HStreamRepeatCallbackStubDemo>(); | 257 | std::shared_ptr<StreamRepeatCallbackStub> callback = std::make_shared<HStreamRepeatCallbackStubDemo>(); |
| 260 | MessageParcel data; | 258 | MessageParcel data; |
| 261 | MessageParcel reply; | 259 | MessageParcel reply; |
| @@ -275,21 +273,17 @@ void Init() | |||
| 275 | { | 273 | { |
| 276 | CHECK_RETURN_ELOG(!TestToken().GetAllCameraPermission(), "Get permission fail"); | 274 | CHECK_RETURN_ELOG(!TestToken().GetAllCameraPermission(), "Get permission fail"); |
| 277 | sptr<IConsumerSurface> photoSurface = IConsumerSurface::Create(); | 275 | sptr<IConsumerSurface> photoSurface = IConsumerSurface::Create(); |
| 278 | - sptr<IBufferProducer> producer = photoSurface->GetProducer(); | 276 | + g_producer = photoSurface->GetProducer(); |
| 279 | - g_hStreamRepeat = | ||
| 280 | - new (std::nothrow) HStreamRepeat(producer, PHOTO_FORMAT, PHOTO_WIDTH, PHOTO_HEIGHT, RepeatStreamType::PREVIEW); | ||
| 281 | } | 277 | } |
| 282 | 278 | ||
| 283 | void Test(FuzzedDataProvider& fdp) | 279 | void Test(FuzzedDataProvider& fdp) |
| 284 | { | 280 | { |
| 285 | - CHECK_RETURN_ELOG(g_hStreamRepeat == nullptr, "g_hStreamMetadata is nullptr"); | ||
| 286 | auto func = fdp.PickValueInArray({ | 281 | auto func = fdp.PickValueInArray({ |
| 287 | Start, | 282 | Start, |
| 288 | Stop, | 283 | Stop, |
| 289 | Release, | 284 | Release, |
| 290 | SetCallback, | 285 | SetCallback, |
| 291 | AddDeferredSurface, | 286 | AddDeferredSurface, |
| 292 | - ForkSketchStreamRepeat, | ||
| 293 | RemoveSketchStreamRepeat, | 287 | RemoveSketchStreamRepeat, |
| 294 | UpdateSketchRatio, | 288 | UpdateSketchRatio, |
| 295 | SetFrameRate, | 289 | SetFrameRate, |