diff options
10 files changed, 70 insertions, 0 deletions
diff --git a/api/current.txt b/api/current.txt index 79d5ea0..a129a63 100644 --- a/api/current.txt +++ b/api/current.txt @@ -28825,6 +28825,7 @@ package android.service.voice { method public void onHandleAssist(android.os.Bundle, android.app.assist.AssistStructure, android.app.assist.AssistContent); method public void onHandleScreenshot(android.graphics.Bitmap); method public void onHide(); + method public void onLockscreenShown(); method public boolean onKeyDown(int, android.view.KeyEvent); method public boolean onKeyLongPress(int, android.view.KeyEvent); method public boolean onKeyMultiple(int, int, android.view.KeyEvent); diff --git a/api/system-current.txt b/api/system-current.txt index 0af72d5..c2fd0d1 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -30977,6 +30977,7 @@ package android.service.voice { method public void onHandleAssist(android.os.Bundle, android.app.assist.AssistStructure, android.app.assist.AssistContent); method public void onHandleScreenshot(android.graphics.Bitmap); method public void onHide(); + method public void onLockscreenShown(); method public boolean onKeyDown(int, android.view.KeyEvent); method public boolean onKeyLongPress(int, android.view.KeyEvent); method public boolean onKeyMultiple(int, int, android.view.KeyEvent); diff --git a/core/java/android/service/voice/IVoiceInteractionSession.aidl b/core/java/android/service/voice/IVoiceInteractionSession.aidl index 8fe84e1..dbc28f7 100644 --- a/core/java/android/service/voice/IVoiceInteractionSession.aidl +++ b/core/java/android/service/voice/IVoiceInteractionSession.aidl @@ -35,5 +35,6 @@ oneway interface IVoiceInteractionSession { void taskStarted(in Intent intent, int taskId); void taskFinished(in Intent intent, int taskId); void closeSystemDialogs(); + void onLockscreenShown(); void destroy(); } diff --git a/core/java/android/service/voice/VoiceInteractionSession.java b/core/java/android/service/voice/VoiceInteractionSession.java index f08e93c..f647aa6 100644 --- a/core/java/android/service/voice/VoiceInteractionSession.java +++ b/core/java/android/service/voice/VoiceInteractionSession.java @@ -265,6 +265,11 @@ public class VoiceInteractionSession implements KeyEvent.Callback, ComponentCall } @Override + public void onLockscreenShown() { + mHandlerCaller.sendMessage(mHandlerCaller.obtainMessage(MSG_ON_LOCKSCREEN_SHOWN)); + } + + @Override public void destroy() { mHandlerCaller.sendMessage(mHandlerCaller.obtainMessage(MSG_DESTROY)); } @@ -674,6 +679,7 @@ public class VoiceInteractionSession implements KeyEvent.Callback, ComponentCall static final int MSG_HANDLE_SCREENSHOT = 105; static final int MSG_SHOW = 106; static final int MSG_HIDE = 107; + static final int MSG_ON_LOCKSCREEN_SHOWN = 108; class MyCallbacks implements HandlerCaller.Callback, SoftInputWindow.Callback { @Override @@ -752,6 +758,10 @@ public class VoiceInteractionSession implements KeyEvent.Callback, ComponentCall if (DEBUG) Log.d(TAG, "doHide"); doHide(); break; + case MSG_ON_LOCKSCREEN_SHOWN: + if (DEBUG) Log.d(TAG, "onLockscreenShown"); + onLockscreenShown(); + break; } if (args != null) { args.recycle(); @@ -1296,6 +1306,13 @@ public class VoiceInteractionSession implements KeyEvent.Callback, ComponentCall hide(); } + /** + * Called when the lockscreen was shown. + */ + public void onLockscreenShown() { + hide(); + } + @Override public void onConfigurationChanged(Configuration newConfig) { } diff --git a/core/java/com/android/internal/app/AssistUtils.java b/core/java/com/android/internal/app/AssistUtils.java index 0910daf..d552e54 100644 --- a/core/java/com/android/internal/app/AssistUtils.java +++ b/core/java/com/android/internal/app/AssistUtils.java @@ -122,6 +122,16 @@ public class AssistUtils { } } + public void onLockscreenShown() { + try { + if (mVoiceInteractionManagerService != null) { + mVoiceInteractionManagerService.onLockscreenShown(); + } + } catch (RemoteException e) { + Log.w(TAG, "Failed to call onLockscreenShown", e); + } + } + public ComponentName getAssistComponentForUser(int userId) { final String setting = Settings.Secure.getStringForUser(mContext.getContentResolver(), Settings.Secure.ASSISTANT, userId); diff --git a/core/java/com/android/internal/app/IVoiceInteractionManagerService.aidl b/core/java/com/android/internal/app/IVoiceInteractionManagerService.aidl index dc946ab..1a963f3 100644 --- a/core/java/com/android/internal/app/IVoiceInteractionManagerService.aidl +++ b/core/java/com/android/internal/app/IVoiceInteractionManagerService.aidl @@ -131,4 +131,9 @@ interface IVoiceInteractionManagerService { * from the lockscreen. */ boolean activeServiceSupportsLaunchFromKeyguard(); + + /** + * Called when the lockscreen got shown. + */ + void onLockscreenShown(); } diff --git a/packages/SystemUI/src/com/android/systemui/assist/AssistManager.java b/packages/SystemUI/src/com/android/systemui/assist/AssistManager.java index f66a7dd..9265b63 100644 --- a/packages/SystemUI/src/com/android/systemui/assist/AssistManager.java +++ b/packages/SystemUI/src/com/android/systemui/assist/AssistManager.java @@ -304,4 +304,8 @@ public class AssistManager { public void onUserSwitched(int newUserId) { updateAssistInfo(); } + + public void onLockscreenShown() { + mAssistUtils.onLockscreenShown(); + } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java index 6ebb012..46beed7 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java @@ -3311,6 +3311,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, mDraggedDownRow.notifyHeightChanged(false /* needsAnimation */); mDraggedDownRow = null; } + mAssistManager.onLockscreenShown(); } private void onLaunchTransitionFadingEnded() { diff --git a/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java b/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java index b57c413..a8874d0 100644 --- a/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java +++ b/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java @@ -894,6 +894,28 @@ public class VoiceInteractionManagerService extends SystemService { } @Override + public void onLockscreenShown() { + enforceCallingPermission(Manifest.permission.ACCESS_VOICE_INTERACTION_SERVICE); + synchronized (this) { + if (mImpl == null) { + return; + } + final long caller = Binder.clearCallingIdentity(); + try { + if (mImpl.mActiveSession != null && mImpl.mActiveSession.mSession != null) { + try { + mImpl.mActiveSession.mSession.onLockscreenShown(); + } catch (RemoteException e) { + Log.w(TAG, "Failed to call onLockscreenShown", e); + } + } + } finally { + Binder.restoreCallingIdentity(caller); + } + } + } + + @Override public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { if (mContext.checkCallingOrSelfPermission(Manifest.permission.DUMP) != PackageManager.PERMISSION_GRANTED) { diff --git a/tests/Assist/src/com/android/test/assist/AssistInteractionSession.java b/tests/Assist/src/com/android/test/assist/AssistInteractionSession.java index 43f1e32..851bda9 100644 --- a/tests/Assist/src/com/android/test/assist/AssistInteractionSession.java +++ b/tests/Assist/src/com/android/test/assist/AssistInteractionSession.java @@ -24,6 +24,7 @@ import android.graphics.Color; import android.os.Bundle; import android.os.Handler; import android.service.voice.VoiceInteractionSession; +import android.util.Log; import android.view.View; import android.view.ViewAnimationUtils; import android.view.ViewTreeObserver; @@ -69,6 +70,7 @@ public class AssistInteractionSession extends VoiceInteractionSession { @Override public void onCreate() { + super.onCreate(); // Simulate slowness of Assist app try { Thread.sleep(1000); @@ -105,6 +107,12 @@ public class AssistInteractionSession extends VoiceInteractionSession { } } + @Override + public void onLockscreenShown() { + super.onLockscreenShown(); + Log.i("Assistant", "Lockscreen was shown"); + } + private void playAssistAnimation() { Interpolator linearOutSlowIn = AnimationUtils.loadInterpolator(mBackground.getContext(), android.R.interpolator.linear_out_slow_in); |