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 #include "widget_context_callback_impl.h"
16 
17 #include <sstream>
18 
19 #include "iam_check.h"
20 #include "iam_logger.h"
21 #include "iam_mem.h"
22 #include "iam_ptr.h"
23 #include "widget_context.h"
24 
25 #define LOG_TAG "USER_AUTH_SA"
26 namespace OHOS {
27 namespace UserIam {
28 namespace UserAuth {
WidgetContextCallbackImpl(std::weak_ptr<WidgetContext> widgetContext,int32_t authType)29 WidgetContextCallbackImpl::WidgetContextCallbackImpl(std::weak_ptr<WidgetContext> widgetContext, int32_t authType)
30     : authType_(authType), widgetContext_(widgetContext),
31     iamHitraceHelper_(Common::MakeShared<UserIam::UserAuth::IamHitraceHelper>("WidgetContext"))
32 {
33 }
34 
OnResult(int32_t result,const Attributes & extraInfo)35 void WidgetContextCallbackImpl::OnResult(int32_t result, const Attributes &extraInfo)
36 {
37     std::lock_guard lock(mutex_);
38     auto widgetContext = widgetContext_.lock();
39     if (widgetContext != nullptr) {
40         widgetContext->AuthResult(result, authType_, extraInfo);
41     }
42 }
43 
OnAcquireInfo(int32_t module,int32_t acquireInfo,const Attributes & extraInfo)44 void WidgetContextCallbackImpl::OnAcquireInfo(int32_t module, int32_t acquireInfo, const Attributes &extraInfo)
45 {
46     std::lock_guard lock(mutex_);
47     auto widgetContext = widgetContext_.lock();
48     if (widgetContext != nullptr) {
49         widgetContext->AuthTipInfo(acquireInfo, authType_, extraInfo);
50     }
51 }
52 
AsObject()53 sptr<IRemoteObject> WidgetContextCallbackImpl::AsObject()
54 {
55     sptr<IRemoteObject> tmp(nullptr);
56     return tmp;
57 }
58 } // namespace UserAuth
59 } // namespace UserIam
60 } // namespace OHOS
61