Change SoundTriggerMiddleware to log to Slog
Clean up places where we still incorrectly log to the main logcat, instead of the system one. Test: Compiles Bug: 286573268 Change-Id: I89cff5a157e13b885108c622c450a2feae48e737
This commit is contained in:
@@ -22,7 +22,7 @@ import android.os.HwBinder;
|
||||
import android.os.RemoteException;
|
||||
import android.os.ServiceManager;
|
||||
import android.os.SystemProperties;
|
||||
import android.util.Log;
|
||||
import android.util.Slog;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -62,7 +62,7 @@ class DefaultHalFactory implements HalFactory {
|
||||
android.hardware.soundtrigger3.ISoundTriggerHw.class.getCanonicalName()
|
||||
+ "/default";
|
||||
if (ServiceManager.isDeclared(aidlServiceName)) {
|
||||
Log.i(TAG, "Connecting to default soundtrigger3.ISoundTriggerHw");
|
||||
Slog.i(TAG, "Connecting to default soundtrigger3.ISoundTriggerHw");
|
||||
return new SoundTriggerHw3Compat(ServiceManager.waitForService(aidlServiceName),
|
||||
() -> {
|
||||
// This property needs to be defined in an init.rc script and
|
||||
@@ -72,7 +72,7 @@ class DefaultHalFactory implements HalFactory {
|
||||
}
|
||||
|
||||
// Fallback to soundtrigger-V2.x (HIDL).
|
||||
Log.i(TAG, "Connecting to default soundtrigger-V2.x.ISoundTriggerHw");
|
||||
Slog.i(TAG, "Connecting to default soundtrigger-V2.x.ISoundTriggerHw");
|
||||
ISoundTriggerHw driver = ISoundTriggerHw.getService(true);
|
||||
return SoundTriggerHw2Compat.create(driver, () -> {
|
||||
// This property needs to be defined in an init.rc script and
|
||||
@@ -81,7 +81,7 @@ class DefaultHalFactory implements HalFactory {
|
||||
}, mCaptureStateNotifier);
|
||||
} else if (mockHal == USE_MOCK_HAL_V2) {
|
||||
// Use V2 mock.
|
||||
Log.i(TAG, "Connecting to mock soundtrigger-V2.x.ISoundTriggerHw");
|
||||
Slog.i(TAG, "Connecting to mock soundtrigger-V2.x.ISoundTriggerHw");
|
||||
HwBinder.setTrebleTestingOverride(true);
|
||||
try {
|
||||
ISoundTriggerHw driver = ISoundTriggerHw.getService("mock", true);
|
||||
@@ -89,7 +89,7 @@ class DefaultHalFactory implements HalFactory {
|
||||
try {
|
||||
driver.debug(null, new ArrayList<>(Arrays.asList("reboot")));
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Failed to reboot mock HAL", e);
|
||||
Slog.e(TAG, "Failed to reboot mock HAL", e);
|
||||
}
|
||||
}, mCaptureStateNotifier);
|
||||
} finally {
|
||||
@@ -100,14 +100,14 @@ class DefaultHalFactory implements HalFactory {
|
||||
final String aidlServiceName =
|
||||
android.hardware.soundtrigger3.ISoundTriggerHw.class.getCanonicalName()
|
||||
+ "/mock";
|
||||
Log.i(TAG, "Connecting to mock soundtrigger3.ISoundTriggerHw");
|
||||
Slog.i(TAG, "Connecting to mock soundtrigger3.ISoundTriggerHw");
|
||||
return new SoundTriggerHw3Compat(ServiceManager.waitForService(aidlServiceName),
|
||||
() -> {
|
||||
try {
|
||||
ServiceManager.waitForService(aidlServiceName).shellCommand(null,
|
||||
null, null, new String[]{"reboot"}, null, null);
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Failed to reboot mock HAL", e);
|
||||
Slog.e(TAG, "Failed to reboot mock HAL", e);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
package com.android.server.soundtrigger_middleware;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.util.Log;
|
||||
import android.util.Slog;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
@@ -94,7 +94,7 @@ class ExternalCaptureStateTracker implements ICaptureStateNotifier {
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Exception caught while setting capture state", e);
|
||||
Slog.e(TAG, "Exception caught while setting capture state", e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ class ExternalCaptureStateTracker implements ICaptureStateNotifier {
|
||||
* Called by native code when the remote service died.
|
||||
*/
|
||||
private void binderDied() {
|
||||
Log.w(TAG, "Audio policy service died");
|
||||
Slog.w(TAG, "Audio policy service died");
|
||||
mNeedToConnect.release();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ import android.media.soundtrigger_middleware.PhraseRecognitionEventSys;
|
||||
import android.media.soundtrigger_middleware.RecognitionEventSys;
|
||||
import android.os.DeadObjectException;
|
||||
import android.os.IBinder;
|
||||
import android.util.Log;
|
||||
import android.util.Slog;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -227,10 +227,10 @@ public class SoundTriggerHalEnforcer implements ISoundTriggerHal {
|
||||
}
|
||||
if (e.getCause() instanceof DeadObjectException) {
|
||||
// Server is dead, no need to reboot.
|
||||
Log.e(TAG, "HAL died");
|
||||
Slog.e(TAG, "HAL died");
|
||||
throw new RecoverableException(Status.DEAD_OBJECT);
|
||||
}
|
||||
Log.e(TAG, "Exception caught from HAL, rebooting HAL");
|
||||
Slog.e(TAG, "Exception caught from HAL, rebooting HAL");
|
||||
reboot();
|
||||
throw e;
|
||||
}
|
||||
@@ -257,14 +257,14 @@ public class SoundTriggerHalEnforcer implements ISoundTriggerHal {
|
||||
synchronized (mModelStates) {
|
||||
ModelState state = mModelStates.get(model);
|
||||
if (state == null) {
|
||||
Log.wtfStack(TAG, "Unexpected recognition event for model: " + model);
|
||||
Slog.wtfStack(TAG, "Unexpected recognition event for model: " + model);
|
||||
reboot();
|
||||
return;
|
||||
}
|
||||
if (event.recognitionEvent.recognitionStillActive
|
||||
&& event.recognitionEvent.status != RecognitionStatus.SUCCESS
|
||||
&& event.recognitionEvent.status != RecognitionStatus.FORCED) {
|
||||
Log.wtfStack(TAG,
|
||||
Slog.wtfStack(TAG,
|
||||
"recognitionStillActive is only allowed when the recognition status "
|
||||
+ "is SUCCESS");
|
||||
reboot();
|
||||
@@ -283,14 +283,14 @@ public class SoundTriggerHalEnforcer implements ISoundTriggerHal {
|
||||
synchronized (mModelStates) {
|
||||
ModelState state = mModelStates.get(model);
|
||||
if (state == null) {
|
||||
Log.wtfStack(TAG, "Unexpected recognition event for model: " + model);
|
||||
Slog.wtfStack(TAG, "Unexpected recognition event for model: " + model);
|
||||
reboot();
|
||||
return;
|
||||
}
|
||||
if (event.phraseRecognitionEvent.common.recognitionStillActive
|
||||
&& event.phraseRecognitionEvent.common.status != RecognitionStatus.SUCCESS
|
||||
&& event.phraseRecognitionEvent.common.status != RecognitionStatus.FORCED) {
|
||||
Log.wtfStack(TAG,
|
||||
Slog.wtfStack(TAG,
|
||||
"recognitionStillActive is only allowed when the recognition status "
|
||||
+ "is SUCCESS");
|
||||
reboot();
|
||||
@@ -309,13 +309,13 @@ public class SoundTriggerHalEnforcer implements ISoundTriggerHal {
|
||||
synchronized (mModelStates) {
|
||||
ModelState state = mModelStates.get(modelHandle);
|
||||
if (state == null) {
|
||||
Log.wtfStack(TAG, "Unexpected unload event for model: " + modelHandle);
|
||||
Slog.wtfStack(TAG, "Unexpected unload event for model: " + modelHandle);
|
||||
reboot();
|
||||
return;
|
||||
}
|
||||
|
||||
if (state == ModelState.ACTIVE) {
|
||||
Log.wtfStack(TAG, "Trying to unload an active model: " + modelHandle);
|
||||
Slog.wtfStack(TAG, "Trying to unload an active model: " + modelHandle);
|
||||
reboot();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ import android.media.soundtrigger.Properties;
|
||||
import android.media.soundtrigger.RecognitionConfig;
|
||||
import android.media.soundtrigger.SoundModel;
|
||||
import android.os.IBinder;
|
||||
import android.util.Log;
|
||||
import android.util.Slog;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -172,7 +172,7 @@ public class SoundTriggerHalWatchdog implements ISoundTriggerHal {
|
||||
|
||||
Watchdog() {
|
||||
mTask = mTimer.createTask(() -> {
|
||||
Log.e(TAG, "HAL deadline expired. Rebooting.", mException);
|
||||
Slog.e(TAG, "HAL deadline expired. Rebooting.", mException);
|
||||
reboot();
|
||||
}, TIMEOUT_MS);
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ import android.os.IHwBinder;
|
||||
import android.os.RemoteException;
|
||||
import android.os.SystemClock;
|
||||
import android.system.OsConstants;
|
||||
import android.util.Log;
|
||||
import android.util.Slog;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
@@ -240,7 +240,7 @@ final class SoundTriggerHw2Compat implements ISoundTriggerHal {
|
||||
try {
|
||||
hidlModel.data.close();
|
||||
} catch (IOException e) {
|
||||
Log.e(TAG, "Failed to close file", e);
|
||||
Slog.e(TAG, "Failed to close file", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -276,7 +276,7 @@ final class SoundTriggerHw2Compat implements ISoundTriggerHal {
|
||||
try {
|
||||
hidlModel.common.data.close();
|
||||
} catch (IOException e) {
|
||||
Log.e(TAG, "Failed to close file", e);
|
||||
Slog.e(TAG, "Failed to close file", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ import android.annotation.NonNull;
|
||||
import android.media.soundtrigger_middleware.ISoundTriggerCallback;
|
||||
import android.media.soundtrigger_middleware.ISoundTriggerModule;
|
||||
import android.media.soundtrigger_middleware.SoundTriggerModuleDescriptor;
|
||||
import android.util.Log;
|
||||
import android.util.Slog;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -85,7 +85,7 @@ public class SoundTriggerMiddlewareImpl implements ISoundTriggerMiddlewareIntern
|
||||
try {
|
||||
modules.add(new SoundTriggerModule(halFactory, audioSessionProvider));
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Failed to add a SoundTriggerModule instance", e);
|
||||
Slog.e(TAG, "Failed to add a SoundTriggerModule instance", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ import android.media.soundtrigger_middleware.SoundTriggerModuleDescriptor;
|
||||
import android.os.IBinder;
|
||||
import android.os.RemoteException;
|
||||
import android.os.ServiceSpecificException;
|
||||
import android.util.Log;
|
||||
import android.util.Slog;
|
||||
import android.util.SparseArray;
|
||||
|
||||
import com.android.internal.util.Preconditions;
|
||||
@@ -150,7 +150,7 @@ public class SoundTriggerMiddlewareValidation implements ISoundTriggerMiddleware
|
||||
e.getMessage());
|
||||
}
|
||||
|
||||
Log.wtf(TAG, "Unexpected exception", e);
|
||||
Slog.wtf(TAG, "Unexpected exception", e);
|
||||
throw new ServiceSpecificException(Status.INTERNAL_ERROR, e.getMessage());
|
||||
}
|
||||
|
||||
@@ -701,7 +701,7 @@ public class SoundTriggerMiddlewareValidation implements ISoundTriggerMiddleware
|
||||
try {
|
||||
mCallback.onRecognition(modelHandle, event, captureSession);
|
||||
} catch (Exception e) {
|
||||
Log.w(TAG, "Client callback exception.", e);
|
||||
Slog.w(TAG, "Client callback exception.", e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -719,7 +719,7 @@ public class SoundTriggerMiddlewareValidation implements ISoundTriggerMiddleware
|
||||
try {
|
||||
mCallback.onPhraseRecognition(modelHandle, event, captureSession);
|
||||
} catch (Exception e) {
|
||||
Log.w(TAG, "Client callback exception.", e);
|
||||
Slog.w(TAG, "Client callback exception.", e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -734,7 +734,7 @@ public class SoundTriggerMiddlewareValidation implements ISoundTriggerMiddleware
|
||||
try {
|
||||
mCallback.onModelUnloaded(modelHandle);
|
||||
} catch (Exception e) {
|
||||
Log.w(TAG, "Client callback exception.", e);
|
||||
Slog.w(TAG, "Client callback exception.", e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -746,7 +746,7 @@ public class SoundTriggerMiddlewareValidation implements ISoundTriggerMiddleware
|
||||
} catch (RemoteException e) {
|
||||
// Dead client will be handled by binderDied() - no need to handle here.
|
||||
// In any case, client callbacks are considered best effort.
|
||||
Log.e(TAG, "Client callback exception.", e);
|
||||
Slog.e(TAG, "Client callback exception.", e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -761,7 +761,7 @@ public class SoundTriggerMiddlewareValidation implements ISoundTriggerMiddleware
|
||||
} catch (RemoteException e) {
|
||||
// Dead client will be handled by binderDied() - no need to handle here.
|
||||
// In any case, client callbacks are considered best effort.
|
||||
Log.e(TAG, "Client callback exception.", e);
|
||||
Slog.e(TAG, "Client callback exception.", e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -795,11 +795,11 @@ public class SoundTriggerMiddlewareValidation implements ISoundTriggerMiddleware
|
||||
// Check if state updated unexpectedly to log race conditions.
|
||||
for (Map.Entry<Integer, ModelState> entry : mLoadedModels.entrySet()) {
|
||||
if (cachedMap.get(entry.getKey()) != entry.getValue().activityState) {
|
||||
Log.e(TAG, "Unexpected state update in binderDied. Race occurred!");
|
||||
Slog.e(TAG, "Unexpected state update in binderDied. Race occurred!");
|
||||
}
|
||||
}
|
||||
if (mLoadedModels.size() != cachedMap.size()) {
|
||||
Log.e(TAG, "Unexpected state update in binderDied. Race occurred!");
|
||||
Slog.e(TAG, "Unexpected state update in binderDied. Race occurred!");
|
||||
}
|
||||
try {
|
||||
// Detach
|
||||
|
||||
@@ -31,7 +31,7 @@ import android.media.soundtrigger_middleware.RecognitionEventSys;
|
||||
import android.os.Binder;
|
||||
import android.os.IBinder;
|
||||
import android.os.RemoteException;
|
||||
import android.util.Log;
|
||||
import android.util.Slog;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@@ -136,7 +136,7 @@ class SoundTriggerModule implements IBinder.DeathRecipient, ISoundTriggerHal.Glo
|
||||
|
||||
@Override
|
||||
public void binderDied() {
|
||||
Log.w(TAG, "Underlying HAL driver died.");
|
||||
Slog.w(TAG, "Underlying HAL driver died.");
|
||||
List<ISoundTriggerCallback> callbacks;
|
||||
synchronized (this) {
|
||||
callbacks = new ArrayList<>(mActiveSessions.size());
|
||||
@@ -270,7 +270,7 @@ class SoundTriggerModule implements IBinder.DeathRecipient, ISoundTriggerHal.Glo
|
||||
try {
|
||||
mAudioSessionProvider.releaseSession(audioSession.mSessionHandle);
|
||||
} catch (Exception ee) {
|
||||
Log.e(TAG, "Failed to release session.", ee);
|
||||
Slog.e(TAG, "Failed to release session.", ee);
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
@@ -286,7 +286,7 @@ class SoundTriggerModule implements IBinder.DeathRecipient, ISoundTriggerHal.Glo
|
||||
checkValid();
|
||||
Model loadedModel = new Model();
|
||||
int result = loadedModel.load(model, audioSession);
|
||||
Log.d(TAG, String.format("loadPhraseModel()->%d", result));
|
||||
Slog.d(TAG, String.format("loadPhraseModel()->%d", result));
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
// We must do this outside the lock, to avoid possible deadlocks with the remote
|
||||
@@ -294,7 +294,7 @@ class SoundTriggerModule implements IBinder.DeathRecipient, ISoundTriggerHal.Glo
|
||||
try {
|
||||
mAudioSessionProvider.releaseSession(audioSession.mSessionHandle);
|
||||
} catch (Exception ee) {
|
||||
Log.e(TAG, "Failed to release session.", ee);
|
||||
Slog.e(TAG, "Failed to release session.", ee);
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user