From 1e05a086ad7062c4d3496db912e4329d42fb4d7b Mon Sep 17 00:00:00 2001 From: davotoula Date: Thu, 9 Jul 2026 13:41:44 +0100 Subject: [PATCH] fix: suppress RestrictedApi false positive on NappletHostActivity.dispatchKeyEvent Activity.dispatchKeyEvent is a public framework hook; lint flags the override only because androidx.core's intermediate override carries a library-group @RestrictTo. Scoped to the method so the check stays live for genuine restricted-API use. Makes :nappletHost:lintDebug pass. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01HLfwhTdf72qFPnmPRYnzqu --- .../amethyst/napplethost/NappletHostActivity.kt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/nappletHost/src/main/kotlin/com/vitorpamplona/amethyst/napplethost/NappletHostActivity.kt b/nappletHost/src/main/kotlin/com/vitorpamplona/amethyst/napplethost/NappletHostActivity.kt index fd8eda6617..26922f5217 100644 --- a/nappletHost/src/main/kotlin/com/vitorpamplona/amethyst/napplethost/NappletHostActivity.kt +++ b/nappletHost/src/main/kotlin/com/vitorpamplona/amethyst/napplethost/NappletHostActivity.kt @@ -20,6 +20,7 @@ */ package com.vitorpamplona.amethyst.napplethost +import android.annotation.SuppressLint import android.app.AlertDialog import android.content.ComponentName import android.content.Intent @@ -430,7 +431,13 @@ class NappletHostActivity : ComponentActivity() { * Intercepts hardware-key combos the applet bound via `keys.registerAction` and turns them into a * `keys.action` push — the applet never sees raw key events, only its own named action. Unmatched * keys fall through to the WebView (so the applet's own text inputs still work normally). + * + * RestrictedApi is a false positive: `Activity.dispatchKeyEvent` is a public framework + * hook; lint flags it only because androidx.core's intermediate override carries a + * library-group `@RestrictTo`. Unmatched keys still reach `super`, so androidx's + * KeyEventDispatcher routing is preserved. */ + @SuppressLint("RestrictedApi") override fun dispatchKeyEvent(event: KeyEvent): Boolean { val actionId = keyActions.actionFor(event) if (actionId != null) {