am db45e0bd: am ecce539f: Merge "Release wakelock after use" into honeycomb-mr2
* commit 'db45e0bdd02c2b9416b89999422561929feb5cc0':
Release wakelock after use
diff --git a/core/java/android/net/DhcpStateMachine.java b/core/java/android/net/DhcpStateMachine.java
index c49c019..445b2f7 100644
--- a/core/java/android/net/DhcpStateMachine.java
+++ b/core/java/android/net/DhcpStateMachine.java
@@ -117,13 +117,14 @@
PowerManager powerManager = (PowerManager)mContext.getSystemService(Context.POWER_SERVICE);
mDhcpRenewWakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, WAKELOCK_TAG);
+ mDhcpRenewWakeLock.setReferenceCounted(false);
mBroadcastReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
//DHCP renew
if (DBG) Log.d(TAG, "Sending a DHCP renewal " + this);
- //acquire a 40s wakelock to finish DHCP renewal
+ //Lock released after 40s in worst case scenario
mDhcpRenewWakeLock.acquire(40000);
sendMessage(CMD_RENEW_DHCP);
}
@@ -166,6 +167,7 @@
switch (message.what) {
case CMD_RENEW_DHCP:
Log.e(TAG, "Error! Failed to handle a DHCP renewal on " + mInterfaceName);
+ mDhcpRenewWakeLock.release();
break;
case SM_QUIT_CMD:
mContext.unregisterReceiver(mBroadcastReceiver);
@@ -268,10 +270,12 @@
/* Notify controller before starting DHCP */
mController.sendMessage(CMD_PRE_DHCP_ACTION);
transitionTo(mWaitBeforeRenewalState);
+ //mDhcpRenewWakeLock is released in WaitBeforeRenewalState
} else {
if (!runDhcp(DhcpAction.RENEW)) {
transitionTo(mStoppedState);
}
+ mDhcpRenewWakeLock.release();
}
break;
case CMD_START_DHCP:
@@ -318,6 +322,10 @@
}
return retValue;
}
+ @Override
+ public void exit() {
+ mDhcpRenewWakeLock.release();
+ }
}
private boolean runDhcp(DhcpAction dhcpAction) {