Merge "Fix issue #22124996: VI: Command Request not Active" into mnc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
80abf887a1
@@ -5805,7 +5805,7 @@ package android.app.admin {
|
|||||||
|
|
||||||
package android.app.assist {
|
package android.app.assist {
|
||||||
|
|
||||||
public deprecated class AssistContent implements android.os.Parcelable {
|
public class AssistContent implements android.os.Parcelable {
|
||||||
ctor public AssistContent();
|
ctor public AssistContent();
|
||||||
method public int describeContents();
|
method public int describeContents();
|
||||||
method public android.content.ClipData getClipData();
|
method public android.content.ClipData getClipData();
|
||||||
|
|||||||
@@ -5937,7 +5937,7 @@ package android.app.admin {
|
|||||||
|
|
||||||
package android.app.assist {
|
package android.app.assist {
|
||||||
|
|
||||||
public deprecated class AssistContent implements android.os.Parcelable {
|
public class AssistContent implements android.os.Parcelable {
|
||||||
ctor public AssistContent();
|
ctor public AssistContent();
|
||||||
method public int describeContents();
|
method public int describeContents();
|
||||||
method public android.content.ClipData getClipData();
|
method public android.content.ClipData getClipData();
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ import android.os.Parcelable;
|
|||||||
* assistant at the user's request. This is filled in by
|
* assistant at the user's request. This is filled in by
|
||||||
* {@link android.app.Activity#onProvideAssistContent Activity.onProvideAssistContent}.
|
* {@link android.app.Activity#onProvideAssistContent Activity.onProvideAssistContent}.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
|
||||||
public class AssistContent implements Parcelable {
|
public class AssistContent implements Parcelable {
|
||||||
private boolean mIsAppProvidedIntent = false;
|
private boolean mIsAppProvidedIntent = false;
|
||||||
private Intent mIntent;
|
private Intent mIntent;
|
||||||
|
|||||||
@@ -172,15 +172,6 @@ public class VoiceInteractionService extends Service {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @hide */
|
|
||||||
public void startSession(Bundle args, int flags) {
|
|
||||||
showSession(args, flags);
|
|
||||||
}
|
|
||||||
/** @hide */
|
|
||||||
public void startSession(Bundle args) {
|
|
||||||
startSession(args, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
|
|||||||
*/
|
*/
|
||||||
public class VoiceInteractionSession implements KeyEvent.Callback, ComponentCallbacks2 {
|
public class VoiceInteractionSession implements KeyEvent.Callback, ComponentCallbacks2 {
|
||||||
static final String TAG = "VoiceInteractionSession";
|
static final String TAG = "VoiceInteractionSession";
|
||||||
static final boolean DEBUG = true;
|
static final boolean DEBUG = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flag received in {@link #onShow}: originator requested that the session be started with
|
* Flag received in {@link #onShow}: originator requested that the session be started with
|
||||||
@@ -175,6 +175,7 @@ public class VoiceInteractionSession implements KeyEvent.Callback, ComponentCall
|
|||||||
CommandRequest request = new CommandRequest(callingPackage,
|
CommandRequest request = new CommandRequest(callingPackage,
|
||||||
Binder.getCallingUid(), callback, VoiceInteractionSession.this,
|
Binder.getCallingUid(), callback, VoiceInteractionSession.this,
|
||||||
command, extras);
|
command, extras);
|
||||||
|
addRequest(request);
|
||||||
mHandlerCaller.sendMessage(mHandlerCaller.obtainMessageO(MSG_START_COMMAND,
|
mHandlerCaller.sendMessage(mHandlerCaller.obtainMessageO(MSG_START_COMMAND,
|
||||||
request));
|
request));
|
||||||
return request.mInterface;
|
return request.mInterface;
|
||||||
@@ -249,16 +250,12 @@ public class VoiceInteractionSession implements KeyEvent.Callback, ComponentCall
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** @hide */
|
|
||||||
public static class Caller {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class representing a request from a voice-driver app to perform a particular
|
* Base class representing a request from a voice-driver app to perform a particular
|
||||||
* voice operation with the user. See related subclasses for the types of requests
|
* voice operation with the user. See related subclasses for the types of requests
|
||||||
* that are possible.
|
* that are possible.
|
||||||
*/
|
*/
|
||||||
public static class Request extends Caller {
|
public static class Request {
|
||||||
final IVoiceInteractorRequest mInterface = new IVoiceInteractorRequest.Stub() {
|
final IVoiceInteractorRequest mInterface = new IVoiceInteractorRequest.Stub() {
|
||||||
@Override
|
@Override
|
||||||
public void cancel() throws RemoteException {
|
public void cancel() throws RemoteException {
|
||||||
@@ -319,74 +316,8 @@ public class VoiceInteractionSession implements KeyEvent.Callback, ComponentCall
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @hide */
|
|
||||||
public void sendConfirmResult(boolean confirmed, Bundle result) {
|
|
||||||
try {
|
|
||||||
if (DEBUG) Log.d(TAG, "sendConfirmResult: req=" + mInterface
|
|
||||||
+ " confirmed=" + confirmed + " result=" + result);
|
|
||||||
finishRequest();
|
|
||||||
mCallback.deliverConfirmationResult(mInterface, confirmed, result);
|
|
||||||
} catch (RemoteException e) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @hide */
|
|
||||||
public void sendPickOptionResult(boolean finished,
|
|
||||||
VoiceInteractor.PickOptionRequest.Option[] selections, Bundle result) {
|
|
||||||
try {
|
|
||||||
if (DEBUG) Log.d(TAG, "sendPickOptionResult: req=" + mInterface
|
|
||||||
+ " finished=" + finished + " selections=" + selections
|
|
||||||
+ " result=" + result);
|
|
||||||
if (finished) {
|
|
||||||
finishRequest();
|
|
||||||
}
|
|
||||||
mCallback.deliverPickOptionResult(mInterface, finished, selections, result);
|
|
||||||
} catch (RemoteException e) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @hide */
|
|
||||||
public void sendCompleteVoiceResult(Bundle result) {
|
|
||||||
try {
|
|
||||||
if (DEBUG) Log.d(TAG, "sendCompleteVoiceResult: req=" + mInterface
|
|
||||||
+ " result=" + result);
|
|
||||||
finishRequest();
|
|
||||||
mCallback.deliverCompleteVoiceResult(mInterface, result);
|
|
||||||
} catch (RemoteException e) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @hide */
|
|
||||||
public void sendAbortVoiceResult(Bundle result) {
|
|
||||||
try {
|
|
||||||
if (DEBUG) Log.d(TAG, "sendConfirmResult: req=" + mInterface
|
|
||||||
+ " result=" + result);
|
|
||||||
finishRequest();
|
|
||||||
mCallback.deliverAbortVoiceResult(mInterface, result);
|
|
||||||
} catch (RemoteException e) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @hide */
|
|
||||||
public void sendCommandResult(boolean finished, Bundle result) {
|
|
||||||
try {
|
|
||||||
if (DEBUG) Log.d(TAG, "sendCommandResult: req=" + mInterface
|
|
||||||
+ " result=" + result);
|
|
||||||
if (finished) {
|
|
||||||
finishRequest();
|
|
||||||
}
|
|
||||||
mCallback.deliverCommandResult(mInterface, finished, result);
|
|
||||||
} catch (RemoteException e) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @hide */
|
|
||||||
public void sendCancelResult() {
|
|
||||||
cancel();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ASk the app to cancelLocked this current request.
|
* Ask the app to cancel this current request.
|
||||||
*/
|
*/
|
||||||
public void cancel() {
|
public void cancel() {
|
||||||
try {
|
try {
|
||||||
@@ -440,7 +371,13 @@ public class VoiceInteractionSession implements KeyEvent.Callback, ComponentCall
|
|||||||
* VoiceInteractor.ConfirmationRequest.onConfirmationResult}.
|
* VoiceInteractor.ConfirmationRequest.onConfirmationResult}.
|
||||||
*/
|
*/
|
||||||
public void sendConfirmationResult(boolean confirmed, Bundle result) {
|
public void sendConfirmationResult(boolean confirmed, Bundle result) {
|
||||||
sendConfirmResult(confirmed, result);
|
try {
|
||||||
|
if (DEBUG) Log.d(TAG, "sendConfirmationResult: req=" + mInterface
|
||||||
|
+ " confirmed=" + confirmed + " result=" + result);
|
||||||
|
finishRequest();
|
||||||
|
mCallback.deliverConfirmationResult(mInterface, confirmed, result);
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -487,6 +424,20 @@ public class VoiceInteractionSession implements KeyEvent.Callback, ComponentCall
|
|||||||
return mOptions;
|
return mOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void sendPickOptionResult(boolean finished,
|
||||||
|
VoiceInteractor.PickOptionRequest.Option[] selections, Bundle result) {
|
||||||
|
try {
|
||||||
|
if (DEBUG) Log.d(TAG, "sendPickOptionResult: req=" + mInterface
|
||||||
|
+ " finished=" + finished + " selections=" + selections
|
||||||
|
+ " result=" + result);
|
||||||
|
if (finished) {
|
||||||
|
finishRequest();
|
||||||
|
}
|
||||||
|
mCallback.deliverPickOptionResult(mInterface, finished, selections, result);
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Report an intermediate option selection from the request, without completing it (the
|
* Report an intermediate option selection from the request, without completing it (the
|
||||||
* request is still active and the app is waiting for the final option selection),
|
* request is still active and the app is waiting for the final option selection),
|
||||||
@@ -553,7 +504,13 @@ public class VoiceInteractionSession implements KeyEvent.Callback, ComponentCall
|
|||||||
* VoiceInteractor.CompleteVoiceRequest.onCompleteResult}.
|
* VoiceInteractor.CompleteVoiceRequest.onCompleteResult}.
|
||||||
*/
|
*/
|
||||||
public void sendCompleteResult(Bundle result) {
|
public void sendCompleteResult(Bundle result) {
|
||||||
sendCompleteVoiceResult(result);
|
try {
|
||||||
|
if (DEBUG) Log.d(TAG, "sendCompleteVoiceResult: req=" + mInterface
|
||||||
|
+ " result=" + result);
|
||||||
|
finishRequest();
|
||||||
|
mCallback.deliverCompleteVoiceResult(mInterface, result);
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -596,7 +553,13 @@ public class VoiceInteractionSession implements KeyEvent.Callback, ComponentCall
|
|||||||
* VoiceInteractor.AbortVoiceRequest.onAbortResult}.
|
* VoiceInteractor.AbortVoiceRequest.onAbortResult}.
|
||||||
*/
|
*/
|
||||||
public void sendAbortResult(Bundle result) {
|
public void sendAbortResult(Bundle result) {
|
||||||
sendAbortVoiceResult(result);
|
try {
|
||||||
|
if (DEBUG) Log.d(TAG, "sendConfirmResult: req=" + mInterface
|
||||||
|
+ " result=" + result);
|
||||||
|
finishRequest();
|
||||||
|
mCallback.deliverAbortVoiceResult(mInterface, result);
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -621,6 +584,18 @@ public class VoiceInteractionSession implements KeyEvent.Callback, ComponentCall
|
|||||||
return mCommand;
|
return mCommand;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void sendCommandResult(boolean finished, Bundle result) {
|
||||||
|
try {
|
||||||
|
if (DEBUG) Log.d(TAG, "sendCommandResult: req=" + mInterface
|
||||||
|
+ " result=" + result);
|
||||||
|
if (finished) {
|
||||||
|
finishRequest();
|
||||||
|
}
|
||||||
|
mCallback.deliverCommandResult(mInterface, finished, result);
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Report an intermediate result of the request, without completing it (the request
|
* Report an intermediate result of the request, without completing it (the request
|
||||||
* is still active and the app is waiting for the final result), resulting in a call to
|
* is still active and the app is waiting for the final result), resulting in a call to
|
||||||
@@ -829,11 +804,10 @@ public class VoiceInteractionSession implements KeyEvent.Callback, ComponentCall
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void doCreate(IVoiceInteractionManagerService service, IBinder token, Bundle args,
|
void doCreate(IVoiceInteractionManagerService service, IBinder token) {
|
||||||
int startFlags) {
|
|
||||||
mSystemService = service;
|
mSystemService = service;
|
||||||
mToken = token;
|
mToken = token;
|
||||||
onCreate(args, startFlags);
|
onCreate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void doShow(Bundle args, int flags, final IVoiceInteractionSessionShowCallback showCallback) {
|
void doShow(Bundle args, int flags, final IVoiceInteractionSessionShowCallback showCallback) {
|
||||||
@@ -919,11 +893,6 @@ public class VoiceInteractionSession implements KeyEvent.Callback, ComponentCall
|
|||||||
mContentFrame = (FrameLayout)mRootView.findViewById(android.R.id.content);
|
mContentFrame = (FrameLayout)mRootView.findViewById(android.R.id.content);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @hide */
|
|
||||||
public void show() {
|
|
||||||
show(null, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show the UI for this session. This asks the system to go through the process of showing
|
* Show the UI for this session. This asks the system to go through the process of showing
|
||||||
* your UI, which will eventually culminate in {@link #onShow}. This is similar to calling
|
* your UI, which will eventually culminate in {@link #onShow}. This is similar to calling
|
||||||
@@ -958,14 +927,6 @@ public class VoiceInteractionSession implements KeyEvent.Callback, ComponentCall
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @hide */
|
|
||||||
public void showWindow() {
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @hide */
|
|
||||||
public void hideWindow() {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* You can call this to customize the theme used by your IME's window.
|
* You can call this to customize the theme used by your IME's window.
|
||||||
* This must be set before {@link #onCreate}, so you
|
* This must be set before {@link #onCreate}, so you
|
||||||
@@ -1062,7 +1023,6 @@ public class VoiceInteractionSession implements KeyEvent.Callback, ComponentCall
|
|||||||
if (mToken == null) {
|
if (mToken == null) {
|
||||||
throw new IllegalStateException("Can't call before onCreate()");
|
throw new IllegalStateException("Can't call before onCreate()");
|
||||||
}
|
}
|
||||||
hideWindow();
|
|
||||||
try {
|
try {
|
||||||
mSystemService.finish(mToken);
|
mSystemService.finish(mToken);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
@@ -1077,16 +1037,6 @@ public class VoiceInteractionSession implements KeyEvent.Callback, ComponentCall
|
|||||||
doOnCreate();
|
doOnCreate();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @hide */
|
|
||||||
public void onCreate(Bundle args) {
|
|
||||||
doOnCreate();
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @hide */
|
|
||||||
public void onCreate(Bundle args, int showFlags) {
|
|
||||||
doOnCreate();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void doOnCreate() {
|
private void doOnCreate() {
|
||||||
mTheme = mTheme != 0 ? mTheme
|
mTheme = mTheme != 0 ? mTheme
|
||||||
: com.android.internal.R.style.Theme_DeviceDefault_VoiceInteractionSession;
|
: com.android.internal.R.style.Theme_DeviceDefault_VoiceInteractionSession;
|
||||||
@@ -1244,34 +1194,6 @@ public class VoiceInteractionSession implements KeyEvent.Callback, ComponentCall
|
|||||||
hide();
|
hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @hide */
|
|
||||||
public boolean[] onGetSupportedCommands(Caller caller, String[] commands) {
|
|
||||||
return new boolean[commands.length];
|
|
||||||
}
|
|
||||||
/** @hide */
|
|
||||||
public void onConfirm(Caller caller, Request request, CharSequence prompt,
|
|
||||||
Bundle extras) {
|
|
||||||
}
|
|
||||||
/** @hide */
|
|
||||||
public void onPickOption(Caller caller, Request request, CharSequence prompt,
|
|
||||||
VoiceInteractor.PickOptionRequest.Option[] options, Bundle extras) {
|
|
||||||
}
|
|
||||||
/** @hide */
|
|
||||||
public void onCompleteVoice(Caller caller, Request request, CharSequence message,
|
|
||||||
Bundle extras) {
|
|
||||||
request.sendCompleteVoiceResult(null);
|
|
||||||
}
|
|
||||||
/** @hide */
|
|
||||||
public void onAbortVoice(Caller caller, Request request, CharSequence message, Bundle extras) {
|
|
||||||
request.sendAbortVoiceResult(null);
|
|
||||||
}
|
|
||||||
/** @hide */
|
|
||||||
public void onCommand(Caller caller, Request request, String command, Bundle extras) {
|
|
||||||
}
|
|
||||||
/** @hide */
|
|
||||||
public void onCancel(Request request) {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Request to query for what extended commands the session supports.
|
* Request to query for what extended commands the session supports.
|
||||||
*
|
*
|
||||||
@@ -1282,7 +1204,7 @@ public class VoiceInteractionSession implements KeyEvent.Callback, ComponentCall
|
|||||||
* an array of all false entries.
|
* an array of all false entries.
|
||||||
*/
|
*/
|
||||||
public boolean[] onGetSupportedCommands(String[] commands) {
|
public boolean[] onGetSupportedCommands(String[] commands) {
|
||||||
return onGetSupportedCommands(new Caller(), commands);
|
return new boolean[commands.length];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1293,7 +1215,6 @@ public class VoiceInteractionSession implements KeyEvent.Callback, ComponentCall
|
|||||||
* @param request The active request.
|
* @param request The active request.
|
||||||
*/
|
*/
|
||||||
public void onRequestConfirmation(ConfirmationRequest request) {
|
public void onRequestConfirmation(ConfirmationRequest request) {
|
||||||
onConfirm(request, request, request.getPrompt(), request.getExtras());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1303,8 +1224,6 @@ public class VoiceInteractionSession implements KeyEvent.Callback, ComponentCall
|
|||||||
* @param request The active request.
|
* @param request The active request.
|
||||||
*/
|
*/
|
||||||
public void onRequestPickOption(PickOptionRequest request) {
|
public void onRequestPickOption(PickOptionRequest request) {
|
||||||
onPickOption(request, request, request.getPrompt(), request.getOptions(),
|
|
||||||
request.getExtras());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1317,7 +1236,6 @@ public class VoiceInteractionSession implements KeyEvent.Callback, ComponentCall
|
|||||||
* @param request The active request.
|
* @param request The active request.
|
||||||
*/
|
*/
|
||||||
public void onRequestCompleteVoice(CompleteVoiceRequest request) {
|
public void onRequestCompleteVoice(CompleteVoiceRequest request) {
|
||||||
onCompleteVoice(request, request, request.getMessage(), request.getExtras());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1330,7 +1248,6 @@ public class VoiceInteractionSession implements KeyEvent.Callback, ComponentCall
|
|||||||
* @param request The active request.
|
* @param request The active request.
|
||||||
*/
|
*/
|
||||||
public void onRequestAbortVoice(AbortVoiceRequest request) {
|
public void onRequestAbortVoice(AbortVoiceRequest request) {
|
||||||
onAbortVoice(request, request, request.getMessage(), request.getExtras());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1341,11 +1258,10 @@ public class VoiceInteractionSession implements KeyEvent.Callback, ComponentCall
|
|||||||
* @param request The active request.
|
* @param request The active request.
|
||||||
*/
|
*/
|
||||||
public void onRequestCommand(CommandRequest request) {
|
public void onRequestCommand(CommandRequest request) {
|
||||||
onCommand(request, request, request.getCommand(), request.getExtras());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the {@link android.app.VoiceInteractor} has asked to cancelLocked a {@link Request}
|
* Called when the {@link android.app.VoiceInteractor} has asked to cancel a {@link Request}
|
||||||
* that was previously delivered to {@link #onRequestConfirmation},
|
* that was previously delivered to {@link #onRequestConfirmation},
|
||||||
* {@link #onRequestPickOption}, {@link #onRequestCompleteVoice}, {@link #onRequestAbortVoice},
|
* {@link #onRequestPickOption}, {@link #onRequestCompleteVoice}, {@link #onRequestAbortVoice},
|
||||||
* or {@link #onRequestCommand}.
|
* or {@link #onRequestCommand}.
|
||||||
@@ -1353,6 +1269,5 @@ public class VoiceInteractionSession implements KeyEvent.Callback, ComponentCall
|
|||||||
* @param request The request that is being canceled.
|
* @param request The request that is being canceled.
|
||||||
*/
|
*/
|
||||||
public void onCancelRequest(Request request) {
|
public void onCancelRequest(Request request) {
|
||||||
onCancel(request);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ public abstract class VoiceInteractionSessionService extends Service {
|
|||||||
mSession = onNewSession(args);
|
mSession = onNewSession(args);
|
||||||
try {
|
try {
|
||||||
mSystemService.deliverNewSession(token, mSession.mSession, mSession.mInteractor);
|
mSystemService.deliverNewSession(token, mSession.mSession, mSession.mInteractor);
|
||||||
mSession.doCreate(mSystemService, token, args, startFlags);
|
mSession.doCreate(mSystemService, token);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,28 +52,23 @@ public class AssistInteractionSession extends VoiceInteractionSession {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onConfirm(Caller caller,
|
public void onRequestConfirmation(ConfirmationRequest request) {
|
||||||
Request request, CharSequence prompt, Bundle extras) {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPickOption(Caller caller,
|
public void onRequestPickOption(PickOptionRequest request) {
|
||||||
Request request, CharSequence prompt,
|
|
||||||
VoiceInteractor.PickOptionRequest.Option[] options, Bundle extras) {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCommand(Caller caller,
|
public void onRequestCommand(CommandRequest request) {
|
||||||
Request request, String command, Bundle extras) {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle args) {
|
public void onCancelRequest(Request request) {
|
||||||
super.onCreate(args);
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate() {
|
||||||
// Simulate slowness of Assist app
|
// Simulate slowness of Assist app
|
||||||
try {
|
try {
|
||||||
Thread.sleep(1000);
|
Thread.sleep(1000);
|
||||||
@@ -82,11 +77,6 @@ public class AssistInteractionSession extends VoiceInteractionSession {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCancel(Request request) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateContentView() {
|
public View onCreateContentView() {
|
||||||
View v = getLayoutInflater().inflate(R.layout.assist, null);
|
View v = getLayoutInflater().inflate(R.layout.assist, null);
|
||||||
|
|||||||
@@ -51,6 +51,19 @@
|
|||||||
android:text="@string/abortVoice"
|
android:text="@string/abortVoice"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<Button android:id="@+id/command"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/commandVoice"
|
||||||
|
/>
|
||||||
|
|
||||||
<Button android:id="@+id/pick"
|
<Button android:id="@+id/pick"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
<string name="abort">Abort</string>
|
<string name="abort">Abort</string>
|
||||||
<string name="complete">Complete</string>
|
<string name="complete">Complete</string>
|
||||||
<string name="abortVoice">Abort Voice</string>
|
<string name="abortVoice">Abort Voice</string>
|
||||||
|
<string name="commandVoice">Command</string>
|
||||||
<string name="completeVoice">Complete Voice</string>
|
<string name="completeVoice">Complete Voice</string>
|
||||||
<string name="pickVoice">Pick Voice</string>
|
<string name="pickVoice">Pick Voice</string>
|
||||||
<string name="cancelVoice">Cancel</string>
|
<string name="cancelVoice">Cancel</string>
|
||||||
|
|||||||
@@ -80,7 +80,8 @@ public class MainInteractionService extends VoiceInteractionService {
|
|||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
args.putParcelable("intent", new Intent(this, TestInteractionActivity.class));
|
args.putParcelable("intent", new Intent(this, TestInteractionActivity.class));
|
||||||
args.putBundle("assist", intent.getExtras());
|
args.putBundle("assist", intent.getExtras());
|
||||||
startSession(args, VoiceInteractionSession.SHOW_WITH_ASSIST | VoiceInteractionSession.SHOW_WITH_SCREENSHOT);
|
showSession(args, VoiceInteractionSession.SHOW_WITH_ASSIST
|
||||||
|
| VoiceInteractionSession.SHOW_WITH_SCREENSHOT);
|
||||||
} else {
|
} else {
|
||||||
Log.w(TAG, "Not starting -- not current voice interaction service");
|
Log.w(TAG, "Not starting -- not current voice interaction service");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ public class MainInteractionSession extends VoiceInteractionSession
|
|||||||
static final int STATE_COMMAND = 4;
|
static final int STATE_COMMAND = 4;
|
||||||
static final int STATE_ABORT_VOICE = 5;
|
static final int STATE_ABORT_VOICE = 5;
|
||||||
static final int STATE_COMPLETE_VOICE = 6;
|
static final int STATE_COMPLETE_VOICE = 6;
|
||||||
static final int STATE_DONE=7;
|
static final int STATE_DONE = 7;
|
||||||
|
|
||||||
int mState = STATE_IDLE;
|
int mState = STATE_IDLE;
|
||||||
VoiceInteractor.PickOptionRequest.Option[] mPendingOptions;
|
VoiceInteractor.PickOptionRequest.Option[] mPendingOptions;
|
||||||
@@ -72,8 +72,8 @@ public class MainInteractionSession extends VoiceInteractionSession
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle args, int startFlags) {
|
public void onCreate() {
|
||||||
super.onCreate(args, startFlags);
|
super.onCreate();
|
||||||
ActivityManager am = getContext().getSystemService(ActivityManager.class);
|
ActivityManager am = getContext().getSystemService(ActivityManager.class);
|
||||||
am.setWatchHeapLimit(40 * 1024 * 1024);
|
am.setWatchHeapLimit(40 * 1024 * 1024);
|
||||||
}
|
}
|
||||||
@@ -163,8 +163,8 @@ public class MainInteractionSession extends VoiceInteractionSession
|
|||||||
if (screenshot != null) {
|
if (screenshot != null) {
|
||||||
mScreenshot.setImageBitmap(screenshot);
|
mScreenshot.setImageBitmap(screenshot);
|
||||||
mScreenshot.setAdjustViewBounds(true);
|
mScreenshot.setAdjustViewBounds(true);
|
||||||
mScreenshot.setMaxWidth(screenshot.getWidth()/3);
|
mScreenshot.setMaxWidth(screenshot.getWidth() / 3);
|
||||||
mScreenshot.setMaxHeight(screenshot.getHeight()/3);
|
mScreenshot.setMaxHeight(screenshot.getHeight() / 3);
|
||||||
mFullScreenshot.setImageBitmap(screenshot);
|
mFullScreenshot.setImageBitmap(screenshot);
|
||||||
} else {
|
} else {
|
||||||
mScreenshot.setImageDrawable(null);
|
mScreenshot.setImageDrawable(null);
|
||||||
@@ -207,11 +207,12 @@ public class MainInteractionSession extends VoiceInteractionSession
|
|||||||
updateState();
|
updateState();
|
||||||
startVoiceActivity(mStartIntent);
|
startVoiceActivity(mStartIntent);
|
||||||
} else if (v == mConfirmButton) {
|
} else if (v == mConfirmButton) {
|
||||||
if (mState == STATE_CONFIRM) {
|
if (mPendingRequest instanceof ConfirmationRequest) {
|
||||||
mPendingRequest.sendConfirmResult(true, null);
|
((ConfirmationRequest)mPendingRequest).sendConfirmationResult(true, null);
|
||||||
mPendingRequest = null;
|
mPendingRequest = null;
|
||||||
mState = STATE_LAUNCHING;
|
mState = STATE_LAUNCHING;
|
||||||
} else if (mState == STATE_PICK_OPTION) {
|
} else if (mPendingRequest instanceof PickOptionRequest) {
|
||||||
|
PickOptionRequest pick = (PickOptionRequest)mPendingRequest;
|
||||||
int numReturn = mPendingOptions.length/2;
|
int numReturn = mPendingOptions.length/2;
|
||||||
if (numReturn <= 0) {
|
if (numReturn <= 0) {
|
||||||
numReturn = 1;
|
numReturn = 1;
|
||||||
@@ -223,23 +224,25 @@ public class MainInteractionSession extends VoiceInteractionSession
|
|||||||
}
|
}
|
||||||
mPendingOptions = picked;
|
mPendingOptions = picked;
|
||||||
if (picked.length <= 1) {
|
if (picked.length <= 1) {
|
||||||
mPendingRequest.sendPickOptionResult(true, picked, null);
|
pick.sendPickOptionResult(picked, null);
|
||||||
mPendingRequest = null;
|
mPendingRequest = null;
|
||||||
mState = STATE_LAUNCHING;
|
mState = STATE_LAUNCHING;
|
||||||
} else {
|
} else {
|
||||||
mPendingRequest.sendPickOptionResult(false, picked, null);
|
pick.sendIntermediatePickOptionResult(picked, null);
|
||||||
updatePickText();
|
updatePickText();
|
||||||
}
|
}
|
||||||
} else if (mPendingRequest != null) {
|
} else if (mPendingRequest instanceof CommandRequest) {
|
||||||
mPendingRequest.sendCommandResult(true, null);
|
Bundle result = new Bundle();
|
||||||
|
result.putString("key", "a result!");
|
||||||
|
((CommandRequest)mPendingRequest).sendResult(result);
|
||||||
mPendingRequest = null;
|
mPendingRequest = null;
|
||||||
mState = STATE_LAUNCHING;
|
mState = STATE_LAUNCHING;
|
||||||
}
|
}
|
||||||
} else if (v == mAbortButton) {
|
} else if (v == mAbortButton && mPendingRequest instanceof AbortVoiceRequest) {
|
||||||
mPendingRequest.sendAbortVoiceResult(null);
|
((AbortVoiceRequest)mPendingRequest).sendAbortResult(null);
|
||||||
mPendingRequest = null;
|
mPendingRequest = null;
|
||||||
} else if (v == mCompleteButton) {
|
} else if (v == mCompleteButton && mPendingRequest instanceof CompleteVoiceRequest) {
|
||||||
mPendingRequest.sendCompleteVoiceResult(null);
|
((CompleteVoiceRequest)mPendingRequest).sendCompleteResult(null);
|
||||||
mPendingRequest = null;
|
mPendingRequest = null;
|
||||||
} else if (v == mScreenshot) {
|
} else if (v == mScreenshot) {
|
||||||
if (mFullScreenshot.getVisibility() != View.VISIBLE) {
|
if (mFullScreenshot.getVisibility() != View.VISIBLE) {
|
||||||
@@ -261,29 +264,45 @@ public class MainInteractionSession extends VoiceInteractionSession
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean[] onGetSupportedCommands(Caller caller, String[] commands) {
|
public boolean[] onGetSupportedCommands(String[] commands) {
|
||||||
return new boolean[commands.length];
|
boolean[] res = new boolean[commands.length];
|
||||||
|
for (int i=0; i<commands.length; i++) {
|
||||||
|
if ("com.android.test.voiceinteraction.COMMAND".equals(commands[i])) {
|
||||||
|
res[i] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setPrompt(VoiceInteractor.Prompt prompt) {
|
||||||
|
if (prompt == null) {
|
||||||
|
mText.setText("(null)");
|
||||||
|
mPendingPrompt = "";
|
||||||
|
} else {
|
||||||
|
mText.setText(prompt.getVisualPrompt());
|
||||||
|
mPendingPrompt = prompt.getVisualPrompt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onConfirm(Caller caller, Request request, CharSequence prompt, Bundle extras) {
|
public void onRequestConfirmation(ConfirmationRequest request) {
|
||||||
Log.i(TAG, "onConfirm: prompt=" + prompt + " extras=" + extras);
|
Log.i(TAG, "onConfirm: prompt=" + request.getVoicePrompt() + " extras="
|
||||||
mText.setText(prompt);
|
+ request.getExtras());
|
||||||
|
setPrompt(request.getVoicePrompt());
|
||||||
mConfirmButton.setText("Confirm");
|
mConfirmButton.setText("Confirm");
|
||||||
mPendingRequest = request;
|
mPendingRequest = request;
|
||||||
mPendingPrompt = prompt;
|
|
||||||
mState = STATE_CONFIRM;
|
mState = STATE_CONFIRM;
|
||||||
updateState();
|
updateState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPickOption(Caller caller, Request request, CharSequence prompt,
|
public void onRequestPickOption(PickOptionRequest request) {
|
||||||
VoiceInteractor.PickOptionRequest.Option[] options, Bundle extras) {
|
Log.i(TAG, "onPickOption: prompt=" + request.getVoicePrompt() + " options="
|
||||||
Log.i(TAG, "onPickOption: prompt=" + prompt + " options=" + options + " extras=" + extras);
|
+ request.getOptions() + " extras=" + request.getExtras());
|
||||||
mConfirmButton.setText("Pick Option");
|
mConfirmButton.setText("Pick Option");
|
||||||
mPendingRequest = request;
|
mPendingRequest = request;
|
||||||
mPendingPrompt = prompt;
|
setPrompt(request.getVoicePrompt());
|
||||||
mPendingOptions = options;
|
mPendingOptions = request.getOptions();
|
||||||
mState = STATE_PICK_OPTION;
|
mState = STATE_PICK_OPTION;
|
||||||
updatePickText();
|
updatePickText();
|
||||||
updateState();
|
updateState();
|
||||||
@@ -303,27 +322,33 @@ public class MainInteractionSession extends VoiceInteractionSession
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCompleteVoice(Caller caller, Request request, CharSequence message, Bundle extras) {
|
public void onRequestCompleteVoice(CompleteVoiceRequest request) {
|
||||||
Log.i(TAG, "onCompleteVoice: message=" + message + " extras=" + extras);
|
Log.i(TAG, "onCompleteVoice: message=" + request.getVoicePrompt() + " extras="
|
||||||
mText.setText(message);
|
+ request.getExtras());
|
||||||
|
setPrompt(request.getVoicePrompt());
|
||||||
mPendingRequest = request;
|
mPendingRequest = request;
|
||||||
mState = STATE_COMPLETE_VOICE;
|
mState = STATE_COMPLETE_VOICE;
|
||||||
updateState();
|
updateState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAbortVoice(Caller caller, Request request, CharSequence message, Bundle extras) {
|
public void onRequestAbortVoice(AbortVoiceRequest request) {
|
||||||
Log.i(TAG, "onAbortVoice: message=" + message + " extras=" + extras);
|
Log.i(TAG, "onAbortVoice: message=" + request.getVoicePrompt() + " extras="
|
||||||
mText.setText(message);
|
+ request.getExtras());
|
||||||
|
setPrompt(request.getVoicePrompt());
|
||||||
mPendingRequest = request;
|
mPendingRequest = request;
|
||||||
mState = STATE_ABORT_VOICE;
|
mState = STATE_ABORT_VOICE;
|
||||||
updateState();
|
updateState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCommand(Caller caller, Request request, String command, Bundle extras) {
|
public void onRequestCommand(CommandRequest request) {
|
||||||
Log.i(TAG, "onCommand: command=" + command + " extras=" + extras);
|
Bundle extras = request.getExtras();
|
||||||
mText.setText("Command: " + command);
|
if (extras != null) {
|
||||||
|
extras.getString("arg");
|
||||||
|
}
|
||||||
|
Log.i(TAG, "onCommand: command=" + request.getCommand() + " extras=" + extras);
|
||||||
|
mText.setText("Command: " + request.getCommand() + ", " + extras);
|
||||||
mConfirmButton.setText("Finish Command");
|
mConfirmButton.setText("Finish Command");
|
||||||
mPendingRequest = request;
|
mPendingRequest = request;
|
||||||
mState = STATE_COMMAND;
|
mState = STATE_COMMAND;
|
||||||
@@ -331,8 +356,13 @@ public class MainInteractionSession extends VoiceInteractionSession
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCancel(Request request) {
|
public void onCancelRequest(Request request) {
|
||||||
Log.i(TAG, "onCancel");
|
Log.i(TAG, "onCancel");
|
||||||
request.sendCancelResult();
|
if (mPendingRequest == request) {
|
||||||
|
mPendingRequest = null;
|
||||||
|
mState = STATE_LAUNCHING;
|
||||||
|
updateState();
|
||||||
|
}
|
||||||
|
request.cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ public class TestInteractionActivity extends Activity implements View.OnClickLis
|
|||||||
|
|
||||||
static final String REQUEST_ABORT = "abort";
|
static final String REQUEST_ABORT = "abort";
|
||||||
static final String REQUEST_COMPLETE = "complete";
|
static final String REQUEST_COMPLETE = "complete";
|
||||||
|
static final String REQUEST_COMMAND = "command";
|
||||||
static final String REQUEST_PICK = "pick";
|
static final String REQUEST_PICK = "pick";
|
||||||
static final String REQUEST_CONFIRM = "confirm";
|
static final String REQUEST_CONFIRM = "confirm";
|
||||||
|
|
||||||
@@ -41,6 +42,7 @@ public class TestInteractionActivity extends Activity implements View.OnClickLis
|
|||||||
TextView mLog;
|
TextView mLog;
|
||||||
Button mAbortButton;
|
Button mAbortButton;
|
||||||
Button mCompleteButton;
|
Button mCompleteButton;
|
||||||
|
Button mCommandButton;
|
||||||
Button mPickButton;
|
Button mPickButton;
|
||||||
Button mJumpOutButton;
|
Button mJumpOutButton;
|
||||||
Button mCancelButton;
|
Button mCancelButton;
|
||||||
@@ -68,6 +70,8 @@ public class TestInteractionActivity extends Activity implements View.OnClickLis
|
|||||||
mAbortButton.setOnClickListener(this);
|
mAbortButton.setOnClickListener(this);
|
||||||
mCompleteButton = (Button)findViewById(R.id.complete);
|
mCompleteButton = (Button)findViewById(R.id.complete);
|
||||||
mCompleteButton.setOnClickListener(this);
|
mCompleteButton.setOnClickListener(this);
|
||||||
|
mCommandButton = (Button)findViewById(R.id.command);
|
||||||
|
mCommandButton.setOnClickListener(this);
|
||||||
mPickButton = (Button)findViewById(R.id.pick);
|
mPickButton = (Button)findViewById(R.id.pick);
|
||||||
mPickButton.setOnClickListener(this);
|
mPickButton.setOnClickListener(this);
|
||||||
mJumpOutButton = (Button)findViewById(R.id.jump);
|
mJumpOutButton = (Button)findViewById(R.id.jump);
|
||||||
@@ -117,6 +121,9 @@ public class TestInteractionActivity extends Activity implements View.OnClickLis
|
|||||||
} else if (v == mCompleteButton) {
|
} else if (v == mCompleteButton) {
|
||||||
VoiceInteractor.CompleteVoiceRequest req = new TestCompleteVoice();
|
VoiceInteractor.CompleteVoiceRequest req = new TestCompleteVoice();
|
||||||
mInteractor.submitRequest(req, REQUEST_COMPLETE);
|
mInteractor.submitRequest(req, REQUEST_COMPLETE);
|
||||||
|
} else if (v == mCommandButton) {
|
||||||
|
VoiceInteractor.CommandRequest req = new TestCommand("Some arg");
|
||||||
|
mInteractor.submitRequest(req, REQUEST_COMMAND);
|
||||||
} else if (v == mPickButton) {
|
} else if (v == mPickButton) {
|
||||||
VoiceInteractor.PickOptionRequest.Option[] options =
|
VoiceInteractor.PickOptionRequest.Option[] options =
|
||||||
new VoiceInteractor.PickOptionRequest.Option[5];
|
new VoiceInteractor.PickOptionRequest.Option[5];
|
||||||
@@ -176,6 +183,37 @@ public class TestInteractionActivity extends Activity implements View.OnClickLis
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class TestCommand extends VoiceInteractor.CommandRequest {
|
||||||
|
public TestCommand(String arg) {
|
||||||
|
super("com.android.test.voiceinteraction.COMMAND", makeBundle(arg));
|
||||||
|
}
|
||||||
|
@Override public void onCancel() {
|
||||||
|
Log.i(TAG, "Canceled!");
|
||||||
|
((TestInteractionActivity)getActivity()).mLog.append("Canceled command\n");
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void onCommandResult(boolean finished, Bundle result) {
|
||||||
|
Log.i(TAG, "Command result: finished=" + finished + " result=" + result);
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
if (finished) {
|
||||||
|
sb.append("Command final result: ");
|
||||||
|
} else {
|
||||||
|
sb.append("Command intermediate result: ");
|
||||||
|
}
|
||||||
|
if (result != null) {
|
||||||
|
result.getString("key");
|
||||||
|
}
|
||||||
|
sb.append(result);
|
||||||
|
sb.append("\n");
|
||||||
|
((TestInteractionActivity)getActivity()).mLog.append(sb.toString());
|
||||||
|
}
|
||||||
|
static Bundle makeBundle(String arg) {
|
||||||
|
Bundle b = new Bundle();
|
||||||
|
b.putString("key", arg);
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static class TestPickOption extends VoiceInteractor.PickOptionRequest {
|
static class TestPickOption extends VoiceInteractor.PickOptionRequest {
|
||||||
public TestPickOption(Option[] options) {
|
public TestPickOption(Option[] options) {
|
||||||
super(new VoiceInteractor.Prompt("Need to pick something"), options, null);
|
super(new VoiceInteractor.Prompt("Need to pick something"), options, null);
|
||||||
@@ -200,10 +238,8 @@ public class TestInteractionActivity extends Activity implements View.OnClickLis
|
|||||||
}
|
}
|
||||||
sb.append(selections[i].getLabel());
|
sb.append(selections[i].getLabel());
|
||||||
}
|
}
|
||||||
|
sb.append("\n");
|
||||||
((TestInteractionActivity)getActivity()).mLog.append(sb.toString());
|
((TestInteractionActivity)getActivity()).mLog.append(sb.toString());
|
||||||
if (finished) {
|
|
||||||
getActivity().finish();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user