diff options
author | Mike Lockwood <> | 2009-04-05 14:50:22 -0700 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2009-04-05 14:50:22 -0700 |
commit | 66eb4acb89a5e54bdb5b9973e9a1c1b9853d154d (patch) | |
tree | e08d5314f3f6adc8e1bd4062bd92a2a4ccbfac85 /location | |
parent | b9db7c9f5a8924361ae2f439509e19993d82b884 (diff) | |
download | frameworks_base-66eb4acb89a5e54bdb5b9973e9a1c1b9853d154d.zip frameworks_base-66eb4acb89a5e54bdb5b9973e9a1c1b9853d154d.tar.gz frameworks_base-66eb4acb89a5e54bdb5b9973e9a1c1b9853d154d.tar.bz2 |
AI 144599: Location Manager cleanup:
Move PhoneStateListener for listening to cell location changes from LocationManagerService
to the NetworkLocationProvider.
Move CellState class out of the core framework to the NetworkLocationProvider service.
NetworkLocationManager now notifies the collector of its state, rather than LocationManagerService.
BUG=1729031
Automated import of CL 144599
Diffstat (limited to 'location')
3 files changed, 0 insertions, 329 deletions
diff --git a/location/java/android/location/LocationProviderImpl.java b/location/java/android/location/LocationProviderImpl.java index bb225e2..b6453c6 100644 --- a/location/java/android/location/LocationProviderImpl.java +++ b/location/java/android/location/LocationProviderImpl.java @@ -16,8 +16,6 @@ package android.location; -import com.android.internal.location.CellState; - import java.io.BufferedReader; import java.io.File; import java.io.FileReader; @@ -240,15 +238,6 @@ public abstract class LocationProviderImpl extends LocationProvider { } /** - * Updates the cell state for the given provider. This function must be - * overwritten if {@link #requiresCell} returns true. - * - * @param state cell state - */ - public void updateCellState(CellState state) { - } - - /** * Implements addditional location provider specific additional commands. * * @param command name of the command to send to the provider. diff --git a/location/java/com/android/internal/location/CellState.java b/location/java/com/android/internal/location/CellState.java deleted file mode 100644 index ad89f85..0000000 --- a/location/java/com/android/internal/location/CellState.java +++ /dev/null @@ -1,300 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.internal.location; - -import android.telephony.CellLocation; -import android.telephony.TelephonyManager; -import android.telephony.NeighboringCellInfo; -import android.telephony.gsm.GsmCellLocation; -import android.util.Log; - -import com.android.internal.telephony.TelephonyProperties; - -import java.util.List; -import java.util.ArrayList; - -import android.os.SystemProperties; - -/** - * Stores the cell tower state - * - * {@hide} - */ -public class CellState { - - public static String TAG = "CellState"; - - public static int RADIO_TYPE_GPRS = 1; - public static int RADIO_TYPE_CDMA = 2; - public static int RADIO_TYPE_WCDMA = 3; - - private int mCid = -1; - private int mLac = -1; - private int mMcc = -1; - private int mMnc = -1; - private int mHomeMcc = -1; - private int mHomeMnc = -1; - private String mCarrier = null; - private int mRadioType = -1; - private long mTime = 0; - private int mSignalStrength = -1; - - private List<NeighborCell> mNeighbors; - - public CellState() { - // constructor for invalid cell location - } - - public CellState(TelephonyManager telephonyManager, CellLocation location, int signalStrength) { - if (location instanceof GsmCellLocation) { - GsmCellLocation loc = (GsmCellLocation)location; - mLac = loc.getLac(); // example: 6032 - mCid = loc.getCid(); // example: 31792 - } - mTime = System.currentTimeMillis(); - - // Get radio type - int radioType = telephonyManager.getNetworkType(); - if (radioType == TelephonyManager.NETWORK_TYPE_GPRS || - radioType == TelephonyManager.NETWORK_TYPE_EDGE) { - mRadioType = RADIO_TYPE_GPRS; - } else if (radioType == TelephonyManager.NETWORK_TYPE_UMTS) { - mRadioType = RADIO_TYPE_WCDMA; - } else if (radioType == TelephonyManager.NETWORK_TYPE_CDMA || - radioType == TelephonyManager.NETWORK_TYPE_EVDO_0 || - radioType == TelephonyManager.NETWORK_TYPE_EVDO_A || - radioType == TelephonyManager.NETWORK_TYPE_1xRTT) { - mRadioType = RADIO_TYPE_CDMA; - } - - // Get neighboring cells - mNeighbors = new ArrayList<NeighborCell>(); - List<NeighboringCellInfo> neighboringCells = telephonyManager.getNeighboringCellInfo(); - if (neighboringCells != null) { - for (NeighboringCellInfo n : neighboringCells) { - if (n.getCid() == NeighboringCellInfo.UNKNOWN_CID) { - continue; - } - - if (mRadioType == RADIO_TYPE_WCDMA) { - mNeighbors.add(new NeighborCell(-1, -1, n.getCid(), n.getRssi())); - } else if (mRadioType == RADIO_TYPE_GPRS) { - try { - String hexCidLac = Integer.toHexString(n.getCid()); - int l = hexCidLac.length(); - if (l > 8) { - Log.w(TAG, "Unable to parse 2G Cell \"" + hexCidLac + "\""); - continue; - } - if (l < 8) { - for (int i = 0; i < (8-l); i++) { - hexCidLac = "0" + hexCidLac; - } - } - int lac = Integer.valueOf(hexCidLac.substring(0, 4), 16); - int cid = Integer.valueOf(hexCidLac.substring(4), 16); - mNeighbors.add(new NeighborCell(cid, lac, -1, n.getRssi())); - - } catch (Exception e) { - Log.e(TAG, "Error parsing 2G Cell \"" + n.getCid() + "\"", e); - } - } - } - } - - // Get MCC/MNC - String operator = telephonyManager.getNetworkOperator(); - if (operator != null && !operator.equals("")) { - // Use a try/catch block to detect index out of bounds or number format exceptions. - // If an error occurs, both mMcc and mMnc will be equal to -1. - try { - String mcc = operator.substring(0, 3); - String mnc = operator.substring(3); - int mccTmp = Integer.parseInt(mcc); - int mncTmp = Integer.parseInt(mnc); - - // Parsing succeeded, update the instance variables together - mMcc = mccTmp; - mMnc = mncTmp; - } catch (Exception e) { - Log.e(TAG, "Error parsing MCC/MNC from operator \"" + operator + "\"", e); - } - } - - // Get Home MCC/MNC - String homeOperator = telephonyManager.getSimOperator(); - if (homeOperator != null && !homeOperator.equals("")) { - // Use a try/catch block to detect index out of bounds or number format exceptions. - // If an error occurs, both mHomeMcc and mHomeMnc will be equal to -1. - try { - String mcc = homeOperator.substring(0, 3); - String mnc = homeOperator.substring(3); - int mccTmp = Integer.parseInt(mcc); - int mncTmp = Integer.parseInt(mnc); - - // Parsing succeeded, update the instance variables together - mHomeMcc = mccTmp; - mHomeMnc = mncTmp; - } catch (Exception e) { - Log.e(TAG, "Error parsing MCC/MNC from home operator \"" + homeOperator + "\"", e); - } - } - - // Get Carrier - String carrier = telephonyManager.getNetworkOperatorName(); - if (carrier != null && !carrier.equals("")) { - mCarrier = carrier; - } - - // Initial signal strength - mSignalStrength = signalStrength; - - if (Log.isLoggable(TAG, Log.VERBOSE)) { - String neighbors = "["; - for (NeighborCell n : mNeighbors) { - neighbors += n.toString() + ","; - } - neighbors += "]"; - Log.d(TAG, "CellState(): " + mLac +"," + mCid + "," + mMnc +"," + mMcc + "," + - mHomeMcc + "," + mHomeMnc + "," + mCarrier + "," + mRadioType + "," + - mSignalStrength + "," + neighbors); - } - } - - public void updateRadioType(int radioType) { - mRadioType = radioType; - - if (Log.isLoggable(TAG, Log.VERBOSE)) { - Log.d(TAG, "updateRadioType(): " + mLac +"," + mCid + "," + mMnc +"," + mMcc + "," + - mHomeMcc + "," + mHomeMnc + "," + mCarrier + "," + mRadioType + "," + - mSignalStrength); - } - } - - public void updateSignalStrength(int signalStrength) { - mSignalStrength = signalStrength; - - if (Log.isLoggable(TAG, Log.VERBOSE)) { - Log.d(TAG, "updateSignal(): " + mLac +"," + mCid + "," + mMnc +"," + mMcc + "," + - mHomeMcc + "," + mHomeMnc + "," + mCarrier + "," + mRadioType + "," + - mSignalStrength); - } - } - - public int getCid() { - return mCid; - } - - public int getLac() { - return mLac; - } - - public int getMcc() { - return mMcc; - } - - public int getMnc() { - return mMnc; - } - - public int getHomeMcc() { - return mHomeMcc; - } - - public void setHomeMcc(int homeMcc) { - this.mHomeMcc = homeMcc; - } - - public int getHomeMnc() { - return mHomeMnc; - } - - public void setHomeMnc(int homeMnc) { - this.mHomeMnc = homeMnc; - } - - public String getCarrier() { - return mCarrier; - } - - public void setCarrier(String carrier) { - this.mCarrier = carrier; - } - - public int getRadioType() { - return mRadioType; - } - - public long getTime() { - return mTime; - } - - public int getSignalStrength() { - return mSignalStrength; - } - - public List<NeighborCell> getNeighbors() { - return mNeighbors; - } - - public boolean equals(CellState other) { - return (mCid == other.mCid && mLac == other.mLac); - } - - public boolean isValid() { - return (mCid != -1 && mLac != -1); - } - - public static class NeighborCell { - private int mCid = -1; - private int mLac = -1; - private int mPsc = -1; - private int mRssi = -1; - - NeighborCell(int cid, int lac, int psc, int rssi) { - mCid = cid; - mLac = lac; - mPsc = psc; - mRssi = rssi; - } - - public int getCid() { - return mCid; - } - - public int getLac() { - return mLac; - } - - public int getPsc() { - return mPsc; - } - - public int getRssi() { - return mRssi; - } - - public String toString() { - if (mPsc != -1) { - return String.valueOf(mPsc) + "@" + mRssi; - } else { - return mCid + ":" + mLac + "@" + mRssi; - } - } - } -} - diff --git a/location/java/com/android/internal/location/ILocationCollector.java b/location/java/com/android/internal/location/ILocationCollector.java index 8a7cdcc..5c1f152 100644 --- a/location/java/com/android/internal/location/ILocationCollector.java +++ b/location/java/com/android/internal/location/ILocationCollector.java @@ -19,8 +19,6 @@ package com.android.internal.location; import android.location.Location; import android.net.wifi.ScanResult; -import com.android.internal.location.CellState; - import java.util.List; /** @@ -46,22 +44,6 @@ public interface ILocationCollector { abstract public void updateWifiScanResults(List<ScanResult> currentScanResults); /** - * Updates the status of the network location provider. - * - * @param enabled true if user has enabled network location based on Google's database - * of wifi points and cell towers. - */ - abstract public void updateNetworkProviderStatus(boolean enabled); - - /** - * Updates cell tower state. This is usually always up to date so should be uploaded - * each time a new location is available. - * - * @param newState cell state - */ - abstract public void updateCellState(CellState newState); - - /** * Updates the battery health. Battery level is healthy if there is greater than * {@link #MIN_BATTERY_LEVEL} percentage left or if the device is plugged in * |