From 33b0951a1b3211c4e6c180d99306fbde0834f613 Mon Sep 17 00:00:00 2001 From: f43nd1r Date: Fri, 21 Dec 2018 03:26:09 +0100 Subject: [PATCH] Revert "Merge branch 'asl'" This reverts commit 6553fea1f96db46102e8213eb2f5e652075fffcf, reversing changes made to d51602383e21628ce6a0ecdb6929a22399c87b2c. --- .../scheduler/AdvancedSenderScheduler.java | 2 +- .../scheduler/RestartingAdministrator.java | 2 +- acra-core/build.gradle | 2 +- .../java/org/acra/builder/ReportExecutor.java | 2 +- .../collector/ConfigurationCollector.java | 2 +- .../acra/collector/CustomDataCollector.java | 2 +- .../collector/DeviceFeaturesCollector.java | 2 +- .../org/acra/collector/DeviceIdCollector.java | 2 +- .../collector/DisplayManagerCollector.java | 2 +- .../org/acra/collector/DropBoxCollector.java | 2 +- .../org/acra/collector/LogCatCollector.java | 2 +- .../org/acra/collector/LogFileCollector.java | 2 +- .../collector/MediaCodecListCollector.java | 2 +- .../acra/collector/MemoryInfoCollector.java | 2 +- .../collector/PackageManagerCollector.java | 2 +- .../acra/collector/ReflectionCollector.java | 2 +- .../org/acra/collector/SettingsCollector.java | 2 +- .../collector/SharedPreferencesCollector.java | 2 +- .../acra/collector/SimpleValuesCollector.java | 2 +- .../acra/collector/StacktraceCollector.java | 2 +- .../org/acra/collector/ThreadCollector.java | 2 +- .../org/acra/collector/TimeCollector.java | 2 +- .../config/BaseCoreConfigurationBuilder.java | 2 +- .../org/acra/data/CrashReportDataFactory.java | 2 +- .../ReportInteractionExecutor.java | 2 +- .../java/org/acra/plugins/PluginLoader.java | 5 ++--- .../org/acra/plugins/ServicePluginLoader.java | 22 ++++++------------- .../org/acra/plugins/SimplePluginLoader.java | 7 +++--- .../org/acra/scheduler/SchedulerStarter.java | 2 +- .../java/org/acra/sender/SenderService.java | 16 ++++++++++++-- .../startup/StartupProcessorExecutor.java | 2 +- .../startup/UnapprovedStartupProcessor.java | 2 +- .../src/test/java/org/acra/ACRATest.java | 6 ++--- .../attachment/AcraContentProviderTest.java | 19 ++++++++++------ .../DefaultAttachmentProviderTest.java | 6 ++--- .../java/org/acra/util/InstallationTest.java | 10 ++++----- acra-dialog/build.gradle | 1 + .../acra/interaction/DialogInteraction.java | 2 +- acra-http/build.gradle | 1 + .../org/acra/sender/HttpSenderFactory.java | 2 +- acra-limiter/build.gradle | 1 + .../config/LimitingReportAdministrator.java | 4 +--- .../acra/startup/LimiterStartupProcessor.java | 2 +- acra-mail/build.gradle | 1 + .../acra/sender/EmailIntentSenderFactory.java | 2 +- acra-notification/build.gradle | 1 + .../interaction/NotificationInteraction.java | 2 +- acra-toast/build.gradle | 1 + .../acra/interaction/ToastInteraction.java | 2 +- annotationprocessor/build.gradle | 1 - .../acra/processor/creator/ClassCreator.java | 2 +- build.gradle | 7 ------ gradle.properties | 1 - 53 files changed, 91 insertions(+), 89 deletions(-) diff --git a/acra-advanced-scheduler/src/main/java/org/acra/scheduler/AdvancedSenderScheduler.java b/acra-advanced-scheduler/src/main/java/org/acra/scheduler/AdvancedSenderScheduler.java index d89262816d..678d471440 100644 --- a/acra-advanced-scheduler/src/main/java/org/acra/scheduler/AdvancedSenderScheduler.java +++ b/acra-advanced-scheduler/src/main/java/org/acra/scheduler/AdvancedSenderScheduler.java @@ -21,7 +21,7 @@ import android.support.annotation.NonNull; import androidx.work.Constraints; import androidx.work.OneTimeWorkRequest; -import com.faendir.asl.annotation.AutoService; +import com.google.auto.service.AutoService; import org.acra.config.ConfigUtils; import org.acra.config.CoreConfiguration; import org.acra.config.SchedulerConfiguration; diff --git a/acra-advanced-scheduler/src/main/java/org/acra/scheduler/RestartingAdministrator.java b/acra-advanced-scheduler/src/main/java/org/acra/scheduler/RestartingAdministrator.java index c4156c3fec..c7df3bb9f8 100644 --- a/acra-advanced-scheduler/src/main/java/org/acra/scheduler/RestartingAdministrator.java +++ b/acra-advanced-scheduler/src/main/java/org/acra/scheduler/RestartingAdministrator.java @@ -21,7 +21,7 @@ import android.content.Intent; import android.support.annotation.NonNull; import androidx.work.*; -import com.faendir.asl.annotation.AutoService; +import com.google.auto.service.AutoService; import org.acra.ACRA; import org.acra.builder.LastActivityManager; import org.acra.config.ConfigUtils; diff --git a/acra-core/build.gradle b/acra-core/build.gradle index 2da509d1bb..c9cd2bd55c 100644 --- a/acra-core/build.gradle +++ b/acra-core/build.gradle @@ -30,7 +30,7 @@ dependencies { exclude group: 'com.android.support', module: 'support-fragment' } api project(':acra-javacore') - implementation "com.faendir.asl:serviceloader:$aslVersion" + compileOnly "com.google.auto.service:auto-service:$autoServiceVersion" annotationProcessor project(':annotationprocessor') compileOnly project(':annotations') } diff --git a/acra-core/src/main/java/org/acra/builder/ReportExecutor.java b/acra-core/src/main/java/org/acra/builder/ReportExecutor.java index f26d4d4370..ab69714caf 100644 --- a/acra-core/src/main/java/org/acra/builder/ReportExecutor.java +++ b/acra-core/src/main/java/org/acra/builder/ReportExecutor.java @@ -81,7 +81,7 @@ public ReportExecutor(@NonNull Context context, @NonNull CoreConfiguration confi this.crashReportDataFactory = crashReportDataFactory; this.defaultExceptionHandler = defaultExceptionHandler; this.processFinisher = processFinisher; - reportingAdministrators = config.pluginLoader().loadEnabled(context, config, ReportingAdministrator.class); + reportingAdministrators = config.pluginLoader().loadEnabled(config, ReportingAdministrator.class); this.schedulerStarter = schedulerStarter; this.lastActivityManager = lastActivityManager; } diff --git a/acra-core/src/main/java/org/acra/collector/ConfigurationCollector.java b/acra-core/src/main/java/org/acra/collector/ConfigurationCollector.java index b51d2952ed..ee35ed00b6 100644 --- a/acra-core/src/main/java/org/acra/collector/ConfigurationCollector.java +++ b/acra-core/src/main/java/org/acra/collector/ConfigurationCollector.java @@ -21,7 +21,7 @@ import android.support.annotation.Nullable; import android.util.SparseArray; -import com.faendir.asl.annotation.AutoService; +import com.google.auto.service.AutoService; import org.acra.ACRA; import org.acra.ReportField; diff --git a/acra-core/src/main/java/org/acra/collector/CustomDataCollector.java b/acra-core/src/main/java/org/acra/collector/CustomDataCollector.java index 5765288012..af5099fa7a 100644 --- a/acra-core/src/main/java/org/acra/collector/CustomDataCollector.java +++ b/acra-core/src/main/java/org/acra/collector/CustomDataCollector.java @@ -18,7 +18,7 @@ import android.content.Context; import android.support.annotation.NonNull; -import com.faendir.asl.annotation.AutoService; +import com.google.auto.service.AutoService; import org.acra.ReportField; import org.acra.builder.ReportBuilder; diff --git a/acra-core/src/main/java/org/acra/collector/DeviceFeaturesCollector.java b/acra-core/src/main/java/org/acra/collector/DeviceFeaturesCollector.java index 5fbcf56a8a..6064f06e3a 100644 --- a/acra-core/src/main/java/org/acra/collector/DeviceFeaturesCollector.java +++ b/acra-core/src/main/java/org/acra/collector/DeviceFeaturesCollector.java @@ -20,7 +20,7 @@ import android.content.pm.PackageManager; import android.support.annotation.NonNull; -import com.faendir.asl.annotation.AutoService; +import com.google.auto.service.AutoService; import org.acra.ReportField; import org.acra.builder.ReportBuilder; diff --git a/acra-core/src/main/java/org/acra/collector/DeviceIdCollector.java b/acra-core/src/main/java/org/acra/collector/DeviceIdCollector.java index 56e35274ef..f2bddfe36c 100644 --- a/acra-core/src/main/java/org/acra/collector/DeviceIdCollector.java +++ b/acra-core/src/main/java/org/acra/collector/DeviceIdCollector.java @@ -21,7 +21,7 @@ import android.support.annotation.NonNull; import android.support.annotation.RequiresPermission; -import com.faendir.asl.annotation.AutoService; +import com.google.auto.service.AutoService; import org.acra.ACRA; import org.acra.ReportField; diff --git a/acra-core/src/main/java/org/acra/collector/DisplayManagerCollector.java b/acra-core/src/main/java/org/acra/collector/DisplayManagerCollector.java index c410ae878a..0b65bd2690 100644 --- a/acra-core/src/main/java/org/acra/collector/DisplayManagerCollector.java +++ b/acra-core/src/main/java/org/acra/collector/DisplayManagerCollector.java @@ -26,7 +26,7 @@ import android.view.Display; import android.view.Surface; -import com.faendir.asl.annotation.AutoService; +import com.google.auto.service.AutoService; import org.acra.ACRA; import org.acra.ReportField; diff --git a/acra-core/src/main/java/org/acra/collector/DropBoxCollector.java b/acra-core/src/main/java/org/acra/collector/DropBoxCollector.java index f62176faea..a42966bd81 100644 --- a/acra-core/src/main/java/org/acra/collector/DropBoxCollector.java +++ b/acra-core/src/main/java/org/acra/collector/DropBoxCollector.java @@ -21,7 +21,7 @@ import android.os.DropBoxManager; import android.support.annotation.NonNull; -import com.faendir.asl.annotation.AutoService; +import com.google.auto.service.AutoService; import org.acra.ACRA; import org.acra.ReportField; diff --git a/acra-core/src/main/java/org/acra/collector/LogCatCollector.java b/acra-core/src/main/java/org/acra/collector/LogCatCollector.java index cb19f80e21..903f1675bc 100644 --- a/acra-core/src/main/java/org/acra/collector/LogCatCollector.java +++ b/acra-core/src/main/java/org/acra/collector/LogCatCollector.java @@ -20,7 +20,7 @@ import android.os.Build; import android.support.annotation.NonNull; import android.support.annotation.Nullable; -import com.faendir.asl.annotation.AutoService; +import com.google.auto.service.AutoService; import org.acra.ACRA; import org.acra.ReportField; import org.acra.builder.ReportBuilder; diff --git a/acra-core/src/main/java/org/acra/collector/LogFileCollector.java b/acra-core/src/main/java/org/acra/collector/LogFileCollector.java index d23ea2427f..a342120123 100644 --- a/acra-core/src/main/java/org/acra/collector/LogFileCollector.java +++ b/acra-core/src/main/java/org/acra/collector/LogFileCollector.java @@ -19,7 +19,7 @@ import android.content.Context; import android.support.annotation.NonNull; -import com.faendir.asl.annotation.AutoService; +import com.google.auto.service.AutoService; import org.acra.ReportField; import org.acra.builder.ReportBuilder; diff --git a/acra-core/src/main/java/org/acra/collector/MediaCodecListCollector.java b/acra-core/src/main/java/org/acra/collector/MediaCodecListCollector.java index 63a8441a58..48c9100b06 100644 --- a/acra-core/src/main/java/org/acra/collector/MediaCodecListCollector.java +++ b/acra-core/src/main/java/org/acra/collector/MediaCodecListCollector.java @@ -25,7 +25,7 @@ import android.support.annotation.Nullable; import android.util.SparseArray; -import com.faendir.asl.annotation.AutoService; +import com.google.auto.service.AutoService; import org.acra.ReportField; import org.acra.builder.ReportBuilder; diff --git a/acra-core/src/main/java/org/acra/collector/MemoryInfoCollector.java b/acra-core/src/main/java/org/acra/collector/MemoryInfoCollector.java index 464f2acee7..0967671354 100644 --- a/acra-core/src/main/java/org/acra/collector/MemoryInfoCollector.java +++ b/acra-core/src/main/java/org/acra/collector/MemoryInfoCollector.java @@ -22,7 +22,7 @@ import android.support.annotation.NonNull; import android.support.annotation.Nullable; -import com.faendir.asl.annotation.AutoService; +import com.google.auto.service.AutoService; import org.acra.ACRA; import org.acra.ReportField; diff --git a/acra-core/src/main/java/org/acra/collector/PackageManagerCollector.java b/acra-core/src/main/java/org/acra/collector/PackageManagerCollector.java index a4427886c2..b5b4e317a6 100644 --- a/acra-core/src/main/java/org/acra/collector/PackageManagerCollector.java +++ b/acra-core/src/main/java/org/acra/collector/PackageManagerCollector.java @@ -19,7 +19,7 @@ import android.content.pm.PackageInfo; import android.support.annotation.NonNull; -import com.faendir.asl.annotation.AutoService; +import com.google.auto.service.AutoService; import org.acra.ReportField; import org.acra.builder.ReportBuilder; diff --git a/acra-core/src/main/java/org/acra/collector/ReflectionCollector.java b/acra-core/src/main/java/org/acra/collector/ReflectionCollector.java index f72fd2d1ad..4099ff2e6b 100644 --- a/acra-core/src/main/java/org/acra/collector/ReflectionCollector.java +++ b/acra-core/src/main/java/org/acra/collector/ReflectionCollector.java @@ -21,7 +21,7 @@ import android.os.Environment; import android.support.annotation.NonNull; -import com.faendir.asl.annotation.AutoService; +import com.google.auto.service.AutoService; import org.acra.ReportField; import org.acra.builder.ReportBuilder; diff --git a/acra-core/src/main/java/org/acra/collector/SettingsCollector.java b/acra-core/src/main/java/org/acra/collector/SettingsCollector.java index 800cf4f8f2..2ff2099f83 100644 --- a/acra-core/src/main/java/org/acra/collector/SettingsCollector.java +++ b/acra-core/src/main/java/org/acra/collector/SettingsCollector.java @@ -25,7 +25,7 @@ import android.support.annotation.NonNull; import android.support.annotation.Nullable; -import com.faendir.asl.annotation.AutoService; +import com.google.auto.service.AutoService; import org.acra.ACRA; import org.acra.ReportField; diff --git a/acra-core/src/main/java/org/acra/collector/SharedPreferencesCollector.java b/acra-core/src/main/java/org/acra/collector/SharedPreferencesCollector.java index 1dca71327e..beb89b6ee5 100644 --- a/acra-core/src/main/java/org/acra/collector/SharedPreferencesCollector.java +++ b/acra-core/src/main/java/org/acra/collector/SharedPreferencesCollector.java @@ -20,7 +20,7 @@ import android.preference.PreferenceManager; import android.support.annotation.NonNull; -import com.faendir.asl.annotation.AutoService; +import com.google.auto.service.AutoService; import org.acra.ACRA; import org.acra.ReportField; diff --git a/acra-core/src/main/java/org/acra/collector/SimpleValuesCollector.java b/acra-core/src/main/java/org/acra/collector/SimpleValuesCollector.java index 4b7c8e25aa..ee1cfa6144 100644 --- a/acra-core/src/main/java/org/acra/collector/SimpleValuesCollector.java +++ b/acra-core/src/main/java/org/acra/collector/SimpleValuesCollector.java @@ -19,7 +19,7 @@ import android.os.Build; import android.support.annotation.NonNull; -import com.faendir.asl.annotation.AutoService; +import com.google.auto.service.AutoService; import org.acra.ReportField; import org.acra.builder.ReportBuilder; diff --git a/acra-core/src/main/java/org/acra/collector/StacktraceCollector.java b/acra-core/src/main/java/org/acra/collector/StacktraceCollector.java index b11ed471de..a6933e376e 100644 --- a/acra-core/src/main/java/org/acra/collector/StacktraceCollector.java +++ b/acra-core/src/main/java/org/acra/collector/StacktraceCollector.java @@ -20,7 +20,7 @@ import android.support.annotation.Nullable; import android.text.TextUtils; -import com.faendir.asl.annotation.AutoService; +import com.google.auto.service.AutoService; import org.acra.ReportField; import org.acra.builder.ReportBuilder; diff --git a/acra-core/src/main/java/org/acra/collector/ThreadCollector.java b/acra-core/src/main/java/org/acra/collector/ThreadCollector.java index 91b5fc6e59..d8839ce8fc 100644 --- a/acra-core/src/main/java/org/acra/collector/ThreadCollector.java +++ b/acra-core/src/main/java/org/acra/collector/ThreadCollector.java @@ -19,7 +19,7 @@ import android.content.Context; import android.support.annotation.NonNull; -import com.faendir.asl.annotation.AutoService; +import com.google.auto.service.AutoService; import org.acra.ReportField; import org.acra.builder.ReportBuilder; diff --git a/acra-core/src/main/java/org/acra/collector/TimeCollector.java b/acra-core/src/main/java/org/acra/collector/TimeCollector.java index 3228a959f0..905c6414dc 100644 --- a/acra-core/src/main/java/org/acra/collector/TimeCollector.java +++ b/acra-core/src/main/java/org/acra/collector/TimeCollector.java @@ -18,7 +18,7 @@ import android.content.Context; import android.support.annotation.NonNull; -import com.faendir.asl.annotation.AutoService; +import com.google.auto.service.AutoService; import org.acra.ACRAConstants; import org.acra.ReportField; diff --git a/acra-core/src/main/java/org/acra/config/BaseCoreConfigurationBuilder.java b/acra-core/src/main/java/org/acra/config/BaseCoreConfigurationBuilder.java index 012423f414..21d608e2de 100644 --- a/acra-core/src/main/java/org/acra/config/BaseCoreConfigurationBuilder.java +++ b/acra-core/src/main/java/org/acra/config/BaseCoreConfigurationBuilder.java @@ -55,7 +55,7 @@ public final class BaseCoreConfigurationBuilder { private List configurationBuilders() { if (configurationBuilders == null) { - List factories = pluginLoader.load(app, ConfigurationBuilderFactory.class); + List factories = pluginLoader.load(ConfigurationBuilderFactory.class); if (ACRA.DEV_LOGGING) ACRA.log.d(LOG_TAG, "Found ConfigurationBuilderFactories : " + factories); configurationBuilders = new ArrayList<>(factories.size()); for (ConfigurationBuilderFactory factory : factories) { diff --git a/acra-core/src/main/java/org/acra/data/CrashReportDataFactory.java b/acra-core/src/main/java/org/acra/data/CrashReportDataFactory.java index 5cabd95b9b..6ce64ff7b3 100644 --- a/acra-core/src/main/java/org/acra/data/CrashReportDataFactory.java +++ b/acra-core/src/main/java/org/acra/data/CrashReportDataFactory.java @@ -50,7 +50,7 @@ public final class CrashReportDataFactory { public CrashReportDataFactory(@NonNull Context context, @NonNull CoreConfiguration config) { this.context = context; this.config = config; - collectors = config.pluginLoader().loadEnabled(context, config, Collector.class); + collectors = config.pluginLoader().loadEnabled(config, Collector.class); //noinspection Java8ListSort Collections.sort(collectors, (c1, c2) -> { Collector.Order o1; diff --git a/acra-core/src/main/java/org/acra/interaction/ReportInteractionExecutor.java b/acra-core/src/main/java/org/acra/interaction/ReportInteractionExecutor.java index 8f5e099761..c5b768cacc 100644 --- a/acra-core/src/main/java/org/acra/interaction/ReportInteractionExecutor.java +++ b/acra-core/src/main/java/org/acra/interaction/ReportInteractionExecutor.java @@ -44,7 +44,7 @@ public class ReportInteractionExecutor { public ReportInteractionExecutor(@NonNull final Context context, @NonNull final CoreConfiguration config) { this.context = context; this.config = config; - reportInteractions = config.pluginLoader().loadEnabled(context, config, ReportInteraction.class); + reportInteractions = config.pluginLoader().loadEnabled(config, ReportInteraction.class); } public boolean hasInteractions() { diff --git a/acra-core/src/main/java/org/acra/plugins/PluginLoader.java b/acra-core/src/main/java/org/acra/plugins/PluginLoader.java index ebc4d601e2..0e190263c6 100644 --- a/acra-core/src/main/java/org/acra/plugins/PluginLoader.java +++ b/acra-core/src/main/java/org/acra/plugins/PluginLoader.java @@ -16,7 +16,6 @@ package org.acra.plugins; -import android.content.Context; import android.support.annotation.NonNull; import org.acra.config.CoreConfiguration; @@ -28,7 +27,7 @@ * @since 01.07.18 */ public interface PluginLoader extends Serializable { - List load(@NonNull Context context, @NonNull Class clazz); + List load(@NonNull Class clazz); - List loadEnabled(@NonNull Context context, @NonNull CoreConfiguration config, @NonNull Class clazz); + List loadEnabled(@NonNull CoreConfiguration config, @NonNull Class clazz); } diff --git a/acra-core/src/main/java/org/acra/plugins/ServicePluginLoader.java b/acra-core/src/main/java/org/acra/plugins/ServicePluginLoader.java index 501a002fd1..2d449c08c6 100644 --- a/acra-core/src/main/java/org/acra/plugins/ServicePluginLoader.java +++ b/acra-core/src/main/java/org/acra/plugins/ServicePluginLoader.java @@ -16,7 +16,6 @@ package org.acra.plugins; -import android.content.Context; import android.support.annotation.NonNull; import org.acra.ACRA; import org.acra.config.CoreConfiguration; @@ -35,26 +34,19 @@ public class ServicePluginLoader implements PluginLoader { @Override - public List load(@NonNull Context context, @NonNull Class clazz) { - return loadInternal(context, clazz, plugin -> true); + public List load(@NonNull Class clazz) { + return loadInternal(clazz, plugin -> true); } @Override - public List loadEnabled(@NonNull Context context, @NonNull CoreConfiguration config, @NonNull Class clazz) { - return loadInternal(context, clazz, plugin -> plugin.enabled(config)); + public List loadEnabled(@NonNull CoreConfiguration config, @NonNull Class clazz) { + return loadInternal(clazz, plugin -> plugin.enabled(config)); } - private List loadInternal(@NonNull Context context, @NonNull Class clazz, Predicate shouldLoadPredicate) { - List plugins = new ArrayList<>(new com.faendir.asl.serviceloader.ServiceLoader(context).load(clazz)); - for (Iterator iterator = plugins.iterator(); iterator.hasNext(); ) { - T plugin = iterator.next(); - if (!shouldLoadPredicate.apply(plugin)) { - iterator.remove(); - } else if (ACRA.DEV_LOGGING) ACRA.log.d(ACRA.LOG_TAG, "Loaded " + clazz.getSimpleName() + " of type " + plugin.getClass().getName()); - } - //legacy + private List loadInternal(@NonNull Class clazz, Predicate shouldLoadPredicate) { + List plugins = new ArrayList<>(); //noinspection ForLoopReplaceableByForEach - final ServiceLoader serviceLoader = ServiceLoader.load(clazz, context.getClassLoader()); + final ServiceLoader serviceLoader = ServiceLoader.load(clazz, getClass().getClassLoader()); if (ACRA.DEV_LOGGING) ACRA.log.d(LOG_TAG, "ServicePluginLoader loading services from ServiceLoader : " + serviceLoader); for (final Iterator iterator = serviceLoader.iterator(); iterator.hasNext(); ) { diff --git a/acra-core/src/main/java/org/acra/plugins/SimplePluginLoader.java b/acra-core/src/main/java/org/acra/plugins/SimplePluginLoader.java index b9e6e78b37..207be18f6f 100644 --- a/acra-core/src/main/java/org/acra/plugins/SimplePluginLoader.java +++ b/acra-core/src/main/java/org/acra/plugins/SimplePluginLoader.java @@ -16,7 +16,6 @@ package org.acra.plugins; -import android.content.Context; import android.support.annotation.NonNull; import org.acra.ACRA; import org.acra.config.CoreConfiguration; @@ -41,7 +40,7 @@ public SimplePluginLoader(@NonNull Class... plugins) { } @Override - public List load(@NonNull Context context, @NonNull Class clazz) { + public List load(@NonNull Class clazz) { List list = new ArrayList<>(); if (ACRA.DEV_LOGGING) ACRA.log.d(LOG_TAG, "SimplePluginLoader loading services from plugin classes : " + plugins); for (Class plugin : plugins) { @@ -59,8 +58,8 @@ public List load(@NonNull Context context, @NonNull Class< } @Override - public List loadEnabled(@NonNull Context context, @NonNull CoreConfiguration config, @NonNull Class clazz) { - List list = load(context, clazz); + public List loadEnabled(@NonNull CoreConfiguration config, @NonNull Class clazz) { + List list = load(clazz); //noinspection Java8CollectionRemoveIf for (Iterator iterator = list.iterator(); iterator.hasNext(); ) { T plugin = iterator.next(); diff --git a/acra-core/src/main/java/org/acra/scheduler/SchedulerStarter.java b/acra-core/src/main/java/org/acra/scheduler/SchedulerStarter.java index 071e2488a2..ba641a0d23 100644 --- a/acra-core/src/main/java/org/acra/scheduler/SchedulerStarter.java +++ b/acra-core/src/main/java/org/acra/scheduler/SchedulerStarter.java @@ -39,7 +39,7 @@ public class SchedulerStarter { public SchedulerStarter(@NonNull Context context, @NonNull CoreConfiguration config) { locator = new ReportLocator(context); - List schedulerFactories = config.pluginLoader().loadEnabled(context, config, SenderSchedulerFactory.class); + List schedulerFactories = config.pluginLoader().loadEnabled(config, SenderSchedulerFactory.class); if (schedulerFactories.isEmpty()) { senderScheduler = new DefaultSenderScheduler(context, config); } else { diff --git a/acra-core/src/main/java/org/acra/sender/SenderService.java b/acra-core/src/main/java/org/acra/sender/SenderService.java index e2dd68849f..31917fe2b3 100644 --- a/acra-core/src/main/java/org/acra/sender/SenderService.java +++ b/acra-core/src/main/java/org/acra/sender/SenderService.java @@ -162,9 +162,21 @@ private void sendReports(@NonNull CoreConfiguration config, boolean onlySendSile @NonNull private List getSenderInstances(@NonNull CoreConfiguration config) { List> factoryClasses = config.reportSenderFactoryClasses(); - List factories = !factoryClasses.isEmpty() ? new InstanceCreator().create(factoryClasses) : config.pluginLoader() - .loadEnabled(this, config, ReportSenderFactory.class); + + if (ACRA.DEV_LOGGING) ACRA.log.d(LOG_TAG, "config#reportSenderFactoryClasses : " + factoryClasses); + + final List factories; + if (factoryClasses.isEmpty()) { + if (ACRA.DEV_LOGGING) ACRA.log.d(LOG_TAG, "Using PluginLoader to find ReportSender factories"); + final PluginLoader loader = config.pluginLoader(); + factories = loader.loadEnabled(config, ReportSenderFactory.class); + } else { + if (ACRA.DEV_LOGGING) ACRA.log.d(LOG_TAG, "Creating reportSenderFactories for reportSenderFactory config"); + factories = new InstanceCreator().create(factoryClasses); + } if (ACRA.DEV_LOGGING) ACRA.log.d(LOG_TAG, "reportSenderFactories : " + factories); + + final List reportSenders = new ArrayList<>(); for (ReportSenderFactory factory : factories) { final ReportSender sender = factory.create(this.getApplication(), config); diff --git a/acra-core/src/main/java/org/acra/startup/StartupProcessorExecutor.java b/acra-core/src/main/java/org/acra/startup/StartupProcessorExecutor.java index 882298c114..fe0478e172 100644 --- a/acra-core/src/main/java/org/acra/startup/StartupProcessorExecutor.java +++ b/acra-core/src/main/java/org/acra/startup/StartupProcessorExecutor.java @@ -63,7 +63,7 @@ public void processReports(boolean isAcraEnabled) { for (File r : reportLocator.getApprovedReports()) { reports.add(new Report(r, true)); } - final List startupProcessors = config.pluginLoader().loadEnabled(context, config, StartupProcessor.class); + final List startupProcessors = config.pluginLoader().loadEnabled(config, StartupProcessor.class); for (StartupProcessor processor : startupProcessors) { processor.processReports(context, config, reports); } diff --git a/acra-core/src/main/java/org/acra/startup/UnapprovedStartupProcessor.java b/acra-core/src/main/java/org/acra/startup/UnapprovedStartupProcessor.java index 02fd9cb5d0..f2a716b05b 100644 --- a/acra-core/src/main/java/org/acra/startup/UnapprovedStartupProcessor.java +++ b/acra-core/src/main/java/org/acra/startup/UnapprovedStartupProcessor.java @@ -18,7 +18,7 @@ import android.content.Context; import android.support.annotation.NonNull; -import com.faendir.asl.annotation.AutoService; +import com.google.auto.service.AutoService; import org.acra.config.CoreConfiguration; import org.acra.file.LastModifiedComparator; diff --git a/acra-core/src/test/java/org/acra/ACRATest.java b/acra-core/src/test/java/org/acra/ACRATest.java index 7e9e1436f6..09d7c12ded 100644 --- a/acra-core/src/test/java/org/acra/ACRATest.java +++ b/acra-core/src/test/java/org/acra/ACRATest.java @@ -19,7 +19,6 @@ import android.app.Application; import android.content.Context; import android.support.annotation.NonNull; -import androidx.test.core.app.ApplicationProvider; import org.acra.builder.ReportBuilder; import org.acra.collector.StacktraceCollector; import org.acra.config.CoreConfiguration; @@ -30,6 +29,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.robolectric.RobolectricTestRunner; +import org.robolectric.RuntimeEnvironment; import static org.hamcrest.Matchers.containsString; import static org.junit.Assert.*; @@ -43,7 +43,7 @@ public class ACRATest { @Test public void init() { - Application application = ApplicationProvider.getApplicationContext(); + Application application = RuntimeEnvironment.application; CoreConfigurationBuilder builder = new CoreConfigurationBuilder(application).setPluginLoader(new SimplePluginLoader(StacktraceCollector.class, TestAdministrator.class)); ACRA.init(application, builder); ACRA.getErrorReporter().handleException(new RuntimeException()); @@ -51,7 +51,7 @@ public void init() { @Test(expected = AssertionError.class) public void failing() { - Application application = ApplicationProvider.getApplicationContext(); + Application application = RuntimeEnvironment.application; CoreConfigurationBuilder builder = new CoreConfigurationBuilder(application).setPluginLoader(new SimplePluginLoader(FailingTestAdministrator.class)); ACRA.init(application, builder); ACRA.getErrorReporter().handleException(new RuntimeException()); diff --git a/acra-core/src/test/java/org/acra/attachment/AcraContentProviderTest.java b/acra-core/src/test/java/org/acra/attachment/AcraContentProviderTest.java index 6d225d1970..61e88bfc39 100644 --- a/acra-core/src/test/java/org/acra/attachment/AcraContentProviderTest.java +++ b/acra-core/src/test/java/org/acra/attachment/AcraContentProviderTest.java @@ -21,8 +21,9 @@ import android.net.Uri; import android.provider.OpenableColumns; import android.webkit.MimeTypeMap; -import androidx.test.core.app.ApplicationProvider; + import com.google.common.net.MediaType; + import org.acra.ACRA; import org.acra.log.RobolectricLog; import org.junit.Before; @@ -30,11 +31,15 @@ import org.junit.runner.RunWith; import org.robolectric.Robolectric; import org.robolectric.RobolectricTestRunner; +import org.robolectric.RuntimeEnvironment; import org.robolectric.Shadows; import java.io.File; -import static junit.framework.Assert.*; +import static junit.framework.Assert.assertEquals; +import static junit.framework.Assert.assertFalse; +import static junit.framework.Assert.assertNotNull; +import static junit.framework.Assert.assertTrue; /** * @author F43nd1r @@ -52,15 +57,15 @@ public class AcraContentProviderTest { public void setUp() throws Exception { ACRA.log = new RobolectricLog(); ACRA.DEV_LOGGING = true; - Robolectric.setupContentProvider(AcraContentProvider.class, ApplicationProvider.getApplicationContext().getPackageName() + ".acra"); - resolver = ApplicationProvider.getApplicationContext().getContentResolver(); + Robolectric.setupContentProvider(AcraContentProvider.class, RuntimeEnvironment.application.getPackageName() + ".acra"); + resolver = RuntimeEnvironment.application.getContentResolver(); file = File.createTempFile("test", "." + JSON_EXTENSION); Shadows.shadowOf(MimeTypeMap.getSingleton()).addExtensionMimeTypMapping(JSON_EXTENSION, JSON_MIMETYPE); } @Test public void query() { - final Cursor cursor = resolver.query(AcraContentProvider.getUriForFile(ApplicationProvider.getApplicationContext(), file), new String[]{OpenableColumns.SIZE, OpenableColumns.DISPLAY_NAME}, null, null, null); + final Cursor cursor = resolver.query(AcraContentProvider.getUriForFile(RuntimeEnvironment.application, file), new String[]{OpenableColumns.SIZE, OpenableColumns.DISPLAY_NAME}, null, null, null); assertNotNull(cursor); assertTrue(cursor.moveToFirst()); assertEquals(file.length(), cursor.getInt(0)); @@ -71,14 +76,14 @@ public void query() { @Test public void openFile() throws Exception { - final Uri uri = AcraContentProvider.getUriForFile(ApplicationProvider.getApplicationContext(), file); + final Uri uri = AcraContentProvider.getUriForFile(RuntimeEnvironment.application, file); assertNotNull(resolver.openFileDescriptor(uri, "r")); } @Test public void guessMimeType() { - assertEquals(JSON_MIMETYPE, AcraContentProvider.guessMimeType(AcraContentProvider.getUriForFile(ApplicationProvider.getApplicationContext(), file))); + assertEquals(JSON_MIMETYPE, AcraContentProvider.guessMimeType(AcraContentProvider.getUriForFile(RuntimeEnvironment.application, file))); } } \ No newline at end of file diff --git a/acra-core/src/test/java/org/acra/attachment/DefaultAttachmentProviderTest.java b/acra-core/src/test/java/org/acra/attachment/DefaultAttachmentProviderTest.java index f800aadf90..71ad3867d3 100644 --- a/acra-core/src/test/java/org/acra/attachment/DefaultAttachmentProviderTest.java +++ b/acra-core/src/test/java/org/acra/attachment/DefaultAttachmentProviderTest.java @@ -18,11 +18,12 @@ import android.app.Application; import android.net.Uri; -import androidx.test.core.app.ApplicationProvider; + import org.acra.config.CoreConfigurationBuilder; import org.junit.Test; import org.junit.runner.RunWith; import org.robolectric.RobolectricTestRunner; +import org.robolectric.RuntimeEnvironment; import java.util.List; @@ -39,8 +40,7 @@ public class DefaultAttachmentProviderTest { @Test public void getAttachments() throws Exception { Uri uri = Uri.parse("content://not-a-valid-content-uri"); - Application application = ApplicationProvider.getApplicationContext(); - List result = new DefaultAttachmentProvider().getAttachments(application, new CoreConfigurationBuilder(application).setAttachmentUris(uri.toString()).build()); + List result = new DefaultAttachmentProvider().getAttachments(RuntimeEnvironment.application, new CoreConfigurationBuilder(new Application()).setAttachmentUris(uri.toString()).build()); assertThat(result, hasSize(1)); assertEquals(uri, result.get(0)); } diff --git a/acra-core/src/test/java/org/acra/util/InstallationTest.java b/acra-core/src/test/java/org/acra/util/InstallationTest.java index 4ab0a52bfc..170c2bf4c6 100644 --- a/acra-core/src/test/java/org/acra/util/InstallationTest.java +++ b/acra-core/src/test/java/org/acra/util/InstallationTest.java @@ -16,10 +16,10 @@ package org.acra.util; -import androidx.test.core.app.ApplicationProvider; import org.junit.Test; import org.junit.runner.RunWith; import org.robolectric.RobolectricTestRunner; +import org.robolectric.RuntimeEnvironment; import java.io.File; @@ -35,12 +35,12 @@ public class InstallationTest { @Test public void id() { - final String id = Installation.id(ApplicationProvider.getApplicationContext()); - assertEquals(id, Installation.id(ApplicationProvider.getApplicationContext())); - for(File child : ApplicationProvider.getApplicationContext().getFilesDir().listFiles()){ + final String id = Installation.id(RuntimeEnvironment.application); + assertEquals(id, Installation.id(RuntimeEnvironment.application)); + for(File child : RuntimeEnvironment.application.getFilesDir().listFiles()){ if(child.isFile()) child.delete(); } - assertThat(Installation.id(ApplicationProvider.getApplicationContext()), not(id)); + assertThat(Installation.id(RuntimeEnvironment.application), not(id)); } } \ No newline at end of file diff --git a/acra-dialog/build.gradle b/acra-dialog/build.gradle index a9c3b52f25..095cd911e6 100644 --- a/acra-dialog/build.gradle +++ b/acra-dialog/build.gradle @@ -22,6 +22,7 @@ dependencies { //noinspection GradleDependency implementation("com.android.support:support-fragment:$supportVersion@aar") { transitive = true } api project(':acra-core') + compileOnly "com.google.auto.service:auto-service:$autoServiceVersion" annotationProcessor project(':annotationprocessor') compileOnly project(':annotations') } diff --git a/acra-dialog/src/main/java/org/acra/interaction/DialogInteraction.java b/acra-dialog/src/main/java/org/acra/interaction/DialogInteraction.java index 6386184482..2044c4e8c6 100644 --- a/acra-dialog/src/main/java/org/acra/interaction/DialogInteraction.java +++ b/acra-dialog/src/main/java/org/acra/interaction/DialogInteraction.java @@ -21,7 +21,7 @@ import android.content.SharedPreferences; import android.support.annotation.NonNull; -import com.faendir.asl.annotation.AutoService; +import com.google.auto.service.AutoService; import org.acra.ACRA; import org.acra.config.ConfigUtils; diff --git a/acra-http/build.gradle b/acra-http/build.gradle index 45c8583e86..6df9403c2a 100644 --- a/acra-http/build.gradle +++ b/acra-http/build.gradle @@ -20,6 +20,7 @@ apply plugin: 'com.jfrog.bintray' dependencies { api project(':acra-core') + compileOnly "com.google.auto.service:auto-service:$autoServiceVersion" annotationProcessor project(':annotationprocessor') compileOnly project(':annotations') } diff --git a/acra-http/src/main/java/org/acra/sender/HttpSenderFactory.java b/acra-http/src/main/java/org/acra/sender/HttpSenderFactory.java index 76b0831100..aae7fd1cfb 100644 --- a/acra-http/src/main/java/org/acra/sender/HttpSenderFactory.java +++ b/acra-http/src/main/java/org/acra/sender/HttpSenderFactory.java @@ -19,7 +19,7 @@ import android.content.Context; import android.support.annotation.NonNull; -import com.faendir.asl.annotation.AutoService; +import com.google.auto.service.AutoService; import org.acra.config.CoreConfiguration; import org.acra.config.HttpSenderConfiguration; diff --git a/acra-limiter/build.gradle b/acra-limiter/build.gradle index 45c8583e86..6df9403c2a 100644 --- a/acra-limiter/build.gradle +++ b/acra-limiter/build.gradle @@ -20,6 +20,7 @@ apply plugin: 'com.jfrog.bintray' dependencies { api project(':acra-core') + compileOnly "com.google.auto.service:auto-service:$autoServiceVersion" annotationProcessor project(':annotationprocessor') compileOnly project(':annotations') } diff --git a/acra-limiter/src/main/java/org/acra/config/LimitingReportAdministrator.java b/acra-limiter/src/main/java/org/acra/config/LimitingReportAdministrator.java index 2784ae3829..cb245408e8 100644 --- a/acra-limiter/src/main/java/org/acra/config/LimitingReportAdministrator.java +++ b/acra-limiter/src/main/java/org/acra/config/LimitingReportAdministrator.java @@ -22,9 +22,7 @@ import android.os.Looper; import android.support.annotation.NonNull; import android.widget.Toast; - -import com.faendir.asl.annotation.AutoService; - +import com.google.auto.service.AutoService; import org.acra.ACRA; import org.acra.builder.ReportBuilder; import org.acra.data.CrashReportData; diff --git a/acra-limiter/src/main/java/org/acra/startup/LimiterStartupProcessor.java b/acra-limiter/src/main/java/org/acra/startup/LimiterStartupProcessor.java index 202b089115..8b93c05ad5 100644 --- a/acra-limiter/src/main/java/org/acra/startup/LimiterStartupProcessor.java +++ b/acra-limiter/src/main/java/org/acra/startup/LimiterStartupProcessor.java @@ -20,7 +20,7 @@ import android.content.SharedPreferences; import android.content.pm.PackageInfo; import android.support.annotation.NonNull; -import com.faendir.asl.annotation.AutoService; +import com.google.auto.service.AutoService; import org.acra.ACRA; import org.acra.config.ConfigUtils; import org.acra.config.CoreConfiguration; diff --git a/acra-mail/build.gradle b/acra-mail/build.gradle index 45c8583e86..6df9403c2a 100644 --- a/acra-mail/build.gradle +++ b/acra-mail/build.gradle @@ -20,6 +20,7 @@ apply plugin: 'com.jfrog.bintray' dependencies { api project(':acra-core') + compileOnly "com.google.auto.service:auto-service:$autoServiceVersion" annotationProcessor project(':annotationprocessor') compileOnly project(':annotations') } diff --git a/acra-mail/src/main/java/org/acra/sender/EmailIntentSenderFactory.java b/acra-mail/src/main/java/org/acra/sender/EmailIntentSenderFactory.java index aca66e80b5..e767f47f5c 100644 --- a/acra-mail/src/main/java/org/acra/sender/EmailIntentSenderFactory.java +++ b/acra-mail/src/main/java/org/acra/sender/EmailIntentSenderFactory.java @@ -18,7 +18,7 @@ import android.content.Context; import android.support.annotation.NonNull; -import com.faendir.asl.annotation.AutoService; +import com.google.auto.service.AutoService; import org.acra.config.CoreConfiguration; import org.acra.config.MailSenderConfiguration; import org.acra.plugins.HasConfigPlugin; diff --git a/acra-notification/build.gradle b/acra-notification/build.gradle index ae9b17993e..9767eecd3c 100644 --- a/acra-notification/build.gradle +++ b/acra-notification/build.gradle @@ -21,6 +21,7 @@ apply plugin: 'com.jfrog.bintray' dependencies { api project(':acra-core') implementation("com.android.support:support-compat:$supportVersion@aar") { transitive = true } + compileOnly "com.google.auto.service:auto-service:$autoServiceVersion" annotationProcessor project(':annotationprocessor') compileOnly project(':annotations') } diff --git a/acra-notification/src/main/java/org/acra/interaction/NotificationInteraction.java b/acra-notification/src/main/java/org/acra/interaction/NotificationInteraction.java index d9e936d436..cf44dbc3e6 100644 --- a/acra-notification/src/main/java/org/acra/interaction/NotificationInteraction.java +++ b/acra-notification/src/main/java/org/acra/interaction/NotificationInteraction.java @@ -28,7 +28,7 @@ import android.support.v4.app.RemoteInput; import android.widget.RemoteViews; -import com.faendir.asl.annotation.AutoService; +import com.google.auto.service.AutoService; import org.acra.ACRA; import org.acra.config.ConfigUtils; diff --git a/acra-toast/build.gradle b/acra-toast/build.gradle index 45c8583e86..6df9403c2a 100644 --- a/acra-toast/build.gradle +++ b/acra-toast/build.gradle @@ -20,6 +20,7 @@ apply plugin: 'com.jfrog.bintray' dependencies { api project(':acra-core') + compileOnly "com.google.auto.service:auto-service:$autoServiceVersion" annotationProcessor project(':annotationprocessor') compileOnly project(':annotations') } diff --git a/acra-toast/src/main/java/org/acra/interaction/ToastInteraction.java b/acra-toast/src/main/java/org/acra/interaction/ToastInteraction.java index d037b12d51..6c870acd05 100644 --- a/acra-toast/src/main/java/org/acra/interaction/ToastInteraction.java +++ b/acra-toast/src/main/java/org/acra/interaction/ToastInteraction.java @@ -23,7 +23,7 @@ import android.support.annotation.NonNull; import android.widget.Toast; -import com.faendir.asl.annotation.AutoService; +import com.google.auto.service.AutoService; import org.acra.config.ConfigUtils; import org.acra.config.CoreConfiguration; diff --git a/annotationprocessor/build.gradle b/annotationprocessor/build.gradle index bd66605832..3084170e10 100644 --- a/annotationprocessor/build.gradle +++ b/annotationprocessor/build.gradle @@ -19,7 +19,6 @@ apply plugin: 'java' dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile "com.google.auto.service:auto-service:$autoServiceVersion" - compile "com.faendir.asl:annotation:1.0" compile 'com.squareup:javapoet:1.9.0' compile 'org.apache.commons:commons-lang3:3.7' compile 'org.apache.commons:commons-text:1.1' diff --git a/annotationprocessor/src/main/java/org/acra/processor/creator/ClassCreator.java b/annotationprocessor/src/main/java/org/acra/processor/creator/ClassCreator.java index 5b9fa148a0..a3132f63b4 100644 --- a/annotationprocessor/src/main/java/org/acra/processor/creator/ClassCreator.java +++ b/annotationprocessor/src/main/java/org/acra/processor/creator/ClassCreator.java @@ -18,7 +18,7 @@ import android.support.annotation.NonNull; import com.google.auto.common.MoreTypes; -import com.faendir.asl.annotation.AutoService; +import com.google.auto.service.AutoService; import com.squareup.javapoet.*; import org.acra.annotation.Configuration; import org.acra.config.ConfigurationBuilder; diff --git a/build.gradle b/build.gradle index b46613f867..9d7e1b6e8c 100644 --- a/build.gradle +++ b/build.gradle @@ -114,16 +114,9 @@ subprojects { sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8 } - sourceSets { - main { - assets.srcDirs += "build/generated/assets/serviceloader/release" - } - } } dependencies { - compileOnly "com.faendir.asl:annotation:$aslVersion" - annotationProcessor "com.faendir.asl:processor:$aslVersion" testImplementation "junit:junit:$junitVersion" testImplementation "org.robolectric:robolectric:$roboelectricVersion" testImplementation "androidx.test:core:$androidTestVersion" diff --git a/gradle.properties b/gradle.properties index 98fbde8b6f..d21b368454 100644 --- a/gradle.properties +++ b/gradle.properties @@ -39,5 +39,4 @@ junitVersion=4.12 roboelectricVersion=4.0.2 androidTestVersion=1.0.0 jobVersion=1.2.6 -aslVersion=1.0.1 workVersion=1.0.0-alpha12 \ No newline at end of file