blob: a88497cdf1038d7d4a0a592a2a2ebb7a1351b8ed [file] [log] [blame]
The Android Open Source Project1f838aa2009-03-03 19:32:13 -08001/*
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 Miller5ecd8112013-01-09 18:50:26 -080017package com.android.keyguard;
The Android Open Source Project1f838aa2009-03-03 19:32:13 -080018
Jim Millerd6523da2012-10-21 16:47:02 -070019import android.app.Activity;
Jim Miller3eb49712014-01-28 18:22:42 -080020import android.app.ActivityManager;
The Android Open Source Project1f838aa2009-03-03 19:32:13 -080021import android.content.Context;
Jim Miller3eb49712014-01-28 18:22:42 -080022import android.content.res.Resources;
23import android.graphics.Canvas;
The Android Open Source Project1f838aa2009-03-03 19:32:13 -080024import android.media.AudioManager;
Jim Miller3eb49712014-01-28 18:22:42 -080025import android.os.SystemClock;
The Android Open Source Projectbc8d29f2009-03-05 20:00:44 -080026import android.telephony.TelephonyManager;
Karl Rosaenad297342009-03-24 18:55:19 -070027import android.util.AttributeSet;
Jean-Michel Trivic6802222012-04-30 11:15:03 -070028import android.util.Log;
Jim Miller838906b2012-10-19 18:41:25 -070029import android.view.KeyEvent;
Jorim Jaggi10c85c72015-02-02 20:45:32 +010030import android.view.accessibility.AccessibilityEvent;
Jim Miller838906b2012-10-19 18:41:25 -070031import android.widget.FrameLayout;
The Android Open Source Project1f838aa2009-03-03 19:32:13 -080032
Jim Miller3eb49712014-01-28 18:22:42 -080033import com.android.internal.widget.LockPatternUtils;
Jim Miller3eb49712014-01-28 18:22:42 -080034import com.android.keyguard.KeyguardSecurityContainer.SecurityCallback;
35import com.android.keyguard.KeyguardSecurityModel.SecurityMode;
36
37import java.io.File;
38
The Android Open Source Project1f838aa2009-03-03 19:32:13 -080039/**
Jim Millerdcb3d842012-08-23 19:18:12 -070040 * Base class for keyguard view. {@link #reset} is where you should
The Android Open Source Project1f838aa2009-03-03 19:32:13 -080041 * reset the state of your view. Use the {@link KeyguardViewCallback} via
42 * {@link #getCallback()} to send information back (such as poking the wake lock,
43 * or finishing the keyguard).
44 *
45 * Handles intercepting of media keys that still work when the keyguard is
46 * showing.
47 */
Jorim Jaggi6b88cdf2014-12-22 20:56:50 +010048public class KeyguardHostView extends FrameLayout implements SecurityCallback {
The Android Open Source Project1f838aa2009-03-03 19:32:13 -080049
Jorim Jaggi5c60b642014-12-19 18:13:28 +010050 public interface OnDismissAction {
51 /**
52 * @return true if the dismiss should be deferred
53 */
54 boolean onDismiss();
55 }
56
The Android Open Source Project1f838aa2009-03-03 19:32:13 -080057 private AudioManager mAudioManager;
The Android Open Source Projectbc8d29f2009-03-05 20:00:44 -080058 private TelephonyManager mTelephonyManager = null;
Jorim Jaggi5cf17872014-03-26 18:31:48 +010059 protected ViewMediatorCallback mViewMediatorCallback;
Jim Miller3eb49712014-01-28 18:22:42 -080060 protected LockPatternUtils mLockPatternUtils;
61 private OnDismissAction mDismissAction;
Jim Millerdcb3d842012-08-23 19:18:12 -070062
Jorim Jaggi6b88cdf2014-12-22 20:56:50 +010063 private final KeyguardUpdateMonitorCallback mUpdateCallback =
64 new KeyguardUpdateMonitorCallback() {
65
66 @Override
67 public void onUserSwitchComplete(int userId) {
68 getSecurityContainer().showPrimarySecurityScreen(false /* turning off */);
69 }
70
71 @Override
72 public void onTrustInitiatedByUser(int userId) {
73 if (userId != mLockPatternUtils.getCurrentUser()) return;
74 if (!isAttachedToWindow()) return;
75
76 if (isVisibleToUser()) {
77 dismiss(false /* authenticated */);
78 } else {
79 mViewMediatorCallback.playTrustedSound();
80 }
81 }
82 };
83
Amith Yamasani2ef6f1b2011-12-01 14:01:30 -080084 // Whether the volume keys should be handled by keyguard. If true, then
85 // they will be handled here for specific media types such as music, otherwise
86 // the audio service will bring up the volume dialog.
John Spurlockae641c92014-06-30 18:11:40 -040087 private static final boolean KEYGUARD_MANAGES_VOLUME = false;
Jorim Jaggi5cf17872014-03-26 18:31:48 +010088 public static final boolean DEBUG = KeyguardConstants.DEBUG;
Jim Miller3eb49712014-01-28 18:22:42 -080089 private static final String TAG = "KeyguardViewBase";
90
91 private KeyguardSecurityContainer mSecurityContainer;
The Android Open Source Project1f838aa2009-03-03 19:32:13 -080092
Jorim Jaggi6b88cdf2014-12-22 20:56:50 +010093 public KeyguardHostView(Context context) {
Jim Millerdcb3d842012-08-23 19:18:12 -070094 this(context, null);
95 }
96
Jorim Jaggi6b88cdf2014-12-22 20:56:50 +010097 public KeyguardHostView(Context context, AttributeSet attrs) {
Jim Millerdcb3d842012-08-23 19:18:12 -070098 super(context, attrs);
Jorim Jaggi6b88cdf2014-12-22 20:56:50 +010099 KeyguardUpdateMonitor.getInstance(context).registerCallback(mUpdateCallback);
The Android Open Source Project1f838aa2009-03-03 19:32:13 -0800100 }
101
Jim Miller3eb49712014-01-28 18:22:42 -0800102 @Override
103 protected void dispatchDraw(Canvas canvas) {
104 super.dispatchDraw(canvas);
105 if (mViewMediatorCallback != null) {
106 mViewMediatorCallback.keyguardDoneDrawing();
107 }
108 }
The Android Open Source Project1f838aa2009-03-03 19:32:13 -0800109
110 /**
Jim Miller3eb49712014-01-28 18:22:42 -0800111 * Sets an action to run when keyguard finishes.
112 *
113 * @param action
The Android Open Source Project1f838aa2009-03-03 19:32:13 -0800114 */
Jim Miller3eb49712014-01-28 18:22:42 -0800115 public void setOnDismissAction(OnDismissAction action) {
116 mDismissAction = action;
117 }
118
119 @Override
120 protected void onFinishInflate() {
121 mSecurityContainer =
122 (KeyguardSecurityContainer) findViewById(R.id.keyguard_security_container);
Jim Miller5e612cf2014-02-03 17:57:23 -0800123 mLockPatternUtils = new LockPatternUtils(mContext);
Jim Miller3eb49712014-01-28 18:22:42 -0800124 mSecurityContainer.setLockPatternUtils(mLockPatternUtils);
Jim Millerba7d94b2014-02-05 17:30:50 -0800125 mSecurityContainer.setSecurityCallback(this);
Jim Miller3eb49712014-01-28 18:22:42 -0800126 mSecurityContainer.showPrimarySecurityScreen(false);
127 // mSecurityContainer.updateSecurityViews(false /* not bouncing */);
Jim Miller3eb49712014-01-28 18:22:42 -0800128 }
The Android Open Source Project1f838aa2009-03-03 19:32:13 -0800129
130 /**
Brian Colonna4284e9d2011-09-28 12:08:58 -0400131 * Called when the view needs to be shown.
132 */
Jorim Jaggi95e89ca2014-11-24 20:12:50 +0100133 public void showPrimarySecurityScreen() {
Jim Miller3eb49712014-01-28 18:22:42 -0800134 if (DEBUG) Log.d(TAG, "show()");
135 mSecurityContainer.showPrimarySecurityScreen(false);
136 }
137
138 /**
139 * Dismisses the keyguard by going to the next screen or making it gone.
Jorim Jaggi0bed7f22014-04-03 16:12:54 +0200140 *
141 * @return True if the keyguard is done.
Jim Miller3eb49712014-01-28 18:22:42 -0800142 */
Jorim Jaggi0bed7f22014-04-03 16:12:54 +0200143 public boolean dismiss() {
144 return dismiss(false);
Jim Miller3eb49712014-01-28 18:22:42 -0800145 }
146
Jim Miller3eb49712014-01-28 18:22:42 -0800147 public boolean handleBackKey() {
Jim Miller3eb49712014-01-28 18:22:42 -0800148 if (mSecurityContainer.getCurrentSecuritySelection() != SecurityMode.None) {
149 mSecurityContainer.dismiss(false);
150 return true;
151 }
152 return false;
153 }
154
Jorim Jaggi10c85c72015-02-02 20:45:32 +0100155 @Override
156 public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
157 if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) {
158 event.getText().add(mSecurityContainer.getCurrentSecurityModeContentDescription());
159 return true;
Jim Miller9ccf1232013-10-10 22:23:07 -0700160 } else {
Jorim Jaggi10c85c72015-02-02 20:45:32 +0100161 return super.dispatchPopulateAccessibilityEvent(event);
Jim Miller9ccf1232013-10-10 22:23:07 -0700162 }
Jim Millere46efc02012-09-07 16:43:51 -0700163 }
Jim Millerdcb3d842012-08-23 19:18:12 -0700164
Jim Millerba7d94b2014-02-05 17:30:50 -0800165 protected KeyguardSecurityContainer getSecurityContainer() {
166 return mSecurityContainer;
167 }
Jim Miller3eb49712014-01-28 18:22:42 -0800168
Jim Millerba7d94b2014-02-05 17:30:50 -0800169 @Override
170 public boolean dismiss(boolean authenticated) {
171 return mSecurityContainer.showNextSecurityScreenOrFinish(authenticated);
Jim Miller3eb49712014-01-28 18:22:42 -0800172 }
173
174 /**
175 * Authentication has happened and it's time to dismiss keyguard. This function
176 * should clean up and inform KeyguardViewMediator.
177 */
Jim Millerba7d94b2014-02-05 17:30:50 -0800178 @Override
Jim Miller3eb49712014-01-28 18:22:42 -0800179 public void finish() {
Jim Miller3eb49712014-01-28 18:22:42 -0800180 // If there's a pending runnable because the user interacted with a widget
181 // and we're leaving keyguard, then run it.
182 boolean deferKeyguardDone = false;
183 if (mDismissAction != null) {
184 deferKeyguardDone = mDismissAction.onDismiss();
185 mDismissAction = null;
186 }
187 if (mViewMediatorCallback != null) {
188 if (deferKeyguardDone) {
189 mViewMediatorCallback.keyguardDonePending();
190 } else {
191 mViewMediatorCallback.keyguardDone(true);
192 }
193 }
194 }
195
Jim Millerba7d94b2014-02-05 17:30:50 -0800196 @Override
Andrew Lee72b46d42015-01-30 13:23:21 -0800197 public void reset() {
198 mViewMediatorCallback.resetKeyguard();
199 }
200
201 @Override
Jim Millerba7d94b2014-02-05 17:30:50 -0800202 public void onSecurityModeChanged(SecurityMode securityMode, boolean needsInput) {
Jim Miller3eb49712014-01-28 18:22:42 -0800203 if (mViewMediatorCallback != null) {
Jim Millerba7d94b2014-02-05 17:30:50 -0800204 mViewMediatorCallback.setNeedsInput(needsInput);
Jim Miller3eb49712014-01-28 18:22:42 -0800205 }
206 }
207
Jim Millerba7d94b2014-02-05 17:30:50 -0800208 public void userActivity() {
Jim Miller3eb49712014-01-28 18:22:42 -0800209 if (mViewMediatorCallback != null) {
210 mViewMediatorCallback.userActivity();
211 }
212 }
213
Jim Miller3eb49712014-01-28 18:22:42 -0800214 /**
Jorim Jaggia005f1b2014-04-16 19:06:10 +0200215 * Called when the Keyguard is not actively shown anymore on the screen.
Jim Miller3eb49712014-01-28 18:22:42 -0800216 */
Jorim Jaggia005f1b2014-04-16 19:06:10 +0200217 public void onPause() {
Jim Miller3eb49712014-01-28 18:22:42 -0800218 if (DEBUG) Log.d(TAG, String.format("screen off, instance %s at %s",
219 Integer.toHexString(hashCode()), SystemClock.uptimeMillis()));
Jim Miller3eb49712014-01-28 18:22:42 -0800220 mSecurityContainer.showPrimarySecurityScreen(true);
221 mSecurityContainer.onPause();
222 clearFocus();
223 }
224
225 /**
Jorim Jaggia005f1b2014-04-16 19:06:10 +0200226 * Called when the Keyguard is actively shown on the screen.
Jim Miller3eb49712014-01-28 18:22:42 -0800227 */
Jorim Jaggia005f1b2014-04-16 19:06:10 +0200228 public void onResume() {
Jim Miller3eb49712014-01-28 18:22:42 -0800229 if (DEBUG) Log.d(TAG, "screen on, instance " + Integer.toHexString(hashCode()));
Jim Miller3eb49712014-01-28 18:22:42 -0800230 mSecurityContainer.onResume(KeyguardSecurityView.SCREEN_ON);
Jim Miller3eb49712014-01-28 18:22:42 -0800231 requestFocus();
232 }
Brian Colonna4284e9d2011-09-28 12:08:58 -0400233
234 /**
Jorim Jaggic14f8292014-05-27 02:25:45 +0200235 * Starts the animation when the Keyguard gets shown.
236 */
237 public void startAppearAnimation() {
238 mSecurityContainer.startAppearAnimation();
239 }
240
Jorim Jaggi76a16232014-08-08 17:00:47 +0200241 public void startDisappearAnimation(Runnable finishRunnable) {
Jorim Jaggi8de4311c2014-08-11 22:36:20 +0200242 if (!mSecurityContainer.startDisappearAnimation(finishRunnable) && finishRunnable != null) {
Jorim Jaggi76a16232014-08-08 17:00:47 +0200243 finishRunnable.run();
244 }
245 }
246
Jorim Jaggic14f8292014-05-27 02:25:45 +0200247 /**
The Android Open Source Project1f838aa2009-03-03 19:32:13 -0800248 * Verify that the user can get past the keyguard securely. This is called,
249 * for example, when the phone disables the keyguard but then wants to launch
250 * something else that requires secure access.
251 *
252 * The result will be propogated back via {@link KeyguardViewCallback#keyguardDone(boolean)}
253 */
Jim Miller3eb49712014-01-28 18:22:42 -0800254 public void verifyUnlock() {
Jim Millerba7d94b2014-02-05 17:30:50 -0800255 SecurityMode securityMode = mSecurityContainer.getSecurityMode();
Jim Miller3eb49712014-01-28 18:22:42 -0800256 if (securityMode == KeyguardSecurityModel.SecurityMode.None) {
257 if (mViewMediatorCallback != null) {
258 mViewMediatorCallback.keyguardDone(true);
259 }
260 } else if (securityMode != KeyguardSecurityModel.SecurityMode.Pattern
261 && securityMode != KeyguardSecurityModel.SecurityMode.PIN
262 && securityMode != KeyguardSecurityModel.SecurityMode.Password) {
263 // can only verify unlock when in pattern/password mode
264 if (mViewMediatorCallback != null) {
265 mViewMediatorCallback.keyguardDone(false);
266 }
267 } else {
268 // otherwise, go to the unlock screen, see if they can verify it
269 mSecurityContainer.verifyUnlock();
270 }
271 }
The Android Open Source Project1f838aa2009-03-03 19:32:13 -0800272
273 /**
274 * Called before this view is being removed.
275 */
Jorim Jaggi6b88cdf2014-12-22 20:56:50 +0100276 public void cleanUp() {
277 getSecurityContainer().onPause();
278 }
Jeff Brownc7505bc2012-10-05 21:58:15 -0700279
The Android Open Source Project1f838aa2009-03-03 19:32:13 -0800280 @Override
281 public boolean dispatchKeyEvent(KeyEvent event) {
The Android Open Source Project1f838aa2009-03-03 19:32:13 -0800282 if (interceptMediaKey(event)) {
283 return true;
284 }
285 return super.dispatchKeyEvent(event);
286 }
287
The Android Open Source Project1f838aa2009-03-03 19:32:13 -0800288 /**
Marco Nelissen24d10562009-05-12 14:15:17 -0700289 * Allows the media keys to work when the keyguard is showing.
290 * The media keys should be of no interest to the actual keyguard view(s),
The Android Open Source Project1f838aa2009-03-03 19:32:13 -0800291 * so intercepting them here should not be of any harm.
292 * @param event The key event
293 * @return whether the event was consumed as a media key.
294 */
Jorim Jaggidf993512014-05-13 23:06:35 +0200295 public boolean interceptMediaKey(KeyEvent event) {
The Android Open Source Project1f838aa2009-03-03 19:32:13 -0800296 final int keyCode = event.getKeyCode();
297 if (event.getAction() == KeyEvent.ACTION_DOWN) {
298 switch (keyCode) {
Marco Nelissena6face42010-10-25 10:21:59 -0700299 case KeyEvent.KEYCODE_MEDIA_PLAY:
300 case KeyEvent.KEYCODE_MEDIA_PAUSE:
Andy Stadler8b89d692009-04-10 16:24:49 -0700301 case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE:
Jeff Brown4d396052010-10-29 21:50:21 -0700302 /* Suppress PLAY/PAUSE toggle when phone is ringing or
The Android Open Source Projectbc8d29f2009-03-05 20:00:44 -0800303 * in-call to avoid music playback */
304 if (mTelephonyManager == null) {
305 mTelephonyManager = (TelephonyManager) getContext().getSystemService(
306 Context.TELEPHONY_SERVICE);
307 }
308 if (mTelephonyManager != null &&
309 mTelephonyManager.getCallState() != TelephonyManager.CALL_STATE_IDLE) {
310 return true; // suppress key event
311 }
Jeff Brown4d396052010-10-29 21:50:21 -0700312 case KeyEvent.KEYCODE_MUTE:
313 case KeyEvent.KEYCODE_HEADSETHOOK:
314 case KeyEvent.KEYCODE_MEDIA_STOP:
315 case KeyEvent.KEYCODE_MEDIA_NEXT:
316 case KeyEvent.KEYCODE_MEDIA_PREVIOUS:
317 case KeyEvent.KEYCODE_MEDIA_REWIND:
318 case KeyEvent.KEYCODE_MEDIA_RECORD:
Jaekyun Seokbfdad8e2013-07-08 13:53:21 +0900319 case KeyEvent.KEYCODE_MEDIA_FAST_FORWARD:
320 case KeyEvent.KEYCODE_MEDIA_AUDIO_TRACK: {
Jean-Michel Trivic6802222012-04-30 11:15:03 -0700321 handleMediaKeyEvent(event);
The Android Open Source Project1f838aa2009-03-03 19:32:13 -0800322 return true;
323 }
324
325 case KeyEvent.KEYCODE_VOLUME_UP:
Jeff Brownb0418da2010-11-01 15:24:01 -0700326 case KeyEvent.KEYCODE_VOLUME_DOWN:
327 case KeyEvent.KEYCODE_VOLUME_MUTE: {
Amith Yamasani2ef6f1b2011-12-01 14:01:30 -0800328 if (KEYGUARD_MANAGES_VOLUME) {
329 synchronized (this) {
330 if (mAudioManager == null) {
331 mAudioManager = (AudioManager) getContext().getSystemService(
332 Context.AUDIO_SERVICE);
333 }
The Android Open Source Project1f838aa2009-03-03 19:32:13 -0800334 }
Jean-Michel Trivi3114ce32012-06-11 15:03:52 -0700335 // Volume buttons should only function for music (local or remote).
336 // TODO: Actually handle MUTE.
RoboErikd3c86422014-06-16 14:00:48 -0700337 mAudioManager.adjustSuggestedStreamVolume(
Jean-Michel Trivi3114ce32012-06-11 15:03:52 -0700338 keyCode == KeyEvent.KEYCODE_VOLUME_UP
339 ? AudioManager.ADJUST_RAISE
RoboErikd3c86422014-06-16 14:00:48 -0700340 : AudioManager.ADJUST_LOWER /* direction */,
341 AudioManager.STREAM_MUSIC /* stream */, 0 /* flags */);
Amith Yamasani2ef6f1b2011-12-01 14:01:30 -0800342 // Don't execute default volume behavior
343 return true;
344 } else {
345 return false;
The Android Open Source Project1f838aa2009-03-03 19:32:13 -0800346 }
The Android Open Source Project1f838aa2009-03-03 19:32:13 -0800347 }
348 }
349 } else if (event.getAction() == KeyEvent.ACTION_UP) {
350 switch (keyCode) {
351 case KeyEvent.KEYCODE_MUTE:
Jeff Brown4d396052010-10-29 21:50:21 -0700352 case KeyEvent.KEYCODE_HEADSETHOOK:
353 case KeyEvent.KEYCODE_MEDIA_PLAY:
354 case KeyEvent.KEYCODE_MEDIA_PAUSE:
355 case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE:
356 case KeyEvent.KEYCODE_MEDIA_STOP:
357 case KeyEvent.KEYCODE_MEDIA_NEXT:
358 case KeyEvent.KEYCODE_MEDIA_PREVIOUS:
359 case KeyEvent.KEYCODE_MEDIA_REWIND:
360 case KeyEvent.KEYCODE_MEDIA_RECORD:
Jaekyun Seokbfdad8e2013-07-08 13:53:21 +0900361 case KeyEvent.KEYCODE_MEDIA_FAST_FORWARD:
362 case KeyEvent.KEYCODE_MEDIA_AUDIO_TRACK: {
Jean-Michel Trivic6802222012-04-30 11:15:03 -0700363 handleMediaKeyEvent(event);
The Android Open Source Project1f838aa2009-03-03 19:32:13 -0800364 return true;
365 }
366 }
367 }
368 return false;
369 }
370
Jim Miller3eb49712014-01-28 18:22:42 -0800371 private void handleMediaKeyEvent(KeyEvent keyEvent) {
RoboErikd3c86422014-06-16 14:00:48 -0700372 synchronized (this) {
373 if (mAudioManager == null) {
374 mAudioManager = (AudioManager) getContext().getSystemService(
375 Context.AUDIO_SERVICE);
Jean-Michel Trivic6802222012-04-30 11:15:03 -0700376 }
Jean-Michel Trivic6802222012-04-30 11:15:03 -0700377 }
RoboErikd3c86422014-06-16 14:00:48 -0700378 mAudioManager.dispatchMediaKeyEvent(keyEvent);
Jean-Michel Trivic6802222012-04-30 11:15:03 -0700379 }
380
Joe Onorato4671ce52011-01-27 21:15:42 -0800381 @Override
382 public void dispatchSystemUiVisibilityChanged(int visibility) {
383 super.dispatchSystemUiVisibilityChanged(visibility);
Jim Millerd6523da2012-10-21 16:47:02 -0700384
385 if (!(mContext instanceof Activity)) {
386 setSystemUiVisibility(STATUS_BAR_DISABLE_BACK);
387 }
Joe Onorato4671ce52011-01-27 21:15:42 -0800388 }
Jim Millerdcb3d842012-08-23 19:18:12 -0700389
Jim Miller3eb49712014-01-28 18:22:42 -0800390 /**
391 * In general, we enable unlocking the insecure keyguard with the menu key. However, there are
392 * some cases where we wish to disable it, notably when the menu button placement or technology
393 * is prone to false positives.
394 *
395 * @return true if the menu key should be enabled
396 */
397 private static final String ENABLE_MENU_KEY_FILE = "/data/local/enable_menu_key";
398 private boolean shouldEnableMenuKey() {
399 final Resources res = getResources();
400 final boolean configDisabled = res.getBoolean(R.bool.config_disableMenuKeyInLockScreen);
401 final boolean isTestHarness = ActivityManager.isRunningInTestHarness();
402 final boolean fileOverride = (new File(ENABLE_MENU_KEY_FILE)).exists();
403 return !configDisabled || isTestHarness || fileOverride;
404 }
405
406 public boolean handleMenuKey() {
407 // The following enables the MENU key to work for testing automation
408 if (shouldEnableMenuKey()) {
409 dismiss();
410 return true;
411 }
412 return false;
413 }
414
Jorim Jaggi5cf17872014-03-26 18:31:48 +0100415 public void setViewMediatorCallback(ViewMediatorCallback viewMediatorCallback) {
Jim Millerdcb3d842012-08-23 19:18:12 -0700416 mViewMediatorCallback = viewMediatorCallback;
Jim Millerba7d94b2014-02-05 17:30:50 -0800417 // Update ViewMediator with the current input method requirements
418 mViewMediatorCallback.setNeedsInput(mSecurityContainer.needsInput());
Jim Millerdcb3d842012-08-23 19:18:12 -0700419 }
Jim Miller3eb49712014-01-28 18:22:42 -0800420
Jorim Jaggi5cf17872014-03-26 18:31:48 +0100421 public void setLockPatternUtils(LockPatternUtils utils) {
Jim Miller5e612cf2014-02-03 17:57:23 -0800422 mLockPatternUtils = utils;
423 mSecurityContainer.setLockPatternUtils(utils);
424 }
425
Jorim Jaggia005f1b2014-04-16 19:06:10 +0200426 public SecurityMode getSecurityMode() {
427 return mSecurityContainer.getSecurityMode();
428 }
429
Jorim Jaggi95e89ca2014-11-24 20:12:50 +0100430 public SecurityMode getCurrentSecurityMode() {
431 return mSecurityContainer.getCurrentSecurityMode();
432 }
The Android Open Source Project1f838aa2009-03-03 19:32:13 -0800433}