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

Commit c2a28163 authored by Jim Miller's avatar Jim Miller Committed by Android (Google) Code Review
Browse files

Merge "Update keyguard to send userActivity events" into jb-mr1-dev

parents fd28053d 5d2da713
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -724,6 +724,7 @@ public class KeyguardHostView extends KeyguardViewBase {
        inflateAndAddUserSelectorWidgetIfNecessary();

        // Add status widget
        View statusView = null;
        int statusWidgetId = mLockPatternUtils.getStatusWidget();
        if (statusWidgetId != -1) {
            addWidget(statusWidgetId);
@@ -737,6 +738,16 @@ public class KeyguardHostView extends KeyguardViewBase {
            mAppWidgetContainer.removeView(newStatusWidget);
            newStatusWidget.setId(R.id.keyguard_status_view);
            mAppWidgetContainer.addView(newStatusWidget, oldStatusWidgetPosition);
            statusView = newStatusWidget;
        } else {
            statusView = findViewById(R.id.keyguard_status_view);
        }

        // Disable all user interaction on status view. This is done to prevent falsing in the
        // pocket from triggering useractivity and prevents 3rd party replacement widgets
        // from responding to user interaction while in this position.
        if (statusView instanceof KeyguardWidgetFrame) {
            ((KeyguardWidgetFrame) statusView).setDisableUserInteraction(true);
        }

        // Add user-selected widget
+21 −0
Original line number Diff line number Diff line
@@ -26,7 +26,10 @@ import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;
import android.graphics.Rect;
import android.graphics.Shader;
import android.os.PowerManager;
import android.os.SystemClock;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.FrameLayout;

import com.android.internal.R;
@@ -45,6 +48,8 @@ public class KeyguardWidgetFrame extends FrameLayout {
    private float mOverScrollAmount = 0f;
    private final Rect mForegroundRect = new Rect();
    private int mForegroundAlpha = 0;
    private PowerManager mPowerManager;
    private boolean mDisableInteraction;

    public KeyguardWidgetFrame(Context context) {
        this(context, null, 0);
@@ -56,6 +61,9 @@ public class KeyguardWidgetFrame extends FrameLayout {

    public KeyguardWidgetFrame(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);

        mPowerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);

        Resources res = context.getResources();
        int hPadding = res.getDimensionPixelSize(R.dimen.kg_widget_pager_horizontal_padding);
        int topPadding = res.getDimensionPixelSize(R.dimen.kg_widget_pager_top_padding);
@@ -65,6 +73,19 @@ public class KeyguardWidgetFrame extends FrameLayout {
        mGradientPaint.setXfermode(sAddBlendMode);
    }

    public void setDisableUserInteraction(boolean disabled) {
        mDisableInteraction = disabled;
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
        if (!mDisableInteraction) {
            mPowerManager.userActivity(SystemClock.uptimeMillis(), false);
            return super.onInterceptTouchEvent(ev);
        }
        return true;
    }

    @Override
    protected void dispatchDraw(Canvas canvas) {
        super.dispatchDraw(canvas);
+14 −6
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@
package com.android.internal.policy.impl.keyguard;

import android.content.Context;
import android.os.PowerManager;
import android.os.SystemClock;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
@@ -29,6 +31,7 @@ public class KeyguardWidgetRegion extends LinearLayout implements PageSwitchList
    KeyguardGlowStripView mRightStrip;
    KeyguardWidgetPager mPager;
    private int mPage = 0;
    private PowerManager mPowerManager;

    public KeyguardWidgetRegion(Context context) {
        this(context, null, 0);
@@ -40,6 +43,7 @@ public class KeyguardWidgetRegion extends LinearLayout implements PageSwitchList

    public KeyguardWidgetRegion(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        mPowerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
    }

    @Override
@@ -70,21 +74,25 @@ public class KeyguardWidgetRegion extends LinearLayout implements PageSwitchList

    @Override
    public void onPageSwitch(View newPage, int newPageIndex) {
        mPage = newPageIndex;

        // If we're showing the default system status widget, then we want to hide the clock
        boolean hideClock = false;
        boolean showingStatusWidget = false;
        if ((newPage instanceof ViewGroup)) {
            ViewGroup vg = (ViewGroup) newPage;
            if (vg.getChildAt(0) instanceof KeyguardStatusView) {
                hideClock = true;
                showingStatusWidget = true;
            }
        }

        if (hideClock) {
        // Disable the status bar clock if we're showing the default status widget
        if (showingStatusWidget) {
            setSystemUiVisibility(getSystemUiVisibility() | View.STATUS_BAR_DISABLE_CLOCK);
        } else {
            setSystemUiVisibility(getSystemUiVisibility() & ~View.STATUS_BAR_DISABLE_CLOCK);
        }

        // Extend the display timeout if the user switches pages
        if (mPage != newPageIndex) {
            mPowerManager.userActivity(SystemClock.uptimeMillis(), false);
            mPage = newPageIndex;
        }
    }
}