77import android .content .pm .PackageInfo ;
88import android .content .res .AssetManager ;
99import android .os .Build ;
10+ import androidx .annotation .NonNull ;
1011import io .sentry .ILogger ;
1112import io .sentry .SendFireAndForgetEnvelopeSender ;
1213import io .sentry .SendFireAndForgetOutboxSender ;
2425import java .util .Properties ;
2526import org .jetbrains .annotations .NotNull ;
2627import org .jetbrains .annotations .Nullable ;
28+ import org .jetbrains .annotations .TestOnly ;
2729
2830/**
2931 * Android Options initializer, it reads configurations from AndroidManifest and sets to the
@@ -41,35 +43,10 @@ private AndroidOptionsInitializer() {}
4143 * @param options the SentryAndroidOptions
4244 * @param context the Application context
4345 */
44- static void init (final @ NotNull SentryAndroidOptions options , final @ NotNull Context context ) {
45- Objects .requireNonNull (context , "The application context is required." );
46- Objects .requireNonNull (options , "The options object is required." );
47-
48- init (options , context , new AndroidLogger (), false , false );
49- }
50-
51- /**
52- * Init method of the Android Options initializer
53- *
54- * @param options the SentryAndroidOptions
55- * @param context the Application context
56- * @param logger the ILogger interface
57- * @param isFragmentAvailable whether the Fragment integration is available on the classpath
58- * @param isTimberAvailable whether the Timber integration is available on the classpath
59- */
60- static void init (
61- final @ NotNull SentryAndroidOptions options ,
62- @ NotNull Context context ,
63- final @ NotNull ILogger logger ,
64- final boolean isFragmentAvailable ,
65- final boolean isTimberAvailable ) {
66- init (
67- options ,
68- context ,
69- logger ,
70- new BuildInfoProvider (logger ),
71- isFragmentAvailable ,
72- isTimberAvailable );
46+ static void loadDefaultAndMetadataOptions (
47+ final @ NotNull SentryAndroidOptions options , @ NotNull Context context ) {
48+ final ILogger logger = new AndroidLogger ();
49+ loadDefaultAndMetadataOptions (options , context , logger , new BuildInfoProvider (logger ));
7350 }
7451
7552 /**
@@ -79,45 +56,12 @@ static void init(
7956 * @param context the Application context
8057 * @param logger the ILogger interface
8158 * @param buildInfoProvider the BuildInfoProvider interface
82- * @param isFragmentAvailable whether the Fragment integration is available on the classpath
83- * @param isTimberAvailable whether the Timber integration is available on the classpath
8459 */
85- static void init (
60+ static void loadDefaultAndMetadataOptions (
8661 final @ NotNull SentryAndroidOptions options ,
8762 @ NotNull Context context ,
8863 final @ NotNull ILogger logger ,
89- final @ NotNull BuildInfoProvider buildInfoProvider ,
90- final boolean isFragmentAvailable ,
91- final boolean isTimberAvailable ) {
92- init (
93- options ,
94- context ,
95- logger ,
96- buildInfoProvider ,
97- new LoadClass (),
98- isFragmentAvailable ,
99- isTimberAvailable );
100- }
101-
102- /**
103- * Init method of the Android Options initializer
104- *
105- * @param options the SentryAndroidOptions
106- * @param context the Application context
107- * @param logger the ILogger interface
108- * @param buildInfoProvider the BuildInfoProvider interface
109- * @param loadClass the LoadClass wrapper
110- * @param isFragmentAvailable whether the Fragment integration is available on the classpath
111- * @param isTimberAvailable whether the Timber integration is available on the classpath
112- */
113- static void init (
114- final @ NotNull SentryAndroidOptions options ,
115- @ NotNull Context context ,
116- final @ NotNull ILogger logger ,
117- final @ NotNull BuildInfoProvider buildInfoProvider ,
118- final @ NotNull LoadClass loadClass ,
119- final boolean isFragmentAvailable ,
120- final boolean isTimberAvailable ) {
64+ final @ NotNull BuildInfoProvider buildInfoProvider ) {
12165 Objects .requireNonNull (context , "The context is required." );
12266
12367 // it returns null if ContextImpl, so let's check for nullability
@@ -135,6 +79,28 @@ static void init(
13579 initializeCacheDirs (context , options );
13680 options .setEnvelopeDiskCache (new AndroidEnvelopeCache (options ));
13781
82+ readDefaultOptionValues (options , context , buildInfoProvider );
83+ }
84+
85+ @ TestOnly
86+ static void initializeIntegrationsAndProcessors (
87+ @ NonNull SentryAndroidOptions options , @ NonNull Context context ) {
88+ initializeIntegrationsAndProcessors (
89+ options ,
90+ context ,
91+ new BuildInfoProvider (new AndroidLogger ()),
92+ new LoadClass (),
93+ false ,
94+ false );
95+ }
96+
97+ static void initializeIntegrationsAndProcessors (
98+ @ NonNull SentryAndroidOptions options ,
99+ @ NonNull Context context ,
100+ @ NonNull BuildInfoProvider buildInfoProvider ,
101+ @ NonNull LoadClass loadClass ,
102+ boolean isFragmentAvailable ,
103+ boolean isTimberAvailable ) {
138104 final ActivityFramesTracker activityFramesTracker =
139105 new ActivityFramesTracker (loadClass , options );
140106
@@ -147,8 +113,6 @@ static void init(
147113 isFragmentAvailable ,
148114 isTimberAvailable );
149115
150- readDefaultOptionValues (options , context , buildInfoProvider );
151-
152116 options .addEventProcessor (
153117 new DefaultAndroidEventProcessor (context , buildInfoProvider , options ));
154118 options .addEventProcessor (new PerformanceAndroidEventProcessor (options , activityFramesTracker ));
0 commit comments