Improved way to ensure Service is running when UI resumes
This commit is contained in:
parent
6187466b06
commit
8d5e5f0c8f
43 changed files with 544 additions and 446 deletions
291
app/src/main/java/org/linphone/LinphoneContext.java
Normal file
291
app/src/main/java/org/linphone/LinphoneContext.java
Normal file
|
@ -0,0 +1,291 @@
|
||||||
|
package org.linphone;
|
||||||
|
|
||||||
|
/*
|
||||||
|
LinphoneContext.java
|
||||||
|
Copyright (C) 2019 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.app.Activity;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.pm.PackageInfo;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.provider.ContactsContract;
|
||||||
|
import org.linphone.call.CallActivity;
|
||||||
|
import org.linphone.call.CallIncomingActivity;
|
||||||
|
import org.linphone.call.CallOutgoingActivity;
|
||||||
|
import org.linphone.contacts.ContactsManager;
|
||||||
|
import org.linphone.core.Call;
|
||||||
|
import org.linphone.core.Core;
|
||||||
|
import org.linphone.core.CoreListenerStub;
|
||||||
|
import org.linphone.core.Factory;
|
||||||
|
import org.linphone.core.LogLevel;
|
||||||
|
import org.linphone.core.LoggingService;
|
||||||
|
import org.linphone.core.LoggingServiceListener;
|
||||||
|
import org.linphone.core.tools.Log;
|
||||||
|
import org.linphone.mediastream.Version;
|
||||||
|
import org.linphone.notifications.NotificationsManager;
|
||||||
|
import org.linphone.settings.LinphonePreferences;
|
||||||
|
import org.linphone.utils.LinphoneUtils;
|
||||||
|
|
||||||
|
public class LinphoneContext {
|
||||||
|
private static final String START_LINPHONE_LOGS = " ==== Phone information dump ====";
|
||||||
|
private static LinphoneContext sInstance = null;
|
||||||
|
|
||||||
|
private Context mContext;
|
||||||
|
public final Handler handler = new Handler();
|
||||||
|
|
||||||
|
private final LoggingServiceListener mJavaLoggingService =
|
||||||
|
new LoggingServiceListener() {
|
||||||
|
@Override
|
||||||
|
public void onLogMessageWritten(
|
||||||
|
LoggingService logService, String domain, LogLevel lev, String message) {
|
||||||
|
switch (lev) {
|
||||||
|
case Debug:
|
||||||
|
android.util.Log.d(domain, message);
|
||||||
|
break;
|
||||||
|
case Message:
|
||||||
|
android.util.Log.i(domain, message);
|
||||||
|
break;
|
||||||
|
case Warning:
|
||||||
|
android.util.Log.w(domain, message);
|
||||||
|
break;
|
||||||
|
case Error:
|
||||||
|
android.util.Log.e(domain, message);
|
||||||
|
break;
|
||||||
|
case Fatal:
|
||||||
|
default:
|
||||||
|
android.util.Log.wtf(domain, message);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
private CoreListenerStub mListener;
|
||||||
|
private NotificationsManager mNotificationManager;
|
||||||
|
private LinphoneManager mLinphoneManager;
|
||||||
|
private ContactsManager mContactsManager;
|
||||||
|
|
||||||
|
private Class<? extends Activity> mIncomingReceivedActivity = CallIncomingActivity.class;
|
||||||
|
|
||||||
|
public static boolean isReady() {
|
||||||
|
return sInstance != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static LinphoneContext instance() {
|
||||||
|
return sInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LinphoneContext(Context context) {
|
||||||
|
mContext = context;
|
||||||
|
|
||||||
|
LinphonePreferences.instance().setContext(context);
|
||||||
|
Factory.instance().setLogCollectionPath(context.getFilesDir().getAbsolutePath());
|
||||||
|
boolean isDebugEnabled = LinphonePreferences.instance().isDebugEnabled();
|
||||||
|
LinphoneUtils.configureLoggingService(isDebugEnabled, context.getString(R.string.app_name));
|
||||||
|
|
||||||
|
// Dump some debugging information to the logs
|
||||||
|
Log.i(START_LINPHONE_LOGS);
|
||||||
|
dumpDeviceInformation();
|
||||||
|
dumpInstalledLinphoneInformation();
|
||||||
|
|
||||||
|
String incomingReceivedActivityName =
|
||||||
|
LinphonePreferences.instance().getActivityToLaunchOnIncomingReceived();
|
||||||
|
try {
|
||||||
|
mIncomingReceivedActivity =
|
||||||
|
(Class<? extends Activity>) Class.forName(incomingReceivedActivityName);
|
||||||
|
} catch (ClassNotFoundException e) {
|
||||||
|
Log.e(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
sInstance = this;
|
||||||
|
Log.i("[Context] Ready");
|
||||||
|
|
||||||
|
mListener =
|
||||||
|
new CoreListenerStub() {
|
||||||
|
@Override
|
||||||
|
public void onCallStateChanged(
|
||||||
|
Core core, Call call, Call.State state, String message) {
|
||||||
|
if (mContext.getResources().getBoolean(R.bool.enable_call_notification)) {
|
||||||
|
mNotificationManager.displayCallNotification(call);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state == Call.State.IncomingReceived
|
||||||
|
|| state == Call.State.IncomingEarlyMedia) {
|
||||||
|
// Starting SDK 24 (Android 7.0) we rely on the fullscreen intent of the
|
||||||
|
// call incoming notification
|
||||||
|
if (Version.sdkStrictlyBelow(Version.API24_NOUGAT_70)) {
|
||||||
|
if (!mLinphoneManager.getCallGsmON()) onIncomingReceived();
|
||||||
|
}
|
||||||
|
} else if (state == Call.State.OutgoingInit) {
|
||||||
|
onOutgoingStarted();
|
||||||
|
} else if (state == Call.State.Connected) {
|
||||||
|
onCallStarted();
|
||||||
|
} else if (state == Call.State.End
|
||||||
|
|| state == Call.State.Released
|
||||||
|
|| state == Call.State.Error) {
|
||||||
|
if (LinphoneService.isReady()) {
|
||||||
|
LinphoneService.instance().destroyOverlay();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state == Call.State.Released
|
||||||
|
&& call.getCallLog().getStatus() == Call.Status.Missed) {
|
||||||
|
mNotificationManager.displayMissedCallNotification(call);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
mLinphoneManager = new LinphoneManager(context);
|
||||||
|
mNotificationManager = new NotificationsManager(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void start(boolean isPush) {
|
||||||
|
Log.i("[Context] Starting");
|
||||||
|
mLinphoneManager.startLibLinphone(isPush);
|
||||||
|
LinphoneManager.getCore().addListener(mListener);
|
||||||
|
|
||||||
|
mNotificationManager.onCoreReady();
|
||||||
|
|
||||||
|
mContactsManager = new ContactsManager(mContext, handler);
|
||||||
|
if (!Version.sdkAboveOrEqual(Version.API26_O_80)
|
||||||
|
|| (mContactsManager.hasReadContactsAccess())) {
|
||||||
|
mContext.getContentResolver()
|
||||||
|
.registerContentObserver(
|
||||||
|
ContactsContract.Contacts.CONTENT_URI, true, mContactsManager);
|
||||||
|
}
|
||||||
|
if (mContactsManager.hasReadContactsAccess()) {
|
||||||
|
mContactsManager.enableContactsAccess();
|
||||||
|
}
|
||||||
|
mContactsManager.initializeContactManager();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void destroy() {
|
||||||
|
Log.i("[Context] Destroying");
|
||||||
|
Core core = LinphoneManager.getCore();
|
||||||
|
if (core != null) {
|
||||||
|
core.removeListener(mListener);
|
||||||
|
core = null; // To allow the gc calls below to free the Core
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make sure our notification is gone.
|
||||||
|
if (mNotificationManager != null) {
|
||||||
|
mNotificationManager.destroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mContactsManager != null) {
|
||||||
|
mContactsManager.destroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Destroy the LinphoneManager second to last to ensure any getCore() call will work
|
||||||
|
if (mLinphoneManager != null) {
|
||||||
|
mLinphoneManager.destroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Wait for every other object to be destroyed to make LinphoneService.instance() invalid
|
||||||
|
sInstance = null;
|
||||||
|
|
||||||
|
if (LinphonePreferences.instance().useJavaLogger()) {
|
||||||
|
Factory.instance().getLoggingService().removeListener(mJavaLoggingService);
|
||||||
|
}
|
||||||
|
LinphonePreferences.instance().destroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateContext(Context context) {
|
||||||
|
mContext = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Context getApplicationContext() {
|
||||||
|
return mContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Managers accessors */
|
||||||
|
|
||||||
|
public LoggingServiceListener getJavaLoggingService() {
|
||||||
|
return mJavaLoggingService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public NotificationsManager getNotificationManager() {
|
||||||
|
return mNotificationManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LinphoneManager getLinphoneManager() {
|
||||||
|
return mLinphoneManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ContactsManager getContactsManager() {
|
||||||
|
return mContactsManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Log device related information */
|
||||||
|
|
||||||
|
private void dumpDeviceInformation() {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append("DEVICE=").append(Build.DEVICE).append("\n");
|
||||||
|
sb.append("MODEL=").append(Build.MODEL).append("\n");
|
||||||
|
sb.append("MANUFACTURER=").append(Build.MANUFACTURER).append("\n");
|
||||||
|
sb.append("SDK=").append(Build.VERSION.SDK_INT).append("\n");
|
||||||
|
sb.append("Supported ABIs=");
|
||||||
|
for (String abi : Version.getCpuAbis()) {
|
||||||
|
sb.append(abi).append(", ");
|
||||||
|
}
|
||||||
|
sb.append("\n");
|
||||||
|
Log.i(sb.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void dumpInstalledLinphoneInformation() {
|
||||||
|
PackageInfo info = null;
|
||||||
|
try {
|
||||||
|
info = mContext.getPackageManager().getPackageInfo(mContext.getPackageName(), 0);
|
||||||
|
} catch (PackageManager.NameNotFoundException nnfe) {
|
||||||
|
Log.e(nnfe);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (info != null) {
|
||||||
|
Log.i(
|
||||||
|
"[Context] Linphone version is ",
|
||||||
|
info.versionName + " (" + info.versionCode + ")");
|
||||||
|
} else {
|
||||||
|
Log.i("[Context] Linphone version is unknown");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Call activities */
|
||||||
|
|
||||||
|
private void onIncomingReceived() {
|
||||||
|
Intent intent = new Intent().setClass(mContext, mIncomingReceivedActivity);
|
||||||
|
// This flag is required to start an Activity from a Service context
|
||||||
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
mContext.startActivity(intent);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onOutgoingStarted() {
|
||||||
|
Intent intent = new Intent(mContext, CallOutgoingActivity.class);
|
||||||
|
// This flag is required to start an Activity from a Service context
|
||||||
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
mContext.startActivity(intent);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onCallStarted() {
|
||||||
|
Intent intent = new Intent(mContext, CallActivity.class);
|
||||||
|
// This flag is required to start an Activity from a Service context
|
||||||
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
mContext.startActivity(intent);
|
||||||
|
}
|
||||||
|
}
|
|
@ -299,7 +299,7 @@ public class LinphoneManager implements SensorEventListener {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFriendListCreated(Core core, FriendList list) {
|
public void onFriendListCreated(Core core, FriendList list) {
|
||||||
if (LinphoneService.isReady()) {
|
if (LinphoneContext.isReady()) {
|
||||||
list.addListener(ContactsManager.getInstance());
|
list.addListener(ContactsManager.getInstance());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -345,7 +345,7 @@ public class LinphoneManager implements SensorEventListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static synchronized LinphoneManager getInstance() {
|
public static synchronized LinphoneManager getInstance() {
|
||||||
LinphoneManager manager = LinphoneService.instance().getLinphoneManager();
|
LinphoneManager manager = LinphoneContext.instance().getLinphoneManager();
|
||||||
if (manager == null) {
|
if (manager == null) {
|
||||||
throw new RuntimeException(
|
throw new RuntimeException(
|
||||||
"[Manager] Linphone Manager should be created before accessed");
|
"[Manager] Linphone Manager should be created before accessed");
|
||||||
|
|
|
@ -19,90 +19,28 @@ along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
import android.app.Service;
|
import android.app.Service;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.PackageInfo;
|
|
||||||
import android.content.pm.PackageManager.NameNotFoundException;
|
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Handler;
|
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.provider.ContactsContract;
|
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import org.linphone.call.CallActivity;
|
|
||||||
import org.linphone.call.CallIncomingActivity;
|
|
||||||
import org.linphone.call.CallOutgoingActivity;
|
|
||||||
import org.linphone.contacts.ContactsManager;
|
|
||||||
import org.linphone.core.Call;
|
import org.linphone.core.Call;
|
||||||
import org.linphone.core.Call.State;
|
|
||||||
import org.linphone.core.Core;
|
import org.linphone.core.Core;
|
||||||
import org.linphone.core.CoreListenerStub;
|
|
||||||
import org.linphone.core.Factory;
|
|
||||||
import org.linphone.core.LogLevel;
|
|
||||||
import org.linphone.core.LoggingService;
|
|
||||||
import org.linphone.core.LoggingServiceListener;
|
|
||||||
import org.linphone.core.tools.Log;
|
import org.linphone.core.tools.Log;
|
||||||
import org.linphone.mediastream.Version;
|
import org.linphone.mediastream.Version;
|
||||||
import org.linphone.notifications.NotificationsManager;
|
|
||||||
import org.linphone.settings.LinphonePreferences;
|
import org.linphone.settings.LinphonePreferences;
|
||||||
import org.linphone.utils.ActivityMonitor;
|
import org.linphone.utils.ActivityMonitor;
|
||||||
import org.linphone.utils.LinphoneUtils;
|
|
||||||
import org.linphone.views.LinphoneGL2JNIViewOverlay;
|
import org.linphone.views.LinphoneGL2JNIViewOverlay;
|
||||||
import org.linphone.views.LinphoneOverlay;
|
import org.linphone.views.LinphoneOverlay;
|
||||||
import org.linphone.views.LinphoneTextureViewOverlay;
|
import org.linphone.views.LinphoneTextureViewOverlay;
|
||||||
|
|
||||||
/**
|
|
||||||
* Linphone service, reacting to Incoming calls, ...<br>
|
|
||||||
*
|
|
||||||
* <p>Roles include:
|
|
||||||
*
|
|
||||||
* <ul>
|
|
||||||
* <li>Initializing LinphoneManager
|
|
||||||
* <li>Starting C libLinphone through LinphoneManager
|
|
||||||
* <li>Reacting to LinphoneManager state changes
|
|
||||||
* <li>Delegating GUI state change actions to GUI listener
|
|
||||||
*/
|
|
||||||
public final class LinphoneService extends Service {
|
public final class LinphoneService extends Service {
|
||||||
private static final String START_LINPHONE_LOGS = " ==== Phone information dump ====";
|
|
||||||
private static LinphoneService sInstance;
|
private static LinphoneService sInstance;
|
||||||
|
|
||||||
public final Handler handler = new Handler();
|
|
||||||
private LinphoneOverlay mOverlay;
|
private LinphoneOverlay mOverlay;
|
||||||
private WindowManager mWindowManager;
|
private WindowManager mWindowManager;
|
||||||
private Application.ActivityLifecycleCallbacks mActivityCallbacks;
|
private Application.ActivityLifecycleCallbacks mActivityCallbacks;
|
||||||
|
private boolean misLinphoneContextOwned;
|
||||||
private final LoggingServiceListener mJavaLoggingService =
|
|
||||||
new LoggingServiceListener() {
|
|
||||||
@Override
|
|
||||||
public void onLogMessageWritten(
|
|
||||||
LoggingService logService, String domain, LogLevel lev, String message) {
|
|
||||||
switch (lev) {
|
|
||||||
case Debug:
|
|
||||||
android.util.Log.d(domain, message);
|
|
||||||
break;
|
|
||||||
case Message:
|
|
||||||
android.util.Log.i(domain, message);
|
|
||||||
break;
|
|
||||||
case Warning:
|
|
||||||
android.util.Log.w(domain, message);
|
|
||||||
break;
|
|
||||||
case Error:
|
|
||||||
android.util.Log.e(domain, message);
|
|
||||||
break;
|
|
||||||
case Fatal:
|
|
||||||
default:
|
|
||||||
android.util.Log.wtf(domain, message);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
private CoreListenerStub mListener;
|
|
||||||
private NotificationsManager mNotificationManager;
|
|
||||||
private LinphoneManager mLinphoneManager;
|
|
||||||
private ContactsManager mContactsManager;
|
|
||||||
|
|
||||||
private Class<? extends Activity> mIncomingReceivedActivity = CallIncomingActivity.class;
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
|
@ -111,71 +49,14 @@ public final class LinphoneService extends Service {
|
||||||
|
|
||||||
setupActivityMonitor();
|
setupActivityMonitor();
|
||||||
|
|
||||||
// Needed in order for the two next calls to succeed, libraries must have been loaded first
|
misLinphoneContextOwned = false;
|
||||||
LinphonePreferences.instance().setContext(this);
|
if (!LinphoneContext.isReady()) {
|
||||||
Factory.instance().setLogCollectionPath(getFilesDir().getAbsolutePath());
|
new LinphoneContext(getApplicationContext());
|
||||||
boolean isDebugEnabled = LinphonePreferences.instance().isDebugEnabled();
|
misLinphoneContextOwned = true;
|
||||||
LinphoneUtils.configureLoggingService(isDebugEnabled, getString(R.string.app_name));
|
|
||||||
// LinphoneService isn't ready yet so we have to manually set up the Java logging service
|
|
||||||
if (LinphonePreferences.instance().useJavaLogger()) {
|
|
||||||
Factory.instance().getLoggingService().addListener(mJavaLoggingService);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Dump some debugging information to the logs
|
|
||||||
Log.i(START_LINPHONE_LOGS);
|
|
||||||
dumpDeviceInformation();
|
|
||||||
dumpInstalledLinphoneInformation();
|
|
||||||
|
|
||||||
String incomingReceivedActivityName =
|
|
||||||
LinphonePreferences.instance().getActivityToLaunchOnIncomingReceived();
|
|
||||||
try {
|
|
||||||
mIncomingReceivedActivity =
|
|
||||||
(Class<? extends Activity>) Class.forName(incomingReceivedActivityName);
|
|
||||||
} catch (ClassNotFoundException e) {
|
|
||||||
Log.e(e);
|
|
||||||
}
|
}
|
||||||
|
Log.i("[Service] Created");
|
||||||
|
|
||||||
mWindowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
|
mWindowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
|
||||||
|
|
||||||
mListener =
|
|
||||||
new CoreListenerStub() {
|
|
||||||
@Override
|
|
||||||
public void onCallStateChanged(
|
|
||||||
Core core, Call call, Call.State state, String message) {
|
|
||||||
if (sInstance == null) {
|
|
||||||
Log.i(
|
|
||||||
"[Service] Service not ready, discarding call state change to ",
|
|
||||||
state.toString());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getResources().getBoolean(R.bool.enable_call_notification)) {
|
|
||||||
mNotificationManager.displayCallNotification(call);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (state == Call.State.IncomingReceived
|
|
||||||
|| state == State.IncomingEarlyMedia) {
|
|
||||||
// Starting SDK 24 (Android 7.0) we rely on the fullscreen intent of the
|
|
||||||
// call incoming notification
|
|
||||||
if (Version.sdkStrictlyBelow(Version.API24_NOUGAT_70)) {
|
|
||||||
if (!mLinphoneManager.getCallGsmON()) onIncomingReceived();
|
|
||||||
}
|
|
||||||
} else if (state == State.OutgoingInit) {
|
|
||||||
onOutgoingStarted();
|
|
||||||
} else if (state == State.Connected) {
|
|
||||||
onCallStarted();
|
|
||||||
} else if (state == State.End
|
|
||||||
|| state == State.Released
|
|
||||||
|| state == State.Error) {
|
|
||||||
destroyOverlay();
|
|
||||||
|
|
||||||
if (state == State.Released
|
|
||||||
&& call.getCallLog().getStatus() == Call.Status.Missed) {
|
|
||||||
mNotificationManager.displayMissedCallNotification(call);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -192,34 +73,26 @@ public final class LinphoneService extends Service {
|
||||||
Log.w("[Service] Attempt to start the LinphoneService but it is already running !");
|
Log.w("[Service] Attempt to start the LinphoneService but it is already running !");
|
||||||
return START_STICKY;
|
return START_STICKY;
|
||||||
}
|
}
|
||||||
|
sInstance = this;
|
||||||
|
|
||||||
mLinphoneManager = new LinphoneManager(getApplicationContext());
|
if (LinphonePreferences.instance().getServiceNotificationVisibility()) {
|
||||||
sInstance = this; // sInstance is ready once linphone manager has been created
|
Log.i("[Service] Background service mode enabled, displaying notification");
|
||||||
|
LinphoneContext.instance().getNotificationManager().startForeground();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (misLinphoneContextOwned) {
|
||||||
|
LinphoneContext.instance().start(isPush);
|
||||||
|
} else {
|
||||||
|
LinphoneContext.instance().updateContext(this);
|
||||||
|
}
|
||||||
|
|
||||||
mNotificationManager = new NotificationsManager(this);
|
|
||||||
if (Version.sdkAboveOrEqual(Version.API26_O_80)
|
if (Version.sdkAboveOrEqual(Version.API26_O_80)
|
||||||
&& intent != null
|
&& intent != null
|
||||||
&& intent.getBooleanExtra("ForceStartForeground", false)) {
|
&& intent.getBooleanExtra("ForceStartForeground", false)) {
|
||||||
// We need to call this asap after the Service can be accessed through it's singleton
|
// We need to call this asap after the Service can be accessed through it's singleton
|
||||||
mNotificationManager.startForeground();
|
LinphoneContext.instance().getNotificationManager().startForeground();
|
||||||
}
|
}
|
||||||
|
Log.i("[Service] Started");
|
||||||
mLinphoneManager.startLibLinphone(isPush);
|
|
||||||
LinphoneManager.getCore().addListener(mListener);
|
|
||||||
|
|
||||||
mNotificationManager.onCoreReady();
|
|
||||||
|
|
||||||
mContactsManager = new ContactsManager(this, handler);
|
|
||||||
if (!Version.sdkAboveOrEqual(Version.API26_O_80)
|
|
||||||
|| (mContactsManager.hasReadContactsAccess())) {
|
|
||||||
getContentResolver()
|
|
||||||
.registerContentObserver(
|
|
||||||
ContactsContract.Contacts.CONTENT_URI, true, mContactsManager);
|
|
||||||
}
|
|
||||||
if (mContactsManager.hasReadContactsAccess()) {
|
|
||||||
mContactsManager.enableContactsAccess();
|
|
||||||
}
|
|
||||||
mContactsManager.initializeContactManager();
|
|
||||||
|
|
||||||
return START_STICKY;
|
return START_STICKY;
|
||||||
}
|
}
|
||||||
|
@ -248,35 +121,17 @@ public final class LinphoneService extends Service {
|
||||||
@SuppressWarnings("UnusedAssignment")
|
@SuppressWarnings("UnusedAssignment")
|
||||||
@Override
|
@Override
|
||||||
public synchronized void onDestroy() {
|
public synchronized void onDestroy() {
|
||||||
|
Log.i("[Service] Destroying");
|
||||||
|
|
||||||
if (mActivityCallbacks != null) {
|
if (mActivityCallbacks != null) {
|
||||||
getApplication().unregisterActivityLifecycleCallbacks(mActivityCallbacks);
|
getApplication().unregisterActivityLifecycleCallbacks(mActivityCallbacks);
|
||||||
mActivityCallbacks = null;
|
mActivityCallbacks = null;
|
||||||
}
|
}
|
||||||
destroyOverlay();
|
destroyOverlay();
|
||||||
|
|
||||||
Core core = LinphoneManager.getCore();
|
LinphoneContext.instance().destroy();
|
||||||
if (core != null) {
|
|
||||||
core.removeListener(mListener);
|
|
||||||
core = null; // To allow the gc calls below to free the Core
|
|
||||||
}
|
|
||||||
|
|
||||||
// Make sure our notification is gone.
|
|
||||||
if (mNotificationManager != null) {
|
|
||||||
mNotificationManager.destroy();
|
|
||||||
}
|
|
||||||
mContactsManager.destroy();
|
|
||||||
|
|
||||||
// Destroy the LinphoneManager second to last to ensure any getCore() call will work
|
|
||||||
mLinphoneManager.destroy();
|
|
||||||
|
|
||||||
// Wait for every other object to be destroyed to make LinphoneService.instance() invalid
|
|
||||||
sInstance = null;
|
sInstance = null;
|
||||||
|
|
||||||
if (LinphonePreferences.instance().useJavaLogger()) {
|
|
||||||
Factory.instance().getLoggingService().removeListener(mJavaLoggingService);
|
|
||||||
}
|
|
||||||
LinphonePreferences.instance().destroy();
|
|
||||||
|
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -297,23 +152,8 @@ public final class LinphoneService extends Service {
|
||||||
|
|
||||||
/* Managers accessors */
|
/* Managers accessors */
|
||||||
|
|
||||||
public LoggingServiceListener getJavaLoggingService() {
|
|
||||||
return mJavaLoggingService;
|
|
||||||
}
|
|
||||||
|
|
||||||
public NotificationsManager getNotificationManager() {
|
|
||||||
return mNotificationManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
public LinphoneManager getLinphoneManager() {
|
|
||||||
return mLinphoneManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ContactsManager getContactsManager() {
|
|
||||||
return mContactsManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void createOverlay() {
|
public void createOverlay() {
|
||||||
|
Log.i("[Service] Creating video overlay");
|
||||||
if (mOverlay != null) destroyOverlay();
|
if (mOverlay != null) destroyOverlay();
|
||||||
|
|
||||||
Core core = LinphoneManager.getCore();
|
Core core = LinphoneManager.getCore();
|
||||||
|
@ -332,6 +172,7 @@ public final class LinphoneService extends Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void destroyOverlay() {
|
public void destroyOverlay() {
|
||||||
|
Log.i("[Service] Destroying video overlay");
|
||||||
if (mOverlay != null) {
|
if (mOverlay != null) {
|
||||||
mOverlay.removeFromWindowManager(mWindowManager);
|
mOverlay.removeFromWindowManager(mWindowManager);
|
||||||
mOverlay.destroy();
|
mOverlay.destroy();
|
||||||
|
@ -344,56 +185,4 @@ public final class LinphoneService extends Service {
|
||||||
getApplication()
|
getApplication()
|
||||||
.registerActivityLifecycleCallbacks(mActivityCallbacks = new ActivityMonitor());
|
.registerActivityLifecycleCallbacks(mActivityCallbacks = new ActivityMonitor());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void dumpDeviceInformation() {
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
sb.append("DEVICE=").append(Build.DEVICE).append("\n");
|
|
||||||
sb.append("MODEL=").append(Build.MODEL).append("\n");
|
|
||||||
sb.append("MANUFACTURER=").append(Build.MANUFACTURER).append("\n");
|
|
||||||
sb.append("SDK=").append(Build.VERSION.SDK_INT).append("\n");
|
|
||||||
sb.append("Supported ABIs=");
|
|
||||||
for (String abi : Version.getCpuAbis()) {
|
|
||||||
sb.append(abi).append(", ");
|
|
||||||
}
|
|
||||||
sb.append("\n");
|
|
||||||
Log.i(sb.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void dumpInstalledLinphoneInformation() {
|
|
||||||
PackageInfo info = null;
|
|
||||||
try {
|
|
||||||
info = getPackageManager().getPackageInfo(getPackageName(), 0);
|
|
||||||
} catch (NameNotFoundException nnfe) {
|
|
||||||
Log.e(nnfe);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (info != null) {
|
|
||||||
Log.i(
|
|
||||||
"[Service] Linphone version is ",
|
|
||||||
info.versionName + " (" + info.versionCode + ")");
|
|
||||||
} else {
|
|
||||||
Log.i("[Service] Linphone version is unknown");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void onIncomingReceived() {
|
|
||||||
Intent intent = new Intent().setClass(this, mIncomingReceivedActivity);
|
|
||||||
// This flag is required to start an Activity from a Service context
|
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
||||||
startActivity(intent);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void onOutgoingStarted() {
|
|
||||||
Intent intent = new Intent(LinphoneService.this, CallOutgoingActivity.class);
|
|
||||||
// This flag is required to start an Activity from a Service context
|
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
||||||
startActivity(intent);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void onCallStarted() {
|
|
||||||
Intent intent = new Intent(LinphoneService.this, CallActivity.class);
|
|
||||||
// This flag is required to start an Activity from a Service context
|
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
||||||
startActivity(intent);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,9 +48,6 @@ public class AboutActivity extends MainActivity {
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
if (mAbortCreation) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
mOnBackPressGoHome = false;
|
mOnBackPressGoHome = false;
|
||||||
mAlwaysHideTabBar = true;
|
mAlwaysHideTabBar = true;
|
||||||
|
|
|
@ -64,9 +64,6 @@ public class DialerActivity extends MainActivity implements AddressText.AddressC
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
if (mAbortCreation) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
mInterfaceLoaded = false;
|
mInterfaceLoaded = false;
|
||||||
// Uses the fragment container layout to inflate the dialer view instead of using a fragment
|
// Uses the fragment container layout to inflate the dialer view instead of using a fragment
|
||||||
|
|
|
@ -19,34 +19,30 @@ along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.Surface;
|
import android.view.Surface;
|
||||||
|
import org.linphone.LinphoneContext;
|
||||||
import org.linphone.LinphoneManager;
|
import org.linphone.LinphoneManager;
|
||||||
import org.linphone.LinphoneService;
|
import org.linphone.LinphoneService;
|
||||||
import org.linphone.core.Core;
|
import org.linphone.core.Core;
|
||||||
import org.linphone.core.tools.Log;
|
import org.linphone.core.tools.Log;
|
||||||
|
|
||||||
public abstract class LinphoneGenericActivity extends ThemeableActivity {
|
public abstract class LinphoneGenericActivity extends ThemeableActivity {
|
||||||
protected boolean mAbortCreation;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
mAbortCreation = false;
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
// After a crash, Android restart the last Activity so we need to check
|
|
||||||
// if all dependencies are loaded
|
ensureServiceIsRunning();
|
||||||
if (!LinphoneService.isReady()) {
|
|
||||||
startActivity(getIntent().setClass(this, LinphoneLauncherActivity.class));
|
|
||||||
mAbortCreation = true;
|
|
||||||
finish();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
if (LinphoneService.isReady()) {
|
ensureServiceIsRunning();
|
||||||
|
|
||||||
|
if (LinphoneContext.isReady()) {
|
||||||
int degrees = 270;
|
int degrees = 270;
|
||||||
int orientation = getWindowManager().getDefaultDisplay().getRotation();
|
int orientation = getWindowManager().getDefaultDisplay().getRotation();
|
||||||
switch (orientation) {
|
switch (orientation) {
|
||||||
|
@ -78,4 +74,14 @@ public abstract class LinphoneGenericActivity extends ThemeableActivity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ensureServiceIsRunning() {
|
||||||
|
if (!LinphoneService.isReady()) {
|
||||||
|
if (!LinphoneContext.isReady()) {
|
||||||
|
new LinphoneContext(getApplicationContext());
|
||||||
|
LinphoneContext.instance().start(false);
|
||||||
|
}
|
||||||
|
startService(new Intent().setClass(this, LinphoneService.class));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,10 +31,11 @@ import org.linphone.chat.ChatActivity;
|
||||||
import org.linphone.contacts.ContactsActivity;
|
import org.linphone.contacts.ContactsActivity;
|
||||||
import org.linphone.history.HistoryActivity;
|
import org.linphone.history.HistoryActivity;
|
||||||
import org.linphone.settings.LinphonePreferences;
|
import org.linphone.settings.LinphonePreferences;
|
||||||
import org.linphone.utils.LinphoneUtils;
|
import org.linphone.utils.ServiceWaitThread;
|
||||||
|
import org.linphone.utils.ServiceWaitThreadListener;
|
||||||
|
|
||||||
/** Creates LinphoneService and wait until Core is ready to start main Activity */
|
/** Creates LinphoneService and wait until Core is ready to start main Activity */
|
||||||
public class LinphoneLauncherActivity extends Activity {
|
public class LinphoneLauncherActivity extends Activity implements ServiceWaitThreadListener {
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
@ -57,11 +58,12 @@ public class LinphoneLauncherActivity extends Activity {
|
||||||
} else {
|
} else {
|
||||||
startService(
|
startService(
|
||||||
new Intent().setClass(LinphoneLauncherActivity.this, LinphoneService.class));
|
new Intent().setClass(LinphoneLauncherActivity.this, LinphoneService.class));
|
||||||
new ServiceWaitThread().start();
|
new ServiceWaitThread(this).start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onServiceReady() {
|
@Override
|
||||||
|
public void onServiceReady() {
|
||||||
final Class<? extends Activity> classToStart;
|
final Class<? extends Activity> classToStart;
|
||||||
|
|
||||||
boolean useFirstLoginActivity =
|
boolean useFirstLoginActivity =
|
||||||
|
@ -89,10 +91,6 @@ public class LinphoneLauncherActivity extends Activity {
|
||||||
LinphoneManager.getInstance().checkForUpdate();
|
LinphoneManager.getInstance().checkForUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
LinphoneUtils.dispatchOnUIThreadAfter(
|
|
||||||
new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
intent.setClass(LinphoneLauncherActivity.this, classToStart);
|
intent.setClass(LinphoneLauncherActivity.this, classToStart);
|
||||||
if (getIntent() != null && getIntent().getExtras() != null) {
|
if (getIntent() != null && getIntent().getExtras() != null) {
|
||||||
|
@ -102,29 +100,7 @@ public class LinphoneLauncherActivity extends Activity {
|
||||||
intent.setType(getIntent().getType());
|
intent.setType(getIntent().getType());
|
||||||
intent.setData(getIntent().getData());
|
intent.setData(getIntent().getData());
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
|
||||||
},
|
|
||||||
100);
|
|
||||||
|
|
||||||
LinphoneManager.getInstance().changeStatusToOnline();
|
LinphoneManager.getInstance().changeStatusToOnline();
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ServiceWaitThread extends Thread {
|
|
||||||
public void run() {
|
|
||||||
while (!LinphoneService.isReady()) {
|
|
||||||
try {
|
|
||||||
sleep(30);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
throw new RuntimeException("waiting thread sleep() has been interrupted");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
LinphoneUtils.dispatchOnUIThread(
|
|
||||||
new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
onServiceReady();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,6 +44,7 @@ import android.widget.Toast;
|
||||||
import androidx.core.app.ActivityCompat;
|
import androidx.core.app.ActivityCompat;
|
||||||
import androidx.drawerlayout.widget.DrawerLayout;
|
import androidx.drawerlayout.widget.DrawerLayout;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import org.linphone.LinphoneContext;
|
||||||
import org.linphone.LinphoneManager;
|
import org.linphone.LinphoneManager;
|
||||||
import org.linphone.LinphoneService;
|
import org.linphone.LinphoneService;
|
||||||
import org.linphone.R;
|
import org.linphone.R;
|
||||||
|
@ -102,13 +103,6 @@ public abstract class MainActivity extends LinphoneGenericActivity
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
if (mAbortCreation) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!LinphoneService.isReady()) {
|
|
||||||
finish();
|
|
||||||
}
|
|
||||||
|
|
||||||
setContentView(R.layout.main);
|
setContentView(R.layout.main);
|
||||||
|
|
||||||
|
@ -304,7 +298,7 @@ public abstract class MainActivity extends LinphoneGenericActivity
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
LinphoneService.instance()
|
LinphoneContext.instance()
|
||||||
.getNotificationManager()
|
.getNotificationManager()
|
||||||
.removeForegroundServiceNotificationIfPossible();
|
.removeForegroundServiceNotificationIfPossible();
|
||||||
|
|
||||||
|
|
|
@ -48,9 +48,6 @@ public class AccountConnectionAssistantActivity extends AssistantActivity {
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
if (mAbortCreation) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
setContentView(R.layout.assistant_account_connection);
|
setContentView(R.layout.assistant_account_connection);
|
||||||
|
|
||||||
|
|
|
@ -27,8 +27,8 @@ import android.view.View;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
import org.linphone.LinphoneContext;
|
||||||
import org.linphone.LinphoneManager;
|
import org.linphone.LinphoneManager;
|
||||||
import org.linphone.LinphoneService;
|
|
||||||
import org.linphone.R;
|
import org.linphone.R;
|
||||||
import org.linphone.activities.DialerActivity;
|
import org.linphone.activities.DialerActivity;
|
||||||
import org.linphone.activities.LinphoneGenericActivity;
|
import org.linphone.activities.LinphoneGenericActivity;
|
||||||
|
@ -52,9 +52,6 @@ public abstract class AssistantActivity extends LinphoneGenericActivity
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
if (mAbortCreation) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mAccountCreator == null) {
|
if (mAccountCreator == null) {
|
||||||
String url = LinphonePreferences.instance().getXmlrpcUrl();
|
String url = LinphonePreferences.instance().getXmlrpcUrl();
|
||||||
|
@ -124,7 +121,7 @@ public abstract class AssistantActivity extends LinphoneGenericActivity
|
||||||
// If this isn't a sip.linphone.org account, disable push notifications and enable
|
// If this isn't a sip.linphone.org account, disable push notifications and enable
|
||||||
// service notification, otherwise incoming calls won't work (most probably)
|
// service notification, otherwise incoming calls won't work (most probably)
|
||||||
LinphonePreferences.instance().setServiceNotificationVisibility(true);
|
LinphonePreferences.instance().setServiceNotificationVisibility(true);
|
||||||
LinphoneService.instance().getNotificationManager().startForeground();
|
LinphoneContext.instance().getNotificationManager().startForeground();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (proxyConfig == null) {
|
if (proxyConfig == null) {
|
||||||
|
|
|
@ -44,9 +44,6 @@ public class EmailAccountCreationAssistantActivity extends AssistantActivity {
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
if (mAbortCreation) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
setContentView(R.layout.assistant_email_account_creation);
|
setContentView(R.layout.assistant_email_account_creation);
|
||||||
|
|
||||||
|
|
|
@ -37,9 +37,6 @@ public class EmailAccountValidationAssistantActivity extends AssistantActivity {
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
if (mAbortCreation) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
setContentView(R.layout.assistant_email_account_validation);
|
setContentView(R.layout.assistant_email_account_validation);
|
||||||
|
|
||||||
|
|
|
@ -38,9 +38,6 @@ public class GenericConnectionAssistantActivity extends AssistantActivity implem
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
if (mAbortCreation) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
setContentView(R.layout.assistant_generic_connection);
|
setContentView(R.layout.assistant_generic_connection);
|
||||||
|
|
||||||
|
|
|
@ -33,9 +33,6 @@ public class MenuAssistantActivity extends AssistantActivity {
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
if (mAbortCreation) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
setContentView(R.layout.assistant_menu);
|
setContentView(R.layout.assistant_menu);
|
||||||
|
|
||||||
|
|
|
@ -44,9 +44,6 @@ public class OpenH264DownloadAssistantActivity extends AssistantActivity {
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
if (mAbortCreation) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
setContentView(R.layout.assistant_openh264_codec_download);
|
setContentView(R.layout.assistant_openh264_codec_download);
|
||||||
mHelper = Factory.instance().createOpenH264DownloadHelper(this);
|
mHelper = Factory.instance().createOpenH264DownloadHelper(this);
|
||||||
|
|
|
@ -46,9 +46,6 @@ public class PhoneAccountCreationAssistantActivity extends AssistantActivity {
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
if (mAbortCreation) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
setContentView(R.layout.assistant_phone_account_creation);
|
setContentView(R.layout.assistant_phone_account_creation);
|
||||||
|
|
||||||
|
|
|
@ -49,9 +49,6 @@ public class PhoneAccountLinkingAssistantActivity extends AssistantActivity {
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
if (mAbortCreation) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
setContentView(R.layout.assistant_phone_account_linking);
|
setContentView(R.layout.assistant_phone_account_linking);
|
||||||
|
|
||||||
|
|
|
@ -46,9 +46,6 @@ public class PhoneAccountValidationAssistantActivity extends AssistantActivity {
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
if (mAbortCreation) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
setContentView(R.layout.assistant_phone_account_validation);
|
setContentView(R.layout.assistant_phone_account_validation);
|
||||||
|
|
||||||
|
|
|
@ -40,9 +40,6 @@ public class QrCodeConfigurationAssistantActivity extends AssistantActivity {
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
if (mAbortCreation) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
setContentView(R.layout.assistant_qr_code_remote_configuration);
|
setContentView(R.layout.assistant_qr_code_remote_configuration);
|
||||||
|
|
||||||
|
|
|
@ -56,9 +56,6 @@ public class RemoteConfigurationAssistantActivity extends AssistantActivity {
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
if (mAbortCreation) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
setContentView(R.layout.assistant_remote_configuration);
|
setContentView(R.layout.assistant_remote_configuration);
|
||||||
|
|
||||||
|
|
|
@ -131,9 +131,6 @@ public class CallActivity extends LinphoneGenericActivity
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
if (mAbortCreation) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||||
Compatibility.setShowWhenLocked(this, true);
|
Compatibility.setShowWhenLocked(this, true);
|
||||||
|
|
|
@ -32,8 +32,8 @@ import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
import androidx.core.app.ActivityCompat;
|
import androidx.core.app.ActivityCompat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import org.linphone.LinphoneContext;
|
||||||
import org.linphone.LinphoneManager;
|
import org.linphone.LinphoneManager;
|
||||||
import org.linphone.LinphoneService;
|
|
||||||
import org.linphone.R;
|
import org.linphone.R;
|
||||||
import org.linphone.activities.LinphoneGenericActivity;
|
import org.linphone.activities.LinphoneGenericActivity;
|
||||||
import org.linphone.compatibility.Compatibility;
|
import org.linphone.compatibility.Compatibility;
|
||||||
|
@ -62,9 +62,6 @@ public class CallIncomingActivity extends LinphoneGenericActivity {
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
if (mAbortCreation) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Compatibility.setShowWhenLocked(this, true);
|
Compatibility.setShowWhenLocked(this, true);
|
||||||
Compatibility.setTurnScreenOn(this, true);
|
Compatibility.setTurnScreenOn(this, true);
|
||||||
|
@ -206,7 +203,7 @@ public class CallIncomingActivity extends LinphoneGenericActivity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||||
if (LinphoneService.isReady()
|
if (LinphoneContext.isReady()
|
||||||
&& (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_HOME)) {
|
&& (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_HOME)) {
|
||||||
mCall.terminate();
|
mCall.terminate();
|
||||||
finish();
|
finish();
|
||||||
|
|
|
@ -23,8 +23,8 @@ import android.content.ContentResolver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
import org.linphone.LinphoneContext;
|
||||||
import org.linphone.LinphoneManager;
|
import org.linphone.LinphoneManager;
|
||||||
import org.linphone.LinphoneService;
|
|
||||||
import org.linphone.R;
|
import org.linphone.R;
|
||||||
import org.linphone.contacts.ContactsManager;
|
import org.linphone.contacts.ContactsManager;
|
||||||
import org.linphone.contacts.LinphoneContact;
|
import org.linphone.contacts.LinphoneContact;
|
||||||
|
@ -122,7 +122,8 @@ public class CallManager {
|
||||||
CallParams params = core.createCallParams(call);
|
CallParams params = core.createCallParams(call);
|
||||||
|
|
||||||
boolean isLowBandwidthConnection =
|
boolean isLowBandwidthConnection =
|
||||||
!LinphoneUtils.isHighBandwidthConnection(LinphoneService.instance());
|
!LinphoneUtils.isHighBandwidthConnection(
|
||||||
|
LinphoneContext.instance().getApplicationContext());
|
||||||
|
|
||||||
if (params != null) {
|
if (params != null) {
|
||||||
params.enableLowBandwidth(isLowBandwidthConnection);
|
params.enableLowBandwidth(isLowBandwidthConnection);
|
||||||
|
@ -156,7 +157,8 @@ public class CallManager {
|
||||||
|
|
||||||
public void inviteAddress(Address address, boolean forceZRTP) {
|
public void inviteAddress(Address address, boolean forceZRTP) {
|
||||||
boolean isLowBandwidthConnection =
|
boolean isLowBandwidthConnection =
|
||||||
!LinphoneUtils.isHighBandwidthConnection(LinphoneService.instance());
|
!LinphoneUtils.isHighBandwidthConnection(
|
||||||
|
LinphoneContext.instance().getApplicationContext());
|
||||||
|
|
||||||
inviteAddress(address, false, isLowBandwidthConnection, forceZRTP);
|
inviteAddress(address, false, isLowBandwidthConnection, forceZRTP);
|
||||||
}
|
}
|
||||||
|
@ -202,7 +204,8 @@ public class CallManager {
|
||||||
address.setDisplayName(displayName);
|
address.setDisplayName(displayName);
|
||||||
|
|
||||||
boolean isLowBandwidthConnection =
|
boolean isLowBandwidthConnection =
|
||||||
!LinphoneUtils.isHighBandwidthConnection(LinphoneService.instance());
|
!LinphoneUtils.isHighBandwidthConnection(
|
||||||
|
LinphoneContext.instance().getApplicationContext());
|
||||||
|
|
||||||
if (core.isNetworkReachable()) {
|
if (core.isNetworkReachable()) {
|
||||||
if (Version.isVideoCapable()) {
|
if (Version.isVideoCapable()) {
|
||||||
|
@ -324,7 +327,9 @@ public class CallManager {
|
||||||
params.setMediaEncryption(MediaEncryption.ZRTP);
|
params.setMediaEncryption(MediaEncryption.ZRTP);
|
||||||
}
|
}
|
||||||
|
|
||||||
String recordFile = FileUtils.getCallRecordingFilename(LinphoneService.instance(), address);
|
String recordFile =
|
||||||
|
FileUtils.getCallRecordingFilename(
|
||||||
|
LinphoneContext.instance().getApplicationContext(), address);
|
||||||
params.setRecordFile(recordFile);
|
params.setRecordFile(recordFile);
|
||||||
|
|
||||||
core.inviteAddressWithParams(address, params);
|
core.inviteAddressWithParams(address, params);
|
||||||
|
@ -362,7 +367,7 @@ public class CallManager {
|
||||||
if (call != null) {
|
if (call != null) {
|
||||||
call.enableCamera(enable);
|
call.enableCamera(enable);
|
||||||
if (mContext.getResources().getBoolean(R.bool.enable_call_notification))
|
if (mContext.getResources().getBoolean(R.bool.enable_call_notification))
|
||||||
LinphoneService.instance()
|
LinphoneContext.instance()
|
||||||
.getNotificationManager()
|
.getNotificationManager()
|
||||||
.displayCallNotification(LinphoneManager.getCore().getCurrentCall());
|
.displayCallNotification(LinphoneManager.getCore().getCurrentCall());
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,8 +31,8 @@ import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
import androidx.core.app.ActivityCompat;
|
import androidx.core.app.ActivityCompat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import org.linphone.LinphoneContext;
|
||||||
import org.linphone.LinphoneManager;
|
import org.linphone.LinphoneManager;
|
||||||
import org.linphone.LinphoneService;
|
|
||||||
import org.linphone.R;
|
import org.linphone.R;
|
||||||
import org.linphone.activities.LinphoneGenericActivity;
|
import org.linphone.activities.LinphoneGenericActivity;
|
||||||
import org.linphone.contacts.ContactsManager;
|
import org.linphone.contacts.ContactsManager;
|
||||||
|
@ -59,9 +59,6 @@ public class CallOutgoingActivity extends LinphoneGenericActivity implements OnC
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
if (mAbortCreation) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||||
setContentView(R.layout.call_outgoing);
|
setContentView(R.layout.call_outgoing);
|
||||||
|
@ -234,7 +231,7 @@ public class CallOutgoingActivity extends LinphoneGenericActivity implements OnC
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||||
if (LinphoneService.isReady()
|
if (LinphoneContext.isReady()
|
||||||
&& (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_HOME)) {
|
&& (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_HOME)) {
|
||||||
mCall.terminate();
|
mCall.terminate();
|
||||||
finish();
|
finish();
|
||||||
|
|
|
@ -59,8 +59,8 @@ import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import org.linphone.LinphoneContext;
|
||||||
import org.linphone.LinphoneManager;
|
import org.linphone.LinphoneManager;
|
||||||
import org.linphone.LinphoneService;
|
|
||||||
import org.linphone.R;
|
import org.linphone.R;
|
||||||
import org.linphone.activities.MainActivity;
|
import org.linphone.activities.MainActivity;
|
||||||
import org.linphone.contacts.ContactAddress;
|
import org.linphone.contacts.ContactAddress;
|
||||||
|
@ -386,7 +386,7 @@ public class ChatMessagesFragment extends Fragment
|
||||||
displayChatRoomHeader();
|
displayChatRoomHeader();
|
||||||
displayChatRoomHistory();
|
displayChatRoomHistory();
|
||||||
|
|
||||||
LinphoneService.instance()
|
LinphoneContext.instance()
|
||||||
.getNotificationManager()
|
.getNotificationManager()
|
||||||
.setCurrentlyDisplayedChatRoom(
|
.setCurrentlyDisplayedChatRoom(
|
||||||
mRemoteSipAddress != null ? mRemoteSipAddress.asStringUriOnly() : null);
|
mRemoteSipAddress != null ? mRemoteSipAddress.asStringUriOnly() : null);
|
||||||
|
@ -401,7 +401,7 @@ public class ChatMessagesFragment extends Fragment
|
||||||
|
|
||||||
ContactsManager.getInstance().removeContactsListener(this);
|
ContactsManager.getInstance().removeContactsListener(this);
|
||||||
removeVirtualKeyboardVisiblityListener();
|
removeVirtualKeyboardVisiblityListener();
|
||||||
LinphoneService.instance().getNotificationManager().setCurrentlyDisplayedChatRoom(null);
|
LinphoneContext.instance().getNotificationManager().setCurrentlyDisplayedChatRoom(null);
|
||||||
if (mChatRoom != null) mChatRoom.removeListener(this);
|
if (mChatRoom != null) mChatRoom.removeListener(this);
|
||||||
if (mChatEventsList.getAdapter() != null)
|
if (mChatEventsList.getAdapter() != null)
|
||||||
((ChatMessagesGenericAdapter) mChatEventsList.getAdapter()).clear();
|
((ChatMessagesGenericAdapter) mChatEventsList.getAdapter()).clear();
|
||||||
|
|
|
@ -26,7 +26,7 @@ import androidx.annotation.NonNull;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.linphone.LinphoneService;
|
import org.linphone.LinphoneContext;
|
||||||
import org.linphone.R;
|
import org.linphone.R;
|
||||||
import org.linphone.contacts.ContactAddress;
|
import org.linphone.contacts.ContactAddress;
|
||||||
import org.linphone.contacts.LinphoneContact;
|
import org.linphone.contacts.LinphoneContact;
|
||||||
|
@ -73,7 +73,10 @@ class GroupInfoAdapter extends RecyclerView.Adapter<GroupInfoViewHolder> {
|
||||||
|
|
||||||
holder.sipUri.setText(ca.getAddressAsDisplayableString());
|
holder.sipUri.setText(ca.getAddressAsDisplayableString());
|
||||||
|
|
||||||
if (!LinphoneService.instance().getResources().getBoolean(R.bool.show_sip_uri_in_chat)) {
|
if (!LinphoneContext.instance()
|
||||||
|
.getApplicationContext()
|
||||||
|
.getResources()
|
||||||
|
.getBoolean(R.bool.show_sip_uri_in_chat)) {
|
||||||
holder.sipUri.setVisibility(View.GONE);
|
holder.sipUri.setVisibility(View.GONE);
|
||||||
holder.name.setOnClickListener(
|
holder.name.setOnClickListener(
|
||||||
new View.OnClickListener() {
|
new View.OnClickListener() {
|
||||||
|
|
|
@ -32,7 +32,7 @@ import android.provider.ContactsContract.Data;
|
||||||
import android.provider.ContactsContract.RawContacts;
|
import android.provider.ContactsContract.RawContacts;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import org.linphone.LinphoneService;
|
import org.linphone.LinphoneContext;
|
||||||
import org.linphone.R;
|
import org.linphone.R;
|
||||||
import org.linphone.core.tools.Log;
|
import org.linphone.core.tools.Log;
|
||||||
|
|
||||||
|
@ -67,7 +67,8 @@ class AndroidContact implements Serializable {
|
||||||
void saveChangesCommited() {
|
void saveChangesCommited() {
|
||||||
if (ContactsManager.getInstance().hasReadContactsAccess() && mChangesToCommit.size() > 0) {
|
if (ContactsManager.getInstance().hasReadContactsAccess() && mChangesToCommit.size() > 0) {
|
||||||
try {
|
try {
|
||||||
ContentResolver contentResolver = LinphoneService.instance().getContentResolver();
|
ContentResolver contentResolver =
|
||||||
|
LinphoneContext.instance().getApplicationContext().getContentResolver();
|
||||||
ContentProviderResult[] results =
|
ContentProviderResult[] results =
|
||||||
contentResolver.applyBatch(ContactsContract.AUTHORITY, mChangesToCommit);
|
contentResolver.applyBatch(ContactsContract.AUTHORITY, mChangesToCommit);
|
||||||
if (results != null
|
if (results != null
|
||||||
|
@ -110,7 +111,10 @@ class AndroidContact implements Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
void createAndroidContact() {
|
void createAndroidContact() {
|
||||||
if (LinphoneService.instance().getResources().getBoolean(R.bool.use_linphone_tag)) {
|
if (LinphoneContext.instance()
|
||||||
|
.getApplicationContext()
|
||||||
|
.getResources()
|
||||||
|
.getBoolean(R.bool.use_linphone_tag)) {
|
||||||
Log.i("[Contact] Creating contact using linphone account type");
|
Log.i("[Contact] Creating contact using linphone account type");
|
||||||
addChangesToCommit(
|
addChangesToCommit(
|
||||||
ContentProviderOperation.newInsert(RawContacts.CONTENT_URI)
|
ContentProviderOperation.newInsert(RawContacts.CONTENT_URI)
|
||||||
|
@ -229,7 +233,8 @@ class AndroidContact implements Serializable {
|
||||||
boolean isLinphoneAddressMimeEntryAlreadyExisting(String value) {
|
boolean isLinphoneAddressMimeEntryAlreadyExisting(String value) {
|
||||||
boolean result = false;
|
boolean result = false;
|
||||||
|
|
||||||
ContentResolver resolver = LinphoneService.instance().getContentResolver();
|
ContentResolver resolver =
|
||||||
|
LinphoneContext.instance().getApplicationContext().getContentResolver();
|
||||||
String[] projection = {"data1", "data3"};
|
String[] projection = {"data1", "data3"};
|
||||||
String selection =
|
String selection =
|
||||||
ContactsContract.Data.RAW_CONTACT_ID
|
ContactsContract.Data.RAW_CONTACT_ID
|
||||||
|
@ -576,7 +581,8 @@ class AndroidContact implements Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
private String findRawContactID() {
|
private String findRawContactID() {
|
||||||
ContentResolver resolver = LinphoneService.instance().getContentResolver();
|
ContentResolver resolver =
|
||||||
|
LinphoneContext.instance().getApplicationContext().getContentResolver();
|
||||||
String result = null;
|
String result = null;
|
||||||
String[] projection = {ContactsContract.RawContacts._ID};
|
String[] projection = {ContactsContract.RawContacts._ID};
|
||||||
|
|
||||||
|
@ -598,7 +604,10 @@ class AndroidContact implements Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
void createRawLinphoneContactFromExistingAndroidContactIfNeeded() {
|
void createRawLinphoneContactFromExistingAndroidContactIfNeeded() {
|
||||||
if (LinphoneService.instance().getResources().getBoolean(R.bool.use_linphone_tag)) {
|
if (LinphoneContext.instance()
|
||||||
|
.getApplicationContext()
|
||||||
|
.getResources()
|
||||||
|
.getBoolean(R.bool.use_linphone_tag)) {
|
||||||
if (mAndroidId != null && (mAndroidRawId == null || !isAndroidRawIdLinphone)) {
|
if (mAndroidId != null && (mAndroidRawId == null || !isAndroidRawIdLinphone)) {
|
||||||
if (mAndroidRawId == null) {
|
if (mAndroidRawId == null) {
|
||||||
Log.d("[Contact] RAW ID not found for contact " + mAndroidId);
|
Log.d("[Contact] RAW ID not found for contact " + mAndroidId);
|
||||||
|
@ -659,7 +668,8 @@ class AndroidContact implements Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
private String findLinphoneRawContactId() {
|
private String findLinphoneRawContactId() {
|
||||||
ContentResolver resolver = LinphoneService.instance().getContentResolver();
|
ContentResolver resolver =
|
||||||
|
LinphoneContext.instance().getApplicationContext().getContentResolver();
|
||||||
String result = null;
|
String result = null;
|
||||||
String[] projection = {ContactsContract.RawContacts._ID};
|
String[] projection = {ContactsContract.RawContacts._ID};
|
||||||
|
|
||||||
|
|
|
@ -40,8 +40,8 @@ import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
import org.linphone.LinphoneContext;
|
||||||
import org.linphone.LinphoneManager;
|
import org.linphone.LinphoneManager;
|
||||||
import org.linphone.LinphoneService;
|
|
||||||
import org.linphone.R;
|
import org.linphone.R;
|
||||||
import org.linphone.compatibility.Compatibility;
|
import org.linphone.compatibility.Compatibility;
|
||||||
import org.linphone.core.Address;
|
import org.linphone.core.Address;
|
||||||
|
@ -64,7 +64,7 @@ public class ContactsManager extends ContentObserver implements FriendListListen
|
||||||
private boolean mInitialized = false;
|
private boolean mInitialized = false;
|
||||||
|
|
||||||
public static ContactsManager getInstance() {
|
public static ContactsManager getInstance() {
|
||||||
return LinphoneService.instance().getContactsManager();
|
return LinphoneContext.instance().getContactsManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ContactsManager(Context context, Handler handler) {
|
public ContactsManager(Context context, Handler handler) {
|
||||||
|
@ -256,7 +256,7 @@ public class ContactsManager extends ContentObserver implements FriendListListen
|
||||||
if (hasReadContactsAccess()
|
if (hasReadContactsAccess()
|
||||||
&& hasWriteContactsAccess()
|
&& hasWriteContactsAccess()
|
||||||
&& hasWriteSyncPermission()) {
|
&& hasWriteSyncPermission()) {
|
||||||
if (LinphoneService.isReady()) {
|
if (LinphoneContext.isReady()) {
|
||||||
initializeSyncAccount();
|
initializeSyncAccount();
|
||||||
mInitialized = true;
|
mInitialized = true;
|
||||||
}
|
}
|
||||||
|
@ -452,7 +452,10 @@ public class ContactsManager extends ContentObserver implements FriendListListen
|
||||||
LinphoneContact contact = (LinphoneContact) lf.getUserData();
|
LinphoneContact contact = (LinphoneContact) lf.getUserData();
|
||||||
|
|
||||||
if (contact != null) {
|
if (contact != null) {
|
||||||
if (LinphoneService.instance().getResources().getBoolean(R.bool.use_linphone_tag)) {
|
if (LinphoneContext.instance()
|
||||||
|
.getApplicationContext()
|
||||||
|
.getResources()
|
||||||
|
.getBoolean(R.bool.use_linphone_tag)) {
|
||||||
// Inserting Linphone information in Android contact if the parameter is enabled
|
// Inserting Linphone information in Android contact if the parameter is enabled
|
||||||
if (LinphonePreferences.instance()
|
if (LinphonePreferences.instance()
|
||||||
.isPresenceStorageInNativeAndroidContactEnabled()) {
|
.isPresenceStorageInNativeAndroidContactEnabled()) {
|
||||||
|
|
|
@ -26,8 +26,8 @@ import android.provider.ContactsContract;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import org.linphone.LinphoneContext;
|
||||||
import org.linphone.LinphoneManager;
|
import org.linphone.LinphoneManager;
|
||||||
import org.linphone.LinphoneService;
|
|
||||||
import org.linphone.R;
|
import org.linphone.R;
|
||||||
import org.linphone.core.Address;
|
import org.linphone.core.Address;
|
||||||
import org.linphone.core.Core;
|
import org.linphone.core.Core;
|
||||||
|
@ -547,7 +547,8 @@ public class LinphoneContact extends AndroidContact
|
||||||
Log.d("[Linphone Contact] Found phone number " + data1 + " (" + data4 + ")");
|
Log.d("[Linphone Contact] Found phone number " + data1 + " (" + data4 + ")");
|
||||||
addNumberOrAddress(new LinphoneNumberOrAddress(data1, data4));
|
addNumberOrAddress(new LinphoneNumberOrAddress(data1, data4));
|
||||||
} else if (ContactsContract.CommonDataKinds.SipAddress.CONTENT_ITEM_TYPE.equals(mime)
|
} else if (ContactsContract.CommonDataKinds.SipAddress.CONTENT_ITEM_TYPE.equals(mime)
|
||||||
|| LinphoneService.instance()
|
|| LinphoneContext.instance()
|
||||||
|
.getApplicationContext()
|
||||||
.getString(R.string.linphone_address_mime_type)
|
.getString(R.string.linphone_address_mime_type)
|
||||||
.equals(mime)) {
|
.equals(mime)) {
|
||||||
Log.d("[Linphone Contact] Found SIP address " + data1);
|
Log.d("[Linphone Contact] Found SIP address " + data1);
|
||||||
|
@ -595,7 +596,7 @@ public class LinphoneContact extends AndroidContact
|
||||||
|
|
||||||
public void save() {
|
public void save() {
|
||||||
saveChangesCommited();
|
saveChangesCommited();
|
||||||
syncValuesFromAndroidContact(LinphoneService.instance());
|
syncValuesFromAndroidContact(LinphoneContext.instance().getApplicationContext());
|
||||||
createOrUpdateFriend();
|
createOrUpdateFriend();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,8 +27,8 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import org.linphone.LinphoneContext;
|
||||||
import org.linphone.LinphoneManager;
|
import org.linphone.LinphoneManager;
|
||||||
import org.linphone.LinphoneService;
|
|
||||||
import org.linphone.R;
|
import org.linphone.R;
|
||||||
import org.linphone.core.Address;
|
import org.linphone.core.Address;
|
||||||
import org.linphone.core.FriendCapability;
|
import org.linphone.core.FriendCapability;
|
||||||
|
@ -243,7 +243,8 @@ public class SearchContactsAdapter extends RecyclerView.Adapter<SearchContactVie
|
||||||
.getContactListFromFilter(search, mOnlySipContact ? domain : "");
|
.getContactListFromFilter(search, mOnlySipContact ? domain : "");
|
||||||
|
|
||||||
for (SearchResult sr : searchResults) {
|
for (SearchResult sr : searchResults) {
|
||||||
if (LinphoneService.instance()
|
if (LinphoneContext.instance()
|
||||||
|
.getApplicationContext()
|
||||||
.getResources()
|
.getResources()
|
||||||
.getBoolean(R.bool.hide_sip_contacts_without_presence)) {
|
.getBoolean(R.bool.hide_sip_contacts_without_presence)) {
|
||||||
if (sr.getFriend() != null) {
|
if (sr.getFriend() != null) {
|
||||||
|
|
|
@ -85,11 +85,9 @@ public class StatusBarFragment extends Fragment {
|
||||||
mStatusLed.setVisibility(View.VISIBLE);
|
mStatusLed.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (core.getDefaultProxyConfig() != null
|
if ((core.getDefaultProxyConfig() != null
|
||||||
&& core.getDefaultProxyConfig().equals(proxy)) {
|
&& core.getDefaultProxyConfig().equals(proxy))
|
||||||
mStatusLed.setImageResource(getStatusIconResource(state));
|
|| core.getDefaultProxyConfig() == null) {
|
||||||
mStatusText.setText(getStatusIconText(state));
|
|
||||||
} else if (core.getDefaultProxyConfig() == null) {
|
|
||||||
mStatusLed.setImageResource(getStatusIconResource(state));
|
mStatusLed.setImageResource(getStatusIconResource(state));
|
||||||
mStatusText.setText(getStatusIconText(state));
|
mStatusText.setText(getStatusIconText(state));
|
||||||
}
|
}
|
||||||
|
@ -188,12 +186,7 @@ public class StatusBarFragment extends Fragment {
|
||||||
|
|
||||||
private int getStatusIconResource(RegistrationState state) {
|
private int getStatusIconResource(RegistrationState state) {
|
||||||
try {
|
try {
|
||||||
Core core = LinphoneManager.getCore();
|
if (state == RegistrationState.Ok) {
|
||||||
boolean defaultAccountConnected =
|
|
||||||
(core != null
|
|
||||||
&& core.getDefaultProxyConfig() != null
|
|
||||||
&& core.getDefaultProxyConfig().getState() == RegistrationState.Ok);
|
|
||||||
if (state == RegistrationState.Ok && defaultAccountConnected) {
|
|
||||||
return R.drawable.led_connected;
|
return R.drawable.led_connected;
|
||||||
} else if (state == RegistrationState.Progress) {
|
} else if (state == RegistrationState.Progress) {
|
||||||
return R.drawable.led_inprogress;
|
return R.drawable.led_inprogress;
|
||||||
|
@ -212,9 +205,7 @@ public class StatusBarFragment extends Fragment {
|
||||||
private String getStatusIconText(RegistrationState state) {
|
private String getStatusIconText(RegistrationState state) {
|
||||||
Context context = getActivity();
|
Context context = getActivity();
|
||||||
try {
|
try {
|
||||||
if (state == RegistrationState.Ok
|
if (state == RegistrationState.Ok) {
|
||||||
&& LinphoneManager.getCore().getDefaultProxyConfig().getState()
|
|
||||||
== RegistrationState.Ok) {
|
|
||||||
return context.getString(R.string.status_connected);
|
return context.getString(R.string.status_connected);
|
||||||
} else if (state == RegistrationState.Progress) {
|
} else if (state == RegistrationState.Progress) {
|
||||||
return context.getString(R.string.status_in_progress);
|
return context.getString(R.string.status_in_progress);
|
||||||
|
|
|
@ -25,8 +25,8 @@ import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import org.linphone.LinphoneContext;
|
||||||
import org.linphone.LinphoneManager;
|
import org.linphone.LinphoneManager;
|
||||||
import org.linphone.LinphoneService;
|
|
||||||
import org.linphone.R;
|
import org.linphone.R;
|
||||||
import org.linphone.compatibility.Compatibility;
|
import org.linphone.compatibility.Compatibility;
|
||||||
import org.linphone.core.Address;
|
import org.linphone.core.Address;
|
||||||
|
@ -45,7 +45,7 @@ public class NotificationBroadcastReceiver extends BroadcastReceiver {
|
||||||
if (intent.getAction().equals(Compatibility.INTENT_REPLY_NOTIF_ACTION)
|
if (intent.getAction().equals(Compatibility.INTENT_REPLY_NOTIF_ACTION)
|
||||||
|| intent.getAction().equals(Compatibility.INTENT_MARK_AS_READ_ACTION)) {
|
|| intent.getAction().equals(Compatibility.INTENT_MARK_AS_READ_ACTION)) {
|
||||||
String remoteSipAddr =
|
String remoteSipAddr =
|
||||||
LinphoneService.instance()
|
LinphoneContext.instance()
|
||||||
.getNotificationManager()
|
.getNotificationManager()
|
||||||
.getSipUriForNotificationId(notifId);
|
.getSipUriForNotificationId(notifId);
|
||||||
|
|
||||||
|
@ -98,16 +98,16 @@ public class NotificationBroadcastReceiver extends BroadcastReceiver {
|
||||||
ChatMessage msg = room.createMessage(reply);
|
ChatMessage msg = room.createMessage(reply);
|
||||||
msg.setUserData(notifId);
|
msg.setUserData(notifId);
|
||||||
msg.addListener(
|
msg.addListener(
|
||||||
LinphoneService.instance().getNotificationManager().getMessageListener());
|
LinphoneContext.instance().getNotificationManager().getMessageListener());
|
||||||
msg.send();
|
msg.send();
|
||||||
Log.i("[Notification Broadcast Receiver] Reply sent for notif id " + notifId);
|
Log.i("[Notification Broadcast Receiver] Reply sent for notif id " + notifId);
|
||||||
} else {
|
} else {
|
||||||
LinphoneService.instance().getNotificationManager().dismissNotification(notifId);
|
LinphoneContext.instance().getNotificationManager().dismissNotification(notifId);
|
||||||
}
|
}
|
||||||
} else if (intent.getAction().equals(Compatibility.INTENT_ANSWER_CALL_NOTIF_ACTION)
|
} else if (intent.getAction().equals(Compatibility.INTENT_ANSWER_CALL_NOTIF_ACTION)
|
||||||
|| intent.getAction().equals(Compatibility.INTENT_HANGUP_CALL_NOTIF_ACTION)) {
|
|| intent.getAction().equals(Compatibility.INTENT_HANGUP_CALL_NOTIF_ACTION)) {
|
||||||
String remoteAddr =
|
String remoteAddr =
|
||||||
LinphoneService.instance()
|
LinphoneContext.instance()
|
||||||
.getNotificationManager()
|
.getNotificationManager()
|
||||||
.getSipUriForCallNotificationId(notifId);
|
.getSipUriForCallNotificationId(notifId);
|
||||||
|
|
||||||
|
@ -135,7 +135,7 @@ public class NotificationBroadcastReceiver extends BroadcastReceiver {
|
||||||
private void onError(Context context, int notifId) {
|
private void onError(Context context, int notifId) {
|
||||||
Notification replyError =
|
Notification replyError =
|
||||||
Compatibility.createRepliedNotification(context, context.getString(R.string.error));
|
Compatibility.createRepliedNotification(context, context.getString(R.string.error));
|
||||||
LinphoneService.instance().getNotificationManager().sendNotification(notifId, replyError);
|
LinphoneContext.instance().getNotificationManager().sendNotification(notifId, replyError);
|
||||||
}
|
}
|
||||||
|
|
||||||
private CharSequence getMessageText(Intent intent) {
|
private CharSequence getMessageText(Intent intent) {
|
||||||
|
|
|
@ -116,12 +116,6 @@ public class NotificationsManager {
|
||||||
Notification.PRIORITY_MIN,
|
Notification.PRIORITY_MIN,
|
||||||
true);
|
true);
|
||||||
|
|
||||||
if (isServiceNotificationDisplayed()) {
|
|
||||||
Log.i(
|
|
||||||
"[Notifications Manager] Background service mode enabled, displaying notification");
|
|
||||||
startForeground();
|
|
||||||
}
|
|
||||||
|
|
||||||
mListener =
|
mListener =
|
||||||
new CoreListenerStub() {
|
new CoreListenerStub() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -292,24 +286,31 @@ public class NotificationsManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startForeground() {
|
public void startForeground() {
|
||||||
|
if (LinphoneService.isReady()) {
|
||||||
Log.i("[Notifications Manager] Starting Service as foreground");
|
Log.i("[Notifications Manager] Starting Service as foreground");
|
||||||
LinphoneService.instance().startForeground(SERVICE_NOTIF_ID, mServiceNotification);
|
LinphoneService.instance().startForeground(SERVICE_NOTIF_ID, mServiceNotification);
|
||||||
mCurrentForegroundServiceNotification = SERVICE_NOTIF_ID;
|
mCurrentForegroundServiceNotification = SERVICE_NOTIF_ID;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void startForeground(Notification notification, int id) {
|
private void startForeground(Notification notification, int id) {
|
||||||
|
if (LinphoneService.isReady()) {
|
||||||
Log.i("[Notifications Manager] Starting Service as foreground while in call");
|
Log.i("[Notifications Manager] Starting Service as foreground while in call");
|
||||||
LinphoneService.instance().startForeground(id, notification);
|
LinphoneService.instance().startForeground(id, notification);
|
||||||
mCurrentForegroundServiceNotification = id;
|
mCurrentForegroundServiceNotification = id;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void stopForeground() {
|
public void stopForeground() {
|
||||||
|
if (LinphoneService.isReady()) {
|
||||||
Log.i("[Notifications Manager] Stopping Service as foreground");
|
Log.i("[Notifications Manager] Stopping Service as foreground");
|
||||||
LinphoneService.instance().stopForeground(true);
|
LinphoneService.instance().stopForeground(true);
|
||||||
mCurrentForegroundServiceNotification = 0;
|
mCurrentForegroundServiceNotification = 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void removeForegroundServiceNotificationIfPossible() {
|
public void removeForegroundServiceNotificationIfPossible() {
|
||||||
|
if (LinphoneService.isReady()) {
|
||||||
if (mCurrentForegroundServiceNotification == SERVICE_NOTIF_ID
|
if (mCurrentForegroundServiceNotification == SERVICE_NOTIF_ID
|
||||||
&& !isServiceNotificationDisplayed()) {
|
&& !isServiceNotificationDisplayed()) {
|
||||||
Log.i(
|
Log.i(
|
||||||
|
@ -317,6 +318,7 @@ public class NotificationsManager {
|
||||||
stopForeground();
|
stopForeground();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void setCurrentlyDisplayedChatRoom(String address) {
|
public void setCurrentlyDisplayedChatRoom(String address) {
|
||||||
mCurrentChatRoomAddress = address;
|
mCurrentChatRoomAddress = address;
|
||||||
|
|
|
@ -52,9 +52,6 @@ public class RecordingsActivity extends MainActivity
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
if (mAbortCreation) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
mOnBackPressGoHome = false;
|
mOnBackPressGoHome = false;
|
||||||
mAlwaysHideTabBar = true;
|
mAlwaysHideTabBar = true;
|
||||||
|
|
|
@ -31,7 +31,7 @@ import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.appcompat.app.AppCompatDelegate;
|
import androidx.appcompat.app.AppCompatDelegate;
|
||||||
import org.linphone.LinphoneService;
|
import org.linphone.LinphoneContext;
|
||||||
import org.linphone.R;
|
import org.linphone.R;
|
||||||
import org.linphone.compatibility.Compatibility;
|
import org.linphone.compatibility.Compatibility;
|
||||||
import org.linphone.settings.widget.BasicSetting;
|
import org.linphone.settings.widget.BasicSetting;
|
||||||
|
@ -128,9 +128,9 @@ public class AdvancedSettingsFragment extends SettingsFragment {
|
||||||
public void onBoolValueChanged(boolean newValue) {
|
public void onBoolValueChanged(boolean newValue) {
|
||||||
mPrefs.setServiceNotificationVisibility(newValue);
|
mPrefs.setServiceNotificationVisibility(newValue);
|
||||||
if (newValue) {
|
if (newValue) {
|
||||||
LinphoneService.instance().getNotificationManager().startForeground();
|
LinphoneContext.instance().getNotificationManager().startForeground();
|
||||||
} else {
|
} else {
|
||||||
LinphoneService.instance().getNotificationManager().stopForeground();
|
LinphoneContext.instance().getNotificationManager().stopForeground();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -30,8 +30,8 @@ import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import org.linphone.LinphoneContext;
|
||||||
import org.linphone.LinphoneManager;
|
import org.linphone.LinphoneManager;
|
||||||
import org.linphone.LinphoneService;
|
|
||||||
import org.linphone.R;
|
import org.linphone.R;
|
||||||
import org.linphone.compatibility.Compatibility;
|
import org.linphone.compatibility.Compatibility;
|
||||||
import org.linphone.core.Address;
|
import org.linphone.core.Address;
|
||||||
|
@ -142,15 +142,15 @@ public class LinphonePreferences {
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getString(int key) {
|
private String getString(int key) {
|
||||||
if (mContext == null && LinphoneService.isReady()) {
|
if (mContext == null && LinphoneContext.isReady()) {
|
||||||
mContext = LinphoneService.instance();
|
mContext = LinphoneContext.instance().getApplicationContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
return mContext.getString(key);
|
return mContext.getString(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Core getLc() {
|
private Core getLc() {
|
||||||
if (!LinphoneService.isReady()) return null;
|
if (!LinphoneContext.isReady()) return null;
|
||||||
|
|
||||||
return LinphoneManager.getCore();
|
return LinphoneManager.getCore();
|
||||||
}
|
}
|
||||||
|
@ -161,7 +161,7 @@ public class LinphonePreferences {
|
||||||
return core.getConfig();
|
return core.getConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!LinphoneService.isReady()) {
|
if (!LinphoneContext.isReady()) {
|
||||||
File linphonerc = new File(mBasePath + "/.linphonerc");
|
File linphonerc = new File(mBasePath + "/.linphonerc");
|
||||||
if (linphonerc.exists()) {
|
if (linphonerc.exists()) {
|
||||||
return Factory.instance().createConfig(linphonerc.getAbsolutePath());
|
return Factory.instance().createConfig(linphonerc.getAbsolutePath());
|
||||||
|
|
|
@ -42,8 +42,8 @@ import java.text.SimpleDateFormat;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
import org.linphone.LinphoneContext;
|
||||||
import org.linphone.LinphoneManager;
|
import org.linphone.LinphoneManager;
|
||||||
import org.linphone.LinphoneService;
|
|
||||||
import org.linphone.R;
|
import org.linphone.R;
|
||||||
import org.linphone.core.Address;
|
import org.linphone.core.Address;
|
||||||
import org.linphone.core.Call;
|
import org.linphone.core.Call;
|
||||||
|
@ -71,16 +71,16 @@ public final class LinphoneUtils {
|
||||||
Factory.instance()
|
Factory.instance()
|
||||||
.enableLogCollection(LogCollectionState.EnabledWithoutPreviousLogHandler);
|
.enableLogCollection(LogCollectionState.EnabledWithoutPreviousLogHandler);
|
||||||
if (isDebugEnabled) {
|
if (isDebugEnabled) {
|
||||||
if (LinphoneService.isReady()) {
|
if (LinphoneContext.isReady()) {
|
||||||
Factory.instance()
|
Factory.instance()
|
||||||
.getLoggingService()
|
.getLoggingService()
|
||||||
.addListener(LinphoneService.instance().getJavaLoggingService());
|
.addListener(LinphoneContext.instance().getJavaLoggingService());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (LinphoneService.isReady()) {
|
if (LinphoneContext.isReady()) {
|
||||||
Factory.instance()
|
Factory.instance()
|
||||||
.getLoggingService()
|
.getLoggingService()
|
||||||
.removeListener(LinphoneService.instance().getJavaLoggingService());
|
.removeListener(LinphoneContext.instance().getJavaLoggingService());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -265,7 +265,10 @@ public final class LinphoneUtils {
|
||||||
return username.split("@")[0];
|
return username.split("@")[0];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (domain.equals(LinphoneService.instance().getString(R.string.default_domain))) {
|
if (domain.equals(
|
||||||
|
LinphoneContext.instance()
|
||||||
|
.getApplicationContext()
|
||||||
|
.getString(R.string.default_domain))) {
|
||||||
return username.split("@")[0];
|
return username.split("@")[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -290,7 +293,9 @@ public final class LinphoneUtils {
|
||||||
sipAddress =
|
sipAddress =
|
||||||
sipAddress
|
sipAddress
|
||||||
+ "@"
|
+ "@"
|
||||||
+ LinphoneService.instance().getString(R.string.default_domain);
|
+ LinphoneContext.instance()
|
||||||
|
.getApplicationContext()
|
||||||
|
.getString(R.string.default_domain);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return sipAddress;
|
return sipAddress;
|
||||||
|
|
51
app/src/main/java/org/linphone/utils/ServiceWaitThread.java
Normal file
51
app/src/main/java/org/linphone/utils/ServiceWaitThread.java
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
package org.linphone.utils;
|
||||||
|
|
||||||
|
/*
|
||||||
|
ServiceWaitThread.java
|
||||||
|
Copyright (C) 2019 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 org.linphone.LinphoneService;
|
||||||
|
|
||||||
|
public class ServiceWaitThread extends Thread {
|
||||||
|
private ServiceWaitThreadListener mListener;
|
||||||
|
|
||||||
|
public ServiceWaitThread(ServiceWaitThreadListener listener) {
|
||||||
|
mListener = listener;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
while (!LinphoneService.isReady()) {
|
||||||
|
try {
|
||||||
|
sleep(30);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
throw new RuntimeException("waiting thread sleep() has been interrupted");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mListener != null) {
|
||||||
|
LinphoneUtils.dispatchOnUIThread(
|
||||||
|
new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
mListener.onServiceReady();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
package org.linphone.utils;
|
||||||
|
|
||||||
|
/*
|
||||||
|
ServiceWaitThreadListener.java
|
||||||
|
Copyright (C) 2019 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public interface ServiceWaitThreadListener {
|
||||||
|
void onServiceReady();
|
||||||
|
}
|
|
@ -33,7 +33,7 @@ import android.widget.ImageView;
|
||||||
import android.widget.RelativeLayout;
|
import android.widget.RelativeLayout;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
import org.linphone.LinphoneService;
|
import org.linphone.LinphoneContext;
|
||||||
import org.linphone.core.tools.Log;
|
import org.linphone.core.tools.Log;
|
||||||
import org.linphone.utils.FileUtils;
|
import org.linphone.utils.FileUtils;
|
||||||
import org.linphone.utils.ImageUtils;
|
import org.linphone.utils.ImageUtils;
|
||||||
|
@ -76,7 +76,7 @@ public class BitmapWorkerTask extends AsyncTask<String, Void, Bitmap> {
|
||||||
// Decode image in background.
|
// Decode image in background.
|
||||||
@Override
|
@Override
|
||||||
protected Bitmap doInBackground(String... params) {
|
protected Bitmap doInBackground(String... params) {
|
||||||
Context context = LinphoneService.instance();
|
Context context = LinphoneContext.instance().getApplicationContext();
|
||||||
path = params[0];
|
path = params[0];
|
||||||
Bitmap bm = null;
|
Bitmap bm = null;
|
||||||
Bitmap thumbnail = null;
|
Bitmap thumbnail = null;
|
||||||
|
@ -146,7 +146,7 @@ public class BitmapWorkerTask extends AsyncTask<String, Void, Bitmap> {
|
||||||
bitmap = null;
|
bitmap = null;
|
||||||
}
|
}
|
||||||
if (mImageViewReference != null && bitmap != null) {
|
if (mImageViewReference != null && bitmap != null) {
|
||||||
Context context = LinphoneService.instance();
|
Context context = LinphoneContext.instance().getApplicationContext();
|
||||||
final ImageView imageView = mImageViewReference.get();
|
final ImageView imageView = mImageViewReference.get();
|
||||||
final BitmapWorkerTask bitmapWorkerTask = getBitmapWorkerTask(imageView);
|
final BitmapWorkerTask bitmapWorkerTask = getBitmapWorkerTask(imageView);
|
||||||
if (this == bitmapWorkerTask && imageView != null) {
|
if (this == bitmapWorkerTask && imageView != null) {
|
||||||
|
|
|
@ -28,8 +28,8 @@ import android.util.AttributeSet;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
|
import org.linphone.LinphoneContext;
|
||||||
import org.linphone.LinphoneManager;
|
import org.linphone.LinphoneManager;
|
||||||
import org.linphone.LinphoneService;
|
|
||||||
import org.linphone.R;
|
import org.linphone.R;
|
||||||
import org.linphone.core.Call;
|
import org.linphone.core.Call;
|
||||||
import org.linphone.core.Core;
|
import org.linphone.core.Core;
|
||||||
|
@ -99,7 +99,7 @@ public class Digit extends Button implements AddressAware {
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean linphoneServiceReady() {
|
private boolean linphoneServiceReady() {
|
||||||
if (!LinphoneService.isReady()) {
|
if (!LinphoneContext.isReady()) {
|
||||||
Log.e("[Numpad] Service is not ready while pressing digit");
|
Log.e("[Numpad] Service is not ready while pressing digit");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,8 +30,8 @@ import android.view.MotionEvent;
|
||||||
import android.view.SurfaceView;
|
import android.view.SurfaceView;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
|
import org.linphone.LinphoneContext;
|
||||||
import org.linphone.LinphoneManager;
|
import org.linphone.LinphoneManager;
|
||||||
import org.linphone.LinphoneService;
|
|
||||||
import org.linphone.call.CallActivity;
|
import org.linphone.call.CallActivity;
|
||||||
import org.linphone.core.Call;
|
import org.linphone.core.Call;
|
||||||
import org.linphone.core.CallParams;
|
import org.linphone.core.CallParams;
|
||||||
|
@ -100,7 +100,7 @@ public class LinphoneGL2JNIViewOverlay extends org.linphone.mediastream.video.di
|
||||||
new OnClickListener() {
|
new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
Context context = LinphoneService.instance();
|
Context context = LinphoneContext.instance().getApplicationContext();
|
||||||
Intent intent = new Intent(context, CallActivity.class);
|
Intent intent = new Intent(context, CallActivity.class);
|
||||||
// This flag is required to start an Activity from a Service context
|
// This flag is required to start an Activity from a Service context
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
|
|
@ -32,8 +32,8 @@ import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.widget.RelativeLayout;
|
import android.widget.RelativeLayout;
|
||||||
|
import org.linphone.LinphoneContext;
|
||||||
import org.linphone.LinphoneManager;
|
import org.linphone.LinphoneManager;
|
||||||
import org.linphone.LinphoneService;
|
|
||||||
import org.linphone.call.CallActivity;
|
import org.linphone.call.CallActivity;
|
||||||
import org.linphone.core.Call;
|
import org.linphone.core.Call;
|
||||||
import org.linphone.core.CallParams;
|
import org.linphone.core.CallParams;
|
||||||
|
@ -106,7 +106,7 @@ public class LinphoneTextureViewOverlay extends RelativeLayout implements Linpho
|
||||||
new OnClickListener() {
|
new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
Context context = LinphoneService.instance();
|
Context context = LinphoneContext.instance().getApplicationContext();
|
||||||
Intent intent = new Intent(context, CallActivity.class);
|
Intent intent = new Intent(context, CallActivity.class);
|
||||||
// This flag is required to start an Activity from a Service context
|
// This flag is required to start an Activity from a Service context
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
|
Loading…
Reference in a new issue