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 <map> 21 #include "system_ability.h" 22 #include "iremote_stub.h" 23 #include "iremote_object.h" 24 #include "singleton.h" 25 26 #include "devattest_interface.h" 27 #include "devattest_service_stub.h" 28 #include "system_ability_status_change_stub.h" 29 #include "attest_result_info.h" 30 31 namespace OHOS { 32 namespace DevAttest { 33 enum class ServiceRunningState { 34 STATE_NOT_START, 35 STATE_RUNNING 36 }; 37 38 class DevAttestService : public SystemAbility, public DevAttestServiceStub { 39 DECLARE_SYSTEM_ABILITY(DevAttestService); 40 DECLARE_DELAYED_SINGLETON(DevAttestService); 41 42 public: 43 DevAttestService(int32_t systemAbilityId, bool runOnCreate = true); 44 void OnStart() override; 45 void OnStop() override; QueryServiceState()46 ServiceRunningState QueryServiceState() const 47 { 48 return state_; 49 } 50 int32_t GetAttestStatus(AttestResultInfo &attestResultInfo) override; 51 52 private: 53 bool Init(); 54 ServiceRunningState state_ = ServiceRunningState::STATE_NOT_START; 55 bool registerToSa_ = false; 56 bool CheckPermission(const std::string &packageName); 57 const int32_t NETMANAGER_SAMGR_ID = 1151; 58 int32_t CopyAttestResult(int32_t *resultArray, AttestResultInfo &attestResultInfo); 59 }; 60 } // end of DevAttest 61 } // end of OHOS 62 #endif