diff --git a/wifi/aidl/aidl_api/android.hardware.wifi/current/android/hardware/wifi/IWifiNanIfaceEventCallback.aidl b/wifi/aidl/aidl_api/android.hardware.wifi/current/android/hardware/wifi/IWifiNanIfaceEventCallback.aidl index ed78d35d38..8c443309ee 100644 --- a/wifi/aidl/aidl_api/android.hardware.wifi/current/android/hardware/wifi/IWifiNanIfaceEventCallback.aidl +++ b/wifi/aidl/aidl_api/android.hardware.wifi/current/android/hardware/wifi/IWifiNanIfaceEventCallback.aidl @@ -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); diff --git a/wifi/aidl/aidl_api/android.hardware.wifi/current/android/hardware/wifi/NanInitiateDataPathRequest.aidl b/wifi/aidl/aidl_api/android.hardware.wifi/current/android/hardware/wifi/NanInitiateDataPathRequest.aidl index 697e29a7c8..740a140780 100644 --- a/wifi/aidl/aidl_api/android.hardware.wifi/current/android/hardware/wifi/NanInitiateDataPathRequest.aidl +++ b/wifi/aidl/aidl_api/android.hardware.wifi/current/android/hardware/wifi/NanInitiateDataPathRequest.aidl @@ -42,4 +42,5 @@ parcelable NanInitiateDataPathRequest { android.hardware.wifi.NanDataPathSecurityConfig securityConfig; byte[] appInfo; byte[] serviceNameOutOfBand; + byte discoverySessionId; } diff --git a/wifi/aidl/aidl_api/android.hardware.wifi/current/android/hardware/wifi/NanRespondToDataPathIndicationRequest.aidl b/wifi/aidl/aidl_api/android.hardware.wifi/current/android/hardware/wifi/NanRespondToDataPathIndicationRequest.aidl index 5542ff62ba..0f873b5ea8 100644 --- a/wifi/aidl/aidl_api/android.hardware.wifi/current/android/hardware/wifi/NanRespondToDataPathIndicationRequest.aidl +++ b/wifi/aidl/aidl_api/android.hardware.wifi/current/android/hardware/wifi/NanRespondToDataPathIndicationRequest.aidl @@ -40,4 +40,5 @@ parcelable NanRespondToDataPathIndicationRequest { android.hardware.wifi.NanDataPathSecurityConfig securityConfig; byte[] appInfo; byte[] serviceNameOutOfBand; + byte discoverySessionId; } diff --git a/wifi/aidl/aidl_api/android.hardware.wifi/current/android/hardware/wifi/NanStatusCode.aidl b/wifi/aidl/aidl_api/android.hardware.wifi/current/android/hardware/wifi/NanStatusCode.aidl index 40844cc416..ec12eb0c4c 100644 --- a/wifi/aidl/aidl_api/android.hardware.wifi/current/android/hardware/wifi/NanStatusCode.aidl +++ b/wifi/aidl/aidl_api/android.hardware.wifi/current/android/hardware/wifi/NanStatusCode.aidl @@ -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, } diff --git a/wifi/aidl/aidl_api/android.hardware.wifi/current/android/hardware/wifi/NanSuspensionModeChangeInd.aidl b/wifi/aidl/aidl_api/android.hardware.wifi/current/android/hardware/wifi/NanSuspensionModeChangeInd.aidl new file mode 100644 index 0000000000..557fc796d9 --- /dev/null +++ b/wifi/aidl/aidl_api/android.hardware.wifi/current/android/hardware/wifi/NanSuspensionModeChangeInd.aidl @@ -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 -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; +} diff --git a/wifi/aidl/android/hardware/wifi/IWifiNanIfaceEventCallback.aidl b/wifi/aidl/android/hardware/wifi/IWifiNanIfaceEventCallback.aidl index edca1d551a..8a61a9c812 100644 --- a/wifi/aidl/android/hardware/wifi/IWifiNanIfaceEventCallback.aidl +++ b/wifi/aidl/android/hardware/wifi/IWifiNanIfaceEventCallback.aidl @@ -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|. diff --git a/wifi/aidl/android/hardware/wifi/NanInitiateDataPathRequest.aidl b/wifi/aidl/android/hardware/wifi/NanInitiateDataPathRequest.aidl index 264a873a3e..2f2532929f 100644 --- a/wifi/aidl/android/hardware/wifi/NanInitiateDataPathRequest.aidl +++ b/wifi/aidl/android/hardware/wifi/NanInitiateDataPathRequest.aidl @@ -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; } diff --git a/wifi/aidl/android/hardware/wifi/NanRespondToDataPathIndicationRequest.aidl b/wifi/aidl/android/hardware/wifi/NanRespondToDataPathIndicationRequest.aidl index 6960e71fba..e543b7bf07 100644 --- a/wifi/aidl/android/hardware/wifi/NanRespondToDataPathIndicationRequest.aidl +++ b/wifi/aidl/android/hardware/wifi/NanRespondToDataPathIndicationRequest.aidl @@ -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; } diff --git a/wifi/aidl/android/hardware/wifi/NanStatusCode.aidl b/wifi/aidl/android/hardware/wifi/NanStatusCode.aidl index d609797131..6706839aa4 100644 --- a/wifi/aidl/android/hardware/wifi/NanStatusCode.aidl +++ b/wifi/aidl/android/hardware/wifi/NanStatusCode.aidl @@ -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 } diff --git a/wifi/aidl/android/hardware/wifi/NanSuspensionModeChangeInd.aidl b/wifi/aidl/android/hardware/wifi/NanSuspensionModeChangeInd.aidl new file mode 100644 index 0000000000..afabe8c496 --- /dev/null +++ b/wifi/aidl/android/hardware/wifi/NanSuspensionModeChangeInd.aidl @@ -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; +} diff --git a/wifi/aidl/default/aidl_struct_util.cpp b/wifi/aidl/default/aidl_struct_util.cpp index 4094c365cb..9011d2701b 100644 --- a/wifi/aidl/default/aidl_struct_util.cpp +++ b/wifi/aidl/default/aidl_struct_util.cpp @@ -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(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(aidl_request.discoverySessionId); return true; } diff --git a/wifi/aidl/default/tests/wifi_nan_iface_unit_tests.cpp b/wifi/aidl/default/tests/wifi_nan_iface_unit_tests.cpp index fc58c3e879..d58a9b0ace 100644 --- a/wifi/aidl/default/tests/wifi_nan_iface_unit_tests.cpp +++ b/wifi/aidl/default/tests/wifi_nan_iface_unit_tests.cpp @@ -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 { diff --git a/wifi/aidl/default/wifi_legacy_hal.cpp b/wifi/aidl/default/wifi_legacy_hal.cpp index 6436fb71f6..796098db2a 100644 --- a/wifi/aidl/default/wifi_legacy_hal.cpp +++ b/wifi/aidl/default/wifi_legacy_hal.cpp @@ -351,6 +351,15 @@ void onAsyncNanEventScheduleUpdate(NanDataPathScheduleUpdateInd* event) { } } +std::function + 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 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, diff --git a/wifi/aidl/default/wifi_legacy_hal.h b/wifi/aidl/default/wifi_legacy_hal.h index 468d8d7d08..85a8ac4fc3 100644 --- a/wifi/aidl/default/wifi_legacy_hal.h +++ b/wifi/aidl/default/wifi_legacy_hal.h @@ -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 on_event_pairing_confirm; std::function on_event_bootstrapping_request; std::function on_event_bootstrapping_confirm; + std::function on_event_suspension_mode_change; }; // Full scan results contain IE info and are hence passed by reference, to diff --git a/wifi/aidl/default/wifi_nan_iface.cpp b/wifi/aidl/default/wifi_nan_iface.cpp index 0d538033be..8e3a191b7a 100644 --- a/wifi/aidl/default/wifi_nan_iface.cpp +++ b/wifi/aidl/default/wifi_nan_iface.cpp @@ -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); diff --git a/wifi/aidl/vts/functional/wifi_nan_iface_aidl_test.cpp b/wifi/aidl/vts/functional/wifi_nan_iface_aidl_test.cpp index d2c3235bc8..bebad7ca08 100644 --- a/wifi/aidl/vts/functional/wifi_nan_iface_aidl_test.cpp +++ b/wifi/aidl/vts/functional/wifi_nan_iface_aidl_test.cpp @@ -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 { 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 { 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 { 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(); }