diff options
author | TreeHugger Robot <treehugger-gerrit@google.com> | 2018-06-28 06:28:43 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2018-06-28 06:28:43 +0000 |
commit | f1fb26b5936d952a9a678e31a6ffe093ef9a2138 (patch) | |
tree | ea7aa6a938a32c69d5563a3656b4300eb7350524 /src | |
parent | ad387b76244e41de22ae32c56177ede5619ddc38 (diff) | |
parent | 3bb8f7841c7427a3dc2d0217ca7482bb8b0296fe (diff) | |
download | android_packages_apps_Bluetooth-f1fb26b5936d952a9a678e31a6ffe093ef9a2138.tar.gz android_packages_apps_Bluetooth-f1fb26b5936d952a9a678e31a6ffe093ef9a2138.tar.bz2 android_packages_apps_Bluetooth-f1fb26b5936d952a9a678e31a6ffe093ef9a2138.zip |
Merge "HFP: Use SignalStrength#getLevel() to get signal level" into pi-dev
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/bluetooth/hfp/HeadsetPhoneState.java | 122 |
1 files changed, 3 insertions, 119 deletions
diff --git a/src/com/android/bluetooth/hfp/HeadsetPhoneState.java b/src/com/android/bluetooth/hfp/HeadsetPhoneState.java index a0914384f..bcf123cd6 100644 --- a/src/com/android/bluetooth/hfp/HeadsetPhoneState.java +++ b/src/com/android/bluetooth/hfp/HeadsetPhoneState.java @@ -323,134 +323,18 @@ public class HeadsetPhoneState { @Override public void onSignalStrengthsChanged(SignalStrength signalStrength) { - int prevSignal = mCindSignal; if (mCindService == HeadsetHalConstants.NETWORK_STATE_NOT_AVAILABLE) { mCindSignal = 0; - } else if (signalStrength.isGsm()) { - mCindSignal = signalStrength.getLteLevel(); - if (mCindSignal == SignalStrength.SIGNAL_STRENGTH_NONE_OR_UNKNOWN) { - mCindSignal = gsmAsuToSignal(signalStrength); - } else { - // SignalStrength#getLteLevel returns the scale from 0-4 - // Bluetooth signal scales at 0-5 - // Let's match up the larger side - mCindSignal++; - } } else { - mCindSignal = cdmaDbmEcioToSignal(signalStrength); + mCindSignal = signalStrength.getLevel() + 1; } - - // network signal strength is scaled to BT 1-5 levels. + // +CIND "signal" indicator is always between 0 to 5 + mCindSignal = Integer.max(Integer.min(mCindSignal, 5), 0); // This results in a lot of duplicate messages, hence this check if (prevSignal != mCindSignal) { sendDeviceStateChanged(); } } - - /* convert [0,31] ASU signal strength to the [0,5] expected by - * bluetooth devices. Scale is similar to status bar policy - */ - private int gsmAsuToSignal(SignalStrength signalStrength) { - int asu = signalStrength.getGsmSignalStrength(); - if (asu == 99) { - return 0; - } else if (asu >= 16) { - return 5; - } else if (asu >= 8) { - return 4; - } else if (asu >= 4) { - return 3; - } else if (asu >= 2) { - return 2; - } else if (asu >= 1) { - return 1; - } else { - return 0; - } - } - - /** - * Convert the cdma / evdo db levels to appropriate icon level. - * The scale is similar to the one used in status bar policy. - * - * @param signalStrength signal strength level - * @return the icon level for remote device - */ - private int cdmaDbmEcioToSignal(SignalStrength signalStrength) { - int levelDbm = 0; - int levelEcio = 0; - int cdmaIconLevel = 0; - int evdoIconLevel = 0; - int cdmaDbm = signalStrength.getCdmaDbm(); - int cdmaEcio = signalStrength.getCdmaEcio(); - - if (cdmaDbm >= -75) { - levelDbm = 4; - } else if (cdmaDbm >= -85) { - levelDbm = 3; - } else if (cdmaDbm >= -95) { - levelDbm = 2; - } else if (cdmaDbm >= -100) { - levelDbm = 1; - } else { - levelDbm = 0; - } - - // Ec/Io are in dB*10 - if (cdmaEcio >= -90) { - levelEcio = 4; - } else if (cdmaEcio >= -110) { - levelEcio = 3; - } else if (cdmaEcio >= -130) { - levelEcio = 2; - } else if (cdmaEcio >= -150) { - levelEcio = 1; - } else { - levelEcio = 0; - } - - cdmaIconLevel = (levelDbm < levelEcio) ? levelDbm : levelEcio; - - // STOPSHIP: Change back to getRilVoiceRadioTechnology - if (mServiceState != null && ( - mServiceState.getRadioTechnology() == ServiceState.RIL_RADIO_TECHNOLOGY_EVDO_0 - || mServiceState.getRadioTechnology() - == ServiceState.RIL_RADIO_TECHNOLOGY_EVDO_A)) { - int evdoEcio = signalStrength.getEvdoEcio(); - int evdoSnr = signalStrength.getEvdoSnr(); - int levelEvdoEcio = 0; - int levelEvdoSnr = 0; - - // Ec/Io are in dB*10 - if (evdoEcio >= -650) { - levelEvdoEcio = 4; - } else if (evdoEcio >= -750) { - levelEvdoEcio = 3; - } else if (evdoEcio >= -900) { - levelEvdoEcio = 2; - } else if (evdoEcio >= -1050) { - levelEvdoEcio = 1; - } else { - levelEvdoEcio = 0; - } - - if (evdoSnr > 7) { - levelEvdoSnr = 4; - } else if (evdoSnr > 5) { - levelEvdoSnr = 3; - } else if (evdoSnr > 3) { - levelEvdoSnr = 2; - } else if (evdoSnr > 1) { - levelEvdoSnr = 1; - } else { - levelEvdoSnr = 0; - } - - evdoIconLevel = (levelEvdoEcio < levelEvdoSnr) ? levelEvdoEcio : levelEvdoSnr; - } - // TODO(): There is a bug open regarding what should be sent. - return (cdmaIconLevel > evdoIconLevel) ? cdmaIconLevel : evdoIconLevel; - } } } |