Use random ints for request codes to ensure no overlap (#3427)

This commit is contained in:
David Perez 2024-07-09 14:13:58 -05:00 committed by GitHub
parent 0dc606b470
commit 5677373421
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 7 additions and 5 deletions

View file

@ -18,7 +18,7 @@ import com.x8bit.bitwarden.data.autofill.model.AutofillSelectionData
import com.x8bit.bitwarden.data.autofill.model.AutofillTotpCopyData
import com.x8bit.bitwarden.data.platform.annotation.OmitFromCoverage
import com.x8bit.bitwarden.data.platform.util.getSafeParcelableExtra
import java.util.UUID
import kotlin.random.Random
private const val AUTOFILL_SAVE_ITEM_DATA_KEY = "autofill-save-item-data"
private const val AUTOFILL_SELECTION_DATA_KEY = "autofill-selection-data"
@ -67,7 +67,7 @@ fun createTotpCopyIntentSender(
return PendingIntent
.getActivity(
context,
UUID.randomUUID().hashCode(),
Random.nextInt(),
intent,
PendingIntent.FLAG_CANCEL_CURRENT.toPendingIntentMutabilityFlag(),
)
@ -93,7 +93,7 @@ fun createAutofillSavedItemIntentSender(
return PendingIntent
.getActivity(
autofillAppInfo.context,
0,
Random.nextInt(),
intent,
PendingIntent.FLAG_CANCEL_CURRENT.toPendingIntentMutabilityFlag(),
)

View file

@ -17,6 +17,7 @@ import com.x8bit.bitwarden.data.autofill.model.FilledData
import com.x8bit.bitwarden.data.autofill.model.FilledItem
import com.x8bit.bitwarden.ui.autofill.buildVaultItemAutofillRemoteViews
import com.x8bit.bitwarden.ui.autofill.util.createVaultItemInlinePresentationOrNull
import kotlin.random.Random
/**
* Returns all the possible [AutofillId]s that were potentially fillable for the given [FilledData].
@ -43,7 +44,7 @@ fun FilledData.buildVaultItemDataset(
val pendingIntent = PendingIntent
.getActivity(
autofillAppInfo.context,
0,
Random.nextInt(),
intent,
PendingIntent.FLAG_CANCEL_CURRENT.toPendingIntentMutabilityFlag(),
)

View file

@ -8,6 +8,7 @@ import android.nfc.NfcAdapter
import com.x8bit.bitwarden.AuthCallbackActivity
import com.x8bit.bitwarden.data.autofill.util.toPendingIntentMutabilityFlag
import com.x8bit.bitwarden.data.platform.annotation.OmitFromCoverage
import kotlin.random.Random
/**
* The default implementation of the [NfcManager].
@ -26,7 +27,7 @@ class NfcManagerImpl(
activity,
PendingIntent.getActivity(
activity,
1,
Random.nextInt(),
Intent(activity, AuthCallbackActivity::class.java).addFlags(
Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP,
),