Fixed crash & improved logs when linphone is started from a contact

This commit is contained in:
Sylvain Berfini 2019-05-17 10:51:04 +02:00
parent 5aeebfeb72
commit 9e0a441896
3 changed files with 24 additions and 22 deletions

View file

@ -87,19 +87,16 @@
android:name=".activities.DialerActivity" android:name=".activities.DialerActivity"
android:launchMode="singleTop"> android:launchMode="singleTop">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.DIAL" />
<action android:name="android.intent.action.CALL" /> <action android:name="android.intent.action.CALL" />
<action android:name="android.intent.action.CALL_PRIVILEGED" /> <action android:name="android.intent.action.CALL_PRIVILEGED" />
<category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.DEFAULT" />
<data android:scheme="tel" /> <data android:scheme="tel" />
<data android:scheme="sip" /> <data android:scheme="sip" />
</intent-filter> </intent-filter>
<intent-filter> <intent-filter>
<action android:name="android.intent.action.SENDTO" /> <action android:name="android.intent.action.SENDTO" />
<category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.DEFAULT" />
<data android:scheme="sip" /> <data android:scheme="sip" />
<data android:scheme="imto" /> <data android:scheme="imto" />
</intent-filter> </intent-filter>

View file

@ -190,10 +190,9 @@ public final class LinphoneService extends Service {
return START_STICKY; return START_STICKY;
} }
mLinphoneManager = new LinphoneManager(this); mLinphoneManager = new LinphoneManager(this);
sInstance = this; // sInstance is ready once linphone manager has been created sInstance = this; // sInstance is ready once linphone manager has been created
mNotificationManager = new NotificationsManager(this); mNotificationManager = new NotificationsManager(this);
if (Version.sdkAboveOrEqual(Version.API26_O_80) if (Version.sdkAboveOrEqual(Version.API26_O_80)
&& intent != null && intent != null

View file

@ -22,6 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
import android.Manifest; import android.Manifest;
import android.content.Intent; import android.content.Intent;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.TextureView; import android.view.TextureView;
@ -266,24 +267,29 @@ public class DialerActivity extends MainActivity implements AddressText.AddressC
String numberToCall = intent.getStringExtra("NumberToCall"); String numberToCall = intent.getStringExtra("NumberToCall");
Log.i("[Dialer] ACTION_CALL_LINPHONE with number: " + numberToCall); Log.i("[Dialer] ACTION_CALL_LINPHONE with number: " + numberToCall);
LinphoneManager.getCallManager().newOutgoingCall(numberToCall, null); LinphoneManager.getCallManager().newOutgoingCall(numberToCall, null);
} else if (Intent.ACTION_CALL.equals(action)) { } else {
if (intent.getData() != null) { Uri uri = intent.getData();
addressToCall = intent.getData().toString(); if (uri != null) {
addressToCall = addressToCall.replace("%40", "@"); Log.i("[Dialer] Intent data is: " + uri.toString());
addressToCall = addressToCall.replace("%3A", ":"); if (Intent.ACTION_CALL.equals(action)) {
if (addressToCall.startsWith("sip:")) { addressToCall = intent.getData().toString();
addressToCall = addressToCall.substring("sip:".length()); addressToCall = addressToCall.replace("%40", "@");
} else if (addressToCall.startsWith("tel:")) { addressToCall = addressToCall.replace("%3A", ":");
addressToCall = addressToCall.substring("tel:".length()); if (addressToCall.startsWith("sip:")) {
addressToCall = addressToCall.substring("sip:".length());
} else if (addressToCall.startsWith("tel:")) {
addressToCall = addressToCall.substring("tel:".length());
}
Log.i("[Dialer] ACTION_CALL with number: " + addressToCall);
} else {
addressToCall =
ContactsManager.getInstance()
.getAddressOrNumberForAndroidContact(getContentResolver(), uri);
Log.i("[Dialer] " + action + " with number: " + addressToCall);
} }
Log.i("[Dialer] ACTION_CALL with number: " + addressToCall); } else {
Log.w("[Dialer] Intent data is null for action " + action);
} }
} else if (Intent.ACTION_VIEW.equals(action)) {
addressToCall =
ContactsManager.getInstance()
.getAddressOrNumberForAndroidContact(
getContentResolver(), intent.getData());
Log.i("[Dialer] ACTION_VIEW with number: " + addressToCall);
} }
if (addressToCall != null) { if (addressToCall != null) {