1 /* 2 * Copyright (c) 2022-2023 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 PIN_AUTH_SERVICE_H 17 #define PIN_AUTH_SERVICE_H 18 19 #include <mutex> 20 #include <map> 21 22 #include "nocopyable.h" 23 #include "system_ability.h" 24 #include "system_ability_definition.h" 25 26 #include "pin_auth_stub.h" 27 28 namespace OHOS { 29 namespace UserIam { 30 namespace PinAuth { 31 class PinAuthService : public SystemAbility, public PinAuthStub { 32 public: 33 DECLEAR_SYSTEM_ABILITY(PinAuthService); 34 PinAuthService(); 35 static std::shared_ptr<PinAuthService> GetInstance(); 36 37 bool RegisterInputer(const sptr<InputerGetData> &inputer) override; 38 void UnRegisterInputer() override; 39 bool CheckPermission(const std::string &permission); 40 41 protected: 42 // SystemAbility 43 void OnStart() override; 44 void OnStop() override; 45 46 private: 47 static std::mutex mutex_; 48 static std::shared_ptr<PinAuthService> instance_; 49 inline uint32_t GetTokenId(); 50 void StartDriverManager(); 51 }; 52 } // namespace PinAuth 53 } // namespace UserIam 54 } // namespace OHOS 55 56 #endif // PIN_AUTH_SERVICE_H 57