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<IamCallbackInterface> 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 SetTraceIsBackgroundApplication(bool isBackgroundApplication) override;
46     void SetCleaner(Context::ContextStopCallback callback) override;
47     void SetTraceCallerType(int32_t callerType) override;
48     void ProcessAuthResult(int32_t tip, const std::vector<uint8_t> &extraInfo) override;
49     sptr<IamCallbackInterface> GetIamCallback() override;
50     std::string GetCallerName() override;
51 
52 private:
53     sptr<IamCallbackInterface> iamCallback_ {nullptr};
54     Context::ContextStopCallback stopCallback_ {nullptr};
55     ContextCallbackNotifyListener::MetaData metaData_;
56     std::shared_ptr<IamHitraceHelper> iamHitraceHelper_;
57 };
58 } // namespace UserAuth
59 } // namespace UserIam
60 } // namespace OHOS
61 #endif // CONTEXT_CALLBACK_IMPL_H