diff options
| author | Dianne Hackborn <hackbod@google.com> | 2015-03-16 17:15:53 -0700 |
|---|---|---|
| committer | Dianne Hackborn <hackbod@google.com> | 2015-03-17 16:45:51 -0700 |
| commit | 27eac1d58fe0b7ca3a2e27f5ed64eff232745f45 (patch) | |
| tree | c1f0dc2a368ab1c7db1be81dc02b020eea0d1628 /core/java | |
| parent | 7438f814f16ff1ced53d93a2fe9e3973490f3843 (diff) | |
| download | frameworks_base-27eac1d58fe0b7ca3a2e27f5ed64eff232745f45.zip frameworks_base-27eac1d58fe0b7ca3a2e27f5ed64eff232745f45.tar.gz frameworks_base-27eac1d58fe0b7ca3a2e27f5ed64eff232745f45.tar.bz2 | |
Add ability to get a screenshot for assist.
New flag you pass in to startSession() to say you want it,
new callback on VoiceInteractionSession to receive it.
Change-Id: I61fdcfdee41a60d46036a2ef16681a9b4181115a
Diffstat (limited to 'core/java')
5 files changed, 58 insertions, 6 deletions
diff --git a/core/java/android/service/voice/IVoiceInteractionSession.aidl b/core/java/android/service/voice/IVoiceInteractionSession.aidl index 797457a..4f4b2d5 100644 --- a/core/java/android/service/voice/IVoiceInteractionSession.aidl +++ b/core/java/android/service/voice/IVoiceInteractionSession.aidl @@ -17,6 +17,7 @@ package android.service.voice; import android.content.Intent; +import android.graphics.Bitmap; import android.os.Bundle; /** @@ -26,6 +27,7 @@ oneway interface IVoiceInteractionSession { void show(in Bundle sessionArgs, int flags); void hide(); void handleAssist(in Bundle assistData); + void handleScreenshot(in Bitmap screenshot); void taskStarted(in Intent intent, int taskId); void taskFinished(in Intent intent, int taskId); void closeSystemDialogs(); diff --git a/core/java/android/service/voice/VoiceInteractionService.java b/core/java/android/service/voice/VoiceInteractionService.java index 0c01b25..419b92b 100644 --- a/core/java/android/service/voice/VoiceInteractionService.java +++ b/core/java/android/service/voice/VoiceInteractionService.java @@ -71,11 +71,17 @@ public class VoiceInteractionService extends Service { public static final String SERVICE_META_DATA = "android.voice_interaction"; /** - * Flag for use with {@link #showSession: request that the session be started with + * Flag for use with {@link #showSession}: request that the session be started with * assist data from the currently focused activity. */ public static final int START_WITH_ASSIST = 1<<0; + /** + * Flag for use with {@link #showSession}: request that the session be started with + * a screen shot of the currently focused activity. + */ + public static final int START_WITH_SCREENSHOT = 1<<1; + IVoiceInteractionService mInterface = new IVoiceInteractionService.Stub() { @Override public void ready() { mHandler.sendEmptyMessage(MSG_READY); diff --git a/core/java/android/service/voice/VoiceInteractionSession.java b/core/java/android/service/voice/VoiceInteractionSession.java index 11eaa06..7a5bb90 100644 --- a/core/java/android/service/voice/VoiceInteractionSession.java +++ b/core/java/android/service/voice/VoiceInteractionSession.java @@ -22,6 +22,7 @@ import android.app.VoiceInteractor; import android.content.Context; import android.content.Intent; import android.content.res.TypedArray; +import android.graphics.Bitmap; import android.graphics.Rect; import android.graphics.Region; import android.inputmethodservice.SoftInputWindow; @@ -179,6 +180,12 @@ public abstract class VoiceInteractionSession implements KeyEvent.Callback { } @Override + public void handleScreenshot(Bitmap screenshot) { + mHandlerCaller.sendMessage(mHandlerCaller.obtainMessageO(MSG_HANDLE_SCREENSHOT, + screenshot)); + } + + @Override public void taskStarted(Intent intent, int taskId) { mHandlerCaller.sendMessage(mHandlerCaller.obtainMessageIO(MSG_TASK_STARTED, taskId, intent)); @@ -323,8 +330,9 @@ public abstract class VoiceInteractionSession implements KeyEvent.Callback { static final int MSG_CLOSE_SYSTEM_DIALOGS = 102; static final int MSG_DESTROY = 103; static final int MSG_HANDLE_ASSIST = 104; - static final int MSG_SHOW = 105; - static final int MSG_HIDE = 106; + static final int MSG_HANDLE_SCREENSHOT = 105; + static final int MSG_SHOW = 106; + static final int MSG_HIDE = 107; class MyCallbacks implements HandlerCaller.Callback, SoftInputWindow.Callback { @Override @@ -396,9 +404,13 @@ public abstract class VoiceInteractionSession implements KeyEvent.Callback { doDestroy(); break; case MSG_HANDLE_ASSIST: - if (DEBUG) Log.d(TAG, "onHandleAssist: " + (Bundle)msg.obj); + if (DEBUG) Log.d(TAG, "onHandleAssist: " + msg.obj); onHandleAssist((Bundle) msg.obj); break; + case MSG_HANDLE_SCREENSHOT: + if (DEBUG) Log.d(TAG, "onHandleScreenshot: " + msg.obj); + onHandleScreenshot((Bitmap) msg.obj); + break; case MSG_SHOW: if (DEBUG) Log.d(TAG, "doShow: args=" + msg.obj + " flags=" + msg.arg1); @@ -768,6 +780,9 @@ public abstract class VoiceInteractionSession implements KeyEvent.Callback { public void onHandleAssist(Bundle assistBundle) { } + public void onHandleScreenshot(Bitmap screenshot) { + } + public boolean onKeyDown(int keyCode, KeyEvent event) { return false; } diff --git a/core/java/android/view/IWindowManager.aidl b/core/java/android/view/IWindowManager.aidl index 8ac8bc5..d6625c8 100644 --- a/core/java/android/view/IWindowManager.aidl +++ b/core/java/android/view/IWindowManager.aidl @@ -16,6 +16,7 @@ package android.view; +import com.android.internal.app.IAssistScreenshotReceiver; import com.android.internal.view.IInputContext; import com.android.internal.view.IInputMethodClient; @@ -220,10 +221,14 @@ interface IWindowManager boolean isRotationFrozen(); /** + * Used only for assist -- request a screenshot of the current application. + */ + boolean requestAssistScreenshot(IAssistScreenshotReceiver receiver); + + /** * Create a screenshot of the applications currently displayed. */ - Bitmap screenshotApplications(IBinder appToken, int displayId, int maxWidth, - int maxHeight, boolean force565); + Bitmap screenshotApplications(IBinder appToken, int displayId, int maxWidth, int maxHeight); /** * Called by the status bar to notify Views of changes to System UI visiblity. diff --git a/core/java/com/android/internal/app/IAssistScreenshotReceiver.aidl b/core/java/com/android/internal/app/IAssistScreenshotReceiver.aidl new file mode 100644 index 0000000..a987a16 --- /dev/null +++ b/core/java/com/android/internal/app/IAssistScreenshotReceiver.aidl @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2015 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.internal.app; + +import android.graphics.Bitmap; + +/** @hide */ +oneway interface IAssistScreenshotReceiver { + void send(in Bitmap screenshot); +} |
