Skip to content

Commit b2f0fc0

Browse files
committed
Catch for rare "Unknown exception code: 1 msg null" exception.
1 parent ea7de08 commit b2f0fc0

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

OneSignalSDK/onesignal/src/main/java/com/onesignal/AndroidSupportV4Compat.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,23 @@
3333
import android.annotation.TargetApi;
3434
import android.app.Activity;
3535
import android.content.Context;
36+
import android.content.pm.PackageManager;
3637
import android.support.annotation.NonNull;
38+
import android.util.Log;
3739

3840
// Designed as a compat for use of Android Support v4 revision 23.+ methods when an older revision of the library is included with the app developer's project.
3941
class AndroidSupportV4Compat {
4042

4143
static class ContextCompat {
4244
static int checkSelfPermission(@NonNull Context context, @NonNull String permission) {
43-
if (permission == null)
44-
throw new IllegalArgumentException("permission is null");
45-
46-
return context.checkPermission(permission, android.os.Process.myPid(), android.os.Process.myUid());
45+
// Catch for rare "Unknown exception code: 1 msg null" exception
46+
// See https://github.com/one-signal/OneSignal-Android-SDK/issues/48 for more details.
47+
try {
48+
return context.checkPermission(permission, android.os.Process.myPid(), android.os.Process.myUid());
49+
} catch (Throwable t) {
50+
Log.e("OneSignal", "checkSelfPermission failed, returning PERMISSION_DENIED");
51+
return PackageManager.PERMISSION_DENIED;
52+
}
4753
}
4854
}
4955

0 commit comments

Comments
 (0)