Merge "Add support for PSC of serving cell." into gingerbread

This commit is contained in:
jsh
2010-08-04 14:32:19 -07:00
committed by Android (Google) Code Review
2 changed files with 32 additions and 3 deletions

View File

@@ -25,6 +25,7 @@ import android.telephony.CellLocation;
public class GsmCellLocation extends CellLocation {
private int mLac;
private int mCid;
private int mPsc;
/**
* Empty constructor. Initializes the LAC and CID to -1.
@@ -32,6 +33,7 @@ public class GsmCellLocation extends CellLocation {
public GsmCellLocation() {
mLac = -1;
mCid = -1;
mPsc = -1;
}
/**
@@ -40,6 +42,7 @@ public class GsmCellLocation extends CellLocation {
public GsmCellLocation(Bundle bundle) {
mLac = bundle.getInt("lac", mLac);
mCid = bundle.getInt("cid", mCid);
mPsc = bundle.getInt("psc", mPsc);
}
/**
@@ -56,12 +59,21 @@ public class GsmCellLocation extends CellLocation {
return mCid;
}
/**
* @return primary scrambling code for UMTS, -1 if unknown or GSM
* @hide
*/
public int getPsc() {
return mPsc;
}
/**
* Invalidate this object. The location area code and the cell id are set to -1.
*/
public void setStateInvalid() {
mLac = -1;
mCid = -1;
mPsc = -1;
}
/**
@@ -72,6 +84,14 @@ public class GsmCellLocation extends CellLocation {
mCid = cid;
}
/**
* Set the primary scrambling code.
* @hide
*/
public void setPsc(int psc) {
mPsc = psc;
}
@Override
public int hashCode() {
return mLac ^ mCid;
@@ -91,12 +111,13 @@ public class GsmCellLocation extends CellLocation {
return false;
}
return equalsHandlesNulls(mLac, s.mLac) && equalsHandlesNulls(mCid, s.mCid);
return equalsHandlesNulls(mLac, s.mLac) && equalsHandlesNulls(mCid, s.mCid)
&& equalsHandlesNulls(mPsc, s.mPsc);
}
@Override
public String toString() {
return "["+ mLac + "," + mCid + "]";
return "["+ mLac + "," + mCid + "," + mPsc + "]";
}
/**
@@ -118,12 +139,13 @@ public class GsmCellLocation extends CellLocation {
public void fillInNotifierBundle(Bundle m) {
m.putInt("lac", mLac);
m.putInt("cid", mCid);
m.putInt("psc", mPsc);
}
/**
* @hide
*/
public boolean isEmpty() {
return (mLac == -1 && mCid == -1);
return (mLac == -1 && mCid == -1 && mPsc == -1);
}
}

View File

@@ -650,6 +650,7 @@ final class GsmServiceStateTracker extends ServiceStateTracker {
int lac = -1;
int cid = -1;
int regState = -1;
int psc = -1;
if (states.length > 0) {
try {
regState = Integer.parseInt(states[0]);
@@ -661,6 +662,11 @@ final class GsmServiceStateTracker extends ServiceStateTracker {
cid = Integer.parseInt(states[2], 16);
}
}
if (states.length > 14) {
if (states[14] != null && states[14].length() > 0) {
psc = Integer.parseInt(states[14], 16);
}
}
} catch (NumberFormatException ex) {
Log.w(LOG_TAG, "error parsing RegistrationState: " + ex);
}
@@ -677,6 +683,7 @@ final class GsmServiceStateTracker extends ServiceStateTracker {
// LAC and CID are -1 if not avail
newCellLoc.setLacAndCid(lac, cid);
newCellLoc.setPsc(psc);
break;
case EVENT_POLL_STATE_GPRS: