parent
9f3e328f54
commit
ec02e8a198
|
@ -46,6 +46,7 @@ import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.annotation.BoolRes;
|
import androidx.annotation.BoolRes;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.RequiresApi;
|
||||||
import androidx.annotation.StringRes;
|
import androidx.annotation.StringRes;
|
||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import androidx.appcompat.app.AlertDialog.Builder;
|
import androidx.appcompat.app.AlertDialog.Builder;
|
||||||
|
@ -447,12 +448,22 @@ public abstract class XmppActivity extends ActionBarActivity {
|
||||||
final ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
|
final ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||||
return cm != null
|
return cm != null
|
||||||
&& cm.isActiveNetworkMetered()
|
&& cm.isActiveNetworkMetered()
|
||||||
&& cm.getRestrictBackgroundStatus() == ConnectivityManager.RESTRICT_BACKGROUND_STATUS_ENABLED;
|
&& getRestrictBackgroundStatus(cm) == ConnectivityManager.RESTRICT_BACKGROUND_STATUS_ENABLED;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequiresApi(api = Build.VERSION_CODES.N)
|
||||||
|
private static int getRestrictBackgroundStatus(@NonNull final ConnectivityManager connectivityManager) {
|
||||||
|
try {
|
||||||
|
return connectivityManager.getRestrictBackgroundStatus();
|
||||||
|
} catch (final Exception e) {
|
||||||
|
Log.d(Config.LOGTAG,"platform bug detected. Unable to get restrict background status",e);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private boolean usingEnterKey() {
|
private boolean usingEnterKey() {
|
||||||
return getBooleanPreference("display_enter_key", R.bool.display_enter_key);
|
return getBooleanPreference("display_enter_key", R.bool.display_enter_key);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue