• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 DEVICE_SECURITY_LEVEL_LOADER
17 #define DEVICE_SECURITY_LEVEL_LOADER
18 
19 #include <future>
20 #include <new>
21 #include <cstdint>
22 
23 #include "refbase.h"
24 #include "iremote_object.h"
25 #include "singleton.h"
26 #include "system_ability_load_callback_stub.h"
27 
28 namespace OHOS {
29 namespace Security {
30 namespace DeviceSecurityLevel {
31 using namespace OHOS;
32 class DeviceSecurityLevelLoader : public Singleton<DeviceSecurityLevelLoader> {
33 public:
34     DeviceSecurityLevelLoader() = default;
35     ~DeviceSecurityLevelLoader() override = default;
36     sptr<IRemoteObject> LoadDslmService();
37 
38 private:
39     class LoadCallback : public SystemAbilityLoadCallbackStub {
40     public:
41         void OnLoadSystemAbilitySuccess(int32_t sid, const sptr<IRemoteObject> &object) override;
42         void OnLoadSystemAbilityFail(int32_t sid) override;
43         sptr<IRemoteObject> Promise();
44 
45     private:
46         std::promise<sptr<IRemoteObject>> promise_;
47     };
48 };
49 } // namespace DeviceSecurityLevel
50 } // namespace Security
51 } // namespace OHOS
52 
53 #endif // DEVICE_SECURITY_LEVEL_LOADER