Merge "VoiceInteraction: Handle session delivery failure." into sc-dev
This commit is contained in:
@@ -18,8 +18,6 @@ package android.service.voice;
|
|||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
||||||
import android.service.voice.IVoiceInteractionSession;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -21,11 +21,14 @@ import android.content.Context;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.DeadObjectException;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.os.ServiceManager;
|
import android.os.ServiceManager;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import com.android.internal.app.IVoiceInteractionManagerService;
|
import com.android.internal.app.IVoiceInteractionManagerService;
|
||||||
import com.android.internal.os.HandlerCaller;
|
import com.android.internal.os.HandlerCaller;
|
||||||
import com.android.internal.os.SomeArgs;
|
import com.android.internal.os.SomeArgs;
|
||||||
@@ -38,6 +41,8 @@ import java.io.PrintWriter;
|
|||||||
*/
|
*/
|
||||||
public abstract class VoiceInteractionSessionService extends Service {
|
public abstract class VoiceInteractionSessionService extends Service {
|
||||||
|
|
||||||
|
private static final String TAG = "VoiceInteractionSession";
|
||||||
|
|
||||||
static final int MSG_NEW_SESSION = 1;
|
static final int MSG_NEW_SESSION = 1;
|
||||||
|
|
||||||
IVoiceInteractionManagerService mSystemService;
|
IVoiceInteractionManagerService mSystemService;
|
||||||
@@ -120,10 +125,22 @@ public abstract class VoiceInteractionSessionService extends Service {
|
|||||||
mSession = null;
|
mSession = null;
|
||||||
}
|
}
|
||||||
mSession = onNewSession(args);
|
mSession = onNewSession(args);
|
||||||
try {
|
if (deliverSession(token)) {
|
||||||
mSystemService.deliverNewSession(token, mSession.mSession, mSession.mInteractor);
|
|
||||||
mSession.doCreate(mSystemService, 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