本文整理匯總了Java中android.telephony.gsm.GsmCellLocation.getPsc方法的典型用法代碼示例。如果您正苦於以下問題:Java GsmCellLocation.getPsc方法的具體用法?Java GsmCellLocation.getPsc怎麽用?Java GsmCellLocation.getPsc使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.telephony.gsm.GsmCellLocation
的用法示例。
在下文中一共展示了GsmCellLocation.getPsc方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: isCellLocationEqual
import android.telephony.gsm.GsmCellLocation; //導入方法依賴的package包/類
private boolean isCellLocationEqual(CellLocation cl1, CellLocation cl2) {
boolean result;
if (cl1 instanceof GsmCellLocation && cl2 instanceof GsmCellLocation) {
GsmCellLocation gsm1 = (GsmCellLocation) cl1;
GsmCellLocation gsm2 = (GsmCellLocation) cl2;
result = (gsm1.getCid() == gsm2.getCid()
&& gsm1.getLac() == gsm2.getLac()
&& gsm1.getPsc() == gsm2.getPsc());
Log.d("isCellLocationEqual(): GSM equals = %s", result);
} else if (cl1 instanceof CdmaCellLocation && cl2 instanceof CdmaCellLocation) {
CdmaCellLocation cdma1 = (CdmaCellLocation) cl1;
CdmaCellLocation cdma2 = (CdmaCellLocation) cl2;
result = (cdma1.getBaseStationId() == cdma2.getBaseStationId()
&& cdma1.getNetworkId() == cdma2.getNetworkId()
&& cdma1.getSystemId() == cdma2.getSystemId());
Log.d("isCellLocationEqual(): CDMA equal = %s", result);
} else {
// different types or nulls
result = false;
Log.d("isCellLocationEqual(): Different types or nulls");
}
return result;
}
示例2: update
import android.telephony.gsm.GsmCellLocation; //導入方法依賴的package包/類
public void update(Measurement m, CellLocation cellLocation, int mcc, int mnc, NetworkGroup networkType) {
if (cellLocation instanceof GsmCellLocation) {
GsmCellLocation gsmCellLocation = (GsmCellLocation) cellLocation;
if (gsmCellLocation.getCid() <= 65535 && gsmCellLocation.getPsc() == NeighboringCellInfo.UNKNOWN_CID) {
m.setGsmCellLocation(mcc, mnc, gsmCellLocation.getLac(), gsmCellLocation.getCid(), NetworkGroup.Gsm);
} else {
// fix invalid network types (unfortunately not possible to distinguish between UMTS and LTE)
if (networkType == NetworkGroup.Gsm || networkType == NetworkGroup.Cdma)
networkType = NetworkGroup.Unknown;
int psc = gsmCellLocation.getPsc();
if (psc == NeighboringCellInfo.UNKNOWN_CID || psc == Measurement.UNKNOWN_CID) {
psc = Measurement.UNKNOWN_CID;
} else if (psc >= 504) {
// only UMTS networks support larger PSC
networkType = NetworkGroup.Wcdma;
}
m.setGsmCellLocation(mcc, mnc, gsmCellLocation.getLac(), gsmCellLocation.getCid(), psc, networkType);
}
} else if (cellLocation instanceof CdmaCellLocation) {
CdmaCellLocation cdmaCellLocation = (CdmaCellLocation) cellLocation;
m.setCdmaCellLocation(cdmaCellLocation.getSystemId(), cdmaCellLocation.getNetworkId(), cdmaCellLocation.getBaseStationId());
} else {
throw new UnsupportedOperationException("Cell location type not supported `" + cellLocation.getClass().getName() + "`");
}
}
示例3: getCellId
import android.telephony.gsm.GsmCellLocation; //導入方法依賴的package包/類
/**
* {link http://www.devx.com/wireless/Article/40524/0/page/2}
*/
private int[] getCellId() {
int[] cellId = new int[0];
CellLocation cellLoc = telephonyManager.getCellLocation();
if (cellLoc != null && (cellLoc instanceof GsmCellLocation)) {
GsmCellLocation gsmLoc = (GsmCellLocation) cellLoc;
gsmLoc.getPsc();
// gsm cell id
int cid = gsmLoc.getCid();
// gsm location area code
int lac = gsmLoc.getLac();
// On a UMTS network, returns the primary scrambling code of the
// serving cell.
int psc = gsmLoc.getPsc();
Log.d(TAG, String.format("Cell Id : %s / Lac : %s / Psc : %s", cid, lac, psc));
if (psc > -1) {
cellId = new int[3];
cellId[2] = psc;
} else {
cellId = new int[2];
}
cellId[0] = cid;
cellId[1] = lac;
}
return cellId;
}
示例4: update
import android.telephony.gsm.GsmCellLocation; //導入方法依賴的package包/類
/**
* Adds or updates a cell tower.
* <p>
* If the cell tower is already in the list, its data is updated; if not, a
* new entry is created.
* <p>
* This method will set the cell's identity data. After this call,
* {@link #isServing()} will return {@code true} for this cell.
* @param networkOperator The network operator, as returned by {@link android.telephony.TelephonyManager#getNetworkOperator()}.
* @param location The {@link android.telephony.GsmCellLocation}, as returned by {@link android.telephony.TelephonyManager#getCellLocation()}.
* @return The new or updated entry.
*/
public CellTowerLte update(String networkOperator, GsmCellLocation location) {
int mcc = CellTower.UNKNOWN;
int mnc = CellTower.UNKNOWN;
if (networkOperator.length() > 3) {
mcc = Integer.parseInt(networkOperator.substring(0, 3));
mnc = Integer.parseInt(networkOperator.substring(3));
}
CellTowerLte result = null;
CellTowerLte cand = this.get(mcc, mnc, location.getLac(), location.getCid());
if ((cand != null) && CellTower.matches(location.getPsc(), cand.getPci()))
result = cand;
if (result == null) {
cand = this.get(location.getPsc());
if ((cand != null)
&& CellTower.matches(mcc, cand.getMcc())
&& CellTower.matches(mnc, cand.getMnc())
&& CellTower.matches(location.getLac(), cand.getTac())
&& CellTower.matches(location.getCid(), cand.getCi()))
result = cand;
}
if (result == null)
result = new CellTowerLte(mcc, mnc, location.getLac(), location.getCid(), location.getPsc());
if (result.getMcc() == CellTower.UNKNOWN)
result.setMcc(mcc);
if (result.getMnc() == CellTower.UNKNOWN)
result.setMnc(mnc);
if (result.getTac() == CellTower.UNKNOWN)
result.setTac(location.getLac());
if (result.getCi() == CellTower.UNKNOWN)
result.setCi(location.getCid());
if (result.getPci() == CellTower.UNKNOWN)
result.setPci(location.getPsc());
this.put(result.getText(), result);
this.put(result.getAltText(), result);
result.setCellLocation(true);
Log.d(this.getClass().getSimpleName(), String.format("Added GsmCellLocation for %s, %d G", result.getText(), result.getGeneration()));
return result;
}
示例5: update
import android.telephony.gsm.GsmCellLocation; //導入方法依賴的package包/類
/**
* Adds or updates a cell tower.
* <p>
* If the cell tower is already in the list, its data is updated; if not, a
* new entry is created.
* <p>
* This method will set the cell's identity data. After this call,
* {@link #isServing()} will return {@code true} for this cell.
* @param networkOperator The network operator, as returned by {@link android.telephony.TelephonyManager#getNetworkOperator()}.
* @param location The {@link android.telephony.GsmCellLocation}, as returned by {@link android.telephony.TelephonyManager#getCellLocation()}.
* @return The new or updated entry.
*/
public CellTowerGsm update(String networkOperator, GsmCellLocation location) {
int mcc = CellTower.UNKNOWN;
int mnc = CellTower.UNKNOWN;
if (networkOperator.length() > 3) {
mcc = Integer.parseInt(networkOperator.substring(0, 3));
mnc = Integer.parseInt(networkOperator.substring(3));
}
CellTowerGsm result = null;
CellTowerGsm cand = this.get(mcc, mnc, location.getLac(), location.getCid());
if ((cand != null) && CellTower.matches(location.getPsc(), cand.getPsc()))
result = cand;
if (result == null) {
cand = this.get(location.getPsc());
if ((cand != null)
&& CellTower.matches(mcc, cand.getMcc())
&& CellTower.matches(mnc, cand.getMnc())
&& CellTower.matches(location.getLac(), cand.getLac())
&& CellTower.matches(location.getCid(), cand.getCid()))
result = cand;
}
if (result == null)
result = new CellTowerGsm(mcc, mnc, location.getLac(), location.getCid(), location.getPsc());
if (result.getMcc() == CellTower.UNKNOWN)
result.setMcc(mcc);
if (result.getMnc() == CellTower.UNKNOWN)
result.setMnc(mnc);
if (result.getLac() == CellTower.UNKNOWN)
result.setLac(location.getLac());
if (result.getCid() == CellTower.UNKNOWN)
result.setCid(location.getCid());
if (result.getPsc() == CellTower.UNKNOWN)
result.setPsc(location.getPsc());
this.put(result.getText(), result);
this.put(result.getAltText(), result);
if ((result.getText() == null) && (result.getAltText() == null))
Log.d(this.getClass().getSimpleName(), String.format("Added %d G cell with no data from GsmCellLocation", result.getGeneration()));
result.setCellLocation(true);
return result;
}
示例6: onCellLocationChanged
import android.telephony.gsm.GsmCellLocation; //導入方法依賴的package包/類
public void onCellLocationChanged(CellLocation location) {
checkForNeighbourCount(location);
compareLac(location);
refreshDevice();
mDevice.setNetID(tm);
mDevice.getNetworkTypeName();
switch (mDevice.getPhoneID()) {
case TelephonyManager.PHONE_TYPE_NONE:
case TelephonyManager.PHONE_TYPE_SIP:
case TelephonyManager.PHONE_TYPE_GSM:
GsmCellLocation gsmCellLocation = (GsmCellLocation) location;
if (gsmCellLocation != null) {
//TODO @EVA where are we sending this setCellInfo data?
//TODO
/*@EVA
Is it a good idea to dump all cells to db because if we spot a known cell
with different lac then this will also be dump to db.
*/
mDevice.setCellInfo(
gsmCellLocation.toString() + // ??
mDevice.getDataActivityTypeShort() + "|" + // No,In,Ou,IO,Do
mDevice.getDataStateShort() + "|" + // Di,Ct,Cd,Su
mDevice.getNetworkTypeName() + "|" // HSPA,LTE etc
);
mDevice.mCell.setLAC(gsmCellLocation.getLac()); // LAC
mDevice.mCell.setCID(gsmCellLocation.getCid()); // CID
if (gsmCellLocation.getPsc() != -1) {
mDevice.mCell.setPSC(gsmCellLocation.getPsc()); // PSC
}
/*
Add cell if gps is not enabled
when gps enabled lat lon will be updated
by function below
*/
}
break;
case TelephonyManager.PHONE_TYPE_CDMA:
CdmaCellLocation cdmaCellLocation = (CdmaCellLocation) location;
if (cdmaCellLocation != null) {
mDevice.setCellInfo(
cdmaCellLocation.toString() + // ??
mDevice.getDataActivityTypeShort() + "|" + // No,In,Ou,IO,Do
mDevice.getDataStateShort() + "|" + // Di,Ct,Cd,Su
mDevice.getNetworkTypeName() + "|" // HSPA,LTE etc
);
mDevice.mCell.setLAC(cdmaCellLocation.getNetworkId()); // NID
mDevice.mCell.setCID(cdmaCellLocation.getBaseStationId()); // BID
mDevice.mCell.setSID(cdmaCellLocation.getSystemId()); // SID
mDevice.mCell.setMNC(cdmaCellLocation.getSystemId()); // MNC <== BUG!??
mDevice.setNetworkName(tm.getNetworkOperatorName()); // ??
}
}
}
示例7: onCellLocationChanged
import android.telephony.gsm.GsmCellLocation; //導入方法依賴的package包/類
public void onCellLocationChanged(CellLocation location) {
checkForNeighborCount(location);
compareLac(location);
refreshDevice();
device.setNetID(tm);
device.getNetworkTypeName();
switch (device.getPhoneId()) {
case TelephonyManager.PHONE_TYPE_NONE:
case TelephonyManager.PHONE_TYPE_SIP:
case TelephonyManager.PHONE_TYPE_GSM:
GsmCellLocation gsmCellLocation = (GsmCellLocation) location;
if (gsmCellLocation != null) {
//TODO @EVA where are we sending this setCellInfo data?
//TODO
/*@EVA
Is it a good idea to dump all cells to db because if we spot a known cell
with different locationAreaCode then this will also be dump to db.
*/
device.setCellInfo(
gsmCellLocation.toString() + // ??
device.getDataActivityTypeShort() + "|" + // No,In,Ou,IO,Do
device.getDataStateShort() + "|" + // Di,Ct,Cd,Su
device.getNetworkTypeName() + "|" // HSPA,LTE etc
);
device.cell.setLocationAreaCode(gsmCellLocation.getLac()); // LAC
device.cell.setCellId(gsmCellLocation.getCid()); // CID
if (gsmCellLocation.getPsc() != -1) {
device.cell.setPrimaryScramblingCode(gsmCellLocation.getPsc()); // PSC
}
/*
Add cell if gps is not enabled
when gps enabled lat lon will be updated
by function below
*/
}
break;
case TelephonyManager.PHONE_TYPE_CDMA:
CdmaCellLocation cdmaCellLocation = (CdmaCellLocation) location;
if (cdmaCellLocation != null) {
device.setCellInfo(
cdmaCellLocation.toString() + // ??
device.getDataActivityTypeShort() + "|" + // No,In,Ou,IO,Do
device.getDataStateShort() + "|" + // Di,Ct,Cd,Su
device.getNetworkTypeName() + "|" // HSPA,LTE etc
);
device.cell.setLocationAreaCode(cdmaCellLocation.getNetworkId()); // NID
device.cell.setCellId(cdmaCellLocation.getBaseStationId()); // BID
device.cell.setSid(cdmaCellLocation.getSystemId()); // SID
device.cell.setMobileNetworkCode(cdmaCellLocation.getSystemId()); // MNC <== BUG!??
device.setNetworkName(tm.getNetworkOperatorName()); // ??
}
}
}
示例8: updateNetworkData
import android.telephony.gsm.GsmCellLocation; //導入方法依賴的package包/類
@SuppressLint("NewApi")
private void updateNetworkData(CellLocation location){
TextView mynetcountry = (TextView)findViewById(R.id.mynetcountry);
TextView mynetoperator = (TextView)findViewById(R.id.mynetoperator);
TextView mynetmcc = (TextView)findViewById(R.id.mynetmcc);
TextView mynetmnc = (TextView)findViewById(R.id.mynetmnc);
TextView mynettype = (TextView)findViewById(R.id.mynettype);
TextView mylac = (TextView)findViewById(R.id.mylac);
TextView mycid = (TextView)findViewById(R.id.mycid);
TextView mypsc = (TextView)findViewById(R.id.mypsc);
if (location != null) {
/**The country iso code and the operator name as read from the network*/
mynetcountry.setText(telephonyManager.getNetworkCountryIso());
mynetoperator.setText(telephonyManager.getNetworkOperatorName());
/**The type of network.
* Actually I do not support American handsets (1xRTT, EVDO_0, and EVDO_A).
* But I show it here anyway. :-) Who knows... */
int nettype = telephonyManager.getNetworkType();
switch (nettype) {
case (TelephonyManager.NETWORK_TYPE_1xRTT): mynettype.setText("1xRTT"); break;
case (TelephonyManager.NETWORK_TYPE_CDMA): mynettype.setText("CDMA"); break;
case (TelephonyManager.NETWORK_TYPE_EDGE): mynettype.setText("EDGE"); break;
case (TelephonyManager.NETWORK_TYPE_EVDO_0): mynettype.setText("EVDO_0"); break;
case (TelephonyManager.NETWORK_TYPE_EVDO_A): mynettype.setText("EVDO_A"); break;
case (TelephonyManager.NETWORK_TYPE_HSDPA): mynettype.setText("HSDPA"); break;
case (TelephonyManager.NETWORK_TYPE_HSPA): mynettype.setText("HSPA"); break;
case (TelephonyManager.NETWORK_TYPE_HSUPA): mynettype.setText("HSUPA"); break;
case (TelephonyManager.NETWORK_TYPE_UMTS): mynettype.setText("UMTS"); break;
case (TelephonyManager.NETWORK_TYPE_UNKNOWN): mynettype.setText("UNKNOWN"); break;
default: break;
}
/** MCC and MNC. the check is required, otherwise crash when no coverage is available*/
String mynetmccmnc = telephonyManager.getNetworkOperator();
if (mynetmccmnc != null && mynetmccmnc.length() >= 4) {
mynetmcc.setText(mynetmccmnc.substring(0,3));
mynetmnc.setText(mynetmccmnc.substring(3));
} else {
mynetmcc.setText("NA");
mynetmnc.setText("NA");
}
/** LAC and Cellid*/
GsmCellLocation gsmLocation = (GsmCellLocation)location;
int psc=gsmLocation.getPsc();
int lac = gsmLocation.getLac();
int cid = gsmLocation.getCid() & 0xffff;
if (lac!=-1 && lac !=65535)
mylac.setText(String.valueOf(lac));
else mylac.setText("NA");
if (cid!=-1 && cid != 65535)
mycid.setText(String.valueOf(cid));
else mycid.setText("NA");
if (psc!=-1 && psc != 65535)
mypsc.setText(String.valueOf(psc));
else mypsc.setText("NA");
} else {
mynetcountry.setText("NA");
mynetoperator.setText("NA");
mynetmcc.setText("NA");
mynetmnc.setText("NA");
mynettype.setText("NA");
mylac.setText("NA");
mycid.setText("NA");
mypsc.setText("NA");
}
}
示例9: onCellLocationChanged
import android.telephony.gsm.GsmCellLocation; //導入方法依賴的package包/類
@SuppressLint("NewApi")
public void onCellLocationChanged(CellLocation location){
String mccmnc = srvcTelephonyManager.getNetworkOperator();
/** MCC and MNC. the check is required, otherwise crash when no coverage is available*/
if (mccmnc != null && mccmnc.length() >= 4) {
mcc = mccmnc.substring(0,3);
mnc = mccmnc.substring(3);
} else {
mcc = "-1";
mnc = "-1";
}
/** LAC and Cellid*/
GsmCellLocation gsmLocation = (GsmCellLocation)location;
lac=gsmLocation.getLac();
cellid=gsmLocation.getCid() & 0xffff;
cellpsc=gsmLocation.getPsc();
//if (lac == 65535) lac=-1;
//if (cellid == 65535) cellid=-1;
switch (srvcTelephonyManager.getNetworkType()) {
case (TelephonyManager.NETWORK_TYPE_1xRTT): nettype = "1xRTT"; break;
case (TelephonyManager.NETWORK_TYPE_CDMA): nettype = "CDMA"; break;
case (TelephonyManager.NETWORK_TYPE_EDGE): nettype = "EDGE"; break;
case (TelephonyManager.NETWORK_TYPE_EVDO_0): nettype = "EVDO_0"; break;
case (TelephonyManager.NETWORK_TYPE_EVDO_A): nettype = "EVDO_A"; break;
case (TelephonyManager.NETWORK_TYPE_HSDPA): nettype = "HSDPA"; break;
case (TelephonyManager.NETWORK_TYPE_HSPA): nettype = "HSPA"; break;
case (TelephonyManager.NETWORK_TYPE_HSUPA): nettype = "HSUPA"; break;
case (TelephonyManager.NETWORK_TYPE_UMTS): nettype = "UMTS"; break;
case (TelephonyManager.NETWORK_TYPE_UNKNOWN): nettype = "UNKNOWN"; break;
default: break;
}
if (cellid_logging && updateInterval==0){
// if we change cell write datapoint to the CSV file. KML is not required as GPS info is redundant
writeDataPoint();
}
if (neighbors_logging){
neighborsmapGSM.clear(); //clean the list of neighbors (GSM networks)
neighborsmapUMTS.clear(); //clean the list of neighbors (UMTS networks)
}
}
示例10: onLocationChanged
import android.telephony.gsm.GsmCellLocation; //導入方法依賴的package包/類
@Override
public void onLocationChanged(Location location) {
// Report to the UI that the location was updated
String[] data = new String[5];
data[0] = String.valueOf(location.getLatitude());
data[1] = String.valueOf(location.getLongitude());
TelephonyManager telephonyManager = (TelephonyManager) activity
.getSystemService(Context.TELEPHONY_SERVICE);
CellLocation cellLocation = telephonyManager.getCellLocation();
String cellLocationData = "[]";
switch (telephonyManager.getPhoneType()) {
case TelephonyManager.PHONE_TYPE_NONE:
cellLocationData = "[" + TelephonyManager.PHONE_TYPE_NONE + "]";
break;
case TelephonyManager.PHONE_TYPE_CDMA:
CdmaCellLocation cdmaLocation = (CdmaCellLocation) cellLocation;
cellLocationData = "[" + TelephonyManager.PHONE_TYPE_CDMA
+ cdmaLocation.getBaseStationId() + ", "
+ cdmaLocation.getBaseStationLatitude() + ", "
+ cdmaLocation.getBaseStationLongitude() + ", "
+ cdmaLocation.getSystemId() + ", "
+ cdmaLocation.getNetworkId() + "]";
break;
case TelephonyManager.PHONE_TYPE_GSM:
GsmCellLocation gsmLocation = (GsmCellLocation) cellLocation;
cellLocationData = "[" + TelephonyManager.PHONE_TYPE_GSM + ", "
+ gsmLocation.getLac() + ", " + gsmLocation.getCid() + ", "
+ gsmLocation.getPsc() + "]";
break;
}
;
data[2] = cellLocationData;
data[3] = "[]";
data[4] = "[]";
SettingsDB helper = new SettingsDB(activity.getBaseContext());
SQLiteDatabase db = helper.getWritableDatabase();
String[] columns = SettingsDB.LOCATION_TABLE_COLUMNS;
ContentValues values = new ContentValues();
for (int i = 0; i < columns.length; i++)
values.put(columns[i], data[i]);
db.replace(SettingsDB.LOCATION_STATES_TABLE, null, values);
Toast.makeText(activity, "Current location has been added",
Toast.LENGTH_SHORT).show();
db.close();
activity.getLocationClient().removeLocationUpdates(this);
}