Move all debug message to debug/ folder.
Bug: 244122804 Test: manual - build gallery Change-Id: If6be5c083d001350dd42038b2f4d63be9aa95218
This commit is contained in:
@@ -22,12 +22,4 @@ package com.android.settingslib.spa.framework.common
|
||||
data class EntrySearchData(
|
||||
val title: String = "",
|
||||
val keyword: List<String> = emptyList(),
|
||||
) {
|
||||
fun format(): String {
|
||||
val content = listOf(
|
||||
"search_title = $title",
|
||||
"search_keyword = $keyword",
|
||||
)
|
||||
return content.joinToString("\n")
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
@@ -99,10 +99,6 @@ data class SettingsEntry(
|
||||
*/
|
||||
private val uiLayoutImpl: (@Composable (arguments: Bundle?) -> Unit) = {},
|
||||
) {
|
||||
fun displayTitle(): String {
|
||||
return "${owner.displayName}:$displayName"
|
||||
}
|
||||
|
||||
fun containerPage(): SettingsPage {
|
||||
// The Container page of the entry, which is the from-page or
|
||||
// the owner-page if from-page is unset.
|
||||
|
||||
@@ -84,16 +84,6 @@ data class SettingsPage(
|
||||
return sppName == SppName
|
||||
}
|
||||
|
||||
fun formatArguments(): String {
|
||||
val normArguments = parameter.normalize(arguments)
|
||||
if (normArguments == null || normArguments.isEmpty) return "[No arguments]"
|
||||
return normArguments.toString().removeRange(0, 6)
|
||||
}
|
||||
|
||||
fun formatDisplayTitle(): String {
|
||||
return "$displayName ${formatArguments()}"
|
||||
}
|
||||
|
||||
fun buildRoute(): String {
|
||||
return sppName + parameter.navLink(arguments)
|
||||
}
|
||||
@@ -115,7 +105,7 @@ data class SettingsPage(
|
||||
id,
|
||||
LogEvent.PAGE_ENTER,
|
||||
category = LogCategory.FRAMEWORK,
|
||||
details = formatDisplayTitle()
|
||||
details = displayName,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -124,7 +114,7 @@ data class SettingsPage(
|
||||
id,
|
||||
LogEvent.PAGE_LEAVE,
|
||||
category = LogCategory.FRAMEWORK,
|
||||
details = formatDisplayTitle()
|
||||
details = displayName,
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -120,12 +120,11 @@ class DebugActivity : ComponentActivity() {
|
||||
val allPageWithEntry = remember { entryRepository.getAllPageWithEntry() }
|
||||
RegularScaffold(title = "All Pages (${allPageWithEntry.size})") {
|
||||
for (pageWithEntry in allPageWithEntry) {
|
||||
val page = pageWithEntry.page
|
||||
Preference(object : PreferenceModel {
|
||||
override val title =
|
||||
"${pageWithEntry.page.displayName} (${pageWithEntry.entries.size})"
|
||||
override val summary = pageWithEntry.page.formatArguments().toState()
|
||||
override val onClick =
|
||||
navigator(route = ROUTE_PAGE + "/${pageWithEntry.page.id}")
|
||||
override val title = "${page.debugBrief()} (${pageWithEntry.entries.size})"
|
||||
override val summary = page.debugArguments().toState()
|
||||
override val onClick = navigator(route = ROUTE_PAGE + "/${page.id}")
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -146,16 +145,16 @@ class DebugActivity : ComponentActivity() {
|
||||
val entryRepository by spaEnvironment.entryRepository
|
||||
val id = arguments!!.getString(PARAM_NAME_PAGE_ID, "")
|
||||
val pageWithEntry = entryRepository.getPageWithEntry(id)!!
|
||||
RegularScaffold(title = "Page - ${pageWithEntry.page.displayName}") {
|
||||
Text(text = "id = ${pageWithEntry.page.id}")
|
||||
Text(text = pageWithEntry.page.formatArguments())
|
||||
val page = pageWithEntry.page
|
||||
RegularScaffold(title = "Page - ${page.debugBrief()}") {
|
||||
Text(text = "id = ${page.id}")
|
||||
Text(text = page.debugArguments())
|
||||
Text(text = "Entry size: ${pageWithEntry.entries.size}")
|
||||
Preference(model = object : PreferenceModel {
|
||||
override val title = "open page"
|
||||
override val enabled =
|
||||
pageWithEntry.page.isBrowsable(context, spaEnvironment.browseActivityClass)
|
||||
.toState()
|
||||
override val onClick = openPage(pageWithEntry.page)
|
||||
page.isBrowsable(context, spaEnvironment.browseActivityClass).toState()
|
||||
override val onClick = openPage(page)
|
||||
})
|
||||
EntryList(pageWithEntry.entries)
|
||||
}
|
||||
@@ -168,7 +167,7 @@ class DebugActivity : ComponentActivity() {
|
||||
val id = arguments!!.getString(PARAM_NAME_ENTRY_ID, "")
|
||||
val entry = entryRepository.getEntry(id)!!
|
||||
val entryContent = remember { entry.debugContent(entryRepository) }
|
||||
RegularScaffold(title = "Entry - ${entry.displayTitle()}") {
|
||||
RegularScaffold(title = "Entry - ${entry.debugBrief()}") {
|
||||
Preference(model = object : PreferenceModel {
|
||||
override val title = "open entry"
|
||||
override val enabled =
|
||||
@@ -184,7 +183,7 @@ class DebugActivity : ComponentActivity() {
|
||||
private fun EntryList(entries: Collection<SettingsEntry>) {
|
||||
for (entry in entries) {
|
||||
Preference(object : PreferenceModel {
|
||||
override val title = entry.displayTitle()
|
||||
override val title = entry.debugBrief()
|
||||
override val summary =
|
||||
"${entry.fromPage?.displayName} -> ${entry.toPage?.displayName}".toState()
|
||||
override val onClick = navigator(route = ROUTE_ENTRY + "/${entry.id}")
|
||||
|
||||
@@ -16,11 +16,22 @@
|
||||
|
||||
package com.android.settingslib.spa.framework.debug
|
||||
|
||||
import com.android.settingslib.spa.framework.common.EntrySearchData
|
||||
import com.android.settingslib.spa.framework.common.EntryStatusData
|
||||
import com.android.settingslib.spa.framework.common.SettingsEntry
|
||||
import com.android.settingslib.spa.framework.common.SettingsEntryRepository
|
||||
import com.android.settingslib.spa.framework.common.SettingsPage
|
||||
import com.android.settingslib.spa.framework.util.normalize
|
||||
|
||||
fun EntryStatusData.debugContent(): String {
|
||||
private fun EntrySearchData.debugContent(): String {
|
||||
val content = listOf(
|
||||
"search_title = $title",
|
||||
"search_keyword = $keyword",
|
||||
)
|
||||
return content.joinToString("\n")
|
||||
}
|
||||
|
||||
private fun EntryStatusData.debugContent(): String {
|
||||
val content = listOf(
|
||||
"is_disabled = $isDisabled",
|
||||
"is_switch_off = $isSwitchOff",
|
||||
@@ -28,6 +39,20 @@ fun EntryStatusData.debugContent(): String {
|
||||
return content.joinToString("\n")
|
||||
}
|
||||
|
||||
fun SettingsPage.debugArguments(): String {
|
||||
val normArguments = parameter.normalize(arguments)
|
||||
if (normArguments == null || normArguments.isEmpty) return "[No arguments]"
|
||||
return normArguments.toString().removeRange(0, 6)
|
||||
}
|
||||
|
||||
fun SettingsPage.debugBrief(): String {
|
||||
return displayName
|
||||
}
|
||||
|
||||
fun SettingsEntry.debugBrief(): String {
|
||||
return "${owner.displayName}:$displayName"
|
||||
}
|
||||
|
||||
fun SettingsEntry.debugContent(entryRepository: SettingsEntryRepository): String {
|
||||
val searchData = getSearchData()
|
||||
val statusData = getStatusData()
|
||||
@@ -37,14 +62,14 @@ fun SettingsEntry.debugContent(entryRepository: SettingsEntryRepository): String
|
||||
val content = listOf(
|
||||
"------ STATIC ------",
|
||||
"id = $id",
|
||||
"owner = ${owner.formatDisplayTitle()}",
|
||||
"linkFrom = ${fromPage?.formatDisplayTitle()}",
|
||||
"linkTo = ${toPage?.formatDisplayTitle()}",
|
||||
"owner = ${owner.debugBrief()} ${owner.debugArguments()}",
|
||||
"linkFrom = ${fromPage?.debugBrief()} ${fromPage?.debugArguments()}",
|
||||
"linkTo = ${toPage?.debugBrief()} ${toPage?.debugArguments()}",
|
||||
"hierarchy_path = $entryPathWithName",
|
||||
"------ SEARCH ------",
|
||||
"search_path = $entryPathWithTitle",
|
||||
"${searchData?.format()}",
|
||||
"${statusData?.debugContent()}"
|
||||
searchData?.debugContent() ?: "no search data",
|
||||
statusData?.debugContent() ?: "no status data",
|
||||
)
|
||||
return content.joinToString("\n")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user