ContentProvider: wrap in try/catch

Errors thrown here shouldn't be fatal, the app will often work just fine
without any ContentProviders (especially a mostly-native app probably
only uses them for ads)
This commit is contained in:
Mis012
2024-11-09 16:27:07 +01:00
parent da36ebea9a
commit ab114245bd

View File

@@ -14,8 +14,9 @@ public abstract class ContentProvider {
static Map<String, ContentProvider> providers = new HashMap<String, ContentProvider>();
static void createContentProviders() throws Exception {
static void createContentProviders() {
for (PackageParser.Provider provider_parsed : Context.pkg.providers) {
try {
String providerName = provider_parsed.className;
System.out.println("creating " + providerName);
Class<? extends ContentProvider> providerCls = Class.forName(providerName).asSubclass(ContentProvider.class);
@@ -23,6 +24,7 @@ public abstract class ContentProvider {
provider.attachInfo(Context.this_application, provider_parsed.info);
provider.onCreate();
providers.put(provider_parsed.info.authority, provider);
} catch(Exception e) { e.printStackTrace(); }
}
}