1
0
Fork 0
mirror of https://github.com/syncthing/syncthing-android.git synced 2025-01-09 11:41:29 +00:00

Add delay for charging detection (fixes #1595) (#1817)

This commit is contained in:
Niccolò Maggioni 2022-08-11 21:54:46 +02:00 committed by GitHub
parent 192c00ebf0
commit 83ee3f3db9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -14,6 +14,7 @@ import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager; import android.net.wifi.WifiManager;
import android.os.BatteryManager; import android.os.BatteryManager;
import android.os.Build; import android.os.Build;
import android.os.Handler;
import android.os.PowerManager; import android.os.PowerManager;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import android.util.Log; import android.util.Log;
@ -118,7 +119,13 @@ public class RunConditionMonitor {
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
if (Intent.ACTION_POWER_CONNECTED.equals(intent.getAction()) if (Intent.ACTION_POWER_CONNECTED.equals(intent.getAction())
|| Intent.ACTION_POWER_DISCONNECTED.equals(intent.getAction())) { || Intent.ACTION_POWER_DISCONNECTED.equals(intent.getAction())) {
updateShouldRunDecision(); Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
updateShouldRunDecision();
}
}, 5000);
} }
} }
} }