1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-06-20 12:00:51 +02:00

Remove reference to PebbleIOThread from BluetoothCommunicationService

Let PebbleSupport do this instead.
This commit is contained in:
cpfeiffer 2015-06-06 23:24:00 +02:00
parent 3fe9195d0d
commit f6d5767276
4 changed files with 27 additions and 6 deletions

View File

@ -63,7 +63,6 @@ public class BluetoothCommunicationService extends Service {
private static final Logger LOG = LoggerFactory.getLogger(BluetoothCommunicationService.class);
public static final String EXTRA_DEVICE_ADDRESS = "device_address";
private GBDeviceIoThread mGBDeviceIoThread = null;
private boolean mStarted = false;
@ -166,9 +165,6 @@ public class BluetoothCommunicationService extends Service {
} else {
mDeviceSupport.connect();
}
if (mDeviceSupport instanceof AbstractBTDeviceSupport) {
mGBDeviceIoThread = ((AbstractBTDeviceSupport) mDeviceSupport).getDeviceIOThread();
}
}
} catch (Exception e) {
Toast.makeText(this, R.string.cannot_connect_bt_address_invalid_, Toast.LENGTH_SHORT).show();
@ -246,7 +242,7 @@ public class BluetoothCommunicationService extends Service {
String uriString = intent.getStringExtra("app_uri");
if (uriString != null) {
LOG.info("will try to install app");
((PebbleIoThread) mGBDeviceIoThread).installApp(Uri.parse(uriString));
mDeviceSupport.onInstallApp(Uri.parse(uriString));
}
break;
case ACTION_START:

View File

@ -1,5 +1,8 @@
package nodomain.freeyourgadget.gadgetbridge;
import android.net.Uri;
import java.net.URI;
import java.util.UUID;
public interface EventHandler {
@ -19,6 +22,8 @@ public interface EventHandler {
void onBatteryInfoReq();
void onInstallApp(Uri uri);
void onAppInfoReq();
void onAppStart(UUID uuid);
@ -30,5 +35,4 @@ public interface EventHandler {
void onFetchActivityData();
void onReboot();
}

View File

@ -3,12 +3,14 @@ package nodomain.freeyourgadget.gadgetbridge.miband;
import android.bluetooth.BluetoothGatt;
import android.bluetooth.BluetoothGattCharacteristic;
import android.content.SharedPreferences;
import android.net.Uri;
import android.preference.PreferenceManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.net.URI;
import java.util.Arrays;
import java.util.Calendar;
import java.util.GregorianCalendar;
@ -380,6 +382,11 @@ public class MiBandSupport extends AbstractBTLEDeviceSupport {
}
}
@Override
public void onInstallApp(Uri uri) {
// not supported
}
@Override
public void onAppInfoReq() {
// not supported

View File

@ -1,5 +1,9 @@
package nodomain.freeyourgadget.gadgetbridge.pebble;
import android.net.Uri;
import java.net.URI;
import nodomain.freeyourgadget.gadgetbridge.AbstractBTDeviceSupport;
import nodomain.freeyourgadget.gadgetbridge.GBDeviceIoThread;
import nodomain.freeyourgadget.gadgetbridge.protocol.GBDeviceProtocol;
@ -26,4 +30,14 @@ public class PebbleSupport extends AbstractBTDeviceSupport {
public boolean useAutoConnect() {
return false;
}
@Override
public void onInstallApp(Uri uri) {
getDeviceIOThread().installApp(uri);
}
@Override
public synchronized PebbleIoThread getDeviceIOThread() {
return (PebbleIoThread) super.getDeviceIOThread();
}
}