天天看點

android10TYPE_PHONE,Java TelephonyManager.PHONE_TYPE_GSM屬性代碼示例

public void onLocationChanged(Location loc) {

DeviceApi18.loadCellInfo(tm, mDevice);

if (!mDevice.mCell.isValid()) {

CellLocation cellLocation = tm.getCellLocation();

if (cellLocation != null) {

switch (mDevice.getPhoneID()) {

case TelephonyManager.PHONE_TYPE_NONE:

case TelephonyManager.PHONE_TYPE_SIP:

case TelephonyManager.PHONE_TYPE_GSM:

GsmCellLocation gsmCellLocation = (GsmCellLocation) cellLocation;

mDevice.mCell.setCID(gsmCellLocation.getCid()); // CID

mDevice.mCell.setLAC(gsmCellLocation.getLac()); // LAC

mDevice.mCell.setPSC(gsmCellLocation.getPsc()); // PSC

break;

case TelephonyManager.PHONE_TYPE_CDMA:

CdmaCellLocation cdmaCellLocation = (CdmaCellLocation) cellLocation;

mDevice.mCell.setCID(cdmaCellLocation.getBaseStationId()); // BSID ??

mDevice.mCell.setLAC(cdmaCellLocation.getNetworkId()); // NID

mDevice.mCell.setSID(cdmaCellLocation.getSystemId()); // SID

mDevice.mCell.setMNC(cdmaCellLocation.getSystemId()); // MNC <== BUG!??

break;

}

}

}

if (loc != null && (Double.doubleToRawLongBits(loc.getLatitude()) != 0 && Double.doubleToRawLongBits(loc.getLongitude()) != 0)) {

mDevice.mCell.setLon(loc.getLongitude()); // gpsd_lon

mDevice.mCell.setLat(loc.getLatitude()); // gpsd_lat

mDevice.mCell.setSpeed(loc.getSpeed()); // speed // TODO: Remove, we're not using it!

mDevice.mCell.setAccuracy(loc.getAccuracy()); // gpsd_accu

mDevice.mCell.setBearing(loc.getBearing()); // -- [deg]?? // TODO: Remove, we're not using it!

mDevice.setLastLocation(loc); //

// Store last known location in preference

SharedPreferences.Editor prefsEditor;

prefsEditor = prefs.edit();

prefsEditor.putString(context.getString(R.string.data_last_lat_lon),

String.valueOf(loc.getLatitude()) + ":" + String.valueOf(loc.getLongitude()));

prefsEditor.apply();

// This only logs a BTS if we have GPS lock

// Test: ~~Is correct behaviour? We should consider logging all cells, even without GPS.~~

//if (mTrackingCell) {

// This also checks that the lac are cid are not in DB before inserting

dbHelper.insertBTS(mDevice.mCell);

//}

}

}