• 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 #include "accesstoken_log.h"
17 #include "atm_receiver_impl.h"
18 
19 namespace OHOS {
20 namespace Security {
21 namespace AccessToken {
22 namespace {
23 static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {
24     LOG_CORE, SECURITY_DOMAIN_ACCESSTOKEN, "AccessTokenManagerTools"
25 };
26 }
27 
AtmReceiverImpl()28 AtmReceiverImpl::AtmReceiverImpl()
29 {
30     ACCESSTOKEN_LOG_DEBUG(LABEL, "create atm status receiver instance");
31 }
32 
~AtmReceiverImpl()33 AtmReceiverImpl::~AtmReceiverImpl()
34 {
35     ACCESSTOKEN_LOG_DEBUG(LABEL, "destory atm status receiver instance");
36 }
37 
OnFinished(const int32_t resultCode,const std::string & resultMsg)38 void AtmReceiverImpl::OnFinished(const int32_t resultCode, const std::string &resultMsg)
39 {
40     ACCESSTOKEN_LOG_DEBUG(LABEL, "on finished result is %{public}d, %{public}s", resultCode, resultMsg.c_str());
41     resultMsgSignal_.set_value(resultCode);
42 }
43 
OnStatusNotify(const int process)44 void AtmReceiverImpl::OnStatusNotify(const int process)
45 {
46     ACCESSTOKEN_LOG_DEBUG(LABEL, "on OnStatusNotify is %{public}d", process);
47 }
48 
GetResultCode() const49 int32_t AtmReceiverImpl::GetResultCode() const
50 {
51     auto future = resultMsgSignal_.get_future();
52     future.wait();
53     int32_t resultCode = future.get();
54 
55     return resultCode;
56 }
57 } // namespace AccessToken
58 } // namespace Security
59 } // namespace OHOS
60