summaryrefslogtreecommitdiffstats
path: root/packages/services/Proxy/src/com/android/proxyhandler/ProxyServiceReceiver.java
blob: 4638def97964a420e12ce8a0f8574713609c3228 (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
package com.android.proxyhandler;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.net.Proxy;
import android.net.ProxyProperties;
import android.os.Bundle;
import android.text.TextUtils;

public class ProxyServiceReceiver extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {
        Intent service = new Intent(context, ProxyService.class);
        Bundle bundle = intent.getExtras();
        ProxyProperties proxy = null;
        if (bundle != null) {
            proxy = bundle.getParcelable(Proxy.EXTRA_PROXY_INFO);
            service.putExtra(Proxy.EXTRA_PROXY_INFO, proxy);
        }
        if ((proxy != null) && (!TextUtils.isEmpty(proxy.getPacFileUrl()))) {
            context.startService(service);
        } else {
            context.stopService(service);
        }
    }

}