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

Garmin: Allow install agps for sony cpe url

This commit is contained in:
José Rebelo 2024-05-31 20:15:15 +01:00
parent 29a10cab59
commit 64258248b6
2 changed files with 10 additions and 0 deletions

View File

@ -82,6 +82,11 @@ public class AgpsHandler {
reportError(request.getUrl()); reportError(request.getUrl());
return null; return null;
} }
} else if (request.getPath().startsWith(("/ephemeris/cpe/sony"))) {
if (!garminAgpsFile.isValidSonyCpe()) {
reportError(request.getUrl());
return null;
}
} else { } else {
LOG.warn("Refusing to send agps for unknown url"); LOG.warn("Refusing to send agps for unknown url");
return null; return null;

View File

@ -19,6 +19,7 @@ public class GarminAgpsFile {
public static final byte[] GZ_HEADER = new byte[]{(byte) 0x1f, (byte) 0x8b}; public static final byte[] GZ_HEADER = new byte[]{(byte) 0x1f, (byte) 0x8b};
public static final byte[] CPE_RXNETWORKS_HEADER = new byte[]{(byte) 0x01, (byte) 0x00, (byte) 0x66}; public static final byte[] CPE_RXNETWORKS_HEADER = new byte[]{(byte) 0x01, (byte) 0x00, (byte) 0x66};
public static final byte[] CPE_SONY_HEADER = new byte[]{(byte) 0x2a, (byte) 0x12, (byte) 0xa0, (byte) 0x02};
public GarminAgpsFile(final byte[] bytes) { public GarminAgpsFile(final byte[] bytes) {
this.bytes = bytes; this.bytes = bytes;
@ -66,6 +67,10 @@ public class GarminAgpsFile {
return false; return false;
} }
public boolean isValidSonyCpe() {
return ArrayUtils.startsWith(bytes, CPE_SONY_HEADER);
}
public byte[] getBytes() { public byte[] getBytes() {
return bytes.clone(); return bytes.clone();
} }