Hotword: Use new Audio Egress metrics instead of older one
Bug: 261793715 Test: stasd_drive Change-Id: I3baf29a547ee69bee7cae4ca7432c489b0bcb700 Merged-In: I3baf29a547ee69bee7cae4ca7432c489b0bcb700
This commit is contained in:
@@ -19,13 +19,13 @@ package com.android.server.voiceinteraction;
|
|||||||
import static android.app.AppOpsManager.MODE_ALLOWED;
|
import static android.app.AppOpsManager.MODE_ALLOWED;
|
||||||
import static android.service.voice.HotwordAudioStream.KEY_AUDIO_STREAM_COPY_BUFFER_LENGTH_BYTES;
|
import static android.service.voice.HotwordAudioStream.KEY_AUDIO_STREAM_COPY_BUFFER_LENGTH_BYTES;
|
||||||
|
|
||||||
import static com.android.internal.util.FrameworkStatsLog.HOTWORD_DETECTOR_EVENTS__EVENT__AUDIO_EGRESS_CLOSE_ERROR_FROM_SYSTEM;
|
import static com.android.internal.util.FrameworkStatsLog.HOTWORD_AUDIO_EGRESS_EVENT_REPORTED__EVENT__CLOSE_ERROR_FROM_SYSTEM;
|
||||||
import static com.android.internal.util.FrameworkStatsLog.HOTWORD_DETECTOR_EVENTS__EVENT__AUDIO_EGRESS_EMPTY_AUDIO_STREAM_LIST;
|
import static com.android.internal.util.FrameworkStatsLog.HOTWORD_AUDIO_EGRESS_EVENT_REPORTED__EVENT__EMPTY_AUDIO_STREAM_LIST;
|
||||||
import static com.android.internal.util.FrameworkStatsLog.HOTWORD_DETECTOR_EVENTS__EVENT__AUDIO_EGRESS_END;
|
import static com.android.internal.util.FrameworkStatsLog.HOTWORD_AUDIO_EGRESS_EVENT_REPORTED__EVENT__ENDED;
|
||||||
import static com.android.internal.util.FrameworkStatsLog.HOTWORD_DETECTOR_EVENTS__EVENT__AUDIO_EGRESS_ILLEGAL_COPY_BUFFER_SIZE;
|
import static com.android.internal.util.FrameworkStatsLog.HOTWORD_AUDIO_EGRESS_EVENT_REPORTED__EVENT__ILLEGAL_COPY_BUFFER_SIZE;
|
||||||
import static com.android.internal.util.FrameworkStatsLog.HOTWORD_DETECTOR_EVENTS__EVENT__AUDIO_EGRESS_INTERRUPTED_EXCEPTION;
|
import static com.android.internal.util.FrameworkStatsLog.HOTWORD_AUDIO_EGRESS_EVENT_REPORTED__EVENT__INTERRUPTED_EXCEPTION;
|
||||||
import static com.android.internal.util.FrameworkStatsLog.HOTWORD_DETECTOR_EVENTS__EVENT__AUDIO_EGRESS_NO_PERMISSION;
|
import static com.android.internal.util.FrameworkStatsLog.HOTWORD_AUDIO_EGRESS_EVENT_REPORTED__EVENT__NO_PERMISSION;
|
||||||
import static com.android.internal.util.FrameworkStatsLog.HOTWORD_DETECTOR_EVENTS__EVENT__AUDIO_EGRESS_START;
|
import static com.android.internal.util.FrameworkStatsLog.HOTWORD_AUDIO_EGRESS_EVENT_REPORTED__EVENT__STARTED;
|
||||||
import static com.android.server.voiceinteraction.HotwordDetectionConnection.DEBUG;
|
import static com.android.server.voiceinteraction.HotwordDetectionConnection.DEBUG;
|
||||||
|
|
||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
@@ -98,12 +98,14 @@ final class HotwordAudioStreamCopier {
|
|||||||
throws IOException {
|
throws IOException {
|
||||||
List<HotwordAudioStream> audioStreams = result.getAudioStreams();
|
List<HotwordAudioStream> audioStreams = result.getAudioStreams();
|
||||||
if (audioStreams.isEmpty()) {
|
if (audioStreams.isEmpty()) {
|
||||||
HotwordMetricsLogger.writeDetectorEvent(mDetectorType,
|
HotwordMetricsLogger.writeAudioEgressEvent(mDetectorType,
|
||||||
HOTWORD_DETECTOR_EVENTS__EVENT__AUDIO_EGRESS_EMPTY_AUDIO_STREAM_LIST,
|
HOTWORD_AUDIO_EGRESS_EVENT_REPORTED__EVENT__EMPTY_AUDIO_STREAM_LIST,
|
||||||
mVoiceInteractorUid);
|
mVoiceInteractorUid, /* streamSizeBytes= */ 0, /* bundleSizeBytes= */ 0,
|
||||||
|
/* streamCount= */ 0);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final int audioStreamCount = audioStreams.size();
|
||||||
List<HotwordAudioStream> newAudioStreams = new ArrayList<>(audioStreams.size());
|
List<HotwordAudioStream> newAudioStreams = new ArrayList<>(audioStreams.size());
|
||||||
List<CopyTaskInfo> copyTaskInfos = new ArrayList<>(audioStreams.size());
|
List<CopyTaskInfo> copyTaskInfos = new ArrayList<>(audioStreams.size());
|
||||||
for (HotwordAudioStream audioStream : audioStreams) {
|
for (HotwordAudioStream audioStream : audioStreams) {
|
||||||
@@ -120,9 +122,10 @@ final class HotwordAudioStreamCopier {
|
|||||||
if (metadata.containsKey(KEY_AUDIO_STREAM_COPY_BUFFER_LENGTH_BYTES)) {
|
if (metadata.containsKey(KEY_AUDIO_STREAM_COPY_BUFFER_LENGTH_BYTES)) {
|
||||||
copyBufferLength = metadata.getInt(KEY_AUDIO_STREAM_COPY_BUFFER_LENGTH_BYTES, -1);
|
copyBufferLength = metadata.getInt(KEY_AUDIO_STREAM_COPY_BUFFER_LENGTH_BYTES, -1);
|
||||||
if (copyBufferLength < 1 || copyBufferLength > MAX_COPY_BUFFER_LENGTH_BYTES) {
|
if (copyBufferLength < 1 || copyBufferLength > MAX_COPY_BUFFER_LENGTH_BYTES) {
|
||||||
HotwordMetricsLogger.writeDetectorEvent(mDetectorType,
|
HotwordMetricsLogger.writeAudioEgressEvent(mDetectorType,
|
||||||
HOTWORD_DETECTOR_EVENTS__EVENT__AUDIO_EGRESS_ILLEGAL_COPY_BUFFER_SIZE,
|
HOTWORD_AUDIO_EGRESS_EVENT_REPORTED__EVENT__ILLEGAL_COPY_BUFFER_SIZE,
|
||||||
mVoiceInteractorUid);
|
mVoiceInteractorUid, /* streamSizeBytes= */ 0, /* bundleSizeBytes= */ 0,
|
||||||
|
audioStreamCount);
|
||||||
Slog.w(TAG, "Attempted to set an invalid copy buffer length ("
|
Slog.w(TAG, "Attempted to set an invalid copy buffer length ("
|
||||||
+ copyBufferLength + ") for: " + audioStream);
|
+ copyBufferLength + ") for: " + audioStream);
|
||||||
copyBufferLength = DEFAULT_COPY_BUFFER_LENGTH_BYTES;
|
copyBufferLength = DEFAULT_COPY_BUFFER_LENGTH_BYTES;
|
||||||
@@ -183,18 +186,21 @@ final class HotwordAudioStreamCopier {
|
|||||||
mVoiceInteractorUid, mVoiceInteractorPackageName,
|
mVoiceInteractorUid, mVoiceInteractorPackageName,
|
||||||
mVoiceInteractorAttributionTag, OP_MESSAGE) == MODE_ALLOWED) {
|
mVoiceInteractorAttributionTag, OP_MESSAGE) == MODE_ALLOWED) {
|
||||||
try {
|
try {
|
||||||
HotwordMetricsLogger.writeDetectorEvent(mDetectorType,
|
HotwordMetricsLogger.writeAudioEgressEvent(mDetectorType,
|
||||||
HOTWORD_DETECTOR_EVENTS__EVENT__AUDIO_EGRESS_START,
|
HOTWORD_AUDIO_EGRESS_EVENT_REPORTED__EVENT__STARTED,
|
||||||
mVoiceInteractorUid);
|
mVoiceInteractorUid, /* streamSizeBytes= */ 0, /* bundleSizeBytes= */ 0,
|
||||||
|
size);
|
||||||
// TODO(b/244599891): Set timeout, close after inactivity
|
// TODO(b/244599891): Set timeout, close after inactivity
|
||||||
mExecutorService.invokeAll(tasks);
|
mExecutorService.invokeAll(tasks);
|
||||||
HotwordMetricsLogger.writeDetectorEvent(mDetectorType,
|
HotwordMetricsLogger.writeAudioEgressEvent(mDetectorType,
|
||||||
HOTWORD_DETECTOR_EVENTS__EVENT__AUDIO_EGRESS_END,
|
HOTWORD_AUDIO_EGRESS_EVENT_REPORTED__EVENT__ENDED,
|
||||||
mVoiceInteractorUid);
|
mVoiceInteractorUid, /* streamSizeBytes= */ 0, /* bundleSizeBytes= */ 0,
|
||||||
|
size);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
HotwordMetricsLogger.writeDetectorEvent(mDetectorType,
|
HotwordMetricsLogger.writeAudioEgressEvent(mDetectorType,
|
||||||
HOTWORD_DETECTOR_EVENTS__EVENT__AUDIO_EGRESS_INTERRUPTED_EXCEPTION,
|
HOTWORD_AUDIO_EGRESS_EVENT_REPORTED__EVENT__INTERRUPTED_EXCEPTION,
|
||||||
mVoiceInteractorUid);
|
mVoiceInteractorUid, /* streamSizeBytes= */ 0, /* bundleSizeBytes= */ 0,
|
||||||
|
size);
|
||||||
Slog.e(TAG, mResultTaskId + ": Task was interrupted", e);
|
Slog.e(TAG, mResultTaskId + ": Task was interrupted", e);
|
||||||
bestEffortPropagateError(e.getMessage());
|
bestEffortPropagateError(e.getMessage());
|
||||||
} finally {
|
} finally {
|
||||||
@@ -203,9 +209,10 @@ final class HotwordAudioStreamCopier {
|
|||||||
mVoiceInteractorAttributionTag);
|
mVoiceInteractorAttributionTag);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
HotwordMetricsLogger.writeDetectorEvent(mDetectorType,
|
HotwordMetricsLogger.writeAudioEgressEvent(mDetectorType,
|
||||||
HOTWORD_DETECTOR_EVENTS__EVENT__AUDIO_EGRESS_NO_PERMISSION,
|
HOTWORD_AUDIO_EGRESS_EVENT_REPORTED__EVENT__NO_PERMISSION,
|
||||||
mVoiceInteractorUid);
|
mVoiceInteractorUid, /* streamSizeBytes= */ 0, /* bundleSizeBytes= */ 0,
|
||||||
|
size);
|
||||||
bestEffortPropagateError(
|
bestEffortPropagateError(
|
||||||
"Failed to obtain RECORD_AUDIO_HOTWORD permission for voice interactor with"
|
"Failed to obtain RECORD_AUDIO_HOTWORD permission for voice interactor with"
|
||||||
+ " uid=" + mVoiceInteractorUid
|
+ " uid=" + mVoiceInteractorUid
|
||||||
@@ -220,9 +227,10 @@ final class HotwordAudioStreamCopier {
|
|||||||
copyTaskInfo.mSource.closeWithError(errorMessage);
|
copyTaskInfo.mSource.closeWithError(errorMessage);
|
||||||
copyTaskInfo.mSink.closeWithError(errorMessage);
|
copyTaskInfo.mSink.closeWithError(errorMessage);
|
||||||
}
|
}
|
||||||
HotwordMetricsLogger.writeDetectorEvent(mDetectorType,
|
HotwordMetricsLogger.writeAudioEgressEvent(mDetectorType,
|
||||||
HOTWORD_DETECTOR_EVENTS__EVENT__AUDIO_EGRESS_CLOSE_ERROR_FROM_SYSTEM,
|
HOTWORD_AUDIO_EGRESS_EVENT_REPORTED__EVENT__CLOSE_ERROR_FROM_SYSTEM,
|
||||||
mVoiceInteractorUid);
|
mVoiceInteractorUid, /* streamSizeBytes= */ 0, /* bundleSizeBytes= */ 0,
|
||||||
|
mCopyTaskInfos.size());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Slog.e(TAG, mResultTaskId + ": Failed to propagate error", e);
|
Slog.e(TAG, mResultTaskId + ": Failed to propagate error", e);
|
||||||
}
|
}
|
||||||
@@ -288,8 +296,10 @@ final class HotwordAudioStreamCopier {
|
|||||||
mAudioSource.closeWithError(e.getMessage());
|
mAudioSource.closeWithError(e.getMessage());
|
||||||
mAudioSink.closeWithError(e.getMessage());
|
mAudioSink.closeWithError(e.getMessage());
|
||||||
Slog.e(TAG, mStreamTaskId + ": Failed to copy audio stream", e);
|
Slog.e(TAG, mStreamTaskId + ": Failed to copy audio stream", e);
|
||||||
HotwordMetricsLogger.writeDetectorEvent(mDetectorType,
|
HotwordMetricsLogger.writeAudioEgressEvent(mDetectorType,
|
||||||
HOTWORD_DETECTOR_EVENTS__EVENT__AUDIO_EGRESS_CLOSE_ERROR_FROM_SYSTEM, mUid);
|
HOTWORD_AUDIO_EGRESS_EVENT_REPORTED__EVENT__CLOSE_ERROR_FROM_SYSTEM,
|
||||||
|
mUid, /* streamSizeBytes= */ 0, /* bundleSizeBytes= */ 0,
|
||||||
|
/* streamCount= */ 0);
|
||||||
} finally {
|
} finally {
|
||||||
if (fis != null) {
|
if (fis != null) {
|
||||||
fis.close();
|
fis.close();
|
||||||
|
|||||||
@@ -16,6 +16,9 @@
|
|||||||
|
|
||||||
package com.android.server.voiceinteraction;
|
package com.android.server.voiceinteraction;
|
||||||
|
|
||||||
|
import static com.android.internal.util.FrameworkStatsLog.HOTWORD_AUDIO_EGRESS_EVENT_REPORTED__DETECTOR_TYPE__NORMAL_DETECTOR;
|
||||||
|
import static com.android.internal.util.FrameworkStatsLog.HOTWORD_AUDIO_EGRESS_EVENT_REPORTED__DETECTOR_TYPE__TRUSTED_DETECTOR_DSP;
|
||||||
|
import static com.android.internal.util.FrameworkStatsLog.HOTWORD_AUDIO_EGRESS_EVENT_REPORTED__DETECTOR_TYPE__TRUSTED_DETECTOR_SOFTWARE;
|
||||||
import static com.android.internal.util.FrameworkStatsLog.HOTWORD_DETECTION_SERVICE_INIT_RESULT_REPORTED__DETECTOR_TYPE__NORMAL_DETECTOR;
|
import static com.android.internal.util.FrameworkStatsLog.HOTWORD_DETECTION_SERVICE_INIT_RESULT_REPORTED__DETECTOR_TYPE__NORMAL_DETECTOR;
|
||||||
import static com.android.internal.util.FrameworkStatsLog.HOTWORD_DETECTION_SERVICE_INIT_RESULT_REPORTED__DETECTOR_TYPE__TRUSTED_DETECTOR_DSP;
|
import static com.android.internal.util.FrameworkStatsLog.HOTWORD_DETECTION_SERVICE_INIT_RESULT_REPORTED__DETECTOR_TYPE__TRUSTED_DETECTOR_DSP;
|
||||||
import static com.android.internal.util.FrameworkStatsLog.HOTWORD_DETECTION_SERVICE_INIT_RESULT_REPORTED__DETECTOR_TYPE__TRUSTED_DETECTOR_SOFTWARE;
|
import static com.android.internal.util.FrameworkStatsLog.HOTWORD_DETECTION_SERVICE_INIT_RESULT_REPORTED__DETECTOR_TYPE__TRUSTED_DETECTOR_SOFTWARE;
|
||||||
@@ -47,6 +50,12 @@ public final class HotwordMetricsLogger {
|
|||||||
HOTWORD_DETECTION_SERVICE_INIT_RESULT_REPORTED__DETECTOR_TYPE__TRUSTED_DETECTOR_DSP;
|
HOTWORD_DETECTION_SERVICE_INIT_RESULT_REPORTED__DETECTOR_TYPE__TRUSTED_DETECTOR_DSP;
|
||||||
private static final int METRICS_INIT_NORMAL_DETECTOR =
|
private static final int METRICS_INIT_NORMAL_DETECTOR =
|
||||||
HOTWORD_DETECTION_SERVICE_INIT_RESULT_REPORTED__DETECTOR_TYPE__NORMAL_DETECTOR;
|
HOTWORD_DETECTION_SERVICE_INIT_RESULT_REPORTED__DETECTOR_TYPE__NORMAL_DETECTOR;
|
||||||
|
private static final int AUDIO_EGRESS_DSP_DETECTOR =
|
||||||
|
HOTWORD_AUDIO_EGRESS_EVENT_REPORTED__DETECTOR_TYPE__TRUSTED_DETECTOR_DSP;
|
||||||
|
private static final int AUDIO_EGRESS_SOFTWARE_DETECTOR =
|
||||||
|
HOTWORD_AUDIO_EGRESS_EVENT_REPORTED__DETECTOR_TYPE__TRUSTED_DETECTOR_SOFTWARE;
|
||||||
|
private static final int AUDIO_EGRESS_NORMAL_DETECTOR =
|
||||||
|
HOTWORD_AUDIO_EGRESS_EVENT_REPORTED__DETECTOR_TYPE__NORMAL_DETECTOR;
|
||||||
|
|
||||||
private HotwordMetricsLogger() {
|
private HotwordMetricsLogger() {
|
||||||
// Class only contains static utility functions, and should not be instantiated
|
// Class only contains static utility functions, and should not be instantiated
|
||||||
@@ -97,6 +106,16 @@ public final class HotwordMetricsLogger {
|
|||||||
metricsDetectorType, event, uid);
|
metricsDetectorType, event, uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logs information related to hotword audio egress events.
|
||||||
|
*/
|
||||||
|
public static void writeAudioEgressEvent(int detectorType, int event, int uid,
|
||||||
|
int streamSizeBytes, int bundleSizeBytes, int streamCount) {
|
||||||
|
int metricsDetectorType = getAudioEgressDetectorType(detectorType);
|
||||||
|
FrameworkStatsLog.write(FrameworkStatsLog.HOTWORD_AUDIO_EGRESS_EVENT_REPORTED,
|
||||||
|
metricsDetectorType, event, uid, streamSizeBytes, bundleSizeBytes, streamCount);
|
||||||
|
}
|
||||||
|
|
||||||
private static int getCreateMetricsDetectorType(int detectorType) {
|
private static int getCreateMetricsDetectorType(int detectorType) {
|
||||||
switch (detectorType) {
|
switch (detectorType) {
|
||||||
case HotwordDetector.DETECTOR_TYPE_TRUSTED_HOTWORD_SOFTWARE:
|
case HotwordDetector.DETECTOR_TYPE_TRUSTED_HOTWORD_SOFTWARE:
|
||||||
@@ -151,4 +170,15 @@ public final class HotwordMetricsLogger {
|
|||||||
return HOTWORD_DETECTOR_EVENTS__DETECTOR_TYPE__NORMAL_DETECTOR;
|
return HOTWORD_DETECTOR_EVENTS__DETECTOR_TYPE__NORMAL_DETECTOR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static int getAudioEgressDetectorType(int detectorType) {
|
||||||
|
switch (detectorType) {
|
||||||
|
case HotwordDetector.DETECTOR_TYPE_TRUSTED_HOTWORD_SOFTWARE:
|
||||||
|
return AUDIO_EGRESS_SOFTWARE_DETECTOR;
|
||||||
|
case HotwordDetector.DETECTOR_TYPE_TRUSTED_HOTWORD_DSP:
|
||||||
|
return AUDIO_EGRESS_DSP_DETECTOR;
|
||||||
|
default:
|
||||||
|
return AUDIO_EGRESS_NORMAL_DETECTOR;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user