Modern Apps git

← Modern-Apps.git

library-avatar: detekt clean (20 tests)

Commit
6739b6b7d6adc756897fce9d89602f90e1738592
Author
Vayun Mathur <[email protected]>
When
2026-11-14 23:07 UTC (21 days ago)
Parents
5d4c81c
Findings before: 4 errors (SwallowedException,
TooGenericExceptionCaught x2, MagicNumber). After: 0.

- YuuAvatarNative availability probe: catch UnsatisfiedLinkError
  and SecurityException specifically instead of Throwable, and
  log the failure reason; a missing native library still falls
  back to the placeholder surface.
- YuuAvatarAssets.adoptBundledMesh: catch IOException (what
  AssetManager.openFd throws) instead of Exception; the absent
  asset still keeps the procedural fallback.
- YuuAvatar3D: named the 200ms config-push debounce window
  CONFIG_DEBOUNCE_MS.

Verified: ./gradlew :library:avatar:detekt
:library:avatar:testDebugUnitTest :library:avatar:lint
--max-workers=32 all green (20 unit tests).

Diff

library/avatar/src/main/java/com/vayunmathur/library/avatar/YuuAvatarAssets.kt
diff --git a/library/avatar/src/main/java/com/vayunmathur/library/avatar/YuuAvatarAssets.kt b/library/avatar/src/main/java/com/vayunmathur/library/avatar/YuuAvatarAssets.ktindex 3e4b88ced2..c338fdb861 100644--- a/library/avatar/src/main/java/com/vayunmathur/library/avatar/YuuAvatarAssets.kt+++ b/library/avatar/src/main/java/com/vayunmathur/library/avatar/YuuAvatarAssets.kt@@ -4,6 +4,7 @@ import android.content.res.AssetFileDescriptor import android.content.res.AssetManager import android.os.ParcelFileDescriptor import com.vayunmathur.library.log.Log+import java.io.IOException  /**  * Loads `models/base_upperbody.glb` from this module's assets and hands the@@ -27,7 +28,7 @@ object YuuAvatarAssets {         if (!YuuAvatarNative.isAvailable) return         try {             assets.openFd(BASE_MESH_PATH).use { afd -> handOff(afd) }-        } catch (e: Exception) {+        } catch (e: IOException) {             Log.status("YuuAvatarAssets", "no bundled mesh - procedural fallback (${e.message})")         }     }
library/avatar/src/main/java/com/vayunmathur/library/avatar/YuuAvatarNative.kt
diff --git a/library/avatar/src/main/java/com/vayunmathur/library/avatar/YuuAvatarNative.kt b/library/avatar/src/main/java/com/vayunmathur/library/avatar/YuuAvatarNative.ktindex 70fbb59b33..fb3423efc3 100644--- a/library/avatar/src/main/java/com/vayunmathur/library/avatar/YuuAvatarNative.kt+++ b/library/avatar/src/main/java/com/vayunmathur/library/avatar/YuuAvatarNative.kt@@ -22,8 +22,12 @@ internal object YuuAvatarNative {         nativeInit()         Log.status("YuuAvatarNative", "libyuu_avatar loaded")         true-    } catch (t: Throwable) {-        Log.status("YuuAvatarNative", "libyuu_avatar absent - using placeholder")+    } catch (e: UnsatisfiedLinkError) {+        // Library absent on this device: surfaces use the placeholder.+        Log.status("YuuAvatarNative", "libyuu_avatar absent - using placeholder (${e.message})")+        false+    } catch (e: SecurityException) {+        Log.status("YuuAvatarNative", "libyuu_avatar load denied - using placeholder (${e.message})")         false     } 
library/avatar/src/main/java/com/vayunmathur/library/avatar/components/YuuAvatar3D.kt
diff --git a/library/avatar/src/main/java/com/vayunmathur/library/avatar/components/YuuAvatar3D.kt b/library/avatar/src/main/java/com/vayunmathur/library/avatar/components/YuuAvatar3D.ktindex a2e188e146..c2585165d2 100644--- a/library/avatar/src/main/java/com/vayunmathur/library/avatar/components/YuuAvatar3D.kt+++ b/library/avatar/src/main/java/com/vayunmathur/library/avatar/components/YuuAvatar3D.kt@@ -68,7 +68,7 @@ fun YuuAvatar3D(      // Debounced config push: rapid draft edits coalesce into one JNI call.     LaunchedEffect(configJson, pose, surfaceId) {-        delay(200)+        delay(CONFIG_DEBOUNCE_MS)         YuuAvatarNative.setConfig(surfaceId, configJson, pose)     } @@ -112,3 +112,6 @@ fun YuuAvatar3D(  /** Radians of orbit per pixel of drag. */ private const val DRAG_RAD_PER_PX = 0.008f++/** Coalescing window for config pushes: rapid draft edits merge into one JNI call. */+private const val CONFIG_DEBOUNCE_MS = 200L