Changes to call Service.startForeground sooner
This commit is contained in:
parent
630876fa8d
commit
3e95ed8ed4
3 changed files with 15 additions and 11 deletions
|
@ -192,18 +192,20 @@ public final class LinphoneService extends Service {
|
|||
return START_STICKY;
|
||||
}
|
||||
|
||||
mNotificationManager = new NotificationsManager(this);
|
||||
if (Version.sdkAboveOrEqual(Version.API26_O_80)
|
||||
&& intent != null
|
||||
&& intent.getBooleanExtra("ForceStartForeground", false)) {
|
||||
// We need to call this asap
|
||||
mNotificationManager.startForeground();
|
||||
}
|
||||
|
||||
mLinphoneManager = new LinphoneManager(this);
|
||||
sInstance = this; // sInstance is ready once linphone manager has been created
|
||||
mLinphoneManager.startLibLinphone(isPush);
|
||||
LinphoneManager.getCore().addListener(mListener);
|
||||
|
||||
mNotificationManager = new NotificationsManager(this);
|
||||
|
||||
if (Version.sdkAboveOrEqual(Version.API26_O_80)
|
||||
&& intent != null
|
||||
&& intent.getBooleanExtra("ForceStartForeground", false)) {
|
||||
mNotificationManager.startForeground();
|
||||
}
|
||||
mNotificationManager.onCoreReady();
|
||||
|
||||
mContactsManager = new ContactsManager(this, handler);
|
||||
if (!Version.sdkAboveOrEqual(Version.API26_O_80)
|
||||
|
|
|
@ -203,7 +203,9 @@ public class NotificationsManager {
|
|||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public void onCoreReady() {
|
||||
Core core = LinphoneManager.getCore();
|
||||
if (core != null) {
|
||||
core.addListener(mListener);
|
||||
|
|
|
@ -41,10 +41,10 @@ public class BootReceiver extends BroadcastReceiver {
|
|||
android.util.Log.i(
|
||||
"LinphoneBootReceiver", "Device is starting, auto_start is " + autostart);
|
||||
if (autostart && !LinphoneService.isReady()) {
|
||||
Intent linphoneServiceIntent = new Intent(Intent.ACTION_MAIN);
|
||||
linphoneServiceIntent.setClass(context, LinphoneService.class);
|
||||
linphoneServiceIntent.putExtra("ForceStartForeground", true);
|
||||
Compatibility.startService(context, linphoneServiceIntent);
|
||||
Intent serviceIntent = new Intent(Intent.ACTION_MAIN);
|
||||
serviceIntent.setClass(context, LinphoneService.class);
|
||||
serviceIntent.putExtra("ForceStartForeground", true);
|
||||
Compatibility.startService(context, serviceIntent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue