chore: code formatting
This commit is contained in:
@@ -140,6 +140,7 @@ class DeviceShortcuts(val devices: List<DeviceShortcut>): List<DeviceShortcut> b
|
|||||||
val p = port ?: old.port
|
val p = port ?: old.port
|
||||||
listOf("$host:$p")
|
listOf("$host:$p")
|
||||||
}
|
}
|
||||||
|
|
||||||
updateById -> old.addresses
|
updateById -> old.addresses
|
||||||
|
|
||||||
newPort != null -> {
|
newPort != null -> {
|
||||||
|
|||||||
@@ -54,8 +54,10 @@ class AnnexBDecoder(
|
|||||||
|
|
||||||
init {
|
init {
|
||||||
if (!outputSurface.isValid) {
|
if (!outputSurface.isValid) {
|
||||||
throw DecoderException(mimeType, width, height,
|
throw DecoderException(
|
||||||
IllegalStateException("Output surface is not valid"))
|
mimeType, width, height,
|
||||||
|
IllegalStateException("Output surface is not valid"),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
val format = MediaFormat.createVideoFormat(mimeType, width, height)
|
val format = MediaFormat.createVideoFormat(mimeType, width, height)
|
||||||
if (sps != null) {
|
if (sps != null) {
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ object DecoderCapabilities {
|
|||||||
val codecList = MediaCodecList(MediaCodecList.REGULAR_CODECS)
|
val codecList = MediaCodecList(MediaCodecList.REGULAR_CODECS)
|
||||||
codecList.codecInfos.any { info ->
|
codecList.codecInfos.any { info ->
|
||||||
info.isEncoder.not() &&
|
info.isEncoder.not() &&
|
||||||
isCodecCapable(info, mime, width, height)
|
isCodecCapable(info, mime, width, height)
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Log.w(TAG, "isSizeSupported(): query failed for $mime ${width}x$height, assuming supported", e)
|
Log.w(TAG, "isSizeSupported(): query failed for $mime ${width}x$height, assuming supported", e)
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ class DecoderException(
|
|||||||
val width: Int,
|
val width: Int,
|
||||||
val height: Int,
|
val height: Int,
|
||||||
cause: Throwable? = null,
|
cause: Throwable? = null,
|
||||||
) : RuntimeException(
|
): RuntimeException(
|
||||||
"Decoder failed for mime=$mime size=${width}x${height}",
|
"Decoder failed for mime=$mime size=${width}x${height}",
|
||||||
cause,
|
cause,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -308,8 +308,7 @@ internal object DirectAdbTransport {
|
|||||||
private fun generatePkcs8PrivateKey(der: ByteArray): PrivateKey {
|
private fun generatePkcs8PrivateKey(der: ByteArray): PrivateKey {
|
||||||
val kf = KeyFactory.getInstance("RSA")
|
val kf = KeyFactory.getInstance("RSA")
|
||||||
val key = runCatching { kf.generatePrivate(PKCS8EncodedKeySpec(der)) }.getOrNull()
|
val key = runCatching { kf.generatePrivate(PKCS8EncodedKeySpec(der)) }.getOrNull()
|
||||||
return if (key is RSAPrivateCrtKey) key
|
return key as? RSAPrivateCrtKey ?: kf.generatePrivate(parsePkcs8PrivateKey(der))
|
||||||
else kf.generatePrivate(parsePkcs8PrivateKey(der))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun parsePublicKey(content: String): PublicKey {
|
private fun parsePublicKey(content: String): PublicKey {
|
||||||
@@ -366,7 +365,25 @@ internal object DirectAdbTransport {
|
|||||||
private data class PemBlock(
|
private data class PemBlock(
|
||||||
val label: String,
|
val label: String,
|
||||||
val bytes: ByteArray,
|
val bytes: ByteArray,
|
||||||
)
|
) {
|
||||||
|
override fun equals(other: Any?): Boolean {
|
||||||
|
if (this === other) return true
|
||||||
|
if (javaClass != other?.javaClass) return false
|
||||||
|
|
||||||
|
other as PemBlock
|
||||||
|
|
||||||
|
if (label != other.label) return false
|
||||||
|
if (!bytes.contentEquals(other.bytes)) return false
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun hashCode(): Int {
|
||||||
|
var result = label.hashCode()
|
||||||
|
result = 31 * result + bytes.contentHashCode()
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun readPem(content: String): PemBlock? {
|
private fun readPem(content: String): PemBlock? {
|
||||||
val begin = Regex("-----BEGIN ([A-Z0-9 ]+)-----").find(content) ?: return null
|
val begin = Regex("-----BEGIN ([A-Z0-9 ]+)-----").find(content) ?: return null
|
||||||
@@ -661,9 +678,13 @@ internal class DirectAdbConnection(
|
|||||||
fun openStream(service: String): AdbSocketStream {
|
fun openStream(service: String): AdbSocketStream {
|
||||||
val localId = nextLocalId.getAndIncrement()
|
val localId = nextLocalId.getAndIncrement()
|
||||||
val flowControlWindow = Storage.appSettings.bundleState.value.adbFlowControlWindow
|
val flowControlWindow = Storage.appSettings.bundleState.value.adbFlowControlWindow
|
||||||
val stream = AdbSocketStream(localId, { command, arg0, arg1, data ->
|
val stream = AdbSocketStream(
|
||||||
sendMsg(command, arg0, arg1, data)
|
localId,
|
||||||
}, flowControlWindow)
|
{ command, arg0, arg1, data ->
|
||||||
|
sendMsg(command, arg0, arg1, data)
|
||||||
|
},
|
||||||
|
flowControlWindow,
|
||||||
|
)
|
||||||
streams[localId] = stream
|
streams[localId] = stream
|
||||||
sendMsg(A_OPEN, localId, 0, (service + "\u0000").toByteArray(Charsets.UTF_8))
|
sendMsg(A_OPEN, localId, 0, (service + "\u0000").toByteArray(Charsets.UTF_8))
|
||||||
try {
|
try {
|
||||||
@@ -979,8 +1000,9 @@ class AdbSocketStream(
|
|||||||
private val queue = LinkedBlockingQueue<Any>()
|
private val queue = LinkedBlockingQueue<Any>()
|
||||||
|
|
||||||
// need notifyAll() / wait()
|
// need notifyAll() / wait()
|
||||||
private val writeLock = java.lang.Object()
|
private val writeLock = Object()
|
||||||
@Volatile private var inflightWrites = 0
|
@Volatile
|
||||||
|
private var inflightWrites = 0
|
||||||
|
|
||||||
private object EndOfStreamMarker
|
private object EndOfStreamMarker
|
||||||
|
|
||||||
|
|||||||
@@ -54,8 +54,11 @@ internal class FileManagerViewModel: ViewModel() {
|
|||||||
|
|
||||||
private fun longestHistoricalPrefix(current: String): String {
|
private fun longestHistoricalPrefix(current: String): String {
|
||||||
val prefixMatch: (String) -> Boolean =
|
val prefixMatch: (String) -> Boolean =
|
||||||
if (current == ROOT_REMOTE_PATH) { { true } }
|
if (current == ROOT_REMOTE_PATH) {
|
||||||
else { { hist -> hist == current || hist.startsWith("$current/") } }
|
{ true }
|
||||||
|
} else {
|
||||||
|
{ hist -> hist == current || hist.startsWith("$current/") }
|
||||||
|
}
|
||||||
var best = current
|
var best = current
|
||||||
var bestLen = current.length
|
var bestLen = current.length
|
||||||
pathHistory.forEach { hist ->
|
pathHistory.forEach { hist ->
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package io.github.miuzarte.scrcpyforandroid.pages
|
package io.github.miuzarte.scrcpyforandroid.pages
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
|
import android.content.Context
|
||||||
import android.graphics.Typeface
|
import android.graphics.Typeface
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.view.KeyEvent
|
import android.view.KeyEvent
|
||||||
@@ -52,10 +53,10 @@ import kotlin.math.max
|
|||||||
private const val FONT_SCALE_STEP_THRESHOLD = 1.08f
|
private const val FONT_SCALE_STEP_THRESHOLD = 1.08f
|
||||||
private const val LOG_TAG = "TerminalScreen"
|
private const val LOG_TAG = "TerminalScreen"
|
||||||
|
|
||||||
private fun terminalFontFile(context: android.content.Context) =
|
private fun terminalFontFile(context: Context) =
|
||||||
File(context.filesDir, "terminal/font.ttf")
|
File(context.filesDir, "terminal/font.ttf")
|
||||||
|
|
||||||
private fun loadTerminalTypeface(context: android.content.Context): Typeface? {
|
private fun loadTerminalTypeface(context: Context): Typeface? {
|
||||||
val file = terminalFontFile(context)
|
val file = terminalFontFile(context)
|
||||||
if (!file.exists()) return null
|
if (!file.exists()) return null
|
||||||
return runCatching { Typeface.createFromFile(file) }.getOrNull()
|
return runCatching { Typeface.createFromFile(file) }.getOrNull()
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package io.github.miuzarte.scrcpyforandroid.storage
|
package io.github.miuzarte.scrcpyforandroid.storage
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import androidx.datastore.preferences.core.Preferences
|
||||||
import androidx.datastore.preferences.core.stringPreferencesKey
|
import androidx.datastore.preferences.core.stringPreferencesKey
|
||||||
import io.github.miuzarte.scrcpyforandroid.services.AppRuntime
|
import io.github.miuzarte.scrcpyforandroid.services.AppRuntime
|
||||||
import kotlinx.coroutines.flow.StateFlow
|
import kotlinx.coroutines.flow.StateFlow
|
||||||
@@ -33,7 +34,7 @@ class ScrcpyProfiles(context: Context): Settings(context, "ScrcpyProfiles") {
|
|||||||
|
|
||||||
val state: StateFlow<State> = createBundleState(::stateFromPreferences)
|
val state: StateFlow<State> = createBundleState(::stateFromPreferences)
|
||||||
|
|
||||||
private fun stateFromPreferences(preferences: androidx.datastore.preferences.core.Preferences): State {
|
private fun stateFromPreferences(preferences: Preferences): State {
|
||||||
val raw = preferences.read(PROFILES_JSON)
|
val raw = preferences.read(PROFILES_JSON)
|
||||||
return normalizeState(
|
return normalizeState(
|
||||||
runCatching { decodeState(raw) }.getOrNull() ?: State(emptyList()),
|
runCatching { decodeState(raw) }.getOrNull() ?: State(emptyList()),
|
||||||
|
|||||||
@@ -63,14 +63,9 @@ import io.github.miuzarte.scrcpyforandroid.storage.Storage
|
|||||||
import io.github.miuzarte.scrcpyforandroid.storage.Storage.scrcpyOptions
|
import io.github.miuzarte.scrcpyforandroid.storage.Storage.scrcpyOptions
|
||||||
import io.github.miuzarte.scrcpyforandroid.ui.confirm
|
import io.github.miuzarte.scrcpyforandroid.ui.confirm
|
||||||
import io.github.miuzarte.scrcpyforandroid.ui.contextClick
|
import io.github.miuzarte.scrcpyforandroid.ui.contextClick
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.*
|
||||||
import kotlinx.coroutines.Dispatchers
|
|
||||||
import kotlinx.coroutines.SupervisorJob
|
|
||||||
import kotlinx.coroutines.delay
|
|
||||||
import kotlinx.coroutines.launch
|
|
||||||
import kotlinx.coroutines.sync.Mutex
|
import kotlinx.coroutines.sync.Mutex
|
||||||
import kotlinx.coroutines.sync.withLock
|
import kotlinx.coroutines.sync.withLock
|
||||||
import kotlinx.coroutines.withContext
|
|
||||||
import top.yukonga.miuix.kmp.basic.*
|
import top.yukonga.miuix.kmp.basic.*
|
||||||
import top.yukonga.miuix.kmp.icon.MiuixIcons
|
import top.yukonga.miuix.kmp.icon.MiuixIcons
|
||||||
import top.yukonga.miuix.kmp.icon.extended.AddCircle
|
import top.yukonga.miuix.kmp.icon.extended.AddCircle
|
||||||
|
|||||||
Reference in New Issue
Block a user