summaryrefslogtreecommitdiffstats
path: root/packages/services/PacProcessor/IProxyService.cpp
blob: 3707d8554b349870dbf11c648740b26ef1cfd1ee (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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#define LOG_TAG "ProxyTesting"

#include <stdint.h>
#include <sys/types.h>
#include <binder/Parcel.h>
#include <binder/IPCThreadState.h>
#include <utils/Errors.h>
#include "IProxyService.h"

#include <utils/Log.h>

#include <private/android_filesystem_config.h>

using namespace android;

String16 BpProxyService::resolveProxies(String16 host, String16 url) {
    String16 ret;
    return ret;
}

void BpProxyService::setPacFile(String16& scriptContents) {

}

void BpProxyService::startPacSystem() {

}
void BpProxyService::stopPacSystem() {

}

IMPLEMENT_META_INTERFACE(ProxyService, "com.android.net.IProxyService");

status_t BnProxyService::onTransact(
            uint32_t code, const Parcel& data,
            Parcel* reply, uint32_t flags) {
    int returnInt = 0;
    switch (code) {
    case RESOLVE_PROXIES:
    {
        CHECK_INTERFACE(IProxyService, data, reply);
        String16 host = data.readString16();
        String16 url = data.readString16();
        String16 response = resolveProxies(host, url);
        reply->writeNoException();
        reply->writeString16(response);
        return NO_ERROR;
    } break;
    case SET_PAC:
    {
        CHECK_INTERFACE(IProxyService, data, reply);
        if (notSystemUid()) {
            returnInt = 1;
        } else {
            String16 pacFile = data.readString16();
            setPacFile(pacFile);
        }
        reply->writeNoException();
        reply->writeInt32(returnInt);
        return NO_ERROR;
    } break;
    case START_PAC:
    {
        CHECK_INTERFACE(IProxyService, data, reply);
        if (notSystemUid()) {
            returnInt = 1;
        } else {
            startPacSystem();
        }
        reply->writeNoException();
        reply->writeInt32(returnInt);
        return NO_ERROR;
    } break;
    case STOP_PAC:
    {
        CHECK_INTERFACE(IProxyService, data, reply);
        if (notSystemUid()) {
            returnInt = 1;
        } else {
            stopPacSystem();
        }
        reply->writeNoException();
        reply->writeInt32(returnInt);
        return NO_ERROR;
    } break;
    default:
        return BBinder::onTransact(code, data, reply, flags);
    }
}

int BnProxyService::getCallingUid() {
    return IPCThreadState::self()->getCallingUid();
}

bool BnProxyService::notSystemUid() {
    return getCallingUid() != AID_SYSTEM;
}