求哪位大神分享一下【艾丽卡 电影】电影百度云资源?

403 Forbidden
You don't have permission to access /forums/lteworld-forum/lte-cell-search
on this server.
Additionally, a 403 Forbidden
error was encountered while trying to use an ErrorDocument to handle the request.
Apache Server at lteworld.org Port 80Java Code Example android.telephony.CellInfoLte
Java Code Examples for android.telephony.CellInfoLte
The following are top voted examples for showing how to use
android.telephony.CellInfoLte. These examples are extracted from open source projects.
You can vote up the examples you like and your votes will be used in our system to product
more good examples.
@SuppressWarnings(&ChainOfInstanceofChecks&)
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
private Cell parceCellInfo18(CellInfo info) {
if (Build.VERSION.SDK_INT & Build.VERSION_CODES.JELLY_BEAN_MR2)
if (info instanceof CellInfoWcdma) {
CellIdentityWcdma identity = ((CellInfoWcdma) info).getCellIdentity();
if (identity.getMcc() == Integer.MAX_VALUE)
CellSignalStrengthWcdma strength = ((CellInfoWcdma) info).getCellSignalStrength();
return new Cell(Cell.CellType.UMTS, identity.getMcc(), identity.getMnc(),
identity.getLac(), identity.getCid(), identity.getPsc(), strength.getDbm());
} else if (info instanceof CellInfoLte) {
CellIdentityLte identity = ((CellInfoLte) info).getCellIdentity();
if (identity.getMcc() == Integer.MAX_VALUE)
CellSignalStrengthLte strength = ((CellInfoLte) info).getCellSignalStrength();
return new Cell(Cell.CellType.LTE, identity.getMcc(), identity.getMnc(),
identity.getTac(), identity.getCi(), identity.getPci(), strength.getDbm());
@TargetApi(17)
public int getLteRsrq(SignalStrength signalStrength) {
// Two hacky ways to attempt to get the rsrq
// First hacky way: reflection on the signalStrength object
Method method = SignalStrength.class.getDeclaredMethod(&getLteRsrq&);
int rsrq = (Integer) method.invoke(signalStrength);
Log.v(TAG, &getLteRsrq: found & + rsrq + & using SignalStrength.getLteRsrq()&);
if (rsrq & 0)
} catch (NoSuchMethodException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
Log.e(TAG, &getLteRsrq Could not get rsrq&, e);
// Second hacky way: reflection on the CellInfo object.
List&CellInfo& cellInfos = mTelephonyManager.getAllCellInfo();
if (cellInfos != null) {
for (CellInfo cellInfo : cellInfos) {
if (cellInfo.isRegistered()) {
if (cellInfo instanceof CellInfoLte) {
CellSignalStrengthLte signalStrengthLte = ((CellInfoLte) cellInfo).getCellSignalStrength();
Field fieldRsrq = CellSignalStrength.class.getDeclaredField(&mRsrq&);
fieldRsrq.setAccessible(true);
int rsrq = (Integer) fieldRsrq.get(signalStrengthLte);
Log.v(TAG, &getLteRsrq: found & + rsrq + & using CellInfoLte.mRsrq&);
if (rsrq & 0)
} catch (NoSuchFieldException | IllegalAccessException | IllegalArgumentException e) {
Log.e(TAG, &getRsrq Could not get Rsrq&, e);
return SIGNAL_STRENGTH_NONE_OR_UNKNOWN;
@SuppressWarnings({&ChainOfInstanceofChecks&, &MagicNumber&})
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
private void fixAllCellInfo(List&CellInfo& cellInfo) {
if (cellInfo == null)
String networkOperator = telephonyManager.getNetworkOperator();
if (networkOperator.length() != 5)
int realMnc = Integer.parseInt(networkOperator.substring(3));
boolean theBug =
for (CellInfo info : cellInfo) {
if (info instanceof CellInfoCdma)
if (info.isRegistered()) {
Cell cell = parseCellInfo(info);
if (cell == null)
int infoMnc = cell.getMnc();
if (infoMnc == (realMnc * 10 + 15)) {
if (theBug) {
for (CellInfo info : cellInfo) {
Object identity =
if (info instanceof CellInfoGsm)
identity = ((CellInfoGsm) info).getCellIdentity();
else if (info instanceof CellInfoLte)
identity = ((CellInfoLte) info).getCellIdentity();
else if (Build.VERSION.SDK_INT &= Build.VERSION_CODES.JELLY_BEAN_MR2 &&
info instanceof CellInfoWcdma)
identity = ((CellInfoWcdma) info).getCellIdentity();
if (identity == null)
Field mncField = identity.getClass().getDeclaredField(&mMnc&);
mncField.setAccessible(true);
int mnc = (Integer) mncField.get(identity);
if (mnc &= 25 && mnc &= 1005) {
mnc = (mnc - 15) / 10;
mncField.setInt(identity, mnc);
} catch (Exception ignored) {
public CdmaLteServiceStateTracker(CDMALTEPhone phone) {
super(phone, new CellInfoLte());
mCdmaLtePhone =
mCellInfoLte = (CellInfoLte) mCellI
mLteSS = new ServiceState();
((CellInfoLte)mCellInfo).setCellSignalStrength(new CellSignalStrengthLte());
((CellInfoLte)mCellInfo).setCellIdentity(new CellIdentityLte());
if (DBG) log(&CdmaLteServiceStateTracker Constructors&);
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
public static void fill(TheDictionary map, CellInfo value) throws Exception {
if (value != null) {
map.put(&time_stamp&, value.getTimeStamp());
map.put(&registered&, value.isRegistered());
if (value instanceof CellInfoCdma) {
fill(map, ((CellInfoCdma) value).getCellIdentity());
fill(map, ((CellInfoCdma) value).getCellSignalStrength());
} else if (value instanceof CellInfoGsm) {
fill(map, ((CellInfoGsm) value).getCellIdentity());
fill(map, ((CellInfoGsm) value).getCellSignalStrength());
} else if (value instanceof CellInfoWcdma) {
if (Build.VERSION.SDK_INT &= Build.VERSION_CODES.JELLY_BEAN_MR2) {
fill(map, ((CellInfoWcdma) value).getCellIdentity());
fill(map, ((CellInfoWcdma) value).getCellSignalStrength());
} else if (value instanceof CellInfoLte) {
fill(map, ((CellInfoLte) value).getCellIdentity());
fill(map, ((CellInfoLte) value).getCellSignalStrength());
map.put(&class&, value.getClass().getName());
map.put(&string&, value.toString());
public CdmaLteServiceStateTracker(CDMALTEPhone phone) {
super(phone, new CellInfoLte());
mCdmaLtePhone =
mCdmaLtePhone.registerForSimRecordsLoaded(this, EVENT_SIM_RECORDS_LOADED, null);
mCellInfoLte = (CellInfoLte) mCellI
((CellInfoLte)mCellInfo).setCellSignalStrength(new CellSignalStrengthLte());
((CellInfoLte)mCellInfo).setCellIdentity(new CellIdentityLte());
if (DBG) log(&CdmaLteServiceStateTracker Constructors&);
protected void pollStateDone() {
// determine data RadioTechnology from both LET and CDMA SS
if (mLteSS.getState() == ServiceState.STATE_IN_SERVICE) {
//in LTE service
mNewRilRadioTechnology = mLteSS.getRilRadioTechnology();
mNewDataConnectionState = mLteSS.getState();
newSS.setRadioTechnology(mNewRilRadioTechnology);
log(&pollStateDone LTE/eHRPD STATE_IN_SERVICE mNewRilRadioTechnology = & +
mNewRilRadioTechnology);
// LTE out of service, get CDMA Service State
mNewRilRadioTechnology = newSS.getRilRadioTechnology();
mNewDataConnectionState = radioTechnologyToDataServiceState(mNewRilRadioTechnology);
log(&pollStateDone CDMA STATE_IN_SERVICE mNewRilRadioTechnology = & +
mNewRilRadioTechnology + & mNewDataConnectionState = & +
mNewDataConnectionState);
// TODO: Add proper support for LTE Only, we should be looking at
the preferred network mode, to know when newSS state should
be coming from mLteSs state. This was needed to pass a VZW
LTE Only test.
// If CDMA service is OOS, double check if the device is running with LTE only
// mode. If that is the case, derive the service state from LTE side.
// To set in LTE only mode, sqlite3 /data/data/com.android.providers.settings/
// databases/settings.db &update secure set value='11' where name='preferred_network_mode'&
if (newSS.getState() == ServiceState.STATE_OUT_OF_SERVICE) {
int networkMode = android.provider.Settings.Global.getInt(phone.getContext()
.getContentResolver(),
android.provider.Settings.Global.PREFERRED_NETWORK_MODE,
RILConstants.PREFERRED_NETWORK_MODE);
if (networkMode == RILConstants.NETWORK_MODE_LTE_ONLY) {
if (DBG) log(&pollState: LTE Only mode&);
newSS.setState(mLteSS.getState());
if (DBG) log(&pollStateDone: oldSS=[& + ss + &] newSS=[& + newSS + &]&);
boolean hasRegistered = ss.getState() != ServiceState.STATE_IN_SERVICE
&& newSS.getState() == ServiceState.STATE_IN_SERVICE;
boolean hasDeregistered = ss.getState() == ServiceState.STATE_IN_SERVICE
&& newSS.getState() != ServiceState.STATE_IN_SERVICE;
boolean hasCdmaDataConnectionAttached =
mDataConnectionState != ServiceState.STATE_IN_SERVICE
&& mNewDataConnectionState == ServiceState.STATE_IN_SERVICE;
boolean hasCdmaDataConnectionDetached =
mDataConnectionState == ServiceState.STATE_IN_SERVICE
&& mNewDataConnectionState != ServiceState.STATE_IN_SERVICE;
boolean hasCdmaDataConnectionChanged =
mDataConnectionState != mNewDataConnectionS
boolean hasRadioTechnologyChanged = mRilRadioTechnology != mNewRilRadioT
boolean hasChanged = !newSS.equals(ss);
boolean hasRoamingOn = !ss.getRoaming() && newSS.getRoaming();
boolean hasRoamingOff = ss.getRoaming() && !newSS.getRoaming();
boolean hasLocationChanged = !newCellLoc.equals(cellLoc);
boolean has4gHandoff =
mNewDataConnectionState == ServiceState.STATE_IN_SERVICE &&
(((mRilRadioTechnology == ServiceState.RIL_RADIO_TECHNOLOGY_LTE) &&
(mNewRilRadioTechnology == ServiceState.RIL_RADIO_TECHNOLOGY_EHRPD)) ||
((mRilRadioTechnology == ServiceState.RIL_RADIO_TECHNOLOGY_EHRPD) &&
(mNewRilRadioTechnology == ServiceState.RIL_RADIO_TECHNOLOGY_LTE)));
boolean hasMultiApnSupport =
(((mNewRilRadioTechnology == ServiceState.RIL_RADIO_TECHNOLOGY_LTE) ||
(mNewRilRadioTechnology == ServiceState.RIL_RADIO_TECHNOLOGY_EHRPD)) &&
((mRilRadioTechnology != ServiceState.RIL_RADIO_TECHNOLOGY_LTE) &&
(mRilRadioTechnology != ServiceState.RIL_RADIO_TECHNOLOGY_EHRPD)));
boolean hasLostMultiApnSupport =
((mNewRilRadioTechnology &= ServiceState.RIL_RADIO_TECHNOLOGY_IS95A) &&
(mNewRilRadioTechnology &= ServiceState.RIL_RADIO_TECHNOLOGY_EVDO_A));
if (DBG) {
log(&pollStateDone:&
+ & hasRegistered=& + hasRegistered
+ & hasDeegistered=& + hasDeregistered
+ & hasCdmaDataConnectionAttached=& + hasCdmaDataConnectionAttached
+ & hasCdmaDataConnectionDetached=& + hasCdmaDataConnectionDetached
+ & hasCdmaDataConnectionChanged=& + hasCdmaDataConnectionChanged
+ & hasRadioTechnologyChanged = & + hasRadioTechnologyChanged
+ & hasChanged=& + hasChanged
+ & hasRoamingOn=& + hasRoamingOn
+ & hasRoamingOff=& + hasRoamingOff
+ & hasLocationChanged=& + hasLocationChanged
+ & has4gHandoff = & + has4gHandoff
+ & hasMultiApnSupport=& + hasMultiApnSupport
+ & hasLostMultiApnSupport=& + hasLostMultiApnSupport);
// Add an event log when connection state changes
if (ss.getState() != newSS.getState()
|| mDataConnectionState != mNewDataConnectionState) {
EventLog.writeEvent(EventLogTags.CDMA_SERVICE_STATE_CHANGE, ss.getState(),
mDataConnectionState, newSS.getState(), mNewDataConnectionState);
ss = newSS;
// clean slate for next time
newSS.setStateOutOfService();
mLteSS.setStateOutOfService();
if ((hasMultiApnSupport)
&& (phone.mDataConnectionTracker instanceof CdmaDataConnectionTracker)) {
if (DBG) log(&GsmDataConnectionTracker Created&);
phone.mDataConnectionTracker.dispose();
phone.mDataConnectionTracker = new GsmDataConnectionTracker(mCdmaLtePhone);
if ((hasLostMultiApnSupport)
&& (phone.mDataConnectionTracker instanceof GsmDataConnectionTracker)) {
if (DBG)log(&GsmDataConnectionTracker disposed&);
phone.mDataConnectionTracker.dispose();
phone.mDataConnectionTracker = new CdmaDataConnectionTracker(phone);
CdmaCellLocation tcl = cellL
cellLoc = newCellL
newCellLoc =
mDataConnectionState = mNewDataConnectionS
mRilRadioTechnology = mNewRilRadioT
mNewRilRadioTechnology = 0;
newSS.setStateOutOfService(); // clean slate for next time
if (hasRadioTechnologyChanged) {
phone.setSystemProperty(TelephonyProperties.PROPERTY_DATA_NETWORK_TYPE,
ServiceState.rilRadioTechnologyToString(mRilRadioTechnology));
if (hasRegistered) {
mNetworkAttachedRegistrants.notifyRegistrants();
if (hasChanged) {
if (phone.isEriFileLoaded()) {
String eriT
// Now the CDMAPhone sees the new ServiceState so it can get the
// new ERI text
if (ss.getState() == ServiceState.STATE_IN_SERVICE) {
eriText = phone.getCdmaEriText();
} else if (ss.getState() == ServiceState.STATE_POWER_OFF) {
eriText = (mIccRecords != null) ? mIccRecords.getServiceProviderName() :
if (TextUtils.isEmpty(eriText)) {
// Sets operator alpha property by retrieving from
// build-time system property
eriText = SystemProperties.get(&ro.cdma.home.operator.alpha&);
// Note that ServiceState.STATE_OUT_OF_SERVICE is valid used
// for mRegistrationState 0,2,3 and 4
eriText = phone.getContext()
.getText(com.android.internal.R.string.roamingTextSearching).toString();
ss.setOperatorAlphaLong(eriText);
if (mUiccApplcation != null && mUiccApplcation.getState() == AppState.APPSTATE_READY &&
mIccRecords != null) {
// SIM is found on the device. If ERI roaming is OFF, and SID/NID matches
// one configfured in SIM, use operator name
from CSIM record.
boolean showSpn =
((RuimRecords)mIccRecords).getCsimSpnDisplayCondition();
int iconIndex = ss.getCdmaEriIconIndex();
if (showSpn && (iconIndex == EriInfo.ROAMING_INDICATOR_OFF) &&
isInHomeSidNid(ss.getSystemId(), ss.getNetworkId()) &&
mIccRecords != null) {
ss.setOperatorAlphaLong(mIccRecords.getServiceProviderName());
String operatorN
phone.setSystemProperty(TelephonyProperties.PROPERTY_OPERATOR_ALPHA,
ss.getOperatorAlphaLong());
String prevOperatorNumeric =
SystemProperties.get(TelephonyProperties.PROPERTY_OPERATOR_NUMERIC, &&);
operatorNumeric = ss.getOperatorNumeric();
phone.setSystemProperty(TelephonyProperties.PROPERTY_OPERATOR_NUMERIC, operatorNumeric);
if (operatorNumeric == null) {
if (DBG) log(&operatorNumeric is null&);
phone.setSystemProperty(TelephonyProperties.PROPERTY_OPERATOR_ISO_COUNTRY, &&);
mGotCountryCode =
String isoCountryCode = &&;
String mcc = operatorNumeric.substring(0, 3);
isoCountryCode = MccTable.countryCodeForMcc(Integer.parseInt(operatorNumeric
.substring(0, 3)));
} catch (NumberFormatException ex) {
loge(&countryCodeForMcc error& + ex);
} catch (StringIndexOutOfBoundsException ex) {
loge(&countryCodeForMcc error& + ex);
phone.setSystemProperty(TelephonyProperties.PROPERTY_OPERATOR_ISO_COUNTRY,
isoCountryCode);
mGotCountryCode =
if (shouldFixTimeZoneNow(phone, operatorNumeric, prevOperatorNumeric,
mNeedFixZone)) {
fixTimeZone(isoCountryCode);
phone.setSystemProperty(TelephonyProperties.PROPERTY_OPERATOR_ISROAMING,
ss.getRoaming() ? &true& : &false&);
updateSpnDisplay();
phone.notifyServiceStateChanged(ss);
if (hasCdmaDataConnectionAttached || has4gHandoff) {
mAttachedRegistrants.notifyRegistrants();
if (hasCdmaDataConnectionDetached) {
mDetachedRegistrants.notifyRegistrants();
if ((hasCdmaDataConnectionChanged || hasRadioTechnologyChanged)) {
phone.notifyDataConnection(null);
if (hasRoamingOn) {
mRoamingOnRegistrants.notifyRegistrants();
if (hasRoamingOff) {
mRoamingOffRegistrants.notifyRegistrants();
if (hasLocationChanged) {
phone.notifyLocationChanged();
ArrayList&CellInfo& arrayCi = new ArrayList&CellInfo&();
synchronized(mCellInfo) {
CellInfoLte cil = (CellInfoLte)mCellI
boolean cidChanged = ! mNewCellIdentityLte.equals(mLasteCellIdentityLte);
if (hasRegistered || hasDeregistered || cidChanged) {
// TODO: Handle the absence of LteCellIdentity
long timeStamp = SystemClock.elapsedRealtime() * 1000;
boolean registered = ss.getState() == ServiceState.STATE_IN_SERVICE;
mLasteCellIdentityLte = mNewCellIdentityL
cil.setRegisterd(registered);
cil.setCellIdentity(mLasteCellIdentityLte);
if (DBG) {
log(&pollStateDone: hasRegistered=& + hasRegistered +
& hasDeregistered=& + hasDeregistered +
& cidChanged=& + cidChanged +
& mCellInfo=& + mCellInfo);
arrayCi.add(mCellInfo);
mPhoneBase.notifyCellInfo(arrayCi);
* Create a
CellRecord} by parsing
* @param cell
* @param position
PositionRecord Current position}
CellRecord}
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
private CellRecord processCellInfo(final CellInfo cell, final PositionRecord position) {
if (cell instanceof CellInfoGsm) {
* In case of GSM network set GSM specific values
final CellIdentityGsm gsmIdentity = ((CellInfoGsm) cell).getCellIdentity();
if (isValidGsmCell(gsmIdentity)) {
Log.i(TAG, &Processing gsm cell & + gsmIdentity.getCid());
final CellRecord result = new CellRecord(mSessionId);
result.setIsCdma(false);
// generic cell info
result.setNetworkType(mTelephonyManager.getNetworkType());
// TODO: unelegant: implicit conversion from UTC to YYYYMMDDHHMMSS in begin.setTimestamp
result.setOpenBmapTimestamp(position.getOpenBmapTimestamp());
result.setBeginPosition(position);
// so far we set end position = begin position
result.setEndPosition(position);
result.setIsServing(true);
result.setIsNeighbor(!cell.isRegistered());
// GSM specific
result.setLogicalCellId(gsmIdentity.getCid());
// add UTRAN ids, if needed
if (gsmIdentity.getCid() & 0xFFFFFF) {
result.setUtranRnc(gsmIdentity.getCid() && 16);
result.setActualCid(gsmIdentity.getCid() & 0xFFFF);
result.setActualCid(gsmIdentity.getCid());
if (Build.VERSION.SDK_INT &= Build.VERSION_CODES.GINGERBREAD) {
// at least for Nexus 4, even HSDPA networks broadcast psc
result.setPsc(gsmIdentity.getPsc());
final String operator = mTelephonyManager.getNetworkOperator();
// getNetworkOperator() may return empty string, probably due to dropped connection
if (operator.length() & 3) {
result.setOperator(operator);
result.setMcc(operator.substring(0, 3));
result.setMnc(operator.substring(3));
Log.e(TAG, &Couldn't determine network operator, skipping cell&);
final String networkOperatorName = mTelephonyManager.getNetworkOperatorName();
if (networkOperatorName != null) {
result.setOperatorName(mTelephonyManager.getNetworkOperatorName());
Log.e(TAG, &Error retrieving network operator's name, skipping cell&);
result.setArea(gsmIdentity.getLac());
result.setStrengthdBm(((CellInfoGsm) cell).getCellSignalStrength().getDbm());
result.setStrengthAsu(((CellInfoGsm) cell).getCellSignalStrength().getAsuLevel());
} else if (cell instanceof CellInfoWcdma) {
final CellIdentityWcdma wcdmaIdentity = ((CellInfoWcdma)cell).getCellIdentity();
if (isValidWcdmaCell(wcdmaIdentity)) {
Log.i(TAG, &Processing wcdma cell & + wcdmaIdentity.getCid());
final CellRecord result = new CellRecord(mSessionId);
result.setIsCdma(false);
// generic cell info
result.setNetworkType(mTelephonyManager.getNetworkType());
// TODO: unelegant: implicit conversion from UTC to YYYYMMDDHHMMSS in begin.setTimestamp
result.setOpenBmapTimestamp(position.getOpenBmapTimestamp());
result.setBeginPosition(position);
// so far we set end position = begin position
result.setEndPosition(position);
result.setIsServing(true);
result.setIsNeighbor(!cell.isRegistered());
result.setLogicalCellId(wcdmaIdentity.getCid());
// add UTRAN ids, if needed
if (wcdmaIdentity.getCid() & 0xFFFFFF) {
result.setUtranRnc(wcdmaIdentity.getCid() && 16);
result.setActualCid(wcdmaIdentity.getCid() & 0xFFFF);
result.setActualCid(wcdmaIdentity.getCid());
if (Build.VERSION.SDK_INT &= Build.VERSION_CODES.GINGERBREAD) {
// at least for Nexus 4, even HSDPA networks broadcast psc
result.setPsc(wcdmaIdentity.getPsc());
final String operator = mTelephonyManager.getNetworkOperator();
// getNetworkOperator() may return empty string, probably due to dropped connection
if (operator.length() & 3) {
result.setOperator(operator);
result.setMcc(operator.substring(0, 3));
result.setMnc(operator.substring(3));
Log.e(TAG, &Couldn't determine network operator, skipping cell&);
final String networkOperatorName = mTelephonyManager.getNetworkOperatorName();
if (networkOperatorName != null) {
result.setOperatorName(mTelephonyManager.getNetworkOperatorName());
Log.e(TAG, &Error retrieving network operator's name, skipping cell&);
result.setArea(wcdmaIdentity.getLac());
result.setStrengthdBm(((CellInfoWcdma) cell).getCellSignalStrength().getDbm());
result.setStrengthAsu(((CellInfoWcdma) cell).getCellSignalStrength().getAsuLevel());
} else if (cell instanceof CellInfoCdma) {
final CellIdentityCdma cdmaIdentity = ((CellInfoCdma) cell).getCellIdentity();
if (isValidCdmaCell(cdmaIdentity)) {
* In case of CDMA network set CDMA specific values
* Assume CDMA network, if cdma location and basestation, network and system id are available
Log.i(TAG, &Processing cdma cell & + cdmaIdentity.getBasestationId());
final CellRecord result = new CellRecord(mSessionId);
result.setIsCdma(true);
// generic cell info
result.setNetworkType(mTelephonyManager.getNetworkType());
// TODO: unelegant: implicit conversion from UTC to YYYYMMDDHHMMSS in begin.setTimestamp
result.setOpenBmapTimestamp(position.getOpenBmapTimestamp());
result.setBeginPosition(position);
// so far we set end position = begin position
result.setEndPosition(position);
result.setIsServing(true);
result.setIsNeighbor(false);
// getNetworkOperator can be unreliable in CDMA networks, thus be careful
/reference/android/telephony/TelephonyManager.html#getNetworkOperator()}
final String operator = mTelephonyManager.getNetworkOperator();
if (operator.length() & 3) {
result.setOperator(operator);
result.setMcc(operator.substring(0, 3));
result.setMnc(operator.substring(3));
Log.i(TAG, &Couldn't determine network operator, this might happen in CDMA network&);
result.setMcc(&&);
result.setMnc(&&);
final String networkOperatorName = mTelephonyManager.getNetworkOperatorName();
if (networkOperatorName != null) {
result.setOperatorName(mTelephonyManager.getNetworkOperatorName());
Log.i(TAG, &Error retrieving network operator's name, this might happen in CDMA network&);
result.setOperatorName(&&);
// CDMA specific
result.setBaseId(String.valueOf(cdmaIdentity.getBasestationId()));
result.setNetworkId(String.valueOf(cdmaIdentity.getNetworkId()));
result.setSystemId(String.valueOf(cdmaIdentity.getSystemId()));
result.setStrengthdBm(((CellInfoCdma) cell).getCellSignalStrength().getCdmaDbm());
result.setStrengthAsu(((CellInfoCdma) cell).getCellSignalStrength().getAsuLevel());
} else if (cell instanceof CellInfoLte) {
final CellIdentityLte lteIdentity = ((CellInfoLte) cell).getCellIdentity();
if (isValidLteCell(lteIdentity)) {
Log.i(TAG, &Processing LTE cell & + lteIdentity.getCi());
final CellRecord result = new CellRecord(mSessionId);
result.setIsCdma(false);
// generic cell info
result.setNetworkType(mTelephonyManager.getNetworkType());
// TODO: unelegant: implicit conversion from UTC to YYYYMMDDHHMMSS in begin.setTimestamp
result.setOpenBmapTimestamp(position.getOpenBmapTimestamp());
result.setBeginPosition(position);
// so far we set end position = begin position
result.setEndPosition(position);
result.setIsServing(true);
result.setIsNeighbor(!cell.isRegistered());
result.setLogicalCellId(lteIdentity.getCi());
// set Actual Cid = Logical Cid (as we don't know better at the moment)
result.setActualCid(result.getLogicalCellId());
final String operator = mTelephonyManager.getNetworkOperator();
// getNetworkOperator() may return empty string, probably due to dropped connection
if (operator.length() & 3) {
result.setOperator(operator);
result.setMcc(operator.substring(0, 3));
result.setMnc(operator.substring(3));
Log.e(TAG, &Couldn't determine network operator, skipping cell&);
final String networkOperatorName = mTelephonyManager.getNetworkOperatorName();
if (networkOperatorName != null) {
result.setOperatorName(mTelephonyManager.getNetworkOperatorName());
Log.e(TAG, &Error retrieving network operator's name, skipping cell&);
// LTE specific
result.setArea(lteIdentity.getTac());
result.setPsc(lteIdentity.getPci());
result.setStrengthdBm(((CellInfoLte) cell).getCellSignalStrength().getDbm());
result.setStrengthAsu(((CellInfoLte) cell).getCellSignalStrength().getAsuLevel());
public static void loadCellInfo(TelephonyManager tm, Device pDevice) {
int lCurrentApiVersion = android.os.Build.VERSION.SDK_INT;
if(pDevice.mCell == null) {
pDevice.mCell = new Cell();
List&CellInfo& cellInfoList = tm.getAllCellInfo();
if (cellInfoList != null) {
for (final CellInfo info : cellInfoList) {
//Network Type
pDevice.mCell.setNetType(tm.getNetworkType());
if (info instanceof CellInfoGsm) {
final CellSignalStrengthGsm gsm = ((CellInfoGsm) info).getCellSignalStrength();
final CellIdentityGsm identityGsm = ((CellInfoGsm) info).getCellIdentity();
// Signal Strength
pDevice.mCell.setDBM(gsm.getDbm()); // [dBm]
// Cell Identity
pDevice.mCell.setCID(identityGsm.getCid());
pDevice.mCell.setMCC(identityGsm.getMcc());
pDevice.mCell.setMNC(identityGsm.getMnc());
pDevice.mCell.setLAC(identityGsm.getLac());
} else if (info instanceof CellInfoCdma) {
final CellSignalStrengthCdma cdma = ((CellInfoCdma) info).getCellSignalStrength();
final CellIdentityCdma identityCdma = ((CellInfoCdma) info).getCellIdentity();
// Signal Strength
pDevice.mCell.setDBM(cdma.getDbm());
// Cell Identity
pDevice.mCell.setCID(identityCdma.getBasestationId());
pDevice.mCell.setMNC(identityCdma.getSystemId());
pDevice.mCell.setLAC(identityCdma.getNetworkId());
pDevice.mCell.setSID(identityCdma.getSystemId());
} else if (info instanceof CellInfoLte) {
final CellSignalStrengthLte lte = ((CellInfoLte) info).getCellSignalStrength();
final CellIdentityLte identityLte = ((CellInfoLte) info).getCellIdentity();
// Signal Strength
pDevice.mCell.setDBM(lte.getDbm());
pDevice.mCell.setTimingAdvance(lte.getTimingAdvance());
// Cell Identity
pDevice.mCell.setMCC(identityLte.getMcc());
pDevice.mCell.setMNC(identityLte.getMnc());
pDevice.mCell.setCID(identityLte.getCi());
(lCurrentApiVersion &= Build.VERSION_CODES.JELLY_BEAN_MR2 && info instanceof CellInfoWcdma) {
final CellSignalStrengthWcdma wcdma = ((CellInfoWcdma) info).getCellSignalStrength();
final CellIdentityWcdma identityWcdma = ((CellInfoWcdma) info).getCellIdentity();
// Signal Strength
pDevice.mCell.setDBM(wcdma.getDbm());
// Cell Identity
pDevice.mCell.setLAC(identityWcdma.getLac());
pDevice.mCell.setMCC(identityWcdma.getMcc());
pDevice.mCell.setMNC(identityWcdma.getMnc());
pDevice.mCell.setCID(identityWcdma.getCid());
pDevice.mCell.setPSC(identityWcdma.getPsc());
Log.i(TAG, mTAG + &: Unknown type of cell signal!&
+ &\n ClassName: & + info.getClass().getSimpleName()
+ &\n ToString: & + info.toString());
if (pDevice.mCell.isValid())
} catch (NullPointerException npe) {
Log.e(TAG, mTAG + &: loadCellInfo: Unable to obtain cell signal information: &, npe);
Example 10
public static void loadCellInfo(TelephonyManager tm, Device pDevice) {
int lCurrentApiVersion = android.os.Build.VERSION.SDK_INT;
if(pDevice.mCell == null) {
pDevice.mCell = new Cell();
List&CellInfo& cellInfoList = tm.getAllCellInfo();
if (cellInfoList != null) {
for (final CellInfo info : cellInfoList) {
//Network Type
pDevice.mCell.setNetType(tm.getNetworkType());
if (info instanceof CellInfoGsm) {
final CellSignalStrengthGsm gsm = ((CellInfoGsm) info)
.getCellSignalStrength();
final CellIdentityGsm identityGsm = ((CellInfoGsm) info)
.getCellIdentity();
//Signal Strength
pDevice.mCell.setDBM(gsm.getDbm()); // [dBm]
//Cell Identity
pDevice.mCell.setCID(identityGsm.getCid());
pDevice.mCell.setMCC(identityGsm.getMcc());
pDevice.mCell.setMNC(identityGsm.getMnc());
pDevice.mCell.setLAC(identityGsm.getLac());
} else if (info instanceof CellInfoCdma) {
final CellSignalStrengthCdma cdma = ((CellInfoCdma) info)
.getCellSignalStrength();
final CellIdentityCdma identityCdma = ((CellInfoCdma) info)
.getCellIdentity();
//Signal Strength
pDevice.mCell.setDBM(cdma.getDbm());
//Cell Identity
pDevice.mCell.setCID(identityCdma.getBasestationId());
pDevice.mCell.setMNC(identityCdma.getSystemId());
pDevice.mCell.setLAC(identityCdma.getNetworkId());
pDevice.mCell.setSID(identityCdma.getSystemId());
} else if (info instanceof CellInfoLte) {
final CellSignalStrengthLte lte = ((CellInfoLte) info)
.getCellSignalStrength();
final CellIdentityLte identityLte = ((CellInfoLte) info)
.getCellIdentity();
//Signal Strength
pDevice.mCell.setDBM(lte.getDbm());
pDevice.mCell.setTimingAdvance(lte.getTimingAdvance());
//Cell Identity
pDevice.mCell.setMCC(identityLte.getMcc());
pDevice.mCell.setMNC(identityLte.getMnc());
pDevice.mCell.setCID(identityLte.getCi());
(lCurrentApiVersion &= Build.VERSION_CODES.JELLY_BEAN_MR2 &&
info instanceof CellInfoWcdma) {
final CellSignalStrengthWcdma wcdma = ((CellInfoWcdma) info)
.getCellSignalStrength();
final CellIdentityWcdma identityWcdma = ((CellInfoWcdma) info)
.getCellIdentity();
//Signal Strength
pDevice.mCell.setDBM(wcdma.getDbm());
//Cell Identity
pDevice.mCell.setLAC(identityWcdma.getLac());
pDevice.mCell.setMCC(identityWcdma.getMcc());
pDevice.mCell.setMNC(identityWcdma.getMnc());
pDevice.mCell.setCID(identityWcdma.getCid());
pDevice.mCell.setPSC(identityWcdma.getPsc());
Log.i(TAG, &Unknown type of cell signal! &
+ &ClassName: & + info.getClass().getSimpleName()
+ & ToString: & + info.toString());
if (pDevice.mCell.isValid())
} catch (NullPointerException npe) {
Log.e(TAG, &loadCellInfo: Unable to obtain cell signal information: &, npe);
Example 11
* @return the current cell location information. Prefer Gsm location
* information if available otherwise return LTE location information
public CellLocation getCellLocation() {
if ((mCellLoc.getLac() &= 0) && (mCellLoc.getCid() &= 0)) {
if (DBG) log(&getCellLocation(): X good mCellLoc=& + mCellLoc);
return mCellL
List&CellInfo& result = getAllCellInfo();
if (result != null) {
// A hack to allow tunneling of LTE information via GsmCellLocation
// so that older Network Location Providers can return some information
// on LTE only networks, see bug 9228974.
// We'll search the return CellInfo array preferring GSM/WCDMA
// data, but if there is none we'll tunnel the first LTE information
// in the list.
// The tunnel'd LTE information is returned as follows:
LAC = TAC field
CID = CI field
GsmCellLocation cellLocOther = new GsmCellLocation();
for (CellInfo ci : result) {
if (ci instanceof CellInfoGsm) {
CellInfoGsm cellInfoGsm = (CellInfoGsm)
CellIdentityGsm cellIdentityGsm = cellInfoGsm.getCellIdentity();
cellLocOther.setLacAndCid(cellIdentityGsm.getLac(),
cellIdentityGsm.getCid());
cellLocOther.setPsc(cellIdentityGsm.getPsc());
if (DBG) log(&getCellLocation(): X ret GSM info=& + cellLocOther);
return cellLocO
} else if (ci instanceof CellInfoWcdma) {
CellInfoWcdma cellInfoWcdma = (CellInfoWcdma)
CellIdentityWcdma cellIdentityWcdma = cellInfoWcdma.getCellIdentity();
cellLocOther.setLacAndCid(cellIdentityWcdma.getLac(),
cellIdentityWcdma.getCid());
cellLocOther.setPsc(cellIdentityWcdma.getPsc());
if (DBG) log(&getCellLocation(): X ret WCDMA info=& + cellLocOther);
return cellLocO
} else if ((ci instanceof CellInfoLte) &&
((cellLocOther.getLac() & 0) || (cellLocOther.getCid() & 0))) {
// We'll return the first good LTE info we get if there is no better answer
CellInfoLte cellInfoLte = (CellInfoLte)
CellIdentityLte cellIdentityLte = cellInfoLte.getCellIdentity();
if ((cellIdentityLte.getTac() != Integer.MAX_VALUE)
&& (cellIdentityLte.getCi() != Integer.MAX_VALUE)) {
cellLocOther.setLacAndCid(cellIdentityLte.getTac(),
cellIdentityLte.getCi());
cellLocOther.setPsc(0);
if (DBG) {
log(&getCellLocation(): possible LTE cellLocOther=& + cellLocOther);
if (DBG) {
log(&getCellLocation(): X ret best answer cellLocOther=& + cellLocOther);
return cellLocO
if (DBG) {
log(&getCellLocation(): X empty mCellLoc and CellInfo mCellLoc=& + mCellLoc);
return mCellL
Example 12
protected void pollStateDone() {
updateRoamingState();
if (Build.IS_DEBUGGABLE && SystemProperties.getBoolean(PROP_FORCE_ROAMING, false)) {
mNewSS.setVoiceRoaming(true);
mNewSS.setDataRoaming(true);
useDataRegStateForDataOnlyDevices();
resetServiceStateInIwlanMode();
log(&pollStateDone: lte 1 ss=[& + mSS + &] newSS=[& + mNewSS + &]&);
boolean hasRegistered = mSS.getVoiceRegState() != ServiceState.STATE_IN_SERVICE
&& mNewSS.getVoiceRegState() == ServiceState.STATE_IN_SERVICE;
boolean hasDeregistered = mSS.getVoiceRegState() == ServiceState.STATE_IN_SERVICE
&& mNewSS.getVoiceRegState() != ServiceState.STATE_IN_SERVICE;
boolean hasCdmaDataConnectionAttached =
mSS.getDataRegState() != ServiceState.STATE_IN_SERVICE
&& mNewSS.getDataRegState() == ServiceState.STATE_IN_SERVICE;
boolean hasCdmaDataConnectionDetached =
mSS.getDataRegState() == ServiceState.STATE_IN_SERVICE
&& mNewSS.getDataRegState() != ServiceState.STATE_IN_SERVICE;
boolean hasCdmaDataConnectionChanged =
mSS.getDataRegState() != mNewSS.getDataRegState();
boolean hasVoiceRadioTechnologyChanged = mSS.getRilVoiceRadioTechnology()
!= mNewSS.getRilVoiceRadioTechnology();
boolean hasDataRadioTechnologyChanged = mSS.getRilDataRadioTechnology()
!= mNewSS.getRilDataRadioTechnology();
boolean hasChanged = !mNewSS.equals(mSS);
boolean hasVoiceRoamingOn = !mSS.getVoiceRoaming() && mNewSS.getVoiceRoaming();
boolean hasVoiceRoamingOff = mSS.getVoiceRoaming() && !mNewSS.getVoiceRoaming();
boolean hasDataRoamingOn = !mSS.getDataRoaming() && mNewSS.getDataRoaming();
boolean hasDataRoamingOff = mSS.getDataRoaming() && !mNewSS.getDataRoaming();
boolean hasLocationChanged = !mNewCellLoc.equals(mCellLoc);
boolean has4gHandoff =
mNewSS.getDataRegState() == ServiceState.STATE_IN_SERVICE &&
(((mSS.getRilDataRadioTechnology() == ServiceState.RIL_RADIO_TECHNOLOGY_LTE) &&
(mNewSS.getRilDataRadioTechnology() == ServiceState.RIL_RADIO_TECHNOLOGY_EHRPD)) ||
((mSS.getRilDataRadioTechnology() == ServiceState.RIL_RADIO_TECHNOLOGY_EHRPD) &&
(mNewSS.getRilDataRadioTechnology() == ServiceState.RIL_RADIO_TECHNOLOGY_LTE)));
boolean hasMultiApnSupport =
(((mNewSS.getRilDataRadioTechnology() == ServiceState.RIL_RADIO_TECHNOLOGY_LTE) ||
(mNewSS.getRilDataRadioTechnology() == ServiceState.RIL_RADIO_TECHNOLOGY_EHRPD)) &&
((mSS.getRilDataRadioTechnology() != ServiceState.RIL_RADIO_TECHNOLOGY_LTE) &&
(mSS.getRilDataRadioTechnology() != ServiceState.RIL_RADIO_TECHNOLOGY_EHRPD)));
boolean hasLostMultiApnSupport =
((mNewSS.getRilDataRadioTechnology() &= ServiceState.RIL_RADIO_TECHNOLOGY_IS95A) &&
(mNewSS.getRilDataRadioTechnology() &= ServiceState.RIL_RADIO_TECHNOLOGY_EVDO_A));
TelephonyManager tm =
(TelephonyManager) mPhone.getContext().getSystemService(Context.TELEPHONY_SERVICE);
if (DBG) {
log(&pollStateDone:&
+ & hasRegistered=& + hasRegistered
+ & hasDeegistered=& + hasDeregistered
+ & hasCdmaDataConnectionAttached=& + hasCdmaDataConnectionAttached
+ & hasCdmaDataConnectionDetached=& + hasCdmaDataConnectionDetached
+ & hasCdmaDataConnectionChanged=& + hasCdmaDataConnectionChanged
+ & hasVoiceRadioTechnologyChanged= & + hasVoiceRadioTechnologyChanged
+ & hasDataRadioTechnologyChanged=& + hasDataRadioTechnologyChanged
+ & hasChanged=& + hasChanged
+ & hasVoiceRoamingOn=& + hasVoiceRoamingOn
+ & hasVoiceRoamingOff=& + hasVoiceRoamingOff
+ & hasDataRoamingOn=& + hasDataRoamingOn
+ & hasDataRoamingOff=& + hasDataRoamingOff
+ & hasLocationChanged=& + hasLocationChanged
+ & has4gHandoff = & + has4gHandoff
+ & hasMultiApnSupport=& + hasMultiApnSupport
+ & hasLostMultiApnSupport=& + hasLostMultiApnSupport);
// Add an event log when connection state changes
if (mSS.getVoiceRegState() != mNewSS.getVoiceRegState()
|| mSS.getDataRegState() != mNewSS.getDataRegState()) {
EventLog.writeEvent(EventLogTags.CDMA_SERVICE_STATE_CHANGE, mSS.getVoiceRegState(),
mSS.getDataRegState(), mNewSS.getVoiceRegState(), mNewSS.getDataRegState());
tss = mSS;
mSS = mNewSS;
// clean slate for next time
mNewSS.setStateOutOfService();
CdmaCellLocation tcl = mCellL
mCellLoc = mNewCellL
mNewCellLoc =
mNewSS.setStateOutOfService(); // clean slate for next time
if (hasVoiceRadioTechnologyChanged) {
updatePhoneObject();
if (hasDataRadioTechnologyChanged) {
tm.setDataNetworkTypeForPhone(mPhone.getPhoneId(), mSS.getRilDataRadioTechnology());
if (ServiceState.RIL_RADIO_TECHNOLOGY_IWLAN
== mSS.getRilDataRadioTechnology()) {
log(&pollStateDone: IWLAN enabled&);
if (hasRegistered) {
mNetworkAttachedRegistrants.notifyRegistrants();
if (hasChanged) {
boolean hasBrandOverride = mUiccController.getUiccCard(getPhoneId()) == null ? false :
(mUiccController.getUiccCard(getPhoneId()).getOperatorBrandOverride() != null);
if (!hasBrandOverride && (mCi.getRadioState().isOn()) && (mPhone.isEriFileLoaded()) &&
(mSS.getRilVoiceRadioTechnology() != ServiceState.RIL_RADIO_TECHNOLOGY_LTE ||
mPhone.getContext().getResources().getBoolean(com.android.internal.R.
bool.config_LTE_eri_for_network_name))) {
// Only when CDMA is in service, ERI will take effect
String eriText = mSS.getOperatorAlphaLong();
// Now the CDMAPhone sees the new ServiceState so it can get the
// new ERI text
if (mSS.getVoiceRegState() == ServiceState.STATE_IN_SERVICE) {
eriText = mPhone.getCdmaEriText();
} else if (mSS.getVoiceRegState() == ServiceState.STATE_POWER_OFF) {
eriText = (mIccRecords != null) ? mIccRecords.getServiceProviderName() :
if (TextUtils.isEmpty(eriText)) {
// Sets operator alpha property by retrieving from
// build-time system property
eriText = SystemProperties.get(&ro.cdma.home.operator.alpha&);
} else if (mSS.getDataRegState() != ServiceState.STATE_IN_SERVICE) {
// Note that ServiceState.STATE_OUT_OF_SERVICE is valid used
// for mRegistrationState 0,2,3 and 4
eriText = mPhone.getContext()
.getText(com.android.internal.R.string.roamingTextSearching).toString();
mSS.setOperatorAlphaLong(eriText);
if (mUiccApplcation != null && mUiccApplcation.getState() == AppState.APPSTATE_READY &&
mIccRecords != null && (mSS.getVoiceRegState() == ServiceState.STATE_IN_SERVICE)
&& mSS.getRilVoiceRadioTechnology() != ServiceState.RIL_RADIO_TECHNOLOGY_LTE) {
// SIM is found on the device. If ERI roaming is OFF, and SID/NID matches
// one configured in SIM, use operator name from CSIM record. Note that ERI, SID,
// and NID are CDMA only, not applicable to LTE.
boolean showSpn =
((RuimRecords)mIccRecords).getCsimSpnDisplayCondition();
int iconIndex = mSS.getCdmaEriIconIndex();
if (showSpn && (iconIndex == EriInfo.ROAMING_INDICATOR_OFF) &&
isInHomeSidNid(mSS.getSystemId(), mSS.getNetworkId()) &&
mIccRecords != null) {
mSS.setOperatorAlphaLong(mIccRecords.getServiceProviderName());
String operatorN
tm.setNetworkOperatorNameForPhone(mPhone.getPhoneId(), mSS.getOperatorAlphaLong());
String prevOperatorNumeric = tm.getNetworkOperatorForPhone(mPhone.getPhoneId());
operatorNumeric = mSS.getOperatorNumeric();
// try to fix the invalid Operator Numeric
if (isInvalidOperatorNumeric(operatorNumeric)) {
int sid = mSS.getSystemId();
operatorNumeric = fixUnknownMcc(operatorNumeric, sid);
tm.setNetworkOperatorNumericForPhone(mPhone.getPhoneId(), operatorNumeric);
updateCarrierMccMncConfiguration(operatorNumeric,
prevOperatorNumeric, mPhone.getContext());
if (isInvalidOperatorNumeric(operatorNumeric)) {
if (DBG) log(&operatorNumeric is null&);
tm.setNetworkCountryIsoForPhone(mPhone.getPhoneId(), &&);
mGotCountryCode =
String isoCountryCode = &&;
String mcc = operatorNumeric.substring(0, 3);
isoCountryCode = MccTable.countryCodeForMcc(Integer.parseInt(operatorNumeric
.substring(0, 3)));
} catch (NumberFormatException ex) {
loge(&countryCodeForMcc error& + ex);
} catch (StringIndexOutOfBoundsException ex) {
loge(&countryCodeForMcc error& + ex);
tm.setNetworkCountryIsoForPhone(mPhone.getPhoneId(), isoCountryCode);
mGotCountryCode =
setOperatorIdd(operatorNumeric);
if (shouldFixTimeZoneNow(mPhone, operatorNumeric, prevOperatorNumeric,
mNeedFixZone)) {
fixTimeZone(isoCountryCode);
tm.setNetworkRoamingForPhone(mPhone.getPhoneId(),
(mSS.getVoiceRoaming() || mSS.getDataRoaming()));
updateSpnDisplay();
setRoamingType(mSS);
log(&Broadcasting ServiceState : & + mSS);
mPhone.notifyServiceStateChanged(mSS);
if (hasCdmaDataConnectionAttached || has4gHandoff) {
mAttachedRegistrants.notifyRegistrants();
if (hasCdmaDataConnectionDetached) {
mDetachedRegistrants.notifyRegistrants();
if ((hasCdmaDataConnectionChanged || hasDataRadioTechnologyChanged)) {
notifyDataRegStateRilRadioTechnologyChanged();
if (ServiceState.RIL_RADIO_TECHNOLOGY_IWLAN
== mSS.getRilDataRadioTechnology()) {
mPhone.notifyDataConnection(Phone.REASON_IWLAN_AVAILABLE);
mPhone.notifyDataConnection(null);
if (hasVoiceRoamingOn) {
mVoiceRoamingOnRegistrants.notifyRegistrants();
if (hasVoiceRoamingOff) {
mVoiceRoamingOffRegistrants.notifyRegistrants();
if (hasDataRoamingOn) {
mDataRoamingOnRegistrants.notifyRegistrants();
if (hasDataRoamingOff) {
mDataRoamingOffRegistrants.notifyRegistrants();
if (hasLocationChanged) {
mPhone.notifyLocationChanged();
ArrayList&CellInfo& arrayCi = new ArrayList&CellInfo&();
synchronized(mCellInfo) {
CellInfoLte cil = (CellInfoLte)mCellI
boolean cidChanged = ! mNewCellIdentityLte.equals(mLasteCellIdentityLte);
if (hasRegistered || hasDeregistered || cidChanged) {
// TODO: Handle the absence of LteCellIdentity
long timeStamp = SystemClock.elapsedRealtime() * 1000;
boolean registered = mSS.getVoiceRegState() == ServiceState.STATE_IN_SERVICE;
mLasteCellIdentityLte = mNewCellIdentityL
cil.setRegistered(registered);
cil.setCellIdentity(mLasteCellIdentityLte);
if (DBG) {
log(&pollStateDone: hasRegistered=& + hasRegistered +
& hasDeregistered=& + hasDeregistered +
& cidChanged=& + cidChanged +
& mCellInfo=& + mCellInfo);
arrayCi.add(mCellInfo);
mPhoneBase.notifyCellInfo(arrayCi);
Example 13
* @param responseReceived - whether or not we received a valid HTTP response to our request.
* If false, isCaptivePortal and responseTimestampMs are ignored
* TODO: This should be moved to the transports.
The latency could be passed to the transports
* along with the captive portal result.
Currently the TYPE_MOBILE broadcasts appear unused so
* perhaps this could just be added to the WiFi transport only.
private void sendNetworkConditionsBroadcast(boolean responseReceived, boolean isCaptivePortal,
long requestTimestampMs, long responseTimestampMs) {
if (Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.WIFI_SCAN_ALWAYS_AVAILABLE, 0) == 0) {
if (systemReady == false)
Intent latencyBroadcast = new Intent(ACTION_NETWORK_CONDITIONS_MEASURED);
switch (mNetworkAgentInfo.networkInfo.getType()) {
case ConnectivityManager.TYPE_WIFI:
WifiInfo currentWifiInfo = mWifiManager.getConnectionInfo();
if (currentWifiInfo != null) {
// NOTE: getSSID()'s behavior changed in API 17; before that, SSIDs were not
// surrounded by double quotation marks (thus violating the Javadoc), but this
// was changed to match the Javadoc in API 17. Since clients may have started
// sanitizing the output of this method since API 17 was released, we should
// not change it here as it would become impossible to tell whether the SSID is
// simply being surrounded by quotes due to the API, or whether those quotes
// are actually part of the SSID.
latencyBroadcast.putExtra(EXTRA_SSID, currentWifiInfo.getSSID());
latencyBroadcast.putExtra(EXTRA_BSSID, currentWifiInfo.getBSSID());
if (DBG) logw(&network info is TYPE_WIFI but no ConnectionInfo found&);
case ConnectivityManager.TYPE_MOBILE:
latencyBroadcast.putExtra(EXTRA_NETWORK_TYPE, mTelephonyManager.getNetworkType());
List&CellInfo& info = mTelephonyManager.getAllCellInfo();
if (info == null)
int numRegisteredCellInfo = 0;
for (CellInfo cellInfo : info) {
if (cellInfo.isRegistered()) {
numRegisteredCellInfo++;
if (numRegisteredCellInfo & 1) {
log(&more than one registered CellInfo.
&tell which is active.
Bailing.&);
if (cellInfo instanceof CellInfoCdma) {
CellIdentityCdma cellId = ((CellInfoCdma) cellInfo).getCellIdentity();
latencyBroadcast.putExtra(EXTRA_CELL_ID, cellId);
} else if (cellInfo instanceof CellInfoGsm) {
CellIdentityGsm cellId = ((CellInfoGsm) cellInfo).getCellIdentity();
latencyBroadcast.putExtra(EXTRA_CELL_ID, cellId);
} else if (cellInfo instanceof CellInfoLte) {
CellIdentityLte cellId = ((CellInfoLte) cellInfo).getCellIdentity();
latencyBroadcast.putExtra(EXTRA_CELL_ID, cellId);
} else if (cellInfo instanceof CellInfoWcdma) {
CellIdentityWcdma cellId = ((CellInfoWcdma) cellInfo).getCellIdentity();
latencyBroadcast.putExtra(EXTRA_CELL_ID, cellId);
if (DBG) logw(&Registered cellinfo is unrecognized&);
latencyBroadcast.putExtra(EXTRA_CONNECTIVITY_TYPE, mNetworkAgentInfo.networkInfo.getType());
latencyBroadcast.putExtra(EXTRA_RESPONSE_RECEIVED, responseReceived);
latencyBroadcast.putExtra(EXTRA_REQUEST_TIMESTAMP_MS, requestTimestampMs);
if (responseReceived) {
latencyBroadcast.putExtra(EXTRA_IS_CAPTIVE_PORTAL, isCaptivePortal);
latencyBroadcast.putExtra(EXTRA_RESPONSE_TIMESTAMP_MS, responseTimestampMs);
mContext.sendBroadcastAsUser(latencyBroadcast, UserHandle.CURRENT,
PERMISSION_ACCESS_NETWORK_CONDITIONS);
Example 14
public static ConnectionData gatherConnectionData(Context context) {
Bundle data = new Bundle();
// Wifi data
WifiManager wm = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
String ssid = wm.getConnectionInfo().getSSID();
String bssid = wm.getConnectionInfo().getBSSID();
int frequency = - 1;
if(android.os.Build.VERSION.SDK_INT &= Build.VERSION_CODES.LOLLIPOP)
frequency = wm.getConnectionInfo().getFrequency();
String wifiIP = Formatter.formatIpAddress(wm.getConnectionInfo().getIpAddress());
int rssi = wm.getConnectionInfo().getRssi();
boolean rssiFromScanResult =
int speed = wm.getConnectionInfo().getLinkSpeed();
// A little work-around.
// Problem: After the phone connects to a wifi network while the screen is turned off,
// the ConnectionInfo will report speed==-1 and rssi==-127 until the screen is turned on
// once (Nexus 5 with 5.0.1)
// Work-around: If this bug happens we get the rssi from the last scan results:
if(speed & 0 && ssid != null && ssid.length() & 0) {
List&ScanResult& scanResultList = wm.getScanResults();
if(scanResultList != null) {
for(ScanResult result: scanResultList) {
if(result.BSSID.equals(bssid)) {
rssi = result.
Log.d(LOGTAG, &gatherConnectionData: SSID is set but Linkspeed is -1 and ScanResult Level is:&
+ result.level);
rssiFromScanResult =
if(!rssiFromScanResult)
Log.d(LOGTAG, &gatherConnectionData: SSID is set but Linkspeed is -1 and ScanResults don't contain BSSID (&
+ wm.getConnectionInfo().getBSSID() + &)!&);
Log.d(LOGTAG, &gatherConnectionData: SSID is set but Linkspeed is -1 and ScanResults are null!&);
data.putString(WIFI_BSSID, bssid);
data.putString(WIFI_SSID, ssid);
data.putInt(WIFI_RSSI, rssi);
data.putInt(WIFI_FREQUENCY, frequency);
data.putString(WIFI_IP, wifiIP);
data.putBoolean(WIFI_RSSI_FROM_SCAN_RESULT, rssiFromScanResult);
data.putInt(WIFI_SPEED, speed);
// Cellular data
TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
data.putString(CELLULAR_NETWORK_OPERATOR, tm.getNetworkOperatorName());
data.putInt(CELLULAR_NETWORK_TYPE, tm.getNetworkType());
// Get the signal strength by looking at the first connected cell (if it exists):
int dbm = Integer.MIN_VALUE;
int asuLevel = Integer.MIN_VALUE;
int mcc = -1;
int mnc = -1;
int lac = -1;
int cid = -1;
if(tm.getAllCellInfo() != null && !tm.getAllCellInfo().isEmpty()) {
CellInfo cellInfo = tm.getAllCellInfo().get(0);
if (cellInfo instanceof CellInfoGsm) {
CellInfoGsm cellInfoDetail = (CellInfoGsm) cellI
dbm = cellInfoDetail.getCellSignalStrength().getDbm();
asuLevel = cellInfoDetail.getCellSignalStrength().getAsuLevel();
mcc = cellInfoDetail.getCellIdentity().getMcc();
mnc = cellInfoDetail.getCellIdentity().getMnc();
lac = cellInfoDetail.getCellIdentity().getLac();
cid = cellInfoDetail.getCellIdentity().getCid();
} else if (cellInfo instanceof CellInfoCdma) {
CellInfoCdma cellInfoDetail = (CellInfoCdma) cellI
dbm = cellInfoDetail.getCellSignalStrength().getDbm();
asuLevel = cellInfoDetail.getCellSignalStrength().getAsuLevel();
} else if (cellInfo instanceof CellInfoLte) {
CellInfoLte cellInfoDetail = (CellInfoLte) cellI
dbm = cellInfoDetail.getCellSignalStrength().getDbm();
asuLevel = cellInfoDetail.getCellSignalStrength().getAsuLevel();
mcc = cellInfoDetail.getCellIdentity().getMcc();
mnc = cellInfoDetail.getCellIdentity().getMnc();
} else if (cellInfo instanceof CellInfoWcdma) {
CellInfoWcdma cellInfoDetail = (CellInfoWcdma) cellI
dbm = cellInfoDetail.getCellSignalStrength().getDbm();
asuLevel = cellInfoDetail.getCellSignalStrength().getAsuLevel();
mcc = cellInfoDetail.getCellIdentity().getMcc();
mnc = cellInfoDetail.getCellIdentity().getMnc();
lac = cellInfoDetail.getCellIdentity().getLac();
cid = cellInfoDetail.getCellIdentity().getCid();
data.putInt(CELLULAR_DBM, dbm);
data.putInt(CELLULAR_ASU_LEVEL, asuLevel);
data.putInt(CELLULAR_MCC, mcc);
data.putInt(CELLULAR_MNC, mnc);
data.putInt(CELLULAR_LAC, lac);
data.putInt(CELLULAR_CID, cid);
// Basic connectivity data:
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo networkInfo = cm.getActiveNetworkInfo();
int state = STATE_INVALID;
if(networkInfo != null && networkInfo.getType() == ConnectivityManager.TYPE_WIFI
&& networkInfo.isAvailable() && networkInfo.isConnected()) {
state = STATE_WIFI;
} else if(networkInfo != null && networkInfo.getType() == ConnectivityManager.TYPE_MOBILE
&& networkInfo.isAvailable() && networkInfo.isConnected() && asuLevel &= 0
&& tm.getNetworkOperatorName().length() & 0 && tm.getNetworkType() != 0) {
state = STATE_MOBILE;
state = STATE_OFFLINE;
data.putInt(STATE, state);
// also add a timestamp:
data.putLong(TIMESTAMP, System.currentTimeMillis());
return new ConnectionData(context, data);
Example 15
public String getNetworkInformation() {
TelephonyManager tm = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);
ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
WifiManager wm = (WifiManager) getSystemService(Context.WIFI_SERVICE);
StringBuilder stringBuilder = new StringBuilder();
NetworkInfo[] networkInfos = cm.getAllNetworkInfo();
for(int i = 0; i & 2; i++) {
printNetworkInfo(networkInfos[i], stringBuilder);
stringBuilder.append(&\n&);
stringBuilder.append(&Network Operator: & + tm.getNetworkOperator() + &\n&);
stringBuilder.append(&Network Operator Name: & + tm.getNetworkOperatorName() + &\n&);
stringBuilder.append(&Sim Operator Name: & + tm.getSimOperatorName() + &\n&);
stringBuilder.append(&Phone Type: & + tm.getPhoneType() + &\n&);
stringBuilder.append(&Cell State: & + tm.getCallState() + &\n&);
stringBuilder.append(&Network Type: & + tm.getNetworkType() + &\n&);
stringBuilder.append(&Data State: & + tm.getDataState() + &\n&);
CellInfo cellInfo =
if(tm.getAllCellInfo() != null && !tm.getAllCellInfo().isEmpty()) {
cellInfo = tm.getAllCellInfo().get(0);
stringBuilder.append(&Cell toString: & + cellInfo.toString() + &\n&);
int dbm = Integer.MIN_VALUE;
int level = Integer.MIN_VALUE;
int asuLevel = Integer.MIN_VALUE;
if(cellInfo instanceof CellInfoGsm) {
CellInfoGsm cellInfoDetail = (CellInfoGsm) cellI
stringBuilder.append(&Cell is GSM!&);
dbm = cellInfoDetail.getCellSignalStrength().getDbm();
level = cellInfoDetail.getCellSignalStrength().getLevel();
asuLevel = cellInfoDetail.getCellSignalStrength().getAsuLevel();
if(cellInfo instanceof CellInfoCdma) {
CellInfoCdma cellInfoDetail = (CellInfoCdma) cellI
stringBuilder.append(&Cell is CDMA!&);
dbm = cellInfoDetail.getCellSignalStrength().getDbm();
level = cellInfoDetail.getCellSignalStrength().getLevel();
asuLevel = cellInfoDetail.getCellSignalStrength().getAsuLevel();
if(cellInfo instanceof CellInfoLte) {
CellInfoLte cellInfoDetail = (CellInfoLte) cellI
stringBuilder.append(&Cell is LTE!&);
dbm = cellInfoDetail.getCellSignalStrength().getDbm();
level = cellInfoDetail.getCellSignalStrength().getLevel();
asuLevel = cellInfoDetail.getCellSignalStrength().getAsuLevel();
if(cellInfo instanceof CellInfoWcdma) {
CellInfoWcdma cellInfoDetail = (CellInfoWcdma) cellI
stringBuilder.append(&Cell is WCDMA!&);
dbm = cellInfoDetail.getCellSignalStrength().getDbm();
level = cellInfoDetail.getCellSignalStrength().getLevel();
asuLevel = cellInfoDetail.getCellSignalStrength().getAsuLevel();
stringBuilder.append(&dBm: & + dbm + &\n&);
stringBuilder.append(&Level: & + level + &\n&);
stringBuilder.append(&ASU Level: & + asuLevel + &\n&);
stringBuilder.append(&\n&);
//print(&Frequency: & + wm.getConnectionInfo().getFrequency());
stringBuilder.append(&Rssi: & + wm.getConnectionInfo().getRssi() + &\n&);
stringBuilder.append(&ToString: & + wm.getConnectionInfo().toString() + &\n&);
return stringBuilder.toString();
Example 16
private List&Cell& getCells() {
List&Cell& cells = new ArrayList&Cell&();
List&CellInfo& cellsRawList = mTelephonyManager.getAllCellInfo();
if (cellsRawList != null) {
Log.d(TAG, &Found & + cellsRawList.size() + & cells&);
Log.d(TAG, &No cell available (getAllCellInfo returned null)&);
String operator = mTelephonyManager.getNetworkOperator();
// getNetworkOperator() may return empty string, probably due to dropped connection
if (operator != null && operator.length() & 3) {
mcc = Integer.valueOf(operator.substring(0, 3));
mnc = Integer.valueOf(operator.substring(3));
Log.e(TAG, &Error retrieving network operator, skipping cell&);
if (cellsRawList != null) {
for (CellInfo c : cellsRawList) {
Cell cell = new Cell();
if (c instanceof CellInfoGsm) {
Log.v(TAG, &GSM cell found&);
cell.cellId = ((CellInfoGsm) c).getCellIdentity().getCid();
cell.area = ((CellInfoGsm) c).getCellIdentity().getLac();
//cell.mcc = ((CellInfoGsm)c).getCellIdentity().getMcc();
//cell.mnc = ((CellInfoGsm)c).getCellIdentity().getMnc();
cell.mcc =
cell.mnc =
cell.technology = TECHNOLOGY_MAP().get(mTelephonyManager.getNetworkType());
} else if (c instanceof CellInfoCdma) {
object.put(&cellId&, ((CellInfoCdma)s).getCellIdentity().getBasestationId());
object.put(&locationAreaCode&, ((CellInfoCdma)s).getCellIdentity().getLac());
object.put(&mobileCountryCode&, ((CellInfoCdma)s).getCellIdentity().get());
object.put(&mobileNetworkCode&, ((CellInfoCdma)s).getCellIdentity().getMnc());*/
Log.wtf(TAG, &Using of CDMA cells for NLP not yet implemented&);
} else if (c instanceof CellInfoLte) {
Log.v(TAG, &LTE cell found&);
cell.cellId = ((CellInfoLte) c).getCellIdentity().getCi();
cell.area = ((CellInfoLte) c).getCellIdentity().getTac();
//cell.mcc = ((CellInfoLte)c).getCellIdentity().getMcc();
//cell.mnc = ((CellInfoLte)c).getCellIdentity().getMnc();
cell.mcc =
cell.mnc =
cell.technology = TECHNOLOGY_MAP().get(mTelephonyManager.getNetworkType());
} else if (c instanceof CellInfoWcdma) {
Log.v(TAG, &CellInfoWcdma cell found&);
cell.cellId = ((CellInfoWcdma) c).getCellIdentity().getCid();
cell.area = ((CellInfoWcdma) c).getCellIdentity().getLac();
//cell.mcc = ((CellInfoWcdma)c).getCellIdentity().getMcc();
//cell.mnc = ((CellInfoWcdma)c).getCellIdentity().getMnc();
cell.mcc =
cell.mnc =
cell.technology = TECHNOLOGY_MAP().get(mTelephonyManager.getNetworkType());
cells.add(cell);

我要回帖

更多关于 艾丽卡 电影天堂 的文章

 

随机推荐