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:
parent
02b6f987eb
commit
a4c263f7cc
1 changed files with 42 additions and 0 deletions
|
@ -227,6 +227,48 @@ public class RunConditionMonitor implements SharedPreferences.OnSharedPreference
|
||||||
return powerManager.isPowerSaveMode();
|
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() {
|
private boolean isWifiOrEthernetConnection() {
|
||||||
ConnectivityManager cm = (ConnectivityManager) mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
|
ConnectivityManager cm = (ConnectivityManager) mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||||
NetworkInfo ni = cm.getActiveNetworkInfo();
|
NetworkInfo ni = cm.getActiveNetworkInfo();
|
||||||
|
|
Loading…
Reference in a new issue