Java Code Examples for android.telephony.TelephonyManager#PHONE_TYPE_SIP

The following examples show how to use android.telephony.TelephonyManager#PHONE_TYPE_SIP . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Util.java    From kcanotify with GNU General Public License v3.0 5 votes vote down vote up
public static String getPhoneTypeName(int phoneType) {
    switch (phoneType) {
        case TelephonyManager.PHONE_TYPE_NONE:
            return "None";
        case TelephonyManager.PHONE_TYPE_GSM:
            return "GSM";
        case TelephonyManager.PHONE_TYPE_CDMA:
            return "CDMA";
        case TelephonyManager.PHONE_TYPE_SIP:
            return "SIP";
        default:
            return "Unknown";
    }
}
 
Example 2
Source File: MyDialerActivity.java    From Wrox-ProfessionalAndroid-4E with Apache License 2.0 4 votes vote down vote up
private void listing20_6() {
  String srvcName = Context.TELEPHONY_SERVICE;
  TelephonyManager telephonyManager = (TelephonyManager)getSystemService(srvcName);

  // Listing 20-6: Accessing phone-type and the device’s phone number
  String phoneTypeStr = "unknown";

  int phoneType = telephonyManager.getPhoneType();

  switch (phoneType) {
    case (TelephonyManager.PHONE_TYPE_CDMA):
      phoneTypeStr = "CDMA";
      break;
    case (TelephonyManager.PHONE_TYPE_GSM) :
      phoneTypeStr = "GSM";
      break;
    case (TelephonyManager.PHONE_TYPE_SIP):
      phoneTypeStr = "SIP";
      break;
    case (TelephonyManager.PHONE_TYPE_NONE):
      phoneTypeStr = "None";
      break;
    default: break;
  }

  Log.d(TAG, phoneTypeStr);

  // -- These require READ_PHONE_STATE uses-permission --
  int permission = ActivityCompat.checkSelfPermission(this,
    android.Manifest.permission.READ_PHONE_STATE);
  if (permission == PackageManager.PERMISSION_GRANTED) {

    // Read the IMEI for GSM or MEID for CDMA
    String deviceId = telephonyManager.getDeviceId();

    // Read the software version on the phone (note -- not the SDK version)
    String softwareVersion = telephonyManager.getDeviceSoftwareVersion();

    // Get the phone's number (if available)
    String phoneNumber = telephonyManager.getLine1Number();

    // If permission hasn't been granted, request it.
  } else {
    if (ActivityCompat.shouldShowRequestPermissionRationale(
      this, android.Manifest.permission.READ_PHONE_STATE)) {
      // TODO Display additional rationale for the requested permission.
    }
    ActivityCompat.requestPermissions(this,
      new String[]{android.Manifest.permission.READ_PHONE_STATE},
      PHONE_STATE_PERMISSION_REQUEST);
  }
}
 
Example 3
Source File: CellTracker.java    From AIMSICDL with GNU General Public License v3.0 4 votes vote down vote up
public void onCellLocationChanged(CellLocation location) {

            checkForNeighbourCount(location);
            compareLac(location);
            refreshDevice();
            mDevice.setNetID(tm);
            mDevice.getNetworkTypeName();

            switch (mDevice.getPhoneID()) {

                case TelephonyManager.PHONE_TYPE_NONE:
                case TelephonyManager.PHONE_TYPE_SIP:
                case TelephonyManager.PHONE_TYPE_GSM:
                    GsmCellLocation gsmCellLocation = (GsmCellLocation) location;
                    if (gsmCellLocation != null) {
                        //TODO @EVA where are we sending this setCellInfo data?

                        //TODO
                        /*@EVA
                            Is it a good idea to dump all cells to db because if we spot a known cell
                            with different lac then this will also be dump to db.

                        */
                        mDevice.setCellInfo(
                                gsmCellLocation.toString() +                // ??
                                mDevice.getDataActivityTypeShort() + "|" +  // No,In,Ou,IO,Do
                                mDevice.getDataStateShort() + "|" +         // Di,Ct,Cd,Su
                                mDevice.getNetworkTypeName() + "|"          // HSPA,LTE etc
                        );

                        mDevice.mCell.setLAC(gsmCellLocation.getLac());     // LAC
                        mDevice.mCell.setCID(gsmCellLocation.getCid());     // CID
                        if (gsmCellLocation.getPsc() != -1) {
                            mDevice.mCell.setPSC(gsmCellLocation.getPsc()); // PSC
                        }

                        /*
                            Add cell if gps is not enabled
                            when gps enabled lat lon will be updated
                            by function below

                         */
                    }
                    break;

                case TelephonyManager.PHONE_TYPE_CDMA:
                    CdmaCellLocation cdmaCellLocation = (CdmaCellLocation) location;
                    if (cdmaCellLocation != null) {
                        mDevice.setCellInfo(
                                cdmaCellLocation.toString() +                       // ??
                                mDevice.getDataActivityTypeShort() + "|" +  // No,In,Ou,IO,Do
                                mDevice.getDataStateShort() + "|" +         // Di,Ct,Cd,Su
                                mDevice.getNetworkTypeName() + "|"          // HSPA,LTE etc
                        );
                        mDevice.mCell.setLAC(cdmaCellLocation.getNetworkId());      // NID
                        mDevice.mCell.setCID(cdmaCellLocation.getBaseStationId());  // BID
                        mDevice.mCell.setSID(cdmaCellLocation.getSystemId());       // SID
                        mDevice.mCell.setMNC(cdmaCellLocation.getSystemId());       // MNC <== BUG!??
                        mDevice.setNetworkName(tm.getNetworkOperatorName());        // ??
                    }
            }

        }
 
Example 4
Source File: CellTracker.java    From AIMSICDL with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Description:    Add entries to the "DBi_measure" DB table
 *
 * Issues:
 *                  [ ]
 *
 * Notes:           (a)
 *
 *
 * TODO:  Remove OLD notes below, once we have new ones relevant to our new table
 *
 *  From "locationinfo":
 *
 *      $ sqlite3.exe -header aimsicd.db 'select * from locationinfo;'
 *      _id|Lac|CellID|Net|Lat|Lng|Signal|Connection|Timestamp
 *      1|10401|6828xxx|10|54.67874392|25.28693531|24|[10401,6828320,126]No|Di|HSPA||2015-01-21 20:45:10
 *
 *  From "cellinfo":
 *
 *      $ sqlite3.exe -header aimsicd.db 'select * from cellinfo;'
 *      _id|Lac|CellID|Net|Lat|Lng|Signal|Mcc|Mnc|Accuracy|Speed|Direction|NetworkType|MeasurementTaken|OCID_SUBMITTED|Timestamp
 *      1|10401|6828xxx|10|54.67874392|25.28693531|24|246|2|69.0|0.0|0.0|HSPA|82964|0|2015-01-21 20:45:10
 *
 *  Issues:
 *
 */
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);
        //}
    }
}