use of android.telephony.SignalStrength in project android_packages_apps_Settings by DirtyUnicorns.
the class SimStatus method updatePhoneInfos.
private void updatePhoneInfos() {
if (mSir != null) {
// TODO: http://b/23763013
final Phone phone = PhoneFactory.getPhone(SubscriptionManager.getPhoneId(mSir.getSubscriptionId()));
if (UserManager.get(getContext()).isAdminUser() && SubscriptionManager.isValidSubscriptionId(mSir.getSubscriptionId())) {
if (phone == null) {
Log.e(TAG, "Unable to locate a phone object for the given Subscription ID.");
return;
}
mPhone = phone;
// To avoid register multiple listeners when user changes the tab.
if (mPhoneStateListener != null && mTelephonyManager != null) {
mTelephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE);
mPhoneStateListener = null;
}
mPhoneStateListener = new PhoneStateListener(mSir.getSubscriptionId()) {
@Override
public void onDataConnectionStateChanged(int state) {
updateDataState();
updateNetworkType();
}
@Override
public void onSignalStrengthsChanged(SignalStrength signalStrength) {
updateSignalStrength(signalStrength);
}
@Override
public void onServiceStateChanged(ServiceState serviceState) {
updateServiceState(serviceState);
}
};
}
}
}
use of android.telephony.SignalStrength in project android_packages_apps_Settings by crdroidandroid.
the class SimStatus method updatePhoneInfos.
private void updatePhoneInfos() {
if (mSir != null) {
// TODO: http://b/23763013
final Phone phone = PhoneFactory.getPhone(SubscriptionManager.getPhoneId(mSir.getSubscriptionId()));
if (UserManager.get(getContext()).isAdminUser() && SubscriptionManager.isValidSubscriptionId(mSir.getSubscriptionId())) {
if (phone == null) {
Log.e(TAG, "Unable to locate a phone object for the given Subscription ID.");
return;
}
mPhone = phone;
// To avoid register multiple listeners when user changes the tab.
if (mPhoneStateListener != null && mTelephonyManager != null) {
mTelephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE);
mPhoneStateListener = null;
}
mPhoneStateListener = new PhoneStateListener(mSir.getSubscriptionId()) {
@Override
public void onDataConnectionStateChanged(int state) {
updateDataState();
updateNetworkType();
}
@Override
public void onSignalStrengthsChanged(SignalStrength signalStrength) {
updateSignalStrength(signalStrength);
}
@Override
public void onServiceStateChanged(ServiceState serviceState) {
updateServiceState(serviceState);
}
};
}
}
}
use of android.telephony.SignalStrength in project android_frameworks_opt_telephony by LineageOS.
the class ServiceStateTrackerTest method testSignalStrength.
@Test
@MediumTest
public void testSignalStrength() {
SignalStrength ss = new SignalStrength(// gsmSignalStrength
30, // gsmBitErrorRate
0, // cdmaDbm
-1, // cdmaEcio
-1, // evdoDbm
-1, // evdoEcio
-1, // evdoSnr
-1, // lteSignalStrength
99, // lteRsrp
SignalStrength.INVALID, // lteRsrq
SignalStrength.INVALID, // lteRssnr
SignalStrength.INVALID, // lteCqi
SignalStrength.INVALID, // tdScdmaRscp
SignalStrength.INVALID, // gsmFlag
true);
mSimulatedCommands.setSignalStrength(ss);
mSimulatedCommands.notifySignalStrength();
waitForMs(300);
assertEquals(sst.getSignalStrength(), ss);
assertEquals(sst.getSignalStrength().isGsm(), true);
// switch to CDMA
doReturn(false).when(mPhone).isPhoneTypeGsm();
doReturn(true).when(mPhone).isPhoneTypeCdmaLte();
sst.updatePhoneType();
sst.mSS.setRilDataRadioTechnology(ServiceState.RIL_RADIO_TECHNOLOGY_LTE);
mSimulatedCommands.notifySignalStrength();
waitForMs(300);
assertEquals(sst.getSignalStrength(), ss);
assertEquals(sst.getSignalStrength().isGsm(), true);
// notify signal strength again, but this time data RAT is not LTE
sst.mSS.setRilVoiceRadioTechnology(ServiceState.RIL_RADIO_TECHNOLOGY_1xRTT);
sst.mSS.setRilDataRadioTechnology(ServiceState.RIL_RADIO_TECHNOLOGY_EHRPD);
mSimulatedCommands.notifySignalStrength();
waitForMs(300);
assertEquals(sst.getSignalStrength(), ss);
assertEquals(sst.getSignalStrength().isGsm(), false);
}
use of android.telephony.SignalStrength in project android_frameworks_opt_telephony by LineageOS.
the class ServiceStateTracker method updatePhoneType.
@VisibleForTesting
public void updatePhoneType() {
// we change back to non-roaming.
if (mSS != null && mSS.getVoiceRoaming()) {
mVoiceRoamingOffRegistrants.notifyRegistrants();
}
// we change back to non-roaming.
if (mSS != null && mSS.getDataRoaming()) {
mDataRoamingOffRegistrants.notifyRegistrants();
}
// If we are previously in service, we need to notify that we are out of service now.
if (mSS != null && mSS.getDataRegState() == ServiceState.STATE_IN_SERVICE) {
mDetachedRegistrants.notifyRegistrants();
}
mSS = new ServiceState();
mNewSS = new ServiceState();
mLastCellInfoListTime = 0;
mLastCellInfoList = null;
mSignalStrength = new SignalStrength();
mStartedGprsRegCheck = false;
mReportedGprsNoReg = false;
mMdn = null;
mMin = null;
mPrlVersion = null;
mIsMinInfoReady = false;
mNitzUpdatedTime = false;
// cancel any pending pollstate request on voice tech switching
cancelPollState();
if (mPhone.isPhoneTypeGsm()) {
// clear CDMA registrations first
if (mCdmaSSM != null) {
mCdmaSSM.dispose(this);
}
mCi.unregisterForCdmaPrlChanged(this);
mPhone.unregisterForEriFileLoaded(this);
mCi.unregisterForCdmaOtaProvision(this);
mPhone.unregisterForSimRecordsLoaded(this);
mCellLoc = new GsmCellLocation();
mNewCellLoc = new GsmCellLocation();
} else {
if (mPhone.isPhoneTypeCdmaLte()) {
mPhone.registerForSimRecordsLoaded(this, EVENT_SIM_RECORDS_LOADED, null);
}
mCellLoc = new CdmaCellLocation();
mNewCellLoc = new CdmaCellLocation();
mCdmaSSM = CdmaSubscriptionSourceManager.getInstance(mPhone.getContext(), mCi, this, EVENT_CDMA_SUBSCRIPTION_SOURCE_CHANGED, null);
mIsSubscriptionFromRuim = (mCdmaSSM.getCdmaSubscriptionSource() == CdmaSubscriptionSourceManager.SUBSCRIPTION_FROM_RUIM);
mCi.registerForCdmaPrlChanged(this, EVENT_CDMA_PRL_VERSION_CHANGED, null);
mPhone.registerForEriFileLoaded(this, EVENT_ERI_FILE_LOADED, null);
mCi.registerForCdmaOtaProvision(this, EVENT_OTA_PROVISION_STATUS_CHANGE, null);
mHbpcdUtils = new HbpcdUtils(mPhone.getContext());
// update OTASP state in case previously set by another service
updateOtaspState();
}
// This should be done after the technology specific initializations above since it relies
// on fields like mIsSubscriptionFromRuim (which is updated above)
onUpdateIccAvailability();
mPhone.setSystemProperty(TelephonyProperties.PROPERTY_DATA_NETWORK_TYPE, ServiceState.rilRadioTechnologyToString(ServiceState.RIL_RADIO_TECHNOLOGY_UNKNOWN));
// Query signal strength from the modem after service tracker is created (i.e. boot up,
// switching between GSM and CDMA phone), because the unsolicited signal strength
// information might come late or even never come. This will get the accurate signal
// strength information displayed on the UI.
mCi.getSignalStrength(obtainMessage(EVENT_GET_SIGNAL_STRENGTH));
sendMessage(obtainMessage(EVENT_PHONE_TYPE_SWITCHED));
logPhoneTypeChange();
// Tell everybody that the registration state and RAT have changed.
notifyDataRegStateRilRadioTechnologyChanged();
}
use of android.telephony.SignalStrength in project android_frameworks_opt_telephony by LineageOS.
the class RadioResponse method responseSignalStrength.
private void responseSignalStrength(RadioResponseInfo responseInfo, android.hardware.radio.V1_0.SignalStrength sigStrength) {
RILRequest rr = mRil.processResponse(responseInfo);
if (rr != null) {
SignalStrength ret = RIL.convertHalSignalStrength(sigStrength);
if (responseInfo.error == RadioError.NONE) {
sendMessageResponse(rr.mResult, ret);
}
mRil.processResponseDone(rr, responseInfo, ret);
}
}
Aggregations