• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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 DRIVER_LOAD_MANAGER_H
17 #define DRIVER_LOAD_MANAGER_H
18 
19 #include <mutex>
20 
21 #include "iservstat_listener_hdi.h"
22 #include "system_ability_listener.h"
23 
24 namespace OHOS {
25 namespace UserIam {
26 namespace PinAuth {
27 using ServStatListenerStub = HDI::ServiceManager::V1_0::ServStatListenerStub;
28 class DriverLoadManager {
29 public:
30     static DriverLoadManager &GetInstance();
31 
32     void StartSubscribe();
33     void OnTimeout();
34     void OnDriverManagerAdd();
35     void OnServiceStart();
36     void OnServiceStop();
37     void OnSaStopping(bool isStopping);
38 
39 private:
40     DriverLoadManager() = default;
41     ~DriverLoadManager() = default;
42 
43     void ProcessServiceStatus();
44     bool LoadDriver();
45     bool UnloadDriver();
46 
47     bool isSubscribed_ = false;
48     std::recursive_mutex mutex_;
49     sptr<SystemAbilityListener> driverManagerStatusListener_ = nullptr;
50     sptr<ServStatListenerStub> driverStatusListener_ = nullptr;
51     bool isDriverRunning_ = false;
52     bool isSaStopping_ = false;
53     std::optional<int32_t> timerId_ = std::nullopt;
54 };
55 } // namespace PinAuth
56 } // namespace UserIam
57 } // namespace OHOS
58 #endif // DRIVER_LOAD_MANAGER_H