• 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 CO_AUTH_CLIENT_IMPL_H
17 #define CO_AUTH_CLIENT_IMPL_H
18 
19 #include <mutex>
20 
21 #include "nocopyable.h"
22 
23 #include "ico_auth.h"
24 #include "co_auth_client.h"
25 #include "co_auth_interface.h"
26 #include "user_auth_types.h"
27 
28 namespace OHOS {
29 namespace UserIam {
30 namespace UserAuth {
31 class CoAuthClientImpl final : public CoAuthClient, public NoCopyable {
32 public:
33     uint64_t Register(const ExecutorInfo &info, const std::shared_ptr<ExecutorRegisterCallback> &callback) override;
34     void Unregister(uint64_t executorIndex) override;
35 
36 private:
37     friend class CoAuthClient;
38     CoAuthClientImpl() = default;
39     ~CoAuthClientImpl() override = default;
40     static CoAuthClientImpl &Instance();
41     void InitIpcExecutorInfo(const ExecutorInfo &info, IpcExecutorRegisterInfo &ipcExecutorRegisterInfo);
42     class CoAuthImplDeathRecipient : public IRemoteObject::DeathRecipient, public NoCopyable {
43     public:
44         CoAuthImplDeathRecipient() = default;
45         ~CoAuthImplDeathRecipient() override = default;
46         void OnRemoteDied(const wptr<IRemoteObject> &remote) override;
47     };
48     void ResetProxy(const wptr<IRemoteObject> &remote);
49     sptr<ICoAuth> GetProxy();
50     sptr<ICoAuth> proxy_ {nullptr};
51     sptr<IRemoteObject::DeathRecipient> deathRecipient_ {nullptr};
52     std::mutex mutex_;
53 };
54 } // namespace UserAuth
55 } // namespace UserIam
56 } // namespace OHOS
57 #endif // CO_AUTH_CLIENT_IMPL_H