74 lines
2.6 KiB
Java
74 lines
2.6 KiB
Java
/* Copyright (C) 2022 José Rebelo
|
|
|
|
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.huami.amazfittrex2;
|
|
|
|
import android.bluetooth.BluetoothDevice;
|
|
import android.content.Context;
|
|
import android.net.Uri;
|
|
|
|
import androidx.annotation.NonNull;
|
|
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
import nodomain.freeyourgadget.gadgetbridge.devices.huami.Huami2021Coordinator;
|
|
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
|
|
import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate;
|
|
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.AbstractHuami2021FWInstallHandler;
|
|
|
|
public class AmazfitTRex2Coordinator extends Huami2021Coordinator {
|
|
private static final Logger LOG = LoggerFactory.getLogger(AmazfitTRex2Coordinator.class);
|
|
|
|
@NonNull
|
|
@Override
|
|
public DeviceType getSupportedType(final GBDeviceCandidate candidate) {
|
|
try {
|
|
final BluetoothDevice device = candidate.getDevice();
|
|
final String name = device.getName();
|
|
if (name != null && name.startsWith(HuamiConst.AMAZFIT_TREX_2_NAME)) {
|
|
return DeviceType.AMAZFITTREX2;
|
|
}
|
|
} catch (final Exception e) {
|
|
LOG.error("unable to check device support", e);
|
|
}
|
|
|
|
return DeviceType.UNKNOWN;
|
|
}
|
|
|
|
@Override
|
|
public DeviceType getDeviceType() {
|
|
return DeviceType.AMAZFITTREX2;
|
|
}
|
|
|
|
@Override
|
|
public AbstractHuami2021FWInstallHandler findInstallHandler(final Uri uri, final Context context) {
|
|
final AmazfitTRex2FWInstallHandler handler = new AmazfitTRex2FWInstallHandler(uri, context);
|
|
return handler.isValid() ? handler : null;
|
|
}
|
|
|
|
@Override
|
|
public boolean supportsControlCenter() {
|
|
return true;
|
|
}
|
|
|
|
@Override
|
|
public boolean supportsToDoList() {
|
|
return true;
|
|
}
|
|
}
|