Android app: buildable project recovered from the 1.2.2 APK

The original Android source was lost; android/ holds the jadx-decompiled
Java (com.mulberry.player) and resources from Android 1.2.2, fixed so it
compiles again (broken methods rewritten by hand), plus:

- android/build.sh: builds and signs Mulberry-<version>-Android.apk with the
  plain SDK tools (aapt2, javac, d8, apksigner), no Gradle; fetches
  jaudiotagger 2.0.3 (the version the old APK bundled) with a pinned checksum
- versionName 2.0.4, versionCode 6
- recoloured launcher icon (pink cookie, berry note) to match assets/mulberry.svg

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
astar76 2026-12-02 12:32:30 -06:00
commit 320f644bc8

View file

@ -0,0 +1,110 @@
package com.mulberry.player;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.util.Map;
import org.jaudiotagger.tag.id3.framebody.FrameBodyCOMM;
/* JADX INFO: loaded from: classes.dex */
public final class Net {
public static final String UA = "Mulberry-Android/1.0 ( https://github.com/BeamStarTech/Mulberry )";
public static String enc(String str) {
if (str == null) {
str = FrameBodyCOMM.DEFAULT;
}
try {
return URLEncoder.encode(str, "UTF-8");
} catch (Exception e) {
return FrameBodyCOMM.DEFAULT;
}
}
public static String query(Map<String, String> map) {
StringBuilder sb = new StringBuilder();
for (Map.Entry<String, String> entry : map.entrySet()) {
if (sb.length() > 0) {
sb.append('&');
}
sb.append(enc(entry.getKey())).append('=').append(enc(entry.getValue()));
}
return sb.toString();
}
public static byte[] getBytes(String str, Map<String, String> map) throws IOException {
HttpURLConnection httpURLConnection = (HttpURLConnection) new URL(str).openConnection();
httpURLConnection.setConnectTimeout(10000);
httpURLConnection.setReadTimeout(15000);
httpURLConnection.setInstanceFollowRedirects(true);
httpURLConnection.setRequestProperty("User-Agent", UA);
if (map != null) {
for (Map.Entry<String, String> entry : map.entrySet()) {
httpURLConnection.setRequestProperty(entry.getKey(), entry.getValue());
}
}
try {
int responseCode = httpURLConnection.getResponseCode();
InputStream errorStream = responseCode >= 400 ? httpURLConnection.getErrorStream() : httpURLConnection.getInputStream();
byte[] all = errorStream == null ? new byte[0] : readAll(errorStream);
if (responseCode >= 400 && responseCode != 403 && responseCode != 404) {
throw new IOException("HTTP " + responseCode);
}
if (responseCode == 404) {
byte[] bArr = new byte[0];
httpURLConnection.disconnect();
return bArr;
}
httpURLConnection.disconnect();
return all;
} catch (Throwable th) {
httpURLConnection.disconnect();
throw th;
}
}
public static String get(String str, Map<String, String> map) throws IOException {
return new String(getBytes(str, map), "UTF-8");
}
public static String post(String str, String str2) throws IOException {
HttpURLConnection httpURLConnection = (HttpURLConnection) new URL(str).openConnection();
httpURLConnection.setConnectTimeout(10000);
httpURLConnection.setReadTimeout(15000);
httpURLConnection.setDoOutput(true);
httpURLConnection.setRequestMethod("POST");
httpURLConnection.setRequestProperty("User-Agent", UA);
httpURLConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded; charset=utf-8");
try {
OutputStream outputStream = httpURLConnection.getOutputStream();
outputStream.write(str2.getBytes("UTF-8"));
outputStream.close();
InputStream errorStream = httpURLConnection.getResponseCode() >= 400 ? httpURLConnection.getErrorStream() : httpURLConnection.getInputStream();
return errorStream == null ? FrameBodyCOMM.DEFAULT : new String(readAll(errorStream), "UTF-8");
} finally {
httpURLConnection.disconnect();
}
}
public static byte[] readAll(InputStream inputStream) throws IOException {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
byte[] bArr = new byte[16384];
while (true) {
try {
int i = inputStream.read(bArr);
if (i <= 0) {
inputStream.close();
return byteArrayOutputStream.toByteArray();
}
byteArrayOutputStream.write(bArr, 0, i);
} catch (Throwable th) {
inputStream.close();
throw th;
}
}
}
}