If service notif is disabled, start/stop foreground along with calls so it doesn't prevent device to use internet while screen is off
This commit is contained in:
parent
77b008c181
commit
80b147887b
1 changed files with 16 additions and 17 deletions
|
@ -414,22 +414,13 @@ public final class LinphoneService extends Service {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Retrieve methods to publish notification and keep Android
|
|
||||||
// from killing us and keep the audio quality high.
|
|
||||||
if (Version.sdkStrictlyBelow(Version.API05_ECLAIR_20)) {
|
|
||||||
try {
|
|
||||||
mSetForeground = getClass().getMethod("setForeground", mSetFgSign);
|
|
||||||
} catch (NoSuchMethodException e) {
|
|
||||||
Log.e(e, "Couldn't find foreground method");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
try {
|
try {
|
||||||
mStartForeground = getClass().getMethod("startForeground", mStartFgSign);
|
mStartForeground = getClass().getMethod("startForeground", mStartFgSign);
|
||||||
mStopForeground = getClass().getMethod("stopForeground", mStopFgSign);
|
mStopForeground = getClass().getMethod("stopForeground", mStopFgSign);
|
||||||
} catch (NoSuchMethodException e) {
|
} catch (NoSuchMethodException e) {
|
||||||
Log.e(e, "Couldn't find startForeground or stopForeground");
|
Log.e(e, "Couldn't find startForeground or stopForeground");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
getContentResolver().registerContentObserver(ContactsContract.Contacts.CONTENT_URI, true, ContactsManager.getInstance());
|
getContentResolver().registerContentObserver(ContactsContract.Contacts.CONTENT_URI, true, ContactsManager.getInstance());
|
||||||
|
|
||||||
|
@ -487,7 +478,11 @@ public final class LinphoneService extends Service {
|
||||||
|
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case IDLE:
|
case IDLE:
|
||||||
|
if (!displayServiceNotification()) {
|
||||||
|
stopForegroundCompat(INCALL_NOTIF_ID);
|
||||||
|
} else {
|
||||||
mNM.cancel(INCALL_NOTIF_ID);
|
mNM.cancel(INCALL_NOTIF_ID);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
case INCALL:
|
case INCALL:
|
||||||
inconId = R.drawable.topbar_call_notification;
|
inconId = R.drawable.topbar_call_notification;
|
||||||
|
@ -527,8 +522,12 @@ public final class LinphoneService extends Service {
|
||||||
String name = address.getDisplayName() == null ? address.getUserName() : address.getDisplayName();
|
String name = address.getDisplayName() == null ? address.getUserName() : address.getDisplayName();
|
||||||
mIncallNotif = Compatibility.createInCallNotification(getApplicationContext(), mNotificationTitle, getString(notificationTextId), inconId, bm, name, mNotifContentIntent);
|
mIncallNotif = Compatibility.createInCallNotification(getApplicationContext(), mNotificationTitle, getString(notificationTextId), inconId, bm, name, mNotifContentIntent);
|
||||||
|
|
||||||
|
if (!displayServiceNotification()) {
|
||||||
|
startForegroundCompat(INCALL_NOTIF_ID, mIncallNotif);
|
||||||
|
} else {
|
||||||
notifyWrapper(INCALL_NOTIF_ID, mIncallNotif);
|
notifyWrapper(INCALL_NOTIF_ID, mIncallNotif);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void refreshIncallIcon(LinphoneCall currentCall) {
|
public void refreshIncallIcon(LinphoneCall currentCall) {
|
||||||
LinphoneCore lc = LinphoneManager.getLc();
|
LinphoneCore lc = LinphoneManager.getLc();
|
||||||
|
|
Loading…
Reference in a new issue