diff options
author | Roshan Pius <rpius@google.com> | 2017-07-28 02:51:52 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2017-07-28 02:51:52 +0000 |
commit | 78f769ee241ce5d4a0e592ef9fb0ec63054592bc (patch) | |
tree | a2fb85f0a81ae561e639ebce1b332cc31999bf50 /service | |
parent | 31a9e140105fe0c763fc72dd075d7bd876f17989 (diff) | |
parent | 3673d53dea03d18e5b28ce248b9911f81e3f8638 (diff) |
Merge "wifi(framework): Modify the SAR power levels interface" into oc-dr1-dev
am: 3673d53dea
Change-Id: I30fde20315fbdacdf64bce45d159db70ac932da8
Diffstat (limited to 'service')
3 files changed, 48 insertions, 58 deletions
diff --git a/service/java/com/android/server/wifi/WifiNative.java b/service/java/com/android/server/wifi/WifiNative.java index c0ec8b76d..973b659d2 100644 --- a/service/java/com/android/server/wifi/WifiNative.java +++ b/service/java/com/android/server/wifi/WifiNative.java @@ -1684,24 +1684,21 @@ public class WifiNative { } /** - * Set the TX power limit. - * Primarily used for meeting SAR requirements during voice calls. - * - * @param powerLevelInDbm Power level to set in dBm. - * @return true for success; false for failure or if the HAL version does not support this API. + * Tx power level scenarios that can be selected. */ - public boolean setTxPowerLimit(int powerLevelInDbm) { - return mWifiVendorHal.setTxPowerLimit(powerLevelInDbm); - } + public static final int TX_POWER_SCENARIO_NORMAL = 0; + public static final int TX_POWER_SCENARIO_VOICE_CALL = 1; /** - * Reset the TX power limit. + * Select one of the pre-configured TX power level scenarios or reset it back to normal. * Primarily used for meeting SAR requirements during voice calls. * + * @param scenario Should be one {@link #TX_POWER_SCENARIO_NORMAL} or + * {@link #TX_POWER_SCENARIO_VOICE_CALL}. * @return true for success; false for failure or if the HAL version does not support this API. */ - public boolean resetTxPowerLimit() { - return mWifiVendorHal.resetTxPowerLimit(); + public boolean selectTxPowerScenario(int scenario) { + return mWifiVendorHal.selectTxPowerScenario(scenario); } /******************************************************** diff --git a/service/java/com/android/server/wifi/WifiStateMachine.java b/service/java/com/android/server/wifi/WifiStateMachine.java index eec0996c1..1c07c30af 100644 --- a/service/java/com/android/server/wifi/WifiStateMachine.java +++ b/service/java/com/android/server/wifi/WifiStateMachine.java @@ -733,10 +733,7 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss private static final int CMD_DIAGS_CONNECT_TIMEOUT = BASE + 252; /* Used to set the tx power limit for SAR during the start of a phone call. */ - private static final int CMD_SET_SAR_TX_POWER_LIMIT = BASE + 253; - - /* Used to reset the tx power limit for SAR at end of a phone call. */ - private static final int CMD_RESET_SAR_TX_POWER_LIMIT = BASE + 254; + private static final int CMD_SELECT_TX_POWER_SCENARIO = BASE + 253; // For message logging. private static final Class[] sMessageClasses = { @@ -804,7 +801,6 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss private final boolean mEnableChipWakeUpWhenAssociated; private final boolean mEnableRssiPollWhenAssociated; private final boolean mEnableVoiceCallSarTxPowerLimit; - private final int mVoiceCallSarTxPowerLimitInDbm; int mRunningBeaconCount = 0; @@ -1051,8 +1047,6 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss R.bool.config_wifi_enable_disconnection_debounce); mEnableVoiceCallSarTxPowerLimit = mContext.getResources().getBoolean( R.bool.config_wifi_framework_enable_voice_call_sar_tx_power_limit); - mVoiceCallSarTxPowerLimitInDbm = mContext.getResources().getInteger( - R.integer.config_wifi_framework_voice_call_sar_tx_power_limit_in_dbm); mEnableChipWakeUpWhenAssociated = true; mEnableRssiPollWhenAssociated = true; @@ -3786,9 +3780,11 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss public void onCallStateChanged(int state, String incomingNumber) { if (mEnableVoiceCallSarTxPowerLimit) { if (state == CALL_STATE_OFFHOOK) { - sendMessage(CMD_SET_SAR_TX_POWER_LIMIT, mVoiceCallSarTxPowerLimitInDbm); + sendMessage(CMD_SELECT_TX_POWER_SCENARIO, + WifiNative.TX_POWER_SCENARIO_VOICE_CALL); } else if (state == CALL_STATE_IDLE) { - sendMessage(CMD_RESET_SAR_TX_POWER_LIMIT); + sendMessage(CMD_SELECT_TX_POWER_SCENARIO, + WifiNative.TX_POWER_SCENARIO_NORMAL); } } } @@ -3946,8 +3942,7 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss case CMD_ROAM_WATCHDOG_TIMER: case CMD_DISABLE_P2P_WATCHDOG_TIMER: case CMD_DISABLE_EPHEMERAL_NETWORK: - case CMD_SET_SAR_TX_POWER_LIMIT: - case CMD_RESET_SAR_TX_POWER_LIMIT: + case CMD_SELECT_TX_POWER_SCENARIO: messageHandlingStatus = MESSAGE_HANDLING_STATUS_DISCARD; break; case CMD_SET_SUSPEND_OPT_ENABLED: @@ -4340,9 +4335,11 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss // appropriately. if (mEnableVoiceCallSarTxPowerLimit) { if (getTelephonyManager().isOffhook()) { - sendMessage(CMD_SET_SAR_TX_POWER_LIMIT, mVoiceCallSarTxPowerLimitInDbm); - } else if (getTelephonyManager().isIdle()) { - sendMessage(CMD_RESET_SAR_TX_POWER_LIMIT); + sendMessage(CMD_SELECT_TX_POWER_SCENARIO, + WifiNative.TX_POWER_SCENARIO_VOICE_CALL); + } else { + sendMessage(CMD_SELECT_TX_POWER_SCENARIO, + WifiNative.TX_POWER_SCENARIO_NORMAL); } } @@ -4527,17 +4524,11 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss mWifiConnectivityManager.forceConnectivityScan(); } break; - case CMD_SET_SAR_TX_POWER_LIMIT: - int txPowerLevelInDbm = message.arg1; - logd("Setting Tx power limit to " + txPowerLevelInDbm); - if (!mWifiNative.setTxPowerLimit(txPowerLevelInDbm)) { - loge("Failed to set TX power limit"); - } - break; - case CMD_RESET_SAR_TX_POWER_LIMIT: - logd("Resetting Tx power limit"); - if (!mWifiNative.resetTxPowerLimit()) { - loge("Failed to reset TX power limit"); + case CMD_SELECT_TX_POWER_SCENARIO: + int txPowerScenario = message.arg1; + logd("Setting Tx power scenario to " + txPowerScenario); + if (!mWifiNative.selectTxPowerScenario(txPowerScenario)) { + loge("Failed to set TX power scenario"); } break; default: diff --git a/service/java/com/android/server/wifi/WifiVendorHal.java b/service/java/com/android/server/wifi/WifiVendorHal.java index b434f519e..12674aa27 100644 --- a/service/java/com/android/server/wifi/WifiVendorHal.java +++ b/service/java/com/android/server/wifi/WifiVendorHal.java @@ -2370,40 +2370,42 @@ public class WifiVendorHal { return android.hardware.wifi.V1_1.IWifiChip.castFrom(mIWifiChip); } - /** - * Set the TX power limit. - * Primarily used for meeting SAR requirements during voice calls. - * - * @param powerLevelInDbm Power level to set in dBm. - * @return true for success; false for failure or if the HAL version does not support this API. - */ - public boolean setTxPowerLimit(int powerLevelInDbm) { - synchronized (sLock) { - try { - android.hardware.wifi.V1_1.IWifiChip iWifiChipV11 = getWifiChipForV1_1Mockable(); - if (iWifiChipV11 == null) return boolResult(false); - WifiStatus status = iWifiChipV11.setTxPowerLimit(powerLevelInDbm); - if (!ok(status)) return false; - } catch (RemoteException e) { - handleRemoteException(e); - return false; - } - return true; + private int frameworkToHalTxPowerScenario(int scenario) { + switch (scenario) { + case WifiNative.TX_POWER_SCENARIO_VOICE_CALL: + return android.hardware.wifi.V1_1.IWifiChip.TxPowerScenario.VOICE_CALL; + default: + throw new IllegalArgumentException("bad scenario: " + scenario); } } /** - * Reset the TX power limit. + * Select one of the pre-configured TX power level scenarios or reset it back to normal. * Primarily used for meeting SAR requirements during voice calls. * + * @param scenario Should be one {@link WifiNative#TX_POWER_SCENARIO_NORMAL} or + * {@link WifiNative#TX_POWER_SCENARIO_VOICE_CALL}. * @return true for success; false for failure or if the HAL version does not support this API. */ - public boolean resetTxPowerLimit() { + public boolean selectTxPowerScenario(int scenario) { synchronized (sLock) { try { android.hardware.wifi.V1_1.IWifiChip iWifiChipV11 = getWifiChipForV1_1Mockable(); if (iWifiChipV11 == null) return boolResult(false); - WifiStatus status = iWifiChipV11.resetTxPowerLimit(); + WifiStatus status; + if (scenario != WifiNative.TX_POWER_SCENARIO_NORMAL) { + int halScenario; + try { + halScenario = frameworkToHalTxPowerScenario(scenario); + } catch (IllegalArgumentException e) { + mLog.err("Illegal argument for select tx power scenario") + .c(e.toString()).flush(); + return false; + } + status = iWifiChipV11.selectTxPowerScenario(halScenario); + } else { + status = iWifiChipV11.resetTxPowerScenario(); + } if (!ok(status)) return false; } catch (RemoteException e) { handleRemoteException(e); |