blob: 04e4e8b46bd7b834b9e8e101ab55e3d3ffde8332 (
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
|
/*
* Copyright (c) 2012-2016 Arne Schwabe
* Distributed under the GNU GPL v2 with additional terms. For full terms see the file doc/LICENSE.txt
*/
package de.blinkt.openvpn.core;
import android.annotation.TargetApi;
import android.net.ConnectivityManager;
import android.net.LinkProperties;
import android.net.Network;
import android.net.NetworkCapabilities;
import android.os.Build;
/**
* Created by arne on 26.11.14.
*/
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public class LollipopDeviceStateListener extends ConnectivityManager.NetworkCallback {
private String mLastConnectedStatus;
private String mLastLinkProperties;
private String mLastNetworkCapabilities;
@Override
public void onAvailable(Network network) {
super.onAvailable(network);
if (!network.toString().equals(mLastConnectedStatus)) {
mLastConnectedStatus = network.toString();
VpnStatus.logDebug("Connected to " + mLastConnectedStatus);
}
}
@Override
public void onLinkPropertiesChanged(Network network, LinkProperties linkProperties) {
super.onLinkPropertiesChanged(network, linkProperties);
if (!linkProperties.toString().equals(mLastLinkProperties)) {
mLastLinkProperties = linkProperties.toString();
VpnStatus.logDebug(String.format("Linkproperties of %s: %s", network, linkProperties));
}
}
@Override
public void onCapabilitiesChanged(Network network, NetworkCapabilities networkCapabilities) {
super.onCapabilitiesChanged(network, networkCapabilities);
if (!networkCapabilities.toString().equals(mLastNetworkCapabilities)) {
mLastNetworkCapabilities = networkCapabilities.toString();
VpnStatus.logDebug(String.format("Network capabilities of %s: %s", network, networkCapabilities));
}
}
}
|