resolved conflicts for merge of efd91d7c to eclair-mr2-plus-aosp

Signed-off-by: repo sync <lockwood@android.com>
This commit is contained in:
repo sync
2009-11-18 20:12:50 -05:00
4 changed files with 41 additions and 10 deletions

View File

@@ -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);

View File

@@ -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);

View File

@@ -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(

View File

@@ -306,7 +306,7 @@ class PowerManagerService extends IPowerManager.Stub
public void release() {
if (!mRefCounted || --mCount == 0) {
PowerManagerService.this.releaseWakeLockLocked(mToken, false);
PowerManagerService.this.releaseWakeLockLockedmToken, 0, false);
}
if (mCount < 0) {
throw new RuntimeException("WakeLock under-locked " + mTag);
@@ -545,7 +545,7 @@ class PowerManagerService extends IPowerManager.Stub
}
public void binderDied() {
synchronized (mLocks) {
releaseWakeLockLocked(this.binder, true);
releaseWakeLockLocked(this.binder, 0, true);
}
}
final int flags;
@@ -690,18 +690,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;
@@ -733,7 +733,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");
@@ -1909,6 +1910,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) {