1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-12-01 06:22:55 +01:00

Merge branch 'master' into zetime

This commit is contained in:
Sebastian Kranz 2018-07-10 06:48:20 +02:00
commit 7d8d484133
18 changed files with 171 additions and 38 deletions

View File

@ -1,5 +1,12 @@
### Changelog
#### Version 0.27.1
* Pebble: Change appstore search to point to RomanPort's pebble appstore
* Mi Band 3: Allow flashing fonts (untested)
* Amazfit Bip: Allow flashing latest firmwares
* Amazfit Cor: Allow flashing Bip fonts (untested)
* Allow to limit auto fetch to a user configurable time interval
#### Version 0.27.0
* Initial support for Mi Band 3 (largely untested, needs to be connected to Mi Fit once)
* Option for automatic activity sync after screen unlock

View File

@ -25,8 +25,8 @@ android {
targetSdkVersion 27
// Note: always bump BOTH versionCode and versionName!
versionName "0.27.0"
versionCode 132
versionName "0.27.1"
versionCode 133
vectorDrawables.useSupportLibrary = true
}
buildTypes {

View File

@ -447,6 +447,10 @@ public class DiscoveryActivity extends AbstractGBActivity implements AdapterView
LOG.warn("could not get BluetoothLeScanner()!");
return;
}
if (newLeScanCallback == null) {
LOG.warn("newLeScanCallback == null!");
return;
}
bluetoothLeScanner.stopScan(newLeScanCallback);
}

View File

@ -326,6 +326,26 @@ public class SettingsActivity extends AbstractSettingsActivity {
}
});
pref = findPreference("auto_fetch_interval_limit");
pref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object autoFetchInterval) {
String summary = String.format(
getApplicationContext().getString(R.string.pref_auto_fetch_limit_fetches_summary),
Integer.valueOf((String) autoFetchInterval));
preference.setSummary(summary);
return true;
}
});
int autoFetchInterval = GBApplication.getPrefs().getInt("auto_fetch_interval_limit", 0);
summary = String.format(
getApplicationContext().getString(R.string.pref_auto_fetch_limit_fetches_summary),
(int) autoFetchInterval);
pref.setSummary(summary);
final Preference displayPages = findPreference("bip_display_items");
displayPages.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override

View File

@ -85,11 +85,11 @@ class ActivityAnalysis {
}
if (!stats.containsKey(steps)) {
LOG.info("Adding: " + steps);
// LOG.debug("Adding: " + steps);
stats.put(steps, timeDifference);
} else {
long time = stats.get(steps);
LOG.info("Updating: " + steps + " " + timeDifference + time);
// LOG.debug("Updating: " + steps + " " + timeDifference + time);
stats.put(steps, timeDifference + time);
}
}

View File

@ -680,7 +680,7 @@ public class DeviceCommunicationService extends Service implements SharedPrefere
}
}
if (GBApplication.getPrefs().getBoolean("auto_fetch_enabled", false) &&
coordinator != null && coordinator.supportsActivityDataFetching()) {
coordinator != null && coordinator.supportsActivityDataFetching() && mGBAutoFetchReceiver == null) {
mGBAutoFetchReceiver = new GBAutoFetchReceiver();
registerReceiver(mGBAutoFetchReceiver, new IntentFilter("android.intent.action.USER_PRESENT"));
}

View File

@ -48,6 +48,8 @@ public abstract class HuamiFirmwareInfo {
0x4e, 0x45, 0x5a, 0x4b
};
protected static final int FONT_TYPE_OFFSET = 0x9;
private HuamiFirmwareType firmwareType = HuamiFirmwareType.FIRMWARE;
public String toVersion(int crc16) {
@ -172,4 +174,25 @@ public abstract class HuamiFirmwareInfo {
return null;
}
protected boolean searchString32BitAligned(byte[] fwbytes, String findString) {
ByteBuffer stringBuf = ByteBuffer.wrap((findString + "\0").getBytes());
stringBuf.order(ByteOrder.BIG_ENDIAN);
int[] findArray = new int[stringBuf.remaining() / 4];
for (int i = 0; i < findArray.length; i++) {
findArray[i] = stringBuf.getInt();
}
ByteBuffer buf = ByteBuffer.wrap(fwbytes);
buf.order(ByteOrder.BIG_ENDIAN);
while (buf.remaining() > 3) {
int arrayPos = 0;
while (arrayPos < findArray.length && buf.remaining() > 3 && (buf.getInt() == findArray[arrayPos])) {
arrayPos++;
}
if (arrayPos == findArray.length) {
return true;
}
}
return false;
}
}

View File

@ -24,7 +24,6 @@ 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;
import nodomain.freeyourgadget.gadgetbridge.util.Version;
public class AmazfitBipFirmwareInfo extends HuamiFirmwareInfo {
// gps detection is totally bogus, just the first 16 bytes
@ -93,6 +92,7 @@ public class AmazfitBipFirmwareInfo extends HuamiFirmwareInfo {
crcToVersion.put(11062, "0.1.1.39");
crcToVersion.put(56670, "0.1.1.41");
crcToVersion.put(58736, "0.1.1.45");
crcToVersion.put(2602, "1.0.2.00");
// resources
crcToVersion.put(12586, "0.0.8.74");
@ -114,6 +114,7 @@ public class AmazfitBipFirmwareInfo extends HuamiFirmwareInfo {
crcToVersion.put(14334, "0.1.1.39");
crcToVersion.put(21109, "0.1.1.41");
crcToVersion.put(23073, "0.1.1.45");
crcToVersion.put(59245, "1.0.2.00");
// gps
crcToVersion.put(61520, "9367,8f79a91,0,0,");
@ -148,12 +149,8 @@ public class AmazfitBipFirmwareInfo extends HuamiFirmwareInfo {
return HuamiFirmwareType.GPS_CEP;
}
if (ArrayUtils.startsWith(bytes, FW_HEADER)) {
String foundVersion = searchFirmwareVersion(bytes);
if (foundVersion != null) {
Version version = new Version(foundVersion);
if ((version.compareTo(new Version("0.0.8.00")) >= 0) && (version.compareTo(new Version("1.0.0.00")) < 0)) {
return HuamiFirmwareType.FIRMWARE;
}
if (searchString32BitAligned(bytes, "Amazfit Bip Watch")) {
return HuamiFirmwareType.FIRMWARE;
}
return HuamiFirmwareType.INVALID;
}

View File

@ -454,7 +454,7 @@ public class AmazfitBipSupport extends MiBand2Support {
builder.add(new ConditionalWriteAction(getCharacteristic(MiBand2Service.UUID_CHARACTERISTIC_3_CONFIGURATION)) {
@Override
protected byte[] checkCondition() {
if (gbDevice.getType() == DeviceType.AMAZFITBIP && new Version(gbDevice.getFirmwareVersion()).compareTo(new Version("0.1.0.77")) >= 0) {
if (gbDevice.getType() == DeviceType.MIBAND3 || (gbDevice.getType() == DeviceType.AMAZFITBIP && new Version(gbDevice.getFirmwareVersion()).compareTo(new Version("0.1.0.77")) >= 0)) {
return command_new;
} else {
return command_old;

View File

@ -24,7 +24,6 @@ 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;
import nodomain.freeyourgadget.gadgetbridge.util.Version;
public class AmazfitCorFirmwareInfo extends HuamiFirmwareInfo {
// this is the same as Bip
@ -50,6 +49,10 @@ public class AmazfitCorFirmwareInfo extends HuamiFirmwareInfo {
crcToVersion.put(64977, "RES 1.0.6.76");
crcToVersion.put(60501, "RES 1.0.7.52-71");
crcToVersion.put(31263, "RES 1.0.7.77-91");
// font
crcToVersion.put(61054, "8");
crcToVersion.put(62291, "9 (Latin)");
}
public AmazfitCorFirmwareInfo(byte[] bytes) {
@ -68,19 +71,21 @@ public class AmazfitCorFirmwareInfo extends HuamiFirmwareInfo {
return HuamiFirmwareType.RES_COMPRESSED;
}
if (ArrayUtils.startsWith(bytes, FW_HEADER)) {
String foundVersion = searchFirmwareVersion(bytes);
if (foundVersion != null) {
Version version = new Version(foundVersion);
if ((version.compareTo(new Version("1.0.5.00")) >= 0) && (version.compareTo(new Version("2.0.0.00")) < 0)) {
return HuamiFirmwareType.FIRMWARE;
}
if (searchString32BitAligned(bytes, "Amazfit Cor")) {
return HuamiFirmwareType.FIRMWARE;
}
return HuamiFirmwareType.INVALID;
}
if (ArrayUtils.startsWith(bytes, WATCHFACE_HEADER)) {
return HuamiFirmwareType.WATCHFACE;
}
if (ArrayUtils.startsWith(bytes, NEWFT_HEADER)) {
if (bytes[10] == 0x01) {
return HuamiFirmwareType.FONT;
} else if (bytes[10] == 0x02) {
return HuamiFirmwareType.FONT_LATIN;
}
}
return HuamiFirmwareType.INVALID;
}

View File

@ -78,8 +78,11 @@ public class Mi2FirmwareInfo extends HuamiFirmwareInfo {
}
protected HuamiFirmwareType determineFirmwareType(byte[] bytes) {
if (ArrayUtils.startsWith(bytes, HuamiFirmwareInfo.FT_HEADER)) {
return HuamiFirmwareType.FONT;
if (ArrayUtils.startsWith(bytes, FT_HEADER)) {
if (bytes[FONT_TYPE_OFFSET] == 0x00 || bytes[FONT_TYPE_OFFSET] == (byte) 0xff) {
return HuamiFirmwareType.FONT;
}
return HuamiFirmwareType.INVALID;
}
if (ArrayUtils.equals(bytes, FW_HEADER, FW_HEADER_OFFSET)
&& (bytes[FW_MAGIC_OFFSET] == FW_MAGIC)) {

View File

@ -53,6 +53,12 @@ public class MiBand3FirmwareInfo extends HuamiFirmwareInfo {
@Override
protected HuamiFirmwareType determineFirmwareType(byte[] bytes) {
if (ArrayUtils.startsWith(bytes, FT_HEADER)) {
if (bytes[FONT_TYPE_OFFSET] == 0x03 || bytes[FONT_TYPE_OFFSET] == 0x04) {
return HuamiFirmwareType.FONT;
}
return HuamiFirmwareType.INVALID;
}
if (ArrayUtils.startsWith(bytes, RES_HEADER)) {
if (bytes.length > 100000) { // don't know how to distinguish from Bip/Cor .res
return HuamiFirmwareType.INVALID;

View File

@ -20,20 +20,22 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.commons.lang3.time.DateUtils;
import java.util.Date;
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
import nodomain.freeyourgadget.gadgetbridge.model.RecordedDataTypes;
public class GBAutoFetchReceiver extends BroadcastReceiver {
private static final Logger LOG = LoggerFactory.getLogger(GBAutoFetchReceiver.class);
private Date lastSync = new Date();
@Override
public void onReceive(Context context, Intent intent) {
//LOG.info("User is present!");
GBApplication.deviceService().onFetchRecordedData(RecordedDataTypes.TYPE_ACTIVITY);
Date nextSync = DateUtils.addMinutes(lastSync, GBApplication.getPrefs().getInt("auto_fetch_interval_limit", 0));
if (nextSync.before(new Date())) {
GBApplication.deviceService().onFetchRecordedData(RecordedDataTypes.TYPE_ACTIVITY);
lastSync = new Date();
}
}
}

View File

@ -404,14 +404,14 @@
\nNota: Non è necessario installare i file .res e .gps se questi sono gli stessi della versione precedentemente installata.
\n
\nPROCEDI A TUO RISCHIO E PERICOLO!</string>
<string name="fw_upgrade_notice_amazfitcor">Si sta per installare il firmware %s sul Amazfit Cor.
\n
\nSi prega di installare prima il file .fw e successivamente il file .res. Il tuo smartwatch si riavvierà dopo l\'installazione del file .fw.
\n
\nNOTA: Non è necessario installare il file .res se risulta essere uguale a quello precedentemente installato.
\n
\nNON TESTATO: PROCEDI A TUO RISCHIO E PERICOLO!</string>
<string name="pref_title_charts_swipe">Abilit swipe Sinistra/Destra nel grafico delle attività</string>
<string name="fw_upgrade_notice_amazfitcor">Si sta per installare il firmware %s sul Amazfit Cor.
\n
\nSi prega di installare prima il file .fw e successivamente il file .res. Il tuo smartwatch si riavvierà dopo l\'installazione del file .fw.
\n
\nNOTA: Non è necessario installare il file .res se risulta essere uguale a quello precedentemente installato.
\n
\nPROCEDI A TUO RISCHIO E PERICOLO!</string>
<string name="pref_title_charts_swipe">Abilita swipe Sinistra/Destra nel grafico delle attività</string>
<string name="pref_title_weather">Meteo</string>
<string name="pref_title_weather_location">Posizione meteo (CM/LOS)</string>
@ -501,4 +501,49 @@
<string name="devicetype_xwatch">XWatch</string>
<string name="on">Acceso</string>
</resources>
<string name="blacklist_all_for_notifications">Blocca le notifiche da tutte le applicazioni</string>
<string name="whitelist_all_for_notifications">Consenti le notifiche da tutte le applicazioni</string>
<string name="fw_upgrade_notice_miband3">Si sta per installare il firmware %s sul Mi Band 3.
\n
\nSi prega di installare prima il file .fw e successivamente il file .res. Il tuo Miband si riavvierà dopo l\'installazione del file .fw.
\n
\nNOTA: Non è necessario installare il file .res se risulta essere uguale a quello precedentemente installato.
\n
\nNON TESTATO, POTREBBE DANNEGGIARE IL DISPOSITIVO IN MANIERA IRREVERSIBILE, PROCEDI A TUO RISCHIO E PERICOLO!</string>
<string name="pref_title_pebble_gatt_clientonly">Modalità GATT client</string>
<string name="pref_summary_pebble_gatt_clientonly">Sperimentale, compatibile solo con Pebble 2, attivare solo in caso di problemi di connettività</string>
<string name="pref_auto_fetch">"Recupero automatico dati delle attività"</string>
<string name="pref_auto_fetch_summary">Il recupero avviene quando lo schermo viene sbloccato. Funziona solo se è attivata una modalità di blocco!</string>
<string name="controlcenter_start_activity_tracks">Traccia delle tua attività</string>
<string name="activity_type_not_measured">Non misurato</string>
<string name="activity_type_activity">Attività</string>
<string name="activity_type_light_sleep">Sonno leggero</string>
<string name="activity_type_deep_sleep">Sonno profondo</string>
<string name="activity_type_not_worn">Device non indossato</string>
<string name="activity_type_running">Corsa</string>
<string name="activity_type_walking">Camminata</string>
<string name="activity_type_swimming">Nuoto</string>
<string name="activity_type_unknown">Attività sconosciuta</string>
<string name="activity_summaries">Attività</string>
<string name="activity_type_biking">Bicicletta</string>
<string name="activity_type_treadmill">Tapis roulant</string>
<string name="select_all">Seleziona tutto</string>
<string name="share">Condividi</string>
<string name="reset_index">Reset data di recupero</string>
<string name="devicetype_miband3">Mi Band 3</string>
<string name="devicetype_q8">Q8</string>
<string name="menuitem_shortcut_alipay">Alipay (Scorciatoia)</string>
<string name="menuitem_shortcut_weather">Meteo (Scorciatoia)</string>
<string name="menuitem_status">Status</string>
<string name="menuitem_activity">Attività</string>
<string name="menuitem_weather">Meteo</string>
<string name="menuitem_alarm">Allarmi</string>
<string name="menuitem_timer">Timer</string>
<string name="menuitem_compass">Bussola</string>
<string name="menuitem_settings">Impostazioni</string>
<string name="menuitem_alipay">Alipay</string>
</resources>

View File

@ -202,6 +202,8 @@
<!-- Auto fetch activity preferences -->
<string name="pref_auto_fetch">Auto fetch activity data</string>
<string name="pref_auto_fetch_summary">Fetch happens upon screen unlock. Only works if a lock mechanism is set!</string>
<string name="pref_auto_fetch_limit_fetches">Minimum time between fetches</string>
<string name="pref_auto_fetch_limit_fetches_summary">Fetches every %d minutes</string>
<string name="not_connected">Not connected</string>
<string name="connecting">Connecting</string>

View File

@ -1,5 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<changelog>
<release version="0.27.1" versioncode="133">
<change>Pebble: Change appstore search to point to RomanPort's pebble appstore</change>
<change>Mi Band 3: Allow flashing fonts (untested)</change>
<change>Amazfit Bip: Allow flashing latest firmwares</change>
<change>Amazfit Cor: Allow flashing Bip fonts (untested)</change>
<change>Allow to limit auto fetch to a user configurable time interval</change>
</release>
<release version="0.27.0" versioncode="132">
<change>Initial support for Mi Band 3 (largely untested, needs to be connected to Mi Fit once)</change>
<change>Option for automatic activity sync after screen unlock</change>

View File

@ -535,6 +535,13 @@
android:key="auto_fetch_enabled"
android:title="@string/pref_auto_fetch"
android:summary="@string/pref_auto_fetch_summary"/>
<EditTextPreference
android:inputType="number"
android:key="auto_fetch_interval_limit"
android:defaultValue="0"
android:maxLength="3"
android:title="@string/pref_auto_fetch_limit_fetches"
android:summary="@string/pref_auto_fetch_limit_fetches_summary"/>
</PreferenceCategory>
<PreferenceCategory

View File

@ -0,0 +1,5 @@
* Pebble: Change appstore search to point to RomanPort's pebble appstore
* Mi Band 3: Allow flashing fonts (untested)
* Amazfit Bip: Allow flashing latest firmwares
* Amazfit Cor: Allow flashing Bip fonts (untested)
* Allow to limit auto fetch to a user configurable time interval