Always process send operations on connectivity changes

pull/178/head
M66B 5 years ago
parent c225f88159
commit 74e155beb7

@ -229,10 +229,10 @@ public class ServiceSend extends ServiceBase {
}; };
private void checkConnectivity() { private void checkConnectivity() {
boolean suitable = ConnectionHelper.getNetworkState(ServiceSend.this).isSuitable(); boolean suitable = ConnectionHelper.getNetworkState(this).isSuitable();
if (lastSuitable != suitable) { if (lastSuitable != suitable) {
lastSuitable = suitable; lastSuitable = suitable;
EntityLog.log(ServiceSend.this, "Service send suitable=" + suitable); EntityLog.log(this, "Service send suitable=" + suitable);
try { try {
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
@ -240,6 +240,7 @@ public class ServiceSend extends ServiceBase {
} catch (Throwable ex) { } catch (Throwable ex) {
Log.w(ex); Log.w(ex);
} }
}
if (suitable) if (suitable)
executor.submit(new Runnable() { executor.submit(new Runnable() {
@ -249,7 +250,6 @@ public class ServiceSend extends ServiceBase {
} }
}); });
} }
}
private void processOperations() { private void processOperations() {
try { try {
@ -376,6 +376,10 @@ public class ServiceSend extends ServiceBase {
if (!message.content) if (!message.content)
throw new IllegalArgumentException("Message body missing"); throw new IllegalArgumentException("Message body missing");
ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
if (cm.isActiveNetworkMetered())
throw new IOException("Metered");
// Create message // Create message
Properties props = MessageHelper.getSessionProperties(); Properties props = MessageHelper.getSessionProperties();
Session isession = Session.getInstance(props, null); Session isession = Session.getInstance(props, null);

Loading…
Cancel
Save