15bbf6e98Sopenharmony_ci/*
25bbf6e98Sopenharmony_ci * Copyright (C) 2022 Huawei Device Co., Ltd.
35bbf6e98Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
45bbf6e98Sopenharmony_ci * you may not use this file except in compliance with the License.
55bbf6e98Sopenharmony_ci * You may obtain a copy of the License at
65bbf6e98Sopenharmony_ci *
75bbf6e98Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
85bbf6e98Sopenharmony_ci *
95bbf6e98Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
105bbf6e98Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
115bbf6e98Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
125bbf6e98Sopenharmony_ci * See the License for the specific language governing permissions and
135bbf6e98Sopenharmony_ci * limitations under the License.
145bbf6e98Sopenharmony_ci */
155bbf6e98Sopenharmony_ci
165bbf6e98Sopenharmony_ci#ifndef DEVATTEST_SERVICE_H
175bbf6e98Sopenharmony_ci#define DEVATTEST_SERVICE_H
185bbf6e98Sopenharmony_ci
195bbf6e98Sopenharmony_ci#include <string>
205bbf6e98Sopenharmony_ci#include "system_ability.h"
215bbf6e98Sopenharmony_ci#include "singleton.h"
225bbf6e98Sopenharmony_ci#include "system_ability_ondemand_reason.h"
235bbf6e98Sopenharmony_ci#include "event_handler.h"
245bbf6e98Sopenharmony_ci#include "devattest_service_stub.h"
255bbf6e98Sopenharmony_ci
265bbf6e98Sopenharmony_cinamespace OHOS {
275bbf6e98Sopenharmony_cinamespace DevAttest {
285bbf6e98Sopenharmony_cienum class ServiceRunningState {
295bbf6e98Sopenharmony_ci    STATE_NOT_START,
305bbf6e98Sopenharmony_ci    STATE_RUNNING
315bbf6e98Sopenharmony_ci};
325bbf6e98Sopenharmony_ci
335bbf6e98Sopenharmony_ciclass DevAttestService : public SystemAbility, public DevAttestServiceStub {
345bbf6e98Sopenharmony_ci    DECLARE_SYSTEM_ABILITY(DevAttestService);
355bbf6e98Sopenharmony_ci    DECLARE_DELAYED_SINGLETON(DevAttestService);
365bbf6e98Sopenharmony_ci
375bbf6e98Sopenharmony_cipublic:
385bbf6e98Sopenharmony_ci    DevAttestService(int32_t systemAbilityId, bool runOnCreate = true);
395bbf6e98Sopenharmony_ci    void OnStart(const SystemAbilityOnDemandReason& startReason) override;
405bbf6e98Sopenharmony_ci    void OnStop() override;
415bbf6e98Sopenharmony_ci    int32_t OnIdle(const SystemAbilityOnDemandReason& idleReason) override;
425bbf6e98Sopenharmony_ci    void DelayUnloadTask(void) override;
435bbf6e98Sopenharmony_ci    ServiceRunningState QueryServiceState() const
445bbf6e98Sopenharmony_ci    {
455bbf6e98Sopenharmony_ci        return state_;
465bbf6e98Sopenharmony_ci    }
475bbf6e98Sopenharmony_ci    int32_t GetAttestStatus(AttestResultInfo &attestResultInfo) override;
485bbf6e98Sopenharmony_ci
495bbf6e98Sopenharmony_ciprivate:
505bbf6e98Sopenharmony_ci    bool Init();
515bbf6e98Sopenharmony_ci    ServiceRunningState state_ = ServiceRunningState::STATE_NOT_START;
525bbf6e98Sopenharmony_ci    bool registerToSa_ = false;
535bbf6e98Sopenharmony_ci    int32_t CopyAttestResult(int32_t *resultArray, AttestResultInfo &attestResultInfo);
545bbf6e98Sopenharmony_ci    std::shared_ptr<AppExecFwk::EventHandler> unloadHandler_ = nullptr;
555bbf6e98Sopenharmony_ci};
565bbf6e98Sopenharmony_ci} // end of DevAttest
575bbf6e98Sopenharmony_ci} // end of OHOS
585bbf6e98Sopenharmony_ci#endif