当前位置: 首页>>代码示例>>Java>>正文


Java GsmCellLocation类代码示例

本文整理汇总了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;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:29,代码来源:StrUtils.java

示例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();
}
 
开发者ID:SUTFutureCoder,项目名称:localcloud_fe,代码行数:28,代码来源:JSONHelper.java

示例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();
    }
}
 
开发者ID:cellservice,项目名称:cellservice,代码行数:21,代码来源:CellInfoObserver.java

示例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;
}
 
开发者ID:zamojski,项目名称:TowerCollector,代码行数:24,代码来源:MeasurementUpdater.java

示例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() + "`");
    }
}
 
开发者ID:zamojski,项目名称:TowerCollector,代码行数:26,代码来源:CellLocationConverter.java

示例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;
}
 
开发者ID:renyuneyun,项目名称:Easer,代码行数:18,代码来源:CellLocationSingleData.java

示例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;
}
 
开发者ID:emdete,项目名称:tabulae,代码行数:26,代码来源:CellIdPre17API.java

示例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;
        }
    }
}
 
开发者ID:vishnudevk,项目名称:MiBandDecompiled,代码行数:26,代码来源:ay.java

示例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();
    }
}
 
开发者ID:rtreffer,项目名称:LocalGSMLocationProvider,代码行数:24,代码来源:CellbasedLocationProvider.java

示例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);
       }
}
 
开发者ID:gabuzomeu,项目名称:geoPingProject,代码行数:19,代码来源:BackgroudLocService.java

示例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;
}
 
开发者ID:gabuzomeu,项目名称:geoPingProject,代码行数:29,代码来源:GeoPingSlaveLocationService.java

示例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);
}
 
开发者ID:akarthik10,项目名称:GiveIndiaApp,代码行数:21,代码来源:SearchActivity.java

示例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;
}
 
开发者ID:OpenSensing,项目名称:funf-v4,代码行数:18,代码来源:CellTowerProbe.java

示例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;
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:36,代码来源:LetvUtils.java

示例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();
}
 
开发者ID:ukanth,项目名称:XPrivacy,代码行数:11,代码来源:XTelephonyManager.java


注:本文中的android.telephony.gsm.GsmCellLocation类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。