Skip to content

Commit c2a2816

Browse files
Jim MillerAndroid (Google) Code Review
authored andcommitted
Merge "Update keyguard to send userActivity events" into jb-mr1-dev
2 parents fd28053 + 5d2da71 commit c2a2816

File tree

3 files changed

+46
-6
lines changed

3 files changed

+46
-6
lines changed

policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -724,6 +724,7 @@ private void maybePopulateWidgets() {
724724
inflateAndAddUserSelectorWidgetIfNecessary();
725725

726726
// Add status widget
727+
View statusView = null;
727728
int statusWidgetId = mLockPatternUtils.getStatusWidget();
728729
if (statusWidgetId != -1) {
729730
addWidget(statusWidgetId);
@@ -737,6 +738,16 @@ private void maybePopulateWidgets() {
737738
mAppWidgetContainer.removeView(newStatusWidget);
738739
newStatusWidget.setId(R.id.keyguard_status_view);
739740
mAppWidgetContainer.addView(newStatusWidget, oldStatusWidgetPosition);
741+
statusView = newStatusWidget;
742+
} else {
743+
statusView = findViewById(R.id.keyguard_status_view);
744+
}
745+
746+
// Disable all user interaction on status view. This is done to prevent falsing in the
747+
// pocket from triggering useractivity and prevents 3rd party replacement widgets
748+
// from responding to user interaction while in this position.
749+
if (statusView instanceof KeyguardWidgetFrame) {
750+
((KeyguardWidgetFrame) statusView).setDisableUserInteraction(true);
740751
}
741752

742753
// Add user-selected widget

policy/src/com/android/internal/policy/impl/keyguard/KeyguardWidgetFrame.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@
2626
import android.graphics.PorterDuffXfermode;
2727
import android.graphics.Rect;
2828
import android.graphics.Shader;
29+
import android.os.PowerManager;
30+
import android.os.SystemClock;
2931
import android.util.AttributeSet;
32+
import android.view.MotionEvent;
3033
import android.widget.FrameLayout;
3134

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

4954
public KeyguardWidgetFrame(Context context) {
5055
this(context, null, 0);
@@ -56,6 +61,9 @@ public KeyguardWidgetFrame(Context context, AttributeSet attrs) {
5661

5762
public KeyguardWidgetFrame(Context context, AttributeSet attrs, int defStyle) {
5863
super(context, attrs, defStyle);
64+
65+
mPowerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
66+
5967
Resources res = context.getResources();
6068
int hPadding = res.getDimensionPixelSize(R.dimen.kg_widget_pager_horizontal_padding);
6169
int topPadding = res.getDimensionPixelSize(R.dimen.kg_widget_pager_top_padding);
@@ -65,6 +73,19 @@ public KeyguardWidgetFrame(Context context, AttributeSet attrs, int defStyle) {
6573
mGradientPaint.setXfermode(sAddBlendMode);
6674
}
6775

76+
public void setDisableUserInteraction(boolean disabled) {
77+
mDisableInteraction = disabled;
78+
}
79+
80+
@Override
81+
public boolean onInterceptTouchEvent(MotionEvent ev) {
82+
if (!mDisableInteraction) {
83+
mPowerManager.userActivity(SystemClock.uptimeMillis(), false);
84+
return super.onInterceptTouchEvent(ev);
85+
}
86+
return true;
87+
}
88+
6889
@Override
6990
protected void dispatchDraw(Canvas canvas) {
7091
super.dispatchDraw(canvas);

policy/src/com/android/internal/policy/impl/keyguard/KeyguardWidgetRegion.java

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
package com.android.internal.policy.impl.keyguard;
1717

1818
import android.content.Context;
19+
import android.os.PowerManager;
20+
import android.os.SystemClock;
1921
import android.util.AttributeSet;
2022
import android.view.View;
2123
import android.view.ViewGroup;
@@ -29,6 +31,7 @@ public class KeyguardWidgetRegion extends LinearLayout implements PageSwitchList
2931
KeyguardGlowStripView mRightStrip;
3032
KeyguardWidgetPager mPager;
3133
private int mPage = 0;
34+
private PowerManager mPowerManager;
3235

3336
public KeyguardWidgetRegion(Context context) {
3437
this(context, null, 0);
@@ -40,6 +43,7 @@ public KeyguardWidgetRegion(Context context, AttributeSet attrs) {
4043

4144
public KeyguardWidgetRegion(Context context, AttributeSet attrs, int defStyle) {
4245
super(context, attrs, defStyle);
46+
mPowerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
4347
}
4448

4549
@Override
@@ -70,21 +74,25 @@ public void showPagingFeedback() {
7074

7175
@Override
7276
public void onPageSwitch(View newPage, int newPageIndex) {
73-
mPage = newPageIndex;
74-
75-
// If we're showing the default system status widget, then we want to hide the clock
76-
boolean hideClock = false;
77+
boolean showingStatusWidget = false;
7778
if ((newPage instanceof ViewGroup)) {
7879
ViewGroup vg = (ViewGroup) newPage;
7980
if (vg.getChildAt(0) instanceof KeyguardStatusView) {
80-
hideClock = true;
81+
showingStatusWidget = true;
8182
}
8283
}
8384

84-
if (hideClock) {
85+
// Disable the status bar clock if we're showing the default status widget
86+
if (showingStatusWidget) {
8587
setSystemUiVisibility(getSystemUiVisibility() | View.STATUS_BAR_DISABLE_CLOCK);
8688
} else {
8789
setSystemUiVisibility(getSystemUiVisibility() & ~View.STATUS_BAR_DISABLE_CLOCK);
8890
}
91+
92+
// Extend the display timeout if the user switches pages
93+
if (mPage != newPageIndex) {
94+
mPowerManager.userActivity(SystemClock.uptimeMillis(), false);
95+
mPage = newPageIndex;
96+
}
8997
}
9098
}

0 commit comments

Comments
 (0)