From 6e16fdf39907f6edaeb9fb431ed1cf20a8091b05 Mon Sep 17 00:00:00 2001 From: Nathan Harold Date: Tue, 17 Apr 2018 17:01:32 -0700 Subject: [PATCH 1/3] [Telephony Debug Menu] LTE BW and Serving CellInfo Add debug menu support for the serving cell status indication and the LTE bandwidth in the CellInfo display. Bug: 78791811 Test: manual Change-Id: Ic51858131af671317431e0970bdcaeebcb460931 --- src/com/android/settings/RadioInfo.java | 46 ++++++++++++++++++++----- 1 file changed, 37 insertions(+), 9 deletions(-) diff --git a/src/com/android/settings/RadioInfo.java b/src/com/android/settings/RadioInfo.java index b885483b7fc..91d319c42ec 100644 --- a/src/com/android/settings/RadioInfo.java +++ b/src/com/android/settings/RadioInfo.java @@ -58,6 +58,7 @@ import android.telephony.SubscriptionManager; import android.telephony.TelephonyManager; import android.telephony.cdma.CdmaCellLocation; import android.telephony.gsm.GsmCellLocation; +import android.text.TextUtils; import android.util.Log; import android.view.Menu; import android.view.MenuItem; @@ -673,12 +674,34 @@ public class RadioInfo extends Activity { return (i != Long.MAX_VALUE) ? Long.toString(i) : ""; } + private final String getConnectionStatusString(CellInfo ci) { + String regStr = ""; + String connStatStr = ""; + String connector = ""; + + if (ci.isRegistered()) { + regStr = "R"; + } + switch (ci.getCellConnectionStatus()) { + case CellInfo.CONNECTION_PRIMARY_SERVING: connStatStr = "P"; break; + case CellInfo.CONNECTION_SECONDARY_SERVING: connStatStr = "S"; break; + case CellInfo.CONNECTION_NONE: connStatStr = "N"; break; + case CellInfo.CONNECTION_UNKNOWN: /* Field is unsupported */ break; + default: break; + } + if (!TextUtils.isEmpty(regStr) && !TextUtils.isEmpty(connStatStr)) { + connector = "+"; + } + + return regStr + connector + connStatStr; + } + private final String buildCdmaInfoString(CellInfoCdma ci) { CellIdentityCdma cidCdma = ci.getCellIdentity(); CellSignalStrengthCdma ssCdma = ci.getCellSignalStrength(); return String.format("%-3.3s %-5.5s %-5.5s %-5.5s %-6.6s %-6.6s %-6.6s %-6.6s %-5.5s", - ci.isRegistered() ? "S " : " ", + getConnectionStatusString(ci), getCellInfoDisplayString(cidCdma.getSystemId()), getCellInfoDisplayString(cidCdma.getNetworkId()), getCellInfoDisplayString(cidCdma.getBasestationId()), @@ -694,7 +717,7 @@ public class RadioInfo extends Activity { CellSignalStrengthGsm ssGsm = ci.getCellSignalStrength(); return String.format("%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-6.6s %-4.4s %-4.4s\n", - ci.isRegistered() ? "S " : " ", + getConnectionStatusString(ci), getCellInfoDisplayString(cidGsm.getMcc()), getCellInfoDisplayString(cidGsm.getMnc()), getCellInfoDisplayString(cidGsm.getLac()), @@ -709,14 +732,15 @@ public class RadioInfo extends Activity { CellSignalStrengthLte ssLte = ci.getCellSignalStrength(); return String.format( - "%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-3.3s %-6.6s %-4.4s %-4.4s %-2.2s\n", - ci.isRegistered() ? "S " : " ", + "%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-3.3s %-6.6s %-2.2s %-4.4s %-4.4s %-2.2s\n", + getConnectionStatusString(ci), getCellInfoDisplayString(cidLte.getMcc()), getCellInfoDisplayString(cidLte.getMnc()), getCellInfoDisplayString(cidLte.getTac()), getCellInfoDisplayString(cidLte.getCi()), getCellInfoDisplayString(cidLte.getPci()), getCellInfoDisplayString(cidLte.getEarfcn()), + getCellInfoDisplayString(cidLte.getBandwidth()), getCellInfoDisplayString(ssLte.getDbm()), getCellInfoDisplayString(ssLte.getRsrq()), getCellInfoDisplayString(ssLte.getTimingAdvance())); @@ -727,7 +751,7 @@ public class RadioInfo extends Activity { CellSignalStrengthWcdma ssWcdma = ci.getCellSignalStrength(); return String.format("%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-6.6s %-3.3s %-4.4s\n", - ci.isRegistered() ? "S " : " ", + getConnectionStatusString(ci), getCellInfoDisplayString(cidWcdma.getMcc()), getCellInfoDisplayString(cidWcdma.getMnc()), getCellInfoDisplayString(cidWcdma.getLac()), @@ -759,17 +783,21 @@ public class RadioInfo extends Activity { } if (lteCells.length() != 0) { value += String.format( - "LTE\n%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-3.3s %-6.6s %-4.4s %-4.4s %-2.2s\n", - "SRV", "MCC", "MNC", "TAC", "CID", "PCI", "EARFCN", "RSRP", "RSRQ", "TA"); + "LTE\n%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-3.3s" + + " %-6.6s %-2.2s %-4.4s %-4.4s %-2.2s\n", + "SRV", "MCC", "MNC", "TAC", "CID", "PCI", + "EARFCN", "BW", "RSRP", "RSRQ", "TA"); value += lteCells.toString(); } if (wcdmaCells.length() != 0) { - value += String.format("WCDMA\n%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-6.6s %-3.3s %-4.4s\n", + value += String.format( + "WCDMA\n%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-6.6s %-3.3s %-4.4s\n", "SRV", "MCC", "MNC", "LAC", "CID", "UARFCN", "PSC", "RSCP"); value += wcdmaCells.toString(); } if (gsmCells.length() != 0) { - value += String.format("GSM\n%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-6.6s %-4.4s %-4.4s\n", + value += String.format( + "GSM\n%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-6.6s %-4.4s %-4.4s\n", "SRV", "MCC", "MNC", "LAC", "CID", "ARFCN", "BSIC", "RSSI"); value += gsmCells.toString(); } From 433ca4427ca8d3b349b9997f3dca03f96c5739cf Mon Sep 17 00:00:00 2001 From: Nathan Harold Date: Mon, 23 Apr 2018 18:20:43 -0700 Subject: [PATCH 2/3] [Telephony Debug Menu] Add Physical Channel Config Add a field to display the PhyChanConfig and register for this event as part of the PhoneStateListener. Bug: 78791811 Test: manual Change-Id: Ic038aa65655f8efa98bf1d6388e7c61761d2eb4a --- res/layout/radio_info.xml | 12 +++++++++++ res/values/strings.xml | 2 ++ src/com/android/settings/RadioInfo.java | 27 ++++++++++++++++++++++++- 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/res/layout/radio_info.xml b/res/layout/radio_info.xml index 502505c0aee..bc7671a72aa 100644 --- a/res/layout/radio_info.xml +++ b/res/layout/radio_info.xml @@ -91,6 +91,18 @@ + + + + + + + + + Neighbor Cell Info (deprecated): + LTE Physical Channel Configuration: + Cell Info Refresh Rate: All Cell Measurement Info: diff --git a/src/com/android/settings/RadioInfo.java b/src/com/android/settings/RadioInfo.java index 91d319c42ec..ec683f7ec2f 100644 --- a/src/com/android/settings/RadioInfo.java +++ b/src/com/android/settings/RadioInfo.java @@ -52,6 +52,7 @@ import android.telephony.DataConnectionRealTimeInfo; import android.telephony.NeighboringCellInfo; import android.telephony.PreciseCallState; import android.telephony.PhoneStateListener; +import android.telephony.PhysicalChannelConfig; import android.telephony.ServiceState; import android.telephony.SignalStrength; import android.telephony.SubscriptionManager; @@ -194,6 +195,7 @@ public class RadioInfo extends Activity { private TextView mPingHostnameV4; private TextView mPingHostnameV6; private TextView mHttpClientTest; + private TextView mPhyChanConfig; private TextView dnsCheckState; private EditText smsc; private Switch radioPowerOnSwitch; @@ -296,8 +298,29 @@ public class RadioInfo extends Activity { updateNetworkType(); updateImsProvisionedState(); } + + @Override + public void onPhysicalChannelConfigurationChanged( + List configs) { + updatePhysicalChannelConfiguration(configs); + } + }; + private void updatePhysicalChannelConfiguration(List configs) { + StringBuilder sb = new StringBuilder(); + String div = ""; + sb.append("{"); + if (configs != null) { + for(PhysicalChannelConfig c : configs) { + sb.append(div).append(c); + div = ","; + } + } + sb.append("}"); + mPhyChanConfig.setText(sb.toString()); + } + private void updatePreferredNetworkType(int type) { if (type >= mPreferredNetworkLabels.length || type < 0) { log("EVENT_QUERY_PREFERRED_TYPE_DONE: unknown " + @@ -400,6 +423,8 @@ public class RadioInfo extends Activity { mPingHostnameV6 = (TextView) findViewById(R.id.pingHostnameV6); mHttpClientTest = (TextView) findViewById(R.id.httpClientTest); + mPhyChanConfig = (TextView) findViewById(R.id.phy_chan_config); + preferredNetworkType = (Spinner) findViewById(R.id.preferredNetworkType); ArrayAdapter adapter = new ArrayAdapter (this, android.R.layout.simple_spinner_item, mPreferredNetworkLabels); @@ -502,7 +527,7 @@ public class RadioInfo extends Activity { | PhoneStateListener.LISTEN_CELL_INFO | PhoneStateListener.LISTEN_SERVICE_STATE | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS - | PhoneStateListener.LISTEN_DATA_CONNECTION_REAL_TIME_INFO); + | PhoneStateListener.LISTEN_PHYSICAL_CHANNEL_CONFIGURATION); smsc.clearFocus(); } From f10ea32d5572e3e65057532ddb1b3687f5a9f77e Mon Sep 17 00:00:00 2001 From: Nathan Harold Date: Tue, 24 Apr 2018 13:31:07 -0700 Subject: [PATCH 3/3] [Telephony Debug Menu] Add Link Capacity Estimate Register for the Link capacity estimate for the cellular default data connection and report it in the debug menu. Bug: 78791811 Test: manual Change-Id: I73d945dfa192873936107902e0de6d58fc69059b --- res/layout/radio_info.xml | 12 ++++++++ res/values/strings.xml | 4 +++ src/com/android/settings/RadioInfo.java | 40 +++++++++++++++++++++++++ 3 files changed, 56 insertions(+) diff --git a/res/layout/radio_info.xml b/res/layout/radio_info.xml index bc7671a72aa..0ec1f108cb8 100644 --- a/res/layout/radio_info.xml +++ b/res/layout/radio_info.xml @@ -91,6 +91,18 @@ + + + + + + + + + + + + diff --git a/res/values/strings.xml b/res/values/strings.xml index c203fe8b143..49c29125336 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -471,6 +471,10 @@ "PAC URL: " + + DL Bandwidth (kbps): + + UL Bandwidth (kbps): Cell Location Info (deprecated): diff --git a/src/com/android/settings/RadioInfo.java b/src/com/android/settings/RadioInfo.java index ec683f7ec2f..170db1695b4 100644 --- a/src/com/android/settings/RadioInfo.java +++ b/src/com/android/settings/RadioInfo.java @@ -16,6 +16,8 @@ package com.android.settings; +import static android.net.ConnectivityManager.NetworkCallback; + import android.app.Activity; import android.app.AlertDialog; import android.app.Dialog; @@ -27,6 +29,10 @@ import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.content.res.Resources; import android.graphics.Typeface; +import android.net.ConnectivityManager; +import android.net.Network; +import android.net.NetworkCapabilities; +import android.net.NetworkRequest; import android.net.TrafficStats; import android.net.Uri; import android.os.AsyncResult; @@ -197,6 +203,8 @@ public class RadioInfo extends Activity { private TextView mHttpClientTest; private TextView mPhyChanConfig; private TextView dnsCheckState; + private TextView mDownlinkKbps; + private TextView mUplinkKbps; private EditText smsc; private Switch radioPowerOnSwitch; private Button cellInfoRefreshRateButton; @@ -214,6 +222,7 @@ public class RadioInfo extends Activity { private Spinner preferredNetworkType; private Spinner cellInfoRefreshRateSpinner; + private ConnectivityManager mConnectivityManager; private TelephonyManager mTelephonyManager; private ImsManager mImsManager = null; private Phone phone = null; @@ -231,6 +240,19 @@ public class RadioInfo extends Activity { private int mPreferredNetworkTypeResult; private int mCellInfoRefreshRateIndex; + private final NetworkRequest mDefaultNetworkRequest = new NetworkRequest.Builder() + .addTransportType(NetworkCapabilities.TRANSPORT_CELLULAR) + .addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET) + .build(); + + private final NetworkCallback mNetworkCallback = new NetworkCallback() { + public void onCapabilitiesChanged(Network n, NetworkCapabilities nc) { + int dlbw = nc.getLinkDownstreamBandwidthKbps(); + int ulbw = nc.getLinkUpstreamBandwidthKbps(); + updateBandwidths(dlbw, ulbw); + } + }; + private final PhoneStateListener mPhoneStateListener = new PhoneStateListener() { @Override public void onDataConnectionStateChanged(int state) { @@ -389,6 +411,7 @@ public class RadioInfo extends Activity { log("Started onCreate"); mTelephonyManager = (TelephonyManager)getSystemService(TELEPHONY_SERVICE); + mConnectivityManager = (ConnectivityManager)getSystemService(CONNECTIVITY_SERVICE); phone = PhoneFactory.getDefaultPhone(); //TODO: Need to update this if the default phoneId changes? @@ -444,6 +467,10 @@ public class RadioInfo extends Activity { radioPowerOnSwitch = (Switch) findViewById(R.id.radio_power); + mDownlinkKbps = (TextView) findViewById(R.id.dl_kbps); + mUplinkKbps = (TextView) findViewById(R.id.ul_kbps); + updateBandwidths(0, 0); + pingTestButton = (Button) findViewById(R.id.ping_test); pingTestButton.setOnClickListener(mPingButtonHandler); updateSmscButton = (Button) findViewById(R.id.update_smsc); @@ -529,6 +556,9 @@ public class RadioInfo extends Activity { | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS | PhoneStateListener.LISTEN_PHYSICAL_CHANNEL_CONFIGURATION); + mConnectivityManager.registerNetworkCallback( + mDefaultNetworkRequest, mNetworkCallback, mHandler); + smsc.clearFocus(); } @@ -540,6 +570,8 @@ public class RadioInfo extends Activity { mTelephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE); mTelephonyManager.setCellInfoListRate(CELL_INFO_LIST_RATE_DISABLED); + mConnectivityManager.unregisterNetworkCallback(mNetworkCallback); + } private void restoreFromBundle(Bundle b) { @@ -619,6 +651,14 @@ public class RadioInfo extends Activity { "0.0.0.0 allowed" :"0.0.0.0 not allowed"); } + private void updateBandwidths(int dlbw, int ulbw) { + dlbw = (dlbw < 0 || dlbw == Integer.MAX_VALUE) ? -1 : dlbw; + ulbw = (ulbw < 0 || ulbw == Integer.MAX_VALUE) ? -1 : ulbw; + mDownlinkKbps.setText(String.format("%-5d", dlbw)); + mUplinkKbps.setText(String.format("%-5d", ulbw)); + } + + private final void updateSignalStrength(SignalStrength signalStrength) { Resources r = getResources();