The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2007 The Android Open Source Project |
| 3 | * |
| 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 |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 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 |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 17 | package com.android.keyguard; |
| 18 | |
Adam Powell | 43a372f | 2013-09-27 17:43:53 -0700 | [diff] [blame] | 19 | import android.app.PendingIntent; |
| 20 | import android.graphics.Bitmap; |
| 21 | import android.graphics.drawable.BitmapDrawable; |
Jim Miller | 2519057 | 2013-02-28 17:36:24 -0800 | [diff] [blame] | 22 | import com.android.internal.policy.IKeyguardShowCallback; |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 23 | import com.android.internal.widget.LockPatternUtils; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 24 | |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 25 | import android.app.Activity; |
Dianne Hackborn | b375632 | 2011-08-12 13:58:13 -0700 | [diff] [blame] | 26 | import android.app.ActivityManager; |
Michael Jurka | 76017ca | 2012-11-06 16:21:09 -0800 | [diff] [blame] | 27 | import android.appwidget.AppWidgetManager; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 28 | import android.content.Context; |
| 29 | import android.content.pm.ActivityInfo; |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 30 | import android.content.res.Configuration; |
Jim Miller | 06cc78a | 2011-06-02 16:10:16 -0700 | [diff] [blame] | 31 | import android.content.res.Resources; |
John Spurlock | 257f283 | 2013-09-21 18:41:53 -0400 | [diff] [blame] | 32 | import android.graphics.Canvas; |
| 33 | import android.graphics.ColorFilter; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 34 | import android.graphics.PixelFormat; |
John Spurlock | 257f283 | 2013-09-21 18:41:53 -0400 | [diff] [blame] | 35 | import android.graphics.PorterDuff; |
Jim Miller | 2b84b81 | 2012-11-30 15:42:18 -0800 | [diff] [blame] | 36 | import android.graphics.Rect; |
John Spurlock | 257f283 | 2013-09-21 18:41:53 -0400 | [diff] [blame] | 37 | import android.graphics.drawable.Drawable; |
Adam Cohen | f752202 | 2012-10-03 20:03:18 -0700 | [diff] [blame] | 38 | import android.os.Bundle; |
Dianne Hackborn | 38e29a6 | 2011-09-18 14:43:08 -0700 | [diff] [blame] | 39 | import android.os.IBinder; |
Jim Miller | 6bcd732 | 2012-10-02 16:32:04 -0700 | [diff] [blame] | 40 | import android.os.Parcelable; |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 41 | import android.os.RemoteException; |
Jim Miller | 56bacd7 | 2011-09-09 14:12:54 -0700 | [diff] [blame] | 42 | import android.os.SystemProperties; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 43 | import android.util.Log; |
Craig Mautner | 0cbfcff | 2012-09-17 16:40:28 -0700 | [diff] [blame] | 44 | import android.util.Slog; |
Jim Miller | 6bcd732 | 2012-10-02 16:32:04 -0700 | [diff] [blame] | 45 | import android.util.SparseArray; |
Adam Cohen | f752202 | 2012-10-03 20:03:18 -0700 | [diff] [blame] | 46 | import android.view.KeyEvent; |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 47 | import android.view.LayoutInflater; |
Jim Miller | caf24fc | 2013-09-10 18:37:01 -0700 | [diff] [blame] | 48 | import android.view.MotionEvent; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 49 | import android.view.View; |
| 50 | import android.view.ViewGroup; |
| 51 | import android.view.ViewManager; |
| 52 | import android.view.WindowManager; |
| 53 | import android.widget.FrameLayout; |
| 54 | |
| 55 | /** |
| 56 | * Manages creating, showing, hiding and resetting the keyguard. Calls back |
Craig Mautner | 904732c | 2012-10-17 15:20:24 -0700 | [diff] [blame] | 57 | * via {@link KeyguardViewMediator.ViewMediatorCallback} to poke |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 58 | * the wake lock and report that the keyguard is done, which is in turn, |
| 59 | * reported to this class by the current {@link KeyguardViewBase}. |
| 60 | */ |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 61 | public class KeyguardViewManager { |
Jim Miller | a71984f | 2012-10-24 22:08:49 -0700 | [diff] [blame] | 62 | private final static boolean DEBUG = KeyguardViewMediator.DEBUG; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 63 | private static String TAG = "KeyguardViewManager"; |
Chris Wren | f41c61b | 2012-11-29 15:19:54 -0500 | [diff] [blame] | 64 | public final static String IS_SWITCHING_USER = "is_switching_user"; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 65 | |
Jim Miller | 0b9d8ac | 2013-11-07 19:15:49 -0800 | [diff] [blame] | 66 | // Delay dismissing keyguard to allow animations to complete. |
| 67 | private static final int HIDE_KEYGUARD_DELAY = 500; |
| 68 | |
Jim Miller | 9cf2c52 | 2012-10-04 22:02:29 -0700 | [diff] [blame] | 69 | // Timeout used for keypresses |
| 70 | static final int DIGIT_PRESS_WAKE_MILLIS = 5000; |
| 71 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 72 | private final Context mContext; |
| 73 | private final ViewManager mViewManager; |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 74 | private final KeyguardViewMediator.ViewMediatorCallback mViewMediatorCallback; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 75 | |
| 76 | private WindowManager.LayoutParams mWindowLayoutParams; |
| 77 | private boolean mNeedsInput = false; |
Jim Miller | 22dfe72 | 2009-10-07 01:30:21 -0700 | [diff] [blame] | 78 | |
John Spurlock | 257f283 | 2013-09-21 18:41:53 -0400 | [diff] [blame] | 79 | private ViewManagerHost mKeyguardHost; |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 80 | private KeyguardHostView mKeyguardView; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 81 | |
Craig Mautner | ad09bcc | 2012-10-08 13:33:11 -0700 | [diff] [blame] | 82 | private boolean mScreenOn = false; |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 83 | private LockPatternUtils mLockPatternUtils; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 84 | |
Adam Powell | 43a372f | 2013-09-27 17:43:53 -0700 | [diff] [blame] | 85 | private KeyguardUpdateMonitorCallback mBackgroundChanger = new KeyguardUpdateMonitorCallback() { |
| 86 | @Override |
| 87 | public void onSetBackground(Bitmap bmp) { |
| 88 | mKeyguardHost.setCustomBackground(bmp != null ? |
| 89 | new BitmapDrawable(mContext.getResources(), bmp) : null); |
Adam Powell | 9471907 | 2013-10-10 20:01:49 -0700 | [diff] [blame] | 90 | updateShowWallpaper(bmp == null); |
Adam Powell | 43a372f | 2013-09-27 17:43:53 -0700 | [diff] [blame] | 91 | } |
| 92 | }; |
| 93 | |
Dianne Hackborn | 38e29a6 | 2011-09-18 14:43:08 -0700 | [diff] [blame] | 94 | public interface ShowListener { |
| 95 | void onShown(IBinder windowToken); |
| 96 | }; |
| 97 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 98 | /** |
| 99 | * @param context Used to create views. |
| 100 | * @param viewManager Keyguard will be attached to this. |
| 101 | * @param callback Used to notify of changes. |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 102 | * @param lockPatternUtils |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 103 | */ |
| 104 | public KeyguardViewManager(Context context, ViewManager viewManager, |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 105 | KeyguardViewMediator.ViewMediatorCallback callback, |
| 106 | LockPatternUtils lockPatternUtils) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 107 | mContext = context; |
| 108 | mViewManager = viewManager; |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 109 | mViewMediatorCallback = callback; |
| 110 | mLockPatternUtils = lockPatternUtils; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 111 | } |
| 112 | |
| 113 | /** |
| 114 | * Show the keyguard. Will handle creating and attaching to the view manager |
| 115 | * lazily. |
| 116 | */ |
Adam Cohen | f752202 | 2012-10-03 20:03:18 -0700 | [diff] [blame] | 117 | public synchronized void show(Bundle options) { |
Daniel Sandler | 16541e4 | 2009-11-13 17:07:50 -0800 | [diff] [blame] | 118 | if (DEBUG) Log.d(TAG, "show(); mKeyguardView==" + mKeyguardView); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 119 | |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 120 | boolean enableScreenRotation = shouldEnableScreenRotation(); |
| 121 | |
Jim Miller | a71984f | 2012-10-24 22:08:49 -0700 | [diff] [blame] | 122 | maybeCreateKeyguardLocked(enableScreenRotation, false, options); |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 123 | maybeEnableScreenRotation(enableScreenRotation); |
| 124 | |
Jim Miller | e23ab8b | 2012-09-16 15:45:44 -0700 | [diff] [blame] | 125 | // Disable common aspects of the system/status/navigation bars that are not appropriate or |
| 126 | // useful on any keyguard screen but can be re-shown by dialogs or SHOW_WHEN_LOCKED |
| 127 | // activities. Other disabled bits are handled by the KeyguardViewMediator talking |
| 128 | // directly to the status bar service. |
John Spurlock | 257f283 | 2013-09-21 18:41:53 -0400 | [diff] [blame] | 129 | int visFlags = View.STATUS_BAR_DISABLE_HOME; |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 130 | if (shouldEnableTranslucentDecor()) { |
| 131 | mWindowLayoutParams.flags |= WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS |
| 132 | | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION; |
John Spurlock | 257f283 | 2013-09-21 18:41:53 -0400 | [diff] [blame] | 133 | } |
Jim Miller | a71984f | 2012-10-24 22:08:49 -0700 | [diff] [blame] | 134 | if (DEBUG) Log.v(TAG, "show:setSystemUiVisibility(" + Integer.toHexString(visFlags)+")"); |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 135 | mKeyguardHost.setSystemUiVisibility(visFlags); |
| 136 | |
| 137 | mViewManager.updateViewLayout(mKeyguardHost, mWindowLayoutParams); |
| 138 | mKeyguardHost.setVisibility(View.VISIBLE); |
| 139 | mKeyguardView.show(); |
| 140 | mKeyguardView.requestFocus(); |
| 141 | } |
| 142 | |
| 143 | private boolean shouldEnableScreenRotation() { |
Jim Miller | 06cc78a | 2011-06-02 16:10:16 -0700 | [diff] [blame] | 144 | Resources res = mContext.getResources(); |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 145 | return SystemProperties.getBoolean("lockscreen.rot_override",false) |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 146 | || res.getBoolean(R.bool.config_enableLockScreenRotation); |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 147 | } |
| 148 | |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 149 | private boolean shouldEnableTranslucentDecor() { |
John Spurlock | 257f283 | 2013-09-21 18:41:53 -0400 | [diff] [blame] | 150 | Resources res = mContext.getResources(); |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 151 | return res.getBoolean(R.bool.config_enableLockScreenTranslucentDecor); |
John Spurlock | 257f283 | 2013-09-21 18:41:53 -0400 | [diff] [blame] | 152 | } |
| 153 | |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 154 | class ViewManagerHost extends FrameLayout { |
John Spurlock | 257f283 | 2013-09-21 18:41:53 -0400 | [diff] [blame] | 155 | private static final int BACKGROUND_COLOR = 0x70000000; |
John Spurlock | 256ae67 | 2013-09-26 12:14:33 -0400 | [diff] [blame] | 156 | |
Adam Powell | 43a372f | 2013-09-27 17:43:53 -0700 | [diff] [blame] | 157 | private Drawable mCustomBackground; |
| 158 | |
John Spurlock | 257f283 | 2013-09-21 18:41:53 -0400 | [diff] [blame] | 159 | // This is a faster way to draw the background on devices without hardware acceleration |
| 160 | private final Drawable mBackgroundDrawable = new Drawable() { |
| 161 | @Override |
| 162 | public void draw(Canvas canvas) { |
Adam Powell | 43a372f | 2013-09-27 17:43:53 -0700 | [diff] [blame] | 163 | if (mCustomBackground != null) { |
| 164 | final Rect bounds = mCustomBackground.getBounds(); |
| 165 | final int vWidth = getWidth(); |
| 166 | final int vHeight = getHeight(); |
| 167 | |
| 168 | final int restore = canvas.save(); |
| 169 | canvas.translate(-(bounds.width() - vWidth) / 2, |
| 170 | -(bounds.height() - vHeight) / 2); |
| 171 | mCustomBackground.draw(canvas); |
| 172 | canvas.restoreToCount(restore); |
| 173 | } else { |
| 174 | canvas.drawColor(BACKGROUND_COLOR, PorterDuff.Mode.SRC); |
| 175 | } |
John Spurlock | 257f283 | 2013-09-21 18:41:53 -0400 | [diff] [blame] | 176 | } |
| 177 | |
| 178 | @Override |
| 179 | public void setAlpha(int alpha) { |
| 180 | } |
| 181 | |
| 182 | @Override |
| 183 | public void setColorFilter(ColorFilter cf) { |
| 184 | } |
| 185 | |
| 186 | @Override |
| 187 | public int getOpacity() { |
| 188 | return PixelFormat.TRANSLUCENT; |
| 189 | } |
| 190 | }; |
John Spurlock | 256ae67 | 2013-09-26 12:14:33 -0400 | [diff] [blame] | 191 | |
| 192 | public ViewManagerHost(Context context) { |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 193 | super(context); |
John Spurlock | 257f283 | 2013-09-21 18:41:53 -0400 | [diff] [blame] | 194 | setBackground(mBackgroundDrawable); |
Jim Miller | 2b84b81 | 2012-11-30 15:42:18 -0800 | [diff] [blame] | 195 | } |
| 196 | |
Adam Powell | 43a372f | 2013-09-27 17:43:53 -0700 | [diff] [blame] | 197 | public void setCustomBackground(Drawable d) { |
| 198 | mCustomBackground = d; |
| 199 | if (d != null) { |
| 200 | d.setColorFilter(BACKGROUND_COLOR, PorterDuff.Mode.SRC_OVER); |
| 201 | } |
| 202 | computeCustomBackgroundBounds(); |
| 203 | invalidate(); |
| 204 | } |
| 205 | |
| 206 | private void computeCustomBackgroundBounds() { |
| 207 | if (mCustomBackground == null) return; // Nothing to do |
| 208 | if (!isLaidOut()) return; // We'll do this later |
| 209 | |
| 210 | final int bgWidth = mCustomBackground.getIntrinsicWidth(); |
| 211 | final int bgHeight = mCustomBackground.getIntrinsicHeight(); |
| 212 | final int vWidth = getWidth(); |
| 213 | final int vHeight = getHeight(); |
| 214 | |
| 215 | final float bgAspect = (float) bgWidth / bgHeight; |
| 216 | final float vAspect = (float) vWidth / vHeight; |
| 217 | |
| 218 | if (bgAspect > vAspect) { |
| 219 | mCustomBackground.setBounds(0, 0, (int) (vHeight * bgAspect), vHeight); |
| 220 | } else { |
| 221 | mCustomBackground.setBounds(0, 0, vWidth, (int) (vWidth / bgAspect)); |
| 222 | } |
| 223 | } |
| 224 | |
| 225 | @Override |
| 226 | protected void onSizeChanged(int w, int h, int oldw, int oldh) { |
| 227 | super.onSizeChanged(w, h, oldw, oldh); |
| 228 | computeCustomBackgroundBounds(); |
| 229 | } |
| 230 | |
Jim Miller | 2b84b81 | 2012-11-30 15:42:18 -0800 | [diff] [blame] | 231 | @Override |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 232 | protected void onConfigurationChanged(Configuration newConfig) { |
| 233 | super.onConfigurationChanged(newConfig); |
Jim Miller | a71984f | 2012-10-24 22:08:49 -0700 | [diff] [blame] | 234 | if (mKeyguardHost.getVisibility() == View.VISIBLE) { |
| 235 | // only propagate configuration messages if we're currently showing |
| 236 | maybeCreateKeyguardLocked(shouldEnableScreenRotation(), true, null); |
| 237 | } else { |
| 238 | if (DEBUG) Log.v(TAG, "onConfigurationChanged: view not visible"); |
| 239 | } |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 240 | } |
Jim Miller | 0a34d9e | 2012-10-05 17:15:41 -0700 | [diff] [blame] | 241 | |
| 242 | @Override |
| 243 | public boolean dispatchKeyEvent(KeyEvent event) { |
Jim Miller | 42df15e | 2012-12-05 15:15:00 -0800 | [diff] [blame] | 244 | if (mKeyguardView != null) { |
| 245 | // Always process back and menu keys, regardless of focus |
| 246 | if (event.getAction() == KeyEvent.ACTION_DOWN) { |
| 247 | int keyCode = event.getKeyCode(); |
| 248 | if (keyCode == KeyEvent.KEYCODE_BACK && mKeyguardView.handleBackKey()) { |
| 249 | return true; |
| 250 | } else if (keyCode == KeyEvent.KEYCODE_MENU && mKeyguardView.handleMenuKey()) { |
| 251 | return true; |
| 252 | } |
| 253 | } |
| 254 | // Always process media keys, regardless of focus |
| 255 | if (mKeyguardView.dispatchKeyEvent(event)) { |
Jim Miller | 0a34d9e | 2012-10-05 17:15:41 -0700 | [diff] [blame] | 256 | return true; |
| 257 | } |
| 258 | } |
| 259 | return super.dispatchKeyEvent(event); |
| 260 | } |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 261 | } |
| 262 | |
Jim Miller | 6bcd732 | 2012-10-02 16:32:04 -0700 | [diff] [blame] | 263 | SparseArray<Parcelable> mStateContainer = new SparseArray<Parcelable>(); |
| 264 | |
Jim Miller | a71984f | 2012-10-24 22:08:49 -0700 | [diff] [blame] | 265 | private void maybeCreateKeyguardLocked(boolean enableScreenRotation, boolean force, |
| 266 | Bundle options) { |
Jim Miller | 6bcd732 | 2012-10-02 16:32:04 -0700 | [diff] [blame] | 267 | if (mKeyguardHost != null) { |
| 268 | mKeyguardHost.saveHierarchyState(mStateContainer); |
| 269 | } |
| 270 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 271 | if (mKeyguardHost == null) { |
| 272 | if (DEBUG) Log.d(TAG, "keyguard host is null, creating it..."); |
| 273 | |
John Spurlock | 256ae67 | 2013-09-26 12:14:33 -0400 | [diff] [blame] | 274 | mKeyguardHost = new ViewManagerHost(mContext); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 275 | |
Adam Powell | 5da6430 | 2012-11-05 14:16:59 -0800 | [diff] [blame] | 276 | int flags = WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN |
| 277 | | WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR |
Adam Powell | a9fa92e | 2012-11-08 00:03:34 -0800 | [diff] [blame] | 278 | | WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN |
Jim Miller | d2b82f7 | 2012-09-18 20:52:55 -0700 | [diff] [blame] | 279 | | WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER; |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 280 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 281 | if (!mNeedsInput) { |
| 282 | flags |= WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM; |
| 283 | } |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 284 | |
| 285 | final int stretch = ViewGroup.LayoutParams.MATCH_PARENT; |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 286 | final int type = WindowManager.LayoutParams.TYPE_KEYGUARD; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 287 | WindowManager.LayoutParams lp = new WindowManager.LayoutParams( |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 288 | stretch, stretch, type, flags, PixelFormat.TRANSLUCENT); |
Jim Miller | 6b05d58 | 2011-07-18 13:09:59 -0700 | [diff] [blame] | 289 | lp.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE; |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 290 | lp.windowAnimations = R.style.Animation_LockScreen; |
Jim Miller | 8e26cd8 | 2013-03-12 18:45:28 -0700 | [diff] [blame] | 291 | lp.screenOrientation = enableScreenRotation ? |
| 292 | ActivityInfo.SCREEN_ORIENTATION_USER : ActivityInfo.SCREEN_ORIENTATION_NOSENSOR; |
| 293 | |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 294 | if (ActivityManager.isHighEndGfx()) { |
Dianne Hackborn | 5d927c2 | 2011-09-02 12:22:18 -0700 | [diff] [blame] | 295 | lp.flags |= WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED; |
| 296 | lp.privateFlags |= |
| 297 | WindowManager.LayoutParams.PRIVATE_FLAG_FORCE_HARDWARE_ACCELERATED; |
| 298 | } |
Dianne Hackborn | 73ab6a4 | 2011-12-13 11:16:23 -0800 | [diff] [blame] | 299 | lp.privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_SET_NEEDS_MENU_KEY; |
Jeff Brown | 3dc524b | 2012-09-30 19:49:11 -0700 | [diff] [blame] | 300 | lp.inputFeatures |= WindowManager.LayoutParams.INPUT_FEATURE_DISABLE_USER_ACTIVITY; |
Jim Miller | cf182aa | 2013-06-28 16:55:56 -0700 | [diff] [blame] | 301 | lp.setTitle("Keyguard"); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 302 | mWindowLayoutParams = lp; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 303 | mViewManager.addView(mKeyguardHost, lp); |
Adam Powell | 43a372f | 2013-09-27 17:43:53 -0700 | [diff] [blame] | 304 | |
| 305 | KeyguardUpdateMonitor.getInstance(mContext).registerCallback(mBackgroundChanger); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 306 | } |
Jeff Brown | c7505bc | 2012-10-05 21:58:15 -0700 | [diff] [blame] | 307 | |
Jim Miller | a71984f | 2012-10-24 22:08:49 -0700 | [diff] [blame] | 308 | if (force || mKeyguardView == null) { |
Adam Powell | 43a372f | 2013-09-27 17:43:53 -0700 | [diff] [blame] | 309 | mKeyguardHost.setCustomBackground(null); |
Jim Miller | 1de95fb | 2013-09-23 15:43:07 -0700 | [diff] [blame] | 310 | mKeyguardHost.removeAllViews(); |
Jim Miller | a71984f | 2012-10-24 22:08:49 -0700 | [diff] [blame] | 311 | inflateKeyguardView(options); |
Jim Miller | 147f956 | 2012-12-03 17:55:16 -0800 | [diff] [blame] | 312 | mKeyguardView.requestFocus(); |
Jim Miller | a71984f | 2012-10-24 22:08:49 -0700 | [diff] [blame] | 313 | } |
Jeff Brown | c7505bc | 2012-10-05 21:58:15 -0700 | [diff] [blame] | 314 | updateUserActivityTimeoutInWindowLayoutParams(); |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 315 | mViewManager.updateViewLayout(mKeyguardHost, mWindowLayoutParams); |
Jim Miller | 6bcd732 | 2012-10-02 16:32:04 -0700 | [diff] [blame] | 316 | |
| 317 | mKeyguardHost.restoreHierarchyState(mStateContainer); |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 318 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 319 | |
Adam Cohen | f752202 | 2012-10-03 20:03:18 -0700 | [diff] [blame] | 320 | private void inflateKeyguardView(Bundle options) { |
Craig Mautner | 00baebe | 2012-09-28 15:22:39 -0700 | [diff] [blame] | 321 | View v = mKeyguardHost.findViewById(R.id.keyguard_host_view); |
| 322 | if (v != null) { |
| 323 | mKeyguardHost.removeView(v); |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 324 | } |
| 325 | final LayoutInflater inflater = LayoutInflater.from(mContext); |
| 326 | View view = inflater.inflate(R.layout.keyguard_host_view, mKeyguardHost, true); |
| 327 | mKeyguardView = (KeyguardHostView) view.findViewById(R.id.keyguard_host_view); |
| 328 | mKeyguardView.setLockPatternUtils(mLockPatternUtils); |
| 329 | mKeyguardView.setViewMediatorCallback(mViewMediatorCallback); |
Chris Wren | f41c61b | 2012-11-29 15:19:54 -0500 | [diff] [blame] | 330 | mKeyguardView.initializeSwitchingUserState(options != null && |
| 331 | options.getBoolean(IS_SWITCHING_USER)); |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 332 | |
Adam Powell | 70bc9f2 | 2012-10-12 22:02:27 -0700 | [diff] [blame] | 333 | // HACK |
| 334 | // The keyguard view will have set up window flags in onFinishInflate before we set |
| 335 | // the view mediator callback. Make sure it knows the correct IME state. |
| 336 | if (mViewMediatorCallback != null) { |
| 337 | KeyguardPasswordView kpv = (KeyguardPasswordView) mKeyguardView.findViewById( |
| 338 | R.id.keyguard_password_view); |
| 339 | |
| 340 | if (kpv != null) { |
| 341 | mViewMediatorCallback.setNeedsInput(kpv.needsInput()); |
| 342 | } |
| 343 | } |
| 344 | |
Jim Miller | 0ff7f01 | 2012-10-11 20:40:01 -0700 | [diff] [blame] | 345 | if (options != null) { |
Michael Jurka | 76017ca | 2012-11-06 16:21:09 -0800 | [diff] [blame] | 346 | int widgetToShow = options.getInt(LockPatternUtils.KEYGUARD_SHOW_APPWIDGET, |
| 347 | AppWidgetManager.INVALID_APPWIDGET_ID); |
| 348 | if (widgetToShow != AppWidgetManager.INVALID_APPWIDGET_ID) { |
| 349 | mKeyguardView.goToWidget(widgetToShow); |
| 350 | } |
Adam Cohen | f752202 | 2012-10-03 20:03:18 -0700 | [diff] [blame] | 351 | } |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 352 | } |
| 353 | |
Jeff Brown | c7505bc | 2012-10-05 21:58:15 -0700 | [diff] [blame] | 354 | public void updateUserActivityTimeout() { |
| 355 | updateUserActivityTimeoutInWindowLayoutParams(); |
| 356 | mViewManager.updateViewLayout(mKeyguardHost, mWindowLayoutParams); |
| 357 | } |
| 358 | |
| 359 | private void updateUserActivityTimeoutInWindowLayoutParams() { |
| 360 | // Use the user activity timeout requested by the keyguard view, if any. |
| 361 | if (mKeyguardView != null) { |
| 362 | long timeout = mKeyguardView.getUserActivityTimeout(); |
| 363 | if (timeout >= 0) { |
| 364 | mWindowLayoutParams.userActivityTimeout = timeout; |
| 365 | return; |
| 366 | } |
| 367 | } |
| 368 | |
| 369 | // Otherwise, use the default timeout. |
| 370 | mWindowLayoutParams.userActivityTimeout = KeyguardViewMediator.AWAKE_INTERVAL_DEFAULT_MS; |
| 371 | } |
| 372 | |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 373 | private void maybeEnableScreenRotation(boolean enableScreenRotation) { |
| 374 | // TODO: move this outside |
Jim Miller | 06cc78a | 2011-06-02 16:10:16 -0700 | [diff] [blame] | 375 | if (enableScreenRotation) { |
Jim Miller | f344735 | 2011-08-07 14:00:09 -0700 | [diff] [blame] | 376 | if (DEBUG) Log.d(TAG, "Rotation sensor for lock screen On!"); |
Jim Miller | 82f9196 | 2012-07-24 13:33:08 -0700 | [diff] [blame] | 377 | mWindowLayoutParams.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_USER; |
Jim Miller | 06cc78a | 2011-06-02 16:10:16 -0700 | [diff] [blame] | 378 | } else { |
Jim Miller | f344735 | 2011-08-07 14:00:09 -0700 | [diff] [blame] | 379 | if (DEBUG) Log.d(TAG, "Rotation sensor for lock screen Off!"); |
Jim Miller | 06cc78a | 2011-06-02 16:10:16 -0700 | [diff] [blame] | 380 | mWindowLayoutParams.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_NOSENSOR; |
| 381 | } |
Jim Miller | 06cc78a | 2011-06-02 16:10:16 -0700 | [diff] [blame] | 382 | mViewManager.updateViewLayout(mKeyguardHost, mWindowLayoutParams); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 383 | } |
| 384 | |
Adam Powell | 9471907 | 2013-10-10 20:01:49 -0700 | [diff] [blame] | 385 | void updateShowWallpaper(boolean show) { |
| 386 | if (show) { |
| 387 | mWindowLayoutParams.flags |= WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER; |
| 388 | } else { |
| 389 | mWindowLayoutParams.flags &= ~WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER; |
| 390 | } |
| 391 | |
| 392 | mViewManager.updateViewLayout(mKeyguardHost, mWindowLayoutParams); |
| 393 | } |
| 394 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 395 | public void setNeedsInput(boolean needsInput) { |
| 396 | mNeedsInput = needsInput; |
| 397 | if (mWindowLayoutParams != null) { |
| 398 | if (needsInput) { |
| 399 | mWindowLayoutParams.flags &= |
| 400 | ~WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM; |
| 401 | } else { |
| 402 | mWindowLayoutParams.flags |= |
| 403 | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM; |
| 404 | } |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 405 | |
| 406 | try { |
| 407 | mViewManager.updateViewLayout(mKeyguardHost, mWindowLayoutParams); |
| 408 | } catch (java.lang.IllegalArgumentException e) { |
| 409 | // TODO: Ensure this method isn't called on views that are changing... |
| 410 | Log.w(TAG,"Can't update input method on " + mKeyguardHost + " window not attached"); |
| 411 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 412 | } |
| 413 | } |
Jim Miller | 22dfe72 | 2009-10-07 01:30:21 -0700 | [diff] [blame] | 414 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 415 | /** |
| 416 | * Reset the state of the view. |
| 417 | */ |
Adam Cohen | f752202 | 2012-10-03 20:03:18 -0700 | [diff] [blame] | 418 | public synchronized void reset(Bundle options) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 419 | if (DEBUG) Log.d(TAG, "reset()"); |
Amith Yamasani | d979dd7 | 2012-09-11 15:53:37 -0700 | [diff] [blame] | 420 | // User might have switched, check if we need to go back to keyguard |
| 421 | // TODO: It's preferable to stay and show the correct lockscreen or unlock if none |
Jim Miller | a71984f | 2012-10-24 22:08:49 -0700 | [diff] [blame] | 422 | maybeCreateKeyguardLocked(shouldEnableScreenRotation(), true, options); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 423 | } |
| 424 | |
| 425 | public synchronized void onScreenTurnedOff() { |
| 426 | if (DEBUG) Log.d(TAG, "onScreenTurnedOff()"); |
Craig Mautner | ad09bcc | 2012-10-08 13:33:11 -0700 | [diff] [blame] | 427 | mScreenOn = false; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 428 | if (mKeyguardView != null) { |
| 429 | mKeyguardView.onScreenTurnedOff(); |
Brian Colonna | 15ea55a | 2011-09-09 11:48:16 -0400 | [diff] [blame] | 430 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 431 | } |
| 432 | |
Jim Miller | 2519057 | 2013-02-28 17:36:24 -0800 | [diff] [blame] | 433 | public synchronized void onScreenTurnedOn(final IKeyguardShowCallback callback) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 434 | if (DEBUG) Log.d(TAG, "onScreenTurnedOn()"); |
Craig Mautner | ad09bcc | 2012-10-08 13:33:11 -0700 | [diff] [blame] | 435 | mScreenOn = true; |
Jim Miller | 6a3cceb | 2013-10-11 21:03:22 -0700 | [diff] [blame] | 436 | |
Jim Miller | ed80f3f | 2013-10-15 17:48:15 -0700 | [diff] [blame] | 437 | // If keyguard is not showing, we need to inform PhoneWindowManager with a null |
Jim Miller | 6a3cceb | 2013-10-11 21:03:22 -0700 | [diff] [blame] | 438 | // token so it doesn't wait for us to draw... |
Jim Miller | ed80f3f | 2013-10-15 17:48:15 -0700 | [diff] [blame] | 439 | final IBinder token = isShowing() ? mKeyguardHost.getWindowToken() : null; |
| 440 | |
| 441 | if (DEBUG && token == null) Slog.v(TAG, "send wm null token: " |
| 442 | + (mKeyguardHost == null ? "host was null" : "not showing")); |
Jim Miller | 6a3cceb | 2013-10-11 21:03:22 -0700 | [diff] [blame] | 443 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 444 | if (mKeyguardView != null) { |
| 445 | mKeyguardView.onScreenTurnedOn(); |
Jim Miller | 6edf263 | 2011-09-05 16:03:14 -0700 | [diff] [blame] | 446 | |
Dianne Hackborn | 38e29a6 | 2011-09-18 14:43:08 -0700 | [diff] [blame] | 447 | // Caller should wait for this window to be shown before turning |
| 448 | // on the screen. |
Jim Miller | 2519057 | 2013-02-28 17:36:24 -0800 | [diff] [blame] | 449 | if (callback != null) { |
Craig Mautner | 904732c | 2012-10-17 15:20:24 -0700 | [diff] [blame] | 450 | if (mKeyguardHost.getVisibility() == View.VISIBLE) { |
| 451 | // Keyguard may be in the process of being shown, but not yet |
| 452 | // updated with the window manager... give it a chance to do so. |
| 453 | mKeyguardHost.post(new Runnable() { |
| 454 | @Override |
| 455 | public void run() { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 456 | try { |
Jim Miller | 2519057 | 2013-02-28 17:36:24 -0800 | [diff] [blame] | 457 | callback.onShown(token); |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 458 | } catch (RemoteException e) { |
Jim Miller | 2519057 | 2013-02-28 17:36:24 -0800 | [diff] [blame] | 459 | Slog.w(TAG, "Exception calling onShown():", e); |
Craig Mautner | 904732c | 2012-10-17 15:20:24 -0700 | [diff] [blame] | 460 | } |
Dianne Hackborn | 38e29a6 | 2011-09-18 14:43:08 -0700 | [diff] [blame] | 461 | } |
Craig Mautner | 904732c | 2012-10-17 15:20:24 -0700 | [diff] [blame] | 462 | }); |
| 463 | } else { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 464 | try { |
Craig Mautner | 4e8a19c | 2013-10-08 17:26:08 -0700 | [diff] [blame] | 465 | callback.onShown(token); |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 466 | } catch (RemoteException e) { |
Jim Miller | 2519057 | 2013-02-28 17:36:24 -0800 | [diff] [blame] | 467 | Slog.w(TAG, "Exception calling onShown():", e); |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 468 | } |
Craig Mautner | 904732c | 2012-10-17 15:20:24 -0700 | [diff] [blame] | 469 | } |
Dianne Hackborn | 38e29a6 | 2011-09-18 14:43:08 -0700 | [diff] [blame] | 470 | } |
Jim Miller | 2519057 | 2013-02-28 17:36:24 -0800 | [diff] [blame] | 471 | } else if (callback != null) { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 472 | try { |
Craig Mautner | 4e8a19c | 2013-10-08 17:26:08 -0700 | [diff] [blame] | 473 | callback.onShown(token); |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 474 | } catch (RemoteException e) { |
Jim Miller | 2519057 | 2013-02-28 17:36:24 -0800 | [diff] [blame] | 475 | Slog.w(TAG, "Exception calling onShown():", e); |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 476 | } |
Brian Colonna | 15ea55a | 2011-09-09 11:48:16 -0400 | [diff] [blame] | 477 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 478 | } |
| 479 | |
| 480 | public synchronized void verifyUnlock() { |
| 481 | if (DEBUG) Log.d(TAG, "verifyUnlock()"); |
Adam Cohen | f752202 | 2012-10-03 20:03:18 -0700 | [diff] [blame] | 482 | show(null); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 483 | mKeyguardView.verifyUnlock(); |
| 484 | } |
| 485 | |
| 486 | /** |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 487 | * Hides the keyguard view |
| 488 | */ |
| 489 | public synchronized void hide() { |
| 490 | if (DEBUG) Log.d(TAG, "hide()"); |
Jim Miller | 6edf263 | 2011-09-05 16:03:14 -0700 | [diff] [blame] | 491 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 492 | if (mKeyguardHost != null) { |
| 493 | mKeyguardHost.setVisibility(View.GONE); |
Jim Miller | 223ce5c | 2012-10-05 19:13:23 -0700 | [diff] [blame] | 494 | |
| 495 | // We really only want to preserve keyguard state for configuration changes. Hence |
| 496 | // we should clear state of widgets (e.g. Music) when we hide keyguard so it can |
| 497 | // start with a fresh state when we return. |
| 498 | mStateContainer.clear(); |
| 499 | |
Karl Rosaen | a35d753 | 2009-09-25 10:24:26 -0700 | [diff] [blame] | 500 | // Don't do this right away, so we can let the view continue to animate |
Dianne Hackborn | 01ad2f4 | 2009-09-24 19:24:56 -0700 | [diff] [blame] | 501 | // as it goes away. |
Karl Rosaen | a35d753 | 2009-09-25 10:24:26 -0700 | [diff] [blame] | 502 | if (mKeyguardView != null) { |
Jim Miller | 22dfe72 | 2009-10-07 01:30:21 -0700 | [diff] [blame] | 503 | final KeyguardViewBase lastView = mKeyguardView; |
| 504 | mKeyguardView = null; |
Karl Rosaen | a35d753 | 2009-09-25 10:24:26 -0700 | [diff] [blame] | 505 | mKeyguardHost.postDelayed(new Runnable() { |
Craig Mautner | 904732c | 2012-10-17 15:20:24 -0700 | [diff] [blame] | 506 | @Override |
Karl Rosaen | a35d753 | 2009-09-25 10:24:26 -0700 | [diff] [blame] | 507 | public void run() { |
Dianne Hackborn | d7f7deb | 2009-09-25 17:35:10 -0700 | [diff] [blame] | 508 | synchronized (KeyguardViewManager.this) { |
Jim Miller | 22dfe72 | 2009-10-07 01:30:21 -0700 | [diff] [blame] | 509 | lastView.cleanUp(); |
Adam Powell | 43a372f | 2013-09-27 17:43:53 -0700 | [diff] [blame] | 510 | // Let go of any large bitmaps. |
| 511 | mKeyguardHost.setCustomBackground(null); |
Adam Powell | 9471907 | 2013-10-10 20:01:49 -0700 | [diff] [blame] | 512 | updateShowWallpaper(true); |
Jim Miller | 8b886fa | 2011-01-13 17:56:35 -0800 | [diff] [blame] | 513 | mKeyguardHost.removeView(lastView); |
Jim Miller | 0b9d8ac | 2013-11-07 19:15:49 -0800 | [diff] [blame] | 514 | mViewMediatorCallback.keyguardGone(); |
Dianne Hackborn | d7f7deb | 2009-09-25 17:35:10 -0700 | [diff] [blame] | 515 | } |
Karl Rosaen | a35d753 | 2009-09-25 10:24:26 -0700 | [diff] [blame] | 516 | } |
Jim Miller | 0b9d8ac | 2013-11-07 19:15:49 -0800 | [diff] [blame] | 517 | }, HIDE_KEYGUARD_DELAY); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 518 | } |
| 519 | } |
| 520 | } |
| 521 | |
| 522 | /** |
Craig Mautner | ad09bcc | 2012-10-08 13:33:11 -0700 | [diff] [blame] | 523 | * Dismisses the keyguard by going to the next screen or making it gone. |
| 524 | */ |
| 525 | public synchronized void dismiss() { |
| 526 | if (mScreenOn) { |
| 527 | mKeyguardView.dismiss(); |
| 528 | } |
| 529 | } |
| 530 | |
| 531 | /** |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 532 | * @return Whether the keyguard is showing |
| 533 | */ |
| 534 | public synchronized boolean isShowing() { |
| 535 | return (mKeyguardHost != null && mKeyguardHost.getVisibility() == View.VISIBLE); |
| 536 | } |
Jim Miller | 4eeb4f6 | 2012-11-08 00:04:29 -0800 | [diff] [blame] | 537 | |
| 538 | public void showAssistant() { |
| 539 | if (mKeyguardView != null) { |
| 540 | mKeyguardView.showAssistant(); |
| 541 | } |
| 542 | } |
Jim Miller | caf24fc | 2013-09-10 18:37:01 -0700 | [diff] [blame] | 543 | |
| 544 | public void dispatch(MotionEvent event) { |
| 545 | if (mKeyguardView != null) { |
| 546 | mKeyguardView.dispatch(event); |
| 547 | } |
| 548 | } |
Jim Miller | 138f25d | 2013-09-25 13:46:58 -0700 | [diff] [blame] | 549 | |
| 550 | public void launchCamera() { |
| 551 | if (mKeyguardView != null) { |
| 552 | mKeyguardView.launchCamera(); |
| 553 | } |
| 554 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 555 | } |