mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-09-10 08:16:48 +02:00
241 lines
7.3 KiB
Java
241 lines
7.3 KiB
Java
/* Copyright (C) 2015-2017 Andreas Shimokawa, Carsten Pfeiffer, Daniele
|
|
Gobbetti, JohnnySun, Uwe Hermann
|
|
|
|
This file is part of Gadgetbridge.
|
|
|
|
Gadgetbridge is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU Affero General Public License as published
|
|
by the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
Gadgetbridge is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU Affero General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Affero General Public License
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
package nodomain.freeyourgadget.gadgetbridge.devices;
|
|
|
|
import android.annotation.TargetApi;
|
|
import android.app.Activity;
|
|
import android.bluetooth.le.ScanFilter;
|
|
import android.content.Context;
|
|
import android.net.Uri;
|
|
import android.os.Build;
|
|
import android.support.annotation.NonNull;
|
|
import android.support.annotation.Nullable;
|
|
|
|
import java.util.Collection;
|
|
|
|
import nodomain.freeyourgadget.gadgetbridge.GBException;
|
|
import nodomain.freeyourgadget.gadgetbridge.entities.DaoSession;
|
|
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
|
import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate;
|
|
import nodomain.freeyourgadget.gadgetbridge.model.ActivitySample;
|
|
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
|
|
|
|
/**
|
|
* 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.
|
|
* <p/>
|
|
* 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.
|
|
*/
|
|
public interface DeviceCoordinator {
|
|
String EXTRA_DEVICE_CANDIDATE = "nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate.EXTRA_DEVICE_CANDIDATE";
|
|
/**
|
|
* Do not attempt to bond after discovery.
|
|
*/
|
|
int BONDING_STYLE_NONE = 0;
|
|
/**
|
|
* Bond after discovery.
|
|
* This is not recommended, as there are mobile devices on which bonding does not work.
|
|
* Prefer to use #BONDING_STYLE_ASK instead.
|
|
*/
|
|
int BONDING_STYLE_BOND = 1;
|
|
/**
|
|
* Let the user decide whether to bond or not after discovery.
|
|
* Prefer this over #BONDING_STYLE_BOND
|
|
*/
|
|
int BONDING_STYLE_ASK = 2;
|
|
|
|
/**
|
|
* 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.
|
|
*
|
|
* @param candidate
|
|
* @return true if this coordinator handles the given candidate.
|
|
*/
|
|
boolean supports(GBDeviceCandidate candidate);
|
|
|
|
/**
|
|
* Checks whether this candidate handles the given device.
|
|
*
|
|
* @param device
|
|
* @return true if this coordinator handles the given device.
|
|
*/
|
|
boolean supports(GBDevice device);
|
|
|
|
/**
|
|
* 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();
|
|
|
|
GBDevice createDevice(GBDeviceCandidate candidate);
|
|
|
|
/**
|
|
* Deletes all information, including all related database content about the
|
|
* given device.
|
|
* @throws GBException
|
|
*/
|
|
void deleteDevice(GBDevice device) throws GBException;
|
|
|
|
/**
|
|
* Returns the kind of device type this coordinator supports.
|
|
*
|
|
* @return
|
|
*/
|
|
DeviceType getDeviceType();
|
|
|
|
/**
|
|
* Returns the Activity class to be started in order to perform a pairing of a
|
|
* given device after its discovery.
|
|
*
|
|
* @return the activity class for pairing/initial authentication, or null if none
|
|
*/
|
|
@Nullable
|
|
Class<? extends Activity> getPairingActivity();
|
|
|
|
/**
|
|
* Returns the Activity class that will be used as the primary activity
|
|
* for the given device.
|
|
*
|
|
* @return the primary activity class, or null if none
|
|
*/
|
|
@Nullable
|
|
Class<? extends Activity> getPrimaryActivity();
|
|
|
|
/**
|
|
* Returns true if activity data fetching is supported by the device
|
|
* (with this coordinator).
|
|
*
|
|
* @return
|
|
*/
|
|
boolean supportsActivityDataFetching();
|
|
|
|
/**
|
|
* Returns true if activity tracking is supported by the device
|
|
* (with this coordinator).
|
|
*
|
|
* @return
|
|
*/
|
|
boolean supportsActivityTracking();
|
|
|
|
/**
|
|
* 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.
|
|
*
|
|
* @param device
|
|
* @return
|
|
*/
|
|
boolean allowFetchActivityData(GBDevice device);
|
|
|
|
/**
|
|
* Returns the sample provider for the device being supported.
|
|
*
|
|
* @return
|
|
*/
|
|
SampleProvider<? extends ActivitySample> getSampleProvider(GBDevice device, DaoSession session);
|
|
|
|
/**
|
|
* Finds an install handler for the given uri that can install the given
|
|
* uri on the device being managed.
|
|
*
|
|
* @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);
|
|
|
|
/**
|
|
* Returns true if this device/coordinator supports taking screenshots.
|
|
*
|
|
* @return
|
|
*/
|
|
boolean supportsScreenshots();
|
|
|
|
/**
|
|
* Returns true if this device/coordinator supports setting alarms.
|
|
*
|
|
* @return
|
|
*/
|
|
boolean supportsAlarmConfiguration();
|
|
|
|
/**
|
|
* Returns true if this device/coordinator supports alarms with smart wakeup
|
|
* @return
|
|
*/
|
|
boolean supportsSmartWakeup(GBDevice device);
|
|
|
|
/**
|
|
* Returns true if the given device supports heart rate measurements.
|
|
* @return
|
|
*/
|
|
boolean supportsHeartRateMeasurement(GBDevice device);
|
|
|
|
/**
|
|
* Returns the readable name of the manufacturer.
|
|
*/
|
|
String getManufacturer();
|
|
|
|
/**
|
|
* 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();
|
|
|
|
/**
|
|
* Returns how/if the given device should be bonded before connecting to it.
|
|
* @param device
|
|
*/
|
|
int getBondingStyle(GBDevice device);
|
|
|
|
/**
|
|
* Indicates whether the device has some kind of calender we can sync to.
|
|
* Also used for generated sunrise/sunset events
|
|
*/
|
|
boolean supportsCalendarEvents();
|
|
|
|
/**
|
|
* Indicates whether the device supports getting a stream of live data.
|
|
* This can be live HR, steps etc.
|
|
*/
|
|
boolean supportsRealtimeData();
|
|
}
|