• 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 "useridm_getsecinfo_callback_stub.h"
17 #include <message_parcel.h>
18 #include "useridm_hilog_wrapper.h"
19 
20 namespace OHOS {
21 namespace UserIAM {
22 namespace UserIDM {
UserIDMGetSecInfoCallbackStub(const std::shared_ptr<GetSecInfoCallback> & impl)23 UserIDMGetSecInfoCallbackStub::UserIDMGetSecInfoCallbackStub(const std::shared_ptr<GetSecInfoCallback>& impl)
24 {
25     callback_ = impl;
26 }
27 
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)28 int32_t UserIDMGetSecInfoCallbackStub::OnRemoteRequest(uint32_t code,
29     MessageParcel &data, MessageParcel &reply, MessageOption &option)
30 {
31     USERIDM_HILOGI(MODULE_CLIENT,
32         "UserIDMGetSecInfoCallbackStub::OnRemoteRequest, code:%{public}u, flags:%{public}d", code, option.GetFlags());
33 
34     if (UserIDMGetSecInfoCallbackStub::GetDescriptor() != data.ReadInterfaceToken()) {
35         USERIDM_HILOGE(MODULE_CLIENT,
36             "UserIDMGetSecInfoCallbackStub::OnRemoteRequest failed, descriptor is not matched!");
37         return FAIL;
38     }
39 
40     switch (code) {
41         case static_cast<int32_t>(IGetSecInfoCallback::ON_GET_SEC_INFO):
42             return OnGetSecInfoStub(data, reply);
43         default:
44             return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
45     }
46 }
47 
OnGetSecInfoStub(MessageParcel & data,MessageParcel & reply)48 int32_t UserIDMGetSecInfoCallbackStub::OnGetSecInfoStub(MessageParcel& data, MessageParcel& reply)
49 {
50     USERIDM_HILOGI(MODULE_CLIENT, "UserIDMGetSecInfoCallbackStub OnGetSecInfoStub start");
51 
52     int32_t ret = SUCCESS;
53     SecInfo info = {};
54     info.secureUid = data.ReadUint64();
55     info.enrolledInfoLen = data.ReadUint32();
56 
57     this->OnGetSecInfo(info);
58     if (!reply.WriteInt32(ret)) {
59         USERIDM_HILOGE(MODULE_CLIENT, "failed to WriteInt32(ret)");
60         ret = FAIL;
61     }
62 
63     return ret;
64 }
65 
OnGetSecInfo(SecInfo & info)66 void UserIDMGetSecInfoCallbackStub::OnGetSecInfo(SecInfo &info)
67 {
68     USERIDM_HILOGI(MODULE_CLIENT, "UserIDMGetSecInfoCallbackStub OnGetSecInfo start");
69 
70     if (callback_ == nullptr) {
71         USERIDM_HILOGE(MODULE_CLIENT, "UserIDMGetSecInfoCallbackStub callback_ is nullptr");
72         return;
73     } else {
74         callback_->OnGetSecInfo(info);
75     }
76 }
77 }  // namespace UserIDM
78 }  // namespace UserIAM
79 }  // namespace OHOS