Skip to content

Commit 6be441c

Browse files
Jim MillerAndroid (Google) Code Review
authored andcommitted
Merge "Add mechanism to kick keyguard to show the assistant" into jb-mr1-lockscreen-dev
2 parents 5dd8b00 + 4eeb4f6 commit 6be441c

File tree

13 files changed

+179
-48
lines changed

13 files changed

+179
-48
lines changed

core/java/android/view/IWindowManager.aidl

Lines changed: 36 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
/*
22
** Copyright 2006, The Android Open Source Project
33
**
4-
** Licensed under the Apache License, Version 2.0 (the "License");
5-
** you may not use this file except in compliance with the License.
6-
** You may obtain a copy of the License at
4+
** Licensed under the Apache License, Version 2.0 (the "License");
5+
** you may not use this file except in compliance with the License.
6+
** You may obtain a copy of the License at
77
**
8-
** http://www.apache.org/licenses/LICENSE-2.0
8+
** http://www.apache.org/licenses/LICENSE-2.0
99
**
10-
** Unless required by applicable law or agreed to in writing, software
11-
** distributed under the License is distributed on an "AS IS" BASIS,
12-
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
** See the License for the specific language governing permissions and
10+
** Unless required by applicable law or agreed to in writing, software
11+
** distributed under the License is distributed on an "AS IS" BASIS,
12+
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
** See the License for the specific language governing permissions and
1414
** limitations under the License.
1515
*/
1616

@@ -107,7 +107,7 @@ interface IWindowManager
107107
Configuration updateOrientationFromAppTokens(in Configuration currentConfig,
108108
IBinder freezeThisOneIfNeeded);
109109
void setNewConfiguration(in Configuration config);
110-
110+
111111
void startFreezingScreen(int exitAnim, int enterAnim);
112112
void stopFreezingScreen();
113113

@@ -121,13 +121,13 @@ interface IWindowManager
121121
void dismissKeyguard();
122122

123123
void closeSystemDialogs(String reason);
124-
124+
125125
// These can only be called with the SET_ANIMATON_SCALE permission.
126126
float getAnimationScale(int which);
127127
float[] getAnimationScales();
128128
void setAnimationScale(int which, float scale);
129129
void setAnimationScales(in float[] scales);
130-
130+
131131
// For testing
132132
void setInTouchMode(boolean showFocus);
133133

@@ -161,7 +161,7 @@ interface IWindowManager
161161
* {@link android.view.Surface}.
162162
*/
163163
int getRotation();
164-
164+
165165
/**
166166
* Watch the rotation of the screen. Returns the current rotation,
167167
* calls back when it changes.
@@ -175,24 +175,24 @@ interface IWindowManager
175175
*/
176176
int getPreferredOptionsPanelGravity();
177177

178-
/**
179-
* Lock the device orientation to the specified rotation, or to the
180-
* current rotation if -1. Sensor input will be ignored until
181-
* thawRotation() is called.
182-
* @hide
183-
*/
184-
void freezeRotation(int rotation);
185-
186-
/**
187-
* Release the orientation lock imposed by freezeRotation().
188-
* @hide
189-
*/
190-
void thawRotation();
191-
192-
/**
193-
* Create a screenshot of the applications currently displayed.
194-
*/
195-
Bitmap screenshotApplications(IBinder appToken, int displayId, int maxWidth, int maxHeight);
178+
/**
179+
* Lock the device orientation to the specified rotation, or to the
180+
* current rotation if -1. Sensor input will be ignored until
181+
* thawRotation() is called.
182+
* @hide
183+
*/
184+
void freezeRotation(int rotation);
185+
186+
/**
187+
* Release the orientation lock imposed by freezeRotation().
188+
* @hide
189+
*/
190+
void thawRotation();
191+
192+
/**
193+
* Create a screenshot of the applications currently displayed.
194+
*/
195+
Bitmap screenshotApplications(IBinder appToken, int displayId, int maxWidth, int maxHeight);
196196

197197
/**
198198
* Called by the status bar to notify Views of changes to System UI visiblity.
@@ -259,4 +259,10 @@ interface IWindowManager
259259
* Device is in safe mode.
260260
*/
261261
boolean isSafeModeEnabled();
262+
263+
/**
264+
* Tell keyguard to show the assistant (Intent.ACTION_ASSIST) after asking for the user's
265+
* credentials.
266+
*/
267+
void showAssistant();
262268
}

core/java/android/view/WindowManagerPolicy.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1136,4 +1136,10 @@ interface OnKeyguardExitResult {
11361136
* @param args additional arguments to the dump request.
11371137
*/
11381138
public void dump(String prefix, PrintWriter writer, String[] args);
1139+
1140+
/**
1141+
* Ask keyguard to invoke the assist intent after dismissing keyguard
1142+
* {@link android.content.Intent#ACTION_ASSIST}
1143+
*/
1144+
public void showAssistant();
11391145
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
/*
4+
** Copyright 2012, The Android Open Source Project
5+
**
6+
** Licensed under the Apache License, Version 2.0 (the "License");
7+
** you may not use this file except in compliance with the License.
8+
** You may obtain a copy of the License at
9+
**
10+
** http://www.apache.org/licenses/LICENSE-2.0
11+
**
12+
** Unless required by applicable law or agreed to in writing, software
13+
** distributed under the License is distributed on an "AS IS" BASIS,
14+
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
** See the License for the specific language governing permissions and
16+
** limitations under the License.
17+
*/
18+
-->
19+
20+
<set xmlns:android="http://schemas.android.com/apk/res/android"
21+
android:shareInterpolator="false" android:zAdjustment="top">
22+
23+
<alpha android:fromAlpha="0" android:toAlpha="1.0"
24+
android:fillEnabled="true" android:fillBefore="true" android:fillAfter="true"
25+
android:interpolator="@android:interpolator/decelerate_cubic"
26+
android:duration="300"/>
27+
28+
<translate android:fromYDelta="100%" android:toYDelta="0"
29+
android:fillEnabled="true" android:fillBefore="true" android:fillAfter="true"
30+
android:interpolator="@android:interpolator/decelerate_cubic"
31+
android:duration="300" />
32+
</set>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
/*
4+
** Copyright 2012, The Android Open Source Project
5+
**
6+
** Licensed under the Apache License, Version 2.0 (the "License");
7+
** you may not use this file except in compliance with the License.
8+
** You may obtain a copy of the License at
9+
**
10+
** http://www.apache.org/licenses/LICENSE-2.0
11+
**
12+
** Unless required by applicable law or agreed to in writing, software
13+
** distributed under the License is distributed on an "AS IS" BASIS,
14+
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
** See the License for the specific language governing permissions and
16+
** limitations under the License.
17+
*/
18+
-->
19+
20+
<translate xmlns:android="http://schemas.android.com/apk/res/android"
21+
android:interpolator="@android:anim/accelerate_interpolator"
22+
android:fromXDelta="0" android:toXDelta="0"
23+
android:duration="300" />

core/res/res/values/symbols.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1189,6 +1189,9 @@
11891189
<java-symbol type="anim" name="keyguard_security_animate_out" />
11901190
<java-symbol type="anim" name="keyguard_security_fade_in" />
11911191
<java-symbol type="anim" name="keyguard_security_fade_out" />
1192+
<java-symbol type="anim" name="keyguard_action_assist_exit" />
1193+
<java-symbol type="anim" name="keyguard_action_assist_enter" />
1194+
11921195
<java-symbol type="array" name="config_keyboardTapVibePattern" />
11931196
<java-symbol type="array" name="config_longPressVibePattern" />
11941197
<java-symbol type="array" name="config_safeModeDisabledVibePattern" />

packages/SystemUI/src/com/android/systemui/SearchPanelView.java

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,13 @@
2626
import android.content.Intent;
2727
import android.content.res.Resources;
2828
import android.os.RemoteException;
29+
import android.os.ServiceManager;
2930
import android.os.UserHandle;
3031
import android.os.Vibrator;
3132
import android.provider.Settings;
3233
import android.util.AttributeSet;
3334
import android.util.Slog;
35+
import android.view.IWindowManager;
3436
import android.view.MotionEvent;
3537
import android.view.View;
3638
import android.view.ViewGroup;
@@ -62,6 +64,7 @@ public class SearchPanelView extends FrameLayout implements
6264
private boolean mShowing;
6365
private View mSearchTargetsContainer;
6466
private GlowPadView mGlowPadView;
67+
private IWindowManager mWm;
6568

6669
public SearchPanelView(Context context, AttributeSet attrs) {
6770
this(context, attrs, 0);
@@ -70,35 +73,21 @@ public SearchPanelView(Context context, AttributeSet attrs) {
7073
public SearchPanelView(Context context, AttributeSet attrs, int defStyle) {
7174
super(context, attrs, defStyle);
7275
mContext = context;
76+
mWm = IWindowManager.Stub.asInterface(ServiceManager.getService("window"));
7377
}
7478

7579
private void startAssistActivity() {
7680
if (!mBar.isDeviceProvisioned()) return;
7781

7882
// Close Recent Apps if needed
7983
mBar.animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_SEARCH_PANEL);
80-
// Launch Assist
81-
Intent intent = ((SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE))
82-
.getAssistIntent(mContext, UserHandle.USER_CURRENT);
83-
if (intent == null) return;
8484

85-
// Dismiss the keyguard if possible. XXX: TODO: invoke bouncer.
8685
try {
87-
ActivityManagerNative.getDefault().dismissKeyguardOnNextActivity();
86+
mWm.showAssistant();
8887
} catch (RemoteException e) {
88+
// too bad, so sad...
8989
}
90-
91-
try {
92-
ActivityOptions opts = ActivityOptions.makeCustomAnimation(mContext,
93-
R.anim.search_launch_enter, R.anim.search_launch_exit,
94-
getHandler(), this);
95-
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
96-
mContext.startActivityAsUser(intent, opts.toBundle(),
97-
new UserHandle(UserHandle.USER_CURRENT));
98-
} catch (ActivityNotFoundException e) {
99-
Slog.w(TAG, "Activity not found for " + intent.getAction());
100-
onAnimationStarted();
101-
}
90+
onAnimationStarted();
10291
}
10392

10493
class GlowPadTriggerListener implements GlowPadView.OnTriggerListener {

policy/src/com/android/internal/policy/impl/PhoneWindowManager.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4539,6 +4539,11 @@ public void setCurrentUserLw(int newUserId) {
45394539
setLastInputMethodWindowLw(null, null);
45404540
}
45414541

4542+
@Override
4543+
public void showAssistant() {
4544+
mKeyguardMediator.showAssistant();
4545+
}
4546+
45424547
@Override
45434548
public void dump(String prefix, PrintWriter pw, String[] args) {
45444549
pw.print(prefix); pw.print("mSafeMode="); pw.print(mSafeMode);

policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,13 @@
2020
import android.app.ActivityManager;
2121
import android.app.ActivityOptions;
2222
import android.app.AlertDialog;
23+
import android.app.SearchManager;
2324
import android.app.admin.DevicePolicyManager;
2425
import android.appwidget.AppWidgetHost;
2526
import android.appwidget.AppWidgetHostView;
2627
import android.appwidget.AppWidgetManager;
2728
import android.appwidget.AppWidgetProviderInfo;
29+
import android.content.ActivityNotFoundException;
2830
import android.content.ComponentName;
2931
import android.content.Context;
3032
import android.content.Intent;
@@ -37,6 +39,7 @@
3739
import android.os.Parcel;
3840
import android.os.Parcelable;
3941
import android.os.SystemClock;
42+
import android.os.UserHandle;
4043
import android.os.UserManager;
4144
import android.util.AttributeSet;
4245
import android.util.Log;
@@ -1442,4 +1445,31 @@ public boolean handleBackKey() {
14421445
public void dismiss() {
14431446
showNextSecurityScreenOrFinish(false);
14441447
}
1448+
1449+
public void showAssistant() {
1450+
final Intent intent = ((SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE))
1451+
.getAssistIntent(mContext, UserHandle.USER_CURRENT);
1452+
1453+
if (intent == null) return;
1454+
1455+
final ActivityOptions opts = ActivityOptions.makeCustomAnimation(mContext,
1456+
R.anim.keyguard_action_assist_enter, R.anim.keyguard_action_assist_exit,
1457+
getHandler(), null);
1458+
1459+
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
1460+
setOnDismissAction(new OnDismissAction() {
1461+
@Override
1462+
public boolean onDismiss() {
1463+
try {
1464+
mContext.startActivityAsUser(intent, opts.toBundle(),
1465+
new UserHandle(UserHandle.USER_CURRENT));
1466+
} catch (ActivityNotFoundException e) {
1467+
Slog.w(TAG, "Activity not found for " + intent.getAction());
1468+
}
1469+
return false;
1470+
}
1471+
});
1472+
1473+
mViewStateManager.showBouncer(true);
1474+
}
14451475
}

policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewManager.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,4 +425,10 @@ public synchronized void dismiss() {
425425
public synchronized boolean isShowing() {
426426
return (mKeyguardHost != null && mKeyguardHost.getVisibility() == View.VISIBLE);
427427
}
428+
429+
public void showAssistant() {
430+
if (mKeyguardView != null) {
431+
mKeyguardView.showAssistant();
432+
}
433+
}
428434
}

policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewMediator.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ public class KeyguardViewMediator {
116116
private static final int KEYGUARD_DONE_AUTHENTICATING = 11;
117117
private static final int SET_HIDDEN = 12;
118118
private static final int KEYGUARD_TIMEOUT = 13;
119+
private static final int SHOW_ASSISTANT = 14;
119120

120121
/**
121122
* The default amount of time we stay awake (used for all key input)
@@ -1130,6 +1131,9 @@ public void handleMessage(Message msg) {
11301131
doKeyguardLocked((Bundle) msg.obj);
11311132
}
11321133
break;
1134+
case SHOW_ASSISTANT:
1135+
handleShowAssistant();
1136+
break;
11331137
}
11341138
}
11351139
};
@@ -1393,4 +1397,13 @@ public boolean isDismissable() {
13931397
return mKeyguardDonePending || !isSecure();
13941398
}
13951399

1400+
public void showAssistant() {
1401+
Message msg = mHandler.obtainMessage(SHOW_ASSISTANT);
1402+
mHandler.sendMessage(msg);
1403+
}
1404+
1405+
public void handleShowAssistant() {
1406+
mKeyguardViewManager.showAssistant();
1407+
}
1408+
13961409
}

0 commit comments

Comments
 (0)