• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifndef FACTORY_RESET_H
16 #define FACTORY_RESET_H
17 
18 #include <iostream>
19 #include <string>
20 #include <functional>
21 #include "updater/updater.h"
22 #include "updater_main.h"
23 
24 namespace Updater {
25 using CommonResetPostFunc = std::function<int(FactoryResetMode)>;
26 using FactoryResetPreFunc = std::function<int(FactoryResetMode)>;
27 using FactoryResetPostFunc = std::function<int(FactoryResetMode, int)>;
28 class FactoryResetProcess {
29     DISALLOW_COPY_MOVE(FactoryResetProcess);
30 public:
31     FactoryResetProcess();
32     virtual ~FactoryResetProcess() = default;
33 
34     static FactoryResetProcess &GetInstance();
35     void RegisterCommonResetPostFunc(CommonResetPostFunc ptr);
36     void RegisterFactoryResetPreFunc(FactoryResetPreFunc ptr);
37     void RegisterFactoryResetPostFunc(FactoryResetPostFunc ptr);
38     int DoFactoryReset(FactoryResetMode mode, const std::string &path);
39 
40 private:
41     CommonResetPostFunc CommonResetPostFunc_ = nullptr;
42     FactoryResetPreFunc FactoryResetPreFunc_ = nullptr;
43     FactoryResetPostFunc FactoryResetPostFunc_ = nullptr;
44 };
45 
46 } // namespace Updater
47 #endif // FACTORY_RESET_H