From 46e69448046fb9093ca7526d7428bf23a177a0f8 Mon Sep 17 00:00:00 2001 From: Joanne Chung Date: Tue, 15 Mar 2022 18:19:59 +0800 Subject: [PATCH] Use flag to control the restart period value. Bug: 224618257 Test: adb shell cmd device_config get/put voice_interaction \ restart_period_in_seconds works fine Test: the value is expected by command: adb shell dumpsys \ voiceinteraction | grep RESTART_PERIOD_SECONDS Change-Id: Icd8d19c2a482d0d6b9bf0432e2176ca10f3bd2eb --- core/java/android/provider/DeviceConfig.java | 7 +++++++ .../voiceinteraction/HotwordDetectionConnection.java | 6 +++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/core/java/android/provider/DeviceConfig.java b/core/java/android/provider/DeviceConfig.java index 1008a2d0ad1aa..47315047b6c41 100644 --- a/core/java/android/provider/DeviceConfig.java +++ b/core/java/android/provider/DeviceConfig.java @@ -599,6 +599,13 @@ public final class DeviceConfig { @TestApi public static final String NAMESPACE_SELECTION_TOOLBAR = "selection_toolbar"; + /** + * Definitions for voice interaction related functions. + * + * @hide + */ + public static final String NAMESPACE_VOICE_INTERACTION = "voice_interaction"; + /** * List of namespaces which can be read without READ_DEVICE_CONFIG permission * diff --git a/services/voiceinteraction/java/com/android/server/voiceinteraction/HotwordDetectionConnection.java b/services/voiceinteraction/java/com/android/server/voiceinteraction/HotwordDetectionConnection.java index 58a2ac09078c1..398889213ce55 100644 --- a/services/voiceinteraction/java/com/android/server/voiceinteraction/HotwordDetectionConnection.java +++ b/services/voiceinteraction/java/com/android/server/voiceinteraction/HotwordDetectionConnection.java @@ -67,6 +67,7 @@ import android.os.PersistableBundle; import android.os.RemoteException; import android.os.ServiceManager; import android.os.SharedMemory; +import android.provider.DeviceConfig; import android.service.voice.HotwordDetectedResult; import android.service.voice.HotwordDetectionService; import android.service.voice.HotwordDetector; @@ -110,6 +111,7 @@ final class HotwordDetectionConnection { private static final String TAG = "HotwordDetectionConnection"; static final boolean DEBUG = false; + private static final String KEY_RESTART_PERIOD_IN_SECONDS = "restart_period_in_seconds"; // TODO: These constants need to be refined. private static final long VALIDATION_TIMEOUT_MILLIS = 4000; private static final long MAX_UPDATE_TIMEOUT_MILLIS = 6000; @@ -120,7 +122,9 @@ final class HotwordDetectionConnection { * Time after which each HotwordDetectionService process is stopped and replaced by a new one. * 0 indicates no restarts. */ - private static final int RESTART_PERIOD_SECONDS = 0; + private static final int RESTART_PERIOD_SECONDS = + DeviceConfig.getInt(DeviceConfig.NAMESPACE_VOICE_INTERACTION, + KEY_RESTART_PERIOD_IN_SECONDS, 0); private static final int MAX_ISOLATED_PROCESS_NUMBER = 10; // Hotword metrics