¿Funcionará TelephonyManager.getDeviceId sin tarjeta SIM?

Tengo una pregunta simple

Hace

TelephonyManager.getDeviceId(); 

Funcionará sin tarjeta SIM (SIM_STATE_ABSENT) en el dispositivo?

Deberia de funcionar. Acabo de probar esto en mi nexo CDMA Galaxy y devolvió un valor, a pesar de que no tiene una tarjeta SIM en absoluto. Cuando lo corrí en un emulador, devolvió una larga cadena de ceros.

Actualización: Según la documentación , getDeviceId () devuelve IMEI para un dispositivo GSM. Y IMEI no es una característica de la tarjeta SIM, viene con el dispositivo.

Código habla:

Telephony.getDeviceId telephony.getDeviceId() finalmente llama a Phone.getDeviceId (), las implementaciones de este método son diferentes en diferentes teléfonos como CDMA y GSM Phone. Por ejemplo, CDMA Phone.

 public String getMeid() { return mMeid; } //returns MEID or ESN in CDMA public String getDeviceId() { String id = getMeid(); if ((id == null) || id.matches("^0*$")) { Rlog.d(LOG_TAG, "getDeviceId(): MEID is not initialized use ESN"); id = getEsn(); } return id; } 

No tiene cheques en ese estado de ABS SIM. Por supuesto, puede obtener el resultado sin una tarjeta SIM.

Sin embargo, eche un vistazo cuando este mMeid se restablece.

 case EVENT_GET_IMEI_DONE: ar = (AsyncResult)msg.obj; if (ar.exception != null) { break; } mImei = (String)ar.result; case EVENT_RADIO_AVAILABLE: { mCM.getBasebandVersion( obtainMessage(EVENT_GET_BASEBAND_VERSION_DONE)); mCM.getIMEI(obtainMessage(EVENT_GET_IMEI_DONE)); mCM.getIMEISV(obtainMessage(EVENT_GET_IMEISV_DONE)); } 

Por lo tanto, se restablecerá cuando reciba un mensaje EVENT_RADIO_AVAILABLE. Y ese evento es enviado desde RIL . Sólo cuando recibe un mensaje EVENT_RADIO_AVAILABLE, enviará un mensaje para solicitar la identidad del dispositivo. A pesar de que la identificación del dispositivo no tiene nada que ver con la tarjeta SIM, pero puede que EVENT_RADIO_AVAILABLE (necesita confirmación adicional).

Además, compruebo cuándo enviará el sistema un mensaje EVENT_RADIO_AVAILABLE. Y finalmente descubrió que el RadioState contiene:

 enum RadioState { RADIO_OFF, /* Radio explictly powered off (eg CFUN=0) */ RADIO_UNAVAILABLE, /* Radio unavailable (eg, resetting or not booted) */ SIM_NOT_READY, /* Radio is on, but the SIM interface is not ready */ SIM_LOCKED_OR_ABSENT, /* SIM PIN locked, PUK required, network personalization, or SIM absent */ SIM_READY, /* Radio is on and SIM interface is available */ RUIM_NOT_READY, /* Radio is on, but the RUIM interface is not ready */ RUIM_READY, /* Radio is on and the RUIM interface is available */ RUIM_LOCKED_OR_ABSENT, /* RUIM PIN locked, PUK required, network personalization locked, or RUIM absent */ NV_NOT_READY, /* Radio is on, but the NV interface is not available */ NV_READY; /* Radio is on and the NV interface is available */ ... } 

Y cuando isAvailable () devuelve true, enviará el evento. Y el imei se actualizará.

 public boolean isAvailable() { return this != RADIO_UNAVAILABLE; } 

Por lo tanto, SIM_ABSENT no tiene nada que ver con ID de dispositivo.

FlipAndroid es un fan de Google para Android, Todo sobre Android Phones, Android Wear, Android Dev y Aplicaciones para Android Aplicaciones.