auto import from //depot/cupcake/@132589
This commit is contained in:
@@ -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");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
int curAsu = -1;
|
||||
CellLocation curLocation = null;
|
||||
|
||||
while (true) {
|
||||
// See if there is more work to do...
|
||||
synchronized (mLocationListeners) {
|
||||
if (curLocation == mNextLocation) {
|
||||
mCellLocationUpdater = null;
|
||||
break;
|
||||
}
|
||||
|
||||
curLocation = mNextLocation;
|
||||
if (curLocation == null) {
|
||||
mCellLocationUpdater = null;
|
||||
break;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
} 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() {
|
||||
|
||||
private CellState mLastCellState = null;
|
||||
@Override
|
||||
public void onCellLocationChanged(CellLocation cellLocation) {
|
||||
synchronized (mLocationListeners) {
|
||||
if (mCellLocationUpdater == null) {
|
||||
mCellLocationUpdater = new CellLocationUpdater();
|
||||
mCellLocationUpdater.start();
|
||||
try {
|
||||
synchronized (mLocationListeners) {
|
||||
int asu = mSignalStrength;
|
||||
|
||||
// Gets cell state
|
||||
mLastCellState = new CellState(mTelephonyManager, cellLocation, asu);
|
||||
|
||||
// Notify collector
|
||||
if (mCollector != null) {
|
||||
mCollector.updateCellState(mLastCellState);
|
||||
}
|
||||
|
||||
// Updates providers
|
||||
List<LocationProviderImpl> providers = LocationProviderImpl.getProviders();
|
||||
for (LocationProviderImpl provider : providers) {
|
||||
if (provider.requiresCell()) {
|
||||
provider.updateCellState(mLastCellState);
|
||||
}
|
||||
}
|
||||
}
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user