diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/DeviceCommunicationService.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/DeviceCommunicationService.java index 3003a93949..f29bb66ef8 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/DeviceCommunicationService.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/DeviceCommunicationService.java @@ -31,6 +31,7 @@ import android.content.SharedPreferences; import android.content.pm.PackageManager; import android.net.Uri; +import android.os.Binder; import android.os.Handler; import android.os.IBinder; import android.support.annotation.Nullable; @@ -751,9 +752,16 @@ public void onDestroy() { } } + public class CommunicationServiceBinder extends Binder{ + public DeviceSupport getDeviceSupport(){ + if(mDeviceSupport == null) return null; + return ((ServiceDeviceSupport)DeviceCommunicationService.this.mDeviceSupport).getDelegate(); + } + } + @Override public IBinder onBind(Intent intent) { - return null; + return new CommunicationServiceBinder(); } @Override diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/ServiceDeviceSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/ServiceDeviceSupport.java index 4c77c5a01f..e3373ebfe3 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/ServiceDeviceSupport.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/ServiceDeviceSupport.java @@ -62,6 +62,10 @@ public ServiceDeviceSupport(DeviceSupport delegate, EnumSet flags) { this.flags = flags; } + public DeviceSupport getDelegate() { + return delegate; + } + @Override public void setContext(GBDevice gbDevice, BluetoothAdapter btAdapter, Context context) { delegate.setContext(gbDevice, btAdapter, context);