Search in sources :

Example 11 with CellIdentityLte

use of android.telephony.CellIdentityLte in project android_frameworks_base by AOSPA.

the class NetworkMonitor method sendNetworkConditionsBroadcast.

/**
     * @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) {
        return;
    }
    if (systemReady == false)
        return;
    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());
            } else {
                if (VDBG)
                    logw("network info is TYPE_WIFI but no ConnectionInfo found");
                return;
            }
            break;
        case ConnectivityManager.TYPE_MOBILE:
            latencyBroadcast.putExtra(EXTRA_NETWORK_TYPE, mTelephonyManager.getNetworkType());
            List<CellInfo> info = mTelephonyManager.getAllCellInfo();
            if (info == null)
                return;
            int numRegisteredCellInfo = 0;
            for (CellInfo cellInfo : info) {
                if (cellInfo.isRegistered()) {
                    numRegisteredCellInfo++;
                    if (numRegisteredCellInfo > 1) {
                        if (VDBG)
                            logw("more than one registered CellInfo." + " Can't tell which is active.  Bailing.");
                        return;
                    }
                    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);
                    } else {
                        if (VDBG)
                            logw("Registered cellinfo is unrecognized");
                        return;
                    }
                }
            }
            break;
        default:
            return;
    }
    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);
}
Also used : CellInfoCdma(android.telephony.CellInfoCdma) CellInfoWcdma(android.telephony.CellInfoWcdma) CellIdentityGsm(android.telephony.CellIdentityGsm) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) WifiInfo(android.net.wifi.WifiInfo) CellInfoGsm(android.telephony.CellInfoGsm) CellInfoLte(android.telephony.CellInfoLte) CellIdentityCdma(android.telephony.CellIdentityCdma) CellInfo(android.telephony.CellInfo) CellIdentityLte(android.telephony.CellIdentityLte) CellIdentityWcdma(android.telephony.CellIdentityWcdma)

Example 12 with CellIdentityLte

use of android.telephony.CellIdentityLte in project PhoneProfilesPlus by henrichg.

the class PhoneStateScanner method getAllCellInfo.

/*
    void resetListening(boolean oldPowerSaveMode, boolean forceReset) {
        if ((forceReset) || (PPApplication.isPowerSaveMode != oldPowerSaveMode)) {
            disconnect();
            connect();
        }
    }
    */
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
private void getAllCellInfo(List<CellInfo> cellInfo) {
    if (cellInfo != null) {
        if (Permissions.checkLocation(context.getApplicationContext())) {
            for (CellInfo _cellInfo : cellInfo) {
                if (_cellInfo instanceof CellInfoGsm) {
                    // PPApplication.logE("PhoneStateScanner.getAllCellInfo", "gsm info="+_cellInfo);
                    CellIdentityGsm identityGsm = ((CellInfoGsm) _cellInfo).getCellIdentity();
                    if (identityGsm.getCid() != Integer.MAX_VALUE) {
                        // PPApplication.logE("PhoneStateScanner.getAllCellInfo", "gsm mCid="+identityGsm.getCid());
                        if (_cellInfo.isRegistered()) {
                            registeredCell = identityGsm.getCid();
                            lastConnectedTime = Calendar.getInstance().getTimeInMillis();
                        }
                    }
                } else if (_cellInfo instanceof CellInfoLte) {
                    // PPApplication.logE("PhoneStateScanner.getAllCellInfo", "lte info="+_cellInfo);
                    CellIdentityLte identityLte = ((CellInfoLte) _cellInfo).getCellIdentity();
                    if (identityLte.getCi() != Integer.MAX_VALUE) {
                        // PPApplication.logE("PhoneStateScanner.getAllCellInfo", "lte mCi="+identityLte.getCi());
                        if (_cellInfo.isRegistered()) {
                            registeredCell = identityLte.getCi();
                            lastConnectedTime = Calendar.getInstance().getTimeInMillis();
                        }
                    }
                } else if (_cellInfo instanceof CellInfoWcdma) {
                    // PPApplication.logE("PhoneStateScanner.getAllCellInfo", "wcdma info="+_cellInfo);
                    // if (android.os.Build.VERSION.SDK_INT >= 18) {
                    CellIdentityWcdma identityWcdma = ((CellInfoWcdma) _cellInfo).getCellIdentity();
                    if (identityWcdma.getCid() != Integer.MAX_VALUE) {
                        // PPApplication.logE("PhoneStateScanner.getAllCellInfo", "wcdma mCid=" + identityWcdma.getCid());
                        if (_cellInfo.isRegistered()) {
                            registeredCell = identityWcdma.getCid();
                            lastConnectedTime = Calendar.getInstance().getTimeInMillis();
                        }
                    }
                // }
                // else {
                // PPApplication.logE("PhoneStateScanner.getAllCellInfo", "wcdma mCid=not supported for API level < 18");
                // }
                } else if (_cellInfo instanceof CellInfoCdma) {
                    // PPApplication.logE("PhoneStateScanner.getAllCellInfo", "cdma info="+_cellInfo);
                    CellIdentityCdma identityCdma = ((CellInfoCdma) _cellInfo).getCellIdentity();
                    if (identityCdma.getBasestationId() != Integer.MAX_VALUE) {
                        // PPApplication.logE("PhoneStateScanner.getAllCellInfo", "wcdma mCid="+identityCdma.getBasestationId());
                        if (_cellInfo.isRegistered()) {
                            registeredCell = identityCdma.getBasestationId();
                            lastConnectedTime = Calendar.getInstance().getTimeInMillis();
                        }
                    }
                }
            // else {
            // PPApplication.logE("PhoneStateScanner.getAllCellInfo", "unknown info="+_cellInfo);
            // }
            }
            // PPApplication.logE("PhoneStateScanner.getAllCellInfo", "---- end ----------------------------");
            PPApplication.logE("PhoneStateScanner.getAllCellInfo", "registeredCell=" + registeredCell);
        }
    } else
        PPApplication.logE("PhoneStateScanner.getAllCellInfo", "cell info is null");
}
Also used : CellInfoLte(android.telephony.CellInfoLte) CellIdentityCdma(android.telephony.CellIdentityCdma) CellInfo(android.telephony.CellInfo) CellInfoCdma(android.telephony.CellInfoCdma) CellIdentityLte(android.telephony.CellIdentityLte) CellInfoWcdma(android.telephony.CellInfoWcdma) CellIdentityGsm(android.telephony.CellIdentityGsm) CellIdentityWcdma(android.telephony.CellIdentityWcdma) CellInfoGsm(android.telephony.CellInfoGsm) TargetApi(android.annotation.TargetApi)

Example 13 with CellIdentityLte

use of android.telephony.CellIdentityLte in project android_packages_apps_Settings by DirtyUnicorns.

the class RadioInfo method buildLteInfoString.

private final String buildLteInfoString(CellInfoLte ci) {
    CellIdentityLte cidLte = ci.getCellIdentity();
    CellSignalStrengthLte ssLte = ci.getCellSignalStrength();
    return String.format("%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-3.3s %-6.6s %-4.4s %-4.4s %-2.2s\n", ci.isRegistered() ? "S  " : "   ", getCellInfoDisplayString(cidLte.getMcc()), getCellInfoDisplayString(cidLte.getMnc()), getCellInfoDisplayString(cidLte.getTac()), getCellInfoDisplayString(cidLte.getCi()), getCellInfoDisplayString(cidLte.getPci()), getCellInfoDisplayString(cidLte.getEarfcn()), getCellInfoDisplayString(ssLte.getDbm()), getCellInfoDisplayString(ssLte.getRsrq()), getCellInfoDisplayString(ssLte.getTimingAdvance()));
}
Also used : CellSignalStrengthLte(android.telephony.CellSignalStrengthLte) CellIdentityLte(android.telephony.CellIdentityLte)

Example 14 with CellIdentityLte

use of android.telephony.CellIdentityLte in project android_packages_apps_Settings by crdroidandroid.

the class RadioInfo method buildLteInfoString.

private final String buildLteInfoString(CellInfoLte ci) {
    CellIdentityLte cidLte = ci.getCellIdentity();
    CellSignalStrengthLte ssLte = ci.getCellSignalStrength();
    return String.format("%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-3.3s %-6.6s %-4.4s %-4.4s %-2.2s\n", ci.isRegistered() ? "S  " : "   ", getCellInfoDisplayString(cidLte.getMcc()), getCellInfoDisplayString(cidLte.getMnc()), getCellInfoDisplayString(cidLte.getTac()), getCellInfoDisplayString(cidLte.getCi()), getCellInfoDisplayString(cidLte.getPci()), getCellInfoDisplayString(cidLte.getEarfcn()), getCellInfoDisplayString(ssLte.getDbm()), getCellInfoDisplayString(ssLte.getRsrq()), getCellInfoDisplayString(ssLte.getTimingAdvance()));
}
Also used : CellSignalStrengthLte(android.telephony.CellSignalStrengthLte) CellIdentityLte(android.telephony.CellIdentityLte)

Example 15 with CellIdentityLte

use of android.telephony.CellIdentityLte in project android_frameworks_opt_telephony by LineageOS.

the class ServiceStateTracker method getCellLocation.

/**
 * @param workSource calling WorkSource
 * @return the current cell location information. Prefer Gsm location
 * information if available otherwise return LTE location information
 */
public CellLocation getCellLocation(WorkSource workSource) {
    if (((GsmCellLocation) mCellLoc).getLac() >= 0 && ((GsmCellLocation) mCellLoc).getCid() >= 0) {
        if (VDBG)
            log("getCellLocation(): X good mCellLoc=" + mCellLoc);
        return mCellLoc;
    } else {
        List<CellInfo> result = getAllCellInfo(workSource);
        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
            // PSC = 0.
            GsmCellLocation cellLocOther = new GsmCellLocation();
            for (CellInfo ci : result) {
                if (ci instanceof CellInfoGsm) {
                    CellInfoGsm cellInfoGsm = (CellInfoGsm) ci;
                    CellIdentityGsm cellIdentityGsm = cellInfoGsm.getCellIdentity();
                    cellLocOther.setLacAndCid(cellIdentityGsm.getLac(), cellIdentityGsm.getCid());
                    cellLocOther.setPsc(cellIdentityGsm.getPsc());
                    if (VDBG)
                        log("getCellLocation(): X ret GSM info=" + cellLocOther);
                    return cellLocOther;
                } else if (ci instanceof CellInfoWcdma) {
                    CellInfoWcdma cellInfoWcdma = (CellInfoWcdma) ci;
                    CellIdentityWcdma cellIdentityWcdma = cellInfoWcdma.getCellIdentity();
                    cellLocOther.setLacAndCid(cellIdentityWcdma.getLac(), cellIdentityWcdma.getCid());
                    cellLocOther.setPsc(cellIdentityWcdma.getPsc());
                    if (VDBG)
                        log("getCellLocation(): X ret WCDMA info=" + cellLocOther);
                    return cellLocOther;
                } 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) ci;
                    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 (VDBG) {
                            log("getCellLocation(): possible LTE cellLocOther=" + cellLocOther);
                        }
                    }
                }
            }
            if (VDBG) {
                log("getCellLocation(): X ret best answer cellLocOther=" + cellLocOther);
            }
            return cellLocOther;
        } else {
            if (VDBG) {
                log("getCellLocation(): X empty mCellLoc and CellInfo mCellLoc=" + mCellLoc);
            }
            return mCellLoc;
        }
    }
}
Also used : CellInfoLte(android.telephony.CellInfoLte) CellInfo(android.telephony.CellInfo) CellIdentityLte(android.telephony.CellIdentityLte) CellInfoWcdma(android.telephony.CellInfoWcdma) CellIdentityGsm(android.telephony.CellIdentityGsm) GsmCellLocation(android.telephony.gsm.GsmCellLocation) CellIdentityWcdma(android.telephony.CellIdentityWcdma) CellInfoGsm(android.telephony.CellInfoGsm)

Aggregations

CellIdentityLte (android.telephony.CellIdentityLte)22 CellIdentityGsm (android.telephony.CellIdentityGsm)13 CellInfoGsm (android.telephony.CellInfoGsm)13 CellInfoLte (android.telephony.CellInfoLte)13 CellIdentityWcdma (android.telephony.CellIdentityWcdma)12 CellInfo (android.telephony.CellInfo)12 CellInfoWcdma (android.telephony.CellInfoWcdma)12 CellIdentityCdma (android.telephony.CellIdentityCdma)11 CellInfoCdma (android.telephony.CellInfoCdma)11 CellSignalStrengthLte (android.telephony.CellSignalStrengthLte)11 PendingIntent (android.app.PendingIntent)5 Intent (android.content.Intent)5 WifiInfo (android.net.wifi.WifiInfo)5 CellSignalStrengthGsm (android.telephony.CellSignalStrengthGsm)4 TargetApi (android.annotation.TargetApi)3 CellSignalStrengthCdma (android.telephony.CellSignalStrengthCdma)3 CellSignalStrengthWcdma (android.telephony.CellSignalStrengthWcdma)3 SuppressLint (android.annotation.SuppressLint)1 Parcel (android.os.Parcel)1 SmallTest (android.support.test.filters.SmallTest)1