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.
This commit is contained in:
@@ -339,6 +339,15 @@ public final class PowerManager {
|
||||
return SystemProperties.getBoolean("persist.power.useautobrightadj", false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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>
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
@@ -166,12 +165,6 @@ public class KeyguardViewMediator {
|
||||
/** UserManager for querying number of users */
|
||||
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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user