Merge change I813fdb7a into eclair
* changes: Fixes for proximity sensor behavior:
This commit is contained in:
@@ -66,7 +66,7 @@ public class PowerCommand extends Svc.Command {
|
||||
IBinder lock = new Binder();
|
||||
pm.acquireWakeLock(PowerManager.FULL_WAKE_LOCK, lock, "svc power");
|
||||
pm.setStayOnSetting(val);
|
||||
pm.releaseWakeLock(lock);
|
||||
pm.releaseWakeLock(lock, 0);
|
||||
}
|
||||
catch (RemoteException e) {
|
||||
System.err.println("Faild to set setting: " + e);
|
||||
|
||||
@@ -22,7 +22,7 @@ interface IPowerManager
|
||||
{
|
||||
void acquireWakeLock(int flags, IBinder lock, String tag);
|
||||
void goToSleep(long time);
|
||||
void releaseWakeLock(IBinder lock);
|
||||
void releaseWakeLock(IBinder lock, int flags);
|
||||
void userActivity(long when, boolean noChangeLights);
|
||||
void userActivityWithForce(long when, boolean noChangeLights, boolean force);
|
||||
void setPokeLock(int pokey, IBinder lock, String tag);
|
||||
|
||||
@@ -158,6 +158,15 @@ public class PowerManager
|
||||
*/
|
||||
public static final int PROXIMITY_SCREEN_OFF_WAKE_LOCK = WAKE_BIT_PROXIMITY_SCREEN_OFF;
|
||||
|
||||
/**
|
||||
* Flag for {@link WakeLock#release release(int)} to defer releasing a
|
||||
* {@link #WAKE_BIT_PROXIMITY_SCREEN_OFF} wakelock until the proximity sensor returns
|
||||
* a negative value.
|
||||
*
|
||||
* {@hide}
|
||||
*/
|
||||
public static final int WAIT_FOR_PROXIMITY_NEGATIVE = 1;
|
||||
|
||||
/**
|
||||
* Normally wake locks don't actually wake the device, they just cause
|
||||
* it to remain on once it's already on. Think of the video player
|
||||
@@ -266,11 +275,27 @@ public class PowerManager
|
||||
* are other wake locks held.
|
||||
*/
|
||||
public void release()
|
||||
{
|
||||
release(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Release your claim to the CPU or screen being on.
|
||||
* @param flags Combination of flag values to modify the release behavior.
|
||||
* Currently only {@link #WAIT_FOR_PROXIMITY_NEGATIVE} is supported.
|
||||
*
|
||||
* <p>
|
||||
* It may turn off shortly after you release it, or it may not if there
|
||||
* are other wake locks held.
|
||||
*
|
||||
* {@hide}
|
||||
*/
|
||||
public void release(int flags)
|
||||
{
|
||||
synchronized (mToken) {
|
||||
if (!mRefCounted || --mCount == 0) {
|
||||
try {
|
||||
mService.releaseWakeLock(mToken);
|
||||
mService.releaseWakeLock(mToken, flags);
|
||||
} catch (RemoteException e) {
|
||||
}
|
||||
mHeld = false;
|
||||
@@ -302,7 +327,7 @@ public class PowerManager
|
||||
synchronized (mToken) {
|
||||
if (mHeld) {
|
||||
try {
|
||||
mService.releaseWakeLock(mToken);
|
||||
mService.releaseWakeLock(mToken, 0);
|
||||
} catch (RemoteException e) {
|
||||
}
|
||||
RuntimeInit.crash(TAG, new Exception(
|
||||
|
||||
@@ -309,7 +309,7 @@ class PowerManagerService extends IPowerManager.Stub
|
||||
|
||||
public void release() {
|
||||
if (!mRefCounted || --mCount == 0) {
|
||||
PowerManagerService.this.releaseWakeLockLocked(mToken, false);
|
||||
PowerManagerService.this.releaseWakeLockLocked(mToken, 0, false);
|
||||
mHeld = false;
|
||||
}
|
||||
if (mCount < 0) {
|
||||
@@ -556,7 +556,7 @@ class PowerManagerService extends IPowerManager.Stub
|
||||
}
|
||||
public void binderDied() {
|
||||
synchronized (mLocks) {
|
||||
releaseWakeLockLocked(this.binder, true);
|
||||
releaseWakeLockLocked(this.binder, 0, true);
|
||||
}
|
||||
}
|
||||
final int flags;
|
||||
@@ -701,18 +701,18 @@ class PowerManagerService extends IPowerManager.Stub
|
||||
}
|
||||
}
|
||||
|
||||
public void releaseWakeLock(IBinder lock) {
|
||||
public void releaseWakeLock(IBinder lock, int flags) {
|
||||
int uid = Binder.getCallingUid();
|
||||
if (uid != Process.myUid()) {
|
||||
mContext.enforceCallingOrSelfPermission(android.Manifest.permission.WAKE_LOCK, null);
|
||||
}
|
||||
|
||||
synchronized (mLocks) {
|
||||
releaseWakeLockLocked(lock, false);
|
||||
releaseWakeLockLocked(lock, flags, false);
|
||||
}
|
||||
}
|
||||
|
||||
private void releaseWakeLockLocked(IBinder lock, boolean death) {
|
||||
private void releaseWakeLockLocked(IBinder lock, int flags, boolean death) {
|
||||
int releaseUid;
|
||||
String releaseName;
|
||||
int releaseType;
|
||||
@@ -744,7 +744,8 @@ class PowerManagerService extends IPowerManager.Stub
|
||||
} else if ((wl.flags & LOCK_MASK) == PowerManager.PROXIMITY_SCREEN_OFF_WAKE_LOCK) {
|
||||
mProximityWakeLockCount--;
|
||||
if (mProximityWakeLockCount == 0) {
|
||||
if (mProximitySensorActive) {
|
||||
if (mProximitySensorActive &&
|
||||
((flags & PowerManager.WAIT_FOR_PROXIMITY_NEGATIVE) != 0)) {
|
||||
// wait for proximity sensor to go negative before disabling sensor
|
||||
if (mDebugProximitySensor) {
|
||||
Log.d(TAG, "waiting for proximity sensor to go negative");
|
||||
@@ -1923,6 +1924,11 @@ class PowerManagerService extends IPowerManager.Stub
|
||||
Log.d(TAG, "ignoring user activity while turning off screen");
|
||||
return;
|
||||
}
|
||||
// Disable proximity sensor if if user presses power key while we are in the
|
||||
// "waiting for proximity sensor to go negative" state.
|
||||
if (mProximitySensorActive && mProximityWakeLockCount == 0) {
|
||||
mProximitySensorActive = false;
|
||||
}
|
||||
if (mLastEventTime <= time || force) {
|
||||
mLastEventTime = time;
|
||||
if ((mUserActivityAllowed && !mProximitySensorActive) || force) {
|
||||
|
||||
Reference in New Issue
Block a user