summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Brown <jeffbrown@google.com>2012-10-01 15:20:47 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-10-01 15:22:43 -0700
commit410bc60a77ee3ba6e596e84d44ec23f3325ae310 (patch)
treeeb27c9abe95012d62a38cb6c8b9ea2972489e71b
parentcb6f950f15919794d26a55c20090fe5dacd11e4a (diff)
parent90fc9059199cde8ff2ed3e3151070d11416e2553 (diff)
downloadframeworks_base-410bc60a77ee3ba6e596e84d44ec23f3325ae310.zip
frameworks_base-410bc60a77ee3ba6e596e84d44ec23f3325ae310.tar.gz
frameworks_base-410bc60a77ee3ba6e596e84d44ec23f3325ae310.tar.bz2
Merge changes I790820b1,I3fcf3619,Ia0d5a156 into jb-mr1-dev
* changes: Enable hardware acceleration for pointer location overlay. Disable use of twilight mode for auto-brightness. Use new API to override user activity timeout from keyguard.
-rw-r--r--core/java/android/os/PowerManager.java9
-rwxr-xr-xpolicy/src/com/android/internal/policy/impl/PhoneWindowManager.java7
-rw-r--r--policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java4
-rw-r--r--policy/src/com/android/internal/policy/impl/keyguard/KeyguardSelectorView.java2
-rw-r--r--policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewManager.java2
-rw-r--r--policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewMediator.java93
-rw-r--r--services/java/com/android/server/power/DisplayPowerController.java4
7 files changed, 45 insertions, 76 deletions
diff --git a/core/java/android/os/PowerManager.java b/core/java/android/os/PowerManager.java
index 58372f4..ae50ddb 100644
--- a/core/java/android/os/PowerManager.java
+++ b/core/java/android/os/PowerManager.java
@@ -340,6 +340,15 @@ public final class PowerManager {
}
/**
+ * Returns true if the twilight service should be used to adjust screen brightness
+ * policy. This setting is experimental and disabled by default.
+ * @hide
+ */
+ public static boolean useTwilightAdjustmentFeature() {
+ return SystemProperties.getBoolean("persist.power.usetwilightadj", false);
+ }
+
+ /**
* Creates a new wake lock with the specified level and flags.
* <p>
* The {@code levelAndFlags} parameter specifies a wake lock level and optional flags
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
index c94c6c4..76eec71 100755
--- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
+++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
@@ -775,7 +775,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
if (keyguardShowing) {
// since it took two seconds of long press to bring this up,
// poke the wake lock so they have some time to see the dialog.
- mKeyguardMediator.pokeWakelock();
+ mKeyguardMediator.userActivity();
}
}
@@ -1140,6 +1140,11 @@ public class PhoneWindowManager implements WindowManagerPolicy {
| WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
| WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
| WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN;
+ if (ActivityManager.isHighEndGfx()) {
+ lp.flags |= WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED;
+ lp.privateFlags |=
+ WindowManager.LayoutParams.PRIVATE_FLAG_FORCE_HARDWARE_ACCELERATED;
+ }
lp.format = PixelFormat.TRANSLUCENT;
lp.setTitle("PointerLocation");
WindowManager wm = (WindowManager)
diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java
index 14633c4..4d56700 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java
@@ -234,7 +234,7 @@ public class KeyguardHostView extends KeyguardViewBase {
public void userActivity(long timeout) {
if (mViewMediatorCallback != null) {
- mViewMediatorCallback.pokeWakelock(timeout);
+ mViewMediatorCallback.userActivity(timeout);
}
}
@@ -638,7 +638,7 @@ public class KeyguardHostView extends KeyguardViewBase {
if (DEBUG) Log.d(TAG, "poking wake lock immediately");
}
if (mViewMediatorCallback != null) {
- mViewMediatorCallback.pokeWakelock();
+ mViewMediatorCallback.wakeUp();
}
}
diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardSelectorView.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardSelectorView.java
index 8714276..1977b52 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardSelectorView.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardSelectorView.java
@@ -76,6 +76,7 @@ public class KeyguardSelectorView extends LinearLayout implements KeyguardSecuri
case com.android.internal.R.drawable.ic_lockscreen_unlock_phantom:
case com.android.internal.R.drawable.ic_lockscreen_unlock:
+ mCallback.userActivity(0);
mCallback.dismiss(false);
break;
}
@@ -86,6 +87,7 @@ public class KeyguardSelectorView extends LinearLayout implements KeyguardSecuri
}
public void onGrabbed(View v, int handle) {
+ mCallback.userActivity(0);
doTransition(mFadeView, 0.0f);
}
diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewManager.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewManager.java
index 1abcc10..a3a9c5f 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewManager.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewManager.java
@@ -155,6 +155,8 @@ public class KeyguardViewManager {
WindowManager.LayoutParams.PRIVATE_FLAG_FORCE_HARDWARE_ACCELERATED;
}
lp.privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_SET_NEEDS_MENU_KEY;
+ lp.inputFeatures |= WindowManager.LayoutParams.INPUT_FEATURE_DISABLE_USER_ACTIVITY;
+ lp.userActivityTimeout = KeyguardViewMediator.AWAKE_INTERVAL_DEFAULT_MS;
lp.setTitle(isActivity ? "KeyguardMock" : "Keyguard");
mWindowLayoutParams = lp;
mViewManager.addView(mKeyguardHost, lp);
diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewMediator.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewMediator.java
index 212a6bb..2c415db 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewMediator.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewMediator.java
@@ -104,7 +104,6 @@ public class KeyguardViewMediator {
"com.android.internal.policy.impl.PhoneWindowManager.DELAYED_KEYGUARD";
// used for handler messages
- private static final int TIMEOUT = 1;
private static final int SHOW = 2;
private static final int HIDE = 3;
private static final int RESET = 4;
@@ -167,12 +166,6 @@ public class KeyguardViewMediator {
private UserManager mUserManager;
/**
- * Used to keep the device awake while the keyguard is showing, i.e for
- * calls to {@link #pokeWakelock()}
- */
- private PowerManager.WakeLock mWakeLock;
-
- /**
* Used to keep the device awake while to ensure the keyguard finishes opening before
* we sleep.
*/
@@ -215,8 +208,6 @@ public class KeyguardViewMediator {
*/
private int mDelayedShowingSequence;
- private int mWakelockSequence;
-
/**
* If the user has disabled the keyguard, then requests to exit, this is
* how we'll ultimately let them know whether it was successful. We use this
@@ -262,15 +253,16 @@ public class KeyguardViewMediator {
public interface ViewMediatorCallback {
/**
- * Request the wakelock to be poked for the default amount of time.
+ * Wake the device immediately.
*/
- void pokeWakelock();
+ void wakeUp();
/**
- * Request the wakelock to be poked for a specific amount of time.
+ * Reports user activity and requests that the screen stay on for the specified
+ * amount of time.
* @param millis The amount of time in millis.
*/
- void pokeWakelock(long millis);
+ void userActivity(long millis);
/**
* Report that the keyguard is done.
@@ -402,12 +394,12 @@ public class KeyguardViewMediator {
};
ViewMediatorCallback mViewMediatorCallback = new ViewMediatorCallback() {
- public void pokeWakelock() {
- KeyguardViewMediator.this.pokeWakelock();
+ public void wakeUp() {
+ KeyguardViewMediator.this.wakeUp();
}
- public void pokeWakelock(long holdMs) {
- KeyguardViewMediator.this.pokeWakelock(holdMs);
+ public void userActivity(long holdMs) {
+ KeyguardViewMediator.this.userActivity(holdMs);
}
public void keyguardDone(boolean authenticated) {
@@ -424,19 +416,18 @@ public class KeyguardViewMediator {
}
};
- public void pokeWakelock() {
- pokeWakelock(AWAKE_INTERVAL_DEFAULT_MS);
+ public void wakeUp() {
+ mPM.wakeUp(SystemClock.uptimeMillis());
}
- public void pokeWakelock(long holdMs) {
- synchronized (this) {
- if (DBG_WAKE) Log.d(TAG, "pokeWakelock(" + holdMs + ")");
- mWakeLock.acquire();
- mHandler.removeMessages(TIMEOUT);
- mWakelockSequence++;
- Message msg = mHandler.obtainMessage(TIMEOUT, mWakelockSequence, 0);
- mHandler.sendMessageDelayed(msg, holdMs);
- }
+ public void userActivity() {
+ userActivity(AWAKE_INTERVAL_DEFAULT_MS);
+ }
+
+ public void userActivity(long holdMs) {
+ // We ignore the hold time. Eventually we should remove it.
+ // Instead, the keyguard window has an explicit user activity timeout set on it.
+ mPM.userActivity(SystemClock.uptimeMillis(), false);
}
/**
@@ -448,9 +439,6 @@ public class KeyguardViewMediator {
mContext = context;
mPM = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
mUserManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
- mWakeLock = mPM.newWakeLock(
- PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "keyguard");
- mWakeLock.setReferenceCounted(false);
mShowKeyguardWakeLock = mPM.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "show keyguard");
mShowKeyguardWakeLock.setReferenceCounted(false);
@@ -737,7 +725,6 @@ public class KeyguardViewMediator {
if (mHidden != isHidden) {
mHidden = isHidden;
updateActivityLockScreenState();
- adjustUserActivityLocked();
adjustStatusBarLocked();
}
}
@@ -1050,9 +1037,6 @@ public class KeyguardViewMediator {
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
- case TIMEOUT:
- handleTimeout(msg.arg1);
- return ;
case SHOW:
handleShow();
return ;
@@ -1103,9 +1087,8 @@ public class KeyguardViewMediator {
if (DEBUG) Log.d(TAG, "handleKeyguardDone");
handleHide();
if (wakeup) {
- mPM.wakeUp(SystemClock.uptimeMillis());
+ wakeUp();
}
- mWakeLock.release();
sendUserPresentBroadcast();
}
@@ -1137,21 +1120,6 @@ public class KeyguardViewMediator {
}
}
- /**
- * Handles the message sent by {@link #pokeWakelock}
- * @param seq used to determine if anything has changed since the message
- * was sent.
- * @see #TIMEOUT
- */
- private void handleTimeout(int seq) {
- synchronized (KeyguardViewMediator.this) {
- if (DEBUG) Log.d(TAG, "handleTimeout");
- if (seq == mWakelockSequence) {
- mWakeLock.release();
- }
- }
- }
-
private void playSounds(boolean locked) {
// User feedback for keyguard.
@@ -1200,8 +1168,8 @@ public class KeyguardViewMediator {
mKeyguardViewManager.show();
mShowing = true;
updateActivityLockScreenState();
- adjustUserActivityLocked();
adjustStatusBarLocked();
+ userActivity();
try {
ActivityManagerNative.getDefault().closeSystemDialogs("lock");
} catch (RemoteException e) {
@@ -1235,23 +1203,10 @@ public class KeyguardViewMediator {
mKeyguardViewManager.hide();
mShowing = false;
updateActivityLockScreenState();
- adjustUserActivityLocked();
adjustStatusBarLocked();
}
}
- private void adjustUserActivityLocked() {
- // disable user activity if we are shown and not hidden
- if (DEBUG) Log.d(TAG, "adjustUserActivityLocked mShowing: " + mShowing + " mHidden: " + mHidden);
- boolean enabled = !mShowing || mHidden;
- // FIXME: Replace this with a new timeout control mechanism.
- //mRealPowerManager.enableUserActivity(enabled);
- if (!enabled && mScreenOn) {
- // reinstate our short screen timeout policy
- pokeWakelock();
- }
- }
-
private void adjustStatusBarLocked() {
if (mStatusBarManager == null) {
mStatusBarManager = (StatusBarManager)
@@ -1320,7 +1275,7 @@ public class KeyguardViewMediator {
if (!mKeyguardViewManager.wakeWhenReadyTq(keyCode)) {
// poke wakelock ourselves if keyguard is no longer active
Log.w(TAG, "mKeyguardViewManager.wakeWhenReadyTq did not poke wake lock, so poke it ourselves");
- pokeWakelock();
+ userActivity();
}
/**
@@ -1328,10 +1283,6 @@ public class KeyguardViewMediator {
* release the handoff wakelock
*/
mWakeAndHandOff.release();
-
- if (!mWakeLock.isHeld()) {
- Log.w(TAG, "mWakeLock not held in mKeyguardViewManager.wakeWhenReadyTq");
- }
}
}
diff --git a/services/java/com/android/server/power/DisplayPowerController.java b/services/java/com/android/server/power/DisplayPowerController.java
index 5f4a786..4f8cdde 100644
--- a/services/java/com/android/server/power/DisplayPowerController.java
+++ b/services/java/com/android/server/power/DisplayPowerController.java
@@ -44,7 +44,6 @@ import android.util.TimeUtils;
import android.view.Display;
import java.io.PrintWriter;
-import java.io.StringWriter;
import java.util.concurrent.Executor;
/**
@@ -95,7 +94,8 @@ final class DisplayPowerController {
// when it is especially dark outside. The light sensor tends to perform
// poorly at low light levels so we compensate for it by making an
// assumption about the environment.
- private static final boolean USE_TWILIGHT_ADJUSTMENT = true;
+ private static final boolean USE_TWILIGHT_ADJUSTMENT =
+ PowerManager.useTwilightAdjustmentFeature();
// Specifies the maximum magnitude of the time of day adjustment.
private static final float TWILIGHT_ADJUSTMENT_MAX_GAMMA = 1.5f;