From 4eeb4f664ac6b5901a8e874dcf70c0382295f792 Mon Sep 17 00:00:00 2001 From: Jim Miller Date: Thu, 8 Nov 2012 00:04:29 -0800 Subject: Add mechanism to kick keyguard to show the assistant Fixes bug 7499778 Change-Id: Ic9ea514feb489feeee6716f40bdb9792842f9515 --- .../internal/policy/impl/PhoneWindowManager.java | 5 ++++ .../policy/impl/keyguard/KeyguardHostView.java | 30 ++++++++++++++++++++++ .../policy/impl/keyguard/KeyguardViewManager.java | 6 +++++ .../policy/impl/keyguard/KeyguardViewMediator.java | 13 ++++++++++ .../impl/keyguard/KeyguardViewStateManager.java | 4 +++ 5 files changed, 58 insertions(+) (limited to 'policy') diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java index 54bf20d..d9c07f8 100755 --- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java +++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java @@ -4540,6 +4540,11 @@ public class PhoneWindowManager implements WindowManagerPolicy { } @Override + public void showAssistant() { + mKeyguardMediator.showAssistant(); + } + + @Override public void dump(String prefix, PrintWriter pw, String[] args) { pw.print(prefix); pw.print("mSafeMode="); pw.print(mSafeMode); pw.print(" mSystemReady="); pw.print(mSystemReady); diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java index e89888c..916d966 100644 --- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java +++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java @@ -20,11 +20,13 @@ import android.app.Activity; import android.app.ActivityManager; import android.app.ActivityOptions; import android.app.AlertDialog; +import android.app.SearchManager; import android.app.admin.DevicePolicyManager; import android.appwidget.AppWidgetHost; import android.appwidget.AppWidgetHostView; import android.appwidget.AppWidgetManager; import android.appwidget.AppWidgetProviderInfo; +import android.content.ActivityNotFoundException; import android.content.ComponentName; import android.content.Context; import android.content.Intent; @@ -37,6 +39,7 @@ import android.os.Looper; import android.os.Parcel; import android.os.Parcelable; import android.os.SystemClock; +import android.os.UserHandle; import android.os.UserManager; import android.util.AttributeSet; import android.util.Log; @@ -1436,4 +1439,31 @@ public class KeyguardHostView extends KeyguardViewBase { public void dismiss() { showNextSecurityScreenOrFinish(false); } + + public void showAssistant() { + final Intent intent = ((SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE)) + .getAssistIntent(mContext, UserHandle.USER_CURRENT); + + if (intent == null) return; + + final ActivityOptions opts = ActivityOptions.makeCustomAnimation(mContext, + R.anim.keyguard_action_assist_enter, R.anim.keyguard_action_assist_exit, + getHandler(), null); + + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + setOnDismissAction(new OnDismissAction() { + @Override + public boolean onDismiss() { + try { + mContext.startActivityAsUser(intent, opts.toBundle(), + new UserHandle(UserHandle.USER_CURRENT)); + } catch (ActivityNotFoundException e) { + Slog.w(TAG, "Activity not found for " + intent.getAction()); + } + return false; + } + }); + + mViewStateManager.showBouncer(true); + } } diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewManager.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewManager.java index 365c530..3aab3c0 100644 --- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewManager.java +++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewManager.java @@ -424,4 +424,10 @@ public class KeyguardViewManager { public synchronized boolean isShowing() { return (mKeyguardHost != null && mKeyguardHost.getVisibility() == View.VISIBLE); } + + public void showAssistant() { + if (mKeyguardView != null) { + mKeyguardView.showAssistant(); + } + } } diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewMediator.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewMediator.java index 128930a..23c642d 100644 --- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewMediator.java +++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewMediator.java @@ -116,6 +116,7 @@ public class KeyguardViewMediator { private static final int KEYGUARD_DONE_AUTHENTICATING = 11; private static final int SET_HIDDEN = 12; private static final int KEYGUARD_TIMEOUT = 13; + private static final int SHOW_ASSISTANT = 14; /** * The default amount of time we stay awake (used for all key input) @@ -1130,6 +1131,9 @@ public class KeyguardViewMediator { doKeyguardLocked((Bundle) msg.obj); } break; + case SHOW_ASSISTANT: + handleShowAssistant(); + break; } } }; @@ -1393,4 +1397,13 @@ public class KeyguardViewMediator { return mKeyguardDonePending || !isSecure(); } + public void showAssistant() { + Message msg = mHandler.obtainMessage(SHOW_ASSISTANT); + mHandler.sendMessage(msg); + } + + public void handleShowAssistant() { + mKeyguardViewManager.showAssistant(); + } + } diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewStateManager.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewStateManager.java index b82d7c7..a4063b3 100644 --- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewStateManager.java +++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewStateManager.java @@ -120,6 +120,7 @@ public class KeyguardViewStateManager implements // once the user swipes a page we clear that behavior if (mKeyguardHostView != null) { mKeyguardHostView.clearAppWidgetToShow(); + mKeyguardHostView.setOnDismissAction(null); } if (mHideHintsRunnable != null) { mMainQueue.removeCallbacks(mHideHintsRunnable); @@ -311,6 +312,9 @@ public class KeyguardViewStateManager implements mKeyguardWidgetPager.zoomOutToBouncer(); } else { mKeyguardWidgetPager.zoomInFromBouncer(); + if (mKeyguardHostView != null) { + mKeyguardHostView.setOnDismissAction(null); + } } } } -- cgit v1.1