package com.agentui.desktop

import android.content.Intent
import android.os.Bundle
import android.speech.RecognitionService
import android.speech.SpeechRecognizer
import android.util.Log

/**
 * Stub RecognitionService required by Android to register the app
 * as a complete voice interaction service / digital assistant.
 *
 * Without this, the system won't fully recognize the app as an assistant
 * and settings will show "None" even when selected.
 *
 * We delegate actual speech recognition to the system's default
 * RecognizerIntent in VoiceCommandActivity.
 */
class AgentRecognitionService : RecognitionService() {

    companion object {
        private const val TAG = "AgentUI.Recognition"
    }

    override fun onStartListening(intent: Intent?, callback: Callback?) {
        Log.d(TAG, "onStartListening called")
        // We don't do real recognition here - VoiceCommandActivity uses
        // the system RecognizerIntent directly. This stub satisfies the
        // Android requirement that a VoiceInteractionService must have
        // an associated RecognitionService.
        callback?.error(SpeechRecognizer.ERROR_CLIENT)
    }

    override fun onCancel(callback: Callback?) {
        Log.d(TAG, "onCancel called")
    }

    override fun onStopListening(callback: Callback?) {
        Log.d(TAG, "onStopListening called")
    }
}
