Search in sources :

Example 26 with CellInfo

use of android.telephony.CellInfo 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 27 with CellInfo

use of android.telephony.CellInfo in project android_packages_apps_Settings by omnirom.

the class RadioInfo method buildCellInfoString.

private final String buildCellInfoString(List<CellInfo> arrayCi) {
    String value = new String();
    StringBuilder cdmaCells = new StringBuilder(), gsmCells = new StringBuilder(), lteCells = new StringBuilder(), wcdmaCells = new StringBuilder();
    if (arrayCi != null) {
        for (CellInfo ci : arrayCi) {
            if (ci instanceof CellInfoLte) {
                lteCells.append(buildLteInfoString((CellInfoLte) ci));
            } else if (ci instanceof CellInfoWcdma) {
                wcdmaCells.append(buildWcdmaInfoString((CellInfoWcdma) ci));
            } else if (ci instanceof CellInfoGsm) {
                gsmCells.append(buildGsmInfoString((CellInfoGsm) ci));
            } else if (ci instanceof CellInfoCdma) {
                cdmaCells.append(buildCdmaInfoString((CellInfoCdma) ci));
            }
        }
        if (lteCells.length() != 0) {
            value += String.format("LTE\n%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-3.3s %-6.6s %-4.4s %-4.4s %-2.2s\n", "SRV", "MCC", "MNC", "TAC", "CID", "PCI", "EARFCN", "RSRP", "RSRQ", "TA");
            value += lteCells.toString();
        }
        if (wcdmaCells.length() != 0) {
            value += String.format("WCDMA\n%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-6.6s %-3.3s %-4.4s\n", "SRV", "MCC", "MNC", "LAC", "CID", "UARFCN", "PSC", "RSCP");
            value += wcdmaCells.toString();
        }
        if (gsmCells.length() != 0) {
            value += String.format("GSM\n%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-6.6s %-4.4s %-4.4s\n", "SRV", "MCC", "MNC", "LAC", "CID", "ARFCN", "BSIC", "RSSI");
            value += gsmCells.toString();
        }
        if (cdmaCells.length() != 0) {
            value += String.format("CDMA/EVDO\n%-3.3s %-5.5s %-5.5s %-5.5s %-6.6s %-6.6s %-6.6s %-6.6s %-5.5s\n", "SRV", "SID", "NID", "BSID", "C-RSSI", "C-ECIO", "E-RSSI", "E-ECIO", "E-SNR");
            value += cdmaCells.toString();
        }
    } else {
        value = "unknown";
    }
    return value.toString();
}
Also used : CellInfoLte(android.telephony.CellInfoLte) CellInfo(android.telephony.CellInfo) NeighboringCellInfo(android.telephony.NeighboringCellInfo) CellInfoCdma(android.telephony.CellInfoCdma) CellInfoWcdma(android.telephony.CellInfoWcdma) CellInfoGsm(android.telephony.CellInfoGsm)

Example 28 with CellInfo

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

the class SimulatedCommands method getCellInfoList.

@Override
public void getCellInfoList(Message response, WorkSource WorkSource) {
    if (mCellInfoList == null) {
        Parcel p = Parcel.obtain();
        p.writeInt(1);
        p.writeInt(1);
        p.writeInt(2);
        p.writeLong(1453510289108L);
        p.writeInt(310);
        p.writeInt(260);
        p.writeInt(123);
        p.writeInt(456);
        p.writeInt(99);
        p.writeInt(3);
        p.setDataPosition(0);
        CellInfoGsm cellInfo = CellInfoGsm.CREATOR.createFromParcel(p);
        ArrayList<CellInfo> mCellInfoList = new ArrayList();
        mCellInfoList.add(cellInfo);
    }
    resultSuccess(response, mCellInfoList);
}
Also used : CellInfo(android.telephony.CellInfo) Parcel(android.os.Parcel) ArrayList(java.util.ArrayList) CellInfoGsm(android.telephony.CellInfoGsm)

Example 29 with CellInfo

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

the class ServiceStateTrackerTest method testCellInfoList.

@Test
@MediumTest
public void testCellInfoList() {
    Parcel p = Parcel.obtain();
    p.writeInt(1);
    p.writeInt(1);
    p.writeInt(2);
    p.writeLong(1453510289108L);
    p.writeInt(310);
    p.writeInt(260);
    p.writeInt(123);
    p.writeInt(456);
    p.writeInt(99);
    p.writeInt(3);
    p.setDataPosition(0);
    CellInfoGsm cellInfo = CellInfoGsm.CREATOR.createFromParcel(p);
    ArrayList<CellInfo> list = new ArrayList();
    list.add(cellInfo);
    mSimulatedCommands.setCellInfoList(list);
    WorkSource workSource = new WorkSource(Process.myUid(), mContext.getPackageName());
    assertEquals(sst.getAllCellInfo(workSource), list);
}
Also used : CellInfo(android.telephony.CellInfo) Parcel(android.os.Parcel) ArrayList(java.util.ArrayList) WorkSource(android.os.WorkSource) CellInfoGsm(android.telephony.CellInfoGsm) MediumTest(android.test.suitebuilder.annotation.MediumTest) SmallTest(android.test.suitebuilder.annotation.SmallTest) FlakyTest(android.support.test.filters.FlakyTest) Test(org.junit.Test) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 30 with CellInfo

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

the class NetworkScanRequestTracker method notifyMessenger.

/**
 * Sends a message back to the application via its callback.
 */
private void notifyMessenger(NetworkScanRequestInfo nsri, int what, int err, List<CellInfo> result) {
    Messenger messenger = nsri.mMessenger;
    Message message = Message.obtain();
    message.what = what;
    message.arg1 = err;
    message.arg2 = nsri.mScanId;
    if (result != null) {
        CellInfo[] ci = result.toArray(new CellInfo[result.size()]);
        Bundle b = new Bundle();
        b.putParcelableArray(TelephonyScanManager.SCAN_RESULT_KEY, ci);
        message.setData(b);
    } else {
        message.obj = null;
    }
    try {
        messenger.send(message);
    } catch (RemoteException e) {
        Log.e(TAG, "Exception in notifyMessenger: " + e);
    }
}
Also used : Message(android.os.Message) CellInfo(android.telephony.CellInfo) Bundle(android.os.Bundle) Messenger(android.os.Messenger) RemoteException(android.os.RemoteException)

Aggregations

CellInfo (android.telephony.CellInfo)40 CellInfoGsm (android.telephony.CellInfoGsm)26 CellInfoLte (android.telephony.CellInfoLte)25 CellInfoWcdma (android.telephony.CellInfoWcdma)23 CellInfoCdma (android.telephony.CellInfoCdma)18 CellIdentityGsm (android.telephony.CellIdentityGsm)12 CellIdentityLte (android.telephony.CellIdentityLte)12 CellIdentityCdma (android.telephony.CellIdentityCdma)11 CellIdentityWcdma (android.telephony.CellIdentityWcdma)11 NeighboringCellInfo (android.telephony.NeighboringCellInfo)8 ArrayList (java.util.ArrayList)6 PendingIntent (android.app.PendingIntent)5 Intent (android.content.Intent)5 WifiInfo (android.net.wifi.WifiInfo)5 CellSignalStrengthLte (android.telephony.CellSignalStrengthLte)5 Parcel (android.os.Parcel)4 CellSignalStrengthGsm (android.telephony.CellSignalStrengthGsm)4 Test (org.junit.Test)4 SuppressLint (android.annotation.SuppressLint)3 TargetApi (android.annotation.TargetApi)3