Limit HotwordDetection process number to 10

Bug: 216095923
Test: existing CTS tests
Change-Id: I73d12ad84e2dce108dcc923c6ad400a2a1bdddd6
(cherry picked from commit bef5d91b67)
This commit is contained in:
Sergey Volnov
2022-01-24 18:18:05 +00:00
parent 4dfe4924d4
commit 6db1879a19

View File

@@ -97,6 +97,7 @@ final class HotwordDetectionConnection {
private static final Duration MAX_UPDATE_TIMEOUT_DURATION =
Duration.ofMillis(MAX_UPDATE_TIMEOUT_MILLIS);
private static final long RESET_DEBUG_HOTWORD_LOGGING_TIMEOUT_MILLIS = 60 * 60 * 1000; // 1 hour
private static final int MAX_ISOLATED_PROCESS_NUMBER = 10;
private final Executor mAudioCopyExecutor = Executors.newCachedThreadPool();
// TODO: This may need to be a Handler(looper)
@@ -772,7 +773,8 @@ final class HotwordDetectionConnection {
ServiceConnection createLocked() {
ServiceConnection connection =
new ServiceConnection(mContext, mIntent, mBindingFlags, mUser,
IHotwordDetectionService.Stub::asInterface, ++mRestartCount);
IHotwordDetectionService.Stub::asInterface,
mRestartCount++ % MAX_ISOLATED_PROCESS_NUMBER);
connection.connect();
updateAudioFlinger(connection, mAudioFlinger);