#16928: CallActivity must also listen for Broadcast from SipService
diff --git a/src/com/savoirfairelinux/sflphone/client/CallActivity.java b/src/com/savoirfairelinux/sflphone/client/CallActivity.java
index d032e8d..ddbd230 100644
--- a/src/com/savoirfairelinux/sflphone/client/CallActivity.java
+++ b/src/com/savoirfairelinux/sflphone/client/CallActivity.java
@@ -32,13 +32,16 @@
package com.savoirfairelinux.sflphone.client;
import android.app.Activity;
+import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.ComponentName;
import android.content.Intent;
+import android.content.IntentFilter;
import android.content.ServiceConnection;
import android.os.Bundle;
import android.os.IBinder;
import android.os.RemoteException;
+import android.support.v4.content.LocalBroadcastManager;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
@@ -54,6 +57,19 @@
private ISipService service;
private SipCall mCall;
+ private BroadcastReceiver mMessageReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ String signalName = intent.getStringExtra("signal-name");
+ Log.d(TAG, "Signal received: " + signalName);
+
+ if(signalName.equals("new-call-created")) {
+ } else if(signalName.equals("call-state-changed")) {
+ } else if(signalName.equals("incoming-call")) {
+ }
+ }
+ };
+
@Override
protected void onCreate(Bundle savedInstanceState)
{
@@ -71,11 +87,15 @@
findViewById(R.id.buttonhangup).setOnClickListener(this);
+ LocalBroadcastManager.getInstance(this).registerReceiver(mMessageReceiver, new IntentFilter("new-call-created"));
+ LocalBroadcastManager.getInstance(this).registerReceiver(mMessageReceiver, new IntentFilter("call-state-changed"));
+ LocalBroadcastManager.getInstance(this).registerReceiver(mMessageReceiver, new IntentFilter("incoming-call"));
}
@Override
protected void onDestroy() {
- stopService(new Intent(this, SipService.class));
+ LocalBroadcastManager.getInstance(this).unregisterReceiver(mMessageReceiver);
+ unbindService(mConnection);
super.onDestroy();
}
@@ -96,7 +116,7 @@
{
Log.i(TAG, "On click action");
if(view.getId() == R.id.buttonhangup) {
- mCall.hangup(service);
+ mCall.notifyServiceHangup(service);
// terminate this activity
finish();
}
diff --git a/src/com/savoirfairelinux/sflphone/client/CallElementList.java b/src/com/savoirfairelinux/sflphone/client/CallElementList.java
index cbbe17a..a855b43 100644
--- a/src/com/savoirfairelinux/sflphone/client/CallElementList.java
+++ b/src/com/savoirfairelinux/sflphone/client/CallElementList.java
@@ -289,17 +289,17 @@
Log.i(TAG, "Selected " + items[item]);
switch (item) {
case 0:
- call.hangup(service);
+ call.notifyServiceHangup(service);
break;
case 1:
call.sendTextMessage();
// Need to hangup this call immediately since no way to do it after this action
- call.hangup(service);
+ call.notifyServiceHangup(service);
break;
case 2:
call.addToConference();
// Need to hangup this call immediately since no way to do it after this action
- call.hangup(service);
+ call.notifyServiceHangup(service);
break;
default:
break;
@@ -354,7 +354,7 @@
// Insert desired behavior here.
Log.i(TAG, "Item clicked: " + id);
SipCall call = (SipCall) mAdapter.getItem(position);
- call.hangup(service);
+ call.notifyServiceHangup(service);
}
@Override
diff --git a/src/com/savoirfairelinux/sflphone/client/ContactListFragment.java b/src/com/savoirfairelinux/sflphone/client/ContactListFragment.java
index 0cf95b4..54209c1 100644
--- a/src/com/savoirfairelinux/sflphone/client/ContactListFragment.java
+++ b/src/com/savoirfairelinux/sflphone/client/ContactListFragment.java
@@ -232,12 +232,12 @@
case 1:
call.sendTextMessage();
// Need to hangup this call immediately since no way to do it after this action
- call.hangup(service);
+ call.notifyServiceHangup(service);
break;
case 2:
call.addToConference();
// Need to hangup this call immediately since no way to do it after this action
- call.hangup(service);
+ call.notifyServiceHangup(service);
break;
default:
break;
diff --git a/src/com/savoirfairelinux/sflphone/client/SipCall.java b/src/com/savoirfairelinux/sflphone/client/SipCall.java
index ed1aee8..2babf81 100644
--- a/src/com/savoirfairelinux/sflphone/client/SipCall.java
+++ b/src/com/savoirfairelinux/sflphone/client/SipCall.java
@@ -37,11 +37,13 @@
import java.util.ArrayList;
import com.savoirfairelinux.sflphone.service.ISipService;
+import com.savoirfairelinux.sflphone.client.CallActivity;
public class SipCall
{
final static String TAG = "SipCall";
public static CallElementList mCallElementList = null;
+ private static CallActivity mCallActivity = null;
public CallInfo mCallInfo;
public static int CALL_STATE_INVALID = 0; // The call is not existent in SFLphone service
@@ -145,13 +147,24 @@
}
- public void hangup(ISipService service)
- {
+ /**
+ * Perform hangup action without sending request to the service
+ */
+ public void hangup() {
Log.i(TAG, "Hangup call " + mCallInfo.mCallID);
if(mCallElementList != null)
mCallElementList.removeCall(this);
+ if(mCallActivity != null)
+ mCallActivity.finish();
+ }
+
+ /**
+ * Perform hangup action and send request to the service
+ */
+ public void notifyServiceHangup(ISipService service)
+ {
try {
service.hangUp(mCallInfo.mCallID);
} catch (RemoteException e) {