You've already forked android_translation_layer
mirror of
https://gitlab.com/android_translation_layer/android_translation_layer.git
synced 2025-10-27 11:48:10 -07:00
implement ConnectivityManager using GNetworkMonitor
This commit is contained in:
@@ -1,20 +1,25 @@
|
||||
package android.net;
|
||||
|
||||
class Network {}
|
||||
|
||||
public class ConnectivityManager {
|
||||
|
||||
public class NetworkCallback {}
|
||||
public class NetworkCallback {
|
||||
public void onAvailable(Network network) {}
|
||||
public void onLost(Network network) {}
|
||||
}
|
||||
|
||||
public NetworkInfo getNetworkInfo(int networkType) {
|
||||
return null; // this means the network type is not supported, which should make properly coded apps cease any attempts to use network-related APIs
|
||||
}
|
||||
|
||||
public NetworkInfo getActiveNetworkInfo() {
|
||||
return new NetworkInfo();
|
||||
return new NetworkInfo(nativeGetNetworkAvailable());
|
||||
}
|
||||
|
||||
public void registerNetworkCallback(NetworkRequest request, NetworkCallback callback) {}
|
||||
public native void registerNetworkCallback(NetworkRequest request, NetworkCallback callback);
|
||||
|
||||
public boolean isActiveNetworkMetered() {
|
||||
return false;
|
||||
}
|
||||
public native boolean isActiveNetworkMetered();
|
||||
|
||||
protected native boolean nativeGetNetworkAvailable();
|
||||
}
|
||||
|
||||
@@ -10,15 +10,21 @@ public class NetworkInfo {
|
||||
UNKNOWN
|
||||
}
|
||||
|
||||
private State state = State.DISCONNECTED;
|
||||
|
||||
public NetworkInfo(boolean available) {
|
||||
state = available ? State.CONNECTED : State.DISCONNECTED;
|
||||
}
|
||||
|
||||
public NetworkInfo.State getState() {
|
||||
return State.DISCONNECTED;
|
||||
return state;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return 0x8; // where did you even get a NetworkInfo object... there is no network
|
||||
return 0x8; // TYPE_DUMMY
|
||||
}
|
||||
|
||||
public boolean isConnected() {
|
||||
return true;
|
||||
return state == State.CONNECTED;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user