Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import com.duckduckgo.app.fire.DataClearerForegroundAppRestartPixel
import com.duckduckgo.app.global.ApplicationClearDataState
import com.duckduckgo.app.global.DuckDuckGoActivity
import com.duckduckgo.app.global.intentText
import com.duckduckgo.app.global.sanitize
import com.duckduckgo.app.global.view.*
import com.duckduckgo.app.location.ui.LocationPermissionsActivity
import com.duckduckgo.app.onboarding.ui.page.DefaultBrowserPage
Expand Down Expand Up @@ -127,6 +128,9 @@ class BrowserActivity : DuckDuckGoActivity(), CoroutineScope by MainScope() {
override fun onNewIntent(intent: Intent?) {
super.onNewIntent(intent)
Timber.i("onNewIntent: $intent")

intent?.sanitize()

dataClearerForegroundAppRestartPixel.registerIntent(intent)

if (dataClearer.dataClearerState.value == ApplicationClearDataState.FINISHED) {
Expand Down
19 changes: 19 additions & 0 deletions app/src/main/java/com/duckduckgo/app/global/IntentExtension.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,27 @@
package com.duckduckgo.app.global

import android.content.Intent
import android.os.BadParcelableException
import android.os.Bundle
import timber.log.Timber

val Intent.intentText: String?
get() {
return data?.toString() ?: getStringExtra(Intent.EXTRA_TEXT)
}

fun Intent.sanitize() {

try {
// The strings are empty to force unparcel() call in BaseBundle
getStringExtra("")
getBooleanExtra("", false)
} catch (e: BadParcelableException) {
Timber.e(e, "Failed to read Parcelable from intent")
replaceExtras(Bundle())

} catch (e: RuntimeException) {
Timber.e(e, "Failed to receive extras from intent")
replaceExtras(Bundle())
}
}