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

Made the firmware version extraction a bit more robust and added annotations to keep data classes after optimizations

This commit is contained in:
TaaviE 2021-05-29 15:01:35 +03:00
parent 348f459e3f
commit 0b021d72ab
2 changed files with 15 additions and 3 deletions

View File

@ -16,24 +16,30 @@
along with this program. If not, see <https://www.gnu.org/licenses/>. */ along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.pinetime; package nodomain.freeyourgadget.gadgetbridge.devices.pinetime;
import androidx.annotation.Keep;
import java.math.BigInteger; import java.math.BigInteger;
import java.util.List; import java.util.List;
@Keep
public class InfiniTimeDFUPackage { public class InfiniTimeDFUPackage {
InfiniTimeDFUPackageManifest manifest; InfiniTimeDFUPackageManifest manifest;
} }
@Keep
class InfiniTimeDFUPackageManifest { class InfiniTimeDFUPackageManifest {
InfiniTimeDFUPackageApplication application; InfiniTimeDFUPackageApplication application;
Float dfu_version; Float dfu_version;
} }
@Keep
class InfiniTimeDFUPackageApplication { class InfiniTimeDFUPackageApplication {
String bin_file; String bin_file;
String dat_file; String dat_file;
InfiniTimeDFUPackagePacketData init_packet_data; InfiniTimeDFUPackagePacketData init_packet_data;
} }
@Keep
class InfiniTimeDFUPackagePacketData { class InfiniTimeDFUPackagePacketData {
BigInteger application_version; BigInteger application_version;
BigInteger device_revision; BigInteger device_revision;

View File

@ -16,6 +16,8 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. */ along with this program. If not, see <http://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.pinetime; package nodomain.freeyourgadget.gadgetbridge.devices.pinetime;
import static java.nio.charset.StandardCharsets.UTF_8;
import android.content.Context; import android.content.Context;
import android.net.Uri; import android.net.Uri;
import android.os.Build; import android.os.Build;
@ -38,8 +40,6 @@ import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
import nodomain.freeyourgadget.gadgetbridge.model.GenericItem; import nodomain.freeyourgadget.gadgetbridge.model.GenericItem;
import nodomain.freeyourgadget.gadgetbridge.util.UriHelper; import nodomain.freeyourgadget.gadgetbridge.util.UriHelper;
import static java.nio.charset.StandardCharsets.UTF_8;
public class PineTimeInstallHandler implements InstallHandler { public class PineTimeInstallHandler implements InstallHandler {
private static final Logger LOG = LoggerFactory.getLogger(PineTimeInstallHandler.class); private static final Logger LOG = LoggerFactory.getLogger(PineTimeInstallHandler.class);
@ -92,9 +92,15 @@ public class PineTimeInstallHandler implements InstallHandler {
return; return;
} }
if (metadata != null) { if (metadata != null &&
metadata.manifest != null &&
metadata.manifest.application != null &&
metadata.manifest.application.bin_file != null) {
valid = true; valid = true;
version = metadata.manifest.application.bin_file; version = metadata.manifest.application.bin_file;
} else {
valid = false;
LOG.error("Somehow metadata was found, but some data was missing");
} }
} }