1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2024-12-27 10:17:18 +00:00

Refactoring

This commit is contained in:
M66B 2021-01-17 17:26:21 +01:00
parent ae91452293
commit b95f5dc87c

View file

@ -2089,6 +2089,31 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
}
};
private final BroadcastReceiver idleModeChangedReceiver = new BroadcastReceiver() {
@Override
@RequiresApi(api = Build.VERSION_CODES.M)
public void onReceive(Context context, Intent intent) {
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
EntityLog.log(context, "Doze mode=" + pm.isDeviceIdleMode() +
" ignoring=" + pm.isIgnoringBatteryOptimizations(context.getPackageName()));
}
};
private final BroadcastReceiver dataSaverChanged = new BroadcastReceiver() {
@Override
@RequiresApi(api = Build.VERSION_CODES.N)
public void onReceive(Context context, Intent intent) {
Log.i("Received intent=" + intent +
" " + TextUtils.join(" ", Log.getExtras(intent.getExtras())));
ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
Integer status = (cm == null ? null : cm.getRestrictBackgroundStatus());
EntityLog.log(context, "Data saver=" + status);
updateNetworkState(null, "datasaver");
}
};
private void updateNetworkState(final Network network, final String reason) {
getMainHandler().post(new Runnable() {
@Override
@ -2142,31 +2167,6 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
});
}
private final BroadcastReceiver idleModeChangedReceiver = new BroadcastReceiver() {
@Override
@RequiresApi(api = Build.VERSION_CODES.M)
public void onReceive(Context context, Intent intent) {
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
EntityLog.log(context, "Doze mode=" + pm.isDeviceIdleMode() +
" ignoring=" + pm.isIgnoringBatteryOptimizations(context.getPackageName()));
}
};
private final BroadcastReceiver dataSaverChanged = new BroadcastReceiver() {
@Override
@RequiresApi(api = Build.VERSION_CODES.N)
public void onReceive(Context context, Intent intent) {
Log.i("Received intent=" + intent +
" " + TextUtils.join(" ", Log.getExtras(intent.getExtras())));
ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
Integer status = (cm == null ? null : cm.getRestrictBackgroundStatus());
EntityLog.log(context, "Data saver=" + status);
updateNetworkState(null, "datasaver");
}
};
private class MediatorState extends MediatorLiveData<List<TupleAccountNetworkState>> {
private boolean running = true;
private ConnectionHelper.NetworkState lastNetworkState = null;