Merge change 24501 into eclair

* changes:
  Make Phone.updateServiceLocation acquire a one-shot wake lock.
This commit is contained in:
Android (Google) Code Review
2009-09-10 03:40:54 -04:00
7 changed files with 58 additions and 60 deletions

View File

@@ -1189,17 +1189,9 @@ public interface Phone {
List<DataConnection> getCurrentDataConnectionList ();
/**
* Udpate LAC and CID in service state for currnet GSM netowrk registration
*
* If get different LAC and/or CID, notifyServiceState will be sent
*
* @param
* <strong>On failure</strong>,
* (((AsyncResult)response.obj).result) == null and
* (((AsyncResult)response.obj).exception) being an instance of
* com.android.internal.telephony.gsm.CommandException
* Update the ServiceState CellLocation for current network registration.
*/
void updateServiceLocation(Message response);
void updateServiceLocation();
/**
* Enable location update notifications.

View File

@@ -566,8 +566,8 @@ public class PhoneProxy extends Handler implements Phone {
return mActivePhone.getCurrentDataConnectionList();
}
public void updateServiceLocation(Message response) {
mActivePhone.updateServiceLocation(response);
public void updateServiceLocation() {
mActivePhone.updateServiceLocation();
}
public void enableLocationUpdates() {

View File

@@ -226,12 +226,43 @@ public abstract class ServiceStateTracker extends Handler {
setPowerStateToDesired();
}
public void enableLocationUpdates() {
/**
* These two flags manage the behavior of the cell lock -- the
* lock should be held if either flag is true. The intention is
* to allow temporary aquisition of the lock to get a single
* update. Such a lock grab and release can thus be made to not
* interfere with more permanent lock holds -- in other words, the
* lock will only be released if both flags are false, and so
* releases by temporary users will only affect the lock state if
* there is no continuous user.
*/
private boolean mWantContinuousLocationUpdates;
private boolean mWantSingleLocationUpdate;
public void enableSingleLocationUpdate() {
if (mWantSingleLocationUpdate || mWantContinuousLocationUpdates) return;
mWantSingleLocationUpdate = true;
cm.setLocationUpdates(true, obtainMessage(EVENT_LOCATION_UPDATES_ENABLED));
}
public void enableLocationUpdates() {
if (mWantSingleLocationUpdate || mWantContinuousLocationUpdates) return;
mWantContinuousLocationUpdates = true;
cm.setLocationUpdates(true, obtainMessage(EVENT_LOCATION_UPDATES_ENABLED));
}
protected void disableSingleLocationUpdate() {
mWantSingleLocationUpdate = false;
if (!mWantSingleLocationUpdate && !mWantContinuousLocationUpdates) {
cm.setLocationUpdates(false, null);
}
}
public void disableLocationUpdates() {
cm.setLocationUpdates(false, null);
mWantContinuousLocationUpdates = false;
if (!mWantSingleLocationUpdate && !mWantContinuousLocationUpdates) {
cm.setLocationUpdates(false, null);
}
}
public abstract void handleMessage(Message msg);

View File

@@ -500,8 +500,8 @@ public class CDMAPhone extends PhoneBase {
Log.e(LOG_TAG, "method setCallWaiting is NOT supported in CDMA!");
}
public void updateServiceLocation(Message response) {
mSST.getLacAndCid(response);
public void updateServiceLocation() {
mSST.enableSingleLocationUpdate();
}
public void setDataRoamingEnabled(boolean enable) {
@@ -661,6 +661,10 @@ public class CDMAPhone extends PhoneBase {
mSST.enableLocationUpdates();
}
public void disableLocationUpdates() {
mSST.disableLocationUpdates();
}
/**
* @deprecated
*/
@@ -741,10 +745,6 @@ public class CDMAPhone extends PhoneBase {
}
}
public void disableLocationUpdates() {
mSST.disableLocationUpdates();
}
public boolean getIccRecordsLoaded() {
return mRuimRecords.getRecordsLoaded();
}

View File

@@ -279,12 +279,6 @@ final class CdmaServiceStateTracker extends ServiceStateTracker {
cdmaForSubscriptionInfoReadyRegistrants.remove(h);
}
public void
getLacAndCid(Message onComplete) {
cm.getRegistrationState(obtainMessage(
EVENT_GET_LOC_DONE_CDMA, onComplete));
}
@Override
public void handleMessage (Message msg) {
AsyncResult ar;
@@ -377,22 +371,14 @@ final class CdmaServiceStateTracker extends ServiceStateTracker {
}
}
// Only update if cell location really changed.
if (cellLoc.getBaseStationId() != baseStationData[0]
|| cellLoc.getBaseStationLatitude() != baseStationData[1]
|| cellLoc.getBaseStationLongitude() != baseStationData[2]) {
cellLoc.setCellLocationData(baseStationData[0],
baseStationData[1],
baseStationData[2]);
phone.notifyLocationChanged();
}
cellLoc.setCellLocationData(baseStationData[0],
baseStationData[1], baseStationData[2]);
phone.notifyLocationChanged();
}
if (ar.userObj != null) {
AsyncResult.forMessage(((Message) ar.userObj)).exception
= ar.exception;
((Message) ar.userObj).sendToTarget();
}
// Release any temporary cell lock, which could have been
// aquired to allow a single-shot location update.
disableSingleLocationUpdate();
break;
case EVENT_POLL_STATE_REGISTRATION_CDMA:
@@ -487,7 +473,7 @@ final class CdmaServiceStateTracker extends ServiceStateTracker {
ar = (AsyncResult) msg.obj;
if (ar.exception == null) {
getLacAndCid(null);
cm.getRegistrationState(obtainMessage(EVENT_GET_LOC_DONE_CDMA, null));
}
break;

View File

@@ -1099,8 +1099,8 @@ public class GSMPhone extends PhoneBase {
return mDataConnection.getAllDataConnections();
}
public void updateServiceLocation(Message response) {
mSST.getLacAndCid(response);
public void updateServiceLocation() {
mSST.enableSingleLocationUpdate();
}
public void enableLocationUpdates() {

View File

@@ -314,11 +314,6 @@ final class GsmServiceStateTracker extends ServiceStateTracker {
return mDataRoaming;
}
public void getLacAndCid(Message onComplete) {
cm.getRegistrationState(obtainMessage(
EVENT_GET_LOC_DONE, onComplete));
}
public void handleMessage (Message msg) {
AsyncResult ar;
int[] ints;
@@ -391,19 +386,13 @@ final class GsmServiceStateTracker extends ServiceStateTracker {
Log.w(LOG_TAG, "error parsing location: " + ex);
}
}
// only update if lac or cid changed
if (cellLoc.getCid() != cid || cellLoc.getLac() != lac) {
cellLoc.setLacAndCid(lac, cid);
phone.notifyLocationChanged();
}
cellLoc.setLacAndCid(lac, cid);
phone.notifyLocationChanged();
}
if (ar.userObj != null) {
AsyncResult.forMessage(((Message) ar.userObj)).exception
= ar.exception;
((Message) ar.userObj).sendToTarget();
}
// Release any temporary cell lock, which could have been
// aquired to allow a single-shot location update.
disableSingleLocationUpdate();
break;
case EVENT_POLL_STATE_REGISTRATION:
@@ -451,7 +440,7 @@ final class GsmServiceStateTracker extends ServiceStateTracker {
ar = (AsyncResult) msg.obj;
if (ar.exception == null) {
getLacAndCid(null);
cm.getRegistrationState(obtainMessage(EVENT_GET_LOC_DONE, null));
}
break;