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 "device_security_level_callback_stub.h"
17 
18 #include <functional>
19 #include <string>
20 #include <type_traits>
21 
22 #include "hilog/log_cpp.h"
23 
24 #include "device_security_defines.h"
25 #include "device_security_level_defines.h"
26 
27 namespace OHOS {
28 namespace Security {
29 namespace DeviceSecurityLevel {
30 using namespace OHOS::HiviewDFX;
DeviceSecurityLevelCallbackStub(RemoteRequest request)31 DeviceSecurityLevelCallbackStub::DeviceSecurityLevelCallbackStub(RemoteRequest request)
32     : remoteRequest_(std::move(request))
33 {
34 }
35 
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)36 int32_t DeviceSecurityLevelCallbackStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply,
37     MessageOption &option)
38 {
39     if (DeviceSecurityLevelCallbackStub::GetDescriptor() != data.ReadInterfaceToken()) {
40         HILOG_ERROR(LOG_CORE, "descriptor not match");
41         return SUCCESS;
42     }
43 
44     if (remoteRequest_ != nullptr) {
45         return remoteRequest_(code, data, reply, option);
46     }
47     return SUCCESS;
48 }
49 } // namespace DeviceSecurityLevel
50 } // namespace Security
51 } // namespace OHOS
52