1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-24 02:46:50 +01:00

Xiaomi-protobuf: Enable install handler for all devices

This commit is contained in:
José Rebelo 2024-09-20 18:10:55 +01:00
parent 00f8d2259f
commit 409a296666
16 changed files with 9 additions and 233 deletions

View File

@ -21,6 +21,7 @@ import static nodomain.freeyourgadget.gadgetbridge.service.devices.xiaomi.Xiaomi
import android.app.Activity;
import android.bluetooth.le.ScanFilter;
import android.content.Context;
import android.net.Uri;
import android.os.ParcelUuid;
import androidx.annotation.NonNull;
@ -46,6 +47,7 @@ import nodomain.freeyourgadget.gadgetbridge.capabilities.HeartRateCapability;
import nodomain.freeyourgadget.gadgetbridge.capabilities.password.PasswordCapabilityImpl;
import nodomain.freeyourgadget.gadgetbridge.capabilities.widgets.WidgetManager;
import nodomain.freeyourgadget.gadgetbridge.devices.AbstractBLEDeviceCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
import nodomain.freeyourgadget.gadgetbridge.devices.SampleProvider;
import nodomain.freeyourgadget.gadgetbridge.devices.TimeSampleProvider;
import nodomain.freeyourgadget.gadgetbridge.entities.DaoSession;
@ -97,6 +99,13 @@ public abstract class XiaomiCoordinator extends AbstractBLEDeviceCoordinator {
|| AUTH_KEY_PATTERN.matcher(authKey.trim()).matches();
}
@Nullable
@Override
public InstallHandler findInstallHandler(final Uri uri, final Context context) {
final XiaomiInstallHandler handler = new XiaomiInstallHandler(uri, context);
return handler.isValid() ? handler : null;
}
@Override
protected void deleteDevice(@NonNull final GBDevice gbDevice,
@NonNull final Device device,

View File

@ -16,18 +16,11 @@
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.miband7pro;
import android.content.Context;
import android.net.Uri;
import androidx.annotation.Nullable;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
import nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.XiaomiCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.XiaomiInstallHandler;
public class MiBand7ProCoordinator extends XiaomiCoordinator {
@Override
@ -40,13 +33,6 @@ public class MiBand7ProCoordinator extends XiaomiCoordinator {
return Pattern.compile(HuamiConst.XIAOMI_SMART_BAND7_PRO_NAME + ".*");
}
@Nullable
@Override
public InstallHandler findInstallHandler(final Uri uri, final Context context) {
final XiaomiInstallHandler handler = new XiaomiInstallHandler(uri, context);
return handler.isValid() ? handler : null;
}
@Override
public int getDeviceNameResource() {
return R.string.devicetype_miband7pro;

View File

@ -16,17 +16,10 @@
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.miband8;
import android.content.Context;
import android.net.Uri;
import androidx.annotation.Nullable;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
import nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.XiaomiCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.XiaomiInstallHandler;
public class MiBand8Coordinator extends XiaomiCoordinator {
@Override
@ -39,13 +32,6 @@ public class MiBand8Coordinator extends XiaomiCoordinator {
return Pattern.compile("^Xiaomi Smart Band 8 [A-Z0-9]{4}$");
}
@Nullable
@Override
public InstallHandler findInstallHandler(final Uri uri, final Context context) {
final XiaomiInstallHandler handler = new XiaomiInstallHandler(uri, context);
return handler.isValid() ? handler : null;
}
@Override
public int getDeviceNameResource() {
return R.string.devicetype_miband8;
@ -60,22 +46,4 @@ public class MiBand8Coordinator extends XiaomiCoordinator {
public int getDisabledIconResource() {
return R.drawable.ic_device_miband6_disabled;
}
@Override
public boolean supportsActivityDataFetching() {
// FIXME still has some issues
return true;
}
@Override
public boolean supportsActivityTracking() {
// FIXME still has some issues
return true;
}
@Override
public boolean supportsActivityTracks() {
// FIXME still has some issues
return true;
}
}

View File

@ -16,17 +16,10 @@
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.miband8active;
import android.content.Context;
import android.net.Uri;
import androidx.annotation.Nullable;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
import nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.XiaomiCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.XiaomiInstallHandler;
public class MiBand8ActiveCoordinator extends XiaomiCoordinator {
@Override
@ -39,13 +32,6 @@ public class MiBand8ActiveCoordinator extends XiaomiCoordinator {
return Pattern.compile("^Xiaomi( Smart)? Band 8 Active [A-Z0-9]{4}$");
}
@Nullable
@Override
public InstallHandler findInstallHandler(final Uri uri, final Context context) {
final XiaomiInstallHandler handler = new XiaomiInstallHandler(uri, context);
return handler.isValid() ? handler : null;
}
@Override
public int getDeviceNameResource() {
return R.string.devicetype_miband8active;
@ -60,22 +46,4 @@ public class MiBand8ActiveCoordinator extends XiaomiCoordinator {
public int getDisabledIconResource() {
return R.drawable.ic_device_default_disabled;
}
@Override
public boolean supportsActivityDataFetching() {
// FIXME still has some issues
return true;
}
@Override
public boolean supportsActivityTracking() {
// FIXME still has some issues
return true;
}
@Override
public boolean supportsActivityTracks() {
// FIXME still has some issues
return true;
}
}

View File

@ -16,17 +16,10 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.miband8pro;
import android.content.Context;
import android.net.Uri;
import androidx.annotation.Nullable;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
import nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.XiaomiCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.XiaomiInstallHandler;
public class MiBand8ProCoordinator extends XiaomiCoordinator {
@Override
@ -49,12 +42,6 @@ public class MiBand8ProCoordinator extends XiaomiCoordinator {
return ConnectionType.BT_CLASSIC;
}
@Nullable
@Override
public InstallHandler findInstallHandler(final Uri uri, final Context context) {
final XiaomiInstallHandler handler = new XiaomiInstallHandler(uri, context);
return handler.isValid() ? handler : null;
}
@Override
public int getDefaultIconResource() {

View File

@ -16,17 +16,10 @@
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.miwatch;
import android.content.Context;
import android.net.Uri;
import androidx.annotation.Nullable;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
import nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.XiaomiCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.XiaomiInstallHandler;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
public class MiWatchLiteCoordinator extends XiaomiCoordinator {
@ -40,13 +33,6 @@ public class MiWatchLiteCoordinator extends XiaomiCoordinator {
return Pattern.compile("^Mi Watch Lite_[A-Z0-9]{4}$");
}
@Nullable
@Override
public InstallHandler findInstallHandler(final Uri uri, final Context context) {
final XiaomiInstallHandler handler = new XiaomiInstallHandler(uri, context);
return handler.isValid() ? handler : null;
}
@Override
public int getDeviceNameResource() {
return R.string.devicetype_xiaomi_watch_lite;

View File

@ -16,17 +16,10 @@
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.miwatchcolorsport;
import android.content.Context;
import android.net.Uri;
import androidx.annotation.Nullable;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
import nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.XiaomiCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.XiaomiInstallHandler;
public class MiWatchColorSportCoordinator extends XiaomiCoordinator {
@ -45,13 +38,6 @@ public class MiWatchColorSportCoordinator extends XiaomiCoordinator {
return true;
}
@Nullable
@Override
public InstallHandler findInstallHandler(Uri uri, Context context) {
final XiaomiInstallHandler handler = new XiaomiInstallHandler(uri, context);
return handler.isValid() ? handler : null;
}
@Override
public int getDefaultIconResource() {
return R.drawable.ic_device_miwatch;

View File

@ -16,17 +16,10 @@
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.redmismartband2;
import android.content.Context;
import android.net.Uri;
import androidx.annotation.Nullable;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
import nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.XiaomiCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.XiaomiInstallHandler;
public class RedmiSmartBand2Coordinator extends XiaomiCoordinator {
@Override
@ -39,13 +32,6 @@ public class RedmiSmartBand2Coordinator extends XiaomiCoordinator {
return Pattern.compile("^Redmi Smart Band 2 [A-Z0-9]{4}$");
}
@Nullable
@Override
public InstallHandler findInstallHandler(final Uri uri, final Context context) {
final XiaomiInstallHandler handler = new XiaomiInstallHandler(uri, context);
return handler.isValid() ? handler : null;
}
@Override
public int getDeviceNameResource() {
return R.string.devicetype_redmi_smart_band_2;

View File

@ -16,18 +16,11 @@
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.redmismartbandpro;
import android.content.Context;
import android.net.Uri;
import androidx.annotation.Nullable;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.capabilities.password.PasswordCapabilityImpl;
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
import nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.XiaomiCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.XiaomiInstallHandler;
public class RedmiSmartBandProCoordinator extends XiaomiCoordinator {
@Override
@ -40,13 +33,6 @@ public class RedmiSmartBandProCoordinator extends XiaomiCoordinator {
return Pattern.compile("^Redmi Band Pro [A-Z0-9]{4}$");
}
@Nullable
@Override
public InstallHandler findInstallHandler(final Uri uri, final Context context) {
final XiaomiInstallHandler handler = new XiaomiInstallHandler(uri, context);
return handler.isValid() ? handler : null;
}
@Override
public int getDeviceNameResource() {
return R.string.devicetype_redmi_smart_band_pro;

View File

@ -16,17 +16,10 @@
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.redmiwatch2;
import android.content.Context;
import android.net.Uri;
import androidx.annotation.Nullable;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
import nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.XiaomiCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.XiaomiInstallHandler;
public class RedmiWatch2Coordinator extends XiaomiCoordinator {
@Override
@ -39,13 +32,6 @@ public class RedmiWatch2Coordinator extends XiaomiCoordinator {
return Pattern.compile("^Redmi Watch 2 [A-Z0-9]{4}$");
}
@Nullable
@Override
public InstallHandler findInstallHandler(final Uri uri, final Context context) {
final XiaomiInstallHandler handler = new XiaomiInstallHandler(uri, context);
return handler.isValid() ? handler : null;
}
@Override
public int getDeviceNameResource() {
return R.string.devicetype_redmi_watch_2;

View File

@ -16,17 +16,10 @@
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.redmiwatch2lite;
import android.content.Context;
import android.net.Uri;
import androidx.annotation.Nullable;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
import nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.XiaomiCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.XiaomiInstallHandler;
public class RedmiWatch2LiteCoordinator extends XiaomiCoordinator {
@Override
@ -39,13 +32,6 @@ public class RedmiWatch2LiteCoordinator extends XiaomiCoordinator {
return Pattern.compile("^Redmi Watch 2 Lite [A-Z0-9]{4}$");
}
@Nullable
@Override
public InstallHandler findInstallHandler(final Uri uri, final Context context) {
final XiaomiInstallHandler handler = new XiaomiInstallHandler(uri, context);
return handler.isValid() ? handler : null;
}
@Override
public int getDeviceNameResource() {
return R.string.devicetype_redmi_watch_2_lite;

View File

@ -16,17 +16,10 @@
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.redmiwatch3;
import android.content.Context;
import android.net.Uri;
import androidx.annotation.Nullable;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
import nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.XiaomiCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.XiaomiInstallHandler;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
public class RedmiWatch3Coordinator extends XiaomiCoordinator {
@ -45,13 +38,6 @@ public class RedmiWatch3Coordinator extends XiaomiCoordinator {
return Pattern.compile("^Redmi Watch 3 [A-Z0-9]{4}$");
}
@Nullable
@Override
public InstallHandler findInstallHandler(final Uri uri, final Context context) {
final XiaomiInstallHandler handler = new XiaomiInstallHandler(uri, context);
return handler.isValid() ? handler : null;
}
@Override
public int getDeviceNameResource() {
return R.string.devicetype_redmiwatch3;

View File

@ -16,17 +16,10 @@
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.redmiwatch3active;
import android.content.Context;
import android.net.Uri;
import androidx.annotation.Nullable;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
import nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.XiaomiCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.XiaomiInstallHandler;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
public class RedmiWatch3ActiveCoordinator extends XiaomiCoordinator {
@ -45,13 +38,6 @@ public class RedmiWatch3ActiveCoordinator extends XiaomiCoordinator {
return Pattern.compile("^Redmi Watch 3 Active [A-Z0-9]{4}$");
}
@Nullable
@Override
public InstallHandler findInstallHandler(final Uri uri, final Context context) {
final XiaomiInstallHandler handler = new XiaomiInstallHandler(uri, context);
return handler.isValid() ? handler : null;
}
@Override
public int getDeviceNameResource() {
return R.string.devicetype_redmiwatch3active;

View File

@ -16,20 +16,12 @@
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.redmiwatch4;
import android.content.Context;
import android.net.Uri;
import androidx.annotation.Nullable;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
import nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.XiaomiCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.XiaomiInstallHandler;
public class RedmiWatch4Coordinator extends XiaomiCoordinator {
@Override
public int getDeviceNameResource() {
return R.string.devicetype_redmi_watch_4;
@ -52,14 +44,6 @@ public class RedmiWatch4Coordinator extends XiaomiCoordinator {
return ConnectionType.BT_CLASSIC;
}
@Nullable
@Override
public InstallHandler findInstallHandler(Uri uri, Context context) {
final XiaomiInstallHandler handler = new XiaomiInstallHandler(uri, context);
return handler.isValid() ? handler : null;
}
@Override
public int getDefaultIconResource() {
return R.drawable.ic_device_amazfit_bip;

View File

@ -26,7 +26,6 @@ import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
import nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.XiaomiCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.XiaomiInstallHandler;
public class XiaomiWatchS1ActiveCoordinator extends XiaomiCoordinator {
@ -55,14 +54,6 @@ public class XiaomiWatchS1ActiveCoordinator extends XiaomiCoordinator {
return false;
}
@Nullable
@Override
public InstallHandler findInstallHandler(Uri uri, Context context) {
final XiaomiInstallHandler handler = new XiaomiInstallHandler(uri, context);
return handler.isValid() ? handler : null;
}
@Override
public int getDefaultIconResource() {
return R.drawable.ic_device_miwatch;

View File

@ -52,9 +52,4 @@ public class XiaomiWatchS3Coordinator extends XiaomiCoordinator {
public boolean isExperimental() {
return true;
}
@Override
public boolean supportsFindDevice() {
return false;
}
}