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:launchMode="singleTop">
<intent-filter>
<action android:name="android.intent.action.DIAL" />
<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" />
<data android:scheme="sip" />
<data android:scheme="imto" />
</intent-filter>

View file

@ -190,10 +190,9 @@ public final class LinphoneService extends Service {
return START_STICKY;
}
mLinphoneManager = new LinphoneManager(this);
sInstance = this; // sInstance is ready once linphone manager has been created
mNotificationManager = new NotificationsManager(this);
if (Version.sdkAboveOrEqual(Version.API26_O_80)
&& 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.content.Intent;
import android.content.res.Configuration;
import android.net.Uri;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.TextureView;
@ -266,24 +267,29 @@ public class DialerActivity extends MainActivity implements AddressText.AddressC
String numberToCall = intent.getStringExtra("NumberToCall");
Log.i("[Dialer] ACTION_CALL_LINPHONE with number: " + numberToCall);
LinphoneManager.getCallManager().newOutgoingCall(numberToCall, null);
} else if (Intent.ACTION_CALL.equals(action)) {
if (intent.getData() != null) {
addressToCall = intent.getData().toString();
addressToCall = addressToCall.replace("%40", "@");
addressToCall = addressToCall.replace("%3A", ":");
if (addressToCall.startsWith("sip:")) {
addressToCall = addressToCall.substring("sip:".length());
} else if (addressToCall.startsWith("tel:")) {
addressToCall = addressToCall.substring("tel:".length());
} else {
Uri uri = intent.getData();
if (uri != null) {
Log.i("[Dialer] Intent data is: " + uri.toString());
if (Intent.ACTION_CALL.equals(action)) {
addressToCall = intent.getData().toString();
addressToCall = addressToCall.replace("%40", "@");
addressToCall = addressToCall.replace("%3A", ":");
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) {