Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5e612cf0 authored by Jim Miller's avatar Jim Miller
Browse files

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
parent 3eb4971b
Loading
Loading
Loading
Loading
+49 −0
Original line number Diff line number Diff line
<?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>
+19 −5
Original line number Diff line number Diff line
@@ -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);
            }
        }
    }

}
+1 −1
Original line number Diff line number Diff line
@@ -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;
+27 −3
Original line number Diff line number Diff line
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 {

@@ -9,22 +11,44 @@ public class KeyguardSimpleHostView extends KeyguardViewBase {
        super(context, attrs);
    }

    @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;
    }

}
+14 −0
Original line number Diff line number Diff line
@@ -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);

}
Loading