summaryrefslogtreecommitdiffstats
path: root/services/voiceinteraction
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2015-02-11 17:02:41 -0800
committerDianne Hackborn <hackbod@google.com>2015-02-13 11:27:57 -0800
commitae6688b09649447e57468b3e7935691bc09ec9b9 (patch)
tree799d4b2ddeb5b32a578b7300196bfefdf272703e /services/voiceinteraction
parentbc26d2eafd6185a197a968b2dffde5871791cf0b (diff)
downloadframeworks_base-ae6688b09649447e57468b3e7935691bc09ec9b9.zip
frameworks_base-ae6688b09649447e57468b3e7935691bc09ec9b9.tar.gz
frameworks_base-ae6688b09649447e57468b3e7935691bc09ec9b9.tar.bz2
Update voice interaction layer for new UI design.
Can switch from a pure overlay at the top of the screen, to interactive mode with the voice UI drawing at the bottom and pushing its target activity up like an IME. Add mechanism to get assist data to the voice interaction UI. Add some basic visualization of the assist data, outlining where on the screen we have text. Add a test ACTION_ASSIST handler, which can propagate the assist data it gets to the voice interaction session so you can see what kind of data we are getting from different apps. Change-Id: I18312fe1601d7926d1fb96a817638d60f6263771
Diffstat (limited to 'services/voiceinteraction')
-rw-r--r--services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java24
-rw-r--r--services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerServiceImpl.java48
2 files changed, 60 insertions, 12 deletions
diff --git a/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java b/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java
index c32ba67..fd990d7 100644
--- a/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java
+++ b/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java
@@ -129,12 +129,14 @@ public class VoiceInteractionManagerService extends SystemService {
}
public void initForUser(int userHandle) {
- if (DEBUG) Slog.i(TAG, "initForUser user=" + userHandle);
+ if (DEBUG) Slog.d(TAG, "**************** initForUser user=" + userHandle);
String curInteractorStr = Settings.Secure.getStringForUser(
mContext.getContentResolver(),
Settings.Secure.VOICE_INTERACTION_SERVICE, userHandle);
ComponentName curRecognizer = getCurRecognizer(userHandle);
VoiceInteractionServiceInfo curInteractorInfo = null;
+ if (DEBUG) Slog.d(TAG, "curInteractorStr=" + curInteractorStr
+ + " curRecognizer=" + curRecognizer);
if (curInteractorStr == null && curRecognizer != null
&& !ActivityManager.isLowRamDeviceStatic()) {
// If there is no interactor setting, that means we are upgrading
@@ -148,6 +150,8 @@ public class VoiceInteractionManagerService extends SystemService {
// Looks good! We'll apply this one. To make it happen, we clear the
// recognizer so that we don't think we have anything set and will
// re-apply the settings.
+ if (DEBUG) Slog.d(TAG, "No set interactor, found avail: "
+ + curInteractorInfo.getServiceInfo().name);
curRecognizer = null;
}
}
@@ -156,6 +160,7 @@ public class VoiceInteractionManagerService extends SystemService {
// enabled; if it is, turn it off.
if (ActivityManager.isLowRamDeviceStatic() && curInteractorStr != null) {
if (!TextUtils.isEmpty(curInteractorStr)) {
+ if (DEBUG) Slog.d(TAG, "Svelte device; disabling interactor");
setCurInteractor(null, userHandle);
curInteractorStr = "";
}
@@ -178,8 +183,11 @@ public class VoiceInteractionManagerService extends SystemService {
}
// If the apps for the currently set components still exist, then all is okay.
if (recognizerInfo != null && (curInteractor == null || interactorInfo != null)) {
+ if (DEBUG) Slog.d(TAG, "Current interactor/recognizer okay, done!");
return;
}
+ if (DEBUG) Slog.d(TAG, "Bad recognizer (" + recognizerInfo + ") or interactor ("
+ + interactorInfo + ")");
}
// Initializing settings, look for an interactor first (but only on non-svelte).
@@ -316,7 +324,7 @@ public class VoiceInteractionManagerService extends SystemService {
if (TextUtils.isEmpty(curInteractor)) {
return null;
}
- if (DEBUG) Slog.i(TAG, "getCurInteractor curInteractor=" + curInteractor
+ if (DEBUG) Slog.d(TAG, "getCurInteractor curInteractor=" + curInteractor
+ " user=" + userHandle);
return ComponentName.unflattenFromString(curInteractor);
}
@@ -325,7 +333,7 @@ public class VoiceInteractionManagerService extends SystemService {
Settings.Secure.putStringForUser(mContext.getContentResolver(),
Settings.Secure.VOICE_INTERACTION_SERVICE,
comp != null ? comp.flattenToShortString() : "", userHandle);
- if (DEBUG) Slog.i(TAG, "setCurInteractor comp=" + comp
+ if (DEBUG) Slog.d(TAG, "setCurInteractor comp=" + comp
+ " user=" + userHandle);
}
@@ -363,7 +371,7 @@ public class VoiceInteractionManagerService extends SystemService {
if (TextUtils.isEmpty(curRecognizer)) {
return null;
}
- if (DEBUG) Slog.i(TAG, "getCurRecognizer curRecognizer=" + curRecognizer
+ if (DEBUG) Slog.d(TAG, "getCurRecognizer curRecognizer=" + curRecognizer
+ " user=" + userHandle);
return ComponentName.unflattenFromString(curRecognizer);
}
@@ -372,12 +380,12 @@ public class VoiceInteractionManagerService extends SystemService {
Settings.Secure.putStringForUser(mContext.getContentResolver(),
Settings.Secure.VOICE_RECOGNITION_SERVICE,
comp != null ? comp.flattenToShortString() : "", userHandle);
- if (DEBUG) Slog.i(TAG, "setCurRecognizer comp=" + comp
+ if (DEBUG) Slog.d(TAG, "setCurRecognizer comp=" + comp
+ " user=" + userHandle);
}
@Override
- public void startSession(IVoiceInteractionService service, Bundle args) {
+ public void startSession(IVoiceInteractionService service, Bundle args, int flags) {
synchronized (this) {
if (mImpl == null || mImpl.mService == null
|| service.asBinder() != mImpl.mService.asBinder()) {
@@ -388,7 +396,7 @@ public class VoiceInteractionManagerService extends SystemService {
final int callingUid = Binder.getCallingUid();
final long caller = Binder.clearCallingIdentity();
try {
- mImpl.startSessionLocked(callingPid, callingUid, args);
+ mImpl.startSessionLocked(callingPid, callingUid, args, flags);
} finally {
Binder.restoreCallingIdentity(caller);
}
@@ -692,7 +700,7 @@ public class VoiceInteractionManagerService extends SystemService {
@Override
public void onSomePackagesChanged() {
int userHandle = getChangingUserId();
- if (DEBUG) Slog.i(TAG, "onSomePackagesChanged user=" + userHandle);
+ if (DEBUG) Slog.d(TAG, "onSomePackagesChanged user=" + userHandle);
ComponentName curInteractor = getCurInteractor(userHandle);
ComponentName curRecognizer = getCurRecognizer(userHandle);
diff --git a/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerServiceImpl.java b/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerServiceImpl.java
index b36b611..e80f702 100644
--- a/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerServiceImpl.java
+++ b/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerServiceImpl.java
@@ -43,6 +43,7 @@ import android.view.IWindowManager;
import android.view.WindowManager;
import com.android.internal.app.IVoiceInteractor;
+import com.android.internal.os.IResultReceiver;
import java.io.FileDescriptor;
import java.io.PrintWriter;
@@ -103,13 +104,33 @@ class VoiceInteractionManagerServiceImpl {
final class SessionConnection implements ServiceConnection {
final IBinder mToken = new Binder();
final Bundle mArgs;
+ final int mFlags;
boolean mBound;
IVoiceInteractionSessionService mService;
IVoiceInteractionSession mSession;
IVoiceInteractor mInteractor;
+ boolean mHaveAssistData;
+ Bundle mAssistData;
- SessionConnection(Bundle args) {
+ final IResultReceiver mAssistReceiver = new IResultReceiver.Stub() {
+ @Override
+ public void send(int resultCode, Bundle resultData) throws RemoteException {
+ synchronized (mLock) {
+ mHaveAssistData = true;
+ mAssistData = resultData;
+ if (mSession != null) {
+ try {
+ mSession.handleAssist(resultData);
+ } catch (RemoteException e) {
+ }
+ }
+ }
+ }
+ };
+
+ SessionConnection(Bundle args, int flags) {
mArgs = args;
+ mFlags = flags;
Intent serviceIntent = new Intent(VoiceInteractionService.SERVICE_INTERFACE);
serviceIntent.setComponent(mSessionComponentName);
mBound = mContext.bindServiceAsUser(serviceIntent, this,
@@ -121,6 +142,14 @@ class VoiceInteractionManagerServiceImpl {
} catch (RemoteException e) {
Slog.w(TAG, "Failed adding window token", e);
}
+ if ((flags&VoiceInteractionService.START_WITH_ASSIST) != 0) {
+ try {
+ mAm.requestAssistContextExtras(0, mAssistReceiver);
+ } catch (RemoteException e) {
+ }
+ } else {
+ mHaveAssistData = true;
+ }
} else {
Slog.w(TAG, "Failed binding to voice interaction session service " + mComponent);
}
@@ -132,7 +161,7 @@ class VoiceInteractionManagerServiceImpl {
mService = IVoiceInteractionSessionService.Stub.asInterface(service);
if (mActiveSession == this) {
try {
- mService.newSession(mToken, mArgs);
+ mService.newSession(mToken, mArgs, mFlags);
} catch (RemoteException e) {
Slog.w(TAG, "Failed adding window token", e);
}
@@ -176,12 +205,17 @@ class VoiceInteractionManagerServiceImpl {
public void dump(String prefix, PrintWriter pw) {
pw.print(prefix); pw.print("mToken="); pw.println(mToken);
pw.print(prefix); pw.print("mArgs="); pw.println(mArgs);
+ pw.print(prefix); pw.print("mFlags=0x"); pw.println(Integer.toHexString(mFlags));
pw.print(prefix); pw.print("mBound="); pw.println(mBound);
if (mBound) {
pw.print(prefix); pw.print("mService="); pw.println(mService);
pw.print(prefix); pw.print("mSession="); pw.println(mSession);
pw.print(prefix); pw.print("mInteractor="); pw.println(mInteractor);
}
+ pw.print(prefix); pw.print("mHaveAssistData="); pw.println(mHaveAssistData);
+ if (mHaveAssistData) {
+ pw.print(prefix); pw.print("mAssistData="); pw.println(mAssistData);
+ }
}
};
@@ -222,12 +256,12 @@ class VoiceInteractionManagerServiceImpl {
mContext.registerReceiver(mBroadcastReceiver, filter, null, handler);
}
- public void startSessionLocked(int callingPid, int callingUid, Bundle args) {
+ public void startSessionLocked(int callingPid, int callingUid, Bundle args, int flags) {
if (mActiveSession != null) {
mActiveSession.cancel();
mActiveSession = null;
}
- mActiveSession = new SessionConnection(args);
+ mActiveSession = new SessionConnection(args, flags);
}
public boolean deliverNewSessionLocked(int callingPid, int callingUid, IBinder token,
@@ -238,6 +272,12 @@ class VoiceInteractionManagerServiceImpl {
}
mActiveSession.mSession = session;
mActiveSession.mInteractor = interactor;
+ if (mActiveSession.mHaveAssistData) {
+ try {
+ session.handleAssist(mActiveSession.mAssistData);
+ } catch (RemoteException e) {
+ }
+ }
return true;
}