summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Mark Punzalan <markpun@google.com> 2022-11-23 08:51:27 +0000
committer Mark Punzalan <markpun@google.com> 2022-12-01 17:40:31 +0000
commit585c555cc99e3f71cef2f6a1ee09407fe227993d (patch)
treee47a7b7c12773d48515531bf165b3a4c62a963c8
parent2e6c85187e5b47d4fa459c71ba80722a1d5d34e6 (diff)
Rename HotwordAudioStreamManager and add Javadoc
"Manager" is a little vague and "Copier" is clearer with the class's purpose. Bug: 258323047 Test: None with this change; simple refactoring Change-Id: I43a24b27983838e0ef9798eef2f45d1d4b1c9ac8
-rw-r--r--services/voiceinteraction/java/com/android/server/voiceinteraction/HotwordAudioStreamCopier.java (renamed from services/voiceinteraction/java/com/android/server/voiceinteraction/HotwordAudioStreamManager.java)16
-rw-r--r--services/voiceinteraction/java/com/android/server/voiceinteraction/HotwordDetectionConnection.java10
-rw-r--r--services/voiceinteraction/java/com/android/server/voiceinteraction/TrustedHotwordDetectorSession.java10
3 files changed, 22 insertions, 14 deletions
diff --git a/services/voiceinteraction/java/com/android/server/voiceinteraction/HotwordAudioStreamManager.java b/services/voiceinteraction/java/com/android/server/voiceinteraction/HotwordAudioStreamCopier.java
index 57fabcc169a6..76574542da4f 100644
--- a/services/voiceinteraction/java/com/android/server/voiceinteraction/HotwordAudioStreamManager.java
+++ b/services/voiceinteraction/java/com/android/server/voiceinteraction/HotwordAudioStreamCopier.java
@@ -39,9 +39,17 @@ import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
-final class HotwordAudioStreamManager {
+/**
+ * Copies the audio streams in {@link HotwordDetectedResult}s. This allows the system to manage the
+ * lifetime of the {@link ParcelFileDescriptor}s and ensures that the flow of data is in the right
+ * direction from the {@link android.service.voice.HotwordDetectionService} to the client (i.e., the
+ * voice interactor).
+ *
+ * @hide
+ */
+final class HotwordAudioStreamCopier {
- private static final String TAG = "HotwordAudioStreamManager";
+ private static final String TAG = "HotwordAudioStreamCopier";
private static final String OP_MESSAGE = "Streaming hotword audio to VoiceInteractionService";
private static final String TASK_ID_PREFIX = "HotwordDetectedResult@";
private static final String THREAD_NAME_PREFIX = "Copy-";
@@ -56,7 +64,7 @@ final class HotwordAudioStreamManager {
private final String mVoiceInteractorAttributionTag;
private final ExecutorService mExecutorService = Executors.newCachedThreadPool();
- HotwordAudioStreamManager(@NonNull AppOpsManager appOpsManager,
+ HotwordAudioStreamCopier(@NonNull AppOpsManager appOpsManager,
int voiceInteractorUid, @NonNull String voiceInteractorPackageName,
@NonNull String voiceInteractorAttributionTag) {
mAppOpsManager = appOpsManager;
@@ -70,7 +78,7 @@ final class HotwordAudioStreamManager {
* <p>
* The returned {@link HotwordDetectedResult} is identical the one that was passed in, except
* that the {@link ParcelFileDescriptor}s within {@link HotwordDetectedResult#getAudioStreams()}
- * are replaced with descriptors from pipes managed by {@link HotwordAudioStreamManager}. The
+ * are replaced with descriptors from pipes managed by {@link HotwordAudioStreamCopier}. The
* returned value should be passed on to the client (i.e., the voice interactor).
* </p>
*
diff --git a/services/voiceinteraction/java/com/android/server/voiceinteraction/HotwordDetectionConnection.java b/services/voiceinteraction/java/com/android/server/voiceinteraction/HotwordDetectionConnection.java
index 9903481cb360..3bcba6c1af65 100644
--- a/services/voiceinteraction/java/com/android/server/voiceinteraction/HotwordDetectionConnection.java
+++ b/services/voiceinteraction/java/com/android/server/voiceinteraction/HotwordDetectionConnection.java
@@ -183,7 +183,7 @@ final class HotwordDetectionConnection {
private final ScheduledExecutorService mScheduledExecutorService =
Executors.newSingleThreadScheduledExecutor();
private final AppOpsManager mAppOpsManager;
- private final HotwordAudioStreamManager mHotwordAudioStreamManager;
+ private final HotwordAudioStreamCopier mHotwordAudioStreamCopier;
@Nullable private final ScheduledFuture<?> mCancellationTaskFuture;
private final AtomicBoolean mUpdateStateAfterStartFinished = new AtomicBoolean(false);
private final IBinder.DeathRecipient mAudioServerDeathRecipient = this::audioServerDied;
@@ -245,7 +245,7 @@ final class HotwordDetectionConnection {
mVoiceInteractionServiceUid = voiceInteractionServiceUid;
mVoiceInteractorIdentity = voiceInteractorIdentity;
mAppOpsManager = mContext.getSystemService(AppOpsManager.class);
- mHotwordAudioStreamManager = new HotwordAudioStreamManager(mAppOpsManager,
+ mHotwordAudioStreamCopier = new HotwordAudioStreamCopier(mAppOpsManager,
mVoiceInteractorIdentity.uid, mVoiceInteractorIdentity.packageName,
mVoiceInteractorIdentity.attributionTag);
mDetectionComponentName = serviceName;
@@ -507,7 +507,7 @@ final class HotwordDetectionConnection {
saveProximityValueToBundle(result);
HotwordDetectedResult newResult;
try {
- newResult = mHotwordAudioStreamManager.startCopyingAudioStreams(result);
+ newResult = mHotwordAudioStreamCopier.startCopyingAudioStreams(result);
} catch (IOException e) {
// TODO: Write event
mSoftwareCallback.onError();
@@ -642,7 +642,7 @@ final class HotwordDetectionConnection {
saveProximityValueToBundle(result);
HotwordDetectedResult newResult;
try {
- newResult = mHotwordAudioStreamManager.startCopyingAudioStreams(result);
+ newResult = mHotwordAudioStreamCopier.startCopyingAudioStreams(result);
} catch (IOException e) {
// TODO: Write event
externalCallback.onError(CALLBACK_ONDETECTED_STREAM_COPY_ERROR);
@@ -1001,7 +1001,7 @@ final class HotwordDetectionConnection {
HotwordDetectedResult newResult;
try {
newResult =
- mHotwordAudioStreamManager.startCopyingAudioStreams(
+ mHotwordAudioStreamCopier.startCopyingAudioStreams(
triggerResult);
} catch (IOException e) {
// TODO: Write event
diff --git a/services/voiceinteraction/java/com/android/server/voiceinteraction/TrustedHotwordDetectorSession.java b/services/voiceinteraction/java/com/android/server/voiceinteraction/TrustedHotwordDetectorSession.java
index 9d451f4e6247..eeafe910e13e 100644
--- a/services/voiceinteraction/java/com/android/server/voiceinteraction/TrustedHotwordDetectorSession.java
+++ b/services/voiceinteraction/java/com/android/server/voiceinteraction/TrustedHotwordDetectorSession.java
@@ -183,7 +183,7 @@ final class TrustedHotwordDetectorSession {
private final ScheduledExecutorService mScheduledExecutorService =
Executors.newSingleThreadScheduledExecutor();
private final AppOpsManager mAppOpsManager;
- private final HotwordAudioStreamManager mHotwordAudioStreamManager;
+ private final HotwordAudioStreamCopier mHotwordAudioStreamCopier;
@Nullable private final ScheduledFuture<?> mCancellationTaskFuture;
private final AtomicBoolean mUpdateStateAfterStartFinished = new AtomicBoolean(false);
private final IBinder.DeathRecipient mAudioServerDeathRecipient = this::audioServerDied;
@@ -245,7 +245,7 @@ final class TrustedHotwordDetectorSession {
mVoiceInteractionServiceUid = voiceInteractionServiceUid;
mVoiceInteractorIdentity = voiceInteractorIdentity;
mAppOpsManager = mContext.getSystemService(AppOpsManager.class);
- mHotwordAudioStreamManager = new HotwordAudioStreamManager(mAppOpsManager,
+ mHotwordAudioStreamCopier = new HotwordAudioStreamCopier(mAppOpsManager,
mVoiceInteractorIdentity.uid, mVoiceInteractorIdentity.packageName,
mVoiceInteractorIdentity.attributionTag);
mDetectionComponentName = serviceName;
@@ -507,7 +507,7 @@ final class TrustedHotwordDetectorSession {
saveProximityValueToBundle(result);
HotwordDetectedResult newResult;
try {
- newResult = mHotwordAudioStreamManager.startCopyingAudioStreams(result);
+ newResult = mHotwordAudioStreamCopier.startCopyingAudioStreams(result);
} catch (IOException e) {
// TODO: Write event
mSoftwareCallback.onError();
@@ -642,7 +642,7 @@ final class TrustedHotwordDetectorSession {
saveProximityValueToBundle(result);
HotwordDetectedResult newResult;
try {
- newResult = mHotwordAudioStreamManager.startCopyingAudioStreams(result);
+ newResult = mHotwordAudioStreamCopier.startCopyingAudioStreams(result);
} catch (IOException e) {
// TODO: Write event
externalCallback.onError(CALLBACK_ONDETECTED_STREAM_COPY_ERROR);
@@ -1001,7 +1001,7 @@ final class TrustedHotwordDetectorSession {
HotwordDetectedResult newResult;
try {
newResult =
- mHotwordAudioStreamManager.startCopyingAudioStreams(
+ mHotwordAudioStreamCopier.startCopyingAudioStreams(
triggerResult);
} catch (IOException e) {
// TODO: Write event