2024-01-10 18:54:00 +01:00
|
|
|
/* Copyright (C) 2015-2024 Alberto, Andreas Böhler, Andreas Shimokawa,
|
|
|
|
Arjan Schrijver, Carsten Pfeiffer, criogenic, Daniel Dakhno, Daniele Gobbetti,
|
|
|
|
Davis Mosenkovs, Frank Slezak, Gabriele Monaco, Gordon Williams, ivanovlev,
|
|
|
|
José Rebelo, Julien Pivotto, Kasha, mvn23, Petr Vaněk, Roi Greenberg,
|
|
|
|
Sebastian Kranz, Steffen Liebergeld
|
2017-03-10 14:53:19 +01:00
|
|
|
|
|
|
|
This file is part of Gadgetbridge.
|
|
|
|
|
|
|
|
Gadgetbridge is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU Affero General Public License as published
|
|
|
|
by the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
Gadgetbridge 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 Affero General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Affero General Public License
|
2024-01-10 18:54:00 +01:00
|
|
|
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
2015-08-21 00:58:18 +02:00
|
|
|
package nodomain.freeyourgadget.gadgetbridge.impl;
|
|
|
|
|
|
|
|
import android.app.Service;
|
|
|
|
import android.content.Context;
|
|
|
|
import android.content.Intent;
|
2017-01-27 21:16:19 +01:00
|
|
|
import android.database.Cursor;
|
2022-06-04 22:20:28 +02:00
|
|
|
import android.location.Location;
|
2015-08-21 00:58:18 +02:00
|
|
|
import android.net.Uri;
|
2022-08-18 23:03:28 +02:00
|
|
|
import android.os.Parcelable;
|
2017-01-27 21:16:19 +01:00
|
|
|
import android.provider.ContactsContract;
|
2015-08-21 00:58:18 +02:00
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.UUID;
|
|
|
|
|
2017-02-07 10:15:23 +01:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
|
|
|
import nodomain.freeyourgadget.gadgetbridge.R;
|
2023-07-04 00:19:19 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.capabilities.loyaltycards.LoyaltyCard;
|
2015-08-21 00:58:18 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.model.Alarm;
|
2016-05-16 17:30:11 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.model.CalendarEventSpec;
|
2016-04-04 20:08:34 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.model.CallSpec;
|
2016-06-24 10:25:08 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.model.CannedMessagesSpec;
|
2023-05-18 00:43:29 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.model.Contact;
|
2015-08-21 00:58:18 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.model.DeviceService;
|
2016-04-04 20:08:34 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.model.MusicSpec;
|
2016-06-08 20:27:25 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.model.MusicStateSpec;
|
2021-10-20 22:37:23 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.model.NavigationInfoSpec;
|
2015-09-24 14:45:21 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.model.NotificationSpec;
|
2021-12-04 16:55:09 +01:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.model.Reminder;
|
2016-12-31 15:56:05 +01:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.model.WeatherSpec;
|
2022-05-09 20:47:08 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.model.WorldClock;
|
2015-08-22 01:08:46 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.DeviceCommunicationService;
|
2018-09-04 01:00:14 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.util.RtlUtils;
|
2015-08-21 00:58:18 +02:00
|
|
|
|
2017-01-27 21:16:19 +01:00
|
|
|
import static nodomain.freeyourgadget.gadgetbridge.util.JavaExtensions.coalesce;
|
|
|
|
|
2022-10-14 10:56:08 +02:00
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
2018-09-04 01:00:14 +02:00
|
|
|
|
2015-08-21 00:58:18 +02:00
|
|
|
public class GBDeviceService implements DeviceService {
|
|
|
|
protected final Context mContext;
|
2022-08-01 23:04:41 +02:00
|
|
|
private final GBDevice mDevice;
|
2016-12-31 15:56:05 +01:00
|
|
|
private final Class<? extends Service> mServiceClass;
|
2021-03-21 19:46:30 +01:00
|
|
|
public static final String[] transliterationExtras = new String[]{
|
2017-01-24 19:04:06 +01:00
|
|
|
EXTRA_NOTIFICATION_SENDER,
|
|
|
|
EXTRA_NOTIFICATION_SUBJECT,
|
|
|
|
EXTRA_NOTIFICATION_TITLE,
|
|
|
|
EXTRA_NOTIFICATION_BODY,
|
|
|
|
EXTRA_NOTIFICATION_SOURCENAME,
|
2017-01-27 21:16:19 +01:00
|
|
|
EXTRA_CALL_DISPLAYNAME,
|
2023-10-08 20:40:17 +02:00
|
|
|
EXTRA_CALL_SOURCENAME,
|
2017-01-24 19:04:06 +01:00
|
|
|
EXTRA_MUSIC_ARTIST,
|
|
|
|
EXTRA_MUSIC_ALBUM,
|
|
|
|
EXTRA_MUSIC_TRACK,
|
|
|
|
EXTRA_CALENDAREVENT_TITLE,
|
2023-07-08 18:13:53 +02:00
|
|
|
EXTRA_CALENDAREVENT_DESCRIPTION,
|
|
|
|
EXTRA_CALENDAREVENT_LOCATION,
|
|
|
|
EXTRA_CALENDAREVENT_CALNAME,
|
2017-01-24 19:04:06 +01:00
|
|
|
};
|
2022-10-14 10:56:08 +02:00
|
|
|
private static final Logger LOG = LoggerFactory.getLogger(GBDeviceService.class);
|
2015-08-21 00:58:18 +02:00
|
|
|
|
2015-08-22 01:08:46 +02:00
|
|
|
public GBDeviceService(Context context) {
|
2022-08-01 23:04:41 +02:00
|
|
|
this(context, null);
|
|
|
|
}
|
|
|
|
|
|
|
|
public GBDeviceService(Context context, GBDevice device) {
|
2015-08-21 00:58:18 +02:00
|
|
|
mContext = context;
|
2022-08-01 23:04:41 +02:00
|
|
|
mDevice = device;
|
2015-08-22 01:08:46 +02:00
|
|
|
mServiceClass = DeviceCommunicationService.class;
|
2015-08-21 00:58:18 +02:00
|
|
|
}
|
|
|
|
|
2022-08-01 23:04:41 +02:00
|
|
|
@Override
|
|
|
|
public DeviceService forDevice(final GBDevice device) {
|
|
|
|
return new GBDeviceService(mContext, device);
|
|
|
|
}
|
|
|
|
|
2022-08-05 22:36:16 +02:00
|
|
|
public GBDevice getDevice() {
|
|
|
|
return mDevice;
|
|
|
|
}
|
|
|
|
|
2015-08-22 01:08:46 +02:00
|
|
|
protected Intent createIntent() {
|
2016-06-24 10:25:08 +02:00
|
|
|
return new Intent(mContext, mServiceClass);
|
2015-08-21 00:58:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
protected void invokeService(Intent intent) {
|
2017-01-24 19:04:06 +01:00
|
|
|
|
2018-09-04 01:00:14 +02:00
|
|
|
if (RtlUtils.rtlSupport()) {
|
2018-08-21 20:27:00 +02:00
|
|
|
for (String extra : transliterationExtras) {
|
|
|
|
if (intent.hasExtra(extra)) {
|
2018-09-04 01:00:14 +02:00
|
|
|
intent.putExtra(extra, RtlUtils.fixRtl(intent.getStringExtra(extra)));
|
2018-08-21 20:27:00 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-01 23:04:41 +02:00
|
|
|
if (mDevice != null) {
|
|
|
|
intent.putExtra(GBDevice.EXTRA_DEVICE, mDevice);
|
|
|
|
}
|
2022-10-14 10:56:08 +02:00
|
|
|
try {
|
|
|
|
mContext.startService(intent);
|
|
|
|
} catch (IllegalStateException e) {
|
|
|
|
LOG.error("IllegalStateException during startService ("+intent.getAction()+")");
|
|
|
|
}
|
2015-08-21 00:58:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
protected void stopService(Intent intent) {
|
|
|
|
mContext.stopService(intent);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void connect() {
|
2022-08-01 23:04:41 +02:00
|
|
|
connect(false);
|
2015-08-21 00:58:18 +02:00
|
|
|
}
|
|
|
|
|
2015-12-13 00:43:07 +01:00
|
|
|
@Override
|
2022-08-01 23:04:41 +02:00
|
|
|
public void connect(boolean firstTime) {
|
2015-08-21 00:58:18 +02:00
|
|
|
Intent intent = createIntent().setAction(ACTION_CONNECT)
|
2017-04-12 21:33:19 +02:00
|
|
|
.putExtra(EXTRA_CONNECT_FIRST_TIME, firstTime);
|
2015-08-21 00:58:18 +02:00
|
|
|
invokeService(intent);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void disconnect() {
|
|
|
|
Intent intent = createIntent().setAction(ACTION_DISCONNECT);
|
|
|
|
invokeService(intent);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void quit() {
|
|
|
|
Intent intent = createIntent();
|
|
|
|
stopService(intent);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void requestDeviceInfo() {
|
|
|
|
Intent intent = createIntent().setAction(ACTION_REQUEST_DEVICEINFO);
|
|
|
|
invokeService(intent);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-09-24 14:45:21 +02:00
|
|
|
public void onNotification(NotificationSpec notificationSpec) {
|
2023-10-02 19:03:04 +02:00
|
|
|
String messagePrivacyMode = GBApplication.getPrefs().getString("pref_message_privacy_mode",
|
|
|
|
GBApplication.getContext().getString(R.string.p_message_privacy_mode_off));
|
|
|
|
boolean hideMessageDetails = messagePrivacyMode.equals(GBApplication.getContext().getString(R.string.p_message_privacy_mode_complete));
|
|
|
|
boolean hideMessageBodyOnly = messagePrivacyMode.equals(GBApplication.getContext().getString(R.string.p_message_privacy_mode_bodyonly));
|
2021-09-26 21:59:11 +02:00
|
|
|
|
2015-09-24 14:45:21 +02:00
|
|
|
Intent intent = createIntent().setAction(ACTION_NOTIFICATION)
|
2016-01-09 17:54:17 +01:00
|
|
|
.putExtra(EXTRA_NOTIFICATION_FLAGS, notificationSpec.flags)
|
2021-09-26 21:59:11 +02:00
|
|
|
.putExtra(EXTRA_NOTIFICATION_PHONENUMBER, hideMessageDetails ? null : notificationSpec.phoneNumber)
|
|
|
|
.putExtra(EXTRA_NOTIFICATION_SENDER, hideMessageDetails ? null : coalesce(notificationSpec.sender, getContactDisplayNameByNumber(notificationSpec.phoneNumber)))
|
|
|
|
.putExtra(EXTRA_NOTIFICATION_SUBJECT, hideMessageDetails ? null : notificationSpec.subject)
|
|
|
|
.putExtra(EXTRA_NOTIFICATION_TITLE, hideMessageDetails ? null : notificationSpec.title)
|
2023-10-02 19:03:04 +02:00
|
|
|
.putExtra(EXTRA_NOTIFICATION_BODY, hideMessageDetails || hideMessageBodyOnly ? null : notificationSpec.body)
|
2018-10-31 21:47:12 +01:00
|
|
|
.putExtra(EXTRA_NOTIFICATION_ID, notificationSpec.getId())
|
2023-12-08 13:12:35 +01:00
|
|
|
.putExtra(EXTRA_NOTIFICATION_KEY, notificationSpec.key)
|
2015-09-24 14:45:21 +02:00
|
|
|
.putExtra(EXTRA_NOTIFICATION_TYPE, notificationSpec.type)
|
2018-10-31 21:47:12 +01:00
|
|
|
.putExtra(EXTRA_NOTIFICATION_ACTIONS, notificationSpec.attachedActions)
|
2017-09-19 13:24:31 +02:00
|
|
|
.putExtra(EXTRA_NOTIFICATION_SOURCENAME, notificationSpec.sourceName)
|
2018-07-23 02:24:38 +02:00
|
|
|
.putExtra(EXTRA_NOTIFICATION_PEBBLE_COLOR, notificationSpec.pebbleColor)
|
2021-04-20 09:55:27 +02:00
|
|
|
.putExtra(EXTRA_NOTIFICATION_SOURCEAPPID, notificationSpec.sourceAppId)
|
2021-11-19 15:09:27 +01:00
|
|
|
.putExtra(EXTRA_NOTIFICATION_ICONID, notificationSpec.iconId)
|
|
|
|
.putExtra(EXTRA_NOTIFICATION_DNDSUPPRESSED, notificationSpec.dndSuppressed);
|
2015-08-21 00:58:18 +02:00
|
|
|
invokeService(intent);
|
|
|
|
}
|
|
|
|
|
2017-01-09 16:33:00 +01:00
|
|
|
@Override
|
|
|
|
public void onDeleteNotification(int id) {
|
|
|
|
Intent intent = createIntent().setAction(ACTION_DELETE_NOTIFICATION)
|
|
|
|
.putExtra(EXTRA_NOTIFICATION_ID, id);
|
|
|
|
invokeService(intent);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-08-21 00:58:18 +02:00
|
|
|
@Override
|
|
|
|
public void onSetTime() {
|
|
|
|
Intent intent = createIntent().setAction(ACTION_SETTIME);
|
|
|
|
invokeService(intent);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onSetAlarms(ArrayList<? extends Alarm> alarms) {
|
|
|
|
Intent intent = createIntent().setAction(ACTION_SET_ALARMS)
|
2019-01-07 01:10:57 +01:00
|
|
|
.putExtra(EXTRA_ALARMS, alarms);
|
2015-08-21 00:58:18 +02:00
|
|
|
invokeService(intent);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2016-04-04 20:08:34 +02:00
|
|
|
public void onSetCallState(CallSpec callSpec) {
|
2017-02-07 10:15:23 +01:00
|
|
|
Context context = GBApplication.getContext();
|
|
|
|
String currentPrivacyMode = GBApplication.getPrefs().getString("pref_call_privacy_mode", GBApplication.getContext().getString(R.string.p_call_privacy_mode_off));
|
2018-01-30 22:44:27 +01:00
|
|
|
if (currentPrivacyMode.equals(context.getString(R.string.p_call_privacy_mode_name))) {
|
2017-02-07 10:15:23 +01:00
|
|
|
callSpec.name = callSpec.number;
|
2018-01-30 22:44:27 +01:00
|
|
|
} else if (currentPrivacyMode.equals(context.getString(R.string.p_call_privacy_mode_complete))) {
|
2017-02-07 10:15:23 +01:00
|
|
|
callSpec.number = null;
|
|
|
|
callSpec.name = null;
|
2018-01-30 22:44:27 +01:00
|
|
|
} else if (currentPrivacyMode.equals(context.getString(R.string.p_call_privacy_mode_number))){
|
2017-03-14 21:37:16 +01:00
|
|
|
callSpec.name = coalesce(callSpec.name, getContactDisplayNameByNumber(callSpec.number));
|
2017-03-14 22:03:30 +01:00
|
|
|
if (callSpec.name != null && !callSpec.name.equals(callSpec.number)) {
|
2017-03-14 21:37:16 +01:00
|
|
|
callSpec.number = null;
|
|
|
|
}
|
|
|
|
} else {
|
2017-02-07 10:15:23 +01:00
|
|
|
callSpec.name = coalesce(callSpec.name, getContactDisplayNameByNumber(callSpec.number));
|
|
|
|
}
|
|
|
|
|
2015-08-21 00:58:18 +02:00
|
|
|
Intent intent = createIntent().setAction(ACTION_CALLSTATE)
|
2016-04-04 20:08:34 +02:00
|
|
|
.putExtra(EXTRA_CALL_PHONENUMBER, callSpec.number)
|
2017-02-07 10:15:23 +01:00
|
|
|
.putExtra(EXTRA_CALL_DISPLAYNAME, callSpec.name)
|
2023-10-08 20:40:17 +02:00
|
|
|
.putExtra(EXTRA_CALL_SOURCENAME, callSpec.sourceName)
|
|
|
|
.putExtra(EXTRA_CALL_SOURCEAPPID, callSpec.sourceAppId)
|
2022-05-15 16:51:41 +02:00
|
|
|
.putExtra(EXTRA_CALL_COMMAND, callSpec.command)
|
|
|
|
.putExtra(EXTRA_CALL_DNDSUPPRESSED, callSpec.dndSuppressed);
|
2015-08-21 00:58:18 +02:00
|
|
|
invokeService(intent);
|
|
|
|
}
|
|
|
|
|
2016-06-24 10:25:08 +02:00
|
|
|
@Override
|
|
|
|
public void onSetCannedMessages(CannedMessagesSpec cannedMessagesSpec) {
|
|
|
|
Intent intent = createIntent().setAction(ACTION_SETCANNEDMESSAGES)
|
|
|
|
.putExtra(EXTRA_CANNEDMESSAGES_TYPE, cannedMessagesSpec.type)
|
|
|
|
.putExtra(EXTRA_CANNEDMESSAGES, cannedMessagesSpec.cannedMessages);
|
|
|
|
invokeService(intent);
|
|
|
|
}
|
|
|
|
|
2016-06-08 20:27:25 +02:00
|
|
|
@Override
|
|
|
|
public void onSetMusicState(MusicStateSpec stateSpec) {
|
|
|
|
Intent intent = createIntent().setAction(ACTION_SETMUSICSTATE)
|
|
|
|
.putExtra(EXTRA_MUSIC_REPEAT, stateSpec.repeat)
|
|
|
|
.putExtra(EXTRA_MUSIC_RATE, stateSpec.playRate)
|
|
|
|
.putExtra(EXTRA_MUSIC_STATE, stateSpec.state)
|
|
|
|
.putExtra(EXTRA_MUSIC_SHUFFLE, stateSpec.shuffle)
|
|
|
|
.putExtra(EXTRA_MUSIC_POSITION, stateSpec.position);
|
|
|
|
invokeService(intent);
|
|
|
|
}
|
|
|
|
|
2022-05-05 15:14:15 +02:00
|
|
|
@Override
|
|
|
|
public void onSetPhoneVolume(final float volume) {
|
|
|
|
Intent intent = createIntent().setAction(ACTION_SET_PHONE_VOLUME)
|
|
|
|
.putExtra(EXTRA_PHONE_VOLUME, volume);
|
|
|
|
invokeService(intent);
|
|
|
|
}
|
|
|
|
|
2023-12-11 11:50:31 +01:00
|
|
|
@Override
|
|
|
|
public void onChangePhoneSilentMode(int ringerMode) {
|
|
|
|
Intent intent = createIntent().setAction(ACTION_SET_PHONE_SILENT_MODE)
|
|
|
|
.putExtra(EXTRA_PHONE_RINGER_MODE, ringerMode);
|
|
|
|
invokeService(intent);
|
|
|
|
}
|
|
|
|
|
2021-12-04 16:55:09 +01:00
|
|
|
@Override
|
|
|
|
public void onSetReminders(ArrayList<? extends Reminder> reminders) {
|
|
|
|
Intent intent = createIntent().setAction(ACTION_SET_REMINDERS)
|
|
|
|
.putExtra(EXTRA_REMINDERS, reminders);
|
|
|
|
invokeService(intent);
|
|
|
|
}
|
|
|
|
|
2023-07-04 00:19:19 +02:00
|
|
|
@Override
|
|
|
|
public void onSetLoyaltyCards(final ArrayList<LoyaltyCard> cards) {
|
|
|
|
final Intent intent = createIntent().setAction(ACTION_SET_LOYALTY_CARDS)
|
|
|
|
.putExtra(EXTRA_LOYALTY_CARDS, cards);
|
|
|
|
invokeService(intent);
|
|
|
|
}
|
|
|
|
|
2022-05-09 20:47:08 +02:00
|
|
|
@Override
|
|
|
|
public void onSetWorldClocks(ArrayList<? extends WorldClock> clocks) {
|
|
|
|
Intent intent = createIntent().setAction(ACTION_SET_WORLD_CLOCKS)
|
|
|
|
.putExtra(EXTRA_WORLD_CLOCKS, clocks);
|
|
|
|
invokeService(intent);
|
|
|
|
}
|
|
|
|
|
2023-05-18 00:43:29 +02:00
|
|
|
@Override
|
|
|
|
public void onSetContacts(ArrayList<? extends Contact> contacts) {
|
|
|
|
Intent intent = createIntent().setAction(ACTION_SET_CONTACTS)
|
|
|
|
.putExtra(EXTRA_CONTACTS, contacts);
|
|
|
|
invokeService(intent);
|
|
|
|
}
|
|
|
|
|
2015-08-21 00:58:18 +02:00
|
|
|
@Override
|
2016-04-04 20:08:34 +02:00
|
|
|
public void onSetMusicInfo(MusicSpec musicSpec) {
|
2015-08-21 00:58:18 +02:00
|
|
|
Intent intent = createIntent().setAction(ACTION_SETMUSICINFO)
|
2016-04-04 20:08:34 +02:00
|
|
|
.putExtra(EXTRA_MUSIC_ARTIST, musicSpec.artist)
|
|
|
|
.putExtra(EXTRA_MUSIC_ALBUM, musicSpec.album)
|
|
|
|
.putExtra(EXTRA_MUSIC_TRACK, musicSpec.track)
|
|
|
|
.putExtra(EXTRA_MUSIC_DURATION, musicSpec.duration)
|
|
|
|
.putExtra(EXTRA_MUSIC_TRACKCOUNT, musicSpec.trackCount)
|
|
|
|
.putExtra(EXTRA_MUSIC_TRACKNR, musicSpec.trackNr);
|
2015-08-21 00:58:18 +02:00
|
|
|
invokeService(intent);
|
2021-10-20 22:37:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onSetNavigationInfo(NavigationInfoSpec navigationInfoSpec) {
|
|
|
|
Intent intent = createIntent().setAction(ACTION_SETNAVIGATIONINFO)
|
|
|
|
.putExtra(EXTRA_NAVIGATION_INSTRUCTION, navigationInfoSpec.instruction)
|
|
|
|
.putExtra(EXTRA_NAVIGATION_NEXT_ACTION, navigationInfoSpec.nextAction)
|
2023-06-09 09:47:10 +02:00
|
|
|
.putExtra(EXTRA_NAVIGATION_DISTANCE_TO_TURN, navigationInfoSpec.distanceToTurn)
|
|
|
|
.putExtra(EXTRA_NAVIGATION_ETA, navigationInfoSpec.ETA);
|
2021-10-20 22:37:23 +02:00
|
|
|
invokeService(intent);
|
2015-08-21 00:58:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onInstallApp(Uri uri) {
|
|
|
|
Intent intent = createIntent().setAction(ACTION_INSTALL)
|
|
|
|
.putExtra(EXTRA_URI, uri);
|
|
|
|
invokeService(intent);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onAppInfoReq() {
|
|
|
|
Intent intent = createIntent().setAction(ACTION_REQUEST_APPINFO);
|
|
|
|
invokeService(intent);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-09-13 21:44:26 +02:00
|
|
|
public void onAppStart(UUID uuid, boolean start) {
|
2015-08-21 00:58:18 +02:00
|
|
|
Intent intent = createIntent().setAction(ACTION_STARTAPP)
|
2015-09-13 21:44:26 +02:00
|
|
|
.putExtra(EXTRA_APP_UUID, uuid)
|
|
|
|
.putExtra(EXTRA_APP_START, start);
|
2015-08-21 00:58:18 +02:00
|
|
|
invokeService(intent);
|
|
|
|
}
|
|
|
|
|
2023-01-04 22:40:38 +01:00
|
|
|
@Override
|
|
|
|
public void onAppDownload(UUID uuid) {
|
|
|
|
Intent intent = createIntent().setAction(ACTION_DOWNLOADAPP)
|
|
|
|
.putExtra(EXTRA_APP_UUID, uuid);
|
|
|
|
invokeService(intent);
|
|
|
|
}
|
|
|
|
|
2015-08-21 00:58:18 +02:00
|
|
|
@Override
|
|
|
|
public void onAppDelete(UUID uuid) {
|
|
|
|
Intent intent = createIntent().setAction(ACTION_DELETEAPP)
|
|
|
|
.putExtra(EXTRA_APP_UUID, uuid);
|
|
|
|
invokeService(intent);
|
|
|
|
}
|
|
|
|
|
2016-03-03 14:23:17 +01:00
|
|
|
@Override
|
2017-08-01 00:03:28 +02:00
|
|
|
public void onAppConfiguration(UUID uuid, String config, Integer id) {
|
2016-03-03 14:23:17 +01:00
|
|
|
Intent intent = createIntent().setAction(ACTION_APP_CONFIGURE)
|
|
|
|
.putExtra(EXTRA_APP_UUID, uuid)
|
|
|
|
.putExtra(EXTRA_APP_CONFIG, config);
|
2017-08-01 00:03:28 +02:00
|
|
|
|
|
|
|
if (id != null) {
|
|
|
|
intent.putExtra(EXTRA_APP_CONFIG_ID, id);
|
|
|
|
}
|
2016-03-03 14:23:17 +01:00
|
|
|
invokeService(intent);
|
|
|
|
}
|
|
|
|
|
2016-06-12 01:20:12 +02:00
|
|
|
@Override
|
|
|
|
public void onAppReorder(UUID[] uuids) {
|
|
|
|
Intent intent = createIntent().setAction(ACTION_APP_REORDER)
|
|
|
|
.putExtra(EXTRA_APP_UUID, uuids);
|
|
|
|
invokeService(intent);
|
|
|
|
}
|
|
|
|
|
2015-08-21 00:58:18 +02:00
|
|
|
@Override
|
2018-03-31 16:21:25 +02:00
|
|
|
public void onFetchRecordedData(int dataTypes) {
|
|
|
|
Intent intent = createIntent().setAction(ACTION_FETCH_RECORDED_DATA)
|
|
|
|
.putExtra(EXTRA_RECORDED_DATA_TYPES, dataTypes);
|
2015-08-21 00:58:18 +02:00
|
|
|
invokeService(intent);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2018-12-16 16:05:13 +01:00
|
|
|
public void onReset(int flags) {
|
|
|
|
Intent intent = createIntent().setAction(ACTION_RESET)
|
|
|
|
.putExtra(EXTRA_RESET_FLAGS, flags);
|
2015-08-21 00:58:18 +02:00
|
|
|
invokeService(intent);
|
|
|
|
}
|
|
|
|
|
2015-12-28 14:38:56 +01:00
|
|
|
@Override
|
2016-02-29 22:05:29 +01:00
|
|
|
public void onHeartRateTest() {
|
2015-12-28 14:38:56 +01:00
|
|
|
Intent intent = createIntent().setAction(ACTION_HEARTRATE_TEST);
|
|
|
|
invokeService(intent);
|
|
|
|
}
|
|
|
|
|
2015-08-21 00:58:18 +02:00
|
|
|
@Override
|
|
|
|
public void onFindDevice(boolean start) {
|
|
|
|
Intent intent = createIntent().setAction(ACTION_FIND_DEVICE)
|
2015-08-22 12:38:35 +02:00
|
|
|
.putExtra(EXTRA_FIND_START, start);
|
2015-08-21 00:58:18 +02:00
|
|
|
invokeService(intent);
|
|
|
|
}
|
|
|
|
|
2022-08-18 23:03:28 +02:00
|
|
|
@Override
|
2022-10-22 21:53:45 +02:00
|
|
|
public void onFindPhone(final boolean start) {
|
|
|
|
Intent intent = createIntent().setAction(ACTION_PHONE_FOUND)
|
|
|
|
.putExtra(EXTRA_FIND_START, start);
|
2022-08-18 23:03:28 +02:00
|
|
|
invokeService(intent);
|
|
|
|
}
|
|
|
|
|
2016-09-20 20:28:52 +02:00
|
|
|
@Override
|
|
|
|
public void onSetConstantVibration(int intensity) {
|
|
|
|
Intent intent = createIntent().setAction(ACTION_SET_CONSTANT_VIBRATION)
|
|
|
|
.putExtra(EXTRA_VIBRATION_INTENSITY, intensity);
|
|
|
|
invokeService(intent);
|
|
|
|
}
|
|
|
|
|
2015-08-21 00:58:18 +02:00
|
|
|
@Override
|
|
|
|
public void onScreenshotReq() {
|
|
|
|
Intent intent = createIntent().setAction(ACTION_REQUEST_SCREENSHOT);
|
|
|
|
invokeService(intent);
|
|
|
|
}
|
2015-09-02 08:00:26 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onEnableRealtimeSteps(boolean enable) {
|
|
|
|
Intent intent = createIntent().setAction(ACTION_ENABLE_REALTIME_STEPS)
|
2016-04-03 22:38:06 +02:00
|
|
|
.putExtra(EXTRA_BOOLEAN_ENABLE, enable);
|
|
|
|
invokeService(intent);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onEnableHeartRateSleepSupport(boolean enable) {
|
|
|
|
Intent intent = createIntent().setAction(ACTION_ENABLE_HEARTRATE_SLEEP_SUPPORT)
|
|
|
|
.putExtra(EXTRA_BOOLEAN_ENABLE, enable);
|
2015-09-02 08:00:26 +02:00
|
|
|
invokeService(intent);
|
|
|
|
}
|
2016-04-12 23:12:15 +02:00
|
|
|
|
2017-11-11 00:04:51 +01:00
|
|
|
@Override
|
|
|
|
public void onSetHeartRateMeasurementInterval(int seconds) {
|
|
|
|
Intent intent = createIntent().setAction(ACTION_SET_HEARTRATE_MEASUREMENT_INTERVAL)
|
|
|
|
.putExtra(EXTRA_INTERVAL_SECONDS, seconds);
|
|
|
|
invokeService(intent);
|
|
|
|
}
|
|
|
|
|
2016-04-12 23:12:15 +02:00
|
|
|
@Override
|
|
|
|
public void onEnableRealtimeHeartRateMeasurement(boolean enable) {
|
|
|
|
Intent intent = createIntent().setAction(ACTION_ENABLE_REALTIME_HEARTRATE_MEASUREMENT)
|
|
|
|
.putExtra(EXTRA_BOOLEAN_ENABLE, enable);
|
|
|
|
invokeService(intent);
|
|
|
|
}
|
2016-05-16 17:30:11 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onAddCalendarEvent(CalendarEventSpec calendarEventSpec) {
|
|
|
|
Intent intent = createIntent().setAction(ACTION_ADD_CALENDAREVENT)
|
|
|
|
.putExtra(EXTRA_CALENDAREVENT_ID, calendarEventSpec.id)
|
|
|
|
.putExtra(EXTRA_CALENDAREVENT_TYPE, calendarEventSpec.type)
|
|
|
|
.putExtra(EXTRA_CALENDAREVENT_TIMESTAMP, calendarEventSpec.timestamp)
|
|
|
|
.putExtra(EXTRA_CALENDAREVENT_DURATION, calendarEventSpec.durationInSeconds)
|
2022-08-21 15:58:12 +02:00
|
|
|
.putExtra(EXTRA_CALENDAREVENT_ALLDAY, calendarEventSpec.allDay)
|
2016-05-16 17:30:11 +02:00
|
|
|
.putExtra(EXTRA_CALENDAREVENT_TITLE, calendarEventSpec.title)
|
2017-04-21 10:50:10 +02:00
|
|
|
.putExtra(EXTRA_CALENDAREVENT_DESCRIPTION, calendarEventSpec.description)
|
2022-08-23 17:05:38 +02:00
|
|
|
.putExtra(EXTRA_CALENDAREVENT_CALNAME, calendarEventSpec.calName)
|
|
|
|
.putExtra(EXTRA_CALENDAREVENT_COLOR, calendarEventSpec.color)
|
2017-04-21 10:50:10 +02:00
|
|
|
.putExtra(EXTRA_CALENDAREVENT_LOCATION, calendarEventSpec.location);
|
2016-05-16 17:30:11 +02:00
|
|
|
invokeService(intent);
|
|
|
|
}
|
2016-05-16 23:37:40 +02:00
|
|
|
|
|
|
|
@Override
|
2016-05-24 13:11:57 +02:00
|
|
|
public void onDeleteCalendarEvent(byte type, long id) {
|
2016-05-16 23:37:40 +02:00
|
|
|
Intent intent = createIntent().setAction(ACTION_DELETE_CALENDAREVENT)
|
|
|
|
.putExtra(EXTRA_CALENDAREVENT_TYPE, type)
|
|
|
|
.putExtra(EXTRA_CALENDAREVENT_ID, id);
|
|
|
|
invokeService(intent);
|
|
|
|
}
|
2016-10-11 23:06:59 +02:00
|
|
|
|
2016-11-13 20:47:24 +01:00
|
|
|
@Override
|
|
|
|
public void onSendConfiguration(String config) {
|
|
|
|
Intent intent = createIntent().setAction(ACTION_SEND_CONFIGURATION)
|
|
|
|
.putExtra(EXTRA_CONFIG, config);
|
|
|
|
invokeService(intent);
|
|
|
|
}
|
|
|
|
|
2019-02-20 14:09:21 +01:00
|
|
|
@Override
|
|
|
|
public void onReadConfiguration(String config) {
|
|
|
|
Intent intent = createIntent().setAction(ACTION_READ_CONFIGURATION)
|
|
|
|
.putExtra(EXTRA_CONFIG, config);
|
|
|
|
invokeService(intent);
|
|
|
|
}
|
|
|
|
|
2016-10-11 23:06:59 +02:00
|
|
|
@Override
|
|
|
|
public void onTestNewFunction() {
|
|
|
|
Intent intent = createIntent().setAction(ACTION_TEST_NEW_FUNCTION);
|
|
|
|
invokeService(intent);
|
|
|
|
}
|
2016-12-31 15:56:05 +01:00
|
|
|
|
|
|
|
@Override
|
2024-03-29 22:10:40 +01:00
|
|
|
public void onSendWeather(ArrayList<WeatherSpec> weatherSpecs) {
|
2016-12-31 15:56:05 +01:00
|
|
|
Intent intent = createIntent().setAction(ACTION_SEND_WEATHER)
|
2024-03-29 22:10:40 +01:00
|
|
|
.putExtra(EXTRA_WEATHER, weatherSpecs);
|
2016-12-31 15:56:05 +01:00
|
|
|
invokeService(intent);
|
|
|
|
}
|
2017-01-27 21:16:19 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns contact DisplayName by call number
|
2017-03-14 21:37:16 +01:00
|
|
|
*
|
2017-01-27 21:16:19 +01:00
|
|
|
* @param number contact number
|
|
|
|
* @return contact DisplayName, if found it
|
|
|
|
*/
|
|
|
|
private String getContactDisplayNameByNumber(String number) {
|
2022-09-09 19:58:34 +02:00
|
|
|
Uri uri = Uri.withAppendedPath(ContactsContract.PhoneLookup.ENTERPRISE_CONTENT_FILTER_URI, Uri.encode(number));
|
|
|
|
|
2017-01-27 21:16:19 +01:00
|
|
|
String name = number;
|
|
|
|
|
|
|
|
if (number == null || number.equals("")) {
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
|
|
|
try (Cursor contactLookup = mContext.getContentResolver().query(uri, null, null, null, null)) {
|
|
|
|
if (contactLookup != null && contactLookup.getCount() > 0) {
|
|
|
|
contactLookup.moveToNext();
|
|
|
|
name = contactLookup.getString(contactLookup.getColumnIndex(ContactsContract.Data.DISPLAY_NAME));
|
|
|
|
}
|
|
|
|
} catch (SecurityException e) {
|
|
|
|
// ignore, just return name below
|
|
|
|
}
|
|
|
|
|
|
|
|
return name;
|
|
|
|
}
|
2018-07-28 17:23:58 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onSetFmFrequency(float frequency) {
|
|
|
|
Intent intent = createIntent().setAction(ACTION_SET_FM_FREQUENCY)
|
|
|
|
.putExtra(EXTRA_FM_FREQUENCY, frequency);
|
|
|
|
invokeService(intent);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onSetLedColor(int color) {
|
|
|
|
Intent intent = createIntent().setAction(ACTION_SET_LED_COLOR)
|
|
|
|
.putExtra(EXTRA_LED_COLOR, color);
|
|
|
|
invokeService(intent);
|
|
|
|
}
|
2021-12-24 15:20:57 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onPowerOff() {
|
|
|
|
Intent intent = createIntent().setAction(ACTION_POWER_OFF);
|
|
|
|
invokeService(intent);
|
|
|
|
}
|
2022-06-04 22:20:28 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onSetGpsLocation(Location location) {
|
|
|
|
Intent intent = createIntent().setAction(ACTION_SET_GPS_LOCATION);
|
|
|
|
intent.putExtra(EXTRA_GPS_LOCATION, location);
|
|
|
|
invokeService(intent);
|
|
|
|
}
|
2015-08-21 00:58:18 +02:00
|
|
|
}
|