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/Parcel.h>
18 #include <binder/ProcessState.h>
19 #include <binder/IServiceManager.h>
20 #include <binder/TextOutput.h>
21 #include <cutils/ashmem.h>
22 
23 #include <getopt.h>
24 #include <stdlib.h>
25 #include <stdio.h>
26 #include <string.h>
27 #include <unistd.h>
28 #include <sys/mman.h>
29 #include <sys/types.h>
30 #include <sys/stat.h>
31 #include <fcntl.h>
32 
33 using namespace android;
34 
35 /**
36  * This is a small program designed to trigger notifySyspropsChanged in the system
37  * server. This exists in order to fix an issue with missing callbacks for unreadable
38  * GPU buffers on TV devices and should be removed as soon as possible.
39  */
main()40 int main() {
41     sp<IServiceManager> sm = defaultServiceManager();
42 
43     if (sm == nullptr) {
44         aerr << "service: Unable to get default service manager!" << endl;
45         return 20;
46     }
47 
48     sp<IBinder> service = sm->checkService(String16("activity"));
49     if (service != nullptr) {
50         Parcel data;
51         service->transact(IBinder::SYSPROPS_TRANSACTION, data, NULL, 0);
52     } else {
53         aout << "ActivityManagerService not found" << endl;
54         return 10;
55     }
56     return 0;
57 }
58