am a2bf6181: am 2c29deaa: am 6be441c5: Merge "Add mechanism to kick keyguard to show the assistant" into jb-mr1-lockscreen-dev

* commit 'a2bf6181dfca0f93461fc041f2bd2444551a4515':
  Add mechanism to kick keyguard to show the assistant
This commit is contained in:
Jim Miller
2012-11-08 15:47:04 -08:00
committed by Android Git Automerger
13 changed files with 177 additions and 46 deletions

View File

@ -1,16 +1,16 @@
/* /*
** Copyright 2006, The Android Open Source Project ** Copyright 2006, The Android Open Source Project
** **
** Licensed under the Apache License, Version 2.0 (the "License"); ** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License. ** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at ** You may obtain a copy of the License at
** **
** http://www.apache.org/licenses/LICENSE-2.0 ** http://www.apache.org/licenses/LICENSE-2.0
** **
** Unless required by applicable law or agreed to in writing, software ** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS, ** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and ** See the License for the specific language governing permissions and
** limitations under the License. ** limitations under the License.
*/ */
@ -107,7 +107,7 @@ interface IWindowManager
Configuration updateOrientationFromAppTokens(in Configuration currentConfig, Configuration updateOrientationFromAppTokens(in Configuration currentConfig,
IBinder freezeThisOneIfNeeded); IBinder freezeThisOneIfNeeded);
void setNewConfiguration(in Configuration config); void setNewConfiguration(in Configuration config);
void startFreezingScreen(int exitAnim, int enterAnim); void startFreezingScreen(int exitAnim, int enterAnim);
void stopFreezingScreen(); void stopFreezingScreen();
@ -121,13 +121,13 @@ interface IWindowManager
void dismissKeyguard(); void dismissKeyguard();
void closeSystemDialogs(String reason); void closeSystemDialogs(String reason);
// These can only be called with the SET_ANIMATON_SCALE permission. // These can only be called with the SET_ANIMATON_SCALE permission.
float getAnimationScale(int which); float getAnimationScale(int which);
float[] getAnimationScales(); float[] getAnimationScales();
void setAnimationScale(int which, float scale); void setAnimationScale(int which, float scale);
void setAnimationScales(in float[] scales); void setAnimationScales(in float[] scales);
// For testing // For testing
void setInTouchMode(boolean showFocus); void setInTouchMode(boolean showFocus);
@ -161,7 +161,7 @@ interface IWindowManager
* {@link android.view.Surface}. * {@link android.view.Surface}.
*/ */
int getRotation(); int getRotation();
/** /**
* Watch the rotation of the screen. Returns the current rotation, * Watch the rotation of the screen. Returns the current rotation,
* calls back when it changes. * calls back when it changes.
@ -175,24 +175,24 @@ interface IWindowManager
*/ */
int getPreferredOptionsPanelGravity(); int getPreferredOptionsPanelGravity();
/** /**
* Lock the device orientation to the specified rotation, or to the * Lock the device orientation to the specified rotation, or to the
* current rotation if -1. Sensor input will be ignored until * current rotation if -1. Sensor input will be ignored until
* thawRotation() is called. * thawRotation() is called.
* @hide * @hide
*/ */
void freezeRotation(int rotation); void freezeRotation(int rotation);
/** /**
* Release the orientation lock imposed by freezeRotation(). * Release the orientation lock imposed by freezeRotation().
* @hide * @hide
*/ */
void thawRotation(); void thawRotation();
/** /**
* Create a screenshot of the applications currently displayed. * Create a screenshot of the applications currently displayed.
*/ */
Bitmap screenshotApplications(IBinder appToken, int displayId, int maxWidth, int maxHeight); Bitmap screenshotApplications(IBinder appToken, int displayId, int maxWidth, int maxHeight);
/** /**
* Called by the status bar to notify Views of changes to System UI visiblity. * Called by the status bar to notify Views of changes to System UI visiblity.
@ -259,4 +259,10 @@ interface IWindowManager
* Device is in safe mode. * Device is in safe mode.
*/ */
boolean isSafeModeEnabled(); boolean isSafeModeEnabled();
/**
* Tell keyguard to show the assistant (Intent.ACTION_ASSIST) after asking for the user's
* credentials.
*/
void showAssistant();
} }

View File

@ -1136,4 +1136,10 @@ public interface WindowManagerPolicy {
* @param args additional arguments to the dump request. * @param args additional arguments to the dump request.
*/ */
public void dump(String prefix, PrintWriter writer, String[] args); public void dump(String prefix, PrintWriter writer, String[] args);
/**
* Ask keyguard to invoke the assist intent after dismissing keyguard
* {@link android.content.Intent#ACTION_ASSIST}
*/
public void showAssistant();
} }

View File

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
** Copyright 2012, 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.
*/
-->
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false" android:zAdjustment="top">
<alpha android:fromAlpha="0" android:toAlpha="1.0"
android:fillEnabled="true" android:fillBefore="true" android:fillAfter="true"
android:interpolator="@android:interpolator/decelerate_cubic"
android:duration="300"/>
<translate android:fromYDelta="100%" android:toYDelta="0"
android:fillEnabled="true" android:fillBefore="true" android:fillAfter="true"
android:interpolator="@android:interpolator/decelerate_cubic"
android:duration="300" />
</set>

View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
** Copyright 2012, 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.
*/
-->
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator"
android:fromXDelta="0" android:toXDelta="0"
android:duration="300" />

View File

@ -1189,6 +1189,9 @@
<java-symbol type="anim" name="keyguard_security_animate_out" /> <java-symbol type="anim" name="keyguard_security_animate_out" />
<java-symbol type="anim" name="keyguard_security_fade_in" /> <java-symbol type="anim" name="keyguard_security_fade_in" />
<java-symbol type="anim" name="keyguard_security_fade_out" /> <java-symbol type="anim" name="keyguard_security_fade_out" />
<java-symbol type="anim" name="keyguard_action_assist_exit" />
<java-symbol type="anim" name="keyguard_action_assist_enter" />
<java-symbol type="array" name="config_keyboardTapVibePattern" /> <java-symbol type="array" name="config_keyboardTapVibePattern" />
<java-symbol type="array" name="config_longPressVibePattern" /> <java-symbol type="array" name="config_longPressVibePattern" />
<java-symbol type="array" name="config_safeModeDisabledVibePattern" /> <java-symbol type="array" name="config_safeModeDisabledVibePattern" />

View File

@ -26,11 +26,13 @@ import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.res.Resources; import android.content.res.Resources;
import android.os.RemoteException; import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.UserHandle; import android.os.UserHandle;
import android.os.Vibrator; import android.os.Vibrator;
import android.provider.Settings; import android.provider.Settings;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.util.Slog; import android.util.Slog;
import android.view.IWindowManager;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -62,6 +64,7 @@ public class SearchPanelView extends FrameLayout implements
private boolean mShowing; private boolean mShowing;
private View mSearchTargetsContainer; private View mSearchTargetsContainer;
private GlowPadView mGlowPadView; private GlowPadView mGlowPadView;
private IWindowManager mWm;
public SearchPanelView(Context context, AttributeSet attrs) { public SearchPanelView(Context context, AttributeSet attrs) {
this(context, attrs, 0); this(context, attrs, 0);
@ -70,6 +73,7 @@ public class SearchPanelView extends FrameLayout implements
public SearchPanelView(Context context, AttributeSet attrs, int defStyle) { public SearchPanelView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle); super(context, attrs, defStyle);
mContext = context; mContext = context;
mWm = IWindowManager.Stub.asInterface(ServiceManager.getService("window"));
} }
private void startAssistActivity() { private void startAssistActivity() {
@ -77,28 +81,13 @@ public class SearchPanelView extends FrameLayout implements
// Close Recent Apps if needed // Close Recent Apps if needed
mBar.animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_SEARCH_PANEL); mBar.animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_SEARCH_PANEL);
// Launch Assist
Intent intent = ((SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE))
.getAssistIntent(mContext, UserHandle.USER_CURRENT);
if (intent == null) return;
// Dismiss the keyguard if possible. XXX: TODO: invoke bouncer.
try { try {
ActivityManagerNative.getDefault().dismissKeyguardOnNextActivity(); mWm.showAssistant();
} catch (RemoteException e) { } catch (RemoteException e) {
// too bad, so sad...
} }
onAnimationStarted();
try {
ActivityOptions opts = ActivityOptions.makeCustomAnimation(mContext,
R.anim.search_launch_enter, R.anim.search_launch_exit,
getHandler(), this);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
mContext.startActivityAsUser(intent, opts.toBundle(),
new UserHandle(UserHandle.USER_CURRENT));
} catch (ActivityNotFoundException e) {
Slog.w(TAG, "Activity not found for " + intent.getAction());
onAnimationStarted();
}
} }
class GlowPadTriggerListener implements GlowPadView.OnTriggerListener { class GlowPadTriggerListener implements GlowPadView.OnTriggerListener {

View File

@ -4539,6 +4539,11 @@ public class PhoneWindowManager implements WindowManagerPolicy {
setLastInputMethodWindowLw(null, null); setLastInputMethodWindowLw(null, null);
} }
@Override
public void showAssistant() {
mKeyguardMediator.showAssistant();
}
@Override @Override
public void dump(String prefix, PrintWriter pw, String[] args) { public void dump(String prefix, PrintWriter pw, String[] args) {
pw.print(prefix); pw.print("mSafeMode="); pw.print(mSafeMode); pw.print(prefix); pw.print("mSafeMode="); pw.print(mSafeMode);

View File

@ -20,11 +20,13 @@ import android.app.Activity;
import android.app.ActivityManager; import android.app.ActivityManager;
import android.app.ActivityOptions; import android.app.ActivityOptions;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.app.SearchManager;
import android.app.admin.DevicePolicyManager; import android.app.admin.DevicePolicyManager;
import android.appwidget.AppWidgetHost; import android.appwidget.AppWidgetHost;
import android.appwidget.AppWidgetHostView; import android.appwidget.AppWidgetHostView;
import android.appwidget.AppWidgetManager; import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProviderInfo; import android.appwidget.AppWidgetProviderInfo;
import android.content.ActivityNotFoundException;
import android.content.ComponentName; import android.content.ComponentName;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
@ -37,6 +39,7 @@ import android.os.Looper;
import android.os.Parcel; import android.os.Parcel;
import android.os.Parcelable; import android.os.Parcelable;
import android.os.SystemClock; import android.os.SystemClock;
import android.os.UserHandle;
import android.os.UserManager; import android.os.UserManager;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.util.Log; import android.util.Log;
@ -1442,4 +1445,31 @@ public class KeyguardHostView extends KeyguardViewBase {
public void dismiss() { public void dismiss() {
showNextSecurityScreenOrFinish(false); 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);
}
} }

View File

@ -425,4 +425,10 @@ public class KeyguardViewManager {
public synchronized boolean isShowing() { public synchronized boolean isShowing() {
return (mKeyguardHost != null && mKeyguardHost.getVisibility() == View.VISIBLE); return (mKeyguardHost != null && mKeyguardHost.getVisibility() == View.VISIBLE);
} }
public void showAssistant() {
if (mKeyguardView != null) {
mKeyguardView.showAssistant();
}
}
} }

View File

@ -116,6 +116,7 @@ public class KeyguardViewMediator {
private static final int KEYGUARD_DONE_AUTHENTICATING = 11; private static final int KEYGUARD_DONE_AUTHENTICATING = 11;
private static final int SET_HIDDEN = 12; private static final int SET_HIDDEN = 12;
private static final int KEYGUARD_TIMEOUT = 13; 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) * The default amount of time we stay awake (used for all key input)
@ -1130,6 +1131,9 @@ public class KeyguardViewMediator {
doKeyguardLocked((Bundle) msg.obj); doKeyguardLocked((Bundle) msg.obj);
} }
break; break;
case SHOW_ASSISTANT:
handleShowAssistant();
break;
} }
} }
}; };
@ -1393,4 +1397,13 @@ public class KeyguardViewMediator {
return mKeyguardDonePending || !isSecure(); return mKeyguardDonePending || !isSecure();
} }
public void showAssistant() {
Message msg = mHandler.obtainMessage(SHOW_ASSISTANT);
mHandler.sendMessage(msg);
}
public void handleShowAssistant() {
mKeyguardViewManager.showAssistant();
}
} }

View File

@ -120,6 +120,7 @@ public class KeyguardViewStateManager implements
// once the user swipes a page we clear that behavior // once the user swipes a page we clear that behavior
if (mKeyguardHostView != null) { if (mKeyguardHostView != null) {
mKeyguardHostView.clearAppWidgetToShow(); mKeyguardHostView.clearAppWidgetToShow();
mKeyguardHostView.setOnDismissAction(null);
} }
if (mHideHintsRunnable != null) { if (mHideHintsRunnable != null) {
mMainQueue.removeCallbacks(mHideHintsRunnable); mMainQueue.removeCallbacks(mHideHintsRunnable);
@ -316,6 +317,9 @@ public class KeyguardViewStateManager implements
mKeyguardWidgetPager.zoomOutToBouncer(); mKeyguardWidgetPager.zoomOutToBouncer();
} else { } else {
mKeyguardWidgetPager.zoomInFromBouncer(); mKeyguardWidgetPager.zoomInFromBouncer();
if (mKeyguardHostView != null) {
mKeyguardHostView.setOnDismissAction(null);
}
} }
} }
} }

View File

@ -10352,6 +10352,15 @@ public class WindowManagerService extends IWindowManager.Stub
return mSafeMode; return mSafeMode;
} }
public void showAssistant() {
// TODO: What permission?
if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DEVICE_POWER)
!= PackageManager.PERMISSION_GRANTED) {
return;
}
mPolicy.showAssistant();
}
void dumpPolicyLocked(PrintWriter pw, String[] args, boolean dumpAll) { void dumpPolicyLocked(PrintWriter pw, String[] args, boolean dumpAll) {
pw.println("WINDOW MANAGER POLICY STATE (dumpsys window policy)"); pw.println("WINDOW MANAGER POLICY STATE (dumpsys window policy)");
mPolicy.dump(" ", pw, args); mPolicy.dump(" ", pw, args);

View File

@ -452,6 +452,11 @@ public class IWindowManagerImpl implements IWindowManager {
return false; return false;
} }
@Override
public void showAssistant() {
}
@Override @Override
public IBinder getFocusedWindowToken() { public IBinder getFocusedWindowToken() {
// TODO Auto-generated method stub // TODO Auto-generated method stub