Private
Public Access
Minamp 1.1
- Run network/TLS work on 256 KB-stack threads (net/Threads.java): Android 2.x's ~16 KB default stack overflowed during the bundled TLS handshake - Close pooled TLS connections off the caller thread - Try several Plex music-transcoder URL variants until the server accepts one, and remember the one that worked - Accept pasted server URLs with paths; default to 443 for https - Catch fatal errors and save a crash report (shown on next launch and written to Minamp-error.txt on the SD card) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
948d1198ad
commit
0a2ac901bd
16 files changed
+417
-80
No files matched your search
@@ -48,6 +48,7 @@ public class App extends Application {
|
||||
instance = this;
|
||||
handler = new Handler();
|
||||
prefs = getSharedPreferences("minamp", MODE_PRIVATE);
|
||||
installCrashLogger();
|
||||
|
||||
// Android 2.2's HttpURLConnection pool is buggy; we use our own client, but be safe.
|
||||
System.setProperty("http.keepAlive", "false");
|
||||
@@ -64,6 +65,7 @@ public class App extends Application {
|
||||
try { Plex.version = getPackageManager().getPackageInfo(getPackageName(), 0).versionName; } catch (Exception ignored) {}
|
||||
|
||||
CertVerifier.setRootStore(new AssetRoots(this));
|
||||
Library.preferredVariant = Math.max(0, Math.min(Library.VARIANTS - 1, prefs.getInt("tcVariant", 0)));
|
||||
images = new ImageLoader(this);
|
||||
loadServer();
|
||||
PlayQueue.get().restore(this);
|
||||
@@ -76,6 +78,59 @@ public class App extends Application {
|
||||
}, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------ crash reports
|
||||
|
||||
private static final String CRASH_FILE = "crash.txt";
|
||||
|
||||
private void installCrashLogger() {
|
||||
final Thread.UncaughtExceptionHandler previous = Thread.getDefaultUncaughtExceptionHandler();
|
||||
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
|
||||
public void uncaughtException(Thread t, Throwable e) {
|
||||
logError("crash in " + t.getName(), e);
|
||||
if (previous != null) previous.uncaughtException(t, e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/** Saves a stack trace to app storage (shown on next launch) and to the SD card. */
|
||||
public static void logError(String where, Throwable e) {
|
||||
App app = instance;
|
||||
if (app == null) return;
|
||||
try {
|
||||
java.io.StringWriter sw = new java.io.StringWriter();
|
||||
java.io.PrintWriter pw = new java.io.PrintWriter(sw);
|
||||
pw.println("Minamp " + Plex.version + " on " + Build.MODEL + ", Android " + Build.VERSION.RELEASE);
|
||||
pw.println(new java.util.Date() + " - " + where);
|
||||
e.printStackTrace(pw);
|
||||
pw.flush();
|
||||
byte[] text = sw.toString().getBytes("UTF-8");
|
||||
java.io.FileOutputStream out = app.openFileOutput(CRASH_FILE, MODE_PRIVATE);
|
||||
out.write(text);
|
||||
out.close();
|
||||
try {
|
||||
if (android.os.Environment.MEDIA_MOUNTED.equals(android.os.Environment.getExternalStorageState())) {
|
||||
java.io.File f = new java.io.File(android.os.Environment.getExternalStorageDirectory(), "Minamp-error.txt");
|
||||
java.io.FileOutputStream o2 = new java.io.FileOutputStream(f);
|
||||
o2.write(text);
|
||||
o2.close();
|
||||
}
|
||||
} catch (Throwable ignored) {}
|
||||
} catch (Throwable ignored) {}
|
||||
}
|
||||
|
||||
/** The last saved error report, or null. Reading it clears it. */
|
||||
public String takeCrashReport() {
|
||||
try {
|
||||
java.io.File f = getFileStreamPath(CRASH_FILE);
|
||||
if (!f.exists()) return null;
|
||||
String s = new String(readAll(new java.io.FileInputStream(f)), "UTF-8");
|
||||
f.delete();
|
||||
return s;
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------ server/library
|
||||
|
||||
public void loadServer() {
|
||||
|
||||
Reference in new issue
Block a user