summaryrefslogtreecommitdiffstats
path: root/tvouthack/main.cpp
blob: 85005c7cf105eddd66c82696ae880de846b3ef0e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <stdio.h>
#include <binder/IPCThreadState.h>
#include <binder/ProcessState.h>
#include <binder/IServiceManager.h>
#include <utils/Log.h>

using namespace android;

int main() {
    sp<IServiceManager> sm = defaultServiceManager();
    sp<IBinder> binder;

    do {
        binder = sm->getService(String16("tvout"));
        if (binder != 0) break;
        usleep(500000); // 0.5 s
    } while(true);

    int ret;

    Parcel s2, r2;
    s2.writeInterfaceToken(String16("android.hardware.ITvOutService"));
    binder->transact(1, s2, &r2);
    sp<IBinder> binder2 = r2.readStrongBinder();

    while (true) {
        {
            Parcel send, reply;
            int code = 4;
            send.writeInterfaceToken(String16("android.hardware.ITvOut"));
            int ret = binder2->transact(code, send, &reply);
        }
        {
            Parcel send, reply;
            int code = 27;
            send.writeInterfaceToken(String16("android.hardware.ITvOut"));
            int ret = binder2->transact(code, send, &reply);
        }
        {
            Parcel send, reply;
            int code = 13;
            send.writeInterfaceToken(String16("android.hardware.ITvOut"));
            send.writeInt32(0);
            int ret = binder2->transact(code, send, &reply);
        }
        usleep(15000); // Should give ~60 fps
    }
    return 0;
}