xref: /developtools/hdc/src/host/host_updater.h (revision cc290419)
1/*
2 * Copyright (C) 2022 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 HDC_HOST_UPDATER_H
17#define HDC_HOST_UPDATER_H
18
19#include "transfer.h"
20#include "translate.h"
21
22namespace Hdc {
23class HostUpdater : public HdcTransferBase {
24public:
25    explicit HostUpdater(HTaskInfo hTaskInfo);
26    virtual ~HostUpdater();
27    bool CommandDispatch(const uint16_t command, uint8_t *payload, const int payloadSize) override;
28    static bool CheckMatchUpdate(const std::string &input, TranslateCommand::FormatCommand &outCmd);
29    static bool ConfirmCommand(const string &commandIn, bool &closeInput);
30
31protected:
32    void CheckMaster(CtxFile *context) override;
33
34private:
35    bool BeginTransfer(const std::string &function, const uint8_t *payload, int payloadSize, size_t minParam,
36    size_t fileIndex);
37    bool CheckUpdateContinue(const uint16_t command, const uint8_t *payload, int payloadSize);
38    bool RunQueue(CtxFile &context);
39    void ProcessProgress(uint8_t percentage);
40    void SendRawData(std::string rawData) const;
41    bool CheckCmd(HdcCommand command, uint8_t *payload, int payloadSize, size_t paramCount);
42
43private:
44    bool sendProgress_ = false;
45};
46}
47#endif