diff --git a/src/net/java/sip/communicator/impl/sysactivity/SystemActivityNotifications.java b/src/net/java/sip/communicator/impl/sysactivity/SystemActivityNotifications.java index 53d6eb7a0..df0c743a5 100644 --- a/src/net/java/sip/communicator/impl/sysactivity/SystemActivityNotifications.java +++ b/src/net/java/sip/communicator/impl/sysactivity/SystemActivityNotifications.java @@ -99,11 +99,15 @@ public class SystemActivityNotifications { try { - System.loadLibrary("sysactivitynotifications"); - - ptr = allocAndInit(); - if (ptr == -1) - ptr = 0; + // Don't load native library on Android to prevent the exception + if(!org.jitsi.util.OSUtils.IS_ANDROID) + { + System.loadLibrary("sysactivitynotifications"); + + ptr = allocAndInit(); + if (ptr == -1) + ptr = 0; + } } catch (Throwable t) { diff --git a/src/net/java/sip/communicator/plugin/reconnectplugin/ReconnectPluginActivator.java b/src/net/java/sip/communicator/plugin/reconnectplugin/ReconnectPluginActivator.java index 4243804ca..02ad7b8bf 100644 --- a/src/net/java/sip/communicator/plugin/reconnectplugin/ReconnectPluginActivator.java +++ b/src/net/java/sip/communicator/plugin/reconnectplugin/ReconnectPluginActivator.java @@ -173,6 +173,17 @@ public class ReconnectPluginActivator "net.java.sip.communicator.plugin.reconnectplugin." + "ATLEAST_ONE_SUCCESSFUL_CONNECTION"; + /** + * Timer used to filter out too frequent "network down" notifications + * on Android. + */ + private Timer delayedNetworkDown; + + /** + * Delay used for filtering out "network down" notifications. + */ + private static final long NETWORK_DOWN_THRESHOLD = 30 * 1000; + /** * Starts this bundle. * @@ -453,6 +464,8 @@ public synchronized void configurationChanged(ChangeEvent event) // no connection so one is up, lets connect if(connectedInterfaces.isEmpty()) { + onNetworkUp(); + Iterator iter = needsReconnection.iterator(); while (iter.hasNext()) @@ -532,10 +545,7 @@ else if(event.getType() == ChangeEvent.IFACE_DOWN) connectedInterfaces.clear(); - if (logger.isTraceEnabled()) - logger.trace("Network is down!"); - notify("", "plugin.reconnectplugin.NETWORK_DOWN", - new String[0], this); + onNetworkDown(); } } @@ -978,4 +988,58 @@ private void setAtLeastOneSuccessfulConnection( + pp.getAccountID().getAccountUniqueID(), Boolean.valueOf(value).toString()); } + + /** + * Called when first connected interface is added to + * {@link #connectedInterfaces} list. + */ + private void onNetworkUp() + { + if(delayedNetworkDown != null) + { + delayedNetworkDown.cancel(); + delayedNetworkDown = null; + } + } + + /** + * Called when first there are no more connected interface present in + * {@link #connectedInterfaces} list. + */ + private void onNetworkDown() + { + if(!org.jitsi.util.OSUtils.IS_ANDROID) + { + notifyNetworkDown(); + } + else + { + // Android never keeps two active connection at the same time + // and it may take some time to attach next connection + // even if it was already enabled by user + if(delayedNetworkDown == null) + { + delayedNetworkDown = new Timer(); + delayedNetworkDown.schedule(new TimerTask() + { + @Override + public void run() + { + notifyNetworkDown(); + } + }, NETWORK_DOWN_THRESHOLD); + } + } + } + + /** + * Posts "network is down" notification. + */ + private void notifyNetworkDown() + { + if (logger.isTraceEnabled()) + logger.trace("Network is down!"); + notify("", "plugin.reconnectplugin.NETWORK_DOWN", + new String[0], this); + } } diff --git a/src/net/java/sip/communicator/plugin/reconnectplugin/reconnectplugin.manifest.mf b/src/net/java/sip/communicator/plugin/reconnectplugin/reconnectplugin.manifest.mf index d68432ada..c4877dfad 100644 --- a/src/net/java/sip/communicator/plugin/reconnectplugin/reconnectplugin.manifest.mf +++ b/src/net/java/sip/communicator/plugin/reconnectplugin/reconnectplugin.manifest.mf @@ -13,5 +13,6 @@ Import-Package: org.osgi.framework, net.java.sip.communicator.service.protocol, net.java.sip.communicator.service.protocol.event, org.jitsi.service.resources, net.java.sip.communicator.service.resources, + org.jitsi.util, net.java.sip.communicator.util, net.java.sip.communicator.plugin.desktoputil