Fixes a memory leak in NotificationManager. Removes an unnecessary copying of a List in CallManager.

cusax-fix
Lyubomir Marinov 13 years ago
parent 0e62b4b8cb
commit 386c559bb2

@ -1200,11 +1200,11 @@ public static List<ProtocolProviderService> getTelephonyProviders()
}
/**
* Returns a collection of all currently active calls.
* Returns a list of all currently active calls.
*
* @return a collection of all currently active calls
* @return a list of all currently active calls
*/
public static Collection<Call> getActiveCalls()
private static List<Call> getActiveCalls()
{
CallConference[] conferences;
@ -1229,23 +1229,15 @@ public static Collection<Call> getActiveCalls()
}
/**
* Returns a collection of all currently in progress calls.
* Returns a collection of all currently in progress calls. A call is active
* if it is in progress so the method merely delegates to
* {@link #getActiveCalls()}.
*
* @return a collection of all currently in progress calls.
*/
public static Collection<Call> getInProgressCalls()
{
/* TODO Synchronize the access to the callPanels field. */
Collection<Call> calls = getActiveCalls();
List<Call> inProgressCalls = new ArrayList<Call>(calls.size());
for (Call call : calls)
{
if (call.getCallState() == CallState.CALL_IN_PROGRESS)
inProgressCalls.add(call);
}
return inProgressCalls;
return getActiveCalls();
}
/**

@ -80,7 +80,7 @@ private void play(
{
UIService uiService = NotificationActivator.getUIService();
if(uiService.getInProgressCalls().size() > 0)
if(!uiService.getInProgressCalls().isEmpty())
return;
}

@ -565,21 +565,6 @@ private static boolean shouldPlayDialingSound(
return play;
}
/**
* Stops all sounds for the given event type.
*
* @param data the event type for which we should stop sounds. One of
* the static event types defined in this class.
*/
public static void stopSound(NotificationData data)
{
NotificationService notificationService
= NotificationWiringActivator.getNotificationService();
if(notificationService != null)
notificationService.stopNotification(data);
}
/**
* Stores notification references to stop them if a notification has expired
* (e.g. to stop the dialing sound).
@ -617,7 +602,15 @@ public void callEnded(CallEvent ev)
}
catch(Throwable t)
{
logger.error("Error notifying for call ended", t);
if (t instanceof ThreadDeath)
throw (ThreadDeath) t;
else
{
logger.error(
"An error occurred while trying to notify"
+ " about the end of a call.",
t);
}
}
}
@ -1453,7 +1446,15 @@ else if ((newState == CallPeerState.DISCONNECTED)
}
catch(Throwable t)
{
logger.error("Error notifying after peer state changed", t);
if (t instanceof ThreadDeath)
throw (ThreadDeath) t;
else
{
logger.error(
"An error occurred while trying to notify"
+ " about a change in the state of a call peer.",
t);
}
}
}
@ -1539,13 +1540,12 @@ private void registerDefaultNotifications()
inCallSoundHandler);
// Register outgoing call notifications.
SoundNotificationAction outCallSoundHandler
= new SoundNotificationAction(
SoundProperties.OUTGOING_CALL, 3000, false, true, false);
notificationService.registerDefaultNotificationForEvent(
OUTGOING_CALL,
outCallSoundHandler);
new SoundNotificationAction(
SoundProperties.OUTGOING_CALL,
3000,
false, true, false));
// Register busy call notifications.
notificationService.registerDefaultNotificationForEvent(
@ -1766,6 +1766,46 @@ public void serviceChanged(ServiceEvent event)
}
}
/**
* Stops all sounds for the given event type.
*
* @param data the event type for which we should stop sounds. One of
* the static event types defined in this class.
*/
private void stopSound(NotificationData data)
{
if (data == null)
return;
try
{
NotificationService notificationService
= NotificationWiringActivator.getNotificationService();
if(notificationService != null)
notificationService.stopNotification(data);
}
finally
{
/*
* The field callNotifications associates a Call with a
* NotificationData for the purposes of the stopSound method so the
* stopSound method should dissociate them upon stopping a specific
* NotificationData.
*/
Iterator<Map.Entry<Call, NotificationData>> i
= callNotifications.entrySet().iterator();
while (i.hasNext())
{
Map.Entry<Call, NotificationData> e = i.next();
if (data.equals(e.getValue()))
i.remove();
}
}
}
/**
* {@inheritDoc}
*

Loading…
Cancel
Save