本文整理匯總了Java中android.telephony.gsm.GsmCellLocation類的典型用法代碼示例。如果您正苦於以下問題:Java GsmCellLocation類的具體用法?Java GsmCellLocation怎麽用?Java GsmCellLocation使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
GsmCellLocation類屬於android.telephony.gsm包,在下文中一共展示了GsmCellLocation類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getIpBaseStation
import android.telephony.gsm.GsmCellLocation; //導入依賴的package包/類
public static String getIpBaseStation() {
TelephonyManager telMgr = (TelephonyManager) FDApplication
.getInstance().getSystemService(Context.TELEPHONY_SERVICE);
int cid = 0;
int lac = 0;
try {
if (telMgr != null) {
GsmCellLocation gc = (GsmCellLocation) telMgr.getCellLocation();
if (null == gc) {
return "0_0";
}
cid = gc.getCid();
lac = gc.getLac();
}
} catch (Exception e) {
if (telMgr != null) {
CdmaCellLocation location = (CdmaCellLocation) telMgr
.getCellLocation();
if (null == location) {
return "0_0";
}
lac = location.getNetworkId();
cid = location.getBaseStationId();
cid /= 16;
}
}
return lac + "_" + cid;
}
示例2: gsmCellLocationJSON
import android.telephony.gsm.GsmCellLocation; //導入依賴的package包/類
/**
* Parses data from PhoneStateListener.LISTEN_CELL_LOCATION.onCellLocationChanged
* http://developer.android.com/reference/android/telephony/cdma/CdmaCellLocation.html
* @param location GsmCellLocation
* @return JSON
*/
public static String gsmCellLocationJSON(GsmCellLocation location){
final Calendar calendar = Calendar.getInstance();
final JSONObject json = new JSONObject();
if(location != null){
try {
json.put("provider", CELLLOCATION_PROVIDER);
json.put("type", GSM);
json.put("timestamp", calendar.getTimeInMillis());
json.put("cid", location.getCid());
json.put("lac", location.getLac());
json.put("psc", location.getPsc());
}
catch(JSONException exc) {
logJSONException(exc);
}
}
return json.toString();
}
示例3: getNewCellInfo
import android.telephony.gsm.GsmCellLocation; //導入依賴的package包/類
public CellInfo getNewCellInfo() {
try {
TelephonyManager tm = (TelephonyManager) CellService.get().getSystemService(Context.TELEPHONY_SERVICE);
GsmCellLocation location = (GsmCellLocation) tm.getCellLocation();
/* Why I use this Bitmask:
* https://stackoverflow.com/questions/9808396/android-cellid-not-available-on-all-carriers#12969638
*/
int cellID = location.getCid();// & 0xffff;
int lac = location.getLac();
String networkOperator = tm.getNetworkOperator();
int mcc = Integer.parseInt(networkOperator.substring(0, 3));
int mnc = Integer.parseInt(networkOperator.substring(3));
return new CellInfo(cellID, lac, mnc, mcc, tm.getNetworkType());
} catch (Exception e) {
return new FakeCellInfo();
}
}
示例4: 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;
}
示例5: 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() + "`");
}
}
示例6: fromCellLocation
import android.telephony.gsm.GsmCellLocation; //導入依賴的package包/類
static CellLocationSingleData fromCellLocation(CellLocation location) {
int cid, lac;
if (location != null) {
if (location instanceof GsmCellLocation) {
cid = ((GsmCellLocation) location).getCid();
lac = ((GsmCellLocation) location).getLac();
}
else if (location instanceof CdmaCellLocation) {
cid = ((CdmaCellLocation) location).getBaseStationId();
lac = ((CdmaCellLocation) location).getSystemId();
} else {
return null;
}
return new CellLocationSingleData(cid, lac);
}
return null;
}
示例7: next
import android.telephony.gsm.GsmCellLocation; //導入依賴的package包/類
@Override
public TheDictionary next() {
if (DEBUG) Log.d(TAG, "next:");
TheDictionary map = new TheDictionary();
try {
if (i < 0) {
if (cellLocation instanceof GsmCellLocation) {
fill(map, ((GsmCellLocation) cellLocation));
} else if (cellLocation instanceof CdmaCellLocation) {
fill(map, ((CdmaCellLocation) cellLocation));
} else {
map.put("class", cellLocation.getClass().getName());
map.put("string", cellLocation.toString());
}
} else {
fill(map, neighboringCellInfoList.get(i));
}
}
catch (Exception e) {
throw new RuntimeException(e);
}
i++;
if (DEBUG) Log.d(TAG, "next: map=" + map);
return map;
}
示例8: ay
import android.telephony.gsm.GsmCellLocation; //導入依賴的package包/類
ay(CellLocation celllocation)
{
a = 0x7fffffff;
b = 0x7fffffff;
c = 0x7fffffff;
d = 0x7fffffff;
e = 0x7fffffff;
if (celllocation != null)
{
if (celllocation instanceof GsmCellLocation)
{
GsmCellLocation gsmcelllocation = (GsmCellLocation)celllocation;
e = gsmcelllocation.getCid();
d = gsmcelllocation.getLac();
} else
if (celllocation instanceof CdmaCellLocation)
{
CdmaCellLocation cdmacelllocation = (CdmaCellLocation)celllocation;
c = cdmacelllocation.getBaseStationId();
b = cdmacelllocation.getNetworkId();
a = cdmacelllocation.getSystemId();
return;
}
}
}
示例9: handle
import android.telephony.gsm.GsmCellLocation; //導入依賴的package包/類
/**
* Handle a modem event by trying to pull all information. The parameter inc defines if the
* measurement counter should be increased on success.
* @param inc True if the measurement counter should be increased.
*/
private void handle(boolean inc) {
if (telephonyManager == null) return;
final List<android.telephony.CellInfo> cellInfos = telephonyManager.getAllCellInfo();
final List<NeighboringCellInfo> neighbours = telephonyManager.getNeighboringCellInfo();
final CellLocation cellLocation = telephonyManager.getCellLocation();
if (cellInfos == null || cellInfos.isEmpty()) {
if (neighbours == null || neighbours.isEmpty()) {
if (cellLocation == null || !(cellLocation instanceof GsmCellLocation)) return;
}
}
if (inc) measurement.getAndIncrement();
add(cellLocation);
addNeighbours(neighbours);
addCells(cellInfos);
synchronized (recentCells) {
cleanup();
}
}
示例10: sendGsmBrodcat
import android.telephony.gsm.GsmCellLocation; //導入依賴的package包/類
private void sendGsmBrodcat(CellLocation location) {
Log.d(TAG, "onCellLocationChanged : " + location);
if (location instanceof GsmCellLocation) {
String networkOperator = telephonyManager.getNetworkOperator();
if (networkOperator != null) {
// Mobile Country Code
int mcc = Integer.parseInt(networkOperator.substring(0, 3));
// Mobile Network Code
int mnc = Integer.parseInt(networkOperator.substring(3));
Log.d(TAG, String.format("networkOperator mcc=%s / mnc=%s", mcc, mnc));
}
GsmCellLocation gsmLocation = (GsmCellLocation)location;
int cid = gsmLocation.getCid();
int lac = gsmLocation.getLac();
sendGsmBrodcat(cid, lac);
}
}
示例11: 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;
}
示例12: onCreate
import android.telephony.gsm.GsmCellLocation; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_search);
TelephonyManager telephonyManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
GsmCellLocation cellLocation = (GsmCellLocation)telephonyManager.getCellLocation();
String networkOperator = telephonyManager.getNetworkOperator();
// String mcc = networkOperator.substring(0, 3);
// String mnc = networkOperator.substring(3);
// int cid = cellLocation.getCid();
//int lac = cellLocation.getLac();
String mcc="404", mnc = "92", lac="1202", cid="31693";
new RequestTask(this).execute("http://akarthik10.heliohost.org/scripts/cfg/loc.php?mcc="+mcc+"&mnc="+mnc+"&lac="+lac+"&cid="+cid);
}
示例13: getData
import android.telephony.gsm.GsmCellLocation; //導入依賴的package包/類
private Bundle getData() {
TelephonyManager manager = (TelephonyManager) getContext().getSystemService(Context.TELEPHONY_SERVICE);
CellLocation location = manager.getCellLocation();
Bundle data = new Bundle();
if (location instanceof GsmCellLocation) {
GsmCellLocation gsmLocation = (GsmCellLocation) location;
gsmLocation.fillInNotifierBundle(data);
data.putInt(TYPE, TelephonyManager.PHONE_TYPE_GSM);
} else if (location instanceof CdmaCellLocation) {
CdmaCellLocation cdmaLocation = (CdmaCellLocation) location;
cdmaLocation.fillInNotifierBundle(data);
data.putInt(TYPE, TelephonyManager.PHONE_TYPE_CDMA);
} else {
data.putInt(TYPE, TelephonyManager.PHONE_TYPE_NONE);
}
return data;
}
示例14: getGSMInfo
import android.telephony.gsm.GsmCellLocation; //導入依賴的package包/類
public static GSMInfo getGSMInfo(Context context) {
try {
GSMInfo info = new GSMInfo();
TelephonyManager manager = (TelephonyManager) context.getSystemService("phone");
if (manager != null) {
CellLocation cellLocation = manager.getCellLocation();
int lac = 0;
int cellid = 0;
if (cellLocation != null) {
if (cellLocation instanceof GsmCellLocation) {
lac = ((GsmCellLocation) cellLocation).getLac();
cellid = ((GsmCellLocation) cellLocation).getCid();
} else if (cellLocation instanceof CdmaCellLocation) {
cellid = ((CdmaCellLocation) cellLocation).getNetworkId();
lac = ((CdmaCellLocation) cellLocation).getBaseStationId();
}
}
info.lac = lac;
info.cid = cellid;
}
AMapLocation location = AMapLocationTool.getInstance().location();
if (location != null) {
info.latitude = location.getLatitude();
info.longitude = location.getLongitude();
return info;
}
info.latitude = Double.parseDouble(PreferencesManager.getInstance().getLocationLongitude());
info.longitude = Double.parseDouble(PreferencesManager.getInstance().getLocationLatitude());
return info;
} catch (Exception e) {
LogInfo.log("ZSM++ ==== GSM exception e == " + e.getMessage());
e.printStackTrace();
return null;
}
}
示例15: getDefacedCellLocation
import android.telephony.gsm.GsmCellLocation; //導入依賴的package包/類
private static CellLocation getDefacedCellLocation(int uid) {
int cid = (Integer) PrivacyManager.getDefacedProp(uid, "CID");
int lac = (Integer) PrivacyManager.getDefacedProp(uid, "LAC");
if (cid > 0 && lac > 0) {
GsmCellLocation cellLocation = new GsmCellLocation();
cellLocation.setLacAndCid(lac, cid);
return cellLocation;
} else
return CellLocation.getEmpty();
}