Merge "Reset HotwordDetectionConnection when VoiceInteractionService crashes" into sc-dev

This commit is contained in:
TreeHugger Robot
2021-07-17 01:40:25 +00:00
committed by Android (Google) Code Review

View File

@@ -126,6 +126,9 @@ class VoiceInteractionManagerServiceImpl implements VoiceInteractionSessionConne
final ServiceConnection mConnection = new ServiceConnection() { final ServiceConnection mConnection = new ServiceConnection() {
@Override @Override
public void onServiceConnected(ComponentName name, IBinder service) { public void onServiceConnected(ComponentName name, IBinder service) {
if (DEBUG) {
Slog.d(TAG, "onServiceConnected to " + name + " for user(" + mUser + ")");
}
synchronized (mServiceStub) { synchronized (mServiceStub) {
mService = IVoiceInteractionService.Stub.asInterface(service); mService = IVoiceInteractionService.Stub.asInterface(service);
try { try {
@@ -137,7 +140,13 @@ class VoiceInteractionManagerServiceImpl implements VoiceInteractionSessionConne
@Override @Override
public void onServiceDisconnected(ComponentName name) { public void onServiceDisconnected(ComponentName name) {
if (DEBUG) {
Slog.d(TAG, "onServiceDisconnected to " + name);
}
synchronized (mServiceStub) {
mService = null; mService = null;
resetHotwordDetectionConnectionLocked();
}
} }
}; };
@@ -575,6 +584,20 @@ class VoiceInteractionManagerServiceImpl implements VoiceInteractionSessionConne
mHotwordDetectionConnection.forceRestart(); mHotwordDetectionConnection.forceRestart();
} }
void resetHotwordDetectionConnectionLocked() {
if (DEBUG) {
Slog.d(TAG, "resetHotwordDetectionConnectionLocked");
}
if (mHotwordDetectionConnection == null) {
if (DEBUG) {
Slog.w(TAG, "reset, but no hotword detection connection");
}
return;
}
mHotwordDetectionConnection.cancelLocked();
mHotwordDetectionConnection = null;
}
public void dumpLocked(FileDescriptor fd, PrintWriter pw, String[] args) { public void dumpLocked(FileDescriptor fd, PrintWriter pw, String[] args) {
if (!mValid) { if (!mValid) {
pw.print(" NOT VALID: "); pw.print(" NOT VALID: ");