Merge "VoiceInteraction: Handle session delivery failure." into sc-dev am: f32842575b
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13432082 MUST ONLY BE SUBMITTED BY AUTOMERGER Change-Id: I283d99fad6a3ff17a919eabc9b091013a814f9d1
This commit is contained in:
@@ -18,8 +18,6 @@ package android.service.voice;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import android.service.voice.IVoiceInteractionSession;
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
|
||||
@@ -21,11 +21,14 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Configuration;
|
||||
import android.os.Bundle;
|
||||
import android.os.DeadObjectException;
|
||||
import android.os.IBinder;
|
||||
import android.os.Looper;
|
||||
import android.os.Message;
|
||||
import android.os.RemoteException;
|
||||
import android.os.ServiceManager;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.internal.app.IVoiceInteractionManagerService;
|
||||
import com.android.internal.os.HandlerCaller;
|
||||
import com.android.internal.os.SomeArgs;
|
||||
@@ -38,6 +41,8 @@ import java.io.PrintWriter;
|
||||
*/
|
||||
public abstract class VoiceInteractionSessionService extends Service {
|
||||
|
||||
private static final String TAG = "VoiceInteractionSession";
|
||||
|
||||
static final int MSG_NEW_SESSION = 1;
|
||||
|
||||
IVoiceInteractionManagerService mSystemService;
|
||||
@@ -120,10 +125,22 @@ public abstract class VoiceInteractionSessionService extends Service {
|
||||
mSession = null;
|
||||
}
|
||||
mSession = onNewSession(args);
|
||||
try {
|
||||
mSystemService.deliverNewSession(token, mSession.mSession, mSession.mInteractor);
|
||||
if (deliverSession(token)) {
|
||||
mSession.doCreate(mSystemService, token);
|
||||
} catch (RemoteException e) {
|
||||
} else {
|
||||
// TODO(b/178777121): Add an onError() method to let the application know what happened.
|
||||
mSession.doDestroy();
|
||||
mSession = null;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean deliverSession(IBinder token) {
|
||||
try {
|
||||
return mSystemService.deliverNewSession(token, mSession.mSession, mSession.mInteractor);
|
||||
} catch (DeadObjectException ignored) {
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Failed to deliver session: " + e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user