mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-07-22 23:02:33 +02:00
reformat code with androidstudio
This commit is contained in:
parent
09914e6da0
commit
dd12bb11b2
|
@ -7,10 +7,10 @@ import android.content.Context;
|
||||||
* Provides support for a specific device. Has hooks to manage the life cycle
|
* Provides support for a specific device. Has hooks to manage the life cycle
|
||||||
* of a device: instances of this interface will be created, initialized, and disposed
|
* of a device: instances of this interface will be created, initialized, and disposed
|
||||||
* as needed.
|
* as needed.
|
||||||
*
|
* <p/>
|
||||||
* Implementations need to act accordingly, in order to establish, reestablish or close
|
* Implementations need to act accordingly, in order to establish, reestablish or close
|
||||||
* the connection to the device.
|
* the connection to the device.
|
||||||
*
|
* <p/>
|
||||||
* This interface is agnostic to the kind transport, i.e. whether the device is connected
|
* This interface is agnostic to the kind transport, i.e. whether the device is connected
|
||||||
* via Bluetooth, Bluetooth LE, Wifi or something else.
|
* via Bluetooth, Bluetooth LE, Wifi or something else.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,5 +1,10 @@
|
||||||
package nodomain.freeyourgadget.gadgetbridge.btle;
|
package nodomain.freeyourgadget.gadgetbridge.btle;
|
||||||
|
|
||||||
|
import android.bluetooth.BluetoothGatt;
|
||||||
|
import android.bluetooth.BluetoothGattCharacteristic;
|
||||||
|
import android.bluetooth.BluetoothGattService;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
@ -8,13 +13,8 @@ import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.AbstractDeviceSupport;
|
import nodomain.freeyourgadget.gadgetbridge.AbstractDeviceSupport;
|
||||||
import android.bluetooth.BluetoothGatt;
|
|
||||||
import android.bluetooth.BluetoothGattCharacteristic;
|
|
||||||
import android.bluetooth.BluetoothGattService;
|
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @see TransactionBuilder
|
* @see TransactionBuilder
|
||||||
* @see BtLEQueue
|
* @see BtLEQueue
|
||||||
*/
|
*/
|
||||||
|
@ -35,6 +35,7 @@ public abstract class AbstractBTLEDeviceSupport extends AbstractDeviceSupport im
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Subclasses should populate the given builder to initialize the device (if necessary).
|
* Subclasses should populate the given builder to initialize the device (if necessary).
|
||||||
|
*
|
||||||
* @param builder
|
* @param builder
|
||||||
* @return the same builder as passed as the argument
|
* @return the same builder as passed as the argument
|
||||||
*/
|
*/
|
||||||
|
@ -55,6 +56,7 @@ public abstract class AbstractBTLEDeviceSupport extends AbstractDeviceSupport im
|
||||||
* <code>perform("sms notification").write(someCharacteristic, someByteArray).queue(getQueue());</code>
|
* <code>perform("sms notification").write(someCharacteristic, someByteArray).queue(getQueue());</code>
|
||||||
* </p>
|
* </p>
|
||||||
* TODO: support orchestration of multiple reads and writes depending on returned values
|
* TODO: support orchestration of multiple reads and writes depending on returned values
|
||||||
|
*
|
||||||
* @see #performConnected(Transaction)
|
* @see #performConnected(Transaction)
|
||||||
* @see #initializeDevice(TransactionBuilder)
|
* @see #initializeDevice(TransactionBuilder)
|
||||||
*/
|
*/
|
||||||
|
@ -73,7 +75,6 @@ public abstract class AbstractBTLEDeviceSupport extends AbstractDeviceSupport im
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param transaction
|
* @param transaction
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* @see {@link #performInitialized(String)}
|
* @see {@link #performInitialized(String)}
|
||||||
|
@ -94,6 +95,7 @@ public abstract class AbstractBTLEDeviceSupport extends AbstractDeviceSupport im
|
||||||
/**
|
/**
|
||||||
* Subclasses should call this method to add services they support.
|
* Subclasses should call this method to add services they support.
|
||||||
* Only supported services will be queried for characteristics.
|
* Only supported services will be queried for characteristics.
|
||||||
|
*
|
||||||
* @param aSupportedService
|
* @param aSupportedService
|
||||||
* @see #getCharacteristic(UUID)
|
* @see #getCharacteristic(UUID)
|
||||||
*/
|
*/
|
||||||
|
@ -104,6 +106,7 @@ public abstract class AbstractBTLEDeviceSupport extends AbstractDeviceSupport im
|
||||||
/**
|
/**
|
||||||
* Returns the characteristic matching the given UUID. Only characteristics
|
* Returns the characteristic matching the given UUID. Only characteristics
|
||||||
* are returned whose service is marked as supported.
|
* are returned whose service is marked as supported.
|
||||||
|
*
|
||||||
* @param uuid
|
* @param uuid
|
||||||
* @return the characteristic for the given UUID or <code>null</code>
|
* @return the characteristic for the given UUID or <code>null</code>
|
||||||
* @see #addSupportedService(UUID)
|
* @see #addSupportedService(UUID)
|
||||||
|
|
|
@ -7,7 +7,7 @@ import android.bluetooth.BluetoothGattCharacteristic;
|
||||||
* The Bluedroid implementation only allows performing one GATT request at a time.
|
* The Bluedroid implementation only allows performing one GATT request at a time.
|
||||||
* As they are asynchronous anyway, we encapsulate every GATT request (read and write)
|
* As they are asynchronous anyway, we encapsulate every GATT request (read and write)
|
||||||
* inside a runnable action.
|
* inside a runnable action.
|
||||||
*
|
* <p/>
|
||||||
* These actions are then executed one after another, ensuring that every action's result
|
* These actions are then executed one after another, ensuring that every action's result
|
||||||
* has been posted before invoking the next action.
|
* has been posted before invoking the next action.
|
||||||
*/
|
*/
|
||||||
|
@ -23,8 +23,10 @@ public abstract class BtLEAction {
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract boolean run(BluetoothGatt gatt);
|
public abstract boolean run(BluetoothGatt gatt);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the GATT characteristic being read/written/...
|
* Returns the GATT characteristic being read/written/...
|
||||||
|
*
|
||||||
* @return the GATT characteristic, or <code>null</code>
|
* @return the GATT characteristic, or <code>null</code>
|
||||||
*/
|
*/
|
||||||
public BluetoothGattCharacteristic getCharacteristic() {
|
public BluetoothGattCharacteristic getCharacteristic() {
|
||||||
|
|
|
@ -1,5 +1,15 @@
|
||||||
package nodomain.freeyourgadget.gadgetbridge.btle;
|
package nodomain.freeyourgadget.gadgetbridge.btle;
|
||||||
|
|
||||||
|
import android.bluetooth.BluetoothAdapter;
|
||||||
|
import android.bluetooth.BluetoothDevice;
|
||||||
|
import android.bluetooth.BluetoothGatt;
|
||||||
|
import android.bluetooth.BluetoothGattCallback;
|
||||||
|
import android.bluetooth.BluetoothGattCharacteristic;
|
||||||
|
import android.bluetooth.BluetoothGattService;
|
||||||
|
import android.bluetooth.BluetoothProfile;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.BlockingQueue;
|
import java.util.concurrent.BlockingQueue;
|
||||||
|
@ -9,15 +19,6 @@ import java.util.concurrent.LinkedBlockingQueue;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.DeviceSupport;
|
import nodomain.freeyourgadget.gadgetbridge.DeviceSupport;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.GBDevice;
|
import nodomain.freeyourgadget.gadgetbridge.GBDevice;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.GBDevice.State;
|
import nodomain.freeyourgadget.gadgetbridge.GBDevice.State;
|
||||||
import android.bluetooth.BluetoothAdapter;
|
|
||||||
import android.bluetooth.BluetoothDevice;
|
|
||||||
import android.bluetooth.BluetoothGatt;
|
|
||||||
import android.bluetooth.BluetoothGattCallback;
|
|
||||||
import android.bluetooth.BluetoothGattCharacteristic;
|
|
||||||
import android.bluetooth.BluetoothGattService;
|
|
||||||
import android.bluetooth.BluetoothProfile;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* One queue/thread per connectable device.
|
* One queue/thread per connectable device.
|
||||||
|
@ -157,6 +158,7 @@ public final class BtLEQueue {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a transaction to the end of the queue.
|
* Adds a transaction to the end of the queue.
|
||||||
|
*
|
||||||
* @param transaction
|
* @param transaction
|
||||||
*/
|
*/
|
||||||
public void add(Transaction transaction) {
|
public void add(Transaction transaction) {
|
||||||
|
|
|
@ -28,40 +28,40 @@ import android.bluetooth.BluetoothGattCharacteristic;
|
||||||
public interface GattCallback {
|
public interface GattCallback {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see BluetoothGattCallback#onConnectionStateChange(BluetoothGatt, int, int)
|
|
||||||
* @param gatt
|
* @param gatt
|
||||||
* @param status
|
* @param status
|
||||||
* @param newState
|
* @param newState
|
||||||
|
* @see BluetoothGattCallback#onConnectionStateChange(BluetoothGatt, int, int)
|
||||||
*/
|
*/
|
||||||
public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState);
|
public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see BluetoothGattCallback#onServicesDiscovered(BluetoothGatt, int)
|
|
||||||
* @param gatt
|
* @param gatt
|
||||||
|
* @see BluetoothGattCallback#onServicesDiscovered(BluetoothGatt, int)
|
||||||
*/
|
*/
|
||||||
public void onServicesDiscovered(BluetoothGatt gatt);
|
public void onServicesDiscovered(BluetoothGatt gatt);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see BluetoothGattCallback#onCharacteristicRead(BluetoothGatt, BluetoothGattCharacteristic, int)
|
|
||||||
* @param gatt
|
* @param gatt
|
||||||
* @param characteristic
|
* @param characteristic
|
||||||
* @param status
|
* @param status
|
||||||
|
* @see BluetoothGattCallback#onCharacteristicRead(BluetoothGatt, BluetoothGattCharacteristic, int)
|
||||||
*/
|
*/
|
||||||
public void onCharacteristicRead(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status);
|
public void onCharacteristicRead(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see BluetoothGattCallback#onCharacteristicWrite(BluetoothGatt, BluetoothGattCharacteristic, int)
|
|
||||||
* @param gatt
|
* @param gatt
|
||||||
* @param characteristic
|
* @param characteristic
|
||||||
* @param status
|
* @param status
|
||||||
|
* @see BluetoothGattCallback#onCharacteristicWrite(BluetoothGatt, BluetoothGattCharacteristic, int)
|
||||||
*/
|
*/
|
||||||
public void onCharacteristicWrite(BluetoothGatt gatt,
|
public void onCharacteristicWrite(BluetoothGatt gatt,
|
||||||
BluetoothGattCharacteristic characteristic, int status);
|
BluetoothGattCharacteristic characteristic, int status);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see BluetoothGattCallback#onCharacteristicChanged(BluetoothGatt, BluetoothGattCharacteristic)
|
|
||||||
* @param gatt
|
* @param gatt
|
||||||
* @param characteristic
|
* @param characteristic
|
||||||
|
* @see BluetoothGattCallback#onCharacteristicChanged(BluetoothGatt, BluetoothGattCharacteristic)
|
||||||
*/
|
*/
|
||||||
public void onCharacteristicChanged(BluetoothGatt gatt,
|
public void onCharacteristicChanged(BluetoothGatt gatt,
|
||||||
BluetoothGattCharacteristic characteristic);
|
BluetoothGattCharacteristic characteristic);
|
||||||
|
@ -92,10 +92,10 @@ public interface GattCallback {
|
||||||
// public void onReliableWriteCompleted(BluetoothGatt gatt, int status);
|
// public void onReliableWriteCompleted(BluetoothGatt gatt, int status);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see BluetoothGattCallback#onReadRemoteRssi(BluetoothGatt, int, int)
|
|
||||||
* @param gatt
|
* @param gatt
|
||||||
* @param rssi
|
* @param rssi
|
||||||
* @param status
|
* @param status
|
||||||
|
* @see BluetoothGattCallback#onReadRemoteRssi(BluetoothGatt, int, int)
|
||||||
*/
|
*/
|
||||||
public void onReadRemoteRssi(BluetoothGatt gatt, int rssi, int status);
|
public void onReadRemoteRssi(BluetoothGatt gatt, int rssi, int status);
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,7 @@ public class TransactionBuilder {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* To be used as the final step to execute the transaction by the given queue.
|
* To be used as the final step to execute the transaction by the given queue.
|
||||||
|
*
|
||||||
* @param queue
|
* @param queue
|
||||||
*/
|
*/
|
||||||
public void queue(BtLEQueue queue) {
|
public void queue(BtLEQueue queue) {
|
||||||
|
|
|
@ -1,14 +1,15 @@
|
||||||
package nodomain.freeyourgadget.gadgetbridge.miband;
|
package nodomain.freeyourgadget.gadgetbridge.miband;
|
||||||
|
|
||||||
|
import android.bluetooth.BluetoothGatt;
|
||||||
|
import android.bluetooth.BluetoothGattCharacteristic;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.GBCommand;
|
import nodomain.freeyourgadget.gadgetbridge.GBCommand;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.btle.AbstractBTLEDeviceSupport;
|
import nodomain.freeyourgadget.gadgetbridge.btle.AbstractBTLEDeviceSupport;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.btle.TransactionBuilder;
|
import nodomain.freeyourgadget.gadgetbridge.btle.TransactionBuilder;
|
||||||
import android.bluetooth.BluetoothGatt;
|
|
||||||
import android.bluetooth.BluetoothGattCharacteristic;
|
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
public class MiBandSupport extends AbstractBTLEDeviceSupport {
|
public class MiBandSupport extends AbstractBTLEDeviceSupport {
|
||||||
|
|
||||||
|
@ -72,6 +73,7 @@ public class MiBandSupport extends AbstractBTLEDeviceSupport {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Part of device initialization process. Do not call manually.
|
* Part of device initialization process. Do not call manually.
|
||||||
|
*
|
||||||
* @param builder
|
* @param builder
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@ -84,6 +86,7 @@ public class MiBandSupport extends AbstractBTLEDeviceSupport {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Part of device initialization process. Do not call manually.
|
* Part of device initialization process. Do not call manually.
|
||||||
|
*
|
||||||
* @param builder
|
* @param builder
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -17,6 +17,7 @@ public class UserInfo {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a default user info.
|
* Creates a default user info.
|
||||||
|
*
|
||||||
* @param btAddress the address of the MI Band to connect to.
|
* @param btAddress the address of the MI Band to connect to.
|
||||||
*/
|
*/
|
||||||
public static UserInfo getDefault(String btAddress) {
|
public static UserInfo getDefault(String btAddress) {
|
||||||
|
@ -25,6 +26,7 @@ public class UserInfo {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a user info with the given data
|
* Creates a user info with the given data
|
||||||
|
*
|
||||||
* @param address the address of the MI Band to connect to.
|
* @param address the address of the MI Band to connect to.
|
||||||
*/
|
*/
|
||||||
public UserInfo(String address, String alias, int gender, int age, int height, int weight, int type) {
|
public UserInfo(String address, String alias, int gender, int age, int height, int weight, int type) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user