Make Phone.updateServiceLocation acquire a one-shot wake lock.
Phone.updateServiceLocation() is the internal routine triggered by
external calls to CellLocation.requestLocationUpdate().
addresses bug http://b/issue?id=1724246
Change-Id: Id3d5cab1a77df12d3e94373a58ae94688a8630c6
diff --git a/telephony/java/com/android/internal/telephony/Phone.java b/telephony/java/com/android/internal/telephony/Phone.java
index e818175..5203d3f 100644
--- a/telephony/java/com/android/internal/telephony/Phone.java
+++ b/telephony/java/com/android/internal/telephony/Phone.java
@@ -1189,17 +1189,9 @@
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.
diff --git a/telephony/java/com/android/internal/telephony/PhoneProxy.java b/telephony/java/com/android/internal/telephony/PhoneProxy.java
index 8683278..711a48c 100644
--- a/telephony/java/com/android/internal/telephony/PhoneProxy.java
+++ b/telephony/java/com/android/internal/telephony/PhoneProxy.java
@@ -566,8 +566,8 @@
return mActivePhone.getCurrentDataConnectionList();
}
- public void updateServiceLocation(Message response) {
- mActivePhone.updateServiceLocation(response);
+ public void updateServiceLocation() {
+ mActivePhone.updateServiceLocation();
}
public void enableLocationUpdates() {
diff --git a/telephony/java/com/android/internal/telephony/ServiceStateTracker.java b/telephony/java/com/android/internal/telephony/ServiceStateTracker.java
index cc13450..6892998 100644
--- a/telephony/java/com/android/internal/telephony/ServiceStateTracker.java
+++ b/telephony/java/com/android/internal/telephony/ServiceStateTracker.java
@@ -226,12 +226,43 @@
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);
diff --git a/telephony/java/com/android/internal/telephony/cdma/CDMAPhone.java b/telephony/java/com/android/internal/telephony/cdma/CDMAPhone.java
index ff06bc0..dfc4889 100755
--- a/telephony/java/com/android/internal/telephony/cdma/CDMAPhone.java
+++ b/telephony/java/com/android/internal/telephony/cdma/CDMAPhone.java
@@ -500,8 +500,8 @@
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 @@
mSST.enableLocationUpdates();
}
+ public void disableLocationUpdates() {
+ mSST.disableLocationUpdates();
+ }
+
/**
* @deprecated
*/
@@ -741,10 +745,6 @@
}
}
- public void disableLocationUpdates() {
- mSST.disableLocationUpdates();
- }
-
public boolean getIccRecordsLoaded() {
return mRuimRecords.getRecordsLoaded();
}
diff --git a/telephony/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java b/telephony/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java
index 46e360b..9ac78eb 100644
--- a/telephony/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java
+++ b/telephony/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java
@@ -279,12 +279,6 @@
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 @@
}
}
- // 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 @@
ar = (AsyncResult) msg.obj;
if (ar.exception == null) {
- getLacAndCid(null);
+ cm.getRegistrationState(obtainMessage(EVENT_GET_LOC_DONE_CDMA, null));
}
break;
diff --git a/telephony/java/com/android/internal/telephony/gsm/GSMPhone.java b/telephony/java/com/android/internal/telephony/gsm/GSMPhone.java
index ac7331e..2fc2e13 100755
--- a/telephony/java/com/android/internal/telephony/gsm/GSMPhone.java
+++ b/telephony/java/com/android/internal/telephony/gsm/GSMPhone.java
@@ -1099,8 +1099,8 @@
return mDataConnection.getAllDataConnections();
}
- public void updateServiceLocation(Message response) {
- mSST.getLacAndCid(response);
+ public void updateServiceLocation() {
+ mSST.enableSingleLocationUpdate();
}
public void enableLocationUpdates() {
diff --git a/telephony/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java b/telephony/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java
index 65463e5..003899b 100644
--- a/telephony/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java
+++ b/telephony/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java
@@ -314,11 +314,6 @@
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 @@
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 @@
ar = (AsyncResult) msg.obj;
if (ar.exception == null) {
- getLacAndCid(null);
+ cm.getRegistrationState(obtainMessage(EVENT_GET_LOC_DONE, null));
}
break;