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