List of usage examples for android.telephony TelephonyManager PHONE_TYPE_NONE
int PHONE_TYPE_NONE
To view the source code for android.telephony TelephonyManager PHONE_TYPE_NONE.
Click Source Link
From source file:org.mozilla.mozstumbler.service.scanners.cellscanner.CellInfo.java
@SuppressWarnings("fallthrough") private static String getRadioTypeName(int phoneType) { switch (phoneType) { case TelephonyManager.PHONE_TYPE_CDMA: return RADIO_CDMA; case TelephonyManager.PHONE_TYPE_GSM: return RADIO_GSM; default:/*from w w w .j a v a2 s . co m*/ Log.e(LOGTAG, "", new IllegalArgumentException("Unexpected phone type: " + phoneType)); // fallthrough case TelephonyManager.PHONE_TYPE_NONE: case TelephonyManager.PHONE_TYPE_SIP: // These devices have no radio. return ""; } }
From source file:com.yamin.kk.vlc.Util.java
public static boolean isPhone() { TelephonyManager manager = (TelephonyManager) VLCApplication.getAppContext() .getSystemService(Context.TELEPHONY_SERVICE); if (manager.getPhoneType() == TelephonyManager.PHONE_TYPE_NONE) { return false; } else {// w w w . j av a2s.co m return true; } }
From source file:com.lewen.listener.vlc.Util.java
public static boolean isPhone() { TelephonyManager manager = (TelephonyManager) TBApplication.App.getApplicationContext() .getSystemService(Context.TELEPHONY_SERVICE); if (manager.getPhoneType() == TelephonyManager.PHONE_TYPE_NONE) { return false; } else {// w w w. ja va 2 s . c o m return true; } }
From source file:com.mobilyzer.util.PhoneUtils.java
/** Returns "GSM", "CDMA". */ private String getTelephonyPhoneType() { switch (telephonyManager.getPhoneType()) { case TelephonyManager.PHONE_TYPE_CDMA: return "CDMA"; case TelephonyManager.PHONE_TYPE_GSM: return "GSM"; case TelephonyManager.PHONE_TYPE_NONE: return "None"; }/*from www .j a v a2s . co m*/ return "Unknown"; }
From source file:ru.dublgis.androidhelpers.DesktopUtils.java
public static boolean isVoiceTelephonyAvailable(final Context ctx) { try {/* ww w. ja v a 2s . c o m*/ if (!ctx.getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEPHONY)) { return false; } final TelephonyManager manager = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE); if (manager == null) { return false; } if (manager.getPhoneType() == TelephonyManager.PHONE_TYPE_NONE) { return false; } if (Build.VERSION.SDK_INT >= 22) // Android 5.1+ { if (!manager.isVoiceCapable()) { return false; } } return true; } catch (final Throwable e) { Log.e(TAG, "isVoiceTelephonyAvailable exception (will return 'false'): ", e); return false; } }
From source file:com.secupwn.aimsicd.service.CellTracker.java
/** * I removed the timer that activated this code and now the code will be run when * the cell changes so it will detect faster rather than using a timer that might * miss an imsi catcher, also says cpu rather than refreshing every x seconds. * * original comments below from xLaMbChOpSx * * * Description: (From xLaMbChOpSx commit comment) * * Initial implementation for detection method 1 to compare the CID & LAC with the Cell * Information Table contents as an initial implementation for detection of a changed LAC, * once OCID issues (API key use etc) have been finalised this detection method can be * extended to include checking of external data. * * REMOVED: refresh timer info/* w w w.j a va2 s . c om*/ * * As I have no real way of testing this I require testing by other project members who * do have access to equipment or an environment where a changing LAC can be simulated * thus confirming the accuracy of this implementation. * * Presently this will only invoke the MEDIUM threat level through the notification and * does not fully implement the capturing and score based method as per the issue details * once further testing is complete the alert and tracking of information can be refined. * * See: * https://github.com/xLaMbChOpSx/Android-IMSI-Catcher-Detector/commit/43ae77e2a0cad10dfd50f92da5a998f9ece95b38 * https://github.com/SecUpwN/Android-IMSI-Catcher-Detector/issues/91#issuecomment-64391732 * * Short explanation: * * This is a polling mechanism for getting the LAC/CID and location * info for the currently connected cell. * * Variables: * FIXED: now updates on cell change rather than a timer * There is a "timer" here (REFRESH_RATE), what exactly is it timing? * "Every REFRESH_RATE seconds, get connected cell details." * * Issues: [ ] We shouldn't do any detection here! * [ ] We might wanna use a listener to do this? * Are there any reasons why not using a listener? * * ChangeLog: * 2015-03-03 E:V:A Changed getProp() to use TinyDB (SharedPreferences) * 2015-0x-xx banjaxbanjo Update: ??? (hey dude what did you do?) * */ public void compareLac(CellLocation location) { @Cleanup Realm realm = Realm.getDefaultInstance(); switch (device.getPhoneId()) { case TelephonyManager.PHONE_TYPE_NONE: case TelephonyManager.PHONE_TYPE_SIP: case TelephonyManager.PHONE_TYPE_GSM: GsmCellLocation gsmCellLocation = (GsmCellLocation) location; if (gsmCellLocation != null) { monitorCell.setLocationAreaCode(gsmCellLocation.getLac()); monitorCell.setCellId(gsmCellLocation.getCid()); // Check if LAC is ok boolean lacOK = dbHelper.checkLAC(realm, monitorCell); if (!lacOK) { changedLAC = true; dbHelper.toEventLog(realm, 1, "Changing LAC"); // Detection Logs are made in checkLAC() vibrate(100, Status.MEDIUM); } else { changedLAC = false; } if (tinydb.getBoolean("ocid_downloaded")) { if (!dbHelper.openCellExists(realm, monitorCell.getCellId())) { dbHelper.toEventLog(realm, 2, "CID not in Import realm"); log.info("ALERT: Connected to unknown CID not in Import realm: " + monitorCell.getCellId()); vibrate(100, Status.MEDIUM); cellIdNotInOpenDb = true; } else { cellIdNotInOpenDb = false; } } } break; case TelephonyManager.PHONE_TYPE_CDMA: CdmaCellLocation cdmaCellLocation = (CdmaCellLocation) location; if (cdmaCellLocation != null) { monitorCell.setLocationAreaCode(cdmaCellLocation.getNetworkId()); monitorCell.setCellId(cdmaCellLocation.getBaseStationId()); boolean lacOK = dbHelper.checkLAC(realm, monitorCell); if (!lacOK) { changedLAC = true; /*dbHelper.insertEventLog( MiscUtils.getCurrentTimeStamp(), monitorCell.getLAC(), monitorCell.getCid(), monitorCell.getPSC(),//This is giving weird values like 21478364... is this right? String.valueOf(monitorCell.getLat()), String.valueOf(monitorCell.getLon()), (int)monitorCell.getAccuracy(), 1, "Changing LAC" );*/ dbHelper.toEventLog(realm, 1, "Changing LAC"); } else { changedLAC = false; } } } setNotification(); }
From source file:com.compal.telephonytest.TelephonyTest.java
public void InformatonAndStatusCheck() { StringBuilder sb = new StringBuilder(""); boolean hasFailInfo = false; if (mTelephonyManager.getPhoneType() != TelephonyManager.PHONE_TYPE_NONE) { sb.append("getPhoneType:" + Integer.toString(mTelephonyManager.getPhoneType()) + "\n"); } else {/*w ww. j a v a2s .c o m*/ sb.append("getPhoneType:" + "fail"); hasFailInfo = true; } if (mTelephonyManager.getNetworkType() != TelephonyManager.NETWORK_TYPE_UNKNOWN) { sb.append("getNetworkType:" + Integer.toString(mTelephonyManager.getNetworkType()) + "\n"); } else { sb.append("getNetworkType:" + "fail"); hasFailInfo = true; } String operatorName = mTelephonyManager.getNetworkOperatorName(); if (operatorName != null && !operatorName.equals("")) { // OperatorName sb.append("getNetworkOperatorName:" + mTelephonyManager.getNetworkOperatorName() + "\n"); } else { sb.append("getNetworkOperatorName:" + "fail"); hasFailInfo = true; } String serial = Build.SERIAL; if (serial != null && !serial.equals("")) { // SerialNumber sb.append("get Serial Number:" + serial + "\n"); } else { sb.append("get Serial Number:" + "fail"); hasFailInfo = true; } if (mTelephonyManager.getSimState() != TelephonyManager.SIM_STATE_UNKNOWN) { sb.append("getSimState:" + Integer.toString(mTelephonyManager.getSimState()) + "\n"); } else { sb.append("getSimState:" + "fail"); hasFailInfo = true; } //It's all ok sb.append("isNetworkRoaming:" + Boolean.toString(mTelephonyManager.isNetworkRoaming()) + "\n"); if (mTelephonyManager.getDataState() != TelephonyManager.DATA_DISCONNECTED) { sb.append("getDataState:" + Integer.toString(mTelephonyManager.getDataState()) + "\n"); } else { sb.append("getDataState:" + "fail"); hasFailInfo = true; } String formatIP = formatIpAddresses(mLinkProperties); if (formatIP != null && !formatIP.equals("")) { //IP Address sb.append("IP Address:" + formatIpAddresses(mLinkProperties) + "\n"); } else { sb.append("IP Address:" + "fail"); hasFailInfo = true; } if (mTelephonyManager.getPhoneType() == TelephonyManager.PHONE_TYPE_GSM) { if (checkGsmDeviceId(mTelephonyManager.getDeviceId())) { sb.append("IMEI:" + mTelephonyManager.getDeviceId() + "\n"); } else { sb.append("IMEI:" + "fail"); hasFailInfo = true; } } else { sb.append("IMEI:" + "fail"); hasFailInfo = true; } Log.i(tag, sb.toString()); mLog = sb.toString(); if (!hasFailInfo) { Log.i(tag, "test_5th_InformatonAndStatus true"); outputResult(true, tTelephonyBasicFunc, dBasicInformation, testCaseId); } else { Log.i(tag, "test_5th_InformatonAndStatus false"); outputResult(false, tTelephonyBasicFunc, dBasicInformation, testCaseId); } //Log.i(tag, "getPhoneType:" + Integer.toString(mTelephonyManager.getPhoneType())); //Log.i(tag, "getNetworkType:" + Integer.toString(mTelephonyManager.getNetworkType())); //Log.i(tag, "getNetworkOperatorName:" + mTelephonyManager.getNetworkOperatorName()); //Log.i(tag, "getSimSerialNumber:" + mTelephonyManager.getSimSerialNumber()); //Log.i(tag, "getSimState:" + Integer.toString(mTelephonyManager.getSimState())); //Log.i(tag, "isNetworkRoaming:" + Boolean.toString(mTelephonyManager.isNetworkRoaming())); //Log.i(tag, "getDataState:" + Integer.toString(mTelephonyManager.getDataState())); //Log.i(tag,"formatIpAddresses(mLinkProperties): " + formatIpAddresses(mLinkProperties)); }
From source file:com.secupwn.aimsicd.service.CellTracker.java
/** * Add entries to the {@link com.secupwn.aimsicd.data.model.Measure Measure} realm *//* w w w.j a va2 s .c om*/ public void onLocationChanged(Location loc) { // TODO: See issue #555 (DeviceApi17.java is using API 18 CellInfoWcdma calls. if (Build.VERSION.SDK_INT > 17) { DeviceApi18.loadCellInfo(tm, device); } if (!device.cell.isValid()) { CellLocation cellLocation = tm.getCellLocation(); if (cellLocation != null) { switch (device.getPhoneId()) { case TelephonyManager.PHONE_TYPE_NONE: case TelephonyManager.PHONE_TYPE_SIP: case TelephonyManager.PHONE_TYPE_GSM: GsmCellLocation gsmCellLocation = (GsmCellLocation) cellLocation; device.cell.setCellId(gsmCellLocation.getCid()); // CID device.cell.setLocationAreaCode(gsmCellLocation.getLac()); // LAC device.cell.setPrimaryScramblingCode(gsmCellLocation.getPsc()); // PSC break; case TelephonyManager.PHONE_TYPE_CDMA: CdmaCellLocation cdmaCellLocation = (CdmaCellLocation) cellLocation; device.cell.setCellId(cdmaCellLocation.getBaseStationId()); // BSID ?? device.cell.setLocationAreaCode(cdmaCellLocation.getNetworkId()); // NID device.cell.setSid(cdmaCellLocation.getSystemId()); // SID device.cell.setMobileNetworkCode(cdmaCellLocation.getSystemId()); // MNC <== BUG!?? break; } } } if (loc != null && (Double.doubleToRawLongBits(loc.getLatitude()) != 0 && Double.doubleToRawLongBits(loc.getLongitude()) != 0)) { device.cell.setLon(loc.getLongitude()); // gpsd_lon device.cell.setLat(loc.getLatitude()); // gpsd_lat device.cell.setSpeed(loc.getSpeed()); // speed // TODO: Remove, we're not using it! device.cell.setAccuracy(loc.getAccuracy()); // gpsd_accu device.cell.setBearing(loc.getBearing()); // -- [deg]?? // TODO: Remove, we're not using it! device.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 // TODO: Is correct behaviour? We should consider logging all cells, even without GPS. if (trackingCell) { // This also checks that the locationAreaCode are cid are not in DB before inserting @Cleanup Realm realm = Realm.getDefaultInstance(); dbHelper.insertBTS(realm, device.cell); } } }
From source file:com.elitise.appv2.Peripheral.java
public boolean isTabletDevice() { TelephonyManager telephony = (TelephonyManager) getApplicationContext() .getSystemService(Context.TELEPHONY_SERVICE); int type = telephony.getPhoneType(); if (type == TelephonyManager.PHONE_TYPE_NONE) { return true; } else {//from w ww . j a v a 2s. c o m return false; } }
From source file:com.ferdi2005.secondgram.voip.VoIPService.java
public boolean hasEarpiece() { if (((TelephonyManager) getSystemService(TELEPHONY_SERVICE)) .getPhoneType() != TelephonyManager.PHONE_TYPE_NONE) return true; if (mHasEarpiece != null) { return mHasEarpiece; }//from ww w . j a v a 2s. com // not calculated yet, do it now try { AudioManager am = (AudioManager) getSystemService(AUDIO_SERVICE); Method method = AudioManager.class.getMethod("getDevicesForStream", Integer.TYPE); Field field = AudioManager.class.getField("DEVICE_OUT_EARPIECE"); int earpieceFlag = field.getInt(null); int bitmaskResult = (int) method.invoke(am, AudioManager.STREAM_VOICE_CALL); // check if masked by the earpiece flag if ((bitmaskResult & earpieceFlag) == earpieceFlag) { mHasEarpiece = Boolean.TRUE; } else { mHasEarpiece = Boolean.FALSE; } } catch (Throwable error) { FileLog.e("Error while checking earpiece! ", error); mHasEarpiece = Boolean.TRUE; } return mHasEarpiece; }