This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from pathlib import Path, PurePosixPath | |
| def normalize_remote_path(path: str | None) -> str: | |
| if not path: | |
| return "" | |
| normalized = path.replace("\\", "/").strip("/") | |
| if normalized in {"", "."}: | |
| return "" | |
| parts = [part for part in PurePosixPath(normalized).parts if part not in {"", "."}] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private val advertiseCallback = object : AdvertiseCallback() { | |
| override fun onStartSuccess(settingsInEffect: AdvertiseSettings) { | |
| pendingStart = false | |
| log("Advertising started for service $SERVICE_UUID") | |
| } | |
| override fun onStartFailure(errorCode: Int) { | |
| pendingStart = false | |
| log("Advertising failed: ${advertiseFailureMessage(errorCode)}") | |
| stopServer() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class BleTransferService : Service(), BleFileTransferManager.Listener { | |
| inner class LocalBinder : Binder() { | |
| fun getService(): BleTransferService = this@BleTransferService | |
| } | |
| private val binder = LocalBinder() | |
| private lateinit var bleManager: BleFileTransferManager | |
| private lateinit var prefs: SharedPreferences | |
| private var statusText: String = "" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| internal object StrictModeInitializer { | |
| fun enableIfDebuggable(application: Application) { | |
| val isDebuggable = | |
| (application.applicationInfo.flags and ApplicationInfo.FLAG_DEBUGGABLE) != 0 | |
| if (!isDebuggable) return | |
| StrictMode.setThreadPolicy( | |
| StrictMode.ThreadPolicy.Builder() | |
| .detectAll() | |
| .penaltyLog() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @RunWith(AndroidJUnit4::class) | |
| class MainScreenRecompositionOverlayTest { | |
| @get:Rule | |
| val composeRule = createAndroidComposeRule<ComponentActivity>() | |
| @Test | |
| fun overlay_expandShowsCounters_and_clearResetsRows() { | |
| assumeTrue(BuildConfig.DEBUG) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| LaunchedEffect(Unit) { | |
| withFrameNanos { } | |
| displaySettings = withContext(Dispatchers.IO) { readDisplaySettingsState() } | |
| observeDisplaySettings = true | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class BootReceiver : BroadcastReceiver() { | |
| override fun onReceive(context: Context, intent: Intent) { | |
| when (intent.action) { | |
| Intent.ACTION_BOOT_COMPLETED, | |
| Intent.ACTION_LOCKED_BOOT_COMPLETED, | |
| Intent.ACTION_MY_PACKAGE_REPLACED -> { | |
| SystemEventService.start(context) | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| set -euo pipefail | |
| PKG="dev.jamescullimore.app" | |
| ACTIVITY="dev.jamescullimore.app/.MainActivity" | |
| RECEIVER="dev.jamescullimore.app/androidx.profileinstaller.ProfileInstallReceiver" | |
| REMOTE_PROFILE="/data/misc/profman/${PKG}-primary.prof.txt" | |
| run_scenario() { | |
| local onboarding="$1" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package dev.jamescullimore.app.benchmark | |
| import androidx.benchmark.macro.CompilationMode | |
| import androidx.benchmark.macro.StartupMode | |
| import androidx.benchmark.macro.StartupTimingMetric | |
| import androidx.benchmark.macro.junit4.MacrobenchmarkRule | |
| import org.junit.Rule | |
| import org.junit.Test | |
| class StartupBenchmarks { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Composable | |
| private fun RecomposeDebugOverlay(modifier: Modifier = Modifier) { | |
| if (!BuildConfig.DEBUG) return | |
| val counts by RecomposeDebugTracker.counts.collectAsStateWithLifecycle() | |
| var expanded by rememberSaveable { mutableStateOf(false) } | |
| Surface(modifier = modifier.clickable { expanded = !expanded }) { | |
| Column(modifier = Modifier.padding(horizontal = 12.dp, vertical = 8.dp)) { | |
| Text(text = "Recompose ${if (expanded) "hide" else "show"}") |
NewerOlder