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

Multi-device: fixed some build errors

This commit is contained in:
Daniel Dakhno 2021-12-25 22:06:19 +01:00
parent 96cd3e66e4
commit 86e5717be1
3 changed files with 41 additions and 52 deletions

View File

@ -142,8 +142,6 @@ public interface DeviceService extends EventHandler {
void connect(GBDevice device); void connect(GBDevice device);
void connect(GBDevice device, boolean performPair);
void connect(@Nullable GBDevice device, boolean firstTime); void connect(@Nullable GBDevice device, boolean firstTime);
void disconnect(); void disconnect();

View File

@ -375,7 +375,7 @@ public abstract class AbstractDeviceSupport implements DeviceSupport {
.setAutoCancel(true) .setAutoCancel(true)
.build(); .build();
GB.notify(NOTIFICATION_ID_SCREENSHOT, notif, context); GB.notify(NOTIFICATION_ID_SCREENSHOT, notification, context);
} catch (IOException ex) { } catch (IOException ex) {
LOG.error("Error writing screenshot", ex); LOG.error("Error writing screenshot", ex);
} }

View File

@ -365,6 +365,7 @@ public class DeviceCommunicationService extends Service implements SharedPrefere
intentGBDevice.sendDeviceUpdateIntent(this); intentGBDevice.sendDeviceUpdateIntent(this);
} }
break; break;
}
default: default:
if (mDeviceSupport == null || mGBDevice == null) { if (mDeviceSupport == null || mGBDevice == null) {
LOG.warn("device support:" + mDeviceSupport + ", device: " + mGBDevice + ", aborting"); LOG.warn("device support:" + mDeviceSupport + ", device: " + mGBDevice + ", aborting");
@ -409,7 +410,6 @@ public class DeviceCommunicationService extends Service implements SharedPrefere
case ACTION_REQUEST_DEVICEINFO: case ACTION_REQUEST_DEVICEINFO:
mGBDevice.sendDeviceUpdateIntent(this); mGBDevice.sendDeviceUpdateIntent(this);
break; break;
}
case ACTION_NOTIFICATION: { case ACTION_NOTIFICATION: {
int desiredId = intent.getIntExtra(EXTRA_NOTIFICATION_ID, -1); int desiredId = intent.getIntExtra(EXTRA_NOTIFICATION_ID, -1);
NotificationSpec notificationSpec = new NotificationSpec(desiredId); NotificationSpec notificationSpec = new NotificationSpec(desiredId);
@ -436,7 +436,7 @@ public class DeviceCommunicationService extends Service implements SharedPrefere
|| (notificationSpec.type == NotificationType.GENERIC_SMS && notificationSpec.phoneNumber != null)) { || (notificationSpec.type == NotificationType.GENERIC_SMS && notificationSpec.phoneNumber != null)) {
// NOTE: maybe not where it belongs // NOTE: maybe not where it belongs
// I would rather like to save that as an array in SharedPreferences // I would rather like to save that as an array in SharedPreferences
// this would work but I don't know how to do the same in the Settings Activity's xml // this would work but I dont know how to do the same in the Settings Activity's xml
ArrayList<String> replies = new ArrayList<>(); ArrayList<String> replies = new ArrayList<>();
for (int i = 1; i <= 16; i++) { for (int i = 1; i <= 16; i++) {
String reply = devicePrefs.getString("canned_reply_" + i, null); String reply = devicePrefs.getString("canned_reply_" + i, null);
@ -447,11 +447,11 @@ public class DeviceCommunicationService extends Service implements SharedPrefere
notificationSpec.cannedReplies = replies.toArray(new String[0]); notificationSpec.cannedReplies = replies.toArray(new String[0]);
} }
intentGBDeviceContainer.getDeviceSupport().onNotification(notificationSpec); mDeviceSupport.onNotification(notificationSpec);
break; break;
} }
case ACTION_DELETE_NOTIFICATION: { case ACTION_DELETE_NOTIFICATION: {
intentGBDeviceContainer.getDeviceSupport().onDeleteNotification(intent.getIntExtra(EXTRA_NOTIFICATION_ID, -1)); mDeviceSupport.onDeleteNotification(intent.getIntExtra(EXTRA_NOTIFICATION_ID, -1));
break; break;
} }
case ACTION_ADD_CALENDAREVENT: { case ACTION_ADD_CALENDAREVENT: {
@ -463,27 +463,27 @@ public class DeviceCommunicationService extends Service implements SharedPrefere
calendarEventSpec.title = sanitizeNotifText(intent.getStringExtra(EXTRA_CALENDAREVENT_TITLE)); calendarEventSpec.title = sanitizeNotifText(intent.getStringExtra(EXTRA_CALENDAREVENT_TITLE));
calendarEventSpec.description = sanitizeNotifText(intent.getStringExtra(EXTRA_CALENDAREVENT_DESCRIPTION)); calendarEventSpec.description = sanitizeNotifText(intent.getStringExtra(EXTRA_CALENDAREVENT_DESCRIPTION));
calendarEventSpec.location = sanitizeNotifText(intent.getStringExtra(EXTRA_CALENDAREVENT_LOCATION)); calendarEventSpec.location = sanitizeNotifText(intent.getStringExtra(EXTRA_CALENDAREVENT_LOCATION));
intentGBDeviceContainer.getDeviceSupport().onAddCalendarEvent(calendarEventSpec); mDeviceSupport.onAddCalendarEvent(calendarEventSpec);
break; break;
} }
case ACTION_DELETE_CALENDAREVENT: { case ACTION_DELETE_CALENDAREVENT: {
long id = intent.getLongExtra(EXTRA_CALENDAREVENT_ID, -1); long id = intent.getLongExtra(EXTRA_CALENDAREVENT_ID, -1);
byte type = intent.getByteExtra(EXTRA_CALENDAREVENT_TYPE, (byte) -1); byte type = intent.getByteExtra(EXTRA_CALENDAREVENT_TYPE, (byte) -1);
intentGBDeviceContainer.getDeviceSupport().onDeleteCalendarEvent(type, id); mDeviceSupport.onDeleteCalendarEvent(type, id);
break; break;
} }
case ACTION_RESET: { case ACTION_RESET: {
int flags = intent.getIntExtra(EXTRA_RESET_FLAGS, 0); int flags = intent.getIntExtra(EXTRA_RESET_FLAGS, 0);
intentGBDeviceContainer.getDeviceSupport().onReset(flags); mDeviceSupport.onReset(flags);
break; break;
} }
case ACTION_HEARTRATE_TEST: { case ACTION_HEARTRATE_TEST: {
intentGBDeviceContainer.getDeviceSupport().onHeartRateTest(); mDeviceSupport.onHeartRateTest();
break; break;
} }
case ACTION_FETCH_RECORDED_DATA: { case ACTION_FETCH_RECORDED_DATA: {
int dataTypes = intent.getIntExtra(EXTRA_RECORDED_DATA_TYPES, 0); int dataTypes = intent.getIntExtra(EXTRA_RECORDED_DATA_TYPES, 0);
intentGBDeviceContainer.getDeviceSupport().onFetchRecordedData(dataTypes); mDeviceSupport.onFetchRecordedData(dataTypes);
break; break;
} }
case ACTION_DISCONNECT: { case ACTION_DISCONNECT: {
@ -500,37 +500,34 @@ public class DeviceCommunicationService extends Service implements SharedPrefere
} }
case ACTION_FIND_DEVICE: { case ACTION_FIND_DEVICE: {
boolean start = intent.getBooleanExtra(EXTRA_FIND_START, false); boolean start = intent.getBooleanExtra(EXTRA_FIND_START, false);
intentGBDeviceContainer.getDeviceSupport().onFindDevice(start); mDeviceSupport.onFindDevice(start);
break; break;
} }
case ACTION_SET_CONSTANT_VIBRATION: { case ACTION_SET_CONSTANT_VIBRATION: {
int intensity = intent.getIntExtra(EXTRA_VIBRATION_INTENSITY, 0); int intensity = intent.getIntExtra(EXTRA_VIBRATION_INTENSITY, 0);
intentGBDeviceContainer.getDeviceSupport().onSetConstantVibration(intensity); mDeviceSupport.onSetConstantVibration(intensity);
break; break;
} }
case ACTION_CALLSTATE: { case ACTION_CALLSTATE:
CallSpec callSpec = new CallSpec(); CallSpec callSpec = new CallSpec();
callSpec.command = intent.getIntExtra(EXTRA_CALL_COMMAND, CallSpec.CALL_UNDEFINED); callSpec.command = intent.getIntExtra(EXTRA_CALL_COMMAND, CallSpec.CALL_UNDEFINED);
callSpec.number = intent.getStringExtra(EXTRA_CALL_PHONENUMBER); callSpec.number = intent.getStringExtra(EXTRA_CALL_PHONENUMBER);
callSpec.name = sanitizeNotifText(intent.getStringExtra(EXTRA_CALL_DISPLAYNAME)); callSpec.name = sanitizeNotifText(intent.getStringExtra(EXTRA_CALL_DISPLAYNAME));
intentGBDeviceContainer.getDeviceSupport().onSetCallState(callSpec); mDeviceSupport.onSetCallState(callSpec);
break; break;
} case ACTION_SETCANNEDMESSAGES:
case ACTION_SETCANNEDMESSAGES: {
int type = intent.getIntExtra(EXTRA_CANNEDMESSAGES_TYPE, -1); int type = intent.getIntExtra(EXTRA_CANNEDMESSAGES_TYPE, -1);
String[] cannedMessages = intent.getStringArrayExtra(EXTRA_CANNEDMESSAGES); String[] cannedMessages = intent.getStringArrayExtra(EXTRA_CANNEDMESSAGES);
CannedMessagesSpec cannedMessagesSpec = new CannedMessagesSpec(); CannedMessagesSpec cannedMessagesSpec = new CannedMessagesSpec();
cannedMessagesSpec.type = type; cannedMessagesSpec.type = type;
cannedMessagesSpec.cannedMessages = cannedMessages; cannedMessagesSpec.cannedMessages = cannedMessages;
intentGBDeviceContainer.getDeviceSupport().onSetCannedMessages(cannedMessagesSpec); mDeviceSupport.onSetCannedMessages(cannedMessagesSpec);
break; break;
} case ACTION_SETTIME:
case ACTION_SETTIME: { mDeviceSupport.onSetTime();
intentGBDeviceContainer.getDeviceSupport().onSetTime();
break; break;
} case ACTION_SETMUSICINFO:
case ACTION_SETMUSICINFO: {
MusicSpec musicSpec = new MusicSpec(); MusicSpec musicSpec = new MusicSpec();
musicSpec.artist = sanitizeNotifText(intent.getStringExtra(EXTRA_MUSIC_ARTIST)); musicSpec.artist = sanitizeNotifText(intent.getStringExtra(EXTRA_MUSIC_ARTIST));
musicSpec.album = sanitizeNotifText(intent.getStringExtra(EXTRA_MUSIC_ALBUM)); musicSpec.album = sanitizeNotifText(intent.getStringExtra(EXTRA_MUSIC_ALBUM));
@ -538,36 +535,32 @@ public class DeviceCommunicationService extends Service implements SharedPrefere
musicSpec.duration = intent.getIntExtra(EXTRA_MUSIC_DURATION, 0); musicSpec.duration = intent.getIntExtra(EXTRA_MUSIC_DURATION, 0);
musicSpec.trackCount = intent.getIntExtra(EXTRA_MUSIC_TRACKCOUNT, 0); musicSpec.trackCount = intent.getIntExtra(EXTRA_MUSIC_TRACKCOUNT, 0);
musicSpec.trackNr = intent.getIntExtra(EXTRA_MUSIC_TRACKNR, 0); musicSpec.trackNr = intent.getIntExtra(EXTRA_MUSIC_TRACKNR, 0);
intentGBDeviceContainer.getDeviceSupport().onSetMusicInfo(musicSpec); mDeviceSupport.onSetMusicInfo(musicSpec);
break; break;
} case ACTION_SETMUSICSTATE:
case ACTION_SETMUSICSTATE: {
MusicStateSpec stateSpec = new MusicStateSpec(); MusicStateSpec stateSpec = new MusicStateSpec();
stateSpec.shuffle = intent.getByteExtra(EXTRA_MUSIC_SHUFFLE, (byte) 0); stateSpec.shuffle = intent.getByteExtra(EXTRA_MUSIC_SHUFFLE, (byte) 0);
stateSpec.repeat = intent.getByteExtra(EXTRA_MUSIC_REPEAT, (byte) 0); stateSpec.repeat = intent.getByteExtra(EXTRA_MUSIC_REPEAT, (byte) 0);
stateSpec.position = intent.getIntExtra(EXTRA_MUSIC_POSITION, 0); stateSpec.position = intent.getIntExtra(EXTRA_MUSIC_POSITION, 0);
stateSpec.playRate = intent.getIntExtra(EXTRA_MUSIC_RATE, 0); stateSpec.playRate = intent.getIntExtra(EXTRA_MUSIC_RATE, 0);
stateSpec.state = intent.getByteExtra(EXTRA_MUSIC_STATE, (byte) 0); stateSpec.state = intent.getByteExtra(EXTRA_MUSIC_STATE, (byte) 0);
intentGBDeviceContainer.getDeviceSupport().onSetMusicState(stateSpec); mDeviceSupport.onSetMusicState(stateSpec);
break; break;
} case ACTION_REQUEST_APPINFO:
case ACTION_REQUEST_APPINFO: { mDeviceSupport.onAppInfoReq();
intentGBDeviceContainer.getDeviceSupport().onAppInfoReq();
break; break;
} case ACTION_REQUEST_SCREENSHOT:
case ACTION_REQUEST_SCREENSHOT: { mDeviceSupport.onScreenshotReq();
intentGBDeviceContainer.getDeviceSupport().onScreenshotReq();
break; break;
}
case ACTION_STARTAPP: { case ACTION_STARTAPP: {
UUID uuid = (UUID) intent.getSerializableExtra(EXTRA_APP_UUID); UUID uuid = (UUID) intent.getSerializableExtra(EXTRA_APP_UUID);
boolean start = intent.getBooleanExtra(EXTRA_APP_START, true); boolean start = intent.getBooleanExtra(EXTRA_APP_START, true);
intentGBDeviceContainer.getDeviceSupport().onAppStart(uuid, start); mDeviceSupport.onAppStart(uuid, start);
break; break;
} }
case ACTION_DELETEAPP: { case ACTION_DELETEAPP: {
UUID uuid = (UUID) intent.getSerializableExtra(EXTRA_APP_UUID); UUID uuid = (UUID) intent.getSerializableExtra(EXTRA_APP_UUID);
intentGBDeviceContainer.getDeviceSupport().onAppDelete(uuid); mDeviceSupport.onAppDelete(uuid);
break; break;
} }
case ACTION_APP_CONFIGURE: { case ACTION_APP_CONFIGURE: {
@ -577,54 +570,52 @@ public class DeviceCommunicationService extends Service implements SharedPrefere
if (intent.hasExtra(EXTRA_APP_CONFIG_ID)) { if (intent.hasExtra(EXTRA_APP_CONFIG_ID)) {
id = intent.getIntExtra(EXTRA_APP_CONFIG_ID, 0); id = intent.getIntExtra(EXTRA_APP_CONFIG_ID, 0);
} }
intentGBDeviceContainer.getDeviceSupport().onAppConfiguration(uuid, config, id); mDeviceSupport.onAppConfiguration(uuid, config, id);
break; break;
} }
case ACTION_APP_REORDER: { case ACTION_APP_REORDER: {
UUID[] uuids = (UUID[]) intent.getSerializableExtra(EXTRA_APP_UUID); UUID[] uuids = (UUID[]) intent.getSerializableExtra(EXTRA_APP_UUID);
intentGBDeviceContainer.getDeviceSupport().onAppReorder(uuids); mDeviceSupport.onAppReorder(uuids);
break; break;
} }
case ACTION_INSTALL: { case ACTION_INSTALL:
Uri uri = intent.getParcelableExtra(EXTRA_URI); Uri uri = intent.getParcelableExtra(EXTRA_URI);
if (uri != null) { if (uri != null) {
LOG.info("will try to install app/fw"); LOG.info("will try to install app/fw");
intentGBDeviceContainer.getDeviceSupport().onInstallApp(uri); mDeviceSupport.onInstallApp(uri);
} }
break; break;
} case ACTION_SET_ALARMS:
case ACTION_SET_ALARMS: {
ArrayList<? extends Alarm> alarms = (ArrayList<? extends Alarm>) intent.getSerializableExtra(EXTRA_ALARMS); ArrayList<? extends Alarm> alarms = (ArrayList<? extends Alarm>) intent.getSerializableExtra(EXTRA_ALARMS);
intentGBDeviceContainer.getDeviceSupport().onSetAlarms(alarms); mDeviceSupport.onSetAlarms(alarms);
break; break;
case ACTION_SET_REMINDERS: case ACTION_SET_REMINDERS:
ArrayList<? extends Reminder> reminders = (ArrayList<? extends Reminder>) intent.getSerializableExtra(EXTRA_REMINDERS); ArrayList<? extends Reminder> reminders = (ArrayList<? extends Reminder>) intent.getSerializableExtra(EXTRA_REMINDERS);
mDeviceSupport.onSetReminders(reminders); mDeviceSupport.onSetReminders(reminders);
break; break;
}
case ACTION_ENABLE_REALTIME_STEPS: { case ACTION_ENABLE_REALTIME_STEPS: {
boolean enable = intent.getBooleanExtra(EXTRA_BOOLEAN_ENABLE, false); boolean enable = intent.getBooleanExtra(EXTRA_BOOLEAN_ENABLE, false);
intentGBDeviceContainer.getDeviceSupport().onEnableRealtimeSteps(enable); mDeviceSupport.onEnableRealtimeSteps(enable);
break; break;
} }
case ACTION_ENABLE_HEARTRATE_SLEEP_SUPPORT: { case ACTION_ENABLE_HEARTRATE_SLEEP_SUPPORT: {
boolean enable = intent.getBooleanExtra(EXTRA_BOOLEAN_ENABLE, false); boolean enable = intent.getBooleanExtra(EXTRA_BOOLEAN_ENABLE, false);
intentGBDeviceContainer.getDeviceSupport().onEnableHeartRateSleepSupport(enable); mDeviceSupport.onEnableHeartRateSleepSupport(enable);
break; break;
} }
case ACTION_SET_HEARTRATE_MEASUREMENT_INTERVAL: { case ACTION_SET_HEARTRATE_MEASUREMENT_INTERVAL: {
int seconds = intent.getIntExtra(EXTRA_INTERVAL_SECONDS, 0); int seconds = intent.getIntExtra(EXTRA_INTERVAL_SECONDS, 0);
intentGBDeviceContainer.getDeviceSupport().onSetHeartRateMeasurementInterval(seconds); mDeviceSupport.onSetHeartRateMeasurementInterval(seconds);
break; break;
} }
case ACTION_ENABLE_REALTIME_HEARTRATE_MEASUREMENT: { case ACTION_ENABLE_REALTIME_HEARTRATE_MEASUREMENT: {
boolean enable = intent.getBooleanExtra(EXTRA_BOOLEAN_ENABLE, false); boolean enable = intent.getBooleanExtra(EXTRA_BOOLEAN_ENABLE, false);
intentGBDeviceContainer.getDeviceSupport().onEnableRealtimeHeartRateMeasurement(enable); mDeviceSupport.onEnableRealtimeHeartRateMeasurement(enable);
break; break;
} }
case ACTION_SEND_CONFIGURATION: { case ACTION_SEND_CONFIGURATION: {
String config = intent.getStringExtra(EXTRA_CONFIG); String config = intent.getStringExtra(EXTRA_CONFIG);
intentGBDeviceContainer.getDeviceSupport().onSendConfiguration(config); mDeviceSupport.onSendConfiguration(config);
break; break;
} }
case ACTION_READ_CONFIGURATION: { case ACTION_READ_CONFIGURATION: {
@ -633,13 +624,13 @@ public class DeviceCommunicationService extends Service implements SharedPrefere
break; break;
} }
case ACTION_TEST_NEW_FUNCTION: { case ACTION_TEST_NEW_FUNCTION: {
intentGBDeviceContainer.getDeviceSupport().onTestNewFunction(); mDeviceSupport.onTestNewFunction();
break; break;
} }
case ACTION_SEND_WEATHER: { case ACTION_SEND_WEATHER: {
WeatherSpec weatherSpec = intent.getParcelableExtra(EXTRA_WEATHER); WeatherSpec weatherSpec = intent.getParcelableExtra(EXTRA_WEATHER);
if (weatherSpec != null) { if (weatherSpec != null) {
intentGBDeviceContainer.getDeviceSupport().onSendWeather(weatherSpec); mDeviceSupport.onSendWeather(weatherSpec);
} }
break; break;
} }