xref: /aosp_15_r20/cts/tests/tests/binder_ndk/libbinder_ndk_test/legacy_binder.cpp (revision b7c941bb3fa97aba169d73cee0bed2de8ac964bf)
1 /*
2  * Copyright (C) 2021 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include "legacy_binder.h"
18 
LegacyBinder_OnTransact(AIBinder * _aidl_binder,transaction_code_t _aidl_code,const AParcel * _aidl_in,AParcel * _aidl_out)19 static binder_status_t LegacyBinder_OnTransact(AIBinder* _aidl_binder,
20                                                transaction_code_t _aidl_code,
21                                                const AParcel* _aidl_in, AParcel* _aidl_out) {
22   (void)_aidl_binder;
23   (void)_aidl_code;
24 
25   int32_t value;
26   if (binder_status_t status = AParcel_readInt32(_aidl_in, &value); status != STATUS_OK) {
27     return status;
28   }
29   return AParcel_writeInt32(_aidl_out, value);
30 }
31 
LegacyBinder_OnCreate(void * args)32 static void* LegacyBinder_OnCreate(void* args) {
33   return args;
34 }
35 
LegacyBinder_OnDestroy(void * userData)36 static void LegacyBinder_OnDestroy(void* userData) {
37   (void)userData;
38 }
39 
__anonefe68b3f0102() 40 const AIBinder_Class* kLegacyBinderClass = []() {
41   auto clazz = AIBinder_Class_define("LegacyBinder", LegacyBinder_OnCreate, LegacyBinder_OnDestroy,
42                                      LegacyBinder_OnTransact);
43   AIBinder_Class_disableInterfaceTokenHeader(clazz);
44   return clazz;
45 }();
46