diff options
author | Jim Miller <jaggies@google.com> | 2014-02-03 17:57:23 -0800 |
---|---|---|
committer | Jim Miller <jaggies@google.com> | 2014-02-06 16:13:42 -0800 |
commit | 5e612cf07872dc0989a4b9f09e2a38a2ee12186d (patch) | |
tree | b903839085deb9ee5210d039f5324f6dc8df18a4 | |
parent | 3eb4971b679464e206cb666de1cf0e5a538c8d7d (diff) | |
download | frameworks_base-5e612cf07872dc0989a4b9f09e2a38a2ee12186d.zip frameworks_base-5e612cf07872dc0989a4b9f09e2a38a2ee12186d.tar.gz frameworks_base-5e612cf07872dc0989a4b9f09e2a38a2ee12186d.tar.bz2 |
Add KeyguardSimpleHostView and make it the default
This adds a simplified KeyguardHostView that's intended to
be used as an overlay or dialog for asking the user's
credentials.
Bug 12135931
Change-Id: Iecede0715d671e88024e7bb77e7432cd1c7ec356
6 files changed, 120 insertions, 22 deletions
diff --git a/packages/Keyguard/res/layout-port/keyguard_simple_host_view.xml b/packages/Keyguard/res/layout-port/keyguard_simple_host_view.xml new file mode 100644 index 0000000..cba7667 --- /dev/null +++ b/packages/Keyguard/res/layout-port/keyguard_simple_host_view.xml @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +** +** Copyright 2012, The Android Open Source Project +** +** Licensed under the Apache License, Version 2.0 (the "License") +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ +--> + +<!-- This is the host view that generally contains two sub views: the widget view + and the security view. --> +<com.android.keyguard.KeyguardSimpleHostView + xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:androidprv="http://schemas.android.com/apk/res/com.android.keyguard" + android:id="@+id/keyguard_host_view" + android:layout_width="match_parent" + android:layout_height="match_parent"> + + <com.android.keyguard.KeyguardSecurityContainer + android:id="@+id/keyguard_security_container" + android:layout_width="wrap_content" + android:layout_height="@dimen/keyguard_security_height" + android:clipChildren="false" + android:clipToPadding="false" + android:padding="0dp" + android:layout_gravity="center"> + <com.android.keyguard.KeyguardSecurityViewFlipper + android:id="@+id/view_flipper" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:clipChildren="false" + android:clipToPadding="false" + android:paddingTop="@dimen/keyguard_security_view_margin" + android:gravity="center"> + </com.android.keyguard.KeyguardSecurityViewFlipper> + </com.android.keyguard.KeyguardSecurityContainer> + +</com.android.keyguard.KeyguardSimpleHostView> + diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardHostView.java b/packages/Keyguard/src/com/android/keyguard/KeyguardHostView.java index 316a7ec..563aa0b 100644 --- a/packages/Keyguard/src/com/android/keyguard/KeyguardHostView.java +++ b/packages/Keyguard/src/com/android/keyguard/KeyguardHostView.java @@ -40,6 +40,7 @@ import android.content.pm.UserInfo; import android.content.res.Resources; import android.graphics.Rect; import android.media.RemoteControlClient; +import android.os.Bundle; import android.os.Looper; import android.os.Parcel; import android.os.Parcelable; @@ -448,9 +449,9 @@ public class KeyguardHostView extends KeyguardViewBase { || (mDisabledFeatures & DevicePolicyManager.KEYGUARD_DISABLE_SECURE_CAMERA) != 0; } - void setLockPatternUtils(LockPatternUtils utils) { - mLockPatternUtils = utils; - getSecurityContainer().setLockPatternUtils(utils); + @Override + protected void setLockPatternUtils(LockPatternUtils utils) { + super.setLockPatternUtils(utils); getSecurityContainer().updateSecurityViews(mViewStateManager.isBouncing()); } @@ -510,7 +511,8 @@ public class KeyguardHostView extends KeyguardViewBase { } }; - public void initializeSwitchingUserState(boolean switching) { + @Override + public void onUserSwitching(boolean switching) { if (!switching && mKeyguardMultiUserSelectorView != null) { mKeyguardMultiUserSelectorView.finalizeActiveUserView(false); } @@ -1143,8 +1145,20 @@ public class KeyguardHostView extends KeyguardViewBase { mViewStateManager.showBouncer(show); } - public void dispatch(MotionEvent event) { + @Override + public void onExternalMotionEvent(MotionEvent event) { mAppWidgetContainer.handleExternalCameraEvent(event); } + @Override + protected void onCreateOptions(Bundle options) { + if (options != null) { + int widgetToShow = options.getInt(LockPatternUtils.KEYGUARD_SHOW_APPWIDGET, + AppWidgetManager.INVALID_APPWIDGET_ID); + if (widgetToShow != AppWidgetManager.INVALID_APPWIDGET_ID) { + goToWidget(widgetToShow); + } + } + } + } diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardSecurityModel.java b/packages/Keyguard/src/com/android/keyguard/KeyguardSecurityModel.java index 4129e33..9f5768a 100644 --- a/packages/Keyguard/src/com/android/keyguard/KeyguardSecurityModel.java +++ b/packages/Keyguard/src/com/android/keyguard/KeyguardSecurityModel.java @@ -105,7 +105,7 @@ public class KeyguardSecurityModel { break; default: - throw new IllegalStateException("Unknown unlock mode:" + mode); + throw new IllegalStateException("Unknown security quality:" + security); } } return mode; diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardSimpleHostView.java b/packages/Keyguard/src/com/android/keyguard/KeyguardSimpleHostView.java index f1058d2..d980964 100644 --- a/packages/Keyguard/src/com/android/keyguard/KeyguardSimpleHostView.java +++ b/packages/Keyguard/src/com/android/keyguard/KeyguardSimpleHostView.java @@ -1,7 +1,9 @@ package com.android.keyguard; import android.content.Context; +import android.os.Bundle; import android.util.AttributeSet; +import android.view.MotionEvent; public class KeyguardSimpleHostView extends KeyguardViewBase { @@ -10,21 +12,43 @@ public class KeyguardSimpleHostView extends KeyguardViewBase { } @Override + protected void showBouncer(boolean show) { + super.showBouncer(show); + if (show) { + getSecurityContainer().showBouncer(250); + } else { + getSecurityContainer().hideBouncer(250); + } + } + + @Override public void verifyUnlock() { // TODO Auto-generated method stub - } @Override public void cleanUp() { // TODO Auto-generated method stub - } @Override public long getUserActivityTimeout() { + return -1; // not used + } + + @Override + protected void onUserSwitching(boolean switching) { + // TODO Auto-generated method stub + } + + @Override + protected void onCreateOptions(Bundle options) { + // TODO Auto-generated method stub + } + + @Override + protected void onExternalMotionEvent(MotionEvent event) { // TODO Auto-generated method stub - return 0; } } diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardViewBase.java b/packages/Keyguard/src/com/android/keyguard/KeyguardViewBase.java index 79297d6..337beae 100644 --- a/packages/Keyguard/src/com/android/keyguard/KeyguardViewBase.java +++ b/packages/Keyguard/src/com/android/keyguard/KeyguardViewBase.java @@ -26,6 +26,7 @@ import android.content.res.Resources; import android.graphics.Canvas; import android.media.AudioManager; import android.media.IAudioService; +import android.os.Bundle; import android.os.RemoteException; import android.os.ServiceManager; import android.os.SystemClock; @@ -35,6 +36,7 @@ import android.util.AttributeSet; import android.util.Log; import android.util.Slog; import android.view.KeyEvent; +import android.view.MotionEvent; import android.view.View; import android.widget.FrameLayout; @@ -100,6 +102,7 @@ public abstract class KeyguardViewBase extends FrameLayout { protected void onFinishInflate() { mSecurityContainer = (KeyguardSecurityContainer) findViewById(R.id.keyguard_security_container); + mLockPatternUtils = new LockPatternUtils(mContext); mSecurityContainer.setLockPatternUtils(mLockPatternUtils); mSecurityContainer.setSecurityCallback(new SecurityCallback() { @Override @@ -495,4 +498,15 @@ public abstract class KeyguardViewBase extends FrameLayout { mActivityLauncher.launchCamera(getHandler(), null); } + protected void setLockPatternUtils(LockPatternUtils utils) { + mLockPatternUtils = utils; + mSecurityContainer.setLockPatternUtils(utils); + } + + protected abstract void onUserSwitching(boolean switching); + + protected abstract void onCreateOptions(Bundle options); + + protected abstract void onExternalMotionEvent(MotionEvent event); + } diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardViewManager.java b/packages/Keyguard/src/com/android/keyguard/KeyguardViewManager.java index f2853c8..775eb08 100644 --- a/packages/Keyguard/src/com/android/keyguard/KeyguardViewManager.java +++ b/packages/Keyguard/src/com/android/keyguard/KeyguardViewManager.java @@ -18,9 +18,12 @@ package com.android.keyguard; import android.graphics.Bitmap; import android.graphics.drawable.BitmapDrawable; + import com.android.internal.policy.IKeyguardShowCallback; import com.android.internal.widget.LockPatternUtils; +import org.xmlpull.v1.XmlPullParser; + import android.app.ActivityManager; import android.appwidget.AppWidgetManager; import android.content.Context; @@ -66,6 +69,7 @@ public class KeyguardViewManager { // Timeout used for keypresses static final int DIGIT_PRESS_WAKE_MILLIS = 5000; + private static final int HOST_LAYOUT = R.layout.keyguard_simple_host_view; private final Context mContext; private final ViewManager mViewManager; @@ -75,7 +79,7 @@ public class KeyguardViewManager { private boolean mNeedsInput = false; private ViewManagerHost mKeyguardHost; - private KeyguardHostView mKeyguardView; + private KeyguardViewBase mKeyguardView; private boolean mScreenOn = false; private LockPatternUtils mLockPatternUtils; @@ -321,12 +325,11 @@ public class KeyguardViewManager { mKeyguardHost.removeView(v); } final LayoutInflater inflater = LayoutInflater.from(mContext); - View view = inflater.inflate(R.layout.keyguard_host_view, mKeyguardHost, true); - mKeyguardView = (KeyguardHostView) view.findViewById(R.id.keyguard_host_view); + View view = inflater.inflate(HOST_LAYOUT, mKeyguardHost, true); + mKeyguardView = (KeyguardViewBase) view.findViewById(R.id.keyguard_host_view); mKeyguardView.setLockPatternUtils(mLockPatternUtils); mKeyguardView.setViewMediatorCallback(mViewMediatorCallback); - mKeyguardView.initializeSwitchingUserState(options != null && - options.getBoolean(IS_SWITCHING_USER)); + mKeyguardView.onUserSwitching(options != null && options.getBoolean(IS_SWITCHING_USER)); // HACK // The keyguard view will have set up window flags in onFinishInflate before we set @@ -340,13 +343,7 @@ public class KeyguardViewManager { } } - if (options != null) { - int widgetToShow = options.getInt(LockPatternUtils.KEYGUARD_SHOW_APPWIDGET, - AppWidgetManager.INVALID_APPWIDGET_ID); - if (widgetToShow != AppWidgetManager.INVALID_APPWIDGET_ID) { - mKeyguardView.goToWidget(widgetToShow); - } - } + mKeyguardView.onCreateOptions(options); } public void updateUserActivityTimeout() { @@ -541,7 +538,7 @@ public class KeyguardViewManager { public void dispatch(MotionEvent event) { if (mKeyguardView != null) { - mKeyguardView.dispatch(event); + mKeyguardView.onExternalMotionEvent(event); } } |