Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package com.kitakkun.jetwhale.host.data.settings

import com.kitakkun.jetwhale.host.data.AppDataDirectoryProvider
import com.kitakkun.jetwhale.host.data.util.findAdbPath
import com.kitakkun.jetwhale.host.data.util.findIdbCompanionPath
import com.kitakkun.jetwhale.host.data.util.findIdbPath
import com.kitakkun.jetwhale.host.model.DebuggingToolsDiagnostics
import com.kitakkun.jetwhale.host.model.DiagnosticsQueryKey
import dev.zacsweers.metro.AppScope
Expand All @@ -21,6 +23,8 @@ class DefaultDiagnosticsQueryKey(
val appDataPath = appDataDirectoryProvider.getAppDataPath()
DebuggingToolsDiagnostics(
adbPath = adbPath,
idbPath = findIdbPath(),
idbCompanionPath = findIdbCompanionPath(),
appDataPath = appDataPath,
)
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.kitakkun.jetwhale.host.data.util

import java.io.File

/**
* Finds the absolute path to the idb client executable (Facebook's iOS debug bridge, used to
* drive iOS simulator input), checking common installation locations and then the PATH.
*
* @return The absolute path to idb if found, otherwise an empty string
*/
fun findIdbPath(): String = findExecutable(
name = "idb",
candidatePaths = listOf(
"/usr/local/bin/idb",
"/opt/homebrew/bin/idb",
),
)

/**
* Finds the absolute path to the idb_companion executable (the gRPC daemon the idb client talks
* to; installed separately, typically via `brew install idb-companion`).
*
* @return The absolute path to idb_companion if found, otherwise an empty string
*/
fun findIdbCompanionPath(): String = findExecutable(
name = "idb_companion",
candidatePaths = listOf(
"/usr/local/bin/idb_companion",
"/opt/homebrew/bin/idb_companion",
),
)

private fun findExecutable(name: String, candidatePaths: List<String>): String {
candidatePaths.firstOrNull { File(it).canExecute() }?.let { return it }
val pathDirs = System.getenv("PATH")?.split(File.pathSeparator).orEmpty()
return pathDirs.map { File(it, name) }.firstOrNull { it.canExecute() }?.absolutePath.orEmpty()
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@ package com.kitakkun.jetwhale.host.model

data class DebuggingToolsDiagnostics(
val adbPath: String,
// Empty when the tool is not installed.
val idbPath: String,
val idbCompanionPath: String,
Comment on lines +5 to +7
val appDataPath: String,
)
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@
<string name="health_check">ヘルスチェック</string>
<string name="adb_executable_path">ADB実行可能ファイルのパス</string>
<string name="adb_unavailable">ADBコマンドが見つかりません</string>
<string name="idb_executable_path">idb実行可能ファイルのパス</string>
<string name="idb_unavailable">idbコマンドが見つかりません</string>
<string name="idb_companion_executable_path">idb_companion実行可能ファイルのパス</string>
<string name="idb_companion_unavailable">idb_companionコマンドが見つかりません</string>
<string name="view_application_logs">アプリケーションログを表示</string>
<string name="log_viewer_filter_placeholder">ログをフィルター…</string>
<string name="log_viewer_filter_icon">フィルター</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@
<string name="health_check">Health Check</string>
<string name="adb_executable_path">ADB Executable Path</string>
<string name="adb_unavailable">ADB command not found</string>
<string name="idb_executable_path">idb Executable Path</string>
<string name="idb_unavailable">idb command not found</string>
<string name="idb_companion_executable_path">idb_companion Executable Path</string>
<string name="idb_companion_unavailable">idb_companion command not found</string>
<string name="view_application_logs">View Application Logs</string>
<string name="log_viewer_filter_placeholder">Filter logs…</string>
<string name="log_viewer_filter_icon">Filter</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ import com.kitakkun.jetwhale.host.settings.component.SettingsItemRow
import com.kitakkun.jetwhale.host.settings.component.SwitchSettingsItemView
import com.kitakkun.jetwhale.host.settings.current_version
import com.kitakkun.jetwhale.host.settings.health_check
import com.kitakkun.jetwhale.host.settings.idb_companion_executable_path
import com.kitakkun.jetwhale.host.settings.idb_companion_unavailable
import com.kitakkun.jetwhale.host.settings.idb_executable_path
import com.kitakkun.jetwhale.host.settings.idb_unavailable
import com.kitakkun.jetwhale.host.settings.install_update
import com.kitakkun.jetwhale.host.settings.language_option
import com.kitakkun.jetwhale.host.settings.maintenance
Expand Down Expand Up @@ -152,24 +156,45 @@ fun GeneralSettingsScreen(
}
item {
SettingOptionView(stringResource(Res.string.health_check)) {
SettingsItemRow(stringResource(Res.string.adb_executable_path)) {
Text(
text = uiState.adbPath.ifEmpty { stringResource(Res.string.adb_unavailable) },
)
Spacer(Modifier.width(8.dp))
if (uiState.adbPath.isNotEmpty()) {
Icon(
imageVector = Icons.Default.Check,
tint = MaterialTheme.colorScheme.primary,
contentDescription = null,
)
}
}
ToolPathRow(
label = stringResource(Res.string.adb_executable_path),
path = uiState.adbPath,
unavailableText = stringResource(Res.string.adb_unavailable),
)
Comment on lines +159 to +163
ToolPathRow(
label = stringResource(Res.string.idb_executable_path),
path = uiState.idbPath,
unavailableText = stringResource(Res.string.idb_unavailable),
)
ToolPathRow(
label = stringResource(Res.string.idb_companion_executable_path),
path = uiState.idbCompanionPath,
unavailableText = stringResource(Res.string.idb_companion_unavailable),
)
}
}
}
}

@Composable
private fun ToolPathRow(
label: String,
path: String,
unavailableText: String,
) {
SettingsItemRow(label) {
Text(text = path.ifEmpty { unavailableText })
Spacer(Modifier.width(8.dp))
if (path.isNotEmpty()) {
Icon(
imageVector = Icons.Default.Check,
tint = MaterialTheme.colorScheme.primary,
contentDescription = null,
)
}
}
}

@Composable
private fun UpdateCheckStatusView(
isChecking: Boolean,
Expand Down Expand Up @@ -253,6 +278,8 @@ private fun GeneralSettingsScreenPreview() {
language = AppLanguage.English,
appDataPath = "~/.jetwhale",
adbPath = "/path/to/adb",
idbPath = "/path/to/idb",
idbCompanionPath = "",
currentVersion = "1.0.0-alpha08",
checkForUpdatesOnStartup = true,
isCheckingForUpdates = false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ fun generalSettingsScreenPresenter(
language = appearanceSettings.appLanguage,
appDataPath = diagnostics.appDataPath,
adbPath = diagnostics.adbPath,
idbPath = diagnostics.idbPath,
idbCompanionPath = diagnostics.idbCompanionPath,
currentVersion = presenterContext.hostVersionInfo.version,
checkForUpdatesOnStartup = debuggerBehaviorSettings.checkForUpdatesOnStartup,
isCheckingForUpdates = updateCheckMutation.isPending,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ data class GeneralSettingsScreenUiState(
val availableColorSchemes: ImmutableList<JetWhaleColorSchemeId>,
val appDataPath: String,
val adbPath: String,
val idbPath: String,
val idbCompanionPath: String,
val currentVersion: String,
val checkForUpdatesOnStartup: Boolean,
val isCheckingForUpdates: Boolean,
Expand Down
Loading