am 410bc60a: Merge changes I790820b1,I3fcf3619,Ia0d5a156 into jb-mr1-dev

* commit '410bc60a77ee3ba6e596e84d44ec23f3325ae310':
  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:
Jeff Brown
2012-10-01 15:25:35 -07:00
committed by Android Git Automerger
7 changed files with 45 additions and 76 deletions

View File

@@ -339,6 +339,15 @@ public final class PowerManager {
return SystemProperties.getBoolean("persist.power.useautobrightadj", false); 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. * Creates a new wake lock with the specified level and flags.
* <p> * <p>

View File

@@ -775,7 +775,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
if (keyguardShowing) { if (keyguardShowing) {
// since it took two seconds of long press to bring this up, // 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. // 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_TOUCHABLE
| WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
| WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN; | 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.format = PixelFormat.TRANSLUCENT;
lp.setTitle("PointerLocation"); lp.setTitle("PointerLocation");
WindowManager wm = (WindowManager) WindowManager wm = (WindowManager)

View File

@@ -234,7 +234,7 @@ public class KeyguardHostView extends KeyguardViewBase {
public void userActivity(long timeout) { public void userActivity(long timeout) {
if (mViewMediatorCallback != null) { 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 (DEBUG) Log.d(TAG, "poking wake lock immediately");
} }
if (mViewMediatorCallback != null) { if (mViewMediatorCallback != null) {
mViewMediatorCallback.pokeWakelock(); mViewMediatorCallback.wakeUp();
} }
} }

View File

@@ -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_phantom:
case com.android.internal.R.drawable.ic_lockscreen_unlock: case com.android.internal.R.drawable.ic_lockscreen_unlock:
mCallback.userActivity(0);
mCallback.dismiss(false); mCallback.dismiss(false);
break; break;
} }
@@ -86,6 +87,7 @@ public class KeyguardSelectorView extends LinearLayout implements KeyguardSecuri
} }
public void onGrabbed(View v, int handle) { public void onGrabbed(View v, int handle) {
mCallback.userActivity(0);
doTransition(mFadeView, 0.0f); doTransition(mFadeView, 0.0f);
} }

View File

@@ -155,6 +155,8 @@ public class KeyguardViewManager {
WindowManager.LayoutParams.PRIVATE_FLAG_FORCE_HARDWARE_ACCELERATED; WindowManager.LayoutParams.PRIVATE_FLAG_FORCE_HARDWARE_ACCELERATED;
} }
lp.privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_SET_NEEDS_MENU_KEY; 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"); lp.setTitle(isActivity ? "KeyguardMock" : "Keyguard");
mWindowLayoutParams = lp; mWindowLayoutParams = lp;
mViewManager.addView(mKeyguardHost, lp); mViewManager.addView(mKeyguardHost, lp);

View File

@@ -104,7 +104,6 @@ public class KeyguardViewMediator {
"com.android.internal.policy.impl.PhoneWindowManager.DELAYED_KEYGUARD"; "com.android.internal.policy.impl.PhoneWindowManager.DELAYED_KEYGUARD";
// used for handler messages // used for handler messages
private static final int TIMEOUT = 1;
private static final int SHOW = 2; private static final int SHOW = 2;
private static final int HIDE = 3; private static final int HIDE = 3;
private static final int RESET = 4; private static final int RESET = 4;
@@ -166,12 +165,6 @@ public class KeyguardViewMediator {
/** UserManager for querying number of users */ /** UserManager for querying number of users */
private UserManager mUserManager; 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 * Used to keep the device awake while to ensure the keyguard finishes opening before
* we sleep. * we sleep.
@@ -215,8 +208,6 @@ public class KeyguardViewMediator {
*/ */
private int mDelayedShowingSequence; private int mDelayedShowingSequence;
private int mWakelockSequence;
/** /**
* If the user has disabled the keyguard, then requests to exit, this is * 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 * how we'll ultimately let them know whether it was successful. We use this
@@ -262,15 +253,16 @@ public class KeyguardViewMediator {
public interface ViewMediatorCallback { 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. * @param millis The amount of time in millis.
*/ */
void pokeWakelock(long millis); void userActivity(long millis);
/** /**
* Report that the keyguard is done. * Report that the keyguard is done.
@@ -402,12 +394,12 @@ public class KeyguardViewMediator {
}; };
ViewMediatorCallback mViewMediatorCallback = new ViewMediatorCallback() { ViewMediatorCallback mViewMediatorCallback = new ViewMediatorCallback() {
public void pokeWakelock() { public void wakeUp() {
KeyguardViewMediator.this.pokeWakelock(); KeyguardViewMediator.this.wakeUp();
} }
public void pokeWakelock(long holdMs) { public void userActivity(long holdMs) {
KeyguardViewMediator.this.pokeWakelock(holdMs); KeyguardViewMediator.this.userActivity(holdMs);
} }
public void keyguardDone(boolean authenticated) { public void keyguardDone(boolean authenticated) {
@@ -424,19 +416,18 @@ public class KeyguardViewMediator {
} }
}; };
public void pokeWakelock() { public void wakeUp() {
pokeWakelock(AWAKE_INTERVAL_DEFAULT_MS); mPM.wakeUp(SystemClock.uptimeMillis());
} }
public void pokeWakelock(long holdMs) { public void userActivity() {
synchronized (this) { userActivity(AWAKE_INTERVAL_DEFAULT_MS);
if (DBG_WAKE) Log.d(TAG, "pokeWakelock(" + holdMs + ")"); }
mWakeLock.acquire();
mHandler.removeMessages(TIMEOUT); public void userActivity(long holdMs) {
mWakelockSequence++; // We ignore the hold time. Eventually we should remove it.
Message msg = mHandler.obtainMessage(TIMEOUT, mWakelockSequence, 0); // Instead, the keyguard window has an explicit user activity timeout set on it.
mHandler.sendMessageDelayed(msg, holdMs); mPM.userActivity(SystemClock.uptimeMillis(), false);
}
} }
/** /**
@@ -448,9 +439,6 @@ public class KeyguardViewMediator {
mContext = context; mContext = context;
mPM = (PowerManager) context.getSystemService(Context.POWER_SERVICE); mPM = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
mUserManager = (UserManager) mContext.getSystemService(Context.USER_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 = mPM.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "show keyguard");
mShowKeyguardWakeLock.setReferenceCounted(false); mShowKeyguardWakeLock.setReferenceCounted(false);
@@ -737,7 +725,6 @@ public class KeyguardViewMediator {
if (mHidden != isHidden) { if (mHidden != isHidden) {
mHidden = isHidden; mHidden = isHidden;
updateActivityLockScreenState(); updateActivityLockScreenState();
adjustUserActivityLocked();
adjustStatusBarLocked(); adjustStatusBarLocked();
} }
} }
@@ -1050,9 +1037,6 @@ public class KeyguardViewMediator {
@Override @Override
public void handleMessage(Message msg) { public void handleMessage(Message msg) {
switch (msg.what) { switch (msg.what) {
case TIMEOUT:
handleTimeout(msg.arg1);
return ;
case SHOW: case SHOW:
handleShow(); handleShow();
return ; return ;
@@ -1103,9 +1087,8 @@ public class KeyguardViewMediator {
if (DEBUG) Log.d(TAG, "handleKeyguardDone"); if (DEBUG) Log.d(TAG, "handleKeyguardDone");
handleHide(); handleHide();
if (wakeup) { if (wakeup) {
mPM.wakeUp(SystemClock.uptimeMillis()); wakeUp();
} }
mWakeLock.release();
sendUserPresentBroadcast(); 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) { private void playSounds(boolean locked) {
// User feedback for keyguard. // User feedback for keyguard.
@@ -1200,8 +1168,8 @@ public class KeyguardViewMediator {
mKeyguardViewManager.show(); mKeyguardViewManager.show();
mShowing = true; mShowing = true;
updateActivityLockScreenState(); updateActivityLockScreenState();
adjustUserActivityLocked();
adjustStatusBarLocked(); adjustStatusBarLocked();
userActivity();
try { try {
ActivityManagerNative.getDefault().closeSystemDialogs("lock"); ActivityManagerNative.getDefault().closeSystemDialogs("lock");
} catch (RemoteException e) { } catch (RemoteException e) {
@@ -1235,23 +1203,10 @@ public class KeyguardViewMediator {
mKeyguardViewManager.hide(); mKeyguardViewManager.hide();
mShowing = false; mShowing = false;
updateActivityLockScreenState(); updateActivityLockScreenState();
adjustUserActivityLocked();
adjustStatusBarLocked(); 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() { private void adjustStatusBarLocked() {
if (mStatusBarManager == null) { if (mStatusBarManager == null) {
mStatusBarManager = (StatusBarManager) mStatusBarManager = (StatusBarManager)
@@ -1320,7 +1275,7 @@ public class KeyguardViewMediator {
if (!mKeyguardViewManager.wakeWhenReadyTq(keyCode)) { if (!mKeyguardViewManager.wakeWhenReadyTq(keyCode)) {
// poke wakelock ourselves if keyguard is no longer active // poke wakelock ourselves if keyguard is no longer active
Log.w(TAG, "mKeyguardViewManager.wakeWhenReadyTq did not poke wake lock, so poke it ourselves"); 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 * release the handoff wakelock
*/ */
mWakeAndHandOff.release(); mWakeAndHandOff.release();
if (!mWakeLock.isHeld()) {
Log.w(TAG, "mWakeLock not held in mKeyguardViewManager.wakeWhenReadyTq");
}
} }
} }

View File

@@ -44,7 +44,6 @@ import android.util.TimeUtils;
import android.view.Display; import android.view.Display;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.concurrent.Executor; import java.util.concurrent.Executor;
/** /**
@@ -95,7 +94,8 @@ final class DisplayPowerController {
// when it is especially dark outside. The light sensor tends to perform // 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 // poorly at low light levels so we compensate for it by making an
// assumption about the environment. // 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. // Specifies the maximum magnitude of the time of day adjustment.
private static final float TWILIGHT_ADJUSTMENT_MAX_GAMMA = 1.5f; private static final float TWILIGHT_ADJUSTMENT_MAX_GAMMA = 1.5f;