This repository has been archived by the owner. It is now read-only.
Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Mi Band 3: add untested and incomplete support
This also improves firmware/RES probing to distinguish Mi Band 2/3 firmware files and Mi Band 3/Bip RES files. Notes: - Firmware flashing should might but is untested - This basicall runs off the Amazfit Bip code which will probably incorrect (Mi Band 3 is proabably something between the Bip and the Mi Band 2)
- Loading branch information
Showing
with
364 additions
and 67 deletions.
- +5 −0 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/HuamiConst.java
- +1 −1 ...c/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitbip/AmazfitBipFWHelper.java
- +2 −4 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/miband2/MiBand2Coordinator.java
- +1 −1 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/miband2/MiBand2FWHelper.java
- +1 −1 ...main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/miband2/MiBand2FWInstallHandler.java
- +2 −1 ...c/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/miband2/MiBand2HRXCoordinator.java
- +75 −0 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/miband3/MiBand3Coordinator.java
- +40 −0 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/miband3/MiBand3FWHelper.java
- +49 −0 .../main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/miband3/MiBand3WInstallHandler.java
- +0 −2 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/miband/MiBandConst.java
- +1 −0 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/DeviceType.java
- +6 −2 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/DeviceSupportFactory.java
- +3 −3 ...eyourgadget/gadgetbridge/service/devices/{miband2/BatteryInfo.java → huami/HuamiBatteryInfo.java}
- +1 −1 ...main/freeyourgadget/gadgetbridge/service/devices/{ → huami}/amazfitbip/ActivityDetailsParser.java
- +3 −3 ...ain/freeyourgadget/gadgetbridge/service/devices/{ → huami}/amazfitbip/AmazfitBipFirmwareInfo.java
- +5 −5 ...nodomain/freeyourgadget/gadgetbridge/service/devices/{ → huami}/amazfitbip/AmazfitBipSupport.java
- +3 −4 ...gadget/gadgetbridge/service/devices/{ → huami}/amazfitbip/AmazfitBipTextNotificationStrategy.java
- +1 −1 ...a/nodomain/freeyourgadget/gadgetbridge/service/devices/{ → huami}/amazfitbip/BipActivityType.java
- +3 −3 ...t/gadgetbridge/service/devices/{ → huami}/amazfitbip/operations/AmazfitBipFetchLogsOperation.java
- +1 −1 ...java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitcor/AmazfitCorSupport.java
- +1 −1 ...main/freeyourgadget/gadgetbridge/service/devices/{ → huami}/miband2/AbstractMiBand2Operation.java
- +6 −2 ...java/nodomain/freeyourgadget/gadgetbridge/service/devices/{ → huami}/miband2/Mi2FirmwareInfo.java
- +1 −1 ...omain/freeyourgadget/gadgetbridge/service/devices/{ → huami}/miband2/Mi2NotificationStrategy.java
- +1 −1 ...n/freeyourgadget/gadgetbridge/service/devices/{ → huami}/miband2/Mi2TextNotificationStrategy.java
- +8 −7 .../java/nodomain/freeyourgadget/gadgetbridge/service/devices/{ → huami}/miband2/MiBand2Support.java
- +1 −1 ...reeyourgadget/gadgetbridge/service/devices/{ → huami}/miband2/actions/StopNotificationAction.java
- +3 −3 ...yourgadget/gadgetbridge/service/devices/{ → huami}/miband2/operations/AbstractFetchOperation.java
- +2 −2 ...yourgadget/gadgetbridge/service/devices/{ → huami}/miband2/operations/FetchActivityOperation.java
- +3 −3 ...adget/gadgetbridge/service/devices/{ → huami}/miband2/operations/FetchSportsDetailsOperation.java
- +3 −3 ...adget/gadgetbridge/service/devices/{ → huami}/miband2/operations/FetchSportsSummaryOperation.java
- +2 −2 ...main/freeyourgadget/gadgetbridge/service/devices/{ → huami}/miband2/operations/InitOperation.java
- +3 −5 ...ourgadget/gadgetbridge/service/devices/{ → huami}/miband2/operations/UpdateFirmwareOperation.java
- +85 −0 .../java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/miband3/MiBand3FirmwareInfo.java
- +34 −0 .../main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/miband3/MiBand3Support.java
- +2 −0 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/DeviceHelper.java
- +2 −0 app/src/main/res/drawable/level_list_device.xml
- +3 −1 app/src/main/res/values/strings.xml
- +1 −2 app/src/test/java/nodomain/freeyourgadget/gadgetbridge/test/ActivityDetailsParserTest.java
@@ -0,0 +1,75 @@ | ||
/* Copyright (C) 2016-2018 Andreas Shimokawa, Carsten Pfeiffer, 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.miband3; | ||
|
||
import android.bluetooth.BluetoothDevice; | ||
import android.content.Context; | ||
import android.net.Uri; | ||
import android.support.annotation.NonNull; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler; | ||
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst; | ||
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiCoordinator; | ||
import nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBand2Service; | ||
import nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst; | ||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; | ||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate; | ||
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; | ||
|
||
public class MiBand3Coordinator extends HuamiCoordinator { | ||
private static final Logger LOG = LoggerFactory.getLogger(MiBand3Coordinator.class); | ||
|
||
@Override | ||
public DeviceType getDeviceType() { | ||
return DeviceType.MIBAND3; | ||
} | ||
|
||
@NonNull | ||
@Override | ||
public DeviceType getSupportedType(GBDeviceCandidate candidate) { | ||
try { | ||
BluetoothDevice device = candidate.getDevice(); | ||
String name = device.getName(); | ||
if (name != null && name.equalsIgnoreCase(HuamiConst.MI_BAND3_NAME)) { | ||
return DeviceType.MIBAND3; | ||
} | ||
} catch (Exception ex) { | ||
LOG.error("unable to check device support", ex); | ||
} | ||
return DeviceType.UNKNOWN; | ||
|
||
} | ||
|
||
@Override | ||
public InstallHandler findInstallHandler(Uri uri, Context context) { | ||
MiBand3FWInstallHandler handler = new MiBand3FWInstallHandler(uri, context); | ||
return handler.isValid() ? handler : null; | ||
} | ||
|
||
@Override | ||
public boolean supportsHeartRateMeasurement(GBDevice device) { | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean supportsWeather() { | ||
return true; | ||
} | ||
} |
@@ -0,0 +1,40 @@ | ||
/* Copyright (C) 2017-2018 Andreas Shimokawa, Carsten Pfeiffer | ||
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.miband3; | ||
|
||
import android.content.Context; | ||
import android.net.Uri; | ||
|
||
import java.io.IOException; | ||
|
||
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; | ||
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.miband3.MiBand3FirmwareInfo; | ||
|
||
public class MiBand3FWHelper extends HuamiFWHelper { | ||
|
||
public MiBand3FWHelper(Uri uri, Context context) throws IOException { | ||
super(uri, context); | ||
} | ||
|
||
@Override | ||
protected void determineFirmwareInfo(byte[] wholeFirmwareBytes) { | ||
firmwareInfo = new MiBand3FirmwareInfo(wholeFirmwareBytes); | ||
if (!firmwareInfo.isHeaderValid()) { | ||
throw new IllegalArgumentException("Not a Mi Band 3 firmware"); | ||
} | ||
} | ||
} |
@@ -0,0 +1,49 @@ | ||
/* Copyright (C) 2015-2018 Andreas Shimokawa, Carsten Pfeiffer | ||
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.miband3; | ||
|
||
import android.content.Context; | ||
import android.net.Uri; | ||
|
||
import java.io.IOException; | ||
|
||
import nodomain.freeyourgadget.gadgetbridge.R; | ||
import nodomain.freeyourgadget.gadgetbridge.devices.miband.AbstractMiBandFWHelper; | ||
import nodomain.freeyourgadget.gadgetbridge.devices.miband.AbstractMiBandFWInstallHandler; | ||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; | ||
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; | ||
|
||
class MiBand3FWInstallHandler extends AbstractMiBandFWInstallHandler { | ||
MiBand3FWInstallHandler(Uri uri, Context context) { | ||
super(uri, context); | ||
} | ||
|
||
@Override | ||
protected String getFwUpgradeNotice() { | ||
return mContext.getString(R.string.fw_upgrade_notice_miband3, helper.getHumanFirmwareVersion()); | ||
} | ||
|
||
@Override | ||
protected AbstractMiBandFWHelper createHelper(Uri uri, Context context) throws IOException { | ||
return new MiBand3FWHelper(uri, context); | ||
} | ||
|
||
@Override | ||
protected boolean isSupportedDeviceType(GBDevice device) { | ||
return device.getType() == DeviceType.MIBAND3; | ||
} | ||
} |
Oops, something went wrong.