• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 resultCode,const std::vector<uint8_t> & extraInfo)35 int32_t WidgetContextCallbackImpl::OnResult(int32_t resultCode, const std::vector<uint8_t> &extraInfo)
36 {
37     std::lock_guard lock(mutex_);
38     auto widgetContext = widgetContext_.lock();
39     if (widgetContext != nullptr) {
40         Attributes attributes(extraInfo);
41         widgetContext->AuthResult(resultCode, authType_, attributes);
42         return SUCCESS;
43     }
44 
45     return GENERAL_ERROR;
46 }
47 
OnAcquireInfo(int32_t module,int32_t acquireInfo,const std::vector<uint8_t> & extraInfo)48 int32_t WidgetContextCallbackImpl::OnAcquireInfo(int32_t module, int32_t acquireInfo,
49     const std::vector<uint8_t> &extraInfo)
50 {
51     std::lock_guard lock(mutex_);
52     auto widgetContext = widgetContext_.lock();
53     if (widgetContext != nullptr) {
54         Attributes attributes(extraInfo);
55         widgetContext->AuthTipInfo(acquireInfo, authType_, attributes);
56         return SUCCESS;
57     }
58     return GENERAL_ERROR;
59 }
60 
AsObject()61 sptr<IRemoteObject> WidgetContextCallbackImpl::AsObject()
62 {
63     sptr<IRemoteObject> tmp(nullptr);
64     return tmp;
65 }
66 } // namespace UserAuth
67 } // namespace UserIam
68 } // namespace OHOS
69