• 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 CONTEXT_CALLBACK_IMPL_H
17 #define CONTEXT_CALLBACK_IMPL_H
18 
19 #include "iam_hitrace_helper.h"
20 #include "iam_defines.h"
21 
22 #include "context_callback.h"
23 
24 namespace OHOS {
25 namespace UserIam {
26 namespace UserAuth {
27 class ContextCallbackImpl : public ContextCallback, public NoCopyable {
28 public:
29     explicit ContextCallbackImpl(sptr<IIamCallback> iamCallback, OperationType operationType);
30     ~ContextCallbackImpl() override = default;
31     void OnResult(int32_t resultCode, const Attributes &finalResult) override;
32     void OnAcquireInfo(ExecutorRole src, int32_t moduleType, const std::vector<uint8_t> &acquireMsg) override;
33     void SetTraceCallerName(const std::string &callerName) override;
34     void SetTraceRequestContextId(uint64_t requestContextId) override;
35     void SetTraceAuthContextId(uint64_t authContextId) override;
36     void SetTraceUserId(int32_t userId) override;
37     void SetTraceRemainTime(int32_t remainTime) override;
38     void SetTraceFreezingTime(int32_t freezingTime) override;
39     void SetTraceSdkVersion(int32_t version) override;
40     void SetTraceAuthType(int32_t authType) override;
41     void SetTraceAuthWidgetType(uint32_t authWidgetType) override;
42     void SetTraceAuthTrustLevel(AuthTrustLevel atl) override;
43     void SetTraceReuseUnlockResultMode(uint32_t reuseUnlockResultMode) override;
44     void SetTraceReuseUnlockResultDuration(uint64_t reuseUnlockResultDuration) override;
45     void SetTraceCallerType(int32_t callerType) override;
46     void SetTraceIsRemoteAuth(bool isRemoteAuth) override;
47     void SetTraceLocalUdid(const std::string &localUdid) override;
48     void SetTraceRemoteUdid(const std::string &remoteUdid) override;
49     void SetTraceConnectionName(const std::string &connectionName) override;
50     void SetTraceAuthFinishReason(const std::string &authFinishReason) override;
51     void SetTraceIsBackgroundApplication(bool isBackgroundApplication) override;
52     void SetCleaner(Context::ContextStopCallback callback) override;
53     int32_t ParseAuthTipInfo(int32_t tip, const std::vector<uint8_t> &extraInfo,
54         int32_t &authResult, int32_t &freezingTime) override;
55     void ProcessAuthResult(int32_t tip, const std::vector<uint8_t> &extraInfo) override;
56     sptr<IIamCallback> GetIamCallback() override;
57     std::string GetCallerName() override;
58 
59 private:
60     void HandleAuthSuccessResult(int32_t resultCode, const Attributes &finalResult);
61     sptr<IIamCallback> iamCallback_ {nullptr};
62     Context::ContextStopCallback stopCallback_ {nullptr};
63     ContextCallbackNotifyListener::MetaData metaData_;
64     std::shared_ptr<IamHitraceHelper> iamHitraceHelper_;
65 };
66 } // namespace UserAuth
67 } // namespace UserIam
68 } // namespace OHOS
69 #endif // CONTEXT_CALLBACK_IMPL_H