Merge change 24501 into eclair
* changes: Make Phone.updateServiceLocation acquire a one-shot wake lock.
This commit is contained in:
@@ -1189,17 +1189,9 @@ public interface Phone {
|
|||||||
List<DataConnection> getCurrentDataConnectionList ();
|
List<DataConnection> getCurrentDataConnectionList ();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Udpate LAC and CID in service state for currnet GSM netowrk registration
|
* Update the ServiceState CellLocation for current network 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
|
|
||||||
*/
|
*/
|
||||||
void updateServiceLocation(Message response);
|
void updateServiceLocation();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enable location update notifications.
|
* Enable location update notifications.
|
||||||
|
|||||||
@@ -566,8 +566,8 @@ public class PhoneProxy extends Handler implements Phone {
|
|||||||
return mActivePhone.getCurrentDataConnectionList();
|
return mActivePhone.getCurrentDataConnectionList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateServiceLocation(Message response) {
|
public void updateServiceLocation() {
|
||||||
mActivePhone.updateServiceLocation(response);
|
mActivePhone.updateServiceLocation();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void enableLocationUpdates() {
|
public void enableLocationUpdates() {
|
||||||
|
|||||||
@@ -226,12 +226,43 @@ public abstract class ServiceStateTracker extends Handler {
|
|||||||
setPowerStateToDesired();
|
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));
|
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() {
|
public void disableLocationUpdates() {
|
||||||
cm.setLocationUpdates(false, null);
|
mWantContinuousLocationUpdates = false;
|
||||||
|
if (!mWantSingleLocationUpdate && !mWantContinuousLocationUpdates) {
|
||||||
|
cm.setLocationUpdates(false, null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void handleMessage(Message msg);
|
public abstract void handleMessage(Message msg);
|
||||||
|
|||||||
@@ -500,8 +500,8 @@ public class CDMAPhone extends PhoneBase {
|
|||||||
Log.e(LOG_TAG, "method setCallWaiting is NOT supported in CDMA!");
|
Log.e(LOG_TAG, "method setCallWaiting is NOT supported in CDMA!");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateServiceLocation(Message response) {
|
public void updateServiceLocation() {
|
||||||
mSST.getLacAndCid(response);
|
mSST.enableSingleLocationUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDataRoamingEnabled(boolean enable) {
|
public void setDataRoamingEnabled(boolean enable) {
|
||||||
@@ -661,6 +661,10 @@ public class CDMAPhone extends PhoneBase {
|
|||||||
mSST.enableLocationUpdates();
|
mSST.enableLocationUpdates();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void disableLocationUpdates() {
|
||||||
|
mSST.disableLocationUpdates();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated
|
* @deprecated
|
||||||
*/
|
*/
|
||||||
@@ -741,10 +745,6 @@ public class CDMAPhone extends PhoneBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void disableLocationUpdates() {
|
|
||||||
mSST.disableLocationUpdates();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean getIccRecordsLoaded() {
|
public boolean getIccRecordsLoaded() {
|
||||||
return mRuimRecords.getRecordsLoaded();
|
return mRuimRecords.getRecordsLoaded();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -279,12 +279,6 @@ final class CdmaServiceStateTracker extends ServiceStateTracker {
|
|||||||
cdmaForSubscriptionInfoReadyRegistrants.remove(h);
|
cdmaForSubscriptionInfoReadyRegistrants.remove(h);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void
|
|
||||||
getLacAndCid(Message onComplete) {
|
|
||||||
cm.getRegistrationState(obtainMessage(
|
|
||||||
EVENT_GET_LOC_DONE_CDMA, onComplete));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleMessage (Message msg) {
|
public void handleMessage (Message msg) {
|
||||||
AsyncResult ar;
|
AsyncResult ar;
|
||||||
@@ -377,22 +371,14 @@ final class CdmaServiceStateTracker extends ServiceStateTracker {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only update if cell location really changed.
|
cellLoc.setCellLocationData(baseStationData[0],
|
||||||
if (cellLoc.getBaseStationId() != baseStationData[0]
|
baseStationData[1], baseStationData[2]);
|
||||||
|| cellLoc.getBaseStationLatitude() != baseStationData[1]
|
phone.notifyLocationChanged();
|
||||||
|| cellLoc.getBaseStationLongitude() != baseStationData[2]) {
|
|
||||||
cellLoc.setCellLocationData(baseStationData[0],
|
|
||||||
baseStationData[1],
|
|
||||||
baseStationData[2]);
|
|
||||||
phone.notifyLocationChanged();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ar.userObj != null) {
|
// Release any temporary cell lock, which could have been
|
||||||
AsyncResult.forMessage(((Message) ar.userObj)).exception
|
// aquired to allow a single-shot location update.
|
||||||
= ar.exception;
|
disableSingleLocationUpdate();
|
||||||
((Message) ar.userObj).sendToTarget();
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EVENT_POLL_STATE_REGISTRATION_CDMA:
|
case EVENT_POLL_STATE_REGISTRATION_CDMA:
|
||||||
@@ -487,7 +473,7 @@ final class CdmaServiceStateTracker extends ServiceStateTracker {
|
|||||||
ar = (AsyncResult) msg.obj;
|
ar = (AsyncResult) msg.obj;
|
||||||
|
|
||||||
if (ar.exception == null) {
|
if (ar.exception == null) {
|
||||||
getLacAndCid(null);
|
cm.getRegistrationState(obtainMessage(EVENT_GET_LOC_DONE_CDMA, null));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
@@ -1099,8 +1099,8 @@ public class GSMPhone extends PhoneBase {
|
|||||||
return mDataConnection.getAllDataConnections();
|
return mDataConnection.getAllDataConnections();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateServiceLocation(Message response) {
|
public void updateServiceLocation() {
|
||||||
mSST.getLacAndCid(response);
|
mSST.enableSingleLocationUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void enableLocationUpdates() {
|
public void enableLocationUpdates() {
|
||||||
|
|||||||
@@ -314,11 +314,6 @@ final class GsmServiceStateTracker extends ServiceStateTracker {
|
|||||||
return mDataRoaming;
|
return mDataRoaming;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getLacAndCid(Message onComplete) {
|
|
||||||
cm.getRegistrationState(obtainMessage(
|
|
||||||
EVENT_GET_LOC_DONE, onComplete));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void handleMessage (Message msg) {
|
public void handleMessage (Message msg) {
|
||||||
AsyncResult ar;
|
AsyncResult ar;
|
||||||
int[] ints;
|
int[] ints;
|
||||||
@@ -391,19 +386,13 @@ final class GsmServiceStateTracker extends ServiceStateTracker {
|
|||||||
Log.w(LOG_TAG, "error parsing location: " + ex);
|
Log.w(LOG_TAG, "error parsing location: " + ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
cellLoc.setLacAndCid(lac, cid);
|
||||||
// only update if lac or cid changed
|
phone.notifyLocationChanged();
|
||||||
if (cellLoc.getCid() != cid || cellLoc.getLac() != lac) {
|
|
||||||
cellLoc.setLacAndCid(lac, cid);
|
|
||||||
phone.notifyLocationChanged();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ar.userObj != null) {
|
// Release any temporary cell lock, which could have been
|
||||||
AsyncResult.forMessage(((Message) ar.userObj)).exception
|
// aquired to allow a single-shot location update.
|
||||||
= ar.exception;
|
disableSingleLocationUpdate();
|
||||||
((Message) ar.userObj).sendToTarget();
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EVENT_POLL_STATE_REGISTRATION:
|
case EVENT_POLL_STATE_REGISTRATION:
|
||||||
@@ -451,7 +440,7 @@ final class GsmServiceStateTracker extends ServiceStateTracker {
|
|||||||
ar = (AsyncResult) msg.obj;
|
ar = (AsyncResult) msg.obj;
|
||||||
|
|
||||||
if (ar.exception == null) {
|
if (ar.exception == null) {
|
||||||
getLacAndCid(null);
|
cm.getRegistrationState(obtainMessage(EVENT_GET_LOC_DONE, null));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user