forked from Blendman974/faceclaw
Fix Kotlin warnings
This commit is contained in:
1 parent
06146c2b08
commit
48f7f3d01f
14 files changed
+38
-23
No files matched your search
@@ -6,6 +6,14 @@ plugins {
|
||||
id("com.android.kotlin.multiplatform.library")
|
||||
}
|
||||
kotlin {
|
||||
compilerOptions {
|
||||
// expect/actual classes are Beta in Kotlin 2.x; opt in deliberately.
|
||||
freeCompilerArgs.add("-Xexpect-actual-classes")
|
||||
// The compiler prints a warning only when it recompiles that file, and
|
||||
// up-to-date or incremental builds never replay it, so warnings are easy
|
||||
// to miss. Fail the build instead.
|
||||
allWarningsAsErrors.set(true)
|
||||
}
|
||||
android {
|
||||
namespace = "com.faceclaw.shared"
|
||||
compileSdk = 35
|
||||
|
||||
+1
-1
@@ -11,5 +11,5 @@ private object DrawRedrawScheduler {
|
||||
|
||||
internal actual fun scheduleDrawRedraw(delayMs: Int, action: () -> Unit): () -> Unit {
|
||||
val future = DrawRedrawScheduler.executor.schedule(action, delayMs.toLong(), TimeUnit.MILLISECONDS)
|
||||
return { future.cancel(false); Unit }
|
||||
return { future.cancel(false) }
|
||||
}
|
||||
+1
-1
@@ -859,7 +859,7 @@ class BleProtocol {
|
||||
private fun concat(parts: MutableList<ByteArray>): ByteArray {
|
||||
var out: ByteSink = ByteSink()
|
||||
for (part in parts) {
|
||||
if (((part != null) && (part.size > 0))) {
|
||||
if (part.size > 0) {
|
||||
out.write(part, 0, part.size)
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -308,7 +308,7 @@ class TexturePlanner {
|
||||
i++
|
||||
continue
|
||||
}
|
||||
var entry: FwGlyphAtlas.Entry? = FwGlyphAtlas.get(draw.fwCps!![i])
|
||||
var entry: FwGlyphAtlas.Entry? = FwGlyphAtlas.get(draw.fwCps[i])
|
||||
if ((entry == null)) {
|
||||
baked++
|
||||
i++
|
||||
@@ -351,7 +351,7 @@ class TexturePlanner {
|
||||
var bytesToLastInk: Int = 0
|
||||
var bytesSoFar: Int = 0
|
||||
while (((j < n) && ok[j])) {
|
||||
var encodedLength: Int = utf8Length(draw.fwCps!![j])
|
||||
var encodedLength: Int = utf8Length(draw.fwCps[j])
|
||||
if (((bytesSoFar + encodedLength) > 255)) {
|
||||
break
|
||||
}
|
||||
@@ -379,7 +379,7 @@ class TexturePlanner {
|
||||
run {
|
||||
var k: Int = i
|
||||
while ((k <= lastInk)) {
|
||||
var encoded: ByteArray = codePointUtf8(draw.fwCps!![k])
|
||||
var encoded: ByteArray = codePointUtf8(draw.fwCps[k])
|
||||
encoded.copyInto(sub, pos, 0, 0 + encoded.size)
|
||||
pos += encoded.size
|
||||
k++
|
||||
@@ -393,7 +393,7 @@ class TexturePlanner {
|
||||
outPunches.add(
|
||||
FwPunch(
|
||||
entries[k]!!,
|
||||
((draw.x + draw.fwDx!![k]) + entries[k]!!.ofsX),
|
||||
((draw.x + draw.fwDx[k]) + entries[k]!!.ofsX),
|
||||
(draw.y + entries[k]!!.inkTop),
|
||||
)
|
||||
)
|
||||
|
||||
+2
-2
@@ -130,7 +130,7 @@ internal fun GlassesSessionCore.driveSession(): Long {
|
||||
finishDesiredFrameLocked("discarded: glasses charging")
|
||||
if (sessionReady && inFlightMessages.isEmpty() && !pendingMessages.isEmpty()) {
|
||||
messageToWrite = pendingMessages.removeFirst()
|
||||
logLine("sending pending message (charging): " + messageToWrite!!.label)
|
||||
logLine("sending pending message (charging): " + messageToWrite.label)
|
||||
} else if (sessionReady && pendingMessages.isEmpty() && inFlightMessages.isEmpty()
|
||||
&& now - lastBatteryRefreshAtMs >= ConnectionOptions.CHARGING_BATTERY_POLL_MS) {
|
||||
logLine("Writing charging-mode battery poll")
|
||||
@@ -203,7 +203,7 @@ internal fun GlassesSessionCore.driveSession(): Long {
|
||||
if (messageToPrewrite == null && sessionReady && windowHasRoom && !pendingMessages.isEmpty()
|
||||
&& CfwMessageWindow.canSend(inFlightMessages, pendingMessages.firstOrNull()!!)) {
|
||||
messageToWrite = pendingMessages.removeFirst()
|
||||
logLine("sending pending message: " + messageToWrite!!.label)
|
||||
logLine("sending pending message: " + messageToWrite.label)
|
||||
} else if (messageToPrewrite == null && !shutdownRequested && !benchmarkActive
|
||||
&& fixedLayoutCreated
|
||||
&& windowHasRoom && !hasPendingImageLocked()
|
||||
|
||||
+1
-1
@@ -39,7 +39,7 @@ class MenuSelection(val x: Int, val y: Int, val width: Int, val height: Int, val
|
||||
val radius = reader.getShort().toInt() and 65535
|
||||
val background = BmpUtil.nibbleForGray(reader.get() and 255)
|
||||
val border = BmpUtil.nibbleForGray(reader.get() and 255)
|
||||
val depth = reader.get().toByte().toInt()
|
||||
val depth = reader.get().toInt()
|
||||
val count = reader.getShort().toInt() and 65535
|
||||
require(count <= 2048)
|
||||
require(w in 1..640 && h in 1..480 && 5 + (w + 1) / 2 * h <= 65536 && reader.remaining() >= w * h)
|
||||
|
||||
+2
-5
@@ -392,10 +392,7 @@ class SurfaceCompositor @JvmOverloads constructor(private val includePreviewInFr
|
||||
surface = Surface(id)
|
||||
surfaces.put(id, surface)
|
||||
}
|
||||
if (
|
||||
(((surface.pixels == null) || (surface.width != width)) ||
|
||||
(surface.height != height))
|
||||
) {
|
||||
if ((surface.width != width) || (surface.height != height)) {
|
||||
surface.pixels = ByteArray((width * height))
|
||||
surface.fingerprint = ""
|
||||
surface.draws = NO_DRAWS
|
||||
@@ -825,7 +822,7 @@ class SurfaceCompositor @JvmOverloads constructor(private val includePreviewInFr
|
||||
var col: Int = 0
|
||||
while ((col < copyWidth)) {
|
||||
var value: Int = (surface.pixels[(srcOffset + col)] and 0xff)
|
||||
if ((value.toInt() != 0)) {
|
||||
if ((value != 0)) {
|
||||
gray[(dstOffset + col)] = (dimValue(value, dim)).toByte()
|
||||
} else {
|
||||
if ((surface.transparency == TRANSPARENCY_OPAQUE)) {
|
||||
|
||||
+1
-1
@@ -92,7 +92,7 @@ class FrameTimingsCore(
|
||||
fun root(): Frame {
|
||||
var frame: Frame = this
|
||||
while (frame.parent != null) {
|
||||
frame = frame.parent!!
|
||||
frame = frame.parent
|
||||
}
|
||||
return frame
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
@file:OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
|
||||
@file:OptIn(kotlinx.cinterop.ExperimentalForeignApi::class, kotlinx.cinterop.BetaInteropApi::class)
|
||||
|
||||
package com.faceclaw.app
|
||||
|
||||
|
||||
@@ -52,6 +52,9 @@ fun interface IosAncsAuthorizationListener {
|
||||
fun onAncsAuthorization(identifier: String, authorized: Boolean)
|
||||
}
|
||||
|
||||
/** The canonical 8-4-4-4-12 hex form -[NSUUID initWithUUIDString:] accepts. */
|
||||
private val UUID_STRING = Regex("^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$")
|
||||
|
||||
/**
|
||||
* CoreBluetooth central used by the shared session and stock-firmware flows on iOS. It is
|
||||
* the iOS counterpart of Android's FaceclawBleManager: every [SessionLink]/[StockLink] call
|
||||
@@ -268,7 +271,10 @@ class IosBleCentral(private val platform: ProtocolPlatform = IosProtocolPlatform
|
||||
var retrieved: CBPeripheral? = null
|
||||
dispatch_sync(queue) {
|
||||
val manager = central ?: return@dispatch_sync
|
||||
val uuid = NSUUID(uUIDString = identifier) ?: return@dispatch_sync
|
||||
// NSUUID's initializer can return nil, but Kotlin imports it as a
|
||||
// non-null constructor: screen out malformed identifiers first.
|
||||
if (!UUID_STRING.matches(identifier)) return@dispatch_sync
|
||||
val uuid = NSUUID(uUIDString = identifier)
|
||||
retrieved = manager.retrievePeripheralsWithIdentifiers(listOf(uuid)).firstOrNull() as? CBPeripheral
|
||||
}
|
||||
retrieved?.let { return remember(it) }
|
||||
|
||||
@@ -8,7 +8,6 @@ import platform.Foundation.NSData
|
||||
import platform.Foundation.NSError
|
||||
import platform.Foundation.NSHTTPURLResponse
|
||||
import platform.Foundation.NSMutableURLRequest
|
||||
import platform.Foundation.NSString
|
||||
import platform.Foundation.NSURL
|
||||
import platform.Foundation.NSURLRequest
|
||||
import platform.Foundation.NSURLResponse
|
||||
@@ -19,9 +18,6 @@ import platform.Foundation.NSURLSessionDataTask
|
||||
import platform.Foundation.NSURLSessionResponseAllow
|
||||
import platform.Foundation.NSURLSessionResponseDisposition
|
||||
import platform.Foundation.NSURLSessionTask
|
||||
import platform.Foundation.NSUTF8StringEncoding
|
||||
import platform.Foundation.create
|
||||
import platform.Foundation.dataUsingEncoding
|
||||
import platform.Foundation.setHTTPBody
|
||||
import platform.Foundation.setHTTPMethod
|
||||
import platform.Foundation.setValue
|
||||
@@ -31,7 +27,7 @@ import platform.darwin.NSObject
|
||||
internal fun buildRequest(url: NSURL, method: String, body: String?, headers: List<Pair<String, String>>): NSMutableURLRequest {
|
||||
val request = NSMutableURLRequest.requestWithURL(url)
|
||||
request.setHTTPMethod(method)
|
||||
if (body != null) request.setHTTPBody((body as NSString).dataUsingEncoding(NSUTF8StringEncoding))
|
||||
if (body != null) request.setHTTPBody(body.encodeToByteArray().data())
|
||||
var hasUserAgent = false
|
||||
for ((name, value) in headers) {
|
||||
if (name.equals("User-Agent", ignoreCase = true)) hasUserAgent = true
|
||||
|
||||
@@ -7,6 +7,11 @@ plugins {
|
||||
|
||||
// Compile the production sources without building NativeScript or touching BLE.
|
||||
kotlin {
|
||||
// Match native/kotlin/shared/build.gradle.kts.
|
||||
compilerOptions {
|
||||
freeCompilerArgs.add("-Xexpect-actual-classes")
|
||||
allWarningsAsErrors.set(true)
|
||||
}
|
||||
android {
|
||||
namespace = "com.faceclaw.protocoltests"
|
||||
compileSdk = 35
|
||||
|
||||
@@ -46,6 +46,9 @@ android {
|
||||
}
|
||||
kotlinOptions {
|
||||
jvmTarget = "17"
|
||||
// Warnings print only when a file is recompiled; fail instead so they
|
||||
// can't scroll by unnoticed (as in native/kotlin/shared).
|
||||
allWarningsAsErrors = true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.5-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
|
||||
Reference in new issue
Block a user