2021-01-10 23:37:09 +01:00
|
|
|
/* Copyright (C) 2015-2021 Andreas Shimokawa, Carsten Pfeiffer, Daniele
|
|
|
|
Gobbetti, Dmitry Markin, JohnnySun, José Rebelo, Matthieu Baerts, Nephiel,
|
|
|
|
Uwe Hermann
|
2017-03-10 14:53:19 +01:00
|
|
|
|
|
|
|
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/>. */
|
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;
|
|
|
|
|
2021-05-29 16:42:32 +02:00
|
|
|
import java.io.File;
|
|
|
|
import java.io.IOException;
|
2016-11-27 01:09:20 +01:00
|
|
|
import java.util.Collection;
|
2015-05-05 00:48:02 +02:00
|
|
|
|
2019-01-26 15:52:40 +01:00
|
|
|
import androidx.annotation.NonNull;
|
|
|
|
import androidx.annotation.Nullable;
|
2016-10-24 20:02:44 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.GBException;
|
2021-11-28 01:34:29 +01:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSpecificSettingsCustomizer;
|
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;
|
2021-10-31 17:36:04 +01:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.model.BatteryConfig;
|
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";
|
2017-04-06 23:47:35 +02:00
|
|
|
/**
|
|
|
|
* 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;
|
2015-05-05 00:48:02 +02:00
|
|
|
|
2019-10-12 19:44:45 +02:00
|
|
|
/**
|
|
|
|
* A secret key has to be entered before connecting
|
|
|
|
*/
|
|
|
|
int BONDING_STYLE_REQUIRE_KEY = 3;
|
|
|
|
|
2021-09-23 07:09:15 +02:00
|
|
|
/**
|
|
|
|
* Lazy pairing, i.e. device initiated pairing is requested
|
|
|
|
*/
|
|
|
|
int BONDING_STYLE_LAZY = 4;
|
|
|
|
|
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
|
|
|
|
2020-05-24 23:25:52 +02:00
|
|
|
@Nullable
|
|
|
|
Class<? extends Activity> getCalibrationActivity();
|
|
|
|
|
2015-10-26 23:32:03 +01:00
|
|
|
/**
|
|
|
|
* Returns true if activity data fetching is supported by the device
|
|
|
|
* (with this coordinator).
|
2021-11-18 16:00:46 +01:00
|
|
|
* This enables the sync button in control center and the device can thus be asked to send the data
|
|
|
|
* (as opposed the device pushing the data to us by itself)
|
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).
|
2021-11-18 16:00:46 +01:00
|
|
|
* This enables the ChartsActivity.
|
2016-09-20 22:02:40 +02:00
|
|
|
*
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
boolean supportsActivityTracking();
|
|
|
|
|
2017-10-19 21:52:38 +02:00
|
|
|
/**
|
|
|
|
* Indicates whether the device supports recording dedicated activity tracks, like
|
|
|
|
* walking, hiking, running, swimming, etc. and retrieving the recorded
|
|
|
|
* data. This is different from the constant activity tracking since the tracks are
|
|
|
|
* usually recorded with additional features, like e.g. GPS.
|
|
|
|
*/
|
|
|
|
boolean supportsActivityTracks();
|
|
|
|
|
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
|
|
|
|
2018-11-24 12:16:47 +01:00
|
|
|
/**
|
|
|
|
* Returns the number of alarms this device/coordinator supports
|
2019-01-11 23:26:00 +01:00
|
|
|
* Shall return 0 also if it is not possible to set alarms via
|
|
|
|
* protocol, but only on the smart device itself.
|
2018-11-24 12:16:47 +01:00
|
|
|
*
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
int getAlarmSlotCount();
|
|
|
|
|
2017-01-26 20:55:00 +01:00
|
|
|
/**
|
|
|
|
* Returns true if this device/coordinator supports alarms with smart wakeup
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
boolean supportsSmartWakeup(GBDevice device);
|
|
|
|
|
2020-01-12 08:12:21 +01:00
|
|
|
/**
|
|
|
|
* Returns true if this device/coordinator supports alarm snoozing
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
boolean supportsAlarmSnoozing();
|
|
|
|
|
2020-04-24 10:39:32 +02:00
|
|
|
/**
|
|
|
|
* Returns true if this device/coordinator supports alarm descriptions
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
boolean supportsAlarmDescription(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-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();
|
2017-04-06 23:47:35 +02:00
|
|
|
|
2021-06-20 14:17:18 +02:00
|
|
|
/**
|
|
|
|
* Returns the Activity class that will be used to design watchfaces.
|
|
|
|
*
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
Class<? extends Activity> getWatchfaceDesignerActivity();
|
|
|
|
|
2021-05-29 16:42:32 +02:00
|
|
|
/**
|
|
|
|
* Returns the device app cache directory.
|
|
|
|
*/
|
|
|
|
File getAppCacheDir() throws IOException;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a String containing the device app sort order filename.
|
|
|
|
*/
|
|
|
|
String getAppCacheSortFilename();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a String containing the file extension for watch apps.
|
|
|
|
*/
|
|
|
|
String getAppFileExtension();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Indicated whether the device supports fetching a list of its apps.
|
|
|
|
*/
|
|
|
|
boolean supportsAppListFetching();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Indicates whether the device supports reordering of apps.
|
|
|
|
*/
|
|
|
|
boolean supportsAppReordering();
|
|
|
|
|
2017-04-06 23:47:35 +02:00
|
|
|
/**
|
|
|
|
* Returns how/if the given device should be bonded before connecting to it.
|
|
|
|
*/
|
2019-10-12 19:44:45 +02:00
|
|
|
int getBondingStyle();
|
2017-04-19 21:51:23 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Indicates whether the device has some kind of calender we can sync to.
|
|
|
|
* Also used for generated sunrise/sunset events
|
|
|
|
*/
|
|
|
|
boolean supportsCalendarEvents();
|
|
|
|
|
2017-06-02 21:59:46 +02:00
|
|
|
/**
|
|
|
|
* Indicates whether the device supports getting a stream of live data.
|
|
|
|
* This can be live HR, steps etc.
|
|
|
|
*/
|
|
|
|
boolean supportsRealtimeData();
|
2017-12-11 19:09:37 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Indicates whether the device supports current weather and/or weather
|
|
|
|
* forecast display.
|
|
|
|
*/
|
|
|
|
boolean supportsWeather();
|
2018-07-26 21:57:12 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Indicates whether the device supports being found by vibrating,
|
|
|
|
* making some sound or lighting up
|
|
|
|
*/
|
|
|
|
boolean supportsFindDevice();
|
2018-08-07 12:44:00 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Indicates whether the device supports displaying music information
|
|
|
|
* like artist, title, album, play state etc.
|
|
|
|
*/
|
|
|
|
boolean supportsMusicInfo();
|
2018-07-28 17:23:58 +02:00
|
|
|
|
2021-12-04 16:55:09 +01:00
|
|
|
/**
|
|
|
|
* Indicates the maximum reminder message length.
|
|
|
|
*/
|
|
|
|
int getMaximumReminderMessageLength();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Indicates the maximum number of reminder slots available in the device.
|
|
|
|
*/
|
|
|
|
int getReminderSlotCount();
|
|
|
|
|
2022-05-09 20:47:08 +02:00
|
|
|
/**
|
|
|
|
* Indicates the maximum number of slots available for world clocks in the device.
|
|
|
|
*/
|
|
|
|
int getWorldClocksSlotCount();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Indicates the maximum label length for a world clock in the device.
|
|
|
|
*/
|
|
|
|
int getWorldClocksLabelLength();
|
|
|
|
|
2018-07-28 17:23:58 +02:00
|
|
|
/**
|
|
|
|
* Indicates whether the device has an led which supports custom colors
|
|
|
|
*/
|
|
|
|
boolean supportsLedColor();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Indicates whether the device's led supports any RGB color,
|
|
|
|
* or only preset colors
|
|
|
|
*/
|
|
|
|
boolean supportsRgbLedColor();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the preset colors supported by the device, if any, in ARGB, with alpha = 255
|
|
|
|
*/
|
|
|
|
@NonNull
|
|
|
|
int[] getColorPresets();
|
2018-11-25 23:56:52 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Indicates whether the device supports unicode emojis.
|
|
|
|
*/
|
|
|
|
boolean supportsUnicodeEmojis();
|
2019-04-21 15:59:39 +02:00
|
|
|
|
|
|
|
/**
|
2019-05-22 00:42:22 +02:00
|
|
|
* Indicates which device specific settings the device supports (not per device type or family, but unique per device).
|
2019-04-21 15:59:39 +02:00
|
|
|
*/
|
2019-05-22 00:42:22 +02:00
|
|
|
int[] getSupportedDeviceSpecificSettings(GBDevice device);
|
2021-10-07 14:32:09 +02:00
|
|
|
|
2021-11-28 01:34:29 +01:00
|
|
|
/**
|
|
|
|
* Returns the {@link DeviceSpecificSettingsCustomizer}, allowing for the customization of the devices specific settings screen.
|
|
|
|
*/
|
|
|
|
DeviceSpecificSettingsCustomizer getDeviceSpecificSettingsCustomizer(GBDevice device);
|
|
|
|
|
2021-10-07 14:32:09 +02:00
|
|
|
/**
|
|
|
|
* Indicates which device specific language the device supports
|
|
|
|
*/
|
|
|
|
String[] getSupportedLanguageSettings(GBDevice device);
|
|
|
|
|
2021-10-16 22:40:30 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* Multiple battery support: Indicates how many batteries the device has.
|
|
|
|
* 1 is default, 3 is maximum at the moment (as per UI layout)
|
|
|
|
* 0 will disable the battery from the UI
|
|
|
|
*/
|
|
|
|
int getBatteryCount();
|
|
|
|
|
2021-10-31 17:36:04 +01:00
|
|
|
BatteryConfig[] getBatteryConfig();
|
|
|
|
|
2021-12-24 15:20:57 +01:00
|
|
|
boolean supportsPowerOff();
|
2015-05-05 00:48:02 +02:00
|
|
|
}
|