1 /* 2 * Copyright (c) 2023-2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef OHOS_CAMERA_DPS_BACKGROUND_STRATEGY_H 17 #define OHOS_CAMERA_DPS_BACKGROUND_STRATEGY_H 18 19 #include <cstdint> 20 #include <memory> 21 22 #include "istrategy.h" 23 #include "photo_job_repository.h" 24 25 namespace OHOS { 26 namespace CameraStandard { 27 namespace DeferredProcessing { 28 class BackgroundStrategy : public IStrategy { 29 public: 30 BackgroundStrategy(const std::shared_ptr<PhotoJobRepository>& repository); 31 ~BackgroundStrategy(); 32 33 DeferredPhotoWorkPtr GetWork() override; 34 DeferredPhotoJobPtr GetJob() override; 35 ExecutionMode GetExecutionMode() override; 36 HdiStatus GetHdiStatus(); 37 void NotifyPressureLevelChanged(SystemPressureLevel level); 38 void NotifyHdiStatusChanged(HdiStatus status); 39 void NotifyMediaLibStatusChanged(MediaLibraryStatus status); 40 void NotifyCameraStatusChanged(CameraSessionStatus status); 41 42 private: 43 void StartTrailing(uint64_t duration); 44 void StopTrailing(); 45 void FlashTrailingState(); 46 47 uint64_t trailingStartTimeStamp_ {DEFAULT_TRAILING_TIME}; 48 uint64_t remainingTrailingTime_ {DEFAULT_TRAILING_TIME}; 49 bool isInTrailing_ {false}; 50 CameraSessionStatus cameraSessionStatus_ {CameraSessionStatus::NORMAL_CAMERA_CLOSED}; 51 HdiStatus hdiStatus_ {HdiStatus::HDI_DISCONNECTED}; 52 MediaLibraryStatus mediaLibraryStatus_ {MediaLibraryStatus::MEDIA_LIBRARY_AVAILABLE}; 53 SystemPressureLevel systemPressureLevel_ {SystemPressureLevel::NOMINAL}; 54 std::shared_ptr<PhotoJobRepository> repository_; 55 }; 56 } // namespace DeferredProcessing 57 } // namespace CameraStandard 58 } // namespace OHOS 59 #endif // OHOS_CAMERA_DPS_BACKGROUND_STRATEGY_H