gt:                 String artist = intent.getStringExtra(EXTRA_MUSIC_ARTIST);
context: package nodomain.freeyourgadget.gadgetbridge.service;
  
  import android.app.NotificationManager;
  import android.app.Service;
  import android.content.BroadcastReceiver;
  import android.content.ContentResolver;
  import android.content.Context;
  import android.content.Intent;
  import android.content.IntentFilter;
  import android.content.SharedPreferences;
  import android.database.Cursor;
  import android.net.Uri;
  import android.os.IBinder;
  import android.preference.PreferenceManager;
  import android.provider.ContactsContract;
  import android.support.annotation.Nullable;
  import android.support.v4.content.LocalBroadcastManager;
  import android.widget.Toast;
  
  import org.slf4j.Logger;
  import org.slf4j.LoggerFactory;
  
  import java.util.ArrayList;
  import java.util.UUID;
  
  import nodomain.freeyourgadget.gadgetbridge.R;
  import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
  import nodomain.freeyourgadget.gadgetbridge.model.Alarm;
  import nodomain.freeyourgadget.gadgetbridge.model.DeviceService;
  import nodomain.freeyourgadget.gadgetbridge.model.ServiceCommand;
  import nodomain.freeyourgadget.gadgetbridge.util.GB;
  
  import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_CALLSTATE;
  import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_CONNECT;
  import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_DELETEAPP;
  import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_DISCONNECT;
  import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_FETCH_ACTIVITY_DATA;
  import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_FIND_DEVICE;
  import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_INSTALL;
  import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_NOTIFICATION_EMAIL;
  import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_NOTIFICATION_GENERIC;
  import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_NOTIFICATION_SMS;
  import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_REBOOT;
  import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_REQUEST_APPINFO;
  import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_REQUEST_DEVICEINFO;
  import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_REQUEST_SCREENSHOT;
  import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_SETMUSICINFO;
  import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_SETTIME;
  import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_SET_ALARMS;
  import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_START;
  import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_STARTAPP;
  import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_ALARMS;
  import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_APP_UUID;
  import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_CALL_COMMAND;
  import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_CALL_PHONENUMBER;
  import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_DEVICE_ADDRESS;
  import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_FIND_START;
  import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_MUSIC_ALBUM;
  import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_MUSIC_ARTIST;
  import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_MUSIC_TRACK;
  import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_NOTIFICATION_BODY;
  import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_NOTIFICATION_HANDLE;
  import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_NOTIFICATION_SENDER;
  import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_NOTIFICATION_SUBJECT;
  import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_NOTIFICATION_TITLE;
  import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_PERFORM_PAIR;
  import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.EXTRA_URI;
  
  public class DeviceCommunicationService extends Service {
      private static final Logger LOG = LoggerFactory.getLogger(DeviceCommunicationService.class);
  
      private boolean mStarted = false;
  
      private DeviceSupportFactory mFactory;
      private GBDevice mGBDevice = null;
      private DeviceSupport mDeviceSupport;
  
      private BroadcastReceiver mReceiver = new BroadcastReceiver() {
          @Override
          public void onReceive(Context context, Intent intent) {
              String action = intent.getAction();
              if (action.equals(GBDevice.ACTION_DEVICE_CHANGED)) {
                  GBDevice device = intent.getParcelableExtra(GBDevice.EXTRA_DEVICE);
                  if (mGBDevice.equals(device)) {
                      mGBDevice = device;
                      boolean enableReceivers = mDeviceSupport != null && (mDeviceSupport.useAutoConnect() || mGBDevice.isInitialized());
                      GB.setReceiversEnableState(enableReceivers, context);
                      GB.updateNotification(mGBDevice.getName() + " " + mGBDevice.getStateString(), context);
                  } else {
                      LOG.error("Got ACTION_DEVICE_CHANGED from unexpected device: " + mGBDevice);
                  }
              }
          }
      };
  
      @Override
      public void onCreate() {
          LOG.debug("DeviceCommunicationService is being created");
          super.onCreate();
          LocalBroadcastManager.getInstance(this).registerReceiver(mReceiver, new IntentFilter(GBDevice.ACTION_DEVICE_CHANGED));
          mFactory = new DeviceSupportFactory(this);
      }
  
      @Override
      public int onStartCommand(Intent intent, int flags, int startId) {
  
          if (intent == null) {
              LOG.info("no intent");
              return START_NOT_STICKY;
          }
  
          String action = intent.getAction();
          boolean pair = intent.getBooleanExtra(EXTRA_PERFORM_PAIR, false);
  
          if (action == null) {
              LOG.info("no action");
              return START_NOT_STICKY;
          }
  
          LOG.debug("Service startcommand: " + action);
  
          if (!action.equals(ACTION_START) && !action.equals(ACTION_CONNECT)) {
              if (!mStarted) {
                  // using the service before issuing ACTION_START
                  LOG.info("Must start service with " + ACTION_START + " or " + ACTION_CONNECT + " before using it: " + action);
                  return START_NOT_STICKY;
              }
  
              if (mDeviceSupport == null || (!isInitialized() && !mDeviceSupport.useAutoConnect())) {
                  // trying to send notification without valid Bluetooth connection
                  if (mGBDevice != null) {
                      // at least send back the current device state
                      mGBDevice.sendDeviceUpdateIntent(this);
                  }
                  return START_STICKY;
              }
          }
  
          // when we get past this, we should have valid mDeviceSupport and mGBDevice instances
  
          switch (action) {
              case ACTION_START:
                  start();
                  break;
              case ACTION_CONNECT:
                  start(); // ensure started
                  String btDeviceAddress = intent.getStringExtra(EXTRA_DEVICE_ADDRESS);
                  SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
                  if (sharedPrefs != null) { // may be null in test cases
                      if (btDeviceAddress == null) {
                          btDeviceAddress = sharedPrefs.getString("last_device_address", null);
                      } else {
                          sharedPrefs.edit().putString("last_device_address", btDeviceAddress).apply();
                      }
                  }
  
                  if (btDeviceAddress != null && !isConnecting() && !isConnected()) {
                      setDeviceSupport(null);
                      try {
                          DeviceSupport deviceSupport = mFactory.createDeviceSupport(btDeviceAddress);
                          if (deviceSupport != null) {
                              setDeviceSupport(deviceSupport);
                              if (pair) {
                                  deviceSupport.pair();
                              } else {
                                  deviceSupport.connect();
                              }
                          }
                      } catch (Exception e) {
                          GB.toast(this, getString(R.string.cannot_connect, e.getMessage()), Toast.LENGTH_SHORT, GB.ERROR);
                          setDeviceSupport(null);
                      }
                  } else if (mGBDevice != null) {
                      // send an update at least
                      mGBDevice.sendDeviceUpdateIntent(this);
                  }
                  break;
              case ACTION_REQUEST_DEVICEINFO:
                  mGBDevice.sendDeviceUpdateIntent(this);
                  break;
              case ACTION_NOTIFICATION_GENERIC: {
                  String title = intent.getStringExtra(EXTRA_NOTIFICATION_TITLE);
                  String body = intent.getStringExtra(EXTRA_NOTIFICATION_BODY);
                  int handle = intent.getIntExtra(EXTRA_NOTIFICATION_HANDLE,-1);
                  mDeviceSupport.onGenericNotification(title, body, handle);
                  break;
              }
              case ACTION_NOTIFICATION_SMS: {
                  String sender = intent.getStringExtra(EXTRA_NOTIFICATION_SENDER);
                  String body = intent.getStringExtra(EXTRA_NOTIFICATION_BODY);
                  String senderName = getContactDisplayNameByNumber(sender);
                  mDeviceSupport.onSMS(senderName, body);
                  break;
              }
              case ACTION_NOTIFICATION_EMAIL: {
                  String sender = intent.getStringExtra(EXTRA_NOTIFICATION_SENDER);
                  String subject = intent.getStringExtra(EXTRA_NOTIFICATION_SUBJECT);
                  String body = intent.getStringExtra(EXTRA_NOTIFICATION_BODY);
                  mDeviceSupport.onEmail(sender, subject, body);
                  break;
              }
              case ACTION_REBOOT: {
                  mDeviceSupport.onReboot();
                  break;
              }
              case ACTION_FETCH_ACTIVITY_DATA: {
                  mDeviceSupport.onFetchActivityData();
                  break;
              }
              case ACTION_DISCONNECT: {
                  mDeviceSupport.dispose();
                  mDeviceSupport = null;
                  break;
              }
              case ACTION_FIND_DEVICE: {
                  boolean start = intent.getBooleanExtra(EXTRA_FIND_START, false);
                  mDeviceSupport.onFindDevice(start);
                  break;
              }
              case ACTION_CALLSTATE:
                  ServiceCommand command = (ServiceCommand) intent.getSerializableExtra(EXTRA_CALL_COMMAND);
  
                  String phoneNumber = intent.getStringExtra(EXTRA_CALL_PHONENUMBER);
                  String callerName = null;
                  if (phoneNumber != null) {
                      callerName = getContactDisplayNameByNumber(phoneNumber);
                  }
                  mDeviceSupport.onSetCallState(phoneNumber, callerName, command);
                  break;
              case ACTION_SETTIME:
                  mDeviceSupport.onSetTime();
                  break;
              case ACTION_SETMUSICINFO:
  