mroczis / netmonster-core

Android Telephony SDK bridge with some additional features
Apache License 2.0
334 stars 71 forks source link

Bandwidth detection for S21 5G #11

Closed jeffreykog closed 3 years ago

jeffreykog commented 3 years ago

I have noticed the G-MoN Pro app is able to reliably detect the bandwidths of all primary and secondary cells on the Galaxy S21 5G, while Netmonster is not. I have been investigating the situation and i have found the source of this information. I have also looked around the codebase in an attempt to implement it by myself, but i'm not sure about the best implementation.

The Galaxy S21 gives the following serviceState info:

{mVoiceRegState=0(IN_SERVICE), mDataRegState=0(IN_SERVICE), mChannelNumber=3700, duplexMode()=1, mCellBandwidths=[10000, 20000, 20000, 15000, 10000], isManualNetworkSelection=false(automatic), getRilVoiceRadioTechnology=14(LTE), getRilDataRadioTechnology=14(LTE), mCssIndicator=unsupported, mCdmaRoamingIndicator=-1, mCdmaDefaultRoamingIndicator=-1, VoiceRegType=0, ImsVoiceAvail=2, Snap=0, MobileVoice=IN_SERVICE, MobileData=IN_SERVICE, MobileDataRoamingType=home, MobileDataRat=LTE, PsOnly=false, FemtocellInd=0, SprDisplayRoam=false, NrBearerStatus=0, 5gStatus=1, mIsEmergencyOnly=false, isUsingCarrierAggregation=true, mLteEarfcnRsrpBoost=0, mNetworkRegistrationInfos=[NetworkRegistrationInfo{ domain=CS transportType=WWAN registrationState=HOME roamingType=NOT_ROAMING accessNetworkTechnology=LTE rejectCause=0 emergencyEnabled=false availableServices=[VOICE,SMS,VIDEO] cellIdentity=CellIdentityLte:{ mCi=68165141 mPci=408 mTac=563 mEarfcn=3700 mBands=[] mBandwidth=2147483647 mMcc=204 mMnc=16 mAlphaLong=T-Mobile NL mAlphaShort=TMO NL mAdditionalPlmns={} mCsgInfo=null} voiceSpecificInfo=VoiceSpecificRegistrationInfo { mCssSupported=false mRoamingIndicator=0 mSystemIsInPrl=0 mDefaultRoamingIndicator=0} dataSpecificInfo=null nrState=NONE rRplmn=20416}, NetworkRegistrationInfo{ domain=PS transportType=WWAN registrationState=HOME roamingType=NOT_ROAMING accessNetworkTechnology=LTE rejectCause=0 emergencyEnabled=false availableServices=[DATA] cellIdentity=CellIdentityLte:{ mCi=68165141 mPci=408 mTac=563 mEarfcn=3700 mBands=[] mBandwidth=2147483647 mMcc=204 mMnc=16 mAlphaLong=T-Mobile NL mAlphaShort=TMO NL mAdditionalPlmns={} mCsgInfo=null} voiceSpecificInfo=null dataSpecificInfo=android.telephony.DataSpecificRegistrationInfo :{ maxDataCalls = 16 isDcNrRestricted = false isNrAvailable = true isEnDcAvailable = true LteVopsSupportInfo : mVopsSupport = 2 mEmcBearerSupport = 3 mIsUsingCarrierAggregation = true } nrState=NOT_RESTRICTED rRplmn=20416}], mNrFrequencyRange=0, mIsDataRoamingFromRegistration=false, mIsIwlanPreferred=false}

The interesting bit is in the following part:

mCellBandwidths=[10000, 20000, 20000, 15000, 10000]

This contains the bandwidths for the primary (index 0) and secondary cells. The mBandwidth field of a cell object is always empty. As far as i can see this entire information blob is only used for detecting CA and 5G activity, and it is not linked to the cell scanning itself.

Can you point me into the direction where and how i can implement the detection based on this field? I like to help, but i'm not yet fully comfortable with the Netmonster core codebase.

mroczis commented 3 years ago

Adding bandwidth from this source to primary cell should be easy assuming that 1st entry belongs to primarily serving cell. I kinda struggle how to assign bandwidth to secondarily serving cells properly since there's no way how to connect PCIs with bandwidths.

Note: Will be officially supported starting Android 12, worked with NTM Core till Android 10 https://issuetracker.google.com/issues/182811458

jeffreykog commented 3 years ago

Assigning it to the secondary cells can be difficult. While the bandwidth order list matches with the secundary band order as shown in the service mode, most samsung phone's don't report secundary cells at all. So only showing bandwidth for the primary cell would be a nice addition.

As this is the general serviceState, i cannot predict how this behaves with dual sim phones