1
0
Fork 0
mirror of https://github.com/syncthing/syncthing-android.git synced 2025-01-11 04:25:53 +00:00

WIP - Extend run condition monitor functions

This commit is contained in:
Catfriend1 2018-07-24 22:07:06 +02:00
parent 02b6f987eb
commit a4c263f7cc

View file

@ -227,6 +227,48 @@ public class RunConditionMonitor implements SharedPreferences.OnSharedPreference
return powerManager.isPowerSaveMode();
}
private boolean isFlightMode() {
ConnectivityManager cm = (ConnectivityManager) mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo ni = cm.getActiveNetworkInfo();
return ni == null;
}
private boolean isMeteredNetworkConnection() {
ConnectivityManager cm = (ConnectivityManager) mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo ni = cm.getActiveNetworkInfo();
if (ni == null) {
// In flight mode.
return false;
}
if (!ni.isConnected()) {
// No network connection.
return false;
}
return cm.isActiveNetworkMetered();
}
private boolean isMobileDataConnection() {
ConnectivityManager cm = (ConnectivityManager) mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo ni = cm.getActiveNetworkInfo();
if (ni == null) {
// In flight mode.
return false;
}
if (!ni.isConnected()) {
// No network connection.
return false;
}
switch (ni.getType()) {
case ConnectivityManager.TYPE_BLUETOOTH:
case ConnectivityManager.TYPE_MOBILE:
case ConnectivityManager.TYPE_MOBILE_DUN:
case ConnectivityManager.TYPE_MOBILE_HIPRI:
return true;
default:
return false;
}
}
private boolean isWifiOrEthernetConnection() {
ConnectivityManager cm = (ConnectivityManager) mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo ni = cm.getActiveNetworkInfo();