summaryrefslogtreecommitdiff
path: root/services/java/com/android/server/LocationManagerService.java
diff options
context:
space:
mode:
Diffstat (limited to 'services/java/com/android/server/LocationManagerService.java')
-rw-r--r--services/java/com/android/server/LocationManagerService.java112
1 files changed, 25 insertions, 87 deletions
diff --git a/services/java/com/android/server/LocationManagerService.java b/services/java/com/android/server/LocationManagerService.java
index 9d691145152c..bc8da93ce92a 100644
--- a/services/java/com/android/server/LocationManagerService.java
+++ b/services/java/com/android/server/LocationManagerService.java
@@ -214,6 +214,7 @@ public class LocationManagerService extends ILocationManager.Stub
// Last known cell service state
private TelephonyManager mTelephonyManager;
+ private int mSignalStrength = -1;
// Location collector
private ILocationCollector mCollector;
@@ -1763,7 +1764,7 @@ public class LocationManagerService extends ILocationManager.Stub
Log.d(TAG, "installing network location provider");
INetworkLocationManager.InstallCallback callback =
(INetworkLocationManager.InstallCallback)msg.obj;
- callback.installNetworkLocationProvider(LocationManagerService.this);
+ callback.installNetworkLocationProvider(mContext, LocationManagerService.this);
}
}
} catch (Exception e) {
@@ -1773,90 +1774,40 @@ public class LocationManagerService extends ILocationManager.Stub
}
}
- class CellLocationUpdater extends Thread {
- CellLocation mNextLocation;
-
- CellLocationUpdater() {
- super("CellLocationUpdater");
- }
-
+ PhoneStateListener mPhoneStateListener = new PhoneStateListener() {
+
+ private CellState mLastCellState = null;
@Override
- public void run() {
- int curAsu = -1;
- CellLocation curLocation = null;
-
- while (true) {
- // See if there is more work to do...
+ public void onCellLocationChanged(CellLocation cellLocation) {
+ try {
synchronized (mLocationListeners) {
- if (curLocation == mNextLocation) {
- mCellLocationUpdater = null;
- break;
- }
-
- curLocation = mNextLocation;
- if (curLocation == null) {
- mCellLocationUpdater = null;
- break;
+ int asu = mSignalStrength;
+
+ // Gets cell state
+ mLastCellState = new CellState(mTelephonyManager, cellLocation, asu);
+
+ // Notify collector
+ if (mCollector != null) {
+ mCollector.updateCellState(mLastCellState);
}
-
- curAsu = mLastSignalStrength;
-
- mNextLocation = null;
- }
-
- try {
- // Gets cell state. This can block so must be done without
- // locks held.
- CellState cs = new CellState(mTelephonyManager, curLocation, curAsu);
-
- synchronized (mLocationListeners) {
- mLastCellState = cs;
-
- cs.updateSignalStrength(mLastSignalStrength);
- cs.updateRadioType(mLastRadioType);
-
- // Notify collector
- if (mCollector != null) {
- mCollector.updateCellState(cs);
- }
- // Updates providers
- List<LocationProviderImpl> providers = LocationProviderImpl.getProviders();
- for (LocationProviderImpl provider : providers) {
- if (provider.requiresCell()) {
- provider.updateCellState(cs);
- }
+ // Updates providers
+ List<LocationProviderImpl> providers = LocationProviderImpl.getProviders();
+ for (LocationProviderImpl provider : providers) {
+ if (provider.requiresCell()) {
+ provider.updateCellState(mLastCellState);
}
}
- } catch (RuntimeException e) {
- Log.e(TAG, "Exception in PhoneStateListener.onCellLocationChanged:", e);
}
- }
- }
- }
-
- CellLocationUpdater mCellLocationUpdater = null;
- CellState mLastCellState = null;
- int mLastSignalStrength = -1;
- int mLastRadioType = -1;
-
- PhoneStateListener mPhoneStateListener = new PhoneStateListener() {
-
- @Override
- public void onCellLocationChanged(CellLocation cellLocation) {
- synchronized (mLocationListeners) {
- if (mCellLocationUpdater == null) {
- mCellLocationUpdater = new CellLocationUpdater();
- mCellLocationUpdater.start();
- }
- mCellLocationUpdater.mNextLocation = cellLocation;
+ } catch (Exception e) {
+ Log.e(TAG, "Exception in PhoneStateListener.onCellLocationCahnged:", e);
}
}
@Override
public void onSignalStrengthChanged(int asu) {
synchronized (mLocationListeners) {
- mLastSignalStrength = asu;
+ mSignalStrength = asu;
if (mLastCellState != null) {
mLastCellState.updateSignalStrength(asu);
@@ -1867,18 +1818,8 @@ public class LocationManagerService extends ILocationManager.Stub
@Override
public void onDataConnectionStateChanged(int state) {
synchronized (mLocationListeners) {
- // Get radio type
- int radioType = mTelephonyManager.getNetworkType();
- if (radioType == TelephonyManager.NETWORK_TYPE_GPRS ||
- radioType == TelephonyManager.NETWORK_TYPE_EDGE) {
- radioType = CellState.RADIO_TYPE_GPRS;
- } else if (radioType == TelephonyManager.NETWORK_TYPE_UMTS) {
- radioType = CellState.RADIO_TYPE_WCDMA;
- }
- mLastRadioType = radioType;
-
if (mLastCellState != null) {
- mLastCellState.updateRadioType(radioType);
+ mLastCellState.updateRadioType(mTelephonyManager);
}
}
}
@@ -2614,11 +2555,8 @@ public class LocationManagerService extends ILocationManager.Stub
pw.println(" mGpsNavigating=" + mGpsNavigating);
pw.println(" mNetworkLocationProvider=" + mNetworkLocationProvider);
pw.println(" mNetworkLocationInterface=" + mNetworkLocationInterface);
- pw.println(" mLastSignalStrength=" + mLastSignalStrength
- + " mLastRadioType=" + mLastRadioType);
- pw.println(" mCellLocationUpdater=" + mCellLocationUpdater);
- pw.println(" mLastCellState=" + mLastCellState);
pw.println(" mCollector=" + mCollector);
+ pw.println(" mSignalStrength=" + mSignalStrength);
pw.println(" mAlarmInterval=" + mAlarmInterval
+ " mScreenOn=" + mScreenOn
+ " mWakeLockAcquireTime=" + mWakeLockAcquireTime);