mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 11:36:00 +00:00
Modify HAL for Aware suspension mode
- Add an event to know the device is suspended - More status code - Add pub_sub_id in the datapath request to build the relationship Bug: 247913151 Test: build Change-Id: I77733c1bca821b77fdab7ed1ed03c1e54c9373b2
This commit is contained in:
@@ -46,6 +46,7 @@ interface IWifiNanIfaceEventCallback {
|
||||
oneway void eventPublishTerminated(in byte sessionId, in android.hardware.wifi.NanStatus status);
|
||||
oneway void eventSubscribeTerminated(in byte sessionId, in android.hardware.wifi.NanStatus status);
|
||||
oneway void eventTransmitFollowup(in char id, in android.hardware.wifi.NanStatus status);
|
||||
oneway void eventSuspensionModeChanged(in android.hardware.wifi.NanSuspensionModeChangeInd event);
|
||||
oneway void notifyCapabilitiesResponse(in char id, in android.hardware.wifi.NanStatus status, in android.hardware.wifi.NanCapabilities capabilities);
|
||||
oneway void notifyConfigResponse(in char id, in android.hardware.wifi.NanStatus status);
|
||||
oneway void notifyCreateDataInterfaceResponse(in char id, in android.hardware.wifi.NanStatus status);
|
||||
|
||||
@@ -42,4 +42,5 @@ parcelable NanInitiateDataPathRequest {
|
||||
android.hardware.wifi.NanDataPathSecurityConfig securityConfig;
|
||||
byte[] appInfo;
|
||||
byte[] serviceNameOutOfBand;
|
||||
byte discoverySessionId;
|
||||
}
|
||||
|
||||
@@ -40,4 +40,5 @@ parcelable NanRespondToDataPathIndicationRequest {
|
||||
android.hardware.wifi.NanDataPathSecurityConfig securityConfig;
|
||||
byte[] appInfo;
|
||||
byte[] serviceNameOutOfBand;
|
||||
byte discoverySessionId;
|
||||
}
|
||||
|
||||
@@ -49,5 +49,7 @@ enum NanStatusCode {
|
||||
UNSUPPORTED_CONCURRENCY_NAN_DISABLED = 12,
|
||||
INVALID_PAIRING_ID = 13,
|
||||
INVALID_BOOTSTRAPPING_ID = 14,
|
||||
INVALID_STATE = 15,
|
||||
REDUNDANT_REQUEST = 15,
|
||||
NOT_SUPPORTED = 16,
|
||||
NO_CONNECTION = 17,
|
||||
}
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (C) 2023 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// This file is a snapshot of an AIDL file. Do not edit it manually. There are
|
||||
// two cases:
|
||||
// 1). this is a frozen version file - do not edit this in any case.
|
||||
// 2). this is a 'current' file. If you make a backwards compatible change to
|
||||
// the interface (from the latest frozen version), the build system will
|
||||
// prompt you to update this file with `m <name>-update-api`.
|
||||
//
|
||||
// You must not make a backward incompatible change to any AIDL file built
|
||||
// with the aidl_interface module type with versions property set. The module
|
||||
// type is used to build AIDL files in a way that they can be used across
|
||||
// independently updatable components of the system. If a device is shipped
|
||||
// with such a backward incompatible change, it has a high risk of breaking
|
||||
// later when a module using the interface is updated, e.g., Mainline modules.
|
||||
|
||||
package android.hardware.wifi;
|
||||
@VintfStability
|
||||
parcelable NanSuspensionModeChangeInd {
|
||||
boolean isSuspended;
|
||||
}
|
||||
@@ -28,7 +28,7 @@ import android.hardware.wifi.NanMatchInd;
|
||||
import android.hardware.wifi.NanPairingConfirmInd;
|
||||
import android.hardware.wifi.NanPairingRequestInd;
|
||||
import android.hardware.wifi.NanStatus;
|
||||
|
||||
import android.hardware.wifi.NanSuspensionModeChangeInd;
|
||||
/**
|
||||
* NAN Response and Asynchronous Event Callbacks.
|
||||
*
|
||||
@@ -140,6 +140,13 @@ oneway interface IWifiNanIfaceEventCallback {
|
||||
*/
|
||||
void eventTransmitFollowup(in char id, in NanStatus status);
|
||||
|
||||
/**
|
||||
* Callback indicating that device suspension mode status change
|
||||
*
|
||||
* @param event NanSuspensionModeChangeInd containing event details.
|
||||
*/
|
||||
void eventSuspensionModeChanged(in NanSuspensionModeChangeInd event);
|
||||
|
||||
/**
|
||||
* Callback invoked in response to a capability request
|
||||
* |IWifiNanIface.getCapabilitiesRequest|.
|
||||
|
||||
@@ -69,4 +69,9 @@ parcelable NanInitiateDataPathRequest {
|
||||
* NAN Spec: Appendix: Mapping pass-phrase to PMK for NCS-SK Cipher Suites
|
||||
*/
|
||||
byte[] serviceNameOutOfBand;
|
||||
/**
|
||||
* ID of an active publish or subscribe discovery session.
|
||||
* NAN Spec: Service Descriptor Attribute (SDA) / Instance ID
|
||||
*/
|
||||
byte discoverySessionId;
|
||||
}
|
||||
|
||||
@@ -58,4 +58,9 @@ parcelable NanRespondToDataPathIndicationRequest {
|
||||
* NAN Spec: Appendix: Mapping pass-phrase to PMK for NCS-SK Cipher Suites
|
||||
*/
|
||||
byte[] serviceNameOutOfBand;
|
||||
/**
|
||||
* ID of an active publish or subscribe discovery session.
|
||||
* NAN Spec: Service Descriptor Attribute (SDA) / Instance ID
|
||||
*/
|
||||
byte discoverySessionId;
|
||||
}
|
||||
|
||||
@@ -79,8 +79,16 @@ enum NanStatusCode {
|
||||
* If the bootstrapping id is invalid
|
||||
*/
|
||||
INVALID_BOOTSTRAPPING_ID = 14,
|
||||
/**
|
||||
* If the system is not in a valid state for the given request.
|
||||
/*
|
||||
* If same request is received again
|
||||
*/
|
||||
INVALID_STATE = 15
|
||||
REDUNDANT_REQUEST = 15,
|
||||
/*
|
||||
* If current request is not supported
|
||||
*/
|
||||
NOT_SUPPORTED = 16,
|
||||
/*
|
||||
* If no Wifi Aware connection is active
|
||||
*/
|
||||
NO_CONNECTION = 17
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright (C) 2023 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package android.hardware.wifi;
|
||||
|
||||
/**
|
||||
* Event indication that the device entered or exited the suspension mode
|
||||
*/
|
||||
@VintfStability
|
||||
parcelable NanSuspensionModeChangeInd {
|
||||
/**
|
||||
* Indication whether the device has entered or existed the NAN suspension mode(deep sleep)
|
||||
*/
|
||||
boolean isSuspended;
|
||||
}
|
||||
@@ -1420,6 +1420,12 @@ NanStatusCode convertLegacyNanStatusTypeToAidl(legacy_hal::NanStatusType type) {
|
||||
return NanStatusCode::INVALID_PAIRING_ID;
|
||||
case legacy_hal::NAN_STATUS_INVALID_BOOTSTRAPPING_ID:
|
||||
return NanStatusCode::INVALID_BOOTSTRAPPING_ID;
|
||||
case legacy_hal::NAN_STATUS_REDUNDANT_REQUEST:
|
||||
return NanStatusCode::REDUNDANT_REQUEST;
|
||||
case legacy_hal::NAN_STATUS_NOT_SUPPORTED:
|
||||
return NanStatusCode::NOT_SUPPORTED;
|
||||
case legacy_hal::NAN_STATUS_NO_CONNECTION:
|
||||
return NanStatusCode::NO_CONNECTION;
|
||||
}
|
||||
CHECK(false);
|
||||
}
|
||||
@@ -2090,6 +2096,7 @@ bool convertAidlNanDataPathInitiatorRequestToLegacy(
|
||||
return false;
|
||||
}
|
||||
memcpy(legacy_request->scid, aidl_request.securityConfig.scid.data(), legacy_request->scid_len);
|
||||
legacy_request->publish_subscribe_id = static_cast<uint8_t>(aidl_request.discoverySessionId);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -2171,6 +2178,7 @@ bool convertAidlNanDataPathIndicationResponseToLegacy(
|
||||
return false;
|
||||
}
|
||||
memcpy(legacy_request->scid, aidl_request.securityConfig.scid.data(), legacy_request->scid_len);
|
||||
legacy_request->publish_subscribe_id = static_cast<uint8_t>(aidl_request.discoverySessionId);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -137,6 +137,7 @@ class MockNanIfaceEventCallback : public IWifiNanIfaceEventCallback {
|
||||
MOCK_METHOD2(notifySuspendResponse, ndk::ScopedAStatus(char16_t, const NanStatus&));
|
||||
MOCK_METHOD2(notifyResumeResponse, ndk::ScopedAStatus(char16_t, const NanStatus&));
|
||||
MOCK_METHOD2(notifyTerminatePairingResponse, ndk::ScopedAStatus(char16_t, const NanStatus&));
|
||||
MOCK_METHOD1(eventSuspensionModeChanged, ndk::ScopedAStatus(const NanSuspensionModeChangeInd&));
|
||||
};
|
||||
|
||||
class WifiNanIfaceTest : public Test {
|
||||
|
||||
@@ -351,6 +351,15 @@ void onAsyncNanEventScheduleUpdate(NanDataPathScheduleUpdateInd* event) {
|
||||
}
|
||||
}
|
||||
|
||||
std::function<void(const NanSuspensionModeChangeInd&)>
|
||||
on_nan_event_suspension_mode_change_user_callback;
|
||||
void onAsyncNanEventSuspensionModeChange(NanSuspensionModeChangeInd* event) {
|
||||
const auto lock = aidl_sync_util::acquireGlobalLock();
|
||||
if (on_nan_event_suspension_mode_change_user_callback && event) {
|
||||
on_nan_event_suspension_mode_change_user_callback(*event);
|
||||
}
|
||||
}
|
||||
|
||||
std::function<void(const NanPairingRequestInd&)> on_nan_event_pairing_request_user_callback;
|
||||
void onAsyncNanEventPairingRequest(NanPairingRequestInd* event) {
|
||||
const auto lock = aidl_sync_util::acquireGlobalLock();
|
||||
@@ -1376,6 +1385,8 @@ wifi_error WifiLegacyHal::nanRegisterCallbackHandlers(const std::string& iface_n
|
||||
on_nan_event_range_request_user_callback = user_callbacks.on_event_range_request;
|
||||
on_nan_event_range_report_user_callback = user_callbacks.on_event_range_report;
|
||||
on_nan_event_schedule_update_user_callback = user_callbacks.on_event_schedule_update;
|
||||
on_nan_event_suspension_mode_change_user_callback =
|
||||
user_callbacks.on_event_suspension_mode_change;
|
||||
|
||||
return global_func_table_.wifi_nan_register_handler(getIfaceHandle(iface_name),
|
||||
{onAsyncNanNotifyResponse,
|
||||
@@ -1399,7 +1410,8 @@ wifi_error WifiLegacyHal::nanRegisterCallbackHandlers(const std::string& iface_n
|
||||
onAsyncNanEventPairingRequest,
|
||||
onAsyncNanEventPairingConfirm,
|
||||
onAsyncNanEventBootstrappingRequest,
|
||||
onAsyncNanEventBootstrappingConfirm});
|
||||
onAsyncNanEventBootstrappingConfirm,
|
||||
onAsyncNanEventSuspensionModeChange});
|
||||
}
|
||||
|
||||
wifi_error WifiLegacyHal::nanEnableRequest(const std::string& iface_name, transaction_id id,
|
||||
|
||||
@@ -91,6 +91,7 @@ using ::NAN_RESPONSE_SUBSCRIBE;
|
||||
using ::NAN_RESPONSE_SUBSCRIBE_CANCEL;
|
||||
using ::NAN_RESPONSE_TCA;
|
||||
using ::NAN_RESPONSE_TRANSMIT_FOLLOWUP;
|
||||
using ::NAN_RESUME_REQUEST_RESPONSE;
|
||||
using ::NAN_SECURITY_KEY_INPUT_PASSPHRASE;
|
||||
using ::NAN_SECURITY_KEY_INPUT_PMK;
|
||||
using ::NAN_SERVICE_ACCEPT_POLICY_ALL;
|
||||
@@ -111,13 +112,17 @@ using ::NAN_STATUS_INVALID_PARAM;
|
||||
using ::NAN_STATUS_INVALID_PUBLISH_SUBSCRIBE_ID;
|
||||
using ::NAN_STATUS_INVALID_REQUESTOR_INSTANCE_ID;
|
||||
using ::NAN_STATUS_NAN_NOT_ALLOWED;
|
||||
using ::NAN_STATUS_NO_CONNECTION;
|
||||
using ::NAN_STATUS_NO_OTA_ACK;
|
||||
using ::NAN_STATUS_NO_RESOURCE_AVAILABLE;
|
||||
using ::NAN_STATUS_NOT_SUPPORTED;
|
||||
using ::NAN_STATUS_PROTOCOL_FAILURE;
|
||||
using ::NAN_STATUS_REDUNDANT_REQUEST;
|
||||
using ::NAN_STATUS_SUCCESS;
|
||||
using ::NAN_STATUS_UNSUPPORTED_CONCURRENCY_NAN_DISABLED;
|
||||
using ::NAN_SUBSCRIBE_TYPE_ACTIVE;
|
||||
using ::NAN_SUBSCRIBE_TYPE_PASSIVE;
|
||||
using ::NAN_SUSPEND_REQUEST_RESPONSE;
|
||||
using ::NAN_TRANSMIT_IN_DW;
|
||||
using ::NAN_TRANSMIT_IN_FAW;
|
||||
using ::NAN_TX_PRIORITY_HIGH;
|
||||
@@ -175,6 +180,7 @@ using ::NanSubscribeRequest;
|
||||
using ::NanSubscribeTerminatedInd;
|
||||
using ::NanSubscribeType;
|
||||
using ::NanSuspendRequest;
|
||||
using ::NanSuspensionModeChangeInd;
|
||||
using ::NanTransmitFollowupInd;
|
||||
using ::NanTransmitFollowupRequest;
|
||||
using ::NanTxType;
|
||||
@@ -452,6 +458,7 @@ struct NanCallbackHandlers {
|
||||
std::function<void(const NanPairingConfirmInd&)> on_event_pairing_confirm;
|
||||
std::function<void(const NanBootstrappingRequestInd&)> on_event_bootstrapping_request;
|
||||
std::function<void(const NanBootstrappingConfirmInd&)> on_event_bootstrapping_confirm;
|
||||
std::function<void(const NanSuspensionModeChangeInd&)> on_event_suspension_mode_change;
|
||||
};
|
||||
|
||||
// Full scan results contain IE info and are hence passed by reference, to
|
||||
|
||||
@@ -253,6 +253,22 @@ void WifiNanIface::registerCallbackHandlers() {
|
||||
}
|
||||
break;
|
||||
}
|
||||
case legacy_hal::NAN_SUSPEND_REQUEST_RESPONSE: {
|
||||
for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
|
||||
if (!callback->notifySuspendResponse(id, nanStatus).isOk()) {
|
||||
LOG(ERROR) << "Failed to invoke the callback";
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case legacy_hal::NAN_RESUME_REQUEST_RESPONSE: {
|
||||
for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
|
||||
if (!callback->notifyResumeResponse(id, nanStatus).isOk()) {
|
||||
LOG(ERROR) << "Failed to invoke the callback";
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case legacy_hal::NAN_RESPONSE_BEACON_SDF_PAYLOAD:
|
||||
/* fall through */
|
||||
case legacy_hal::NAN_RESPONSE_TCA:
|
||||
@@ -581,6 +597,22 @@ void WifiNanIface::registerCallbackHandlers() {
|
||||
}
|
||||
}
|
||||
};
|
||||
callback_handlers.on_event_suspension_mode_change =
|
||||
[weak_ptr_this](const legacy_hal::NanSuspensionModeChangeInd& msg) {
|
||||
const auto shared_ptr_this = weak_ptr_this.lock();
|
||||
if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
|
||||
LOG(ERROR) << "Callback invoked on an invalid object";
|
||||
return;
|
||||
}
|
||||
NanSuspensionModeChangeInd aidl_struct;
|
||||
aidl_struct.isSuspended = msg.is_suspended;
|
||||
|
||||
for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
|
||||
if (!callback->eventSuspensionModeChanged(aidl_struct).isOk()) {
|
||||
LOG(ERROR) << "Failed to invoke the callback";
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
legacy_hal::wifi_error legacy_status =
|
||||
legacy_hal_.lock()->nanRegisterCallbackHandlers(ifname_, callback_handlers);
|
||||
|
||||
@@ -55,6 +55,7 @@ using aidl::android::hardware::wifi::NanPublishType;
|
||||
using aidl::android::hardware::wifi::NanRespondToDataPathIndicationRequest;
|
||||
using aidl::android::hardware::wifi::NanStatus;
|
||||
using aidl::android::hardware::wifi::NanStatusCode;
|
||||
using aidl::android::hardware::wifi::NanSuspensionModeChangeInd;
|
||||
using aidl::android::hardware::wifi::NanTxType;
|
||||
|
||||
#define TIMEOUT_PERIOD 10
|
||||
@@ -124,6 +125,7 @@ class WifiNanIfaceAidlTest : public testing::TestWithParam<std::string> {
|
||||
EVENT_PAIRING_CONFIRM,
|
||||
EVENT_BOOTSTRAPPING_REQUEST,
|
||||
EVENT_BOOTSTRAPPING_CONFIRM,
|
||||
EVENT_SUSPENSION_MODE_CHANGE,
|
||||
};
|
||||
|
||||
// Test code calls this function to wait for data/event callback.
|
||||
@@ -255,6 +257,13 @@ class WifiNanIfaceAidlTest : public testing::TestWithParam<std::string> {
|
||||
parent_.notify();
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
::ndk::ScopedAStatus eventSuspensionModeChanged(
|
||||
const NanSuspensionModeChangeInd& event) override {
|
||||
parent_.callback_type_ = EVENT_SUSPENSION_MODE_CHANGE;
|
||||
parent_.nan_suspension_mode_change_ind_ = event;
|
||||
parent_.notify();
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
::ndk::ScopedAStatus notifyCapabilitiesResponse(
|
||||
char16_t id, const NanStatus& status,
|
||||
const NanCapabilities& capabilities) override {
|
||||
@@ -451,6 +460,7 @@ class WifiNanIfaceAidlTest : public testing::TestWithParam<std::string> {
|
||||
NanPairingConfirmInd nan_pairing_confirm_ind_;
|
||||
NanBootstrappingRequestInd nan_bootstrapping_request_ind_;
|
||||
NanBootstrappingConfirmInd nan_bootstrapping_confirm_ind_;
|
||||
NanSuspensionModeChangeInd nan_suspension_mode_change_ind_;
|
||||
|
||||
const char* getInstanceName() { return GetParam().c_str(); }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user