mirror of
https://github.com/TeamVanced/VancedMicroG
synced 2024-11-19 02:29:25 +01:00
Fix NullReferenceException
This commit is contained in:
parent
6016d001a4
commit
eb6f2b2fc7
@ -53,28 +53,30 @@ private suspend fun ensureCheckinIsUpToDate(context: Context) {
|
||||
}
|
||||
|
||||
private suspend fun ensureAppRegistrationAllowed(context: Context, database: GcmDatabase, packageName: String) {
|
||||
if (!GcmPrefs.get(context).isEnabled) throw RuntimeException("GCM disabled")
|
||||
val app = database.getApp(packageName)
|
||||
if (app == null && GcmPrefs.get(context).isConfirmNewApps) {
|
||||
val accepted: Boolean = suspendCoroutine { continuation ->
|
||||
val i = Intent(context, AskPushPermission::class.java)
|
||||
i.putExtra(AskPushPermission.EXTRA_REQUESTED_PACKAGE, packageName)
|
||||
i.putExtra(AskPushPermission.EXTRA_RESULT_RECEIVER, object : ResultReceiver(null) {
|
||||
override fun onReceiveResult(resultCode: Int, resultData: Bundle?) {
|
||||
continuation.resume(resultCode == Activity.RESULT_OK)
|
||||
}
|
||||
})
|
||||
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
i.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS)
|
||||
i.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT)
|
||||
context.startActivity(i)
|
||||
}
|
||||
if (!accepted) {
|
||||
try {
|
||||
if (!GcmPrefs.get(context).isEnabled) throw RuntimeException("GCM disabled")
|
||||
val app = database.getApp(packageName)
|
||||
if (app == null && GcmPrefs.get(context).isConfirmNewApps) {
|
||||
val accepted: Boolean = suspendCoroutine { continuation ->
|
||||
val i = Intent(context, AskPushPermission::class.java)
|
||||
i.putExtra(AskPushPermission.EXTRA_REQUESTED_PACKAGE, packageName)
|
||||
i.putExtra(AskPushPermission.EXTRA_RESULT_RECEIVER, object : ResultReceiver(null) {
|
||||
override fun onReceiveResult(resultCode: Int, resultData: Bundle?) {
|
||||
continuation.resume(resultCode == Activity.RESULT_OK)
|
||||
}
|
||||
})
|
||||
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
i.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS)
|
||||
i.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT)
|
||||
context.startActivity(i)
|
||||
}
|
||||
if (!accepted) {
|
||||
throw RuntimeException("Push permission not granted to app")
|
||||
}
|
||||
} else if (!app.allowRegister) {
|
||||
throw RuntimeException("Push permission not granted to app")
|
||||
}
|
||||
} else if (!app.allowRegister) {
|
||||
throw RuntimeException("Push permission not granted to app")
|
||||
}
|
||||
} catch (e: Exception) {}
|
||||
}
|
||||
|
||||
suspend fun completeRegisterRequest(context: Context, database: GcmDatabase, request: RegisterRequest, requestId: String? = null): Bundle = suspendCoroutine { continuation ->
|
||||
|
Loading…
Reference in New Issue
Block a user