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 COAUTH_SERVICE_H 17 #define COAUTH_SERVICE_H 18 19 #include <system_ability.h> 20 #include <system_ability_definition.h> 21 #include "coauth_stub.h" 22 #include "iset_prop_callback.h" 23 #include "auth_attributes.h" 24 #include "coauth_info_define.h" 25 #include "auth_res_manager.h" 26 #include "coauth_manager.h" 27 #include "auth_info.h" 28 #include "coauth_hilog_wrapper.h" 29 #include "coauth_errors.h" 30 31 namespace OHOS { 32 namespace UserIAM { 33 namespace CoAuth { 34 const int CHECK_TIMES = 3; 35 const int SLEEP_TIME = 3; 36 enum class CoAuthRunningState { STATE_STOPPED, STATE_RUNNING }; 37 38 class CoAuthService : public SystemAbility, public CoAuthStub { 39 public: 40 DECLEAR_SYSTEM_ABILITY(CoAuthService); 41 explicit CoAuthService(int32_t systemAbilityId, bool runOnCreate = false); 42 virtual ~CoAuthService() override; 43 void OnStart() override; 44 void OnStop() override; 45 virtual uint64_t Register(std::shared_ptr<ResAuthExecutor> executorInfo, 46 const sptr<ResIExecutorCallback> &callback) override; 47 virtual void QueryStatus(ResAuthExecutor &executorInfo, const sptr<ResIQueryCallback> &callback) override; 48 virtual void BeginSchedule(uint64_t scheduleId, AuthInfo &authInfo, const sptr<ICoAuthCallback> &callback) override; 49 virtual int32_t Cancel(uint64_t scheduleId) override; 50 virtual int32_t GetExecutorProp(ResAuthAttributes &conditions, std::shared_ptr<ResAuthAttributes> values) override; 51 virtual void SetExecutorProp(ResAuthAttributes &conditions, const sptr<ISetPropCallback> &callback) override; 52 53 private: 54 CoAuthRunningState state_ = CoAuthRunningState::STATE_STOPPED; 55 AuthResManager authResMgr_; 56 CoAuthManager coAuthMgr_; 57 }; 58 } // namespace CoAuth 59 } // namespace UserIAM 60 } // namespace OHOS 61 #endif // COAUTH_SERVICE_H 62