1
0
Fork 0

For #3505: Opening a sent tab crashes Fenix (#3507)

master
Colin Lee 2019-06-27 10:47:54 -05:00 committed by GitHub
parent 6ccd32f093
commit 7481d52c4b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View File

@ -9,6 +9,7 @@ import android.content.Intent
import android.os.Bundle
import mozilla.components.browser.session.tab.CustomTabConfig
import mozilla.components.support.utils.SafeIntent
import org.mozilla.fenix.components.NotificationManager.Companion.RECEIVE_TABS_TAG
import org.mozilla.fenix.customtabs.CustomTabActivity
import org.mozilla.fenix.ext.components
import org.mozilla.fenix.utils.Settings
@ -38,7 +39,9 @@ class IntentReceiverActivity : Activity() {
}
intent.action == Intent.ACTION_VIEW -> {
intent.setClassName(applicationContext, HomeActivity::class.java.name)
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
if (!intent.getBooleanExtra(RECEIVE_TABS_TAG, false)) {
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
}
true
}
else -> {

View File

@ -55,7 +55,10 @@ class NotificationManager(private val context: Context) {
logger.debug("Showing ${event.entries.size} tab(s) received from deviceID=${event.from?.id}")
event.entries.forEach { tab ->
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(tab.url))
val pendingIntent: PendingIntent = PendingIntent.getActivity(context, 0, intent, 0)
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
intent.putExtra(RECEIVE_TABS_TAG, true)
val pendingIntent: PendingIntent =
PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_ONE_SHOT)
val builder = NotificationCompat.Builder(context, RECEIVE_TABS_CHANNEL_ID)
.setSmallIcon(R.drawable.ic_status_logo)