Improved way of intercepting outgoing gsm calls
This commit is contained in:
parent
b92cb53be8
commit
e74402bd30
7 changed files with 101 additions and 13 deletions
|
@ -2,7 +2,7 @@
|
|||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="org.linphone"
|
||||
android:versionCode="2211" android:installLocation="auto">
|
||||
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="17"/>
|
||||
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="19"/>
|
||||
|
||||
<!-- Permissions for Push Notification -->
|
||||
<permission android:name="org.linphone.permission.C2D_MESSAGE" android:protectionLevel="signature" /> <!-- Change package ! -->
|
||||
|
@ -50,14 +50,6 @@
|
|||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.CALL" />
|
||||
<action android:name="android.intent.action.CALL_PRIVILEGED" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<data android:scheme="tel" />
|
||||
<data android:scheme="sip" />
|
||||
</intent-filter>
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.SENDTO" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
|
@ -107,6 +99,12 @@
|
|||
android:label="@string/service_name"
|
||||
android:stopWithTask="false"/>
|
||||
|
||||
<receiver android:name="org.linphone.AndroidCallInterceptor">
|
||||
<intent-filter android:priority="0">
|
||||
<action android:name="android.intent.action.NEW_OUTGOING_CALL" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
<receiver android:name="org.linphone.NetworkManager">
|
||||
<intent-filter><action android:name="android.net.conn.CONNECTIVITY_CHANGE"></action></intent-filter>
|
||||
</receiver>
|
||||
|
|
|
@ -67,6 +67,8 @@
|
|||
<bool name="disable_chat_send_file">false</bool>
|
||||
<bool name="use_linphone_chat_storage">true</bool>
|
||||
<bool name="auto_answer_calls">false</bool>
|
||||
<bool name="intercept_outgoing_gsm_calls">false</bool>
|
||||
<bool name="automatically_start_intercepted_outgoing_gsm_call">true</bool>
|
||||
|
||||
<bool name="hash_images_as_name_before_upload">true</bool>
|
||||
|
||||
|
|
44
src/org/linphone/AndroidCallInterceptor.java
Normal file
44
src/org/linphone/AndroidCallInterceptor.java
Normal file
|
@ -0,0 +1,44 @@
|
|||
package org.linphone;
|
||||
|
||||
/*
|
||||
AndroidCallInterceptor.java
|
||||
Copyright (C) 2014 Belledonne Communications, Grenoble, France
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
public class AndroidCallInterceptor extends BroadcastReceiver {
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
String phoneNumber = getResultData();
|
||||
if (phoneNumber == null) {
|
||||
phoneNumber = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
|
||||
}
|
||||
|
||||
if (context.getResources().getBoolean(R.bool.intercept_outgoing_gsm_calls) || LinphonePreferences.instance().interceptOutgoingGSMCalls()) {
|
||||
setResultData(null);
|
||||
Intent i = new Intent();
|
||||
i.setClass(context, LinphoneActivity.class);
|
||||
i.putExtra("SipUriOrNumber", phoneNumber);
|
||||
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
context.startActivity(i);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,5 +1,24 @@
|
|||
package org.linphone;
|
||||
|
||||
/*
|
||||
BluetoothActionReceiver.java
|
||||
Copyright (C) 2014 Belledonne Communications, Grenoble, France
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
import org.linphone.mediastream.Log;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
|
|
|
@ -185,6 +185,16 @@ public class DialerFragment extends Fragment {
|
|||
mAddContact.setEnabled(LinphoneManager.getLc().getCallsNb() > 0 || !mAddress.getText().toString().equals(""));
|
||||
}
|
||||
|
||||
public void displayTextInAddressBar(String numberOrSipAddress) {
|
||||
shouldEmptyAddressField = false;
|
||||
mAddress.setText(numberOrSipAddress);
|
||||
}
|
||||
|
||||
public void newOutgoingCall(String numberOrSipAddress) {
|
||||
displayTextInAddressBar(numberOrSipAddress);
|
||||
LinphoneManager.getInstance().newOutgoingCall(mAddress);
|
||||
}
|
||||
|
||||
public void newOutgoingCall(Intent intent) {
|
||||
if (intent != null && intent.getData() != null) {
|
||||
String scheme = intent.getData().getScheme();
|
||||
|
|
|
@ -282,8 +282,12 @@ public class LinphoneActivity extends FragmentActivity implements
|
|||
newFragment = new HistoryDetailFragment();
|
||||
break;
|
||||
case CONTACTS:
|
||||
newFragment = new ContactsFragment();
|
||||
friendStatusListenerFragment = newFragment;
|
||||
if (getResources().getBoolean(R.bool.use_android_native_contact_edit_interface)) {
|
||||
|
||||
} else {
|
||||
newFragment = new ContactsFragment();
|
||||
friendStatusListenerFragment = newFragment;
|
||||
}
|
||||
break;
|
||||
case CONTACT:
|
||||
newFragment = new ContactFragment();
|
||||
|
@ -1302,7 +1306,15 @@ public class LinphoneActivity extends FragmentActivity implements
|
|||
}
|
||||
} else {
|
||||
if (dialerFragment != null) {
|
||||
((DialerFragment) dialerFragment).newOutgoingCall(intent);
|
||||
if (extras.containsKey("SipUriOrNumber")) {
|
||||
if (getResources().getBoolean(R.bool.automatically_start_intercepted_outgoing_gsm_call)) {
|
||||
((DialerFragment) dialerFragment).newOutgoingCall(extras.getString("SipUriOrNumber"));
|
||||
} else {
|
||||
((DialerFragment) dialerFragment).displayTextInAddressBar(extras.getString("SipUriOrNumber"));
|
||||
}
|
||||
} else {
|
||||
((DialerFragment) dialerFragment).newOutgoingCall(intent);
|
||||
}
|
||||
}
|
||||
if (LinphoneManager.getLc().getCalls().length > 0) {
|
||||
LinphoneCall calls[] = LinphoneManager.getLc().getCalls();
|
||||
|
|
|
@ -810,4 +810,7 @@ public class LinphonePreferences {
|
|||
}
|
||||
// End of tunnel settings
|
||||
|
||||
public boolean interceptOutgoingGSMCalls() {
|
||||
return getConfig().getBool("app", "intercept_outgoing_gsm_calls", false);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue