1 /*
2  * Copyright (c) 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 WIDGET_CONTEXT_CALLBACK_IMPL_H
17 #define WIDGET_CONTEXT_CALLBACK_IMPL_H
18 
19 #include <memory>
20 #include <mutex>
21 
22 #include "iam_hitrace_helper.h"
23 #include "iam_defines.h"
24 #include "iam_callback_interface.h"
25 
26 namespace OHOS {
27 namespace UserIam {
28 namespace UserAuth {
29 class WidgetContext;
30 class WidgetContextCallbackImpl : public IamCallbackInterface, public NoCopyable {
31 public:
32     WidgetContextCallbackImpl(std::weak_ptr<WidgetContext> widgetContext, int32_t authType);
33     ~WidgetContextCallbackImpl() override = default;
34     void OnResult(int32_t result, const Attributes &extraInfo) override;
35     void OnAcquireInfo(int32_t module, int32_t acquireInfo, const Attributes &extraInfo) override;
36     sptr<IRemoteObject> AsObject() override;
37 
38 private:
39     std::mutex mutex_;
40     int32_t authType_ {0};
41     std::weak_ptr<WidgetContext> widgetContext_;
42     std::shared_ptr<IamHitraceHelper> iamHitraceHelper_ {nullptr};
43 };
44 } // namespace UserAuth
45 } // namespace UserIam
46 } // namespace OHOS
47 #endif // WIDGET_CONTEXT_CALLBACK_IMPL_H
48