use of nodomain.freeyourgadget.gadgetbridge.model.NotificationSpec in project Gadgetbridge by Freeyourgadget.
the class NotificationListener method onNotificationPosted.
@Override
public void onNotificationPosted(StatusBarNotification sbn, RankingMap rankingMap) {
logNotification(sbn, true);
LOG.debug("notificationAppListIsBlackList: " + GBApplication.getPrefs().getString("notification_list_is_blacklist", "true"));
notificationStack.remove(sbn.getPackageName());
notificationStack.add(sbn.getPackageName());
if (isServiceNotRunningAndShouldIgnoreNotifications())
return;
if (shouldIgnoreSource(sbn)) {
LOG.debug("Ignoring notification source");
return;
}
if (handleMediaSessionNotification(sbn))
return;
int dndSuppressed = 0;
if (GBApplication.isRunningLollipopOrLater() && rankingMap != null) {
// Handle priority notifications for Do Not Disturb
Ranking ranking = new Ranking();
if (rankingMap.getRanking(sbn.getKey(), ranking)) {
if (!ranking.matchesInterruptionFilter())
dndSuppressed = 1;
}
}
Prefs prefs = GBApplication.getPrefs();
if (GBApplication.isRunningLollipopOrLater()) {
if (prefs.getBoolean("notification_filter", false) && dndSuppressed == 1) {
return;
}
if (NotificationCompat.CATEGORY_CALL.equals(sbn.getNotification().category) && prefs.getBoolean("notification_support_voip_calls", false) && sbn.isOngoing()) {
handleCallNotification(sbn);
return;
}
}
if (shouldIgnoreNotification(sbn, false)) {
if (!"com.sec.android.app.clockpackage".equals(sbn.getPackageName())) {
// workaround to allow phone alarm notification
// need to fix
LOG.info("Ignore notification: " + sbn.getPackageName());
return;
}
}
String source = sbn.getPackageName();
Notification notification = sbn.getNotification();
Long notificationOldRepeatPreventionValue = notificationOldRepeatPrevention.get(source);
if (notificationOldRepeatPreventionValue != null && notification.when <= notificationOldRepeatPreventionValue && !shouldIgnoreRepeatPrevention(sbn)) {
LOG.info("NOT processing notification, already sent newer notifications from this source.");
return;
}
// Ignore too frequent notifications, according to user preference
long curTime = System.nanoTime();
Long notificationBurstPreventionValue = notificationBurstPrevention.get(source);
if (notificationBurstPreventionValue != null) {
long diff = curTime - notificationBurstPreventionValue;
if (diff < TimeUnit.SECONDS.toNanos(prefs.getInt("notifications_timeout", 0))) {
LOG.info("Ignoring frequent notification, last one was " + TimeUnit.NANOSECONDS.toMillis(diff) + "ms ago");
return;
}
}
NotificationSpec notificationSpec = new NotificationSpec();
// determinate Source App Name ("Label")
String name = getAppName(source);
if (name != null) {
notificationSpec.sourceName = name;
}
boolean preferBigText = false;
// Get the app ID that generated this notification. For now only used by pebble color, but may be more useful later.
notificationSpec.sourceAppId = source;
// Get the icon of the notification
notificationSpec.iconId = notification.icon;
notificationSpec.type = AppNotificationType.getInstance().get(source);
// FIXME: some quirks lookup table would be the minor evil here
if (source.startsWith("com.fsck.k9")) {
if (NotificationCompat.isGroupSummary(notification)) {
LOG.info("ignore K9 group summary");
return;
}
preferBigText = true;
}
if (notificationSpec.type == null) {
notificationSpec.type = NotificationType.UNKNOWN;
}
// Get color
notificationSpec.pebbleColor = getPebbleColorForNotification(notificationSpec);
LOG.info("Processing notification " + notificationSpec.getId() + " age: " + (System.currentTimeMillis() - notification.when) + " from source " + source + " with flags: " + notification.flags);
dissectNotificationTo(notification, notificationSpec, preferBigText);
if (notificationSpec.body != null) {
if (!checkNotificationContentForWhiteAndBlackList(sbn.getPackageName().toLowerCase(), notificationSpec.body)) {
return;
}
}
// ignore Gadgetbridge's very own notifications, except for those from the debug screen
if (getApplicationContext().getPackageName().equals(source)) {
if (!getApplicationContext().getString(R.string.test_notification).equals(notificationSpec.title)) {
return;
}
}
NotificationCompat.WearableExtender wearableExtender = new NotificationCompat.WearableExtender(notification);
List<NotificationCompat.Action> actions = wearableExtender.getActions();
if (actions.isEmpty() && NotificationCompat.isGroupSummary(notification) && !GROUP_SUMMARY_WHITELIST.contains(source)) {
// this could cause #395 to come back
LOG.info("Not forwarding notification, FLAG_GROUP_SUMMARY is set and no wearable action present. Notification flags: " + notification.flags);
return;
}
notificationSpec.attachedActions = new ArrayList<>();
notificationSpec.dndSuppressed = dndSuppressed;
// DISMISS action
NotificationSpec.Action dismissAction = new NotificationSpec.Action();
dismissAction.title = "Dismiss";
dismissAction.type = NotificationSpec.Action.TYPE_SYNTECTIC_DISMISS;
notificationSpec.attachedActions.add(dismissAction);
for (NotificationCompat.Action act : actions) {
if (act != null) {
NotificationSpec.Action wearableAction = new NotificationSpec.Action();
wearableAction.title = act.getTitle().toString();
if (act.getRemoteInputs() != null) {
wearableAction.type = NotificationSpec.Action.TYPE_WEARABLE_REPLY;
} else {
wearableAction.type = NotificationSpec.Action.TYPE_WEARABLE_SIMPLE;
}
notificationSpec.attachedActions.add(wearableAction);
mActionLookup.add((notificationSpec.getId() << 4) + notificationSpec.attachedActions.size(), act);
LOG.info("found wearable action: " + notificationSpec.attachedActions.size() + " - " + act.getTitle() + " " + sbn.getTag());
}
}
// OPEN action
NotificationSpec.Action openAction = new NotificationSpec.Action();
openAction.title = getString(R.string._pebble_watch_open_on_phone);
openAction.type = NotificationSpec.Action.TYPE_SYNTECTIC_OPEN;
notificationSpec.attachedActions.add(openAction);
// MUTE action
NotificationSpec.Action muteAction = new NotificationSpec.Action();
muteAction.title = getString(R.string._pebble_watch_mute);
muteAction.type = NotificationSpec.Action.TYPE_SYNTECTIC_MUTE;
notificationSpec.attachedActions.add(muteAction);
// for both DISMISS and OPEN
mNotificationHandleLookup.add(notificationSpec.getId(), sbn.getPostTime());
// for MUTE
mPackageLookup.add(notificationSpec.getId(), sbn.getPackageName());
notificationBurstPrevention.put(source, curTime);
if (0 != notification.when) {
notificationOldRepeatPrevention.put(source, notification.when);
} else {
LOG.info("This app might show old/duplicate notifications. notification.when is 0 for " + source);
}
notificationsActive.add(notificationSpec.getId());
// NOTE for future developers: this call goes to implementations of DeviceService.onNotification(NotificationSpec), like in GBDeviceService
// this does NOT directly go to implementations of DeviceSupport.onNotification(NotificationSpec)!
GBApplication.deviceService().onNotification(notificationSpec);
}
use of nodomain.freeyourgadget.gadgetbridge.model.NotificationSpec in project Gadgetbridge by Freeyourgadget.
the class AlarmClockReceiver method sendAlarm.
private synchronized void sendAlarm(boolean on) {
dismissLastAlarm();
if (on) {
NotificationSpec notificationSpec = new NotificationSpec();
// TODO: can we attach a dismiss action to the notification and not use the notification ID explicitly?
lastId = notificationSpec.getId();
notificationSpec.type = NotificationType.GENERIC_ALARM_CLOCK;
notificationSpec.sourceName = "ALARMCLOCKRECEIVER";
notificationSpec.attachedActions = new ArrayList<>();
// DISMISS ALL action
NotificationSpec.Action dismissAllAction = new NotificationSpec.Action();
dismissAllAction.title = "Dismiss All";
dismissAllAction.type = NotificationSpec.Action.TYPE_SYNTECTIC_DISMISS_ALL;
notificationSpec.attachedActions.add(dismissAllAction);
// can we get the alarm title somehow?
GBApplication.deviceService().onNotification(notificationSpec);
}
}
use of nodomain.freeyourgadget.gadgetbridge.model.NotificationSpec in project Gadgetbridge by Freeyourgadget.
the class NotificationListener method onNotificationPosted.
@Override
public void onNotificationPosted(StatusBarNotification sbn) {
/*
* return early if DeviceCommunicationService is not running,
* else the service would get started every time we get a notification.
* unfortunately we cannot enable/disable NotificationListener at runtime like we do with
* broadcast receivers because it seems to invalidate the permissions that are
* necessary for NotificationListenerService
*/
if (!isServiceRunning()) {
return;
}
switch(GBApplication.getGrantedInterruptionFilter()) {
case NotificationManager.INTERRUPTION_FILTER_ALL:
break;
case NotificationManager.INTERRUPTION_FILTER_ALARMS:
case NotificationManager.INTERRUPTION_FILTER_NONE:
return;
case NotificationManager.INTERRUPTION_FILTER_PRIORITY:
// FIXME: Handle Reminders and Events if they are enabled in Do Not Disturb
return;
}
String source = sbn.getPackageName();
Notification notification = sbn.getNotification();
if (handleMediaSessionNotification(notification))
return;
Prefs prefs = GBApplication.getPrefs();
if (!prefs.getBoolean("notifications_generic_whenscreenon", false)) {
PowerManager powermanager = (PowerManager) getSystemService(POWER_SERVICE);
if (powermanager.isScreenOn()) {
// LOG.info("Not forwarding notification, screen seems to be on and settings do not allow this");
return;
}
}
if ((notification.flags & Notification.FLAG_ONGOING_EVENT) == Notification.FLAG_ONGOING_EVENT) {
// LOG.info("Not forwarding notification, FLAG_ONGOING_EVENT is set. Notification flags: " + notification.flags);
return;
}
if (source.equals("android") || source.equals("com.android.systemui") || source.equals("com.android.dialer") || source.equals("com.cyanogenmod.eleven")) {
LOG.info("Not forwarding notification, is a system event");
return;
}
if (source.equals("com.moez.QKSMS") || source.equals("com.android.mms") || source.equals("com.sonyericsson.conversations") || source.equals("com.android.messaging") || source.equals("org.smssecure.smssecure")) {
if (!"never".equals(prefs.getString("notification_mode_sms", "when_screen_off"))) {
return;
}
}
if (GBApplication.blacklist != null && GBApplication.blacklist.contains(source)) {
LOG.info("Not forwarding notification, application is blacklisted");
return;
}
NotificationSpec notificationSpec = new NotificationSpec();
// determinate Source App Name ("Label")
PackageManager pm = getPackageManager();
ApplicationInfo ai = null;
try {
ai = pm.getApplicationInfo(source, 0);
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
if (ai != null) {
notificationSpec.sourceName = (String) pm.getApplicationLabel(ai);
}
boolean preferBigText = false;
notificationSpec.type = AppNotificationType.getInstance().get(source);
if (source.startsWith("com.fsck.k9")) {
// we dont want group summaries at all for k9
if ((notification.flags & Notification.FLAG_GROUP_SUMMARY) == Notification.FLAG_GROUP_SUMMARY) {
return;
}
preferBigText = true;
}
if (notificationSpec.type == null) {
notificationSpec.type = NotificationType.UNKNOWN;
}
LOG.info("Processing notification from source " + source + " with flags: " + notification.flags);
dissectNotificationTo(notification, notificationSpec, preferBigText);
//FIMXE: a truly unique id would be better
notificationSpec.id = (int) sbn.getPostTime();
// ignore Gadgetbridge's very own notifications, except for those from the debug screen
if (getApplicationContext().getPackageName().equals(source)) {
if (!getApplicationContext().getString(R.string.test_notification).equals(notificationSpec.title)) {
return;
}
}
NotificationCompat.WearableExtender wearableExtender = new NotificationCompat.WearableExtender(notification);
List<NotificationCompat.Action> actions = wearableExtender.getActions();
if (actions.isEmpty() && (notification.flags & Notification.FLAG_GROUP_SUMMARY) == Notification.FLAG_GROUP_SUMMARY) {
//this could cause #395 to come back
LOG.info("Not forwarding notification, FLAG_GROUP_SUMMARY is set and no wearable action present. Notification flags: " + notification.flags);
return;
}
for (NotificationCompat.Action act : actions) {
if (act != null && act.getRemoteInputs() != null) {
LOG.info("found wearable action: " + act.getTitle() + " " + sbn.getTag());
mActionLookup.add(notificationSpec.id, act);
notificationSpec.flags |= NotificationSpec.FLAG_WEARABLE_REPLY;
break;
}
}
GBApplication.deviceService().onNotification(notificationSpec);
}
use of nodomain.freeyourgadget.gadgetbridge.model.NotificationSpec in project Gadgetbridge by Freeyourgadget.
the class MiBandPreferencesActivity method tryVibration.
private void tryVibration(NotificationType type) {
NotificationSpec spec = new NotificationSpec();
spec.type = type;
GBApplication.deviceService().onNotification(spec);
}
use of nodomain.freeyourgadget.gadgetbridge.model.NotificationSpec in project Gadgetbridge by Freeyourgadget.
the class DeviceCommunicationService method handleAction.
private void handleAction(Intent intent, String action, Prefs prefs) {
Prefs devicePrefs = new Prefs(GBApplication.getDeviceSpecificSharedPrefs(mGBDevice.getAddress()));
boolean transliterate = devicePrefs.getBoolean(PREF_TRANSLITERATION_ENABLED, false);
if (transliterate) {
for (String extra : GBDeviceService.transliterationExtras) {
if (intent.hasExtra(extra)) {
intent.putExtra(extra, LanguageUtils.transliterate(intent.getStringExtra(extra)));
}
}
}
switch(action) {
case ACTION_REQUEST_DEVICEINFO:
mGBDevice.sendDeviceUpdateIntent(this);
break;
case ACTION_NOTIFICATION:
{
int desiredId = intent.getIntExtra(EXTRA_NOTIFICATION_ID, -1);
NotificationSpec notificationSpec = new NotificationSpec(desiredId);
notificationSpec.phoneNumber = intent.getStringExtra(EXTRA_NOTIFICATION_PHONENUMBER);
notificationSpec.sender = sanitizeNotifText(intent.getStringExtra(EXTRA_NOTIFICATION_SENDER));
notificationSpec.subject = sanitizeNotifText(intent.getStringExtra(EXTRA_NOTIFICATION_SUBJECT));
notificationSpec.title = sanitizeNotifText(intent.getStringExtra(EXTRA_NOTIFICATION_TITLE));
notificationSpec.body = sanitizeNotifText(intent.getStringExtra(EXTRA_NOTIFICATION_BODY));
notificationSpec.sourceName = intent.getStringExtra(EXTRA_NOTIFICATION_SOURCENAME);
notificationSpec.type = (NotificationType) intent.getSerializableExtra(EXTRA_NOTIFICATION_TYPE);
notificationSpec.attachedActions = (ArrayList<NotificationSpec.Action>) intent.getSerializableExtra(EXTRA_NOTIFICATION_ACTIONS);
notificationSpec.pebbleColor = (byte) intent.getSerializableExtra(EXTRA_NOTIFICATION_PEBBLE_COLOR);
notificationSpec.flags = intent.getIntExtra(EXTRA_NOTIFICATION_FLAGS, 0);
notificationSpec.sourceAppId = intent.getStringExtra(EXTRA_NOTIFICATION_SOURCEAPPID);
notificationSpec.iconId = intent.getIntExtra(EXTRA_NOTIFICATION_ICONID, 0);
notificationSpec.dndSuppressed = intent.getIntExtra(EXTRA_NOTIFICATION_DNDSUPPRESSED, 0);
if (notificationSpec.type == NotificationType.GENERIC_SMS && notificationSpec.phoneNumber != null) {
GBApplication.getIDSenderLookup().add(notificationSpec.getId(), notificationSpec.phoneNumber);
}
// TODO: check if at least one of the attached actions is a reply action instead?
if ((notificationSpec.attachedActions != null && notificationSpec.attachedActions.size() > 0) || (notificationSpec.type == NotificationType.GENERIC_SMS && notificationSpec.phoneNumber != null)) {
// NOTE: maybe not where it belongs
// I would rather like to save that as an array in SharedPreferences
// this would work but I dont know how to do the same in the Settings Activity's xml
ArrayList<String> replies = new ArrayList<>();
for (int i = 1; i <= 16; i++) {
String reply = devicePrefs.getString("canned_reply_" + i, null);
if (reply != null && !reply.equals("")) {
replies.add(reply);
}
}
notificationSpec.cannedReplies = replies.toArray(new String[0]);
}
mDeviceSupport.onNotification(notificationSpec);
break;
}
case ACTION_DELETE_NOTIFICATION:
{
mDeviceSupport.onDeleteNotification(intent.getIntExtra(EXTRA_NOTIFICATION_ID, -1));
break;
}
case ACTION_ADD_CALENDAREVENT:
{
CalendarEventSpec calendarEventSpec = new CalendarEventSpec();
calendarEventSpec.id = intent.getLongExtra(EXTRA_CALENDAREVENT_ID, -1);
calendarEventSpec.type = intent.getByteExtra(EXTRA_CALENDAREVENT_TYPE, (byte) -1);
calendarEventSpec.timestamp = intent.getIntExtra(EXTRA_CALENDAREVENT_TIMESTAMP, -1);
calendarEventSpec.durationInSeconds = intent.getIntExtra(EXTRA_CALENDAREVENT_DURATION, -1);
calendarEventSpec.title = sanitizeNotifText(intent.getStringExtra(EXTRA_CALENDAREVENT_TITLE));
calendarEventSpec.description = sanitizeNotifText(intent.getStringExtra(EXTRA_CALENDAREVENT_DESCRIPTION));
calendarEventSpec.location = sanitizeNotifText(intent.getStringExtra(EXTRA_CALENDAREVENT_LOCATION));
mDeviceSupport.onAddCalendarEvent(calendarEventSpec);
break;
}
case ACTION_DELETE_CALENDAREVENT:
{
long id = intent.getLongExtra(EXTRA_CALENDAREVENT_ID, -1);
byte type = intent.getByteExtra(EXTRA_CALENDAREVENT_TYPE, (byte) -1);
mDeviceSupport.onDeleteCalendarEvent(type, id);
break;
}
case ACTION_RESET:
{
int flags = intent.getIntExtra(EXTRA_RESET_FLAGS, 0);
mDeviceSupport.onReset(flags);
break;
}
case ACTION_HEARTRATE_TEST:
{
mDeviceSupport.onHeartRateTest();
break;
}
case ACTION_FETCH_RECORDED_DATA:
{
int dataTypes = intent.getIntExtra(EXTRA_RECORDED_DATA_TYPES, 0);
mDeviceSupport.onFetchRecordedData(dataTypes);
break;
}
case ACTION_DISCONNECT:
{
mDeviceSupport.dispose();
if (mGBDevice != null) {
mGBDevice.setState(GBDevice.State.NOT_CONNECTED);
mGBDevice.sendDeviceUpdateIntent(this);
}
setReceiversEnableState(false, false, null);
mGBDevice = null;
mDeviceSupport = null;
mCoordinator = null;
break;
}
case ACTION_FIND_DEVICE:
{
boolean start = intent.getBooleanExtra(EXTRA_FIND_START, false);
mDeviceSupport.onFindDevice(start);
break;
}
case ACTION_SET_CONSTANT_VIBRATION:
{
int intensity = intent.getIntExtra(EXTRA_VIBRATION_INTENSITY, 0);
mDeviceSupport.onSetConstantVibration(intensity);
break;
}
case ACTION_CALLSTATE:
CallSpec callSpec = new CallSpec();
callSpec.command = intent.getIntExtra(EXTRA_CALL_COMMAND, CallSpec.CALL_UNDEFINED);
callSpec.number = intent.getStringExtra(EXTRA_CALL_PHONENUMBER);
callSpec.name = sanitizeNotifText(intent.getStringExtra(EXTRA_CALL_DISPLAYNAME));
mDeviceSupport.onSetCallState(callSpec);
break;
case ACTION_SETCANNEDMESSAGES:
int type = intent.getIntExtra(EXTRA_CANNEDMESSAGES_TYPE, -1);
String[] cannedMessages = intent.getStringArrayExtra(EXTRA_CANNEDMESSAGES);
CannedMessagesSpec cannedMessagesSpec = new CannedMessagesSpec();
cannedMessagesSpec.type = type;
cannedMessagesSpec.cannedMessages = cannedMessages;
mDeviceSupport.onSetCannedMessages(cannedMessagesSpec);
break;
case ACTION_SETTIME:
mDeviceSupport.onSetTime();
break;
case ACTION_SETMUSICINFO:
MusicSpec musicSpec = new MusicSpec();
musicSpec.artist = sanitizeNotifText(intent.getStringExtra(EXTRA_MUSIC_ARTIST));
musicSpec.album = sanitizeNotifText(intent.getStringExtra(EXTRA_MUSIC_ALBUM));
musicSpec.track = sanitizeNotifText(intent.getStringExtra(EXTRA_MUSIC_TRACK));
musicSpec.duration = intent.getIntExtra(EXTRA_MUSIC_DURATION, 0);
musicSpec.trackCount = intent.getIntExtra(EXTRA_MUSIC_TRACKCOUNT, 0);
musicSpec.trackNr = intent.getIntExtra(EXTRA_MUSIC_TRACKNR, 0);
mDeviceSupport.onSetMusicInfo(musicSpec);
break;
case ACTION_SETMUSICSTATE:
MusicStateSpec stateSpec = new MusicStateSpec();
stateSpec.shuffle = intent.getByteExtra(EXTRA_MUSIC_SHUFFLE, (byte) 0);
stateSpec.repeat = intent.getByteExtra(EXTRA_MUSIC_REPEAT, (byte) 0);
stateSpec.position = intent.getIntExtra(EXTRA_MUSIC_POSITION, 0);
stateSpec.playRate = intent.getIntExtra(EXTRA_MUSIC_RATE, 0);
stateSpec.state = intent.getByteExtra(EXTRA_MUSIC_STATE, (byte) 0);
mDeviceSupport.onSetMusicState(stateSpec);
break;
case ACTION_REQUEST_APPINFO:
mDeviceSupport.onAppInfoReq();
break;
case ACTION_REQUEST_SCREENSHOT:
mDeviceSupport.onScreenshotReq();
break;
case ACTION_STARTAPP:
{
UUID uuid = (UUID) intent.getSerializableExtra(EXTRA_APP_UUID);
boolean start = intent.getBooleanExtra(EXTRA_APP_START, true);
mDeviceSupport.onAppStart(uuid, start);
break;
}
case ACTION_DELETEAPP:
{
UUID uuid = (UUID) intent.getSerializableExtra(EXTRA_APP_UUID);
mDeviceSupport.onAppDelete(uuid);
break;
}
case ACTION_APP_CONFIGURE:
{
UUID uuid = (UUID) intent.getSerializableExtra(EXTRA_APP_UUID);
String config = intent.getStringExtra(EXTRA_APP_CONFIG);
Integer id = null;
if (intent.hasExtra(EXTRA_APP_CONFIG_ID)) {
id = intent.getIntExtra(EXTRA_APP_CONFIG_ID, 0);
}
mDeviceSupport.onAppConfiguration(uuid, config, id);
break;
}
case ACTION_APP_REORDER:
{
UUID[] uuids = (UUID[]) intent.getSerializableExtra(EXTRA_APP_UUID);
mDeviceSupport.onAppReorder(uuids);
break;
}
case ACTION_INSTALL:
Uri uri = intent.getParcelableExtra(EXTRA_URI);
if (uri != null) {
LOG.info("will try to install app/fw");
mDeviceSupport.onInstallApp(uri);
}
break;
case ACTION_SET_ALARMS:
ArrayList<? extends Alarm> alarms = (ArrayList<? extends Alarm>) intent.getSerializableExtra(EXTRA_ALARMS);
mDeviceSupport.onSetAlarms(alarms);
break;
case ACTION_SET_REMINDERS:
ArrayList<? extends Reminder> reminders = (ArrayList<? extends Reminder>) intent.getSerializableExtra(EXTRA_REMINDERS);
mDeviceSupport.onSetReminders(reminders);
break;
case ACTION_ENABLE_REALTIME_STEPS:
{
boolean enable = intent.getBooleanExtra(EXTRA_BOOLEAN_ENABLE, false);
mDeviceSupport.onEnableRealtimeSteps(enable);
break;
}
case ACTION_ENABLE_HEARTRATE_SLEEP_SUPPORT:
{
boolean enable = intent.getBooleanExtra(EXTRA_BOOLEAN_ENABLE, false);
mDeviceSupport.onEnableHeartRateSleepSupport(enable);
break;
}
case ACTION_SET_HEARTRATE_MEASUREMENT_INTERVAL:
{
int seconds = intent.getIntExtra(EXTRA_INTERVAL_SECONDS, 0);
mDeviceSupport.onSetHeartRateMeasurementInterval(seconds);
break;
}
case ACTION_ENABLE_REALTIME_HEARTRATE_MEASUREMENT:
{
boolean enable = intent.getBooleanExtra(EXTRA_BOOLEAN_ENABLE, false);
mDeviceSupport.onEnableRealtimeHeartRateMeasurement(enable);
break;
}
case ACTION_SEND_CONFIGURATION:
{
String config = intent.getStringExtra(EXTRA_CONFIG);
mDeviceSupport.onSendConfiguration(config);
break;
}
case ACTION_READ_CONFIGURATION:
{
String config = intent.getStringExtra(EXTRA_CONFIG);
mDeviceSupport.onReadConfiguration(config);
break;
}
case ACTION_TEST_NEW_FUNCTION:
{
mDeviceSupport.onTestNewFunction();
break;
}
case ACTION_SEND_WEATHER:
{
WeatherSpec weatherSpec = intent.getParcelableExtra(EXTRA_WEATHER);
if (weatherSpec != null) {
mDeviceSupport.onSendWeather(weatherSpec);
}
break;
}
case ACTION_SET_LED_COLOR:
int color = intent.getIntExtra(EXTRA_LED_COLOR, 0);
if (color != 0) {
mDeviceSupport.onSetLedColor(color);
}
break;
case ACTION_POWER_OFF:
mDeviceSupport.onPowerOff();
break;
case ACTION_SET_FM_FREQUENCY:
float frequency = intent.getFloatExtra(EXTRA_FM_FREQUENCY, -1);
if (frequency != -1) {
mDeviceSupport.onSetFmFrequency(frequency);
}
break;
}
}
Aggregations