From 0ebd13f268eaca16e396089983475674620632f3 Mon Sep 17 00:00:00 2001 From: Etan Cohen Date: Tue, 10 Jul 2018 08:47:36 -0700 Subject: [RTT] Recreate RTT controller when HAL indicates it is invalid When there is a HAL mode transition the RTT controller is destroyed. Mode transition is STA - SAP and back transitions for non-DBS devices. Modification to allow framework to detect when the controller is currently invalid and try to recreate it. Will allow recovery for non-DBS devices: otherwise RTT would only recover when Wi-Fi is toggled. Note: not a full solution since the availability APIs (broadcast + API) do not perform correctly in such transitions. That fix will be deeper and require HalDeviceManager mods. Bug: 111218083 Test: (new) unit test Test: new ACTS - RangeApSupporting11McTest:test_rtt_in_and_after_softap_mode Change-Id: I6d28ef7a50b02fe42e23b9172621bd83452658f1 (cherry picked from commit dfa13f1f48895759f77e5522e9c106765de327c8) --- .../java/com/android/server/wifi/rtt/RttNative.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'service') diff --git a/service/java/com/android/server/wifi/rtt/RttNative.java b/service/java/com/android/server/wifi/rtt/RttNative.java index accd1a2f8..34fd2e3e7 100644 --- a/service/java/com/android/server/wifi/rtt/RttNative.java +++ b/service/java/com/android/server/wifi/rtt/RttNative.java @@ -166,6 +166,11 @@ public class RttNative extends IWifiRttControllerEventCallback.Stub { */ public boolean rangeRequest(int cmdId, RangingRequest request, boolean isCalledFromPrivilegedContext) { + return rangeRequestInternal(cmdId, request, isCalledFromPrivilegedContext, true); + } + + private boolean rangeRequestInternal(int cmdId, RangingRequest request, + boolean isCalledFromPrivilegedContext, boolean tryToReinitIfNecessary) { if (mDbg) { Log.v(TAG, "rangeRequest: cmdId=" + cmdId + ", # of requests=" + request.mRttPeers.size()); @@ -175,6 +180,11 @@ public class RttNative extends IWifiRttControllerEventCallback.Stub { synchronized (mLock) { if (!isReady()) { Log.e(TAG, "rangeRequest: RttController is null"); + if (tryToReinitIfNecessary) { + updateController(); + return rangeRequestInternal(cmdId, request, isCalledFromPrivilegedContext, + false); + } return false; } @@ -192,6 +202,14 @@ public class RttNative extends IWifiRttControllerEventCallback.Stub { try { WifiStatus status = mIWifiRttController.rangeRequest(cmdId, rttConfig); + if (status.code == WifiStatusCode.ERROR_WIFI_RTT_CONTROLLER_INVALID + && tryToReinitIfNecessary) { + Log.d(TAG, "rangeRequest: RTT controller invalidated from under us - reinit!"); + mIWifiRttController = null; + updateController(); + return rangeRequestInternal(cmdId, request, isCalledFromPrivilegedContext, + false); + } if (status.code != WifiStatusCode.SUCCESS) { Log.e(TAG, "rangeRequest: cannot issue range request -- code=" + status.code); return false; -- cgit v1.2.3