1
0
mirror of git://f0xx.org/android_cast synced 2026-07-29 07:20:00 +03:00

Merge branch 'feature/gzip-ota-build-deploy' into next.

Resolve deploy.sh migration helper duplication and combine gitignore
entries for out/ and ota-publish/.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Anton Afanasyeu
2026-06-02 22:02:36 +02:00
20 changed files with 283 additions and 18 deletions

View File

@@ -19,6 +19,7 @@ import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.zip.GZIPOutputStream;
/** POST crash JSON to the PHP receiver. */
public final class CrashUploadClient {
@@ -27,6 +28,14 @@ public final class CrashUploadClient {
private CrashUploadClient() {}
private static byte[] gzip(byte[] plain) throws java.io.IOException {
ByteArrayOutputStream buf = new ByteArrayOutputStream(Math.max(256, plain.length / 4));
try (GZIPOutputStream gz = new GZIPOutputStream(buf)) {
gz.write(plain);
}
return buf.toByteArray();
}
public static boolean upload(String uploadUrl, JSONObject report) {
if (uploadUrl == null || uploadUrl.isEmpty() || report == null) {
return false;
@@ -40,7 +49,9 @@ public final class CrashUploadClient {
conn.setDoOutput(true);
conn.setRequestProperty("Content-Type", "application/json; charset=utf-8");
conn.setRequestProperty("Accept", "application/json");
byte[] body = report.toString().getBytes(StandardCharsets.UTF_8);
conn.setRequestProperty("Content-Encoding", "gzip");
byte[] json = report.toString().getBytes(StandardCharsets.UTF_8);
byte[] body = gzip(json);
try (OutputStream out = conn.getOutputStream()) {
out.write(body);
}