mirror of
https://github.com/AntennaPod/AntennaPod.git
synced 2025-12-01 12:31:45 +00:00
Crash debug version when doing I/O on main thread (#8064)
This commit is contained in:
committed by
GitHub
parent
04dfbc1d5d
commit
41edd00b39
@ -21,12 +21,14 @@ public class PodcastApp extends Application {
|
||||
|
||||
if (BuildConfig.DEBUG) {
|
||||
StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder()
|
||||
.detectLeakedSqlLiteObjects()
|
||||
.penaltyDeath()
|
||||
.penaltyLog()
|
||||
.penaltyDropBox()
|
||||
.detectLeakedSqlLiteObjects()
|
||||
.detectActivityLeaks()
|
||||
.detectLeakedClosableObjects()
|
||||
.detectLeakedRegistrationObjects();
|
||||
if (android.os.Build.VERSION.SDK_INT >= 26) {
|
||||
builder.detectContentUriWithoutPermission();
|
||||
}
|
||||
StrictMode.setVmPolicy(builder.build());
|
||||
}
|
||||
|
||||
|
||||
@ -10,6 +10,8 @@ import android.database.SQLException;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.database.sqlite.SQLiteDatabase.CursorFactory;
|
||||
import android.database.sqlite.SQLiteOpenHelper;
|
||||
import android.os.Build;
|
||||
import android.os.Looper;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
@ -387,7 +389,24 @@ public class PodDBAdapter {
|
||||
return newDb;
|
||||
}
|
||||
|
||||
private boolean isTest() {
|
||||
if ("robolectric".equals(Build.FINGERPRINT)) {
|
||||
return true;
|
||||
}
|
||||
try {
|
||||
Class.forName("org.junit.Test");
|
||||
return true;
|
||||
} catch (ClassNotFoundException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized PodDBAdapter open() {
|
||||
if (BuildConfig.DEBUG) {
|
||||
if (Looper.myLooper() == Looper.getMainLooper() && !isTest()) {
|
||||
throw new RuntimeException("I/O on main thread");
|
||||
}
|
||||
}
|
||||
// do nothing
|
||||
return this;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user