File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed
OneSignalSDK/onesignal/src/main/java/com/onesignal Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change 27
27
28
28
package com .onesignal ;
29
29
30
+ import android .annotation .TargetApi ;
30
31
import android .app .Activity ;
31
32
import android .content .ContentResolver ;
32
33
import android .content .Context ;
40
41
import android .net .Uri ;
41
42
import android .os .Build ;
42
43
import android .os .Bundle ;
44
+ import android .os .DeadSystemException ;
43
45
import android .os .Handler ;
44
46
import android .os .Looper ;
45
47
@@ -298,9 +300,21 @@ static boolean isGMSInstalledAndEnabled() {
298
300
}
299
301
300
302
private static final int HMS_AVAILABLE_SUCCESSFUL = 0 ;
303
+ @ TargetApi (24 )
301
304
private static boolean isHMSCoreInstalledAndEnabled () {
302
305
HuaweiApiAvailability availability = HuaweiApiAvailability .getInstance ();
303
- return availability .isHuaweiMobileServicesAvailable (OneSignal .appContext ) == HMS_AVAILABLE_SUCCESSFUL ;
306
+ try {
307
+ return availability .isHuaweiMobileServicesAvailable (OneSignal .appContext ) == HMS_AVAILABLE_SUCCESSFUL ;
308
+ } catch (Exception e ) {
309
+ // Suppressing DeadSystemException as the app is already dying for
310
+ // another reason and allowing this exception to bubble up would
311
+ // create a red herring for app developers. We still re-throw
312
+ // others, as we don't want to silently hide other issues.
313
+ if (!(e instanceof DeadSystemException )) {
314
+ throw e ;
315
+ }
316
+ return false ;
317
+ }
304
318
}
305
319
306
320
private static final String HMS_CORE_SERVICES_PACKAGE = "com.huawei.hwid" ; // = HuaweiApiAvailability.SERVICES_PACKAGE
You can’t perform that action at this time.
0 commit comments