Offload HAL Service: Reset Nano app upon Error

Offload HAL service reports all errors to the client. To bring Wifi Nano
app to a known state, also send a RESET command to the Nano app.

Bug: 32842314
Test: VTS
Change-Id: Ie5834b80e545e9099e3492b0354fefc2bc82ef8c
This commit is contained in:
Sohani Rao
2017-07-28 12:39:15 -07:00
parent 137a0c6542
commit f82c395cfc
2 changed files with 25 additions and 8 deletions

View File

@@ -93,6 +93,17 @@ OffloadStatus OffloadServer::subscribeScanResults(uint32_t delayMs) {
return createOffloadStatus(OffloadStatusCode::OK);
}
void OffloadServer::resetNanoApp() {
LOG(INFO) << "resetting Nano app";
if (!mChreInterface->isConnected()) {
LOG(WARNING) << "Unable to reset nano app, not connected";
return;
}
if (!mChreInterface->sendCommandToApp(wifi_offload::HostMessageType::HOST_CMD_RESET, {})) {
LOG(ERROR) << "Unable to send Reset command to Nano app";
}
}
bool OffloadServer::unsubscribeScanResults() {
LOG(INFO) << "unsubscribeScanResults";
if (!mChreInterface->isConnected()) {
@@ -125,7 +136,10 @@ void OffloadServer::clearEventCallback() {
LOG(INFO) << "Event callback cleared";
}
void OffloadServer::invokeErrorCallback(const OffloadStatus& status) {
void OffloadServer::invokeErrorCallbackAndResetIfNeeded(const OffloadStatus& status) {
if (status.code != OffloadStatusCode::OK) {
resetNanoApp();
}
std::lock_guard<std::mutex> lock(mOffloadLock);
if (mEventCallback != nullptr) {
mEventCallback->onError(status);
@@ -144,12 +158,13 @@ void ChreInterfaceCallbacksImpl::handleConnectionEvents(
case ChreInterfaceCallbacks::ConnectionEvent::DISCONNECTED:
case ChreInterfaceCallbacks::ConnectionEvent::CONNECTION_ABORT: {
LOG(ERROR) << "Connection to socket lost";
mServer->invokeErrorCallback(
mServer->invokeErrorCallbackAndResetIfNeeded(
createOffloadStatus(OffloadStatusCode::NO_CONNECTION, "Connection to socket lost"));
} break;
case ChreInterfaceCallbacks::ConnectionEvent::CONNECTED: {
LOG(INFO) << "Connected to socket";
mServer->invokeErrorCallback(createOffloadStatus(OffloadStatusCode::OK));
mServer->invokeErrorCallbackAndResetIfNeeded(
createOffloadStatus(OffloadStatusCode::OK));
} break;
default:
LOG(WARNING) << "Invalid connection event received " << (int)event;
@@ -162,13 +177,13 @@ void OffloadServer::handleScanResult(const std::vector<uint8_t>& message) {
std::vector<ScanResult> hidlScanResults;
std::string errorMessage;
if (!wifi_offload::fbs::Deserialize((uint8_t*)message.data(), message.size(), &scanResults)) {
invokeErrorCallback(
invokeErrorCallbackAndResetIfNeeded(
createOffloadStatus(OffloadStatusCode::ERROR, "Cannot deserialize scan results"));
return;
}
if (!offload_utils::ToHidlScanResults(scanResults, &hidlScanResults)) {
invokeErrorCallback(createOffloadStatus(OffloadStatusCode::ERROR,
"Cannot convert scan results to HIDL format"));
invokeErrorCallbackAndResetIfNeeded(createOffloadStatus(
OffloadStatusCode::ERROR, "Cannot convert scan results to HIDL format"));
return;
}
{
@@ -213,7 +228,7 @@ void ChreInterfaceCallbacksImpl::handleMessage(uint32_t messageType,
{
std::string errorMessage;
if (offload_utils::ToHidlErrorMessage(message[0], &errorMessage)) {
mServer->invokeErrorCallback(
mServer->invokeErrorCallbackAndResetIfNeeded(
createOffloadStatus(OffloadStatusCode::ERROR, errorMessage));
}
}

View File

@@ -41,9 +41,11 @@ class OffloadServer {
void clearEventCallback();
private:
void invokeErrorCallback(const android::hardware::wifi::offload::V1_0::OffloadStatus& status);
void invokeErrorCallbackAndResetIfNeeded(
const android::hardware::wifi::offload::V1_0::OffloadStatus& status);
void handleScanResult(const std::vector<uint8_t>& message);
void handleScanStats(const std::vector<uint8_t>& message);
void resetNanoApp();
ScanStats mScanStats;
std::mutex mScanStatsLock;