2015-08-03 23:09:49 +02:00
|
|
|
package nodomain.freeyourgadget.gadgetbridge.devices;
|
2015-05-05 00:48:02 +02:00
|
|
|
|
2016-11-27 01:09:20 +01:00
|
|
|
import android.annotation.TargetApi;
|
2015-05-05 00:48:02 +02:00
|
|
|
import android.app.Activity;
|
2016-11-27 01:09:20 +01:00
|
|
|
import android.bluetooth.le.ScanFilter;
|
2015-08-06 02:17:38 +02:00
|
|
|
import android.content.Context;
|
|
|
|
import android.net.Uri;
|
2016-11-27 01:09:20 +01:00
|
|
|
import android.os.Build;
|
2017-02-26 22:46:49 +01:00
|
|
|
import android.support.annotation.DrawableRes;
|
2016-11-27 01:09:20 +01:00
|
|
|
import android.support.annotation.NonNull;
|
2017-02-26 22:46:49 +01:00
|
|
|
import android.support.annotation.Nullable;
|
2016-11-27 01:09:20 +01:00
|
|
|
|
|
|
|
import java.util.Collection;
|
2015-05-05 00:48:02 +02:00
|
|
|
|
2016-10-24 20:02:44 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.GBException;
|
2016-06-18 01:26:36 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.entities.DaoSession;
|
2015-08-03 23:09:49 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
2015-08-06 02:17:38 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate;
|
2016-06-16 21:54:53 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.model.ActivitySample;
|
2015-08-06 02:17:38 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
|
2015-05-05 00:48:02 +02:00
|
|
|
|
2015-10-26 23:32:03 +01:00
|
|
|
/**
|
|
|
|
* This interface is implemented at least once for every supported gadget device.
|
|
|
|
* It allows Gadgetbridge to generically deal with different kinds of devices
|
|
|
|
* without actually knowing the details of any device.
|
2016-02-29 20:54:39 +01:00
|
|
|
* <p/>
|
2015-10-26 23:32:03 +01:00
|
|
|
* Instances will be created as needed and asked whether they support a given
|
|
|
|
* device. If a coordinator answers true, it will be used to assist in handling
|
|
|
|
* the given device.
|
|
|
|
*/
|
2015-05-05 00:48:02 +02:00
|
|
|
public interface DeviceCoordinator {
|
2017-01-26 00:11:52 +01:00
|
|
|
String EXTRA_DEVICE_CANDIDATE = "nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate.EXTRA_DEVICE_CANDIDATE";
|
2015-05-05 00:48:02 +02:00
|
|
|
|
2015-10-26 23:32:03 +01:00
|
|
|
/**
|
2016-11-27 01:09:20 +01:00
|
|
|
* Checks whether this coordinator handles the given candidate.
|
|
|
|
* Returns the supported device type for the given candidate or
|
|
|
|
* DeviceType.UNKNOWN
|
|
|
|
*
|
|
|
|
* @param candidate
|
|
|
|
* @return the supported device type for the given candidate.
|
|
|
|
*/
|
|
|
|
@NonNull
|
|
|
|
DeviceType getSupportedType(GBDeviceCandidate candidate);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks whether this coordinator handles the given candidate.
|
2016-02-29 20:54:39 +01:00
|
|
|
*
|
2015-10-26 23:32:03 +01:00
|
|
|
* @param candidate
|
|
|
|
* @return true if this coordinator handles the given candidate.
|
|
|
|
*/
|
2015-08-03 23:09:49 +02:00
|
|
|
boolean supports(GBDeviceCandidate candidate);
|
2015-05-18 20:56:19 +02:00
|
|
|
|
2015-10-26 23:32:03 +01:00
|
|
|
/**
|
|
|
|
* Checks whether this candidate handles the given device.
|
2016-02-29 20:54:39 +01:00
|
|
|
*
|
2015-10-26 23:32:03 +01:00
|
|
|
* @param device
|
|
|
|
* @return true if this coordinator handles the given device.
|
|
|
|
*/
|
2015-05-12 20:09:35 +02:00
|
|
|
boolean supports(GBDevice device);
|
2015-05-18 20:56:19 +02:00
|
|
|
|
2016-11-27 01:09:20 +01:00
|
|
|
/**
|
|
|
|
* Returns a list of scan filters that shall be used to discover devices supported
|
|
|
|
* by this coordinator.
|
|
|
|
* @return the list of scan filters, may be empty
|
|
|
|
*/
|
|
|
|
@NonNull
|
|
|
|
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
|
|
|
Collection<? extends ScanFilter> createBLEScanFilters();
|
|
|
|
|
2016-08-17 00:53:16 +02:00
|
|
|
GBDevice createDevice(GBDeviceCandidate candidate);
|
|
|
|
|
2016-10-24 20:02:44 +02:00
|
|
|
/**
|
|
|
|
* Deletes all information, including all related database content about the
|
|
|
|
* given device.
|
|
|
|
* @throws GBException
|
|
|
|
*/
|
|
|
|
void deleteDevice(GBDevice device) throws GBException;
|
|
|
|
|
2015-10-26 23:32:03 +01:00
|
|
|
/**
|
|
|
|
* Returns the kind of device type this coordinator supports.
|
2016-02-29 20:54:39 +01:00
|
|
|
*
|
2015-10-26 23:32:03 +01:00
|
|
|
* @return
|
|
|
|
*/
|
2015-05-12 20:09:35 +02:00
|
|
|
DeviceType getDeviceType();
|
2015-05-05 00:48:02 +02:00
|
|
|
|
2015-10-26 23:32:03 +01:00
|
|
|
/**
|
|
|
|
* Returns the Activity class to be started in order to perform a pairing of a
|
2017-02-26 22:46:49 +01:00
|
|
|
* given device after its discovery.
|
2016-02-29 20:54:39 +01:00
|
|
|
*
|
2017-02-26 22:46:49 +01:00
|
|
|
* @return the activity class for pairing/initial authentication, or null if none
|
2015-10-26 23:32:03 +01:00
|
|
|
*/
|
2017-02-26 22:46:49 +01:00
|
|
|
@Nullable
|
2015-05-05 00:48:02 +02:00
|
|
|
Class<? extends Activity> getPairingActivity();
|
2015-07-20 23:20:24 +02:00
|
|
|
|
2015-10-26 23:32:03 +01:00
|
|
|
/**
|
|
|
|
* Returns the Activity class that will be used as the primary activity
|
|
|
|
* for the given device.
|
2016-02-29 20:54:39 +01:00
|
|
|
*
|
2017-02-26 22:46:49 +01:00
|
|
|
* @return the primary activity class, or null if none
|
2015-10-26 23:32:03 +01:00
|
|
|
*/
|
2017-02-26 22:46:49 +01:00
|
|
|
@Nullable
|
2015-07-20 23:20:24 +02:00
|
|
|
Class<? extends Activity> getPrimaryActivity();
|
2015-07-27 23:49:53 +02:00
|
|
|
|
2015-10-26 23:32:03 +01:00
|
|
|
/**
|
|
|
|
* Returns true if activity data fetching is supported by the device
|
|
|
|
* (with this coordinator).
|
2016-02-29 20:54:39 +01:00
|
|
|
*
|
2015-10-26 23:32:03 +01:00
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
boolean supportsActivityDataFetching();
|
2015-10-24 23:28:02 +02:00
|
|
|
|
2016-09-20 22:02:40 +02:00
|
|
|
/**
|
|
|
|
* Returns true if activity tracking is supported by the device
|
|
|
|
* (with this coordinator).
|
|
|
|
*
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
boolean supportsActivityTracking();
|
|
|
|
|
2015-10-26 23:32:03 +01:00
|
|
|
/**
|
|
|
|
* Returns true if activity data fetching is supported AND possible at this
|
|
|
|
* very moment. This will consider the device state (being connected/disconnected/busy...)
|
|
|
|
* etc.
|
2016-02-29 20:54:39 +01:00
|
|
|
*
|
2015-10-26 23:32:03 +01:00
|
|
|
* @param device
|
|
|
|
* @return
|
|
|
|
*/
|
2015-10-24 23:28:02 +02:00
|
|
|
boolean allowFetchActivityData(GBDevice device);
|
|
|
|
|
2015-10-26 23:32:03 +01:00
|
|
|
/**
|
|
|
|
* Returns the sample provider for the device being supported.
|
2016-02-29 20:54:39 +01:00
|
|
|
*
|
2015-10-26 23:32:03 +01:00
|
|
|
* @return
|
|
|
|
*/
|
2016-06-27 20:41:20 +02:00
|
|
|
SampleProvider<? extends ActivitySample> getSampleProvider(GBDevice device, DaoSession session);
|
2015-10-26 23:32:03 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Finds an install handler for the given uri that can install the given
|
|
|
|
* uri on the device being managed.
|
2016-02-29 20:54:39 +01:00
|
|
|
*
|
2015-10-26 23:32:03 +01:00
|
|
|
* @param uri
|
|
|
|
* @param context
|
|
|
|
* @return the install handler or null if that uri cannot be installed on the device
|
|
|
|
*/
|
|
|
|
InstallHandler findInstallHandler(Uri uri, Context context);
|
2015-10-24 23:28:02 +02:00
|
|
|
|
2015-10-26 23:32:03 +01:00
|
|
|
/**
|
|
|
|
* Returns true if this device/coordinator supports taking screenshots.
|
2016-02-29 20:54:39 +01:00
|
|
|
*
|
2015-10-26 23:32:03 +01:00
|
|
|
* @return
|
|
|
|
*/
|
2015-10-24 23:28:02 +02:00
|
|
|
boolean supportsScreenshots();
|
2016-03-20 17:53:55 +01:00
|
|
|
|
|
|
|
/**
|
2016-12-01 20:18:36 +01:00
|
|
|
* Returns true if this device/coordinator supports setting alarms.
|
2016-03-20 17:53:55 +01:00
|
|
|
*
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
boolean supportsAlarmConfiguration();
|
2016-05-04 12:31:29 +02:00
|
|
|
|
2017-01-26 20:55:00 +01:00
|
|
|
/**
|
|
|
|
* Returns true if this device/coordinator supports alarms with smart wakeup
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
boolean supportsSmartWakeup(GBDevice device);
|
|
|
|
|
2016-06-19 23:22:28 +02:00
|
|
|
/**
|
|
|
|
* Returns true if the given device supports heart rate measurements.
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
boolean supportsHeartRateMeasurement(GBDevice device);
|
|
|
|
|
2016-05-04 12:31:29 +02:00
|
|
|
int getTapString();
|
2016-05-13 23:47:47 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the readable name of the manufacturer.
|
|
|
|
*/
|
|
|
|
String getManufacturer();
|
2016-10-25 17:39:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if this device/coordinator supports managing device apps.
|
|
|
|
*
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
boolean supportsAppsManagement();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the Activity class that will be used to manage device apps.
|
|
|
|
*
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
Class<? extends Activity> getAppsManagementActivity();
|
2015-05-05 00:48:02 +02:00
|
|
|
}
|