blob: 117e6fc25a3d3e22893b0c942eeb4a6883225c00 (
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
 | package org.pihole.dnsproxy;
import android.app.Service;
import android.content.Intent;
import android.net.VpnService;
public class DNSProxyService extends VpnService {
    public static String LOG_TAG = "org.pihole.dnsproxy.log";
    public static String NOTIFICATION = "org.pihole.dnsproxy.service";
    private static DNSProxyConnection connection;
    @Override
    public int onStartCommand(Intent intent, int flags, int startId)    {
        this.start();
        return Service.START_STICKY;
    }
    @Override
    public void onDestroy() {
        this.stop();
        super.onDestroy();
    }
    public static boolean isRunning()
    {
        return DNSProxyService.connection != null;
    }
    public void start() {
        DNSProxyService.connection = new DNSProxyConnection(this);
        // DNSProxyService.connection.start();
        // send notification when started
        Intent notification = new Intent(DNSProxyService.NOTIFICATION);
        sendBroadcast(notification);
    }
    public void stop() {
        // DNSProxyService.connection.stop();
        DNSProxyService.connection = null;
        // send notification when stopped
        Intent notification = new Intent(DNSProxyService.NOTIFICATION);
        sendBroadcast(notification);
    }
}
 |