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 DEVATTEST_SERVICE_H 17#define DEVATTEST_SERVICE_H 18 19#include <string> 20#include "system_ability.h" 21#include "singleton.h" 22#include "system_ability_ondemand_reason.h" 23#include "event_handler.h" 24#include "devattest_service_stub.h" 25 26namespace OHOS { 27namespace DevAttest { 28enum class ServiceRunningState { 29 STATE_NOT_START, 30 STATE_RUNNING 31}; 32 33class DevAttestService : public SystemAbility, public DevAttestServiceStub { 34 DECLARE_SYSTEM_ABILITY(DevAttestService); 35 DECLARE_DELAYED_SINGLETON(DevAttestService); 36 37public: 38 DevAttestService(int32_t systemAbilityId, bool runOnCreate = true); 39 void OnStart(const SystemAbilityOnDemandReason& startReason) override; 40 void OnStop() override; 41 int32_t OnIdle(const SystemAbilityOnDemandReason& idleReason) override; 42 void DelayUnloadTask(void) override; 43 ServiceRunningState QueryServiceState() const 44 { 45 return state_; 46 } 47 int32_t GetAttestStatus(AttestResultInfo &attestResultInfo) override; 48 49private: 50 bool Init(); 51 ServiceRunningState state_ = ServiceRunningState::STATE_NOT_START; 52 bool registerToSa_ = false; 53 int32_t CopyAttestResult(int32_t *resultArray, AttestResultInfo &attestResultInfo); 54 std::shared_ptr<AppExecFwk::EventHandler> unloadHandler_ = nullptr; 55}; 56} // end of DevAttest 57} // end of OHOS 58#endif