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