1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-07-22 06:41:06 +02:00

CallSpec: Add source app for VoIP app calls

This commit is contained in:
Davis Mosenkovs 2023-10-08 21:40:17 +03:00 committed by José Rebelo
parent 7f593bf5e4
commit 5d15df0751
5 changed files with 22 additions and 1 deletions

View File

@ -551,17 +551,21 @@ public class NotificationListener extends NotificationListenerService {
// figure out sender
String number;
String appName = getAppName(app);
if (noti.extras.containsKey(Notification.EXTRA_PEOPLE)) {
number = noti.extras.getString(Notification.EXTRA_PEOPLE);
} else if (noti.extras.containsKey(Notification.EXTRA_TITLE)) {
number = noti.extras.getString(Notification.EXTRA_TITLE);
} else {
String appName = getAppName(app);
number = appName != null ? appName : app;
}
activeCallPostTime = sbn.getPostTime();
CallSpec callSpec = new CallSpec();
callSpec.number = number;
callSpec.sourceAppId = app;
if (appName != null) {
callSpec.sourceName = appName;
}
callSpec.command = callStarted ? CallSpec.CALL_START : CallSpec.CALL_INCOMING;
mLastCallCommand = callSpec.command;
GBApplication.deviceService().onSetCallState(callSpec);

View File

@ -67,6 +67,7 @@ public class GBDeviceService implements DeviceService {
EXTRA_NOTIFICATION_BODY,
EXTRA_NOTIFICATION_SOURCENAME,
EXTRA_CALL_DISPLAYNAME,
EXTRA_CALL_SOURCENAME,
EXTRA_MUSIC_ARTIST,
EXTRA_MUSIC_ALBUM,
EXTRA_MUSIC_TRACK,
@ -227,6 +228,8 @@ public class GBDeviceService implements DeviceService {
Intent intent = createIntent().setAction(ACTION_CALLSTATE)
.putExtra(EXTRA_CALL_PHONENUMBER, callSpec.number)
.putExtra(EXTRA_CALL_DISPLAYNAME, callSpec.name)
.putExtra(EXTRA_CALL_SOURCENAME, callSpec.sourceName)
.putExtra(EXTRA_CALL_SOURCEAPPID, callSpec.sourceAppId)
.putExtra(EXTRA_CALL_COMMAND, callSpec.command)
.putExtra(EXTRA_CALL_DNDSUPPRESSED, callSpec.dndSuppressed);
invokeService(intent);

View File

@ -27,6 +27,14 @@ public class CallSpec {
public String number;
public String name;
public String sourceName;
/**
* The application that generated the notification.
*/
public String sourceAppId;
public int command;
public int dndSuppressed;
}

View File

@ -97,6 +97,8 @@ public interface DeviceService extends EventHandler {
String EXTRA_CALL_COMMAND = "call_command";
String EXTRA_CALL_PHONENUMBER = "call_phonenumber";
String EXTRA_CALL_DISPLAYNAME = "call_displayname";
String EXTRA_CALL_SOURCENAME = "call_sourcename";
String EXTRA_CALL_SOURCEAPPID = "call_sourceappid";
String EXTRA_CALL_DNDSUPPRESSED = "call_dndsuppressed";
String EXTRA_CANNEDMESSAGES = "cannedmessages";
String EXTRA_CANNEDMESSAGES_TYPE = "cannedmessages_type";

View File

@ -162,6 +162,8 @@ import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_CAL
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_CALENDAREVENT_COLOR;
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_CALL_COMMAND;
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_CALL_DISPLAYNAME;
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_CALL_SOURCENAME;
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_CALL_SOURCEAPPID;
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_CALL_DNDSUPPRESSED;
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_CALL_PHONENUMBER;
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_CANNEDMESSAGES;
@ -855,6 +857,8 @@ public class DeviceCommunicationService extends Service implements SharedPrefere
callSpec.command = intent.getIntExtra(EXTRA_CALL_COMMAND, CallSpec.CALL_UNDEFINED);
callSpec.number = intent.getStringExtra(EXTRA_CALL_PHONENUMBER);
callSpec.name = intent.getStringExtra(EXTRA_CALL_DISPLAYNAME);
callSpec.sourceName = intent.getStringExtra(EXTRA_CALL_SOURCENAME);
callSpec.sourceAppId = intent.getStringExtra(EXTRA_CALL_SOURCEAPPID);
callSpec.dndSuppressed = intent.getIntExtra(EXTRA_CALL_DNDSUPPRESSED, 0);
deviceSupport.onSetCallState(callSpec);
break;