1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-04 09:17:29 +01:00

Merge branch 'master' of github.com:Freeyourgadget/Gadgetbridge into fossil-q-hybrid

This commit is contained in:
dakhnod 2019-07-25 11:12:50 +02:00
commit ef692498af
16 changed files with 223 additions and 18 deletions

View File

@ -1,5 +1,8 @@
### Changelog
#### Version 0.35.0
* Mi Band 4: Initial support (WARNING: INITIAL SETUP NEEDS MI FIT WITH ACCOUNT AND ROOT, NOT A RECOMMENDED DEVICE FOR GADGETBRIDGE)
#### Version 0.34.1
* Mi Band 1: Fix crash when entering per-device settings
* Mi Band 3: Allow setting date format in per-device settings

View File

@ -41,6 +41,7 @@ vendor's servers.
* Mi Band, Mi Band 1A, Mi Band 1S [Wiki](https://codeberg.org/Freeyourgadget/Gadgetbridge/wiki/Mi-Band)
* Mi Band 2 [Wiki](https://codeberg.org/Freeyourgadget/Gadgetbridge/wiki/Mi-Band-2)
* Mi Band 3 [Wiki](https://codeberg.org/Freeyourgadget/Gadgetbridge/wiki/Mi-Band-3)
* Mi Band 4 (WIP, NOT RECOMMENDED, NEEDS MI FIT WITH ACCOUNT AND ROOT ONCE) [Wiki](https://codeberg.org/Freeyourgadget/Gadgetbridge/wiki/Mi-Band-4)
* Mi Scale 2 (currently only displays a toast after stepping on the scale)
* NO.1 F1 (WIP)
* Pebble, Pebble Steel, Pebble Time, Pebble Time Steel, Pebble Time Round [Wiki](https://codeberg.org/Freeyourgadget/Gadgetbridge/wiki/Pebble)

View File

@ -25,8 +25,8 @@ android {
targetSdkVersion 27
// Note: always bump BOTH versionCode and versionName!
versionName "0.34.1"
versionCode 151
versionName "0.35.0"
versionCode 152
vectorDrawables.useSupportLibrary = true
}
buildTypes {

View File

@ -57,9 +57,11 @@ public class MiBand4Coordinator extends HuamiCoordinator {
}
@Override
public InstallHandler findInstallHandler(Uri uri, Context context) {
return null;
MiBand4FWInstallHandler handler = new MiBand4FWInstallHandler(uri, context);
return handler.isValid() ? handler : null;
}
@Override

View File

@ -0,0 +1,40 @@
/* Copyright (C) 2017-2019 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.miband4;
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.miband4.MiBand4FirmwareInfo;
public class MiBand4FWHelper extends HuamiFWHelper {
public MiBand4FWHelper(Uri uri, Context context) throws IOException {
super(uri, context);
}
@Override
protected void determineFirmwareInfo(byte[] wholeFirmwareBytes) {
firmwareInfo = new MiBand4FirmwareInfo(wholeFirmwareBytes);
if (!firmwareInfo.isHeaderValid()) {
throw new IllegalArgumentException("Not a Mi Band 4 firmware");
}
}
}

View File

@ -0,0 +1,50 @@
/* Copyright (C) 2015-2019 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.miband4;
import android.content.Context;
import android.net.Uri;
import java.io.IOException;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.miband3.MiBand3FWHelper;
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 MiBand4FWInstallHandler extends AbstractMiBandFWInstallHandler {
MiBand4FWInstallHandler(Uri uri, Context context) {
super(uri, context);
}
@Override
protected String getFwUpgradeNotice() {
return mContext.getString(R.string.fw_upgrade_notice_miband4, helper.getHumanFirmwareVersion());
}
@Override
protected AbstractMiBandFWHelper createHelper(Uri uri, Context context) throws IOException {
return new MiBand4FWHelper(uri, context);
}
@Override
protected boolean isSupportedDeviceType(GBDevice device) {
return device.getType() == DeviceType.MIBAND4;
}
}

View File

@ -49,6 +49,8 @@ public abstract class HuamiFirmwareInfo {
};
protected static final int FONT_TYPE_OFFSET = 0x9;
protected static final int COMPRESSED_RES_HEADER_OFFSET = 0x9;
protected static final int COMPRESSED_RES_HEADER_OFFSET_NEW = 0xd;
private HuamiFirmwareType firmwareType;

View File

@ -44,6 +44,7 @@ import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiWeatherConditions
import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitbip.AmazfitBipFWHelper;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitbip.AmazfitBipService;
import nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.model.CallSpec;
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
import nodomain.freeyourgadget.gadgetbridge.model.NotificationSpec;
@ -136,16 +137,25 @@ public class AmazfitBipSupport extends HuamiSupport {
appSuffix = appName.getBytes();
suffixlength = appSuffix.length;
}
if (gbDevice.getType() == DeviceType.MIBAND4) {
prefixlength += 4;
}
byte[] rawmessage = message.getBytes();
int length = Math.min(rawmessage.length, maxLength - prefixlength);
byte[] command = new byte[length + prefixlength + suffixlength];
command[0] = (byte) alertCategory.getId();
command[1] = 1;
int pos = 0;
command[pos++] = (byte) alertCategory.getId();
if (gbDevice.getType() == DeviceType.MIBAND4) {
command[pos++] = 0; // TODO
command[pos++] = 0;
command[pos++] = 0;
command[pos++] = 0;
}
command[pos++] = 1;
if (alertCategory == AlertCategory.CustomHuami) {
command[2] = customIconId;
command[pos] = customIconId;
}
System.arraycopy(rawmessage, 0, command, prefixlength, length);

View File

@ -31,9 +31,6 @@ public class AmazfitCor2FirmwareInfo extends HuamiFirmwareInfo {
0x00, (byte) 0x98, 0x00, 0x20, (byte) 0xA5, 0x04, 0x00, 0x20, (byte) 0xAD, 0x04, 0x00, 0x20, (byte) 0xC5, 0x04, 0x00, 0x20
};
private static final int COMPRESSED_RES_HEADER_OFFSET = 0x9;
private static final int COMPRESSED_RES_HEADER_OFFSET_NEW = 0xd;
private static Map<Integer, String> crcToVersion = new HashMap<>();
static {

View File

@ -0,0 +1,89 @@
/* Copyright (C) 2017-2019 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.service.devices.huami.miband4;
import java.util.HashMap;
import java.util.Map;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.HuamiFirmwareInfo;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.HuamiFirmwareType;
import nodomain.freeyourgadget.gadgetbridge.util.ArrayUtils;
public class MiBand4FirmwareInfo extends HuamiFirmwareInfo {
private static final byte[] FW_HEADER = new byte[]{
0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, (byte) 0x9c, (byte) 0xe3, 0x7d, 0x5c, 0x00, 0x04
};
private static final int FW_HEADER_OFFSET = 16;
private static Map<Integer, String> crcToVersion = new HashMap<>();
static {
// firmware
crcToVersion.put(8969, "1.0.5.22");
// resources
crcToVersion.put(27412, "1.0.5.22");
// font
crcToVersion.put(31978, "1");
}
public MiBand4FirmwareInfo(byte[] bytes) {
super(bytes);
}
@Override
protected HuamiFirmwareType determineFirmwareType(byte[] bytes) {
if (ArrayUtils.equals(bytes, RES_HEADER, COMPRESSED_RES_HEADER_OFFSET) || ArrayUtils.equals(bytes, NEWRES_HEADER, COMPRESSED_RES_HEADER_OFFSET_NEW) || ArrayUtils.equals(bytes, NEWRES_HEADER, COMPRESSED_RES_HEADER_OFFSET)) {
return HuamiFirmwareType.RES_COMPRESSED;
}
if (ArrayUtils.equals(bytes, FW_HEADER, FW_HEADER_OFFSET)) {
if (searchString32BitAligned(bytes, "Mi Smart Band 4")) {
return HuamiFirmwareType.FIRMWARE;
}
return HuamiFirmwareType.INVALID;
}
if (ArrayUtils.startsWith(bytes, WATCHFACE_HEADER)) {
return HuamiFirmwareType.WATCHFACE;
}
if (ArrayUtils.startsWith(bytes, NEWFT_HEADER)) {
if (bytes[10] == 0x03) {
return HuamiFirmwareType.FONT;
}
}
// somebody might have unpacked the compressed res
if (ArrayUtils.startsWith(bytes, RES_HEADER)) {
return HuamiFirmwareType.RES;
}
return HuamiFirmwareType.INVALID;
}
@Override
public boolean isGenerallyCompatibleWith(GBDevice device) {
return isHeaderValid() && device.getType() == DeviceType.MIBAND4;
}
@Override
protected Map<Integer, String> getCrcMap() {
return crcToVersion;
}
}

View File

@ -22,6 +22,7 @@ import android.net.Uri;
import java.io.IOException;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.miband4.MiBand4FWHelper;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.miband3.MiBand3Support;
public class MiBand4Support extends MiBand3Support {
@ -33,6 +34,6 @@ public class MiBand4Support extends MiBand3Support {
@Override
public HuamiFWHelper createFWHelper(Uri uri, Context context) throws IOException {
return null;
return new MiBand4FWHelper(uri, context);
}
}

View File

@ -8,7 +8,7 @@
<string name="action_donate">Donació</string>
<string name="controlcenter_fetch_activity_data">Sincronitza</string>
<string name="controlcenter_start_sleepmonitor">Seguiment del son (ALPHA)</string>
<string name="controlcenter_find_device">Cerca un dispositiu perdut</string>
<string name="controlcenter_find_device">Cerca un aparell perdut</string>
<string name="controlcenter_take_screenshot">Fes una captura de pantalla</string>
<string name="controlcenter_connect">Connecta…</string>
<string name="controlcenter_disconnect">Desconnecta</string>
@ -170,9 +170,9 @@
<string name="this_is_a_test_notification_from_gadgetbridge">Això és una notificació de prova des del Gadgetbridge</string>
<string name="bluetooth_is_not_supported_">El Bluetooth no és compatible o no està implementat.</string>
<string name="bluetooth_is_disabled_">El Bluetooth està desactivat.</string>
<string name="tap_connected_device_for_app_mananger">Toca el dispositiu connectat per obrir el gestor d\'aplicacions</string>
<string name="tap_connected_device_for_activity">Toca el dispositiu connectat per gestionar-ne l\'activitat</string>
<string name="tap_connected_device_for_vibration">Toca el dispositiu per fer-lo vibrar</string>
<string name="tap_connected_device_for_app_mananger">Toca l\'aparell connectat per obrir el gestor d\'aplicacions</string>
<string name="tap_connected_device_for_activity">Toca l\'aparell connectat per gestionar-ne l\'activitat</string>
<string name="tap_connected_device_for_vibration">Toca l\'aparell per fer-lo vibrar</string>
<string name="tap_a_device_to_connect">Toca un aparell per connectar-hi</string>
<string name="cannot_connect_bt_address_invalid_">No es pot connectar. Potser la direcció Bluetooth és incorrecta\?</string>
<string name="gadgetbridge_running">El Gadgetbridge està funcionant</string>
@ -290,11 +290,11 @@
<string name="weekstepschart_steps_a_week">Passes per setmana</string>
<string name="activity_sleepchart_activity_and_sleep">La vostra activitat i el vostre son</string>
<string name="updating_firmware">El microprogramari s\'està instal·lant…</string>
<string name="fwapp_install_device_not_ready">No es pot instal·lar el fitxer. El dispositiu no està preparat.</string>
<string name="fwapp_install_device_not_ready">No es pot instal·lar el fitxer. L\'aparell no està preparat.</string>
<string name="installhandler_firmware_name">%1$s: %2$s %3$s</string>
<string name="miband_fwinstaller_compatible_version">Versió compatible</string>
<string name="miband_fwinstaller_untested_version">Versió no provada!</string>
<string name="fwappinstaller_connection_state">Connexió a dispositiu: %1$s</string>
<string name="fwappinstaller_connection_state">Connexió a l\'aparell: %1$s</string>
<string name="pbw_installhandler_pebble_firmware">Microprogramari Pebble %1$s</string>
<string name="pbwinstallhandler_correct_hw_revision">Revisió del maquinari correcta</string>
<string name="pbwinstallhandler_incorrect_hw_revision">La revisió del maquinari no coincideix!</string>

View File

@ -710,4 +710,5 @@
<string name="vietnamese">Vietnamsky</string>
<string name="portuguese">Portugalsky</string>
<string name="devicetype_amazfit_cor2">Amazfit Cor 2</string>
<string name="devicetype_miband4">Mi Band 4</string>
</resources>

View File

@ -57,7 +57,8 @@
<string name="fw_upgrade_notice_amazfitbip">You are about to install the %s firmware on your Amazfit Bip.\n\nPlease make sure to install the .fw file, then the .res file, and finally the .gps file. Your watch will reboot after installing the .fw file.\n\nNote: You do not have to install .res and .gps if these files are exactly the same as the ones previously installed.\n\nPROCEED AT YOUR OWN RISK!</string>
<string name="fw_upgrade_notice_amazfitcor">You are about to install the %s firmware on your Amazfit Cor.\n\nPlease make sure to install the .fw file, and after that the .res file. Your band will reboot after installing the .fw file.\n\nNote: You do not have to install .res if it is exactly the same as the one previously installed.\n\nPROCEED AT YOUR OWN RISK!</string>
<string name="fw_upgrade_notice_amazfitcor2">You are about to install the %s firmware on your Amazfit Cor 2.\n\nPlease make sure to install the .fw file, and after that the .res file. Your band will reboot after installing the .fw file.\n\nNote: You do not have to install .res if it is exactly the same as the one previously installed.\n\nPROCEED AT YOUR OWN RISK!\n\nCOMPLETELY UNTESTED, PROBABLY YOU NEED TO FLASH A BEATS_W FIRMWARE IF YOUR DEVICE NAME is \"Amazfit Band 2\!"</string>
<string name="fw_upgrade_notice_miband3">You are about to install the %s firmware on your Mi Band 3.\n\nPlease make sure to install the .fw file, and after that the .res file. Your watch will reboot after installing the .fw file.\n\nNote: You do not have to install .res if it is exactly the same as the one previously installed.\n\nPROCEED AT YOUR OWN RISK!</string>
<string name="fw_upgrade_notice_miband3">You are about to install the %s firmware on your Mi Band 3.\n\nPlease make sure to install the .fw file, and after that the .res file. Your band will reboot after installing the .fw file.\n\nNote: You do not have to install .res if it is exactly the same as the one previously installed.\n\nPROCEED AT YOUR OWN RISK!</string>
<string name="fw_upgrade_notice_miband4">You are about to install the %s firmware on your Mi Band 4.\n\nPlease make sure to install the .fw file, and after that the .res file. Your band will reboot after installing the .fw file.\n\nNote: You do not have to install .res if it is exactly the same as the one previously installed.\n\nPROCEED AT YOUR OWN RISK!</string>
<string name="fw_multi_upgrade_notice">You are about to install the %1$s and %2$s firmware, instead of the ones currently on your Mi Band.</string>
<string name="miband_firmware_known">This firmware has been tested and is known to be compatible with Gadgetbridge.</string>
<string name="miband_firmware_unknown_warning">"This firmware is untested and may not be compatible with Gadgetbridge.\n\nYou are DISCOURAGED from flashing it!"</string>
@ -225,6 +226,10 @@
<string name="pref_title_authkey">Auth Key</string>
<string name="pref_summary_authkey">Change the auth key to a common key on all your Android devices from which you would like to connect from. The previous default key for all devices is 0123456789@ABCDE</string>
<string name="prefs_hr_alarm_activity">Heart rate alarm during sports activity</string>
<string name="prefs_hr_alarm_low">Low limit</string>
<string name="prefs_hr_alarm_high">High limit</string>
<!-- Auto export preferences -->
<string name="pref_header_auto_export">Auto export</string>
<string name="pref_title_auto_export_enabled">Auto export enabled</string>

View File

@ -1,5 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<changelog>
<release version="0.35.0" versioncode="152">
<change>Mi Band 4: Initial support (WARNING: INITIAL SETUP NEEDS MI FIT WITH ACCOUNT AND ROOT, NOT A RECOMMENDED DEVICE FOR GADGETBRIDGE)</change>
</release>
<release version="0.34.1" versioncode="151">
<change>Mi Band 1: Fix crash when entering per-device settings</change>
<change>Mi Band 3: Allow setting date format in per-device settings</change>

View File

@ -0,0 +1 @@
* Mi Band 4: Initial support (WARNING: INITIAL SETUP NEEDS MI FIT WITH ACCOUNT AND ROOT, NOT A RECOMMENDED DEVICE FOR GADGETBRIDGE)