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
|
||||
public void onFriendListCreated(Core core, FriendList list) {
|
||||
if (LinphoneService.isReady()) {
|
||||
if (LinphoneContext.isReady()) {
|
||||
list.addListener(ContactsManager.getInstance());
|
||||
}
|
||||
}
|
||||
|
@ -345,7 +345,7 @@ public class LinphoneManager implements SensorEventListener {
|
|||
}
|
||||
|
||||
public static synchronized LinphoneManager getInstance() {
|
||||
LinphoneManager manager = LinphoneService.instance().getLinphoneManager();
|
||||
LinphoneManager manager = LinphoneContext.instance().getLinphoneManager();
|
||||
if (manager == null) {
|
||||
throw new RuntimeException(
|
||||
"[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.
|
||||
*/
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Application;
|
||||
import android.app.Service;
|
||||
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.provider.ContactsContract;
|
||||
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.State;
|
||||
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.ActivityMonitor;
|
||||
import org.linphone.utils.LinphoneUtils;
|
||||
import org.linphone.views.LinphoneGL2JNIViewOverlay;
|
||||
import org.linphone.views.LinphoneOverlay;
|
||||
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 {
|
||||
private static final String START_LINPHONE_LOGS = " ==== Phone information dump ====";
|
||||
private static LinphoneService sInstance;
|
||||
|
||||
public final Handler handler = new Handler();
|
||||
private LinphoneOverlay mOverlay;
|
||||
private WindowManager mWindowManager;
|
||||
private Application.ActivityLifecycleCallbacks mActivityCallbacks;
|
||||
|
||||
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;
|
||||
private boolean misLinphoneContextOwned;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
|
@ -111,71 +49,14 @@ public final class LinphoneService extends Service {
|
|||
|
||||
setupActivityMonitor();
|
||||
|
||||
// Needed in order for the two next calls to succeed, libraries must have been loaded first
|
||||
LinphonePreferences.instance().setContext(this);
|
||||
Factory.instance().setLogCollectionPath(getFilesDir().getAbsolutePath());
|
||||
boolean isDebugEnabled = LinphonePreferences.instance().isDebugEnabled();
|
||||
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);
|
||||
misLinphoneContextOwned = false;
|
||||
if (!LinphoneContext.isReady()) {
|
||||
new LinphoneContext(getApplicationContext());
|
||||
misLinphoneContextOwned = true;
|
||||
}
|
||||
Log.i("[Service] Created");
|
||||
|
||||
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
|
||||
|
@ -192,34 +73,26 @@ public final class LinphoneService extends Service {
|
|||
Log.w("[Service] Attempt to start the LinphoneService but it is already running !");
|
||||
return START_STICKY;
|
||||
}
|
||||
sInstance = this;
|
||||
|
||||
mLinphoneManager = new LinphoneManager(getApplicationContext());
|
||||
sInstance = this; // sInstance is ready once linphone manager has been created
|
||||
if (LinphonePreferences.instance().getServiceNotificationVisibility()) {
|
||||
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)
|
||||
&& intent != null
|
||||
&& intent.getBooleanExtra("ForceStartForeground", false)) {
|
||||
// We need to call this asap after the Service can be accessed through it's singleton
|
||||
mNotificationManager.startForeground();
|
||||
LinphoneContext.instance().getNotificationManager().startForeground();
|
||||
}
|
||||
|
||||
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();
|
||||
Log.i("[Service] Started");
|
||||
|
||||
return START_STICKY;
|
||||
}
|
||||
|
@ -248,35 +121,17 @@ public final class LinphoneService extends Service {
|
|||
@SuppressWarnings("UnusedAssignment")
|
||||
@Override
|
||||
public synchronized void onDestroy() {
|
||||
Log.i("[Service] Destroying");
|
||||
|
||||
if (mActivityCallbacks != null) {
|
||||
getApplication().unregisterActivityLifecycleCallbacks(mActivityCallbacks);
|
||||
mActivityCallbacks = null;
|
||||
}
|
||||
destroyOverlay();
|
||||
|
||||
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();
|
||||
}
|
||||
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
|
||||
LinphoneContext.instance().destroy();
|
||||
sInstance = null;
|
||||
|
||||
if (LinphonePreferences.instance().useJavaLogger()) {
|
||||
Factory.instance().getLoggingService().removeListener(mJavaLoggingService);
|
||||
}
|
||||
LinphonePreferences.instance().destroy();
|
||||
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
|
@ -297,23 +152,8 @@ public final class LinphoneService extends Service {
|
|||
|
||||
/* 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() {
|
||||
Log.i("[Service] Creating video overlay");
|
||||
if (mOverlay != null) destroyOverlay();
|
||||
|
||||
Core core = LinphoneManager.getCore();
|
||||
|
@ -332,6 +172,7 @@ public final class LinphoneService extends Service {
|
|||
}
|
||||
|
||||
public void destroyOverlay() {
|
||||
Log.i("[Service] Destroying video overlay");
|
||||
if (mOverlay != null) {
|
||||
mOverlay.removeFromWindowManager(mWindowManager);
|
||||
mOverlay.destroy();
|
||||
|
@ -344,56 +185,4 @@ public final class LinphoneService extends Service {
|
|||
getApplication()
|
||||
.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
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (mAbortCreation) {
|
||||
return;
|
||||
}
|
||||
|
||||
mOnBackPressGoHome = false;
|
||||
mAlwaysHideTabBar = true;
|
||||
|
|
|
@ -64,9 +64,6 @@ public class DialerActivity extends MainActivity implements AddressText.AddressC
|
|||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (mAbortCreation) {
|
||||
return;
|
||||
}
|
||||
|
||||
mInterfaceLoaded = false;
|
||||
// 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.
|
||||
*/
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.Surface;
|
||||
import org.linphone.LinphoneContext;
|
||||
import org.linphone.LinphoneManager;
|
||||
import org.linphone.LinphoneService;
|
||||
import org.linphone.core.Core;
|
||||
import org.linphone.core.tools.Log;
|
||||
|
||||
public abstract class LinphoneGenericActivity extends ThemeableActivity {
|
||||
protected boolean mAbortCreation;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
mAbortCreation = false;
|
||||
super.onCreate(savedInstanceState);
|
||||
// After a crash, Android restart the last Activity so we need to check
|
||||
// if all dependencies are loaded
|
||||
if (!LinphoneService.isReady()) {
|
||||
startActivity(getIntent().setClass(this, LinphoneLauncherActivity.class));
|
||||
mAbortCreation = true;
|
||||
finish();
|
||||
}
|
||||
|
||||
ensureServiceIsRunning();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
|
||||
if (LinphoneService.isReady()) {
|
||||
ensureServiceIsRunning();
|
||||
|
||||
if (LinphoneContext.isReady()) {
|
||||
int degrees = 270;
|
||||
int orientation = getWindowManager().getDefaultDisplay().getRotation();
|
||||
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.history.HistoryActivity;
|
||||
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 */
|
||||
public class LinphoneLauncherActivity extends Activity {
|
||||
public class LinphoneLauncherActivity extends Activity implements ServiceWaitThreadListener {
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
@ -57,11 +58,12 @@ public class LinphoneLauncherActivity extends Activity {
|
|||
} else {
|
||||
startService(
|
||||
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;
|
||||
|
||||
boolean useFirstLoginActivity =
|
||||
|
@ -89,42 +91,16 @@ public class LinphoneLauncherActivity extends Activity {
|
|||
LinphoneManager.getInstance().checkForUpdate();
|
||||
}
|
||||
|
||||
LinphoneUtils.dispatchOnUIThreadAfter(
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Intent intent = new Intent();
|
||||
intent.setClass(LinphoneLauncherActivity.this, classToStart);
|
||||
if (getIntent() != null && getIntent().getExtras() != null) {
|
||||
intent.putExtras(getIntent().getExtras());
|
||||
}
|
||||
intent.setAction(getIntent().getAction());
|
||||
intent.setType(getIntent().getType());
|
||||
intent.setData(getIntent().getData());
|
||||
startActivity(intent);
|
||||
}
|
||||
},
|
||||
100);
|
||||
Intent intent = new Intent();
|
||||
intent.setClass(LinphoneLauncherActivity.this, classToStart);
|
||||
if (getIntent() != null && getIntent().getExtras() != null) {
|
||||
intent.putExtras(getIntent().getExtras());
|
||||
}
|
||||
intent.setAction(getIntent().getAction());
|
||||
intent.setType(getIntent().getType());
|
||||
intent.setData(getIntent().getData());
|
||||
startActivity(intent);
|
||||
|
||||
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.drawerlayout.widget.DrawerLayout;
|
||||
import java.util.ArrayList;
|
||||
import org.linphone.LinphoneContext;
|
||||
import org.linphone.LinphoneManager;
|
||||
import org.linphone.LinphoneService;
|
||||
import org.linphone.R;
|
||||
|
@ -102,13 +103,6 @@ public abstract class MainActivity extends LinphoneGenericActivity
|
|||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (mAbortCreation) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!LinphoneService.isReady()) {
|
||||
finish();
|
||||
}
|
||||
|
||||
setContentView(R.layout.main);
|
||||
|
||||
|
@ -304,7 +298,7 @@ public abstract class MainActivity extends LinphoneGenericActivity
|
|||
protected void onResume() {
|
||||
super.onResume();
|
||||
|
||||
LinphoneService.instance()
|
||||
LinphoneContext.instance()
|
||||
.getNotificationManager()
|
||||
.removeForegroundServiceNotificationIfPossible();
|
||||
|
||||
|
|
|
@ -48,9 +48,6 @@ public class AccountConnectionAssistantActivity extends AssistantActivity {
|
|||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (mAbortCreation) {
|
||||
return;
|
||||
}
|
||||
|
||||
setContentView(R.layout.assistant_account_connection);
|
||||
|
||||
|
|
|
@ -27,8 +27,8 @@ import android.view.View;
|
|||
import android.view.WindowManager;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import org.linphone.LinphoneContext;
|
||||
import org.linphone.LinphoneManager;
|
||||
import org.linphone.LinphoneService;
|
||||
import org.linphone.R;
|
||||
import org.linphone.activities.DialerActivity;
|
||||
import org.linphone.activities.LinphoneGenericActivity;
|
||||
|
@ -52,9 +52,6 @@ public abstract class AssistantActivity extends LinphoneGenericActivity
|
|||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (mAbortCreation) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mAccountCreator == null) {
|
||||
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
|
||||
// service notification, otherwise incoming calls won't work (most probably)
|
||||
LinphonePreferences.instance().setServiceNotificationVisibility(true);
|
||||
LinphoneService.instance().getNotificationManager().startForeground();
|
||||
LinphoneContext.instance().getNotificationManager().startForeground();
|
||||
}
|
||||
|
||||
if (proxyConfig == null) {
|
||||
|
|
|
@ -44,9 +44,6 @@ public class EmailAccountCreationAssistantActivity extends AssistantActivity {
|
|||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (mAbortCreation) {
|
||||
return;
|
||||
}
|
||||
|
||||
setContentView(R.layout.assistant_email_account_creation);
|
||||
|
||||
|
|
|
@ -37,9 +37,6 @@ public class EmailAccountValidationAssistantActivity extends AssistantActivity {
|
|||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (mAbortCreation) {
|
||||
return;
|
||||
}
|
||||
|
||||
setContentView(R.layout.assistant_email_account_validation);
|
||||
|
||||
|
|
|
@ -38,9 +38,6 @@ public class GenericConnectionAssistantActivity extends AssistantActivity implem
|
|||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (mAbortCreation) {
|
||||
return;
|
||||
}
|
||||
|
||||
setContentView(R.layout.assistant_generic_connection);
|
||||
|
||||
|
|
|
@ -33,9 +33,6 @@ public class MenuAssistantActivity extends AssistantActivity {
|
|||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (mAbortCreation) {
|
||||
return;
|
||||
}
|
||||
|
||||
setContentView(R.layout.assistant_menu);
|
||||
|
||||
|
|
|
@ -44,9 +44,6 @@ public class OpenH264DownloadAssistantActivity extends AssistantActivity {
|
|||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (mAbortCreation) {
|
||||
return;
|
||||
}
|
||||
|
||||
setContentView(R.layout.assistant_openh264_codec_download);
|
||||
mHelper = Factory.instance().createOpenH264DownloadHelper(this);
|
||||
|
|
|
@ -46,9 +46,6 @@ public class PhoneAccountCreationAssistantActivity extends AssistantActivity {
|
|||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (mAbortCreation) {
|
||||
return;
|
||||
}
|
||||
|
||||
setContentView(R.layout.assistant_phone_account_creation);
|
||||
|
||||
|
|
|
@ -49,9 +49,6 @@ public class PhoneAccountLinkingAssistantActivity extends AssistantActivity {
|
|||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (mAbortCreation) {
|
||||
return;
|
||||
}
|
||||
|
||||
setContentView(R.layout.assistant_phone_account_linking);
|
||||
|
||||
|
|
|
@ -46,9 +46,6 @@ public class PhoneAccountValidationAssistantActivity extends AssistantActivity {
|
|||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (mAbortCreation) {
|
||||
return;
|
||||
}
|
||||
|
||||
setContentView(R.layout.assistant_phone_account_validation);
|
||||
|
||||
|
|
|
@ -40,9 +40,6 @@ public class QrCodeConfigurationAssistantActivity extends AssistantActivity {
|
|||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (mAbortCreation) {
|
||||
return;
|
||||
}
|
||||
|
||||
setContentView(R.layout.assistant_qr_code_remote_configuration);
|
||||
|
||||
|
|
|
@ -56,9 +56,6 @@ public class RemoteConfigurationAssistantActivity extends AssistantActivity {
|
|||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (mAbortCreation) {
|
||||
return;
|
||||
}
|
||||
|
||||
setContentView(R.layout.assistant_remote_configuration);
|
||||
|
||||
|
|
|
@ -131,9 +131,6 @@ public class CallActivity extends LinphoneGenericActivity
|
|||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (mAbortCreation) {
|
||||
return;
|
||||
}
|
||||
|
||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||
Compatibility.setShowWhenLocked(this, true);
|
||||
|
|
|
@ -32,8 +32,8 @@ import android.widget.TextView;
|
|||
import android.widget.Toast;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import java.util.ArrayList;
|
||||
import org.linphone.LinphoneContext;
|
||||
import org.linphone.LinphoneManager;
|
||||
import org.linphone.LinphoneService;
|
||||
import org.linphone.R;
|
||||
import org.linphone.activities.LinphoneGenericActivity;
|
||||
import org.linphone.compatibility.Compatibility;
|
||||
|
@ -62,9 +62,6 @@ public class CallIncomingActivity extends LinphoneGenericActivity {
|
|||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (mAbortCreation) {
|
||||
return;
|
||||
}
|
||||
|
||||
Compatibility.setShowWhenLocked(this, true);
|
||||
Compatibility.setTurnScreenOn(this, true);
|
||||
|
@ -206,7 +203,7 @@ public class CallIncomingActivity extends LinphoneGenericActivity {
|
|||
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
if (LinphoneService.isReady()
|
||||
if (LinphoneContext.isReady()
|
||||
&& (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_HOME)) {
|
||||
mCall.terminate();
|
||||
finish();
|
||||
|
|
|
@ -23,8 +23,8 @@ import android.content.ContentResolver;
|
|||
import android.content.Context;
|
||||
import android.provider.Settings;
|
||||
import android.widget.Toast;
|
||||
import org.linphone.LinphoneContext;
|
||||
import org.linphone.LinphoneManager;
|
||||
import org.linphone.LinphoneService;
|
||||
import org.linphone.R;
|
||||
import org.linphone.contacts.ContactsManager;
|
||||
import org.linphone.contacts.LinphoneContact;
|
||||
|
@ -122,7 +122,8 @@ public class CallManager {
|
|||
CallParams params = core.createCallParams(call);
|
||||
|
||||
boolean isLowBandwidthConnection =
|
||||
!LinphoneUtils.isHighBandwidthConnection(LinphoneService.instance());
|
||||
!LinphoneUtils.isHighBandwidthConnection(
|
||||
LinphoneContext.instance().getApplicationContext());
|
||||
|
||||
if (params != null) {
|
||||
params.enableLowBandwidth(isLowBandwidthConnection);
|
||||
|
@ -156,7 +157,8 @@ public class CallManager {
|
|||
|
||||
public void inviteAddress(Address address, boolean forceZRTP) {
|
||||
boolean isLowBandwidthConnection =
|
||||
!LinphoneUtils.isHighBandwidthConnection(LinphoneService.instance());
|
||||
!LinphoneUtils.isHighBandwidthConnection(
|
||||
LinphoneContext.instance().getApplicationContext());
|
||||
|
||||
inviteAddress(address, false, isLowBandwidthConnection, forceZRTP);
|
||||
}
|
||||
|
@ -202,7 +204,8 @@ public class CallManager {
|
|||
address.setDisplayName(displayName);
|
||||
|
||||
boolean isLowBandwidthConnection =
|
||||
!LinphoneUtils.isHighBandwidthConnection(LinphoneService.instance());
|
||||
!LinphoneUtils.isHighBandwidthConnection(
|
||||
LinphoneContext.instance().getApplicationContext());
|
||||
|
||||
if (core.isNetworkReachable()) {
|
||||
if (Version.isVideoCapable()) {
|
||||
|
@ -324,7 +327,9 @@ public class CallManager {
|
|||
params.setMediaEncryption(MediaEncryption.ZRTP);
|
||||
}
|
||||
|
||||
String recordFile = FileUtils.getCallRecordingFilename(LinphoneService.instance(), address);
|
||||
String recordFile =
|
||||
FileUtils.getCallRecordingFilename(
|
||||
LinphoneContext.instance().getApplicationContext(), address);
|
||||
params.setRecordFile(recordFile);
|
||||
|
||||
core.inviteAddressWithParams(address, params);
|
||||
|
@ -362,7 +367,7 @@ public class CallManager {
|
|||
if (call != null) {
|
||||
call.enableCamera(enable);
|
||||
if (mContext.getResources().getBoolean(R.bool.enable_call_notification))
|
||||
LinphoneService.instance()
|
||||
LinphoneContext.instance()
|
||||
.getNotificationManager()
|
||||
.displayCallNotification(LinphoneManager.getCore().getCurrentCall());
|
||||
}
|
||||
|
|
|
@ -31,8 +31,8 @@ import android.widget.TextView;
|
|||
import android.widget.Toast;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import java.util.ArrayList;
|
||||
import org.linphone.LinphoneContext;
|
||||
import org.linphone.LinphoneManager;
|
||||
import org.linphone.LinphoneService;
|
||||
import org.linphone.R;
|
||||
import org.linphone.activities.LinphoneGenericActivity;
|
||||
import org.linphone.contacts.ContactsManager;
|
||||
|
@ -59,9 +59,6 @@ public class CallOutgoingActivity extends LinphoneGenericActivity implements OnC
|
|||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (mAbortCreation) {
|
||||
return;
|
||||
}
|
||||
|
||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||
setContentView(R.layout.call_outgoing);
|
||||
|
@ -234,7 +231,7 @@ public class CallOutgoingActivity extends LinphoneGenericActivity implements OnC
|
|||
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
if (LinphoneService.isReady()
|
||||
if (LinphoneContext.isReady()
|
||||
&& (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_HOME)) {
|
||||
mCall.terminate();
|
||||
finish();
|
||||
|
|
|
@ -59,8 +59,8 @@ import java.io.File;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import org.linphone.LinphoneContext;
|
||||
import org.linphone.LinphoneManager;
|
||||
import org.linphone.LinphoneService;
|
||||
import org.linphone.R;
|
||||
import org.linphone.activities.MainActivity;
|
||||
import org.linphone.contacts.ContactAddress;
|
||||
|
@ -386,7 +386,7 @@ public class ChatMessagesFragment extends Fragment
|
|||
displayChatRoomHeader();
|
||||
displayChatRoomHistory();
|
||||
|
||||
LinphoneService.instance()
|
||||
LinphoneContext.instance()
|
||||
.getNotificationManager()
|
||||
.setCurrentlyDisplayedChatRoom(
|
||||
mRemoteSipAddress != null ? mRemoteSipAddress.asStringUriOnly() : null);
|
||||
|
@ -401,7 +401,7 @@ public class ChatMessagesFragment extends Fragment
|
|||
|
||||
ContactsManager.getInstance().removeContactsListener(this);
|
||||
removeVirtualKeyboardVisiblityListener();
|
||||
LinphoneService.instance().getNotificationManager().setCurrentlyDisplayedChatRoom(null);
|
||||
LinphoneContext.instance().getNotificationManager().setCurrentlyDisplayedChatRoom(null);
|
||||
if (mChatRoom != null) mChatRoom.removeListener(this);
|
||||
if (mChatEventsList.getAdapter() != null)
|
||||
((ChatMessagesGenericAdapter) mChatEventsList.getAdapter()).clear();
|
||||
|
|
|
@ -26,7 +26,7 @@ import androidx.annotation.NonNull;
|
|||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.linphone.LinphoneService;
|
||||
import org.linphone.LinphoneContext;
|
||||
import org.linphone.R;
|
||||
import org.linphone.contacts.ContactAddress;
|
||||
import org.linphone.contacts.LinphoneContact;
|
||||
|
@ -73,7 +73,10 @@ class GroupInfoAdapter extends RecyclerView.Adapter<GroupInfoViewHolder> {
|
|||
|
||||
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.name.setOnClickListener(
|
||||
new View.OnClickListener() {
|
||||
|
|
|
@ -32,7 +32,7 @@ import android.provider.ContactsContract.Data;
|
|||
import android.provider.ContactsContract.RawContacts;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import org.linphone.LinphoneService;
|
||||
import org.linphone.LinphoneContext;
|
||||
import org.linphone.R;
|
||||
import org.linphone.core.tools.Log;
|
||||
|
||||
|
@ -67,7 +67,8 @@ class AndroidContact implements Serializable {
|
|||
void saveChangesCommited() {
|
||||
if (ContactsManager.getInstance().hasReadContactsAccess() && mChangesToCommit.size() > 0) {
|
||||
try {
|
||||
ContentResolver contentResolver = LinphoneService.instance().getContentResolver();
|
||||
ContentResolver contentResolver =
|
||||
LinphoneContext.instance().getApplicationContext().getContentResolver();
|
||||
ContentProviderResult[] results =
|
||||
contentResolver.applyBatch(ContactsContract.AUTHORITY, mChangesToCommit);
|
||||
if (results != null
|
||||
|
@ -110,7 +111,10 @@ class AndroidContact implements Serializable {
|
|||
}
|
||||
|
||||
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");
|
||||
addChangesToCommit(
|
||||
ContentProviderOperation.newInsert(RawContacts.CONTENT_URI)
|
||||
|
@ -229,7 +233,8 @@ class AndroidContact implements Serializable {
|
|||
boolean isLinphoneAddressMimeEntryAlreadyExisting(String value) {
|
||||
boolean result = false;
|
||||
|
||||
ContentResolver resolver = LinphoneService.instance().getContentResolver();
|
||||
ContentResolver resolver =
|
||||
LinphoneContext.instance().getApplicationContext().getContentResolver();
|
||||
String[] projection = {"data1", "data3"};
|
||||
String selection =
|
||||
ContactsContract.Data.RAW_CONTACT_ID
|
||||
|
@ -576,7 +581,8 @@ class AndroidContact implements Serializable {
|
|||
}
|
||||
|
||||
private String findRawContactID() {
|
||||
ContentResolver resolver = LinphoneService.instance().getContentResolver();
|
||||
ContentResolver resolver =
|
||||
LinphoneContext.instance().getApplicationContext().getContentResolver();
|
||||
String result = null;
|
||||
String[] projection = {ContactsContract.RawContacts._ID};
|
||||
|
||||
|
@ -598,7 +604,10 @@ class AndroidContact implements Serializable {
|
|||
}
|
||||
|
||||
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 (mAndroidRawId == null) {
|
||||
Log.d("[Contact] RAW ID not found for contact " + mAndroidId);
|
||||
|
@ -659,7 +668,8 @@ class AndroidContact implements Serializable {
|
|||
}
|
||||
|
||||
private String findLinphoneRawContactId() {
|
||||
ContentResolver resolver = LinphoneService.instance().getContentResolver();
|
||||
ContentResolver resolver =
|
||||
LinphoneContext.instance().getApplicationContext().getContentResolver();
|
||||
String result = null;
|
||||
String[] projection = {ContactsContract.RawContacts._ID};
|
||||
|
||||
|
|
|
@ -40,8 +40,8 @@ import java.util.ArrayList;
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import org.linphone.LinphoneContext;
|
||||
import org.linphone.LinphoneManager;
|
||||
import org.linphone.LinphoneService;
|
||||
import org.linphone.R;
|
||||
import org.linphone.compatibility.Compatibility;
|
||||
import org.linphone.core.Address;
|
||||
|
@ -64,7 +64,7 @@ public class ContactsManager extends ContentObserver implements FriendListListen
|
|||
private boolean mInitialized = false;
|
||||
|
||||
public static ContactsManager getInstance() {
|
||||
return LinphoneService.instance().getContactsManager();
|
||||
return LinphoneContext.instance().getContactsManager();
|
||||
}
|
||||
|
||||
public ContactsManager(Context context, Handler handler) {
|
||||
|
@ -256,7 +256,7 @@ public class ContactsManager extends ContentObserver implements FriendListListen
|
|||
if (hasReadContactsAccess()
|
||||
&& hasWriteContactsAccess()
|
||||
&& hasWriteSyncPermission()) {
|
||||
if (LinphoneService.isReady()) {
|
||||
if (LinphoneContext.isReady()) {
|
||||
initializeSyncAccount();
|
||||
mInitialized = true;
|
||||
}
|
||||
|
@ -452,7 +452,10 @@ public class ContactsManager extends ContentObserver implements FriendListListen
|
|||
LinphoneContact contact = (LinphoneContact) lf.getUserData();
|
||||
|
||||
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
|
||||
if (LinphonePreferences.instance()
|
||||
.isPresenceStorageInNativeAndroidContactEnabled()) {
|
||||
|
|
|
@ -26,8 +26,8 @@ import android.provider.ContactsContract;
|
|||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.linphone.LinphoneContext;
|
||||
import org.linphone.LinphoneManager;
|
||||
import org.linphone.LinphoneService;
|
||||
import org.linphone.R;
|
||||
import org.linphone.core.Address;
|
||||
import org.linphone.core.Core;
|
||||
|
@ -547,7 +547,8 @@ public class LinphoneContact extends AndroidContact
|
|||
Log.d("[Linphone Contact] Found phone number " + data1 + " (" + data4 + ")");
|
||||
addNumberOrAddress(new LinphoneNumberOrAddress(data1, data4));
|
||||
} else if (ContactsContract.CommonDataKinds.SipAddress.CONTENT_ITEM_TYPE.equals(mime)
|
||||
|| LinphoneService.instance()
|
||||
|| LinphoneContext.instance()
|
||||
.getApplicationContext()
|
||||
.getString(R.string.linphone_address_mime_type)
|
||||
.equals(mime)) {
|
||||
Log.d("[Linphone Contact] Found SIP address " + data1);
|
||||
|
@ -595,7 +596,7 @@ public class LinphoneContact extends AndroidContact
|
|||
|
||||
public void save() {
|
||||
saveChangesCommited();
|
||||
syncValuesFromAndroidContact(LinphoneService.instance());
|
||||
syncValuesFromAndroidContact(LinphoneContext.instance().getApplicationContext());
|
||||
createOrUpdateFriend();
|
||||
}
|
||||
|
||||
|
|
|
@ -27,8 +27,8 @@ import androidx.recyclerview.widget.RecyclerView;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import org.linphone.LinphoneContext;
|
||||
import org.linphone.LinphoneManager;
|
||||
import org.linphone.LinphoneService;
|
||||
import org.linphone.R;
|
||||
import org.linphone.core.Address;
|
||||
import org.linphone.core.FriendCapability;
|
||||
|
@ -243,7 +243,8 @@ public class SearchContactsAdapter extends RecyclerView.Adapter<SearchContactVie
|
|||
.getContactListFromFilter(search, mOnlySipContact ? domain : "");
|
||||
|
||||
for (SearchResult sr : searchResults) {
|
||||
if (LinphoneService.instance()
|
||||
if (LinphoneContext.instance()
|
||||
.getApplicationContext()
|
||||
.getResources()
|
||||
.getBoolean(R.bool.hide_sip_contacts_without_presence)) {
|
||||
if (sr.getFriend() != null) {
|
||||
|
|
|
@ -85,11 +85,9 @@ public class StatusBarFragment extends Fragment {
|
|||
mStatusLed.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
if (core.getDefaultProxyConfig() != null
|
||||
&& core.getDefaultProxyConfig().equals(proxy)) {
|
||||
mStatusLed.setImageResource(getStatusIconResource(state));
|
||||
mStatusText.setText(getStatusIconText(state));
|
||||
} else if (core.getDefaultProxyConfig() == null) {
|
||||
if ((core.getDefaultProxyConfig() != null
|
||||
&& core.getDefaultProxyConfig().equals(proxy))
|
||||
|| core.getDefaultProxyConfig() == null) {
|
||||
mStatusLed.setImageResource(getStatusIconResource(state));
|
||||
mStatusText.setText(getStatusIconText(state));
|
||||
}
|
||||
|
@ -188,12 +186,7 @@ public class StatusBarFragment extends Fragment {
|
|||
|
||||
private int getStatusIconResource(RegistrationState state) {
|
||||
try {
|
||||
Core core = LinphoneManager.getCore();
|
||||
boolean defaultAccountConnected =
|
||||
(core != null
|
||||
&& core.getDefaultProxyConfig() != null
|
||||
&& core.getDefaultProxyConfig().getState() == RegistrationState.Ok);
|
||||
if (state == RegistrationState.Ok && defaultAccountConnected) {
|
||||
if (state == RegistrationState.Ok) {
|
||||
return R.drawable.led_connected;
|
||||
} else if (state == RegistrationState.Progress) {
|
||||
return R.drawable.led_inprogress;
|
||||
|
@ -212,9 +205,7 @@ public class StatusBarFragment extends Fragment {
|
|||
private String getStatusIconText(RegistrationState state) {
|
||||
Context context = getActivity();
|
||||
try {
|
||||
if (state == RegistrationState.Ok
|
||||
&& LinphoneManager.getCore().getDefaultProxyConfig().getState()
|
||||
== RegistrationState.Ok) {
|
||||
if (state == RegistrationState.Ok) {
|
||||
return context.getString(R.string.status_connected);
|
||||
} else if (state == RegistrationState.Progress) {
|
||||
return context.getString(R.string.status_in_progress);
|
||||
|
|
|
@ -25,8 +25,8 @@ import android.content.BroadcastReceiver;
|
|||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import org.linphone.LinphoneContext;
|
||||
import org.linphone.LinphoneManager;
|
||||
import org.linphone.LinphoneService;
|
||||
import org.linphone.R;
|
||||
import org.linphone.compatibility.Compatibility;
|
||||
import org.linphone.core.Address;
|
||||
|
@ -45,7 +45,7 @@ public class NotificationBroadcastReceiver extends BroadcastReceiver {
|
|||
if (intent.getAction().equals(Compatibility.INTENT_REPLY_NOTIF_ACTION)
|
||||
|| intent.getAction().equals(Compatibility.INTENT_MARK_AS_READ_ACTION)) {
|
||||
String remoteSipAddr =
|
||||
LinphoneService.instance()
|
||||
LinphoneContext.instance()
|
||||
.getNotificationManager()
|
||||
.getSipUriForNotificationId(notifId);
|
||||
|
||||
|
@ -98,16 +98,16 @@ public class NotificationBroadcastReceiver extends BroadcastReceiver {
|
|||
ChatMessage msg = room.createMessage(reply);
|
||||
msg.setUserData(notifId);
|
||||
msg.addListener(
|
||||
LinphoneService.instance().getNotificationManager().getMessageListener());
|
||||
LinphoneContext.instance().getNotificationManager().getMessageListener());
|
||||
msg.send();
|
||||
Log.i("[Notification Broadcast Receiver] Reply sent for notif id " + notifId);
|
||||
} else {
|
||||
LinphoneService.instance().getNotificationManager().dismissNotification(notifId);
|
||||
LinphoneContext.instance().getNotificationManager().dismissNotification(notifId);
|
||||
}
|
||||
} else if (intent.getAction().equals(Compatibility.INTENT_ANSWER_CALL_NOTIF_ACTION)
|
||||
|| intent.getAction().equals(Compatibility.INTENT_HANGUP_CALL_NOTIF_ACTION)) {
|
||||
String remoteAddr =
|
||||
LinphoneService.instance()
|
||||
LinphoneContext.instance()
|
||||
.getNotificationManager()
|
||||
.getSipUriForCallNotificationId(notifId);
|
||||
|
||||
|
@ -135,7 +135,7 @@ public class NotificationBroadcastReceiver extends BroadcastReceiver {
|
|||
private void onError(Context context, int notifId) {
|
||||
Notification replyError =
|
||||
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) {
|
||||
|
|
|
@ -116,12 +116,6 @@ public class NotificationsManager {
|
|||
Notification.PRIORITY_MIN,
|
||||
true);
|
||||
|
||||
if (isServiceNotificationDisplayed()) {
|
||||
Log.i(
|
||||
"[Notifications Manager] Background service mode enabled, displaying notification");
|
||||
startForeground();
|
||||
}
|
||||
|
||||
mListener =
|
||||
new CoreListenerStub() {
|
||||
@Override
|
||||
|
@ -292,29 +286,37 @@ public class NotificationsManager {
|
|||
}
|
||||
|
||||
public void startForeground() {
|
||||
Log.i("[Notifications Manager] Starting Service as foreground");
|
||||
LinphoneService.instance().startForeground(SERVICE_NOTIF_ID, mServiceNotification);
|
||||
mCurrentForegroundServiceNotification = SERVICE_NOTIF_ID;
|
||||
if (LinphoneService.isReady()) {
|
||||
Log.i("[Notifications Manager] Starting Service as foreground");
|
||||
LinphoneService.instance().startForeground(SERVICE_NOTIF_ID, mServiceNotification);
|
||||
mCurrentForegroundServiceNotification = SERVICE_NOTIF_ID;
|
||||
}
|
||||
}
|
||||
|
||||
private void startForeground(Notification notification, int id) {
|
||||
Log.i("[Notifications Manager] Starting Service as foreground while in call");
|
||||
LinphoneService.instance().startForeground(id, notification);
|
||||
mCurrentForegroundServiceNotification = id;
|
||||
if (LinphoneService.isReady()) {
|
||||
Log.i("[Notifications Manager] Starting Service as foreground while in call");
|
||||
LinphoneService.instance().startForeground(id, notification);
|
||||
mCurrentForegroundServiceNotification = id;
|
||||
}
|
||||
}
|
||||
|
||||
public void stopForeground() {
|
||||
Log.i("[Notifications Manager] Stopping Service as foreground");
|
||||
LinphoneService.instance().stopForeground(true);
|
||||
mCurrentForegroundServiceNotification = 0;
|
||||
if (LinphoneService.isReady()) {
|
||||
Log.i("[Notifications Manager] Stopping Service as foreground");
|
||||
LinphoneService.instance().stopForeground(true);
|
||||
mCurrentForegroundServiceNotification = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public void removeForegroundServiceNotificationIfPossible() {
|
||||
if (mCurrentForegroundServiceNotification == SERVICE_NOTIF_ID
|
||||
&& !isServiceNotificationDisplayed()) {
|
||||
Log.i(
|
||||
"[Notifications Manager] Linphone has started after device boot, stopping Service as foreground");
|
||||
stopForeground();
|
||||
if (LinphoneService.isReady()) {
|
||||
if (mCurrentForegroundServiceNotification == SERVICE_NOTIF_ID
|
||||
&& !isServiceNotificationDisplayed()) {
|
||||
Log.i(
|
||||
"[Notifications Manager] Linphone has started after device boot, stopping Service as foreground");
|
||||
stopForeground();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -52,9 +52,6 @@ public class RecordingsActivity extends MainActivity
|
|||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (mAbortCreation) {
|
||||
return;
|
||||
}
|
||||
|
||||
mOnBackPressGoHome = false;
|
||||
mAlwaysHideTabBar = true;
|
||||
|
|
|
@ -31,7 +31,7 @@ import android.view.View;
|
|||
import android.view.ViewGroup;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatDelegate;
|
||||
import org.linphone.LinphoneService;
|
||||
import org.linphone.LinphoneContext;
|
||||
import org.linphone.R;
|
||||
import org.linphone.compatibility.Compatibility;
|
||||
import org.linphone.settings.widget.BasicSetting;
|
||||
|
@ -128,9 +128,9 @@ public class AdvancedSettingsFragment extends SettingsFragment {
|
|||
public void onBoolValueChanged(boolean newValue) {
|
||||
mPrefs.setServiceNotificationVisibility(newValue);
|
||||
if (newValue) {
|
||||
LinphoneService.instance().getNotificationManager().startForeground();
|
||||
LinphoneContext.instance().getNotificationManager().startForeground();
|
||||
} else {
|
||||
LinphoneService.instance().getNotificationManager().stopForeground();
|
||||
LinphoneContext.instance().getNotificationManager().stopForeground();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -30,8 +30,8 @@ import java.io.IOException;
|
|||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
import org.linphone.LinphoneContext;
|
||||
import org.linphone.LinphoneManager;
|
||||
import org.linphone.LinphoneService;
|
||||
import org.linphone.R;
|
||||
import org.linphone.compatibility.Compatibility;
|
||||
import org.linphone.core.Address;
|
||||
|
@ -142,15 +142,15 @@ public class LinphonePreferences {
|
|||
}
|
||||
|
||||
private String getString(int key) {
|
||||
if (mContext == null && LinphoneService.isReady()) {
|
||||
mContext = LinphoneService.instance();
|
||||
if (mContext == null && LinphoneContext.isReady()) {
|
||||
mContext = LinphoneContext.instance().getApplicationContext();
|
||||
}
|
||||
|
||||
return mContext.getString(key);
|
||||
}
|
||||
|
||||
private Core getLc() {
|
||||
if (!LinphoneService.isReady()) return null;
|
||||
if (!LinphoneContext.isReady()) return null;
|
||||
|
||||
return LinphoneManager.getCore();
|
||||
}
|
||||
|
@ -161,7 +161,7 @@ public class LinphonePreferences {
|
|||
return core.getConfig();
|
||||
}
|
||||
|
||||
if (!LinphoneService.isReady()) {
|
||||
if (!LinphoneContext.isReady()) {
|
||||
File linphonerc = new File(mBasePath + "/.linphonerc");
|
||||
if (linphonerc.exists()) {
|
||||
return Factory.instance().createConfig(linphonerc.getAbsolutePath());
|
||||
|
|
|
@ -42,8 +42,8 @@ import java.text.SimpleDateFormat;
|
|||
import java.util.Calendar;
|
||||
import java.util.Locale;
|
||||
import java.util.regex.Pattern;
|
||||
import org.linphone.LinphoneContext;
|
||||
import org.linphone.LinphoneManager;
|
||||
import org.linphone.LinphoneService;
|
||||
import org.linphone.R;
|
||||
import org.linphone.core.Address;
|
||||
import org.linphone.core.Call;
|
||||
|
@ -71,16 +71,16 @@ public final class LinphoneUtils {
|
|||
Factory.instance()
|
||||
.enableLogCollection(LogCollectionState.EnabledWithoutPreviousLogHandler);
|
||||
if (isDebugEnabled) {
|
||||
if (LinphoneService.isReady()) {
|
||||
if (LinphoneContext.isReady()) {
|
||||
Factory.instance()
|
||||
.getLoggingService()
|
||||
.addListener(LinphoneService.instance().getJavaLoggingService());
|
||||
.addListener(LinphoneContext.instance().getJavaLoggingService());
|
||||
}
|
||||
} else {
|
||||
if (LinphoneService.isReady()) {
|
||||
if (LinphoneContext.isReady()) {
|
||||
Factory.instance()
|
||||
.getLoggingService()
|
||||
.removeListener(LinphoneService.instance().getJavaLoggingService());
|
||||
.removeListener(LinphoneContext.instance().getJavaLoggingService());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -265,7 +265,10 @@ public final class LinphoneUtils {
|
|||
return username.split("@")[0];
|
||||
}
|
||||
} 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];
|
||||
}
|
||||
}
|
||||
|
@ -290,7 +293,9 @@ public final class LinphoneUtils {
|
|||
sipAddress =
|
||||
sipAddress
|
||||
+ "@"
|
||||
+ LinphoneService.instance().getString(R.string.default_domain);
|
||||
+ LinphoneContext.instance()
|
||||
.getApplicationContext()
|
||||
.getString(R.string.default_domain);
|
||||
}
|
||||
}
|
||||
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 java.io.IOException;
|
||||
import java.lang.ref.WeakReference;
|
||||
import org.linphone.LinphoneService;
|
||||
import org.linphone.LinphoneContext;
|
||||
import org.linphone.core.tools.Log;
|
||||
import org.linphone.utils.FileUtils;
|
||||
import org.linphone.utils.ImageUtils;
|
||||
|
@ -76,7 +76,7 @@ public class BitmapWorkerTask extends AsyncTask<String, Void, Bitmap> {
|
|||
// Decode image in background.
|
||||
@Override
|
||||
protected Bitmap doInBackground(String... params) {
|
||||
Context context = LinphoneService.instance();
|
||||
Context context = LinphoneContext.instance().getApplicationContext();
|
||||
path = params[0];
|
||||
Bitmap bm = null;
|
||||
Bitmap thumbnail = null;
|
||||
|
@ -146,7 +146,7 @@ public class BitmapWorkerTask extends AsyncTask<String, Void, Bitmap> {
|
|||
bitmap = null;
|
||||
}
|
||||
if (mImageViewReference != null && bitmap != null) {
|
||||
Context context = LinphoneService.instance();
|
||||
Context context = LinphoneContext.instance().getApplicationContext();
|
||||
final ImageView imageView = mImageViewReference.get();
|
||||
final BitmapWorkerTask bitmapWorkerTask = getBitmapWorkerTask(imageView);
|
||||
if (this == bitmapWorkerTask && imageView != null) {
|
||||
|
|
|
@ -28,8 +28,8 @@ import android.util.AttributeSet;
|
|||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import org.linphone.LinphoneContext;
|
||||
import org.linphone.LinphoneManager;
|
||||
import org.linphone.LinphoneService;
|
||||
import org.linphone.R;
|
||||
import org.linphone.core.Call;
|
||||
import org.linphone.core.Core;
|
||||
|
@ -99,7 +99,7 @@ public class Digit extends Button implements AddressAware {
|
|||
}
|
||||
|
||||
private boolean linphoneServiceReady() {
|
||||
if (!LinphoneService.isReady()) {
|
||||
if (!LinphoneContext.isReady()) {
|
||||
Log.e("[Numpad] Service is not ready while pressing digit");
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -30,8 +30,8 @@ import android.view.MotionEvent;
|
|||
import android.view.SurfaceView;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import org.linphone.LinphoneContext;
|
||||
import org.linphone.LinphoneManager;
|
||||
import org.linphone.LinphoneService;
|
||||
import org.linphone.call.CallActivity;
|
||||
import org.linphone.core.Call;
|
||||
import org.linphone.core.CallParams;
|
||||
|
@ -100,7 +100,7 @@ public class LinphoneGL2JNIViewOverlay extends org.linphone.mediastream.video.di
|
|||
new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Context context = LinphoneService.instance();
|
||||
Context context = LinphoneContext.instance().getApplicationContext();
|
||||
Intent intent = new Intent(context, CallActivity.class);
|
||||
// This flag is required to start an Activity from a Service context
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
|
|
|
@ -32,8 +32,8 @@ import android.view.View;
|
|||
import android.view.ViewGroup;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.RelativeLayout;
|
||||
import org.linphone.LinphoneContext;
|
||||
import org.linphone.LinphoneManager;
|
||||
import org.linphone.LinphoneService;
|
||||
import org.linphone.call.CallActivity;
|
||||
import org.linphone.core.Call;
|
||||
import org.linphone.core.CallParams;
|
||||
|
@ -106,7 +106,7 @@ public class LinphoneTextureViewOverlay extends RelativeLayout implements Linpho
|
|||
new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Context context = LinphoneService.instance();
|
||||
Context context = LinphoneContext.instance().getApplicationContext();
|
||||
Intent intent = new Intent(context, CallActivity.class);
|
||||
// This flag is required to start an Activity from a Service context
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
|
|
Loading…
Reference in a new issue