VoiceInteractorpublic class VoiceInteractor extends Object
Fields Summary |
---|
static final String | TAG | static final boolean | DEBUG | final com.android.internal.app.IVoiceInteractor | mInteractor | android.content.Context | mContext | Activity | mActivity | final com.android.internal.os.HandlerCaller | mHandlerCaller | final HandlerCaller.Callback | mHandlerCallerCallback | final IVoiceInteractorCallback.Stub | mCallback | final android.util.ArrayMap | mActiveRequests | static final int | MSG_CONFIRMATION_RESULT | static final int | MSG_COMPLETE_VOICE_RESULT | static final int | MSG_ABORT_VOICE_RESULT | static final int | MSG_COMMAND_RESULT | static final int | MSG_CANCEL_RESULT |
Methods Summary |
---|
void | attachActivity(Activity activity)
if (mActivity == activity) {
return;
}
mContext = activity;
mActivity = activity;
ArrayList<Request> reqs = makeRequestList();
if (reqs != null) {
for (int i=0; i<reqs.size(); i++) {
Request req = reqs.get(i);
req.mContext = activity;
req.mActivity = activity;
req.onAttached(activity);
}
}
| void | detachActivity()
ArrayList<Request> reqs = makeRequestList();
if (reqs != null) {
for (int i=0; i<reqs.size(); i++) {
Request req = reqs.get(i);
req.onDetached();
req.mActivity = null;
req.mContext = null;
}
}
mContext = null;
mActivity = null;
| private java.util.ArrayList | makeRequestList()
final int N = mActiveRequests.size();
if (N < 1) {
return null;
}
ArrayList<Request> list = new ArrayList<Request>(N);
for (int i=0; i<N; i++) {
list.add(mActiveRequests.valueAt(i));
}
return list;
| android.app.VoiceInteractor$Request | pullRequest(com.android.internal.app.IVoiceInteractorRequest request, boolean complete)
synchronized (mActiveRequests) {
Request req = mActiveRequests.get(request.asBinder());
if (req != null && complete) {
mActiveRequests.remove(request.asBinder());
}
return req;
}
| public boolean | submitRequest(android.app.VoiceInteractor$Request request)
try {
IVoiceInteractorRequest ireq = request.submit(mInteractor,
mContext.getOpPackageName(), mCallback);
request.mRequestInterface = ireq;
request.mContext = mContext;
request.mActivity = mActivity;
synchronized (mActiveRequests) {
mActiveRequests.put(ireq.asBinder(), request);
}
return true;
} catch (RemoteException e) {
Log.w(TAG, "Remove voice interactor service died", e);
return false;
}
| public boolean[] | supportsCommands(java.lang.String[] commands)Queries the supported commands available from the VoiceinteractionService.
The command is a string that describes the generic operation to be performed.
An example might be "com.google.voice.commands.REQUEST_NUMBER_BAGS" to request the number
of bags as part of airline check-in. (This is not an actual working example.)
try {
boolean[] res = mInteractor.supportsCommands(mContext.getOpPackageName(), commands);
if (DEBUG) Log.d(TAG, "supportsCommands: cmds=" + commands + " res=" + res);
return res;
} catch (RemoteException e) {
throw new RuntimeException("Voice interactor has died", e);
}
|
|