1 /* 2 * Copyright (c) 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 FIRMWARE_CHECK_DATA_PROCESSOR_H 17 #define FIRMWARE_CHECK_DATA_PROCESSOR_H 18 19 #include "check_result.h" 20 #include "firmware_common.h" 21 #include "firmware_component.h" 22 #include "firmware_preferences_utils.h" 23 #include "new_version_info.h" 24 25 namespace OHOS { 26 namespace UpdateEngine { 27 class FirmwareCheckDataProcessor { 28 public: 29 FirmwareCheckDataProcessor(); 30 virtual ~FirmwareCheckDataProcessor(); 31 32 void SetCheckResult( 33 CheckStatus status, const Duration &duration, const std::vector<FirmwareComponent> &componentList); 34 bool IsCheckFailed(); 35 bool IsSameWithDb(); 36 bool HasNewVersion(); 37 void BuildCheckResult(CheckResult &checkResult); 38 bool IsUpdateOnStatus(); 39 40 protected: HandleUndoneEvent()41 virtual void HandleUndoneEvent() {} 42 43 protected: 44 std::shared_ptr<FirmwarePreferencesUtil> preferencesUtil_ = 45 DelayedSingleton<FirmwarePreferencesUtil>::GetInstance(); 46 47 private: 48 void HandleCheckResult(); 49 void HandleNewVersion(); 50 void HandleNoNewVersion(); 51 bool IsVersionSameWithDb(); 52 void UpdateFirmwareComponent(); 53 bool HasUndoneTask(); 54 void RefreshPollingCycle(); 55 56 CombinationType GetCombinationType(); 57 void BuildComponentSPath(); 58 void BuildVersionDigest(NewVersionInfo &newVersionInfo, const std::vector<FirmwareComponent> &componentList); 59 60 private: 61 std::vector<FirmwareComponent> componentList_; 62 Duration duration_; 63 bool isSameWithDb_ = true; 64 CheckStatus status_ = CheckStatus::CHECK_FAIL; 65 }; 66 } // namespace UpdateEngine 67 } // namespace OHOS 68 #endif // FIRMWARE_CHECK_DATA_PROCESSOR_H