summaryrefslogtreecommitdiffstats
path: root/core/java/android/service
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2015-02-13 20:15:58 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-02-13 20:16:04 +0000
commit682c8e509b494b8cd221d65df8f5e1f10e5f7bf1 (patch)
tree3f455cdb175df975cd6438158196e3112121c94b /core/java/android/service
parent50dd4c1c591ce22922cee539a73d2e9b821d1c9f (diff)
parentae6688b09649447e57468b3e7935691bc09ec9b9 (diff)
downloadframeworks_base-682c8e509b494b8cd221d65df8f5e1f10e5f7bf1.zip
frameworks_base-682c8e509b494b8cd221d65df8f5e1f10e5f7bf1.tar.gz
frameworks_base-682c8e509b494b8cd221d65df8f5e1f10e5f7bf1.tar.bz2
Merge "Update voice interaction layer for new UI design."
Diffstat (limited to 'core/java/android/service')
-rw-r--r--core/java/android/service/dreams/DreamService.java4
-rw-r--r--core/java/android/service/voice/IVoiceInteractionSession.aidl2
-rw-r--r--core/java/android/service/voice/IVoiceInteractionSessionService.aidl2
-rw-r--r--core/java/android/service/voice/VoiceInteractionService.java19
-rw-r--r--core/java/android/service/voice/VoiceInteractionServiceInfo.java4
-rw-r--r--core/java/android/service/voice/VoiceInteractionSession.java60
-rw-r--r--core/java/android/service/voice/VoiceInteractionSessionService.java12
7 files changed, 70 insertions, 33 deletions
diff --git a/core/java/android/service/dreams/DreamService.java b/core/java/android/service/dreams/DreamService.java
index fa5ac42..d410622 100644
--- a/core/java/android/service/dreams/DreamService.java
+++ b/core/java/android/service/dreams/DreamService.java
@@ -1039,10 +1039,10 @@ public class DreamService extends Service implements Window.Callback {
protected void dump(final FileDescriptor fd, PrintWriter pw, final String[] args) {
DumpUtils.dumpAsync(mHandler, new Dump() {
@Override
- public void dump(PrintWriter pw) {
+ public void dump(PrintWriter pw, String prefix) {
dumpOnHandler(fd, pw, args);
}
- }, pw, 1000);
+ }, pw, "", 1000);
}
/** @hide */
diff --git a/core/java/android/service/voice/IVoiceInteractionSession.aidl b/core/java/android/service/voice/IVoiceInteractionSession.aidl
index 9f9c312..a8c0c4c 100644
--- a/core/java/android/service/voice/IVoiceInteractionSession.aidl
+++ b/core/java/android/service/voice/IVoiceInteractionSession.aidl
@@ -17,11 +17,13 @@
package android.service.voice;
import android.content.Intent;
+import android.os.Bundle;
/**
* @hide
*/
oneway interface IVoiceInteractionSession {
+ void handleAssist(in Bundle assistData);
void taskStarted(in Intent intent, int taskId);
void taskFinished(in Intent intent, int taskId);
void closeSystemDialogs();
diff --git a/core/java/android/service/voice/IVoiceInteractionSessionService.aidl b/core/java/android/service/voice/IVoiceInteractionSessionService.aidl
index 2519442..7f8158f 100644
--- a/core/java/android/service/voice/IVoiceInteractionSessionService.aidl
+++ b/core/java/android/service/voice/IVoiceInteractionSessionService.aidl
@@ -24,5 +24,5 @@ import android.service.voice.IVoiceInteractionSession;
* @hide
*/
oneway interface IVoiceInteractionSessionService {
- void newSession(IBinder token, in Bundle args);
+ void newSession(IBinder token, in Bundle args, int startFlags);
}
diff --git a/core/java/android/service/voice/VoiceInteractionService.java b/core/java/android/service/voice/VoiceInteractionService.java
index 65e6988..54a3a0a 100644
--- a/core/java/android/service/voice/VoiceInteractionService.java
+++ b/core/java/android/service/voice/VoiceInteractionService.java
@@ -70,6 +70,12 @@ public class VoiceInteractionService extends Service {
*/
public static final String SERVICE_META_DATA = "android.voice_interaction";
+ /**
+ * Flag for use with {@link #startSession}: request that the session be started with
+ * assist data from the currently focused activity.
+ */
+ public static final int START_WITH_ASSIST = 1<<0;
+
IVoiceInteractionService mInterface = new IVoiceInteractionService.Stub() {
@Override public void ready() {
mHandler.sendEmptyMessage(MSG_READY);
@@ -136,16 +142,21 @@ public class VoiceInteractionService extends Service {
* Initiate the execution of a new {@link android.service.voice.VoiceInteractionSession}.
* @param args Arbitrary arguments that will be propagated to the session.
*/
- public void startSession(Bundle args) {
+ public void startSession(Bundle args, int flags) {
if (mSystemService == null) {
throw new IllegalStateException("Not available until onReady() is called");
}
try {
- mSystemService.startSession(mInterface, args);
+ mSystemService.startSession(mInterface, args, flags);
} catch (RemoteException e) {
}
}
+ /** @hide */
+ public void startSession(Bundle args) {
+ startSession(args, 0);
+ }
+
@Override
public void onCreate() {
super.onCreate();
@@ -163,8 +174,8 @@ public class VoiceInteractionService extends Service {
/**
* Called during service initialization to tell you when the system is ready
* to receive interaction from it. You should generally do initialization here
- * rather than in {@link #onCreate()}. Methods such as {@link #startSession(Bundle)} and
- * {@link #createAlwaysOnHotwordDetector(String, Locale, android.service.voice.AlwaysOnHotwordDetector.Callback)}
+ * rather than in {@link #onCreate}. Methods such as {@link #startSession} and
+ * {@link #createAlwaysOnHotwordDetector}
* will not be operational until this point.
*/
public void onReady() {
diff --git a/core/java/android/service/voice/VoiceInteractionServiceInfo.java b/core/java/android/service/voice/VoiceInteractionServiceInfo.java
index e6e9413..ebc7507 100644
--- a/core/java/android/service/voice/VoiceInteractionServiceInfo.java
+++ b/core/java/android/service/voice/VoiceInteractionServiceInfo.java
@@ -99,6 +99,10 @@ public class VoiceInteractionServiceInfo {
mParseError = "No sessionService specified";
return;
}
+ if (mRecognitionService == null) {
+ mParseError = "No recognitionService specified";
+ return;
+ }
/* Not yet time
if (mRecognitionService == null) {
mParseError = "No recogitionService specified";
diff --git a/core/java/android/service/voice/VoiceInteractionSession.java b/core/java/android/service/voice/VoiceInteractionSession.java
index 19d14bf..a3a2ca1 100644
--- a/core/java/android/service/voice/VoiceInteractionSession.java
+++ b/core/java/android/service/voice/VoiceInteractionSession.java
@@ -50,7 +50,6 @@ import com.android.internal.os.SomeArgs;
import java.lang.ref.WeakReference;
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
-import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
/**
* An active voice interaction session, providing a facility for the implementation
@@ -91,7 +90,6 @@ public abstract class VoiceInteractionSession implements KeyEvent.Callback {
final ArrayMap<IBinder, Request> mActiveRequests = new ArrayMap<IBinder, Request>();
final Insets mTmpInsets = new Insets();
- final int[] mTmpLocation = new int[2];
final WeakReference<VoiceInteractionSession> mWeakRef
= new WeakReference<VoiceInteractionSession>(this);
@@ -153,6 +151,12 @@ public abstract class VoiceInteractionSession implements KeyEvent.Callback {
final IVoiceInteractionSession mSession = new IVoiceInteractionSession.Stub() {
@Override
+ public void handleAssist(Bundle assistBundle) {
+ mHandlerCaller.sendMessage(mHandlerCaller.obtainMessageO(MSG_HANDLE_ASSIST,
+ assistBundle));
+ }
+
+ @Override
public void taskStarted(Intent intent, int taskId) {
mHandlerCaller.sendMessage(mHandlerCaller.obtainMessageIO(MSG_TASK_STARTED,
taskId, intent));
@@ -279,6 +283,7 @@ public abstract class VoiceInteractionSession implements KeyEvent.Callback {
static final int MSG_TASK_FINISHED = 101;
static final int MSG_CLOSE_SYSTEM_DIALOGS = 102;
static final int MSG_DESTROY = 103;
+ static final int MSG_HANDLE_ASSIST = 104;
class MyCallbacks implements HandlerCaller.Callback, SoftInputWindow.Callback {
@Override
@@ -341,6 +346,10 @@ public abstract class VoiceInteractionSession implements KeyEvent.Callback {
if (DEBUG) Log.d(TAG, "doDestroy");
doDestroy();
break;
+ case MSG_HANDLE_ASSIST:
+ if (DEBUG) Log.d(TAG, "onHandleAssist: " + (Bundle)msg.obj);
+ onHandleAssist((Bundle) msg.obj);
+ break;
}
}
@@ -441,10 +450,11 @@ public abstract class VoiceInteractionSession implements KeyEvent.Callback {
}
}
- void doCreate(IVoiceInteractionManagerService service, IBinder token, Bundle args) {
+ void doCreate(IVoiceInteractionManagerService service, IBinder token, Bundle args,
+ int startFlags) {
mSystemService = service;
mToken = token;
- onCreate(args);
+ onCreate(args, startFlags);
}
void doDestroy() {
@@ -585,12 +595,7 @@ public abstract class VoiceInteractionSession implements KeyEvent.Callback {
}
}
- /**
- * Initiatize a new session.
- *
- * @param args The arguments that were supplied to
- * {@link VoiceInteractionService#startSession VoiceInteractionService.startSession}.
- */
+ /** @hide */
public void onCreate(Bundle args) {
mTheme = mTheme != 0 ? mTheme
: com.android.internal.R.style.Theme_DeviceDefault_VoiceInteractionSession;
@@ -598,14 +603,26 @@ public abstract class VoiceInteractionSession implements KeyEvent.Callback {
Context.LAYOUT_INFLATER_SERVICE);
mWindow = new SoftInputWindow(mContext, "VoiceInteractionSession", mTheme,
mCallbacks, this, mDispatcherState,
- WindowManager.LayoutParams.TYPE_VOICE_INTERACTION, Gravity.TOP, true);
+ WindowManager.LayoutParams.TYPE_VOICE_INTERACTION, Gravity.BOTTOM, true);
mWindow.getWindow().addFlags(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);
initViews();
- mWindow.getWindow().setLayout(MATCH_PARENT, WRAP_CONTENT);
+ mWindow.getWindow().setLayout(MATCH_PARENT, MATCH_PARENT);
mWindow.setToken(mToken);
}
/**
+ * Initiatize a new session.
+ *
+ * @param args The arguments that were supplied to
+ * {@link VoiceInteractionService#startSession VoiceInteractionService.startSession}.
+ * @param startFlags The start flags originally provided to
+ * {@link VoiceInteractionService#startSession VoiceInteractionService.startSession}.
+ */
+ public void onCreate(Bundle args, int startFlags) {
+ onCreate(args);
+ }
+
+ /**
* Last callback to the session as it is being finished.
*/
public void onDestroy() {
@@ -622,10 +639,13 @@ public abstract class VoiceInteractionSession implements KeyEvent.Callback {
mContentFrame.removeAllViews();
mContentFrame.addView(view, new FrameLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
- ViewGroup.LayoutParams.WRAP_CONTENT));
+ ViewGroup.LayoutParams.MATCH_PARENT));
}
+ public void onHandleAssist(Bundle assistBundle) {
+ }
+
public boolean onKeyDown(int keyCode, KeyEvent event) {
return false;
}
@@ -657,19 +677,19 @@ public abstract class VoiceInteractionSession implements KeyEvent.Callback {
/**
* Compute the interesting insets into your UI. The default implementation
- * uses the entire window frame as the insets. The default touchable
- * insets are {@link Insets#TOUCHABLE_INSETS_FRAME}.
+ * sets {@link Insets#contentInsets outInsets.contentInsets.top} to the height
+ * of the window, meaning it should not adjust content underneath. The default touchable
+ * insets are {@link Insets#TOUCHABLE_INSETS_FRAME}, meaning it consumes all touch
+ * events within its window frame.
*
* @param outInsets Fill in with the current UI insets.
*/
public void onComputeInsets(Insets outInsets) {
- int[] loc = mTmpLocation;
- View decor = getWindow().getWindow().getDecorView();
- decor.getLocationInWindow(loc);
- outInsets.contentInsets.top = 0;
outInsets.contentInsets.left = 0;
- outInsets.contentInsets.right = 0;
outInsets.contentInsets.bottom = 0;
+ outInsets.contentInsets.right = 0;
+ View decor = getWindow().getWindow().getDecorView();
+ outInsets.contentInsets.top = decor.getHeight();
outInsets.touchableInsets = Insets.TOUCHABLE_INSETS_FRAME;
outInsets.touchableRegion.setEmpty();
}
diff --git a/core/java/android/service/voice/VoiceInteractionSessionService.java b/core/java/android/service/voice/VoiceInteractionSessionService.java
index e793849..008d55f 100644
--- a/core/java/android/service/voice/VoiceInteractionSessionService.java
+++ b/core/java/android/service/voice/VoiceInteractionSessionService.java
@@ -40,9 +40,9 @@ public abstract class VoiceInteractionSessionService extends Service {
VoiceInteractionSession mSession;
IVoiceInteractionSessionService mInterface = new IVoiceInteractionSessionService.Stub() {
- public void newSession(IBinder token, Bundle args) {
- mHandlerCaller.sendMessage(mHandlerCaller.obtainMessageOO(MSG_NEW_SESSION,
- token, args));
+ public void newSession(IBinder token, Bundle args, int startFlags) {
+ mHandlerCaller.sendMessage(mHandlerCaller.obtainMessageIOO(MSG_NEW_SESSION,
+ startFlags, token, args));
}
};
@@ -54,7 +54,7 @@ public abstract class VoiceInteractionSessionService extends Service {
SomeArgs args = (SomeArgs)msg.obj;
switch (msg.what) {
case MSG_NEW_SESSION:
- doNewSession((IBinder)args.arg1, (Bundle)args.arg2);
+ doNewSession((IBinder)args.arg1, (Bundle)args.arg2, args.argi1);
break;
}
}
@@ -76,7 +76,7 @@ public abstract class VoiceInteractionSessionService extends Service {
return mInterface.asBinder();
}
- void doNewSession(IBinder token, Bundle args) {
+ void doNewSession(IBinder token, Bundle args, int startFlags) {
if (mSession != null) {
mSession.doDestroy();
mSession = null;
@@ -84,7 +84,7 @@ public abstract class VoiceInteractionSessionService extends Service {
mSession = onNewSession(args);
try {
mSystemService.deliverNewSession(token, mSession.mSession, mSession.mInteractor);
- mSession.doCreate(mSystemService, token, args);
+ mSession.doCreate(mSystemService, token, args, startFlags);
} catch (RemoteException e) {
}
}