Filters out too frequent "network down" notifications on Android. Fixes exception when trying to load not supported native library on Android.

cusax-fix 4872
paweldomas 12 years ago
parent a8517a64b2
commit 1a5724af4b

@ -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)
{

@ -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<ProtocolProviderService> 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);
}
}

@ -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

Loading…
Cancel
Save