From c24b0041cf05d87855b999dd80c7d1b911fd1e1d Mon Sep 17 00:00:00 2001 From: Segun Famisa Date: Tue, 8 Apr 2025 10:31:35 +0000 Subject: [PATCH] Bug 1947523 - Remove os_navigation_uses_gestures telemetry r=android-reviewers,petru # Conflicts: # mobile/android/fenix/app/src/main/java/org/mozilla/fenix/HomeActivity.kt Differential Revision: https://phabricator.services.mozilla.com/D244367 --- mobile/android/fenix/app/metrics.yaml | 16 ----- .../java/org/mozilla/fenix/HomeActivity.kt | 17 ----- .../main/java/org/mozilla/fenix/ext/View.kt | 16 ----- .../org/mozilla/fenix/HomeActivityTest.kt | 62 ------------------- .../java/org/mozilla/fenix/ext/ViewTest.kt | 39 ------------ 5 files changed, 150 deletions(-) diff --git a/mobile/android/fenix/app/metrics.yaml b/mobile/android/fenix/app/metrics.yaml index 333a54c91f7f..77f3bda2ddd8 100644 --- a/mobile/android/fenix/app/metrics.yaml +++ b/mobile/android/fenix/app/metrics.yaml @@ -12452,22 +12452,6 @@ navigation_bar: - android-probes@mozilla.com expires: never - os_navigation_uses_gestures: - type: boolean - lifetime: application - description: | - Whether gesture navigation is used instead of the traditional navigation bar. - send_in_pings: - - metrics - bugs: - - https://bugzilla.mozilla.org/show_bug.cgi?id=1917757 - data_reviews: - - https://bugzilla.mozilla.org/show_bug.cgi?id=1917757 - data_sensitivity: - - technical - notification_emails: - - android-probes@mozilla.com - expires: never home_initialize_timespan: type: timespan time_unit: millisecond diff --git a/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/HomeActivity.kt b/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/HomeActivity.kt index 5b64fc29856e..419333348849 100644 --- a/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/HomeActivity.kt +++ b/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/HomeActivity.kt @@ -4,7 +4,6 @@ package org.mozilla.fenix -import android.annotation.SuppressLint import android.app.assist.AssistContent import android.content.ComponentName import android.content.Context @@ -36,7 +35,6 @@ import androidx.core.app.NotificationManagerCompat import androidx.core.net.toUri import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen import androidx.core.text.layoutDirection -import androidx.core.view.doOnAttach import androidx.lifecycle.lifecycleScope import androidx.navigation.NavController import androidx.navigation.fragment.NavHostFragment @@ -87,7 +85,6 @@ import org.mozilla.experiments.nimbus.initializeTooling import org.mozilla.fenix.GleanMetrics.AppIcon import org.mozilla.fenix.GleanMetrics.Events import org.mozilla.fenix.GleanMetrics.Metrics -import org.mozilla.fenix.GleanMetrics.NavigationBar import org.mozilla.fenix.GleanMetrics.SplashScreen import org.mozilla.fenix.GleanMetrics.StartOnHome import org.mozilla.fenix.addons.ExtensionsProcessDisabledBackgroundController @@ -122,7 +119,6 @@ import org.mozilla.fenix.ext.openSetDefaultBrowserOption import org.mozilla.fenix.ext.recordEventInNimbus import org.mozilla.fenix.ext.setNavigationIcon import org.mozilla.fenix.ext.settings -import org.mozilla.fenix.ext.systemGesturesInsets import org.mozilla.fenix.extension.WebExtensionPromptFeature import org.mozilla.fenix.home.HomeFragment import org.mozilla.fenix.home.intent.AssistIntentProcessor @@ -671,7 +667,6 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity { Events.defaultBrowserChanged.record(NoExtras()) } - collectOSNavigationTelemetry() GrowthDataWorker.sendActivatedSignalIfNeeded(applicationContext) FontEnumerationWorker.sendActivatedSignalIfNeeded(applicationContext) @@ -1415,18 +1410,6 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity { messaging.onMessageDisplayed(nextMessage, currentBootUniqueIdentifier) } - @VisibleForTesting - @SuppressLint("NewApi") // The Android Q check is done in the systemGesturesInsets property getter - internal fun collectOSNavigationTelemetry() { - binding.root.doOnAttach { - val systemGestureInsets = binding.root.systemGesturesInsets - - val isUsingGesturesNavigation = - (systemGestureInsets?.left ?: 0) > 0 && (systemGestureInsets?.right ?: 0) > 0 - NavigationBar.osNavigationUsesGestures.set(isUsingGesturesNavigation) - } - } - private fun showCrashReporter() { if (!settings().useNewCrashReporterDialog) { return diff --git a/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/ext/View.kt b/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/ext/View.kt index 39698dc6d76f..52b00985ab59 100644 --- a/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/ext/View.kt +++ b/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/ext/View.kt @@ -127,19 +127,3 @@ fun View.getKeyboardHeight(): Int { return keyboardHeight } - -/** - * Returns the system gesture insets informing about areas where system gestures have priority. - * - * Only available on Android Q and above (API 29+), otherwise, `null` is returned. - * Only available after this view has been attached a Window, otherwise, `null` is returned. - */ -@Suppress("DEPRECATION") -val View.systemGesturesInsets - get() = if (Build.VERSION.SDK_INT == Build.VERSION_CODES.Q) { - rootWindowInsets?.systemGestureInsets - } else if (Build.VERSION.SDK_INT > Build.VERSION_CODES.Q) { - rootWindowInsets?.getInsets(WindowInsetsCompat.Type.systemGestures()) - } else { - null - } diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/HomeActivityTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/HomeActivityTest.kt index 696f58236173..2aa015357534 100644 --- a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/HomeActivityTest.kt +++ b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/HomeActivityTest.kt @@ -5,10 +5,7 @@ package org.mozilla.fenix import android.content.Intent -import android.graphics.Insets import android.os.Bundle -import android.view.View -import android.widget.FrameLayout import io.mockk.Runs import io.mockk.every import io.mockk.just @@ -30,7 +27,6 @@ import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.mozilla.fenix.GleanMetrics.Metrics -import org.mozilla.fenix.GleanMetrics.NavigationBar import org.mozilla.fenix.HomeActivity.Companion.PRIVATE_BROWSING_MODE import org.mozilla.fenix.browser.browsingmode.BrowsingMode import org.mozilla.fenix.browser.browsingmode.BrowsingModeManager @@ -40,7 +36,6 @@ import org.mozilla.fenix.ext.components import org.mozilla.fenix.ext.getIntentSource import org.mozilla.fenix.ext.openSetDefaultBrowserOption import org.mozilla.fenix.ext.settings -import org.mozilla.fenix.ext.systemGesturesInsets import org.mozilla.fenix.helpers.FenixGleanTestRule import org.mozilla.fenix.helpers.FenixRobolectricTestRunner import org.mozilla.fenix.helpers.perf.TestStrictModeManager @@ -194,63 +189,6 @@ class HomeActivityTest { assertFalse(activity.shouldStartOnHome(startingIntent)) } - @Test - fun `GIVEN gesture navigation is enabled WHEN collecting related telemetry THEN send the right value`() { - mockkStatic(View::systemGesturesInsets) { - every { any().systemGesturesInsets } returns Insets.of(10, 20, 10, 20) - val rootView: FrameLayout = mockk { - every { isAttachedToWindow } returns true - } - activity.binding = mockk { - every { root } returns rootView - } - - assertNull(NavigationBar.osNavigationUsesGestures.testGetValue()) - - activity.collectOSNavigationTelemetry() - - assertTrue(NavigationBar.osNavigationUsesGestures.testGetValue()!!) - } - } - - @Test - fun `GIVEN gesture navigation is disabled WHEN collecting related telemetry THEN send the right value`() { - mockkStatic(View::systemGesturesInsets) { - every { any().systemGesturesInsets } returns Insets.of(0, 20, 0, 20) - val rootView: FrameLayout = mockk { - every { isAttachedToWindow } returns true - } - activity.binding = mockk { - every { root } returns rootView - } - - assertNull(NavigationBar.osNavigationUsesGestures.testGetValue()) - - activity.collectOSNavigationTelemetry() - - assertFalse(NavigationBar.osNavigationUsesGestures.testGetValue()!!) - } - } - - @Test - fun `GIVEN gesture navigation is not available WHEN collecting related telemetry THEN send the right value`() { - mockkStatic(View::systemGesturesInsets) { - every { any().systemGesturesInsets } returns null - val rootView: FrameLayout = mockk { - every { isAttachedToWindow } returns true - } - activity.binding = mockk { - every { root } returns rootView - } - - assertNull(NavigationBar.osNavigationUsesGestures.testGetValue()) - - activity.collectOSNavigationTelemetry() - - assertFalse(NavigationBar.osNavigationUsesGestures.testGetValue()!!) - } - } - @Test fun `WHEN Pocket sponsored stories profile is migrated to MARS API THEN delete the old Pocket profile`() { val pocketStoriesService: PocketStoriesService = mockk(relaxed = true) diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/ext/ViewTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/ext/ViewTest.kt index d7a22064d54b..f25965602698 100644 --- a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/ext/ViewTest.kt +++ b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/ext/ViewTest.kt @@ -4,7 +4,6 @@ package org.mozilla.fenix.ext -import android.graphics.Insets import android.graphics.Rect import android.os.Build import android.util.DisplayMetrics @@ -25,7 +24,6 @@ import mozilla.components.support.ktx.android.util.dpToPx import mozilla.components.support.test.robolectric.testContext import mozilla.components.support.utils.ext.bottom import org.junit.Assert.assertEquals -import org.junit.Assert.assertNull import org.junit.Before import org.junit.Test import org.junit.runner.RunWith @@ -201,41 +199,4 @@ class ViewTest { assertEquals(keyboardHeight, view.getKeyboardHeight()) } - - @Config(sdk = [Build.VERSION_CODES.R, Build.VERSION_CODES.TIRAMISU]) - @Test - fun `GIVEN Android 11 and up WHEN system gesture insets are requested THEN query and return the correct values`() { - val rootInsets: WindowInsets = mockk(relaxed = true) - val gestureInsets = Insets.of(10, 20, 30, 40) - every { rootInsets.getInsets(WindowInsetsCompat.Type.systemGestures()) } returns gestureInsets - every { view.rootWindowInsets } returns rootInsets - - val result = view.systemGesturesInsets - - assertEquals(gestureInsets, result) - } - - @Suppress("DEPRECATION") - @Config(sdk = [Build.VERSION_CODES.Q]) - @Test - fun `GIVEN Android 10 WHEN system gesture insets are requested THEN query and return the correct values`() { - val rootInsets: WindowInsets = mockk(relaxed = true) - val gestureInsets = Insets.of(11, 22, 33, 44) - every { rootInsets.systemGestureInsets } returns gestureInsets - every { view.rootWindowInsets } returns rootInsets - - val result = view.systemGesturesInsets - - assertEquals(gestureInsets, result) - } - - @Config(sdk = [Build.VERSION_CODES.LOLLIPOP, Build.VERSION_CODES.P]) - @Test - fun `GIVEN Android 9 and lower WHEN system gesture insets are requested THEN return null`() { - val result = view.systemGesturesInsets - - assertNull(result) - // There's also an implicit assertion that there is no interaction with rootViewInsets - // which would otherwise throw an exception leading to a test failure. - } }