1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-07-24 23:53:39 +02:00
Gadgetbridge/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/adapter/WatchAdapterFactory.java

42 lines
2.1 KiB
Java
Raw Normal View History

2021-01-10 23:37:09 +01:00
/* Copyright (C) 2019-2021 Daniel Dakhno
2019-12-06 22:49:44 +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/>. */
2019-10-24 19:44:35 +02:00
package nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.adapter;
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.QHybridSupport;
2019-10-27 23:24:02 +01:00
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.adapter.fossil.FossilWatchAdapter;
2019-12-15 14:58:19 +01:00
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.adapter.fossil_hr.FossilHRWatchAdapter;
2019-10-24 19:44:35 +02:00
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.adapter.misfit.MisfitWatchAdapter;
public final class WatchAdapterFactory {
public final WatchAdapter createWatchAdapter(String firmwareVersion, QHybridSupport deviceSupport){
2019-12-15 14:58:19 +01:00
char hardwareVersion = firmwareVersion.charAt(2);
if(hardwareVersion == '1') return new FossilHRWatchAdapter(deviceSupport);
if(firmwareVersion.startsWith("IV0")) return new FossilHRWatchAdapter(deviceSupport);
if(firmwareVersion.startsWith("VA")) return new FossilHRWatchAdapter(deviceSupport);
if(firmwareVersion.startsWith("WA")) return new FossilHRWatchAdapter(deviceSupport);
2019-12-15 14:58:19 +01:00
2019-10-24 19:44:35 +02:00
char major = firmwareVersion.charAt(6);
switch (major){
2019-12-15 14:58:19 +01:00
case '0': return new MisfitWatchAdapter(deviceSupport);
2019-10-25 19:13:55 +02:00
case '1': return new MisfitWatchAdapter(deviceSupport);
2019-10-27 23:24:02 +01:00
case '2': return new FossilWatchAdapter(deviceSupport);
2019-10-24 19:44:35 +02:00
}
throw new UnsupportedOperationException("Firmware " + firmwareVersion + " not supported");
}
}