fix #2956 - prevent ANR during some automatic feed update
This commit is contained in:
parent
8252f6a41d
commit
949a05c17a
@ -17,6 +17,9 @@ public class FeedUpdateUtils {
|
|||||||
private FeedUpdateUtils() {}
|
private FeedUpdateUtils() {}
|
||||||
|
|
||||||
public static void startAutoUpdate(Context context, Runnable callback) {
|
public static void startAutoUpdate(Context context, Runnable callback) {
|
||||||
|
// the network check is blocking for possibly a long time: so run the logic
|
||||||
|
// in a separate thread to prevent the code blocking the callers
|
||||||
|
final Runnable runnable = () -> {
|
||||||
try {
|
try {
|
||||||
with().pollInterval(1, TimeUnit.SECONDS)
|
with().pollInterval(1, TimeUnit.SECONDS)
|
||||||
.await()
|
.await()
|
||||||
@ -26,6 +29,8 @@ public class FeedUpdateUtils {
|
|||||||
} catch (ConditionTimeoutException ignore) {
|
} catch (ConditionTimeoutException ignore) {
|
||||||
Log.d(TAG, "Blocking automatic update: no wifi available / no mobile updates allowed");
|
Log.d(TAG, "Blocking automatic update: no wifi available / no mobile updates allowed");
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
new Thread(runnable).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user