diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index ea2f2e74b..445c3ef8b 100755
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -74,6 +74,14 @@
+
+
+
+
+
@@ -122,14 +130,6 @@
-
-
-
-
-
0) {
- startIncallActivity();
- }
- } else if (extras != null && extras.getBoolean("StartCall", false)) {
- if (CallActivity.isInstanciated()) {
- CallActivity.instance().startIncomingCallActivity();
- } else {
- addressWaitingToBeCalled = extras.getString("NumberToCall");
- goToDialerFragment();
- }
- } else if (extras != null && extras.getBoolean("Transfer", false)) {
- intent.putExtra("DoNotGoToCallActivity", true);
- } else if (extras != null && extras.getBoolean("AddCall", false)) {
- intent.putExtra("DoNotGoToCallActivity", true);
- } else {
- DialerFragment dialerFragment = DialerFragment.instance();
- if (dialerFragment != null) {
- if (extras != null && extras.containsKey("SipUriOrNumber")) {
- if (getResources()
- .getBoolean(R.bool.automatically_start_intercepted_outgoing_gsm_call)) {
- dialerFragment.newOutgoingCall(extras.getString("SipUriOrNumber"));
- } else {
- dialerFragment.displayTextInAddressBar(extras.getString("SipUriOrNumber"));
- }
+ if (extras != null) {
+ if (extras.getBoolean("GoToChat", false)) {
+ String localSipUri = extras.getString("LocalSipUri");
+ String remoteSipUri = extras.getString("ChatContactSipUri");
+ Log.i(
+ "[Linphone Activity] Intent asked to go to chat, local URI "
+ + localSipUri
+ + ", remote URI "
+ + remoteSipUri);
+ intent.putExtra("DoNotGoToCallActivity", true);
+ if (remoteSipUri == null) {
+ goToChatList();
} else {
- dialerFragment.newOutgoingCall(intent);
+ goToChat(localSipUri, remoteSipUri, extras);
}
- } else {
- if (extras != null && extras.containsKey("SipUriOrNumber")) {
- addressWaitingToBeCalled = extras.getString("SipUriOrNumber");
+ } else if (extras.getBoolean("GoToHistory", false)) {
+ Log.i("[Linphone Activity] Intent asked to go to call history");
+ intent.putExtra("DoNotGoToCallActivity", true);
+ changeCurrentFragment(FragmentsAvailable.HISTORY_LIST, null);
+ } else if (extras.getBoolean("GoToInapp", false)) {
+ Log.i("[Linphone Activity] Intent asked to go to inapp");
+ intent.putExtra("DoNotGoToCallActivity", true);
+ displayInapp();
+ } else if (extras.getBoolean("Notification", false)) {
+ if (LinphoneManager.getLc().getCallsNb() > 0) {
+ startIncallActivity();
+ }
+ } else if (extras.getBoolean("StartCall", false)) {
+ if (CallActivity.isInstanciated()) {
+ CallActivity.instance().startIncomingCallActivity();
+ } else {
+ addressWaitingToBeCalled = extras.getString("NumberToCall");
goToDialerFragment();
}
- }
- if (LinphoneManager.getLc().getCalls().length > 0) {
- // If a call is ringing, start incomingcallactivity
- Collection incoming = new ArrayList<>();
- incoming.add(Call.State.IncomingReceived);
- if (LinphoneUtils.getCallsInState(LinphoneManager.getLc(), incoming).size() > 0) {
- if (CallActivity.isInstanciated()) {
- CallActivity.instance().startIncomingCallActivity();
- } else {
- startActivity(new Intent(this, CallIncomingActivity.class));
+ } else if (extras.getBoolean("Transfer", false)) {
+ intent.putExtra("DoNotGoToCallActivity", true);
+ } else if (extras.getBoolean("AddCall", false)) {
+ intent.putExtra("DoNotGoToCallActivity", true);
+ } else if (intent.getStringExtra("msgShared") != null) {
+ String message = intent.getStringExtra("msgShared");
+ Log.i(
+ "[Linphone Activity] Intent asked to go to chat list to share message "
+ + message);
+ extras.putString("messageDraft", message);
+ changeCurrentFragment(FragmentsAvailable.CHAT_LIST, extras);
+ intent.removeExtra("msgShared");
+ } else if (intent.getStringExtra("fileShared") != null
+ && !intent.getStringExtra("fileShared").equals("")) {
+ String file = intent.getStringExtra("fileShared");
+ Log.i(
+ "[Linphone Activity] Intent asked to go to chat list to share file(s) "
+ + file);
+ extras.putString("fileSharedUri", file);
+ changeCurrentFragment(FragmentsAvailable.CHAT_LIST, extras);
+ intent.removeExtra("fileShared");
+ } else {
+ DialerFragment dialerFragment = DialerFragment.instance();
+ if (dialerFragment != null) {
+ if (extras.containsKey("SipUriOrNumber")) {
+ if (getResources()
+ .getBoolean(
+ R.bool.automatically_start_intercepted_outgoing_gsm_call)) {
+ dialerFragment.newOutgoingCall(extras.getString("SipUriOrNumber"));
+ } else {
+ dialerFragment.displayTextInAddressBar(
+ extras.getString("SipUriOrNumber"));
+ }
+ }
+ } else {
+ if (extras.containsKey("SipUriOrNumber")) {
+ addressWaitingToBeCalled = extras.getString("SipUriOrNumber");
+ goToDialerFragment();
}
}
}
}
setIntent(intent);
+
+ if (LinphoneManager.getLc().getCalls().length > 0) {
+ // If a call is ringing, start incomingcallactivity
+ Collection incoming = new ArrayList<>();
+ incoming.add(Call.State.IncomingReceived);
+ if (LinphoneUtils.getCallsInState(LinphoneManager.getLc(), incoming).size() > 0) {
+ if (CallActivity.isInstanciated()) {
+ CallActivity.instance().startIncomingCallActivity();
+ } else {
+ startActivity(new Intent(this, CallIncomingActivity.class));
+ }
+ }
+ }
}
public boolean isOnBackground() {
diff --git a/app/src/main/java/org/linphone/LinphoneLauncherActivity.java b/app/src/main/java/org/linphone/LinphoneLauncherActivity.java
index ffe689976..2e9ef0d12 100644
--- a/app/src/main/java/org/linphone/LinphoneLauncherActivity.java
+++ b/app/src/main/java/org/linphone/LinphoneLauncherActivity.java
@@ -24,26 +24,16 @@ import static android.content.Intent.ACTION_MAIN;
import android.app.Activity;
import android.content.Intent;
import android.content.pm.ActivityInfo;
-import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
-import android.util.Log;
-import java.util.ArrayList;
import org.linphone.assistant.RemoteProvisioningActivity;
-import org.linphone.call.CallActivity;
-import org.linphone.contacts.ContactsManager;
import org.linphone.settings.LinphonePreferences;
-import org.linphone.utils.FileUtils;
/** Launch Linphone main activity when Service is ready. */
public class LinphoneLauncherActivity extends Activity {
- private final String ACTION_CALL_LINPHONE = "org.linphone.intent.action.CallLaunched";
-
private Handler mHandler;
private ServiceWaitThread mServiceThread;
- private String mAddressToCall;
- private Uri mUriToResolve;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -56,32 +46,6 @@ public class LinphoneLauncherActivity extends Activity {
mHandler = new Handler();
- Intent intent = getIntent();
- if (intent != null) {
- String action = intent.getAction();
- if (Intent.ACTION_CALL.equals(action)) {
- if (intent.getData() != null) {
- mAddressToCall = intent.getData().toString();
- mAddressToCall = mAddressToCall.replace("%40", "@");
- mAddressToCall = mAddressToCall.replace("%3A", ":");
- if (mAddressToCall.startsWith("sip:")) {
- mAddressToCall = mAddressToCall.substring("sip:".length());
- } else if (mAddressToCall.startsWith("tel:")) {
- mAddressToCall = mAddressToCall.substring("tel:".length());
- }
- }
- } else if (Intent.ACTION_VIEW.equals(action)) {
- if (LinphoneService.isReady()) {
- mAddressToCall =
- ContactsManager.getInstance()
- .getAddressOrNumberForAndroidContact(
- getContentResolver(), intent.getData());
- } else {
- mUriToResolve = intent.getData();
- }
- }
- }
-
if (LinphoneService.isReady()) {
onServiceReady();
} else {
@@ -108,66 +72,8 @@ public class LinphoneLauncherActivity extends Activity {
new Runnable() {
@Override
public void run() {
- Intent newIntent = new Intent(LinphoneLauncherActivity.this, classToStart);
- Intent intent = getIntent();
- String stringFileShared = null;
- String stringUriFileShared = null;
- Uri fileUri = null;
- if (intent != null) {
- String action = intent.getAction();
- String type = intent.getType();
- newIntent.setData(intent.getData());
- if (Intent.ACTION_SEND.equals(action) && type != null) {
- if (("text/plain").equals(type)
- && intent.getStringExtra(Intent.EXTRA_TEXT) != null) {
- stringFileShared = intent.getStringExtra(Intent.EXTRA_TEXT);
- newIntent.putExtra("msgShared", stringFileShared);
- } else {
- fileUri = intent.getParcelableExtra(Intent.EXTRA_STREAM);
- stringUriFileShared =
- FileUtils.getFilePath(getBaseContext(), fileUri);
- newIntent.putExtra("fileShared", stringUriFileShared);
- }
- } else if (Intent.ACTION_SEND_MULTIPLE.equals(action) && type != null) {
- if (type.startsWith("image/")) {
- ArrayList imageUris =
- intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM);
- String filePaths = "";
- for (Uri uri : imageUris) {
- filePaths += FileUtils.getFilePath(getBaseContext(), uri);
- filePaths += ":";
- }
- newIntent.putExtra("fileShared", filePaths);
- }
- } else if (ACTION_CALL_LINPHONE.equals(action)
- && (intent.getStringExtra("NumberToCall") != null)) {
- String numberToCall = intent.getStringExtra("NumberToCall");
- if (CallActivity.isInstanciated()) {
- CallActivity.instance().startIncomingCallActivity();
- } else {
- LinphoneManager.getInstance()
- .newOutgoingCall(numberToCall, null);
- }
- }
- }
- if (mUriToResolve != null) {
- mAddressToCall =
- ContactsManager.getInstance()
- .getAddressOrNumberForAndroidContact(
- getContentResolver(), mUriToResolve);
- Log.i(
- "LinphoneLauncher",
- "Intent has uri to resolve : " + mUriToResolve.toString());
- mUriToResolve = null;
- }
- if (mAddressToCall != null) {
- newIntent.putExtra("SipUriOrNumber", mAddressToCall);
- Log.i(
- "LinphoneLauncher",
- "Intent has address to call : " + mAddressToCall);
- mAddressToCall = null;
- }
- startActivity(newIntent);
+ Intent intent = new Intent(LinphoneLauncherActivity.this, classToStart);
+ startActivity(intent);
}
},
1000);
diff --git a/app/src/main/java/org/linphone/LinphoneService.java b/app/src/main/java/org/linphone/LinphoneService.java
index 56c963ae3..3bb0bb517 100644
--- a/app/src/main/java/org/linphone/LinphoneService.java
+++ b/app/src/main/java/org/linphone/LinphoneService.java
@@ -20,11 +20,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import android.app.Activity;
-import android.app.AlarmManager;
import android.app.Application;
-import android.app.PendingIntent;
import android.app.Service;
-import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager.NameNotFoundException;
@@ -32,7 +29,6 @@ import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
-import android.os.SystemClock;
import android.provider.ContactsContract;
import android.view.WindowManager;
import java.util.ArrayList;
@@ -52,7 +48,6 @@ import org.linphone.core.tools.Log;
import org.linphone.mediastream.Version;
import org.linphone.notifications.NotificationsManager;
import org.linphone.receivers.BluetoothManager;
-import org.linphone.receivers.KeepAliveReceiver;
import org.linphone.settings.LinphonePreferences;
import org.linphone.utils.LinphoneUtils;
import org.linphone.views.LinphoneGL2JNIViewOverlay;
@@ -175,7 +170,7 @@ public final class LinphoneService extends Service {
if (sInstance != null) {
Log.w("[Service] Attempt to start the LinphoneService but it is already running !");
- return START_REDELIVER_INTENT;
+ return START_STICKY;
}
LinphoneManager.createAndStart(this, isPush);
@@ -263,25 +258,9 @@ public final class LinphoneService extends Service {
5000);
}
- // make sure the application will at least wakes up every 10 mn
- if (LinphonePreferences.instance().isBackgroundModeEnabled()
- && (!LinphonePreferences.instance().isPushNotificationEnabled()
- || !LinphoneManager.getInstance().hasLinphoneAccount())) {
- Intent keepAliveIntent = new Intent(this, KeepAliveReceiver.class);
- PendingIntent keepAlivePendingIntent =
- PendingIntent.getBroadcast(
- this, 0, keepAliveIntent, PendingIntent.FLAG_ONE_SHOT);
- AlarmManager alarmManager =
- ((AlarmManager) this.getSystemService(Context.ALARM_SERVICE));
- alarmManager.setExact(
- AlarmManager.ELAPSED_REALTIME_WAKEUP,
- SystemClock.elapsedRealtime() + 600000,
- keepAlivePendingIntent);
- }
-
BluetoothManager.getInstance().initBluetooth();
- return START_REDELIVER_INTENT;
+ return START_STICKY;
}
@SuppressWarnings("unchecked")
diff --git a/app/src/main/java/org/linphone/utils/IntentUtils.java b/app/src/main/java/org/linphone/utils/IntentUtils.java
new file mode 100644
index 000000000..28c660185
--- /dev/null
+++ b/app/src/main/java/org/linphone/utils/IntentUtils.java
@@ -0,0 +1,106 @@
+package org.linphone.utils;
+
+/*
+IntentUtils.java
+Copyright (C) 2018 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+*/
+
+import android.content.Context;
+import android.content.Intent;
+import android.net.Uri;
+import java.util.ArrayList;
+import org.linphone.LinphoneActivity;
+import org.linphone.LinphoneManager;
+import org.linphone.call.CallActivity;
+import org.linphone.contacts.ContactsManager;
+import org.linphone.core.tools.Log;
+
+public class IntentUtils {
+ private static final String ACTION_CALL_LINPHONE = "org.linphone.intent.action.CallLaunched";
+
+ public static void handleIntent(Context context, Intent intent) {
+ if (intent == null) return;
+
+ Intent newIntent = new Intent(context, LinphoneActivity.class);
+ String stringFileShared;
+ String stringUriFileShared;
+ Uri fileUri;
+ String addressToCall;
+
+ String action = intent.getAction();
+ String type = intent.getType();
+ newIntent.setData(intent.getData());
+
+ if (Intent.ACTION_SEND.equals(action) && type != null) {
+ if (("text/plain").equals(type) && intent.getStringExtra(Intent.EXTRA_TEXT) != null) {
+ stringFileShared = intent.getStringExtra(Intent.EXTRA_TEXT);
+ newIntent.putExtra("msgShared", stringFileShared);
+ Log.i("[Intent Utils] ACTION_SEND with text/plain data: " + stringFileShared);
+ } else {
+ fileUri = intent.getParcelableExtra(Intent.EXTRA_STREAM);
+ stringUriFileShared = FileUtils.getFilePath(context, fileUri);
+ newIntent.putExtra("fileShared", stringUriFileShared);
+ Log.i("[Intent Utils] ACTION_SEND with file: " + stringUriFileShared);
+ }
+ } else if (Intent.ACTION_SEND_MULTIPLE.equals(action) && type != null) {
+ if (type.startsWith("image/")) {
+ ArrayList imageUris = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM);
+ String filePaths = "";
+ for (Uri uri : imageUris) {
+ filePaths += FileUtils.getFilePath(context, uri);
+ filePaths += ":";
+ }
+ newIntent.putExtra("fileShared", filePaths);
+ Log.i("[Intent Utils] ACTION_SEND_MULTIPLE with files: " + filePaths);
+ }
+ } else if (ACTION_CALL_LINPHONE.equals(action)
+ && (intent.getStringExtra("NumberToCall") != null)) {
+ String numberToCall = intent.getStringExtra("NumberToCall");
+ Log.i("[Intent Utils] ACTION_CALL_LINPHONE with number: " + numberToCall);
+ if (CallActivity.isInstanciated()) {
+ CallActivity.instance().startIncomingCallActivity();
+ } else {
+ LinphoneManager.getInstance().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());
+ }
+ Log.i("[Intent Utils] ACTION_CALL with number: " + addressToCall);
+ newIntent.putExtra("SipUriOrNumber", addressToCall);
+ }
+ } else if (Intent.ACTION_VIEW.equals(action)) {
+ addressToCall =
+ ContactsManager.getInstance()
+ .getAddressOrNumberForAndroidContact(
+ context.getContentResolver(), intent.getData());
+ newIntent.putExtra("SipUriOrNumber", addressToCall);
+ Log.i("[Intent Utils] ACTION_VIEW with number: " + addressToCall);
+ } else {
+ Log.i("[Intent Utils] Unknown action [" + action + "], skipping");
+ return;
+ }
+
+ context.startActivity(newIntent);
+ }
+}