• 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 "devattest_service_proxy.h"
17 
18 #include "devattest_log.h"
19 #include "devattest_errno.h"
20 #include "attest_result_info.h"
21 
22 using namespace std;
23 namespace OHOS {
24 namespace DevAttest {
GetAttestStatus(AttestResultInfo & attestResultInfo)25 int32_t DevAttestServiceProxy::GetAttestStatus(AttestResultInfo &attestResultInfo)
26 {
27     HILOGI("DevAttestServiceProxy GetAttestStatus begin");
28     MessageParcel data;
29     MessageParcel reply;
30     MessageOption option;
31 
32     if (!data.WriteInterfaceToken(GetDescriptor())) {
33         HILOGE("GetAttestStatus write interface token failed");
34         return DEVATTEST_FAIL;
35     }
36 
37     sptr<IRemoteObject> remote = Remote();
38     if (remote == nullptr) {
39         HILOGE("remote service null");
40         return DEVATTEST_FAIL;
41     }
42     int ret = remote->SendRequest(GET_AUTH_RESULT, data, reply, option);
43     if (ret != DEVATTEST_SUCCESS) {
44         HILOGE("GetAttestStatus: call SendRequest failed %{public}d", ret);
45         return DEVATTEST_FAIL;
46     }
47     int32_t authRet;
48     if (!reply.ReadInt32(authRet)) {
49         HILOGE("GetAttestStatus: authRet failed %{public}d", authRet);
50         return DEVATTEST_FAIL;
51     }
52     if (authRet != DEVATTEST_SUCCESS) {
53         HILOGE("GetAttestStatus: authRet failed code %{public}d", authRet);
54         return authRet;
55     }
56 
57     sptr<AttestResultInfo> attestResultInfoPtr = AttestResultInfo::Unmarshalling(reply);
58     if (attestResultInfoPtr == nullptr) {
59         HILOGE("GetAttestStatus: attestResultInfoPtr is nullptr");
60         return DEVATTEST_FAIL;
61     }
62     attestResultInfo = *attestResultInfoPtr;
63     return DEVATTEST_SUCCESS;
64 }
65 }
66 }