Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit de96f53f authored by SongFerng Wang's avatar SongFerng Wang Committed by Android (Google) Code Review
Browse files

Merge "Add the settings' metrics into SPA" into main

parents beee0ef3 cbdbeacb
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -220,7 +220,7 @@ public class FeatureFlagUtils {
        DEFAULT_FLAGS.put(SETTINGS_NEW_KEYBOARD_TRACKPAD_GESTURE, "false");
        DEFAULT_FLAGS.put(SETTINGS_ENABLE_SPA, "true");
        DEFAULT_FLAGS.put(SETTINGS_ENABLE_SPA_PHASE2, "false");
        DEFAULT_FLAGS.put(SETTINGS_ENABLE_SPA_METRICS, "false");
        DEFAULT_FLAGS.put(SETTINGS_ENABLE_SPA_METRICS, "true");
        DEFAULT_FLAGS.put(SETTINGS_ADB_METRICS_WRITER, "false");
        DEFAULT_FLAGS.put(SETTINGS_SHOW_STYLUS_PREFERENCES, "true");
        DEFAULT_FLAGS.put(SETTINGS_BIOMETRICS2_ENROLLMENT, "false");
+5 −0
Original line number Diff line number Diff line
@@ -33,6 +33,9 @@ data class SettingsPage(
    // The name of the page provider, who creates this page. It is used to compute the unique id.
    val sppName: String,

    // The category id of the page provider which is the PageId at SettingsEnums.
    val metricsCategory: Int = 0,

    // The display name of the page, for better readability.
    val displayName: String,

@@ -46,6 +49,7 @@ data class SettingsPage(
        // TODO: cleanup it once all its usage in Settings are switched to Spp.createSettingsPage
        fun create(
            name: String,
            metricsCategory: Int = 0,
            displayName: String? = null,
            parameter: List<NamedNavArgument> = emptyList(),
            arguments: Bundle? = null
@@ -53,6 +57,7 @@ data class SettingsPage(
            return SettingsPage(
                id = genPageId(name, parameter, arguments),
                sppName = name,
                metricsCategory = metricsCategory,
                displayName = displayName ?: name,
                parameter = parameter,
                arguments = arguments
+5 −0
Original line number Diff line number Diff line
@@ -34,6 +34,10 @@ interface SettingsPageProvider {
    /** The page provider name, needs to be *unique* and *stable*. */
    val name: String

    /** The category id which is the PageId at SettingsEnums.*/
    val metricsCategory: Int
        get() = 0

    enum class NavType {
        Page,
        Dialog,
@@ -79,6 +83,7 @@ fun SettingsPageProvider.createSettingsPage(arguments: Bundle? = null): Settings
    return SettingsPage(
        id = genPageId(name, parameter, arguments),
        sppName = name,
        metricsCategory = metricsCategory,
        displayName = displayName + parameter.normalizeArgList(arguments, eraseRuntimeValues = true)
            .joinToString("") { arg -> "/$arg" },
        parameter = parameter,
+1 −0
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ internal const val LOG_DATA_DISPLAY_NAME = "name"
internal const val LOG_DATA_SWITCH_STATUS = "switch"

const val LOG_DATA_SESSION_NAME = "session"
const val LOG_DATA_METRICS_CATEGORY = "metricsCategory"

/**
 * The interface of logger in Spa
+3 −1
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.settingslib.spa.framework.util
import androidx.compose.runtime.Composable
import androidx.core.os.bundleOf
import com.android.settingslib.spa.framework.common.LOG_DATA_DISPLAY_NAME
import com.android.settingslib.spa.framework.common.LOG_DATA_METRICS_CATEGORY
import com.android.settingslib.spa.framework.common.LOG_DATA_SESSION_NAME
import com.android.settingslib.spa.framework.common.LogCategory
import com.android.settingslib.spa.framework.common.LogEvent
@@ -45,6 +46,7 @@ private fun SettingsPage.logPageEvent(event: LogEvent, navController: NavControl
        extraData = bundleOf(
            LOG_DATA_DISPLAY_NAME to displayName,
            LOG_DATA_SESSION_NAME to navController.sessionSourceName,
            LOG_DATA_METRICS_CATEGORY to metricsCategory,
        ).apply {
            val normArguments = parameter.normalize(arguments)
            if (normArguments != null) putAll(normArguments)