diff --git a/mobile/android/android-components/components/support/utils/src/main/java/mozilla/components/support/utils/SafeIntent.kt b/mobile/android/android-components/components/support/utils/src/main/java/mozilla/components/support/utils/SafeIntent.kt index 71b718d71a4c..9cd8df391fb7 100644 --- a/mobile/android/android-components/components/support/utils/src/main/java/mozilla/components/support/utils/SafeIntent.kt +++ b/mobile/android/android-components/components/support/utils/src/main/java/mozilla/components/support/utils/SafeIntent.kt @@ -113,3 +113,5 @@ fun Intent.toSafeIntent(): SafeIntent = SafeIntent(this) const val EXTRA_ACTIVITY_REFERRER_PACKAGE = "activity_referrer_package" const val EXTRA_ACTIVITY_REFERRER_CATEGORY = "activity_referrer_category" + +const val INTENT_TYPE_PDF = "application/pdf" diff --git a/mobile/android/fenix/app/metrics.yaml b/mobile/android/fenix/app/metrics.yaml index c9af803f4412..702ea8b80692 100644 --- a/mobile/android/fenix/app/metrics.yaml +++ b/mobile/android/fenix/app/metrics.yaml @@ -376,6 +376,27 @@ events: metadata: tags: - PrivateBrowsing + opened_ext_pdf: + type: event + description: | + A user opened a PDF with Fenix from another app + extra_keys: + referrer_is_fenix: + description: | + If the PDF was opened from Fenix itself (for example from the Download notification) + type: boolean + bugs: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1871548 + data_reviews: + - https://github.com/mozilla-mobile/firefox-android/pull/4940 + data_sensitivity: + - interaction + notification_emails: + - android-probes@mozilla.com + - mcastelluccio@mozilla.com + - calixte@mozilla.com + - sylvestre@mozilla.com + expires: never synced_tab_opened: type: event description: | diff --git a/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/IntentReceiverActivity.kt b/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/IntentReceiverActivity.kt index 32b89d5a7dc0..2ebb6bd3e6c7 100644 --- a/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/IntentReceiverActivity.kt +++ b/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/IntentReceiverActivity.kt @@ -15,6 +15,7 @@ import mozilla.components.feature.intent.ext.sanitize import mozilla.components.feature.intent.processing.IntentProcessor import mozilla.components.support.utils.EXTRA_ACTIVITY_REFERRER_CATEGORY import mozilla.components.support.utils.EXTRA_ACTIVITY_REFERRER_PACKAGE +import mozilla.components.support.utils.INTENT_TYPE_PDF import mozilla.components.support.utils.ext.getApplicationInfoCompat import org.mozilla.fenix.GleanMetrics.Events import org.mozilla.fenix.HomeActivity.Companion.PRIVATE_BROWSING_MODE @@ -73,6 +74,12 @@ class IntentReceiverActivity : Activity() { addReferrerInformation(intent) + if (intent.type == INTENT_TYPE_PDF) { + val referrerIsFenix = + intent.getStringExtra(EXTRA_ACTIVITY_REFERRER_PACKAGE) == this.packageName + Events.openedExtPdf.record(Events.OpenedExtPdfExtra(referrerIsFenix)) + } + val processor = getIntentProcessors(private).firstOrNull { it.process(intent) } val intentProcessorType = components.intentProcessors.getType(processor)