Reject incoming sip calls when using GSM.
This commit is contained in:
parent
c4838ad1fa
commit
353ef0cf37
2 changed files with 18 additions and 3 deletions
|
@ -96,6 +96,7 @@ import android.os.PowerManager.WakeLock;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.provider.Settings.SettingNotFoundException;
|
import android.provider.Settings.SettingNotFoundException;
|
||||||
|
import android.telephony.TelephonyManager;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
|
@ -158,6 +159,8 @@ public final class LinphoneManager implements LinphoneCoreListener {
|
||||||
mPref = PreferenceManager.getDefaultSharedPreferences(c);
|
mPref = PreferenceManager.getDefaultSharedPreferences(c);
|
||||||
mPowerManager = (PowerManager) c.getSystemService(Context.POWER_SERVICE);
|
mPowerManager = (PowerManager) c.getSystemService(Context.POWER_SERVICE);
|
||||||
mR = c.getResources();
|
mR = c.getResources();
|
||||||
|
TelephonyManager tm = (TelephonyManager) c.getSystemService(Context.TELEPHONY_SERVICE);
|
||||||
|
gsmIdle = tm.getCallState() == TelephonyManager.CALL_STATE_IDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final int LINPHONE_VOLUME_STREAM = STREAM_VOICE_CALL;
|
private static final int LINPHONE_VOLUME_STREAM = STREAM_VOICE_CALL;
|
||||||
|
@ -752,7 +755,7 @@ public final class LinphoneManager implements LinphoneCoreListener {
|
||||||
listenerDispatcher.onRegistrationStateChanged(state, message);
|
listenerDispatcher.onRegistrationStateChanged(state, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean gsmIdle;
|
||||||
public void callState(final LinphoneCore lc,final LinphoneCall call, final State state, final String message) {
|
public void callState(final LinphoneCore lc,final LinphoneCall call, final State state, final String message) {
|
||||||
Log.i("new state [",state,"]");
|
Log.i("new state [",state,"]");
|
||||||
if (state == IncomingReceived && !call.equals(lc.getCurrentCall())) {
|
if (state == IncomingReceived && !call.equals(lc.getCurrentCall())) {
|
||||||
|
@ -764,6 +767,9 @@ public final class LinphoneManager implements LinphoneCoreListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state == IncomingReceived) {
|
if (state == IncomingReceived) {
|
||||||
|
if (!gsmIdle) {
|
||||||
|
mLc.terminateCall(call);
|
||||||
|
}
|
||||||
// Brighten screen for at least 10 seconds
|
// Brighten screen for at least 10 seconds
|
||||||
WakeLock wl = mPowerManager.newWakeLock(
|
WakeLock wl = mPowerManager.newWakeLock(
|
||||||
PowerManager.ACQUIRE_CAUSES_WAKEUP
|
PowerManager.ACQUIRE_CAUSES_WAKEUP
|
||||||
|
|
|
@ -18,6 +18,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
package org.linphone;
|
package org.linphone;
|
||||||
|
|
||||||
|
import org.linphone.core.Log;
|
||||||
|
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
@ -33,15 +35,22 @@ public class PhoneStateChangedReceiver extends BroadcastReceiver {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
|
||||||
|
|
||||||
final String extraState = intent.getStringExtra(TelephonyManager.EXTRA_STATE);
|
final String extraState = intent.getStringExtra(TelephonyManager.EXTRA_STATE);
|
||||||
|
|
||||||
if (TelephonyManager.EXTRA_STATE_RINGING.equals(extraState) || TelephonyManager.EXTRA_STATE_OFFHOOK.equals(extraState)) {
|
if (TelephonyManager.EXTRA_STATE_RINGING.equals(extraState) || TelephonyManager.EXTRA_STATE_OFFHOOK.equals(extraState)) {
|
||||||
|
LinphoneManager.gsmIdle = false;
|
||||||
if (LinphoneManager.isInstanciated()) {
|
if (LinphoneManager.isInstanciated()) {
|
||||||
LinphoneManager.getLc().pauseAllCalls();
|
Log.i("GSM call state changed but manager not instantiated");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
LinphoneManager.getLc().pauseAllCalls();
|
||||||
|
} else if (TelephonyManager.EXTRA_STATE_IDLE.equals(extraState)) {
|
||||||
|
LinphoneManager.gsmIdle = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TelephonyManager.EXTRA_STATE_IDLE.equals(extraState)
|
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue