Skip to content

Commit

Permalink
Fix some crash with null values
Browse files Browse the repository at this point in the history
token, and pendingMessages
  • Loading branch information
p1gp1g committed Dec 26, 2023
1 parent fb5dc57 commit d28b099
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ open class EmbeddedDistributorReceiver : BroadcastReceiver() {
open val googleProjectNumber = "0000"

override fun onReceive(context: Context, intent: Intent) {
val token = intent.getStringExtra(EXTRA_TOKEN)!!
val token = intent.getStringExtra(EXTRA_TOKEN) ?: return
Log.d(TAG, "New intent for $token")
when (intent.action) {
ACTION_REGISTER -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,16 @@ class FirebaseReceiver : BroadcastReceiver() {
data.getString("s")?.let { splitId ->
if (pendingMessages.containsKey(mId)) {
Log.d(TAG, "Found pending message")
when (splitId) {
message = when (splitId) {
"1" -> {
message = Base64.decode(b64, Base64.DEFAULT) +
pendingMessages[mId]!!
Base64.decode(b64, Base64.DEFAULT) +
(pendingMessages[mId] ?: ByteArray(0))
}
"2" -> {
message = pendingMessages[mId]!! +
(pendingMessages[mId] ?: ByteArray(0)) +
Base64.decode(b64, Base64.DEFAULT)
}
else -> ByteArray(0)
}
pendingMessages.remove(mId)
} else {
Expand Down

0 comments on commit d28b099

Please sign in to comment.