@@ -134,65 +134,69 @@ int initializationChecker(Context context, String oneSignalAppId) {
134
134
return subscribableStatus ;
135
135
}
136
136
137
+ // The the following is done to ensure Proguard compatibility with class existent detection
138
+ // 1. Using Class instead of Strings as class renames would result incorrectly not finding the class
139
+ // 2. class.getName() is called as if no method is called then the try-catch would be removed.
140
+ // - Only an issue when using Proguard (NOT R8) and using getDefaultProguardFile('proguard-android-optimize.txt')
141
+
137
142
static boolean hasFCMLibrary () {
138
143
try {
139
- // Using class instead of Strings for proguard compatibility
140
- // noinspection ConstantConditions
141
- return com .google .firebase .messaging .FirebaseMessaging .class != null ;
142
- } catch (Throwable e ) {
144
+ com .google .firebase .messaging .FirebaseMessaging .class .getName ();
145
+ return true ;
146
+ } catch (NoClassDefFoundError e ) {
143
147
return false ;
144
148
}
145
149
}
146
150
147
151
private static boolean hasGCMLibrary () {
148
152
try {
149
- // noinspection ConstantConditions
150
- return com . google . android . gms . gcm . GoogleCloudMessaging . class != null ;
151
- } catch (Throwable e ) {
153
+ com . google . android . gms . gcm . GoogleCloudMessaging . class . getName ();
154
+ return true ;
155
+ } catch (NoClassDefFoundError e ) {
152
156
return false ;
153
157
}
154
158
}
155
159
156
160
static boolean hasGMSLocationLibrary () {
157
161
try {
158
- // noinspection ConstantConditions
159
- return com . google . android . gms . location . LocationListener . class != null ;
162
+ com . google . android . gms . location . LocationListener . class . getName ();
163
+ return true ;
160
164
} catch (NoClassDefFoundError e ) {
161
165
return false ;
162
166
}
163
167
}
164
168
165
169
private static boolean hasHMSAvailabilityLibrary () {
166
170
try {
167
- // noinspection ConstantConditions
168
- return com . huawei . hms . api . HuaweiApiAvailability . class != null ;
171
+ com . huawei . hms . api . HuaweiApiAvailability . class . getName ();
172
+ return true ;
169
173
} catch (NoClassDefFoundError e ) {
170
174
return false ;
171
175
}
172
176
}
173
177
174
178
private static boolean hasHMSPushKitLibrary () {
175
179
try {
176
- // noinspection ConstantConditions
177
- return com . huawei . hms . aaid . HmsInstanceId . class != null ;
180
+ com . huawei . hms . aaid . HmsInstanceId . class . getName ();
181
+ return true ;
178
182
} catch (NoClassDefFoundError e ) {
179
183
return false ;
180
184
}
181
185
}
182
186
183
187
private static boolean hasHMSAGConnectLibrary () {
184
188
try {
185
- // noinspection ConstantConditions
186
- return com . huawei . agconnect . config . AGConnectServicesConfig . class != null ;
189
+ com . huawei . agconnect . config . AGConnectServicesConfig . class . getName ();
190
+ return true ;
187
191
} catch (NoClassDefFoundError e ) {
188
192
return false ;
189
193
}
190
194
}
191
195
192
196
static boolean hasHMSLocationLibrary () {
193
197
try {
194
- // noinspection ConstantConditions
195
- return com . huawei . hms . location . LocationCallback . class != null ;
198
+ com . huawei . hms . location . LocationCallback . class . getName ();
199
+ return true ;
196
200
} catch (NoClassDefFoundError e ) {
197
201
return false ;
198
202
}
0 commit comments