SoundTriggerLogger replaced with utils.EventLogger
The class was replaced with EventLogger for deduplication purposes Bug: b/254234346 Test: I don't think there are any tests for soundtrigger Change-Id: I1e80a3b31696d010aca8d267af713a9e7ff6a6e6
This commit is contained in:
@@ -1,136 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2019 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.server.soundtrigger;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedList;
|
||||
|
||||
/**
|
||||
* Constructor SoundTriggerLogger class
|
||||
*/
|
||||
public class SoundTriggerLogger {
|
||||
|
||||
// ring buffer of events to log.
|
||||
private final LinkedList<Event> mEvents;
|
||||
|
||||
private final String mTitle;
|
||||
|
||||
// the maximum number of events to keep in log
|
||||
private final int mMemSize;
|
||||
|
||||
/**
|
||||
* Constructor for Event class.
|
||||
*/
|
||||
public abstract static class Event {
|
||||
// formatter for timestamps
|
||||
private static final SimpleDateFormat sFormat = new SimpleDateFormat("MM-dd HH:mm:ss:SSS");
|
||||
|
||||
private final long mTimestamp;
|
||||
|
||||
Event() {
|
||||
mTimestamp = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert event to String
|
||||
* @return StringBuilder
|
||||
*/
|
||||
public String toString() {
|
||||
return (new StringBuilder(sFormat.format(new Date(mTimestamp))))
|
||||
.append(" ").append(eventToString()).toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Causes the string message for the event to appear in the logcat.
|
||||
* Here is an example of how to create a new event (a StringEvent), adding it to the logger
|
||||
* (an instance of SoundTriggerLogger) while also making it show in the logcat:
|
||||
* <pre>
|
||||
* myLogger.log(
|
||||
* (new StringEvent("something for logcat and logger")).printLog(MyClass.TAG) );
|
||||
* </pre>
|
||||
* @param tag the tag for the android.util.Log.v
|
||||
* @return the same instance of the event
|
||||
*/
|
||||
public Event printLog(String tag) {
|
||||
Log.i(tag, eventToString());
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert event to String.
|
||||
* This method is only called when the logger history is about to the dumped,
|
||||
* so this method is where expensive String conversions should be made, not when the Event
|
||||
* subclass is created.
|
||||
* Timestamp information will be automatically added, do not include it.
|
||||
* @return a string representation of the event that occurred.
|
||||
*/
|
||||
public abstract String eventToString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor StringEvent class
|
||||
*/
|
||||
public static class StringEvent extends Event {
|
||||
private final String mMsg;
|
||||
|
||||
public StringEvent(String msg) {
|
||||
mMsg = msg;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String eventToString() {
|
||||
return mMsg;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for logger.
|
||||
* @param size the maximum number of events to keep in log
|
||||
* @param title the string displayed before the recorded log
|
||||
*/
|
||||
public SoundTriggerLogger(int size, String title) {
|
||||
mEvents = new LinkedList<Event>();
|
||||
mMemSize = size;
|
||||
mTitle = title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for logger.
|
||||
* @param evt the maximum number of events to keep in log
|
||||
*/
|
||||
public synchronized void log(Event evt) {
|
||||
if (mEvents.size() >= mMemSize) {
|
||||
mEvents.removeFirst();
|
||||
}
|
||||
mEvents.add(evt);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for logger.
|
||||
* @param pw the maximum number of events to keep in log
|
||||
*/
|
||||
public synchronized void dump(PrintWriter pw) {
|
||||
pw.println("ST Event log: " + mTitle);
|
||||
for (Event evt : mEvents) {
|
||||
pw.println(evt.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -84,6 +84,7 @@ import com.android.internal.annotations.GuardedBy;
|
||||
import com.android.internal.app.ISoundTriggerService;
|
||||
import com.android.internal.app.ISoundTriggerSession;
|
||||
import com.android.server.SystemService;
|
||||
import com.android.server.utils.EventLogger;
|
||||
|
||||
import java.io.FileDescriptor;
|
||||
import java.io.PrintWriter;
|
||||
@@ -309,14 +310,14 @@ public class SoundTriggerService extends SystemService {
|
||||
Slog.i(TAG, "startRecognition(): Uuid : " + parcelUuid);
|
||||
}
|
||||
|
||||
sEventLogger.log(new SoundTriggerLogger.StringEvent("startRecognition(): Uuid : "
|
||||
+ parcelUuid));
|
||||
sEventLogger.enqueue(new EventLogger.StringEvent(
|
||||
"startRecognition(): Uuid : " + parcelUuid));
|
||||
|
||||
GenericSoundModel model = getSoundModel(parcelUuid);
|
||||
if (model == null) {
|
||||
Slog.w(TAG, "Null model in database for id: " + parcelUuid);
|
||||
|
||||
sEventLogger.log(new SoundTriggerLogger.StringEvent(
|
||||
sEventLogger.enqueue(new EventLogger.StringEvent(
|
||||
"startRecognition(): Null model in database for id: " + parcelUuid));
|
||||
|
||||
return STATUS_ERROR;
|
||||
@@ -339,7 +340,7 @@ public class SoundTriggerService extends SystemService {
|
||||
Slog.i(TAG, "stopRecognition(): Uuid : " + parcelUuid);
|
||||
}
|
||||
|
||||
sEventLogger.log(new SoundTriggerLogger.StringEvent("stopRecognition(): Uuid : "
|
||||
sEventLogger.enqueue(new EventLogger.StringEvent("stopRecognition(): Uuid : "
|
||||
+ parcelUuid));
|
||||
|
||||
int ret = mSoundTriggerHelper.stopGenericRecognition(parcelUuid.getUuid(),
|
||||
@@ -359,7 +360,7 @@ public class SoundTriggerService extends SystemService {
|
||||
Slog.i(TAG, "getSoundModel(): id = " + soundModelId);
|
||||
}
|
||||
|
||||
sEventLogger.log(new SoundTriggerLogger.StringEvent("getSoundModel(): id = "
|
||||
sEventLogger.enqueue(new EventLogger.StringEvent("getSoundModel(): id = "
|
||||
+ soundModelId));
|
||||
|
||||
SoundTrigger.GenericSoundModel model = mDbHelper.getGenericSoundModel(
|
||||
@@ -376,7 +377,7 @@ public class SoundTriggerService extends SystemService {
|
||||
Slog.i(TAG, "updateSoundModel(): model = " + soundModel);
|
||||
}
|
||||
|
||||
sEventLogger.log(new SoundTriggerLogger.StringEvent("updateSoundModel(): model = "
|
||||
sEventLogger.enqueue(new EventLogger.StringEvent("updateSoundModel(): model = "
|
||||
+ soundModel));
|
||||
|
||||
mDbHelper.updateGenericSoundModel(soundModel);
|
||||
@@ -391,7 +392,7 @@ public class SoundTriggerService extends SystemService {
|
||||
Slog.i(TAG, "deleteSoundModel(): id = " + soundModelId);
|
||||
}
|
||||
|
||||
sEventLogger.log(new SoundTriggerLogger.StringEvent("deleteSoundModel(): id = "
|
||||
sEventLogger.enqueue(new EventLogger.StringEvent("deleteSoundModel(): id = "
|
||||
+ soundModelId));
|
||||
|
||||
// Unload the model if it is loaded.
|
||||
@@ -411,7 +412,7 @@ public class SoundTriggerService extends SystemService {
|
||||
if (soundModel == null || soundModel.getUuid() == null) {
|
||||
Slog.w(TAG, "Invalid sound model");
|
||||
|
||||
sEventLogger.log(new SoundTriggerLogger.StringEvent(
|
||||
sEventLogger.enqueue(new EventLogger.StringEvent(
|
||||
"loadGenericSoundModel(): Invalid sound model"));
|
||||
|
||||
return STATUS_ERROR;
|
||||
@@ -420,7 +421,7 @@ public class SoundTriggerService extends SystemService {
|
||||
Slog.i(TAG, "loadGenericSoundModel(): id = " + soundModel.getUuid());
|
||||
}
|
||||
|
||||
sEventLogger.log(new SoundTriggerLogger.StringEvent("loadGenericSoundModel(): id = "
|
||||
sEventLogger.enqueue(new EventLogger.StringEvent("loadGenericSoundModel(): id = "
|
||||
+ soundModel.getUuid()));
|
||||
|
||||
synchronized (mLock) {
|
||||
@@ -447,7 +448,7 @@ public class SoundTriggerService extends SystemService {
|
||||
if (soundModel == null || soundModel.getUuid() == null) {
|
||||
Slog.w(TAG, "Invalid sound model");
|
||||
|
||||
sEventLogger.log(new SoundTriggerLogger.StringEvent(
|
||||
sEventLogger.enqueue(new EventLogger.StringEvent(
|
||||
"loadKeyphraseSoundModel(): Invalid sound model"));
|
||||
|
||||
return STATUS_ERROR;
|
||||
@@ -455,7 +456,7 @@ public class SoundTriggerService extends SystemService {
|
||||
if (soundModel.getKeyphrases() == null || soundModel.getKeyphrases().length != 1) {
|
||||
Slog.w(TAG, "Only one keyphrase per model is currently supported.");
|
||||
|
||||
sEventLogger.log(new SoundTriggerLogger.StringEvent(
|
||||
sEventLogger.enqueue(new EventLogger.StringEvent(
|
||||
"loadKeyphraseSoundModel(): Only one keyphrase per model"
|
||||
+ " is currently supported."));
|
||||
|
||||
@@ -465,8 +466,8 @@ public class SoundTriggerService extends SystemService {
|
||||
Slog.i(TAG, "loadKeyphraseSoundModel(): id = " + soundModel.getUuid());
|
||||
}
|
||||
|
||||
sEventLogger.log(
|
||||
new SoundTriggerLogger.StringEvent("loadKeyphraseSoundModel(): id = "
|
||||
sEventLogger.enqueue(
|
||||
new EventLogger.StringEvent("loadKeyphraseSoundModel(): id = "
|
||||
+ soundModel.getUuid()));
|
||||
|
||||
synchronized (mLock) {
|
||||
@@ -503,7 +504,7 @@ public class SoundTriggerService extends SystemService {
|
||||
Slog.i(TAG, "startRecognition(): id = " + soundModelId);
|
||||
}
|
||||
|
||||
sEventLogger.log(new SoundTriggerLogger.StringEvent(
|
||||
sEventLogger.enqueue(new EventLogger.StringEvent(
|
||||
"startRecognitionForService(): id = " + soundModelId));
|
||||
|
||||
IRecognitionStatusCallback callback =
|
||||
@@ -515,7 +516,7 @@ public class SoundTriggerService extends SystemService {
|
||||
if (soundModel == null) {
|
||||
Slog.w(TAG, soundModelId + " is not loaded");
|
||||
|
||||
sEventLogger.log(new SoundTriggerLogger.StringEvent(
|
||||
sEventLogger.enqueue(new EventLogger.StringEvent(
|
||||
"startRecognitionForService():" + soundModelId + " is not loaded"));
|
||||
|
||||
return STATUS_ERROR;
|
||||
@@ -527,7 +528,7 @@ public class SoundTriggerService extends SystemService {
|
||||
if (existingCallback != null) {
|
||||
Slog.w(TAG, soundModelId + " is already running");
|
||||
|
||||
sEventLogger.log(new SoundTriggerLogger.StringEvent(
|
||||
sEventLogger.enqueue(new EventLogger.StringEvent(
|
||||
"startRecognitionForService():"
|
||||
+ soundModelId + " is already running"));
|
||||
|
||||
@@ -542,7 +543,7 @@ public class SoundTriggerService extends SystemService {
|
||||
default:
|
||||
Slog.e(TAG, "Unknown model type");
|
||||
|
||||
sEventLogger.log(new SoundTriggerLogger.StringEvent(
|
||||
sEventLogger.enqueue(new EventLogger.StringEvent(
|
||||
"startRecognitionForService(): Unknown model type"));
|
||||
|
||||
return STATUS_ERROR;
|
||||
@@ -551,7 +552,7 @@ public class SoundTriggerService extends SystemService {
|
||||
if (ret != STATUS_OK) {
|
||||
Slog.e(TAG, "Failed to start model: " + ret);
|
||||
|
||||
sEventLogger.log(new SoundTriggerLogger.StringEvent(
|
||||
sEventLogger.enqueue(new EventLogger.StringEvent(
|
||||
"startRecognitionForService(): Failed to start model:"));
|
||||
|
||||
return ret;
|
||||
@@ -574,7 +575,7 @@ public class SoundTriggerService extends SystemService {
|
||||
Slog.i(TAG, "stopRecognition(): id = " + soundModelId);
|
||||
}
|
||||
|
||||
sEventLogger.log(new SoundTriggerLogger.StringEvent(
|
||||
sEventLogger.enqueue(new EventLogger.StringEvent(
|
||||
"stopRecognitionForService(): id = " + soundModelId));
|
||||
|
||||
synchronized (mLock) {
|
||||
@@ -582,7 +583,7 @@ public class SoundTriggerService extends SystemService {
|
||||
if (soundModel == null) {
|
||||
Slog.w(TAG, soundModelId + " is not loaded");
|
||||
|
||||
sEventLogger.log(new SoundTriggerLogger.StringEvent(
|
||||
sEventLogger.enqueue(new EventLogger.StringEvent(
|
||||
"stopRecognitionForService(): " + soundModelId
|
||||
+ " is not loaded"));
|
||||
|
||||
@@ -595,7 +596,7 @@ public class SoundTriggerService extends SystemService {
|
||||
if (callback == null) {
|
||||
Slog.w(TAG, soundModelId + " is not running");
|
||||
|
||||
sEventLogger.log(new SoundTriggerLogger.StringEvent(
|
||||
sEventLogger.enqueue(new EventLogger.StringEvent(
|
||||
"stopRecognitionForService(): " + soundModelId
|
||||
+ " is not running"));
|
||||
|
||||
@@ -610,7 +611,7 @@ public class SoundTriggerService extends SystemService {
|
||||
default:
|
||||
Slog.e(TAG, "Unknown model type");
|
||||
|
||||
sEventLogger.log(new SoundTriggerLogger.StringEvent(
|
||||
sEventLogger.enqueue(new EventLogger.StringEvent(
|
||||
"stopRecognitionForService(): Unknown model type"));
|
||||
|
||||
return STATUS_ERROR;
|
||||
@@ -619,7 +620,7 @@ public class SoundTriggerService extends SystemService {
|
||||
if (ret != STATUS_OK) {
|
||||
Slog.e(TAG, "Failed to stop model: " + ret);
|
||||
|
||||
sEventLogger.log(new SoundTriggerLogger.StringEvent(
|
||||
sEventLogger.enqueue(new EventLogger.StringEvent(
|
||||
"stopRecognitionForService(): Failed to stop model: " + ret));
|
||||
|
||||
return ret;
|
||||
@@ -642,7 +643,7 @@ public class SoundTriggerService extends SystemService {
|
||||
Slog.i(TAG, "unloadSoundModel(): id = " + soundModelId);
|
||||
}
|
||||
|
||||
sEventLogger.log(new SoundTriggerLogger.StringEvent("unloadSoundModel(): id = "
|
||||
sEventLogger.enqueue(new EventLogger.StringEvent("unloadSoundModel(): id = "
|
||||
+ soundModelId));
|
||||
|
||||
synchronized (mLock) {
|
||||
@@ -650,7 +651,7 @@ public class SoundTriggerService extends SystemService {
|
||||
if (soundModel == null) {
|
||||
Slog.w(TAG, soundModelId + " is not loaded");
|
||||
|
||||
sEventLogger.log(new SoundTriggerLogger.StringEvent(
|
||||
sEventLogger.enqueue(new EventLogger.StringEvent(
|
||||
"unloadSoundModel(): " + soundModelId + " is not loaded"));
|
||||
|
||||
return STATUS_ERROR;
|
||||
@@ -667,7 +668,7 @@ public class SoundTriggerService extends SystemService {
|
||||
default:
|
||||
Slog.e(TAG, "Unknown model type");
|
||||
|
||||
sEventLogger.log(new SoundTriggerLogger.StringEvent(
|
||||
sEventLogger.enqueue(new EventLogger.StringEvent(
|
||||
"unloadSoundModel(): Unknown model type"));
|
||||
|
||||
return STATUS_ERROR;
|
||||
@@ -675,7 +676,7 @@ public class SoundTriggerService extends SystemService {
|
||||
if (ret != STATUS_OK) {
|
||||
Slog.e(TAG, "Failed to unload model");
|
||||
|
||||
sEventLogger.log(new SoundTriggerLogger.StringEvent(
|
||||
sEventLogger.enqueue(new EventLogger.StringEvent(
|
||||
"unloadSoundModel(): Failed to unload model"));
|
||||
|
||||
return ret;
|
||||
@@ -709,7 +710,7 @@ public class SoundTriggerService extends SystemService {
|
||||
Slog.i(TAG, "getModelState(): id = " + soundModelId);
|
||||
}
|
||||
|
||||
sEventLogger.log(new SoundTriggerLogger.StringEvent("getModelState(): id = "
|
||||
sEventLogger.enqueue(new EventLogger.StringEvent("getModelState(): id = "
|
||||
+ soundModelId));
|
||||
|
||||
synchronized (mLock) {
|
||||
@@ -717,7 +718,7 @@ public class SoundTriggerService extends SystemService {
|
||||
if (soundModel == null) {
|
||||
Slog.w(TAG, soundModelId + " is not loaded");
|
||||
|
||||
sEventLogger.log(new SoundTriggerLogger.StringEvent("getModelState(): "
|
||||
sEventLogger.enqueue(new EventLogger.StringEvent("getModelState(): "
|
||||
+ soundModelId + " is not loaded"));
|
||||
|
||||
return ret;
|
||||
@@ -729,7 +730,7 @@ public class SoundTriggerService extends SystemService {
|
||||
default:
|
||||
// SoundModel.TYPE_KEYPHRASE is not supported to increase privacy.
|
||||
Slog.e(TAG, "Unsupported model type, " + soundModel.getType());
|
||||
sEventLogger.log(new SoundTriggerLogger.StringEvent(
|
||||
sEventLogger.enqueue(new EventLogger.StringEvent(
|
||||
"getModelState(): Unsupported model type, "
|
||||
+ soundModel.getType()));
|
||||
break;
|
||||
@@ -751,7 +752,7 @@ public class SoundTriggerService extends SystemService {
|
||||
|
||||
synchronized (mLock) {
|
||||
ModuleProperties properties = mSoundTriggerHelper.getModuleProperties();
|
||||
sEventLogger.log(new SoundTriggerLogger.StringEvent(
|
||||
sEventLogger.enqueue(new EventLogger.StringEvent(
|
||||
"getModuleProperties(): " + properties));
|
||||
return properties;
|
||||
}
|
||||
@@ -769,7 +770,7 @@ public class SoundTriggerService extends SystemService {
|
||||
+ ", value=" + value);
|
||||
}
|
||||
|
||||
sEventLogger.log(new SoundTriggerLogger.StringEvent(
|
||||
sEventLogger.enqueue(new EventLogger.StringEvent(
|
||||
"setParameter(): id=" + soundModelId
|
||||
+ ", param=" + modelParam
|
||||
+ ", value=" + value));
|
||||
@@ -780,7 +781,7 @@ public class SoundTriggerService extends SystemService {
|
||||
Slog.w(TAG, soundModelId + " is not loaded. Loaded models: "
|
||||
+ mLoadedModels.toString());
|
||||
|
||||
sEventLogger.log(new SoundTriggerLogger.StringEvent("setParameter(): "
|
||||
sEventLogger.enqueue(new EventLogger.StringEvent("setParameter(): "
|
||||
+ soundModelId + " is not loaded"));
|
||||
|
||||
return STATUS_BAD_VALUE;
|
||||
@@ -803,7 +804,7 @@ public class SoundTriggerService extends SystemService {
|
||||
+ ", param=" + modelParam);
|
||||
}
|
||||
|
||||
sEventLogger.log(new SoundTriggerLogger.StringEvent(
|
||||
sEventLogger.enqueue(new EventLogger.StringEvent(
|
||||
"getParameter(): id=" + soundModelId
|
||||
+ ", param=" + modelParam));
|
||||
|
||||
@@ -812,7 +813,7 @@ public class SoundTriggerService extends SystemService {
|
||||
if (soundModel == null) {
|
||||
Slog.w(TAG, soundModelId + " is not loaded");
|
||||
|
||||
sEventLogger.log(new SoundTriggerLogger.StringEvent("getParameter(): "
|
||||
sEventLogger.enqueue(new EventLogger.StringEvent("getParameter(): "
|
||||
+ soundModelId + " is not loaded"));
|
||||
|
||||
throw new IllegalArgumentException("sound model is not loaded");
|
||||
@@ -834,7 +835,7 @@ public class SoundTriggerService extends SystemService {
|
||||
+ ", param=" + modelParam);
|
||||
}
|
||||
|
||||
sEventLogger.log(new SoundTriggerLogger.StringEvent(
|
||||
sEventLogger.enqueue(new EventLogger.StringEvent(
|
||||
"queryParameter(): id=" + soundModelId
|
||||
+ ", param=" + modelParam));
|
||||
|
||||
@@ -843,7 +844,7 @@ public class SoundTriggerService extends SystemService {
|
||||
if (soundModel == null) {
|
||||
Slog.w(TAG, soundModelId + " is not loaded");
|
||||
|
||||
sEventLogger.log(new SoundTriggerLogger.StringEvent(
|
||||
sEventLogger.enqueue(new EventLogger.StringEvent(
|
||||
"queryParameter(): "
|
||||
+ soundModelId + " is not loaded"));
|
||||
|
||||
@@ -857,7 +858,7 @@ public class SoundTriggerService extends SystemService {
|
||||
|
||||
private void clientDied() {
|
||||
Slog.w(TAG, "Client died, cleaning up session.");
|
||||
sEventLogger.log(new SoundTriggerLogger.StringEvent(
|
||||
sEventLogger.enqueue(new EventLogger.StringEvent(
|
||||
"Client died, cleaning up session."));
|
||||
mSoundTriggerHelper.detach();
|
||||
}
|
||||
@@ -1027,7 +1028,7 @@ public class SoundTriggerService extends SystemService {
|
||||
} catch (Exception e) {
|
||||
Slog.e(TAG, mPuuid + ": Cannot remove client", e);
|
||||
|
||||
sEventLogger.log(new SoundTriggerLogger.StringEvent(mPuuid
|
||||
sEventLogger.enqueue(new EventLogger.StringEvent(mPuuid
|
||||
+ ": Cannot remove client"));
|
||||
|
||||
}
|
||||
@@ -1052,7 +1053,7 @@ public class SoundTriggerService extends SystemService {
|
||||
private void destroy() {
|
||||
if (DEBUG) Slog.v(TAG, mPuuid + ": destroy");
|
||||
|
||||
sEventLogger.log(new SoundTriggerLogger.StringEvent(mPuuid + ": destroy"));
|
||||
sEventLogger.enqueue(new EventLogger.StringEvent(mPuuid + ": destroy"));
|
||||
|
||||
synchronized (mRemoteServiceLock) {
|
||||
disconnectLocked();
|
||||
@@ -1086,7 +1087,7 @@ public class SoundTriggerService extends SystemService {
|
||||
Slog.e(TAG, mPuuid + ": Could not stop operation "
|
||||
+ mRunningOpIds.valueAt(i), e);
|
||||
|
||||
sEventLogger.log(new SoundTriggerLogger.StringEvent(mPuuid
|
||||
sEventLogger.enqueue(new EventLogger.StringEvent(mPuuid
|
||||
+ ": Could not stop operation " + mRunningOpIds.valueAt(
|
||||
i)));
|
||||
|
||||
@@ -1116,7 +1117,7 @@ public class SoundTriggerService extends SystemService {
|
||||
if (ri == null) {
|
||||
Slog.w(TAG, mPuuid + ": " + mServiceName + " not found");
|
||||
|
||||
sEventLogger.log(new SoundTriggerLogger.StringEvent(mPuuid
|
||||
sEventLogger.enqueue(new EventLogger.StringEvent(mPuuid
|
||||
+ ": " + mServiceName + " not found"));
|
||||
|
||||
return;
|
||||
@@ -1127,7 +1128,7 @@ public class SoundTriggerService extends SystemService {
|
||||
Slog.w(TAG, mPuuid + ": " + mServiceName + " does not require "
|
||||
+ BIND_SOUND_TRIGGER_DETECTION_SERVICE);
|
||||
|
||||
sEventLogger.log(new SoundTriggerLogger.StringEvent(mPuuid
|
||||
sEventLogger.enqueue(new EventLogger.StringEvent(mPuuid
|
||||
+ ": " + mServiceName + " does not require "
|
||||
+ BIND_SOUND_TRIGGER_DETECTION_SERVICE));
|
||||
|
||||
@@ -1143,7 +1144,7 @@ public class SoundTriggerService extends SystemService {
|
||||
} else {
|
||||
Slog.w(TAG, mPuuid + ": Could not bind to " + mServiceName);
|
||||
|
||||
sEventLogger.log(new SoundTriggerLogger.StringEvent(mPuuid
|
||||
sEventLogger.enqueue(new EventLogger.StringEvent(mPuuid
|
||||
+ ": Could not bind to " + mServiceName));
|
||||
|
||||
}
|
||||
@@ -1165,7 +1166,7 @@ public class SoundTriggerService extends SystemService {
|
||||
mPuuid + ": Dropped operation as already destroyed or marked for "
|
||||
+ "destruction");
|
||||
|
||||
sEventLogger.log(new SoundTriggerLogger.StringEvent(mPuuid
|
||||
sEventLogger.enqueue(new EventLogger.StringEvent(mPuuid
|
||||
+ ":Dropped operation as already destroyed or marked for "
|
||||
+ "destruction"));
|
||||
|
||||
@@ -1197,7 +1198,7 @@ public class SoundTriggerService extends SystemService {
|
||||
mPuuid + ": Dropped operation as too many operations "
|
||||
+ "were run in last 24 hours");
|
||||
|
||||
sEventLogger.log(new SoundTriggerLogger.StringEvent(mPuuid
|
||||
sEventLogger.enqueue(new EventLogger.StringEvent(mPuuid
|
||||
+ ": Dropped operation as too many operations "
|
||||
+ "were run in last 24 hours"));
|
||||
|
||||
@@ -1207,7 +1208,7 @@ public class SoundTriggerService extends SystemService {
|
||||
} catch (Exception e) {
|
||||
Slog.e(TAG, mPuuid + ": Could not drop operation", e);
|
||||
|
||||
sEventLogger.log(new SoundTriggerLogger.StringEvent(mPuuid
|
||||
sEventLogger.enqueue(new EventLogger.StringEvent(mPuuid
|
||||
+ ": Could not drop operation"));
|
||||
|
||||
}
|
||||
@@ -1224,7 +1225,7 @@ public class SoundTriggerService extends SystemService {
|
||||
try {
|
||||
if (DEBUG) Slog.v(TAG, mPuuid + ": runOp " + opId);
|
||||
|
||||
sEventLogger.log(new SoundTriggerLogger.StringEvent(mPuuid
|
||||
sEventLogger.enqueue(new EventLogger.StringEvent(mPuuid
|
||||
+ ": runOp " + opId));
|
||||
|
||||
op.run(opId, mService);
|
||||
@@ -1232,7 +1233,7 @@ public class SoundTriggerService extends SystemService {
|
||||
} catch (Exception e) {
|
||||
Slog.e(TAG, mPuuid + ": Could not run operation " + opId, e);
|
||||
|
||||
sEventLogger.log(new SoundTriggerLogger.StringEvent(mPuuid
|
||||
sEventLogger.enqueue(new EventLogger.StringEvent(mPuuid
|
||||
+ ": Could not run operation " + opId));
|
||||
|
||||
}
|
||||
@@ -1265,7 +1266,7 @@ public class SoundTriggerService extends SystemService {
|
||||
Slog.w(TAG, mPuuid + "->" + mServiceName + ": IGNORED onKeyphraseDetected(" + event
|
||||
+ ")");
|
||||
|
||||
sEventLogger.log(new SoundTriggerLogger.StringEvent(mPuuid + "->" + mServiceName
|
||||
sEventLogger.enqueue(new EventLogger.StringEvent(mPuuid + "->" + mServiceName
|
||||
+ ": IGNORED onKeyphraseDetected(" + event + ")"));
|
||||
}
|
||||
|
||||
@@ -1282,9 +1283,9 @@ public class SoundTriggerService extends SystemService {
|
||||
attributesBuilder.setInternalCapturePreset(MediaRecorder.AudioSource.HOTWORD);
|
||||
AudioAttributes attributes = attributesBuilder.build();
|
||||
|
||||
AudioFormat originalFormat = event.getCaptureFormat();
|
||||
AudioFormat originalFormat = event.getCaptureFormat();
|
||||
|
||||
sEventLogger.log(new SoundTriggerLogger.StringEvent("createAudioRecordForEvent"));
|
||||
sEventLogger.enqueue(new EventLogger.StringEvent("createAudioRecordForEvent"));
|
||||
|
||||
return (new AudioRecord.Builder())
|
||||
.setAudioAttributes(attributes)
|
||||
@@ -1301,7 +1302,7 @@ public class SoundTriggerService extends SystemService {
|
||||
public void onGenericSoundTriggerDetected(SoundTrigger.GenericRecognitionEvent event) {
|
||||
if (DEBUG) Slog.v(TAG, mPuuid + ": Generic sound trigger event: " + event);
|
||||
|
||||
sEventLogger.log(new SoundTriggerLogger.StringEvent(mPuuid
|
||||
sEventLogger.enqueue(new EventLogger.StringEvent(mPuuid
|
||||
+ ": Generic sound trigger event: " + event));
|
||||
|
||||
runOrAddOperation(new Operation(
|
||||
@@ -1336,7 +1337,7 @@ public class SoundTriggerService extends SystemService {
|
||||
public void onError(int status) {
|
||||
if (DEBUG) Slog.v(TAG, mPuuid + ": onError: " + status);
|
||||
|
||||
sEventLogger.log(new SoundTriggerLogger.StringEvent(mPuuid
|
||||
sEventLogger.enqueue(new EventLogger.StringEvent(mPuuid
|
||||
+ ": onError: " + status));
|
||||
|
||||
runOrAddOperation(
|
||||
@@ -1359,7 +1360,7 @@ public class SoundTriggerService extends SystemService {
|
||||
public void onRecognitionPaused() {
|
||||
Slog.i(TAG, mPuuid + "->" + mServiceName + ": IGNORED onRecognitionPaused");
|
||||
|
||||
sEventLogger.log(new SoundTriggerLogger.StringEvent(mPuuid
|
||||
sEventLogger.enqueue(new EventLogger.StringEvent(mPuuid
|
||||
+ "->" + mServiceName + ": IGNORED onRecognitionPaused"));
|
||||
|
||||
}
|
||||
@@ -1368,7 +1369,7 @@ public class SoundTriggerService extends SystemService {
|
||||
public void onRecognitionResumed() {
|
||||
Slog.i(TAG, mPuuid + "->" + mServiceName + ": IGNORED onRecognitionResumed");
|
||||
|
||||
sEventLogger.log(new SoundTriggerLogger.StringEvent(mPuuid
|
||||
sEventLogger.enqueue(new EventLogger.StringEvent(mPuuid
|
||||
+ "->" + mServiceName + ": IGNORED onRecognitionResumed"));
|
||||
|
||||
}
|
||||
@@ -1377,7 +1378,7 @@ public class SoundTriggerService extends SystemService {
|
||||
public void onServiceConnected(ComponentName name, IBinder service) {
|
||||
if (DEBUG) Slog.v(TAG, mPuuid + ": onServiceConnected(" + service + ")");
|
||||
|
||||
sEventLogger.log(new SoundTriggerLogger.StringEvent(mPuuid
|
||||
sEventLogger.enqueue(new EventLogger.StringEvent(mPuuid
|
||||
+ ": onServiceConnected(" + service + ")"));
|
||||
|
||||
synchronized (mRemoteServiceLock) {
|
||||
@@ -1400,7 +1401,7 @@ public class SoundTriggerService extends SystemService {
|
||||
public void onServiceDisconnected(ComponentName name) {
|
||||
if (DEBUG) Slog.v(TAG, mPuuid + ": onServiceDisconnected");
|
||||
|
||||
sEventLogger.log(new SoundTriggerLogger.StringEvent(mPuuid
|
||||
sEventLogger.enqueue(new EventLogger.StringEvent(mPuuid
|
||||
+ ": onServiceDisconnected"));
|
||||
|
||||
synchronized (mRemoteServiceLock) {
|
||||
@@ -1412,7 +1413,7 @@ public class SoundTriggerService extends SystemService {
|
||||
public void onBindingDied(ComponentName name) {
|
||||
if (DEBUG) Slog.v(TAG, mPuuid + ": onBindingDied");
|
||||
|
||||
sEventLogger.log(new SoundTriggerLogger.StringEvent(mPuuid
|
||||
sEventLogger.enqueue(new EventLogger.StringEvent(mPuuid
|
||||
+ ": onBindingDied"));
|
||||
|
||||
synchronized (mRemoteServiceLock) {
|
||||
@@ -1424,7 +1425,7 @@ public class SoundTriggerService extends SystemService {
|
||||
public void onNullBinding(ComponentName name) {
|
||||
Slog.w(TAG, name + " for model " + mPuuid + " returned a null binding");
|
||||
|
||||
sEventLogger.log(new SoundTriggerLogger.StringEvent(name + " for model "
|
||||
sEventLogger.enqueue(new EventLogger.StringEvent(name + " for model "
|
||||
+ mPuuid + " returned a null binding"));
|
||||
|
||||
synchronized (mRemoteServiceLock) {
|
||||
@@ -1610,7 +1611,7 @@ public class SoundTriggerService extends SystemService {
|
||||
|
||||
private void clientDied() {
|
||||
Slog.w(TAG, "Client died, cleaning up session.");
|
||||
sEventLogger.log(new SoundTriggerLogger.StringEvent(
|
||||
sEventLogger.enqueue(new EventLogger.StringEvent(
|
||||
"Client died, cleaning up session."));
|
||||
mSoundTriggerHelper.detach();
|
||||
}
|
||||
@@ -1637,7 +1638,7 @@ public class SoundTriggerService extends SystemService {
|
||||
//=================================================================
|
||||
// For logging
|
||||
|
||||
private static final SoundTriggerLogger sEventLogger = new SoundTriggerLogger(200,
|
||||
private static final EventLogger sEventLogger = new EventLogger(200,
|
||||
"SoundTrigger activity");
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user