Merge "Add support for StrongBox implementations to Keymaster HAL"
diff --git a/audio/2.0/config/audio_policy_configuration.xsd b/audio/2.0/config/audio_policy_configuration.xsd
index eb59152..7647cad 100644
--- a/audio/2.0/config/audio_policy_configuration.xsd
+++ b/audio/2.0/config/audio_policy_configuration.xsd
@@ -49,10 +49,6 @@
<xs:selector xpath="modules/module"/>
<xs:field xpath="@name"/>
</xs:key>
- <xs:key name="devicePortNameGlobalKey">
- <xs:selector xpath="modules/module/devicePorts/devicePort"/>
- <xs:field xpath="@tagName"/>
- </xs:key>
<xs:unique name="volumeTargetUniqueness">
<xs:selector xpath="volumes/volume"/>
<xs:field xpath="@stream"/>
@@ -73,14 +69,28 @@
<!-- Enum values of IDevicesFactory::Device
TODO: generate from hidl to avoid manual sync. -->
<xs:simpleType name="halName">
- <xs:restriction base="xs:string">
- <xs:enumeration value="primary"/>
- <xs:enumeration value="a2dp"/>
- <xs:enumeration value="usb"/>
- <xs:enumeration value="r_submix"/>
- <xs:enumeration value="codec_offload"/>
- <xs:enumeration value="stub"/>
- </xs:restriction>
+ <xs:union>
+ <xs:simpleType>
+ <xs:restriction base="xs:string">
+ <xs:enumeration value="primary"/>
+ <xs:enumeration value="a2dp"/>
+ <xs:enumeration value="usb"/>
+ <xs:enumeration value="r_submix"/>
+ <xs:enumeration value="codec_offload"/>
+ <xs:enumeration value="stub"/>
+ </xs:restriction>
+ </xs:simpleType>
+ <xs:simpleType>
+ <!-- Vendor eXtension names must be in the vx namespace.
+ Vendor are encouraged to namespace their module names.
+ Example for an hypothetical Google virtual reality HAL:
+ <module name="vx_google_vr" halVersion="3.0">
+ -->
+ <xs:restriction base="xs:string">
+ <xs:pattern value="vx_[_a-zA-Z0-9]+"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:union>
</xs:simpleType>
<xs:complexType name="modules">
<xs:annotation>
@@ -127,13 +137,15 @@
<xs:selector xpath="mixPorts/mixPort"/>
<xs:field xpath="@name"/>
</xs:unique>
- <!-- Although this key constraint is redundant with devicePortNameGlobalKey,
- the set is used to constraint defaultOutputDevice and attachedDevice
- to reference a devicePort of the same module. -->
<xs:key name="devicePortNameKey">
<xs:selector xpath="devicePorts/devicePort"/>
<xs:field xpath="@tagName"/>
</xs:key>
+ <xs:unique name="devicePortUniqueness">
+ <xs:selector xpath="devicePorts/devicePort"/>
+ <xs:field xpath="@type"/>
+ <xs:field xpath="@address"/>
+ </xs:unique>
<xs:keyref name="defaultOutputDeviceRef" refer="devicePortNameKey">
<xs:selector xpath="defaultOutputDevice"/>
<xs:field xpath="."/>
@@ -405,7 +417,7 @@
<xs:attribute name="tagName" type="xs:token" use="required"/>
<xs:attribute name="type" type="audioDevice" use="required"/>
<xs:attribute name="role" type="role" use="required"/>
- <xs:attribute name="address" type="xs:string" use="optional"/>
+ <xs:attribute name="address" type="xs:string" use="optional" default=""/>
</xs:complexType>
<xs:unique name="devicePortProfileUniqueness">
<xs:selector xpath="profile"/>
diff --git a/audio/2.0/vts/functional/AudioPrimaryHidlHalTest.cpp b/audio/2.0/vts/functional/AudioPrimaryHidlHalTest.cpp
index 7c213d4..fd175de 100644
--- a/audio/2.0/vts/functional/AudioPrimaryHidlHalTest.cpp
+++ b/audio/2.0/vts/functional/AudioPrimaryHidlHalTest.cpp
@@ -716,11 +716,12 @@
ASSERT_GE(extract(stream->getBufferSize()),
extract(stream->getFrameSize())));
-template <class Property, class CapabilityGetter, class Getter, class Setter>
+template <class Property, class CapabilityGetter>
static void testCapabilityGetter(const string& name, IStream* stream,
- Property currentValue,
CapabilityGetter capablityGetter,
- Getter getter, Setter setter) {
+ Return<Property> (IStream::*getter)(),
+ Return<Result> (IStream::*setter)(Property),
+ bool currentMustBeSupported = true) {
hidl_vec<Property> capabilities;
ASSERT_OK((stream->*capablityGetter)(returnIn(capabilities)));
if (capabilities.size() == 0) {
@@ -731,16 +732,24 @@
doc::partialTest(name + " is not supported");
return;
};
- // TODO: This code has never been tested on a hal that supports
- // getSupportedSampleRates
- EXPECT_NE(std::find(capabilities.begin(), capabilities.end(), currentValue),
- capabilities.end())
- << "current " << name << " is not in the list of the supported ones "
- << toString(capabilities);
+
+ if (currentMustBeSupported) {
+ Property currentValue = extract((stream->*getter)());
+ EXPECT_NE(std::find(capabilities.begin(), capabilities.end(), currentValue),
+ capabilities.end())
+ << "current " << name << " is not in the list of the supported ones "
+ << toString(capabilities);
+ }
// Check that all declared supported values are indeed supported
for (auto capability : capabilities) {
- ASSERT_OK((stream->*setter)(capability));
+ auto ret = (stream->*setter)(capability);
+ ASSERT_TRUE(ret.isOk());
+ if (ret == Result::NOT_SUPPORTED) {
+ doc::partialTest("Setter is not supported");
+ return;
+ }
+ ASSERT_OK(ret);
ASSERT_EQ(capability, extract((stream->*getter)()));
}
}
@@ -748,15 +757,17 @@
TEST_IO_STREAM(SupportedSampleRate,
"Check that the stream sample rate is declared as supported",
testCapabilityGetter("getSupportedSampleRate", stream.get(),
- extract(stream->getSampleRate()),
&IStream::getSupportedSampleRates,
&IStream::getSampleRate,
- &IStream::setSampleRate))
+ &IStream::setSampleRate,
+ // getSupportedSampleRate returns the native sampling rates,
+ // (the sampling rates that can be played without resampling)
+ // but other sampling rates can be supported by the HAL.
+ false))
TEST_IO_STREAM(SupportedChannelMask,
"Check that the stream channel mask is declared as supported",
testCapabilityGetter("getSupportedChannelMask", stream.get(),
- extract(stream->getChannelMask()),
&IStream::getSupportedChannelMasks,
&IStream::getChannelMask,
&IStream::setChannelMask))
@@ -764,7 +775,6 @@
TEST_IO_STREAM(SupportedFormat,
"Check that the stream format is declared as supported",
testCapabilityGetter("getSupportedFormat", stream.get(),
- extract(stream->getFormat()),
&IStream::getSupportedFormats,
&IStream::getFormat, &IStream::setFormat))
diff --git a/broadcastradio/1.2/Android.bp b/broadcastradio/1.2/Android.bp
index 913da8c..40eb4e0 100644
--- a/broadcastradio/1.2/Android.bp
+++ b/broadcastradio/1.2/Android.bp
@@ -18,6 +18,7 @@
"android.hidl.base@1.0",
],
types: [
+ "IdentifierType",
],
gen_java: false,
}
diff --git a/broadcastradio/2.0/Android.bp b/broadcastradio/2.0/Android.bp
new file mode 100644
index 0000000..5146932
--- /dev/null
+++ b/broadcastradio/2.0/Android.bp
@@ -0,0 +1,33 @@
+// This file is autogenerated by hidl-gen -Landroidbp.
+
+hidl_interface {
+ name: "android.hardware.broadcastradio@2.0",
+ root: "android.hardware",
+ vndk: {
+ enabled: true,
+ },
+ srcs: [
+ "types.hal",
+ "IBroadcastRadio.hal",
+ "ITunerCallback.hal",
+ "ITunerSession.hal",
+ ],
+ interfaces: [
+ "android.hidl.base@1.0",
+ ],
+ types: [
+ "Constants",
+ "IdentifierType",
+ "Metadata",
+ "MetadataKey",
+ "ProgramIdentifier",
+ "ProgramInfo",
+ "ProgramInfoFlags",
+ "ProgramSelector",
+ "Properties",
+ "Result",
+ "VendorKeyValue",
+ ],
+ gen_java: true,
+}
+
diff --git a/broadcastradio/2.0/IBroadcastRadio.hal b/broadcastradio/2.0/IBroadcastRadio.hal
new file mode 100644
index 0000000..3ab1cc2
--- /dev/null
+++ b/broadcastradio/2.0/IBroadcastRadio.hal
@@ -0,0 +1,81 @@
+/* Copyright (C) 2017 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.broadcastradio@2.0;
+
+import ITunerCallback;
+import ITunerSession;
+
+/**
+ * Represents a hardware broadcast radio module. A single module may contain
+ * multiple hardware tuners (i.e. with an additional background tuner), but the
+ * layers above the HAL see them as a single logical unit.
+ */
+interface IBroadcastRadio {
+ /**
+ * Returns module properties: a description of a module and its
+ * capabilities. This method must not fail.
+ *
+ * @return properties Module description.
+ */
+ getProperties() generates (Properties properties);
+
+ /**
+ * Opens a new tuner session.
+ *
+ * There may be only one session active at a time. If the new session was
+ * requested when the old one was active, the old must be terminated
+ * (aggressive open).
+ *
+ * @param callback The callback interface.
+ * @return result OK in case of success.
+ * @return session The session interface.
+ */
+ openSession(ITunerCallback callback)
+ generates (Result result, ITunerSession session);
+
+ /**
+ * Fetch image from radio module cache.
+ *
+ * This is out-of-band transport mechanism for images carried with metadata.
+ * The metadata vector only passes the identifier, so the client may cache
+ * images or even not fetch them.
+ *
+ * The identifier may be any arbitrary number (i.e. sha256 prefix) selected
+ * by the vendor. It must be stable across sessions so the application may
+ * cache it.
+ *
+ * The data must be a valid PNG, JPEG, GIF or BMP file.
+ * Image data with an invalid format must be handled gracefully in the same
+ * way as a missing image.
+ *
+ * The image identifier may become invalid after some time from passing it
+ * with metadata struct (due to resource cleanup at the HAL implementation).
+ * However, it must remain valid for a currently tuned program at least
+ * until onCurrentProgramInfoChanged is called.
+ *
+ * There is still a race condition possible between
+ * onCurrentProgramInfoChanged callback and the HAL implementation eagerly
+ * clearing the cache (because the next onCurrentProgramInfoChanged came).
+ * In such case, client application may expect the new
+ * onCurrentProgramInfoChanged callback with updated image identifier.
+ *
+ * @param id Identifier of an image (value of Constants::INVALID_IMAGE is
+ * reserved and must be treated as invalid image).
+ * @return image A binary blob with image data
+ * or a zero-length vector if identifier doesn't exist.
+ */
+ getImage(uint32_t id) generates (vec<uint8_t> image);
+};
diff --git a/broadcastradio/2.0/ITunerCallback.hal b/broadcastradio/2.0/ITunerCallback.hal
new file mode 100644
index 0000000..1aefc4e
--- /dev/null
+++ b/broadcastradio/2.0/ITunerCallback.hal
@@ -0,0 +1,67 @@
+/* Copyright (C) 2017 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.broadcastradio@2.0;
+
+interface ITunerCallback {
+ /**
+ * Method called by the HAL when a tuning operation fails
+ * following a step(), scan() or tune() command.
+ *
+ * @param result OK if tune succeeded;
+ * TIMEOUT in case of time out.
+ * @param selector A ProgramSelector structure passed from tune(),
+ * empty for step() and scan().
+ */
+ oneway onTuneFailed(Result result, ProgramSelector selector);
+
+ /**
+ * Method called by the HAL when current program information (including
+ * metadata) is updated.
+ *
+ * This is also called when the radio tuned to the static (not a valid
+ * station), see the TUNED flag of ProgramInfoFlags.
+ *
+ * @param info Current program information.
+ */
+ oneway onCurrentProgramInfoChanged(ProgramInfo info);
+
+ /**
+ * Method called by the HAL when the antenna gets connected or disconnected.
+ *
+ * For a new tuner session, client must assume the antenna is connected.
+ * If it's not, then antennaStateChange must be called within
+ * Constants::ANTENNA_DISCONNECTED_TIMEOUT_MS to indicate that.
+ *
+ * @param connected True if the antenna is now connected, false otherwise.
+ */
+ oneway onAntennaStateChange(bool connected);
+
+ /**
+ * Generic callback for passing updates to vendor-specific parameter values.
+ * The framework does not interpret the parameters, they are passed
+ * in an opaque manner between a vendor application and HAL.
+ *
+ * It's up to the HAL implementation if and how to implement this callback,
+ * as long as it obeys the prefix rule. In particular, only selected keys
+ * may be notified this way. However, setParameters must not trigger
+ * this callback, while an internal event can change parameters
+ * asynchronously.
+ *
+ * @param parameters Vendor-specific key-value pairs,
+ * opaque to Android framework.
+ */
+ oneway onParametersUpdated(vec<VendorKeyValue> parameters);
+};
diff --git a/broadcastradio/2.0/ITunerSession.hal b/broadcastradio/2.0/ITunerSession.hal
new file mode 100644
index 0000000..ae6cbb5
--- /dev/null
+++ b/broadcastradio/2.0/ITunerSession.hal
@@ -0,0 +1,137 @@
+/* Copyright (C) 2017 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.broadcastradio@2.0;
+
+interface ITunerSession {
+ /**
+ * Tune to a specified program.
+ *
+ * Automatically cancels pending scan, step or tune.
+ * If the method returns OK, tuneFailed or currentProgramInfoChanged
+ * callback must be called.
+ *
+ * @param program Program to tune to.
+ * @return result OK if successfully started tuning.
+ * NOT_SUPPORTED if the program selector doesn't contain any
+ * supported identifier.
+ * INVALID_ARGUMENTS if the program selector contains
+ * identifiers in invalid format (i.e. out of range).
+ */
+ tune(ProgramSelector program) generates (Result result);
+
+ /**
+ * Tune to the next valid program.
+ *
+ * Automatically cancels pending scan, step or tune.
+ * If the method returns OK, tuneFailed or currentProgramInfoChanged
+ * callback must be called.
+ *
+ * The skipSubChannel parameter is used to skip digital radio subchannels:
+ * - HD Radio SPS;
+ * - DAB secondary service.
+ *
+ * As an implementation detail, the HAL has the option to perform an actual
+ * scan or select the next program from the list retrieved in the
+ * background, if one is not stale.
+ *
+ * @param directionUp True to change towards higher numeric values
+ * (frequency, channel number), false towards lower.
+ * @param skipSubChannel Don't tune to subchannels.
+ * @return result OK if the scan has successfully started.
+ */
+ scan(bool directionUp, bool skipSubChannel) generates (Result result);
+
+ /**
+ * Tune to the adjacent channel, which may not be occupied by any program.
+ *
+ * Automatically cancels pending scan, step or tune.
+ * If the method returns OK, tuneFailed or currentProgramInfoChanged
+ * callback must be called.
+ *
+ * @param directionUp True to change towards higher numeric values
+ * (frequency, channel number), false towards lower.
+ * @return result OK successfully started tuning.
+ * NOT_SUPPORTED if tuning to an unoccupied channel is not
+ * supported (i.e. for satellite radio).
+ */
+ step(bool directionUp) generates (Result result);
+
+ /**
+ * Cancel a scan, step or tune operation.
+ *
+ * If there is no such operation running, the call must be ignored.
+ */
+ cancel();
+
+ /**
+ * Generic method for setting vendor-specific parameter values.
+ * The framework does not interpret the parameters, they are passed
+ * in an opaque manner between a vendor application and HAL.
+ *
+ * Framework does not make any assumptions on the keys or values, other than
+ * ones stated in VendorKeyValue documentation (a requirement of key
+ * prefixes).
+ *
+ * For each pair in the result vector, the key must be one of the keys
+ * contained in the input (possibly with wildcards expanded), and the value
+ * must be a vendor-specific result status (i.e. the string "OK" or an error
+ * code). The implementation may choose to return an empty vector, or only
+ * return a status for a subset of the provided inputs, at its discretion.
+ *
+ * Application and HAL must not use keys with unknown prefix. In particular,
+ * it must not place a key-value pair in results vector for unknown key from
+ * parameters vector - instead, an unknown key should simply be ignored.
+ * In other words, results vector may contain a subset of parameter keys
+ * (however, the framework doesn't enforce a strict subset - the only
+ * formal requirement is vendor domain prefix for keys).
+ *
+ * @param parameters Vendor-specific key-value pairs.
+ * @return results Operation completion status for parameters being set.
+ */
+ setParameters(vec<VendorKeyValue> parameters)
+ generates (vec<VendorKeyValue> results);
+
+ /**
+ * Generic method for retrieving vendor-specific parameter values.
+ * The framework does not interpret the parameters, they are passed
+ * in an opaque manner between a vendor application and HAL.
+ *
+ * Framework does not cache set/get requests, so it's allowed for
+ * getParameter to return a different value than previous setParameter call.
+ *
+ * The syntax and semantics of keys are up to the vendor (as long as prefix
+ * rules are obeyed). For instance, vendors may include some form of
+ * wildcard support. In such case, result vector may be of different size
+ * than requested keys vector. However, wildcards are not recognized by
+ * framework and they are passed as-is to the HAL implementation.
+ *
+ * Unknown keys must be ignored and not placed into results vector.
+ *
+ * @param keys Parameter keys to fetch.
+ * @return parameters Vendor-specific key-value pairs.
+ */
+ getParameters(vec<string> keys) generates (vec<VendorKeyValue> parameters);
+
+ /**
+ * Closes the session.
+ *
+ * The call must not fail and must only be issued once.
+ *
+ * After the close call is executed, no other calls to this interface
+ * are allowed.
+ */
+ close();
+};
diff --git a/broadcastradio/2.0/types.hal b/broadcastradio/2.0/types.hal
new file mode 100644
index 0000000..4b9878b
--- /dev/null
+++ b/broadcastradio/2.0/types.hal
@@ -0,0 +1,411 @@
+/* Copyright (C) 2017 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.broadcastradio@2.0;
+
+/** Constants used by broadcast radio HAL. */
+enum Constants : int32_t {
+ /** Invalid identifier for IBroadcastRadio::getImage. */
+ INVALID_IMAGE = 0,
+
+ /**
+ * If the antenna is disconnected from the beginning, the
+ * onAntennaStateChange callback must be called within this time.
+ */
+ ANTENNA_DISCONNECTED_TIMEOUT_MS = 100,
+};
+
+enum Result : int32_t {
+ OK,
+ UNKNOWN_ERROR,
+ INVALID_ARGUMENTS,
+ INVALID_STATE,
+ NOT_SUPPORTED,
+ TIMEOUT,
+};
+
+/**
+ * A key-value pair for vendor-specific information to be passed as-is through
+ * Android framework to the front-end application.
+ */
+struct VendorKeyValue {
+ /**
+ * Key must start with unique vendor Java-style namespace,
+ * eg. 'com.somecompany.parameter1'.
+ */
+ string key;
+
+ /**
+ * Value must be passed through the framework without any changes.
+ * Format of this string can vary across vendors.
+ */
+ string value;
+};
+
+/**
+ * Properties of a given broadcast radio module.
+ */
+struct Properties {
+ /**
+ * A company name who made the radio module. Must be a valid, registered
+ * name of the company itself.
+ *
+ * It must be opaque to the Android framework.
+ */
+ string maker;
+
+ /**
+ * A product name. Must be unique within the company.
+ *
+ * It must be opaque to the Android framework.
+ */
+ string product;
+
+ /**
+ * Version of the hardware module.
+ *
+ * It must be opaque to the Android framework.
+ */
+ string version;
+
+ /**
+ * Hardware serial number (for subscription services).
+ *
+ * It must be opaque to the Android framework.
+ */
+ string serial;
+
+ /**
+ * A list of supported IdentifierType values.
+ *
+ * If an identifier is supported by radio module, it means it can use it for
+ * tuning to ProgramSelector with either primary or secondary Identifier of
+ * a given type.
+ *
+ * Support for VENDOR identifier type does not guarantee compatibility, as
+ * other module properties (implementor, product, version) must be checked.
+ */
+ vec<uint32_t> supportedIdentifierTypes;
+
+ /**
+ * Vendor-specific information.
+ *
+ * It may be used for extra features, not supported by the platform,
+ * for example: com.me.preset-slots=6; com.me.ultra-hd-capable=false.
+ */
+ vec<VendorKeyValue> vendorInfo;
+};
+
+/**
+ * Program (channel, station) information.
+ *
+ * Carries both user-visible information (like station name) and technical
+ * details (tuning selector).
+ */
+struct ProgramInfo {
+ /**
+ * An identifier used to point at the program (primarily to tune to it).
+ */
+ ProgramSelector selector;
+
+ bitfield<ProgramInfoFlags> infoFlags;
+
+ /**
+ * Signal quality measured in 0% to 100% range to be shown in the UI.
+ *
+ * The purpose of this field is primarily informative, must not be used to
+ * determine to which frequency should it tune to.
+ */
+ uint32_t signalQuality;
+
+ /**
+ * Program metadata (station name, PTY, song title).
+ */
+ vec<Metadata> metadata;
+
+ /**
+ * Vendor-specific information.
+ *
+ * It may be used for extra features, not supported by the platform,
+ * for example: paid-service=true; bitrate=320kbps.
+ */
+ vec<VendorKeyValue> vendorInfo;
+};
+
+enum ProgramInfoFlags : uint32_t {
+ /**
+ * Set when the program is currently playing live stream.
+ * This may result in a slightly altered reception parameters,
+ * usually targetted at reduced latency.
+ */
+ LIVE = 1 << 0,
+
+ /**
+ * Radio stream is not playing, ie. due to bad reception conditions or
+ * buffering. In this state volume knob MAY be disabled to prevent user
+ * increasing volume too much.
+ */
+ MUTED = 1 << 1,
+
+ /**
+ * Station broadcasts traffic information regularly,
+ * but not necessarily right now.
+ */
+ TRAFFIC_PROGRAM = 1 << 2,
+
+ /**
+ * Station is broadcasting traffic information at the very moment.
+ */
+ TRAFFIC_ANNOUNCEMENT = 1 << 3,
+
+ /**
+ * Tuned to a program (not playing a static).
+ *
+ * It's the same condition that would stop scan() operation.
+ */
+ TUNED = 1 << 4,
+
+ /**
+ * Audio stream is MONO if this bit is not set.
+ */
+ STEREO = 1 << 5,
+};
+
+/**
+ * Type of program identifier component.
+ *
+ * Each identifier type corresponds to exactly one radio technology,
+ * i.e. DAB_ENSEMBLE is specifically for DAB.
+ *
+ * VENDOR identifier types must be opaque to the framework.
+ *
+ * The value format for each (but VENDOR_*) identifier is strictly defined
+ * to maintain interoperability between devices made by different vendors.
+ *
+ * All other values are reserved for future use.
+ * Values not matching any enumerated constant must be ignored.
+ */
+enum IdentifierType : uint32_t {
+ /**
+ * Primary/secondary identifier for vendor-specific radio technology.
+ * The value format is determined by a vendor.
+ *
+ * The vendor identifiers have limited serialization capabilities - see
+ * ProgramSelector description.
+ */
+ VENDOR_START = 1000,
+
+ /** See VENDOR_START */
+ VENDOR_END = 1999,
+
+ /**
+ * Primary identifier for analogue (without RDS) AM/FM stations:
+ * frequency in kHz.
+ *
+ * This identifier also contains band information:
+ * - <500kHz: AM LW;
+ * - 500kHz - 1705kHz: AM MW;
+ * - 1.71MHz - 30MHz: AM SW;
+ * - >60MHz: FM.
+ */
+ AMFM_FREQUENCY = 1,
+
+ /**
+ * 16bit primary identifier for FM RDS station.
+ */
+ RDS_PI,
+
+ /**
+ * 64bit compound primary identifier for HD Radio.
+ *
+ * Consists of (from the LSB):
+ * - 32bit: Station ID number;
+ * - 4bit: HD Radio subchannel;
+ * - 18bit: AMFM_FREQUENCY. // TODO(b/69958777): is it necessary?
+ *
+ * HD Radio subchannel is a value in range 0-7.
+ * This index is 0-based (where 0 is MPS and 1..7 are SPS),
+ * as opposed to HD Radio standard (where it's 1-based).
+ *
+ * The remaining bits should be set to zeros when writing on the chip side
+ * and ignored when read.
+ */
+ HD_STATION_ID_EXT,
+
+ /**
+ * 28bit compound primary identifier for Digital Audio Broadcasting.
+ *
+ * Consists of (from the LSB):
+ * - 16bit: SId;
+ * - 8bit: ECC code;
+ * - 4bit: SCIdS.
+ *
+ * SCIdS (Service Component Identifier within the Service) value
+ * of 0 represents the main service, while 1 and above represents
+ * secondary services.
+ *
+ * The remaining bits should be set to zeros when writing on the chip side
+ * and ignored when read.
+ */
+ DAB_SID_EXT = HD_STATION_ID_EXT + 2,
+
+ /** 16bit */
+ DAB_ENSEMBLE,
+
+ /** 12bit */
+ DAB_SCID,
+
+ /** kHz (see AMFM_FREQUENCY) */
+ DAB_FREQUENCY,
+
+ /**
+ * 24bit primary identifier for Digital Radio Mondiale.
+ */
+ DRMO_SERVICE_ID,
+
+ /** kHz (see AMFM_FREQUENCY) */
+ DRMO_FREQUENCY,
+
+ /**
+ * 32bit primary identifier for SiriusXM Satellite Radio.
+ */
+ SXM_SERVICE_ID = DRMO_FREQUENCY + 2,
+
+ /** 0-999 range */
+ SXM_CHANNEL,
+};
+
+/**
+ * A single program identifier component, i.e. frequency or channel ID.
+ */
+struct ProgramIdentifier {
+ /**
+ * Maps to IdentifierType enum. The enum may be extended in future versions
+ * of the HAL. Values out of the enum range must not be used when writing
+ * and ignored when reading.
+ */
+ uint32_t type;
+
+ /**
+ * The uint64_t value field holds the value in format described in comments
+ * for IdentifierType enum.
+ */
+ uint64_t value;
+};
+
+/**
+ * A set of identifiers necessary to tune to a given station.
+ *
+ * This can hold a combination of various identifiers, like:
+ * - AM/FM frequency,
+ * - HD Radio subchannel,
+ * - DAB service ID.
+ *
+ * The type of radio technology is determined by the primary identifier - if the
+ * primary identifier is for DAB, the program is DAB. However, a program of a
+ * specific radio technology may have additional secondary identifiers for other
+ * technologies, i.e. a satellite program may have FM fallback frequency,
+ * if a station broadcasts both via satellite and FM.
+ *
+ * The identifiers from VENDOR_START..VENDOR_END range have limited
+ * serialization capabilities: they are serialized locally, but ignored by the
+ * cloud services. If a program has primary id from vendor range, it's not
+ * synchronized with other devices at all.
+ */
+struct ProgramSelector {
+ /**
+ * Primary program identifier.
+ *
+ * This identifier uniquely identifies a station and can be used for
+ * equality check.
+ *
+ * It can hold only a subset of identifier types, one per each
+ * radio technology:
+ * - analogue AM/FM: AMFM_FREQUENCY;
+ * - FM RDS: RDS_PI;
+ * - HD Radio: HD_STATION_ID_EXT;
+ * - DAB: DAB_SID_EXT;
+ * - Digital Radio Mondiale: DRMO_SERVICE_ID;
+ * - SiriusXM: SXM_SERVICE_ID;
+ * - vendor-specific: VENDOR_START..VENDOR_END.
+ *
+ * The list may change in future versions, so the implementation must obey,
+ * but not rely on it.
+ */
+ ProgramIdentifier primaryId;
+
+ /**
+ * Secondary program identifiers.
+ *
+ * These identifiers are supplementary and can speed up tuning process,
+ * but the primary ID must be sufficient (i.e. RDS PI is enough to select
+ * a station from the list after a full band scan).
+ *
+ * Two selectors with different secondary IDs, but the same primary ID are
+ * considered equal. In particular, secondary IDs vector may get updated for
+ * an entry on the program list (ie. when a better frequency for a given
+ * station is found).
+ */
+ vec<ProgramIdentifier> secondaryIds;
+};
+
+enum MetadataKey : int32_t {
+ /** RDS PS (string) */
+ RDS_PS = 1,
+
+ /** RDS PTY (uint8_t) */
+ RDS_PTY,
+
+ /** RBDS PTY (uint8_t) */
+ RBDS_PTY,
+
+ /** RDS RT (string) */
+ RDS_RT,
+
+ /** Song title (string) */
+ SONG_TITLE,
+
+ /** Artist name (string) */
+ SONG_ARTIST,
+
+ /** Album name (string) */
+ SONG_ALBUM,
+
+ /** Station icon (uint32_t, see IBroadcastRadio::getImage) */
+ STATION_ICON,
+
+ /** Album art (uint32_t, see IBroadcastRadio::getImage) */
+ ALBUM_ART,
+};
+
+/**
+ * An element of metadata vector.
+ *
+ * Contains one of the entries explained in MetadataKey.
+ *
+ * Depending on a type described in the comment for a specific key, either the
+ * intValue or stringValue field must be populated.
+ */
+struct Metadata {
+ /**
+ * Maps to MetadataKey enum. The enum may be extended in future versions
+ * of the HAL. Values out of the enum range must not be used when writing
+ * and ignored when reading.
+ */
+ uint32_t key;
+
+ int64_t intValue;
+ string stringValue;
+};
diff --git a/camera/metadata/3.2/types.hal b/camera/metadata/3.2/types.hal
index 17d1d5e..67b4e44 100644
--- a/camera/metadata/3.2/types.hal
+++ b/camera/metadata/3.2/types.hal
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2017 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.
@@ -14,13 +14,17 @@
* limitations under the License.
*/
+/*
+ * Autogenerated from camera metadata definitions in
+ * /system/media/camera/docs/metadata_definitions.xml
+ * *** DO NOT EDIT BY HAND ***
+ */
+
package android.hardware.camera.metadata@3.2;
/**
* Top level hierarchy definitions for camera metadata. *_INFO sections are for
* the static metadata that can be retrived without opening the camera device.
- * New sections must be added right before ANDROID_SECTION_COUNT to maintain
- * existing enumerations.
*/
enum CameraMetadataSection : uint32_t {
ANDROID_COLOR_CORRECTION,
@@ -82,7 +86,7 @@
};
/**
- * Hierarchy positions in enum space. All vendor extension tags must be
+ * Hierarchy positions in enum space. All vendor extension sections must be
* defined with tag >= VENDOR_SECTION_START
*/
enum CameraMetadataSectionStart : uint32_t {
@@ -143,1175 +147,2325 @@
};
/**
- * Main enum for defining camera metadata tags. New entries must always go
- * before the section _END tag to preserve existing enumeration values. In
- * addition, the name and type of the tag needs to be added to
- * system/media/camera/src/camera_metadata_tag_info.c
+ * Main enumeration for defining camera metadata tags added in this revision
+ *
+ * <p>Partial documentation is included for each tag; for complete documentation, reference
+ * '/system/media/camera/docs/docs.html' in the corresponding Android source tree.</p>
*/
enum CameraMetadataTag : uint32_t {
+ /** android.colorCorrection.mode [dynamic, enum, public]
+ *
+ * <p>The mode control selects how the image data is converted from the
+ * sensor's native color into linear sRGB color.</p>
+ */
ANDROID_COLOR_CORRECTION_MODE = CameraMetadataSectionStart:ANDROID_COLOR_CORRECTION_START,
+ /** android.colorCorrection.transform [dynamic, rational[], public]
+ *
+ * <p>A color transform matrix to use to transform
+ * from sensor RGB color space to output linear sRGB color space.</p>
+ */
ANDROID_COLOR_CORRECTION_TRANSFORM,
+ /** android.colorCorrection.gains [dynamic, float[], public]
+ *
+ * <p>Gains applying to Bayer raw color channels for
+ * white-balance.</p>
+ */
ANDROID_COLOR_CORRECTION_GAINS,
+ /** android.colorCorrection.aberrationMode [dynamic, enum, public]
+ *
+ * <p>Mode of operation for the chromatic aberration correction algorithm.</p>
+ */
ANDROID_COLOR_CORRECTION_ABERRATION_MODE,
+ /** android.colorCorrection.availableAberrationModes [static, byte[], public]
+ *
+ * <p>List of aberration correction modes for ANDROID_COLOR_CORRECTION_ABERRATION_MODE that are
+ * supported by this camera device.</p>
+ *
+ * @see ANDROID_COLOR_CORRECTION_ABERRATION_MODE
+ */
ANDROID_COLOR_CORRECTION_AVAILABLE_ABERRATION_MODES,
ANDROID_COLOR_CORRECTION_END,
+ /** android.control.aeAntibandingMode [dynamic, enum, public]
+ *
+ * <p>The desired setting for the camera device's auto-exposure
+ * algorithm's antibanding compensation.</p>
+ */
ANDROID_CONTROL_AE_ANTIBANDING_MODE = CameraMetadataSectionStart:ANDROID_CONTROL_START,
+ /** android.control.aeExposureCompensation [dynamic, int32, public]
+ *
+ * <p>Adjustment to auto-exposure (AE) target image
+ * brightness.</p>
+ */
ANDROID_CONTROL_AE_EXPOSURE_COMPENSATION,
+ /** android.control.aeLock [dynamic, enum, public]
+ *
+ * <p>Whether auto-exposure (AE) is currently locked to its latest
+ * calculated values.</p>
+ */
ANDROID_CONTROL_AE_LOCK,
+ /** android.control.aeMode [dynamic, enum, public]
+ *
+ * <p>The desired mode for the camera device's
+ * auto-exposure routine.</p>
+ */
ANDROID_CONTROL_AE_MODE,
+ /** android.control.aeRegions [dynamic, int32[], public]
+ *
+ * <p>List of metering areas to use for auto-exposure adjustment.</p>
+ */
ANDROID_CONTROL_AE_REGIONS,
+ /** android.control.aeTargetFpsRange [dynamic, int32[], public]
+ *
+ * <p>Range over which the auto-exposure routine can
+ * adjust the capture frame rate to maintain good
+ * exposure.</p>
+ */
ANDROID_CONTROL_AE_TARGET_FPS_RANGE,
+ /** android.control.aePrecaptureTrigger [dynamic, enum, public]
+ *
+ * <p>Whether the camera device will trigger a precapture
+ * metering sequence when it processes this request.</p>
+ */
ANDROID_CONTROL_AE_PRECAPTURE_TRIGGER,
+ /** android.control.afMode [dynamic, enum, public]
+ *
+ * <p>Whether auto-focus (AF) is currently enabled, and what
+ * mode it is set to.</p>
+ */
ANDROID_CONTROL_AF_MODE,
+ /** android.control.afRegions [dynamic, int32[], public]
+ *
+ * <p>List of metering areas to use for auto-focus.</p>
+ */
ANDROID_CONTROL_AF_REGIONS,
+ /** android.control.afTrigger [dynamic, enum, public]
+ *
+ * <p>Whether the camera device will trigger autofocus for this request.</p>
+ */
ANDROID_CONTROL_AF_TRIGGER,
+ /** android.control.awbLock [dynamic, enum, public]
+ *
+ * <p>Whether auto-white balance (AWB) is currently locked to its
+ * latest calculated values.</p>
+ */
ANDROID_CONTROL_AWB_LOCK,
+ /** android.control.awbMode [dynamic, enum, public]
+ *
+ * <p>Whether auto-white balance (AWB) is currently setting the color
+ * transform fields, and what its illumination target
+ * is.</p>
+ */
ANDROID_CONTROL_AWB_MODE,
+ /** android.control.awbRegions [dynamic, int32[], public]
+ *
+ * <p>List of metering areas to use for auto-white-balance illuminant
+ * estimation.</p>
+ */
ANDROID_CONTROL_AWB_REGIONS,
+ /** android.control.captureIntent [dynamic, enum, public]
+ *
+ * <p>Information to the camera device 3A (auto-exposure,
+ * auto-focus, auto-white balance) routines about the purpose
+ * of this capture, to help the camera device to decide optimal 3A
+ * strategy.</p>
+ */
ANDROID_CONTROL_CAPTURE_INTENT,
+ /** android.control.effectMode [dynamic, enum, public]
+ *
+ * <p>A special color effect to apply.</p>
+ */
ANDROID_CONTROL_EFFECT_MODE,
+ /** android.control.mode [dynamic, enum, public]
+ *
+ * <p>Overall mode of 3A (auto-exposure, auto-white-balance, auto-focus) control
+ * routines.</p>
+ */
ANDROID_CONTROL_MODE,
+ /** android.control.sceneMode [dynamic, enum, public]
+ *
+ * <p>Control for which scene mode is currently active.</p>
+ */
ANDROID_CONTROL_SCENE_MODE,
+ /** android.control.videoStabilizationMode [dynamic, enum, public]
+ *
+ * <p>Whether video stabilization is
+ * active.</p>
+ */
ANDROID_CONTROL_VIDEO_STABILIZATION_MODE,
+ /** android.control.aeAvailableAntibandingModes [static, byte[], public]
+ *
+ * <p>List of auto-exposure antibanding modes for ANDROID_CONTROL_AE_ANTIBANDING_MODE that are
+ * supported by this camera device.</p>
+ *
+ * @see ANDROID_CONTROL_AE_ANTIBANDING_MODE
+ */
ANDROID_CONTROL_AE_AVAILABLE_ANTIBANDING_MODES,
+ /** android.control.aeAvailableModes [static, byte[], public]
+ *
+ * <p>List of auto-exposure modes for ANDROID_CONTROL_AE_MODE that are supported by this camera
+ * device.</p>
+ *
+ * @see ANDROID_CONTROL_AE_MODE
+ */
ANDROID_CONTROL_AE_AVAILABLE_MODES,
+ /** android.control.aeAvailableTargetFpsRanges [static, int32[], public]
+ *
+ * <p>List of frame rate ranges for ANDROID_CONTROL_AE_TARGET_FPS_RANGE supported by
+ * this camera device.</p>
+ *
+ * @see ANDROID_CONTROL_AE_TARGET_FPS_RANGE
+ */
ANDROID_CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES,
+ /** android.control.aeCompensationRange [static, int32[], public]
+ *
+ * <p>Maximum and minimum exposure compensation values for
+ * ANDROID_CONTROL_AE_EXPOSURE_COMPENSATION, in counts of ANDROID_CONTROL_AE_COMPENSATION_STEP,
+ * that are supported by this camera device.</p>
+ *
+ * @see ANDROID_CONTROL_AE_COMPENSATION_STEP
+ * @see ANDROID_CONTROL_AE_EXPOSURE_COMPENSATION
+ */
ANDROID_CONTROL_AE_COMPENSATION_RANGE,
+ /** android.control.aeCompensationStep [static, rational, public]
+ *
+ * <p>Smallest step by which the exposure compensation
+ * can be changed.</p>
+ */
ANDROID_CONTROL_AE_COMPENSATION_STEP,
+ /** android.control.afAvailableModes [static, byte[], public]
+ *
+ * <p>List of auto-focus (AF) modes for ANDROID_CONTROL_AF_MODE that are
+ * supported by this camera device.</p>
+ *
+ * @see ANDROID_CONTROL_AF_MODE
+ */
ANDROID_CONTROL_AF_AVAILABLE_MODES,
+ /** android.control.availableEffects [static, byte[], public]
+ *
+ * <p>List of color effects for ANDROID_CONTROL_EFFECT_MODE that are supported by this camera
+ * device.</p>
+ *
+ * @see ANDROID_CONTROL_EFFECT_MODE
+ */
ANDROID_CONTROL_AVAILABLE_EFFECTS,
+ /** android.control.availableSceneModes [static, byte[], public]
+ *
+ * <p>List of scene modes for ANDROID_CONTROL_SCENE_MODE that are supported by this camera
+ * device.</p>
+ *
+ * @see ANDROID_CONTROL_SCENE_MODE
+ */
ANDROID_CONTROL_AVAILABLE_SCENE_MODES,
+ /** android.control.availableVideoStabilizationModes [static, byte[], public]
+ *
+ * <p>List of video stabilization modes for ANDROID_CONTROL_VIDEO_STABILIZATION_MODE
+ * that are supported by this camera device.</p>
+ *
+ * @see ANDROID_CONTROL_VIDEO_STABILIZATION_MODE
+ */
ANDROID_CONTROL_AVAILABLE_VIDEO_STABILIZATION_MODES,
+ /** android.control.awbAvailableModes [static, byte[], public]
+ *
+ * <p>List of auto-white-balance modes for ANDROID_CONTROL_AWB_MODE that are supported by this
+ * camera device.</p>
+ *
+ * @see ANDROID_CONTROL_AWB_MODE
+ */
ANDROID_CONTROL_AWB_AVAILABLE_MODES,
+ /** android.control.maxRegions [static, int32[], ndk_public]
+ *
+ * <p>List of the maximum number of regions that can be used for metering in
+ * auto-exposure (AE), auto-white balance (AWB), and auto-focus (AF);
+ * this corresponds to the the maximum number of elements in
+ * ANDROID_CONTROL_AE_REGIONS, ANDROID_CONTROL_AWB_REGIONS,
+ * and ANDROID_CONTROL_AF_REGIONS.</p>
+ *
+ * @see ANDROID_CONTROL_AE_REGIONS
+ * @see ANDROID_CONTROL_AF_REGIONS
+ * @see ANDROID_CONTROL_AWB_REGIONS
+ */
ANDROID_CONTROL_MAX_REGIONS,
+ /** android.control.sceneModeOverrides [static, byte[], system]
+ *
+ * <p>Ordered list of auto-exposure, auto-white balance, and auto-focus
+ * settings to use with each available scene mode.</p>
+ */
ANDROID_CONTROL_SCENE_MODE_OVERRIDES,
+ /** android.control.aePrecaptureId [dynamic, int32, system]
+ *
+ * <p>The ID sent with the latest
+ * CAMERA2_TRIGGER_PRECAPTURE_METERING call</p>
+ */
ANDROID_CONTROL_AE_PRECAPTURE_ID,
+ /** android.control.aeState [dynamic, enum, public]
+ *
+ * <p>Current state of the auto-exposure (AE) algorithm.</p>
+ */
ANDROID_CONTROL_AE_STATE,
+ /** android.control.afState [dynamic, enum, public]
+ *
+ * <p>Current state of auto-focus (AF) algorithm.</p>
+ */
ANDROID_CONTROL_AF_STATE,
+ /** android.control.afTriggerId [dynamic, int32, system]
+ *
+ * <p>The ID sent with the latest
+ * CAMERA2_TRIGGER_AUTOFOCUS call</p>
+ */
ANDROID_CONTROL_AF_TRIGGER_ID,
+ /** android.control.awbState [dynamic, enum, public]
+ *
+ * <p>Current state of auto-white balance (AWB) algorithm.</p>
+ */
ANDROID_CONTROL_AWB_STATE,
+ /** android.control.availableHighSpeedVideoConfigurations [static, int32[], hidden]
+ *
+ * <p>List of available high speed video size, fps range and max batch size configurations
+ * supported by the camera device, in the format of (width, height, fps_min, fps_max, batch_size_max).</p>
+ */
ANDROID_CONTROL_AVAILABLE_HIGH_SPEED_VIDEO_CONFIGURATIONS,
+ /** android.control.aeLockAvailable [static, enum, public]
+ *
+ * <p>Whether the camera device supports ANDROID_CONTROL_AE_LOCK</p>
+ *
+ * @see ANDROID_CONTROL_AE_LOCK
+ */
ANDROID_CONTROL_AE_LOCK_AVAILABLE,
+ /** android.control.awbLockAvailable [static, enum, public]
+ *
+ * <p>Whether the camera device supports ANDROID_CONTROL_AWB_LOCK</p>
+ *
+ * @see ANDROID_CONTROL_AWB_LOCK
+ */
ANDROID_CONTROL_AWB_LOCK_AVAILABLE,
+ /** android.control.availableModes [static, byte[], public]
+ *
+ * <p>List of control modes for ANDROID_CONTROL_MODE that are supported by this camera
+ * device.</p>
+ *
+ * @see ANDROID_CONTROL_MODE
+ */
ANDROID_CONTROL_AVAILABLE_MODES,
+ /** android.control.postRawSensitivityBoostRange [static, int32[], public]
+ *
+ * <p>Range of boosts for ANDROID_CONTROL_POST_RAW_SENSITIVITY_BOOST supported
+ * by this camera device.</p>
+ *
+ * @see ANDROID_CONTROL_POST_RAW_SENSITIVITY_BOOST
+ */
ANDROID_CONTROL_POST_RAW_SENSITIVITY_BOOST_RANGE,
+ /** android.control.postRawSensitivityBoost [dynamic, int32, public]
+ *
+ * <p>The amount of additional sensitivity boost applied to output images
+ * after RAW sensor data is captured.</p>
+ */
ANDROID_CONTROL_POST_RAW_SENSITIVITY_BOOST,
+ /** android.control.enableZsl [dynamic, enum, public]
+ *
+ * <p>Allow camera device to enable zero-shutter-lag mode for requests with
+ * ANDROID_CONTROL_CAPTURE_INTENT == STILL_CAPTURE.</p>
+ *
+ * @see ANDROID_CONTROL_CAPTURE_INTENT
+ */
ANDROID_CONTROL_ENABLE_ZSL,
ANDROID_CONTROL_END,
+ /** android.demosaic.mode [controls, enum, system]
+ *
+ * <p>Controls the quality of the demosaicing
+ * processing.</p>
+ */
ANDROID_DEMOSAIC_MODE = CameraMetadataSectionStart:ANDROID_DEMOSAIC_START,
ANDROID_DEMOSAIC_END,
+ /** android.edge.mode [dynamic, enum, public]
+ *
+ * <p>Operation mode for edge
+ * enhancement.</p>
+ */
ANDROID_EDGE_MODE = CameraMetadataSectionStart:ANDROID_EDGE_START,
+ /** android.edge.strength [controls, byte, system]
+ *
+ * <p>Control the amount of edge enhancement
+ * applied to the images</p>
+ */
ANDROID_EDGE_STRENGTH,
+ /** android.edge.availableEdgeModes [static, byte[], public]
+ *
+ * <p>List of edge enhancement modes for ANDROID_EDGE_MODE that are supported by this camera
+ * device.</p>
+ *
+ * @see ANDROID_EDGE_MODE
+ */
ANDROID_EDGE_AVAILABLE_EDGE_MODES,
ANDROID_EDGE_END,
+ /** android.flash.firingPower [dynamic, byte, system]
+ *
+ * <p>Power for flash firing/torch</p>
+ */
ANDROID_FLASH_FIRING_POWER = CameraMetadataSectionStart:ANDROID_FLASH_START,
+ /** android.flash.firingTime [dynamic, int64, system]
+ *
+ * <p>Firing time of flash relative to start of
+ * exposure</p>
+ */
ANDROID_FLASH_FIRING_TIME,
+ /** android.flash.mode [dynamic, enum, public]
+ *
+ * <p>The desired mode for for the camera device's flash control.</p>
+ */
ANDROID_FLASH_MODE,
+ /** android.flash.colorTemperature [static, byte, system]
+ *
+ * <p>The x,y whitepoint of the
+ * flash</p>
+ */
ANDROID_FLASH_COLOR_TEMPERATURE,
+ /** android.flash.maxEnergy [static, byte, system]
+ *
+ * <p>Max energy output of the flash for a full
+ * power single flash</p>
+ */
ANDROID_FLASH_MAX_ENERGY,
+ /** android.flash.state [dynamic, enum, public]
+ *
+ * <p>Current state of the flash
+ * unit.</p>
+ */
ANDROID_FLASH_STATE,
ANDROID_FLASH_END,
+ /** android.flash.info.available [static, enum, public]
+ *
+ * <p>Whether this camera device has a
+ * flash unit.</p>
+ */
ANDROID_FLASH_INFO_AVAILABLE = CameraMetadataSectionStart:ANDROID_FLASH_INFO_START,
+ /** android.flash.info.chargeDuration [static, int64, system]
+ *
+ * <p>Time taken before flash can fire
+ * again</p>
+ */
ANDROID_FLASH_INFO_CHARGE_DURATION,
ANDROID_FLASH_INFO_END,
+ /** android.hotPixel.mode [dynamic, enum, public]
+ *
+ * <p>Operational mode for hot pixel correction.</p>
+ */
ANDROID_HOT_PIXEL_MODE = CameraMetadataSectionStart:ANDROID_HOT_PIXEL_START,
+ /** android.hotPixel.availableHotPixelModes [static, byte[], public]
+ *
+ * <p>List of hot pixel correction modes for ANDROID_HOT_PIXEL_MODE that are supported by this
+ * camera device.</p>
+ *
+ * @see ANDROID_HOT_PIXEL_MODE
+ */
ANDROID_HOT_PIXEL_AVAILABLE_HOT_PIXEL_MODES,
ANDROID_HOT_PIXEL_END,
+ /** android.jpeg.gpsCoordinates [dynamic, double[], ndk_public]
+ *
+ * <p>GPS coordinates to include in output JPEG
+ * EXIF.</p>
+ */
ANDROID_JPEG_GPS_COORDINATES = CameraMetadataSectionStart:ANDROID_JPEG_START,
+ /** android.jpeg.gpsProcessingMethod [dynamic, byte, ndk_public]
+ *
+ * <p>32 characters describing GPS algorithm to
+ * include in EXIF.</p>
+ */
ANDROID_JPEG_GPS_PROCESSING_METHOD,
+ /** android.jpeg.gpsTimestamp [dynamic, int64, ndk_public]
+ *
+ * <p>Time GPS fix was made to include in
+ * EXIF.</p>
+ */
ANDROID_JPEG_GPS_TIMESTAMP,
+ /** android.jpeg.orientation [dynamic, int32, public]
+ *
+ * <p>The orientation for a JPEG image.</p>
+ */
ANDROID_JPEG_ORIENTATION,
+ /** android.jpeg.quality [dynamic, byte, public]
+ *
+ * <p>Compression quality of the final JPEG
+ * image.</p>
+ */
ANDROID_JPEG_QUALITY,
+ /** android.jpeg.thumbnailQuality [dynamic, byte, public]
+ *
+ * <p>Compression quality of JPEG
+ * thumbnail.</p>
+ */
ANDROID_JPEG_THUMBNAIL_QUALITY,
+ /** android.jpeg.thumbnailSize [dynamic, int32[], public]
+ *
+ * <p>Resolution of embedded JPEG thumbnail.</p>
+ */
ANDROID_JPEG_THUMBNAIL_SIZE,
+ /** android.jpeg.availableThumbnailSizes [static, int32[], public]
+ *
+ * <p>List of JPEG thumbnail sizes for ANDROID_JPEG_THUMBNAIL_SIZE supported by this
+ * camera device.</p>
+ *
+ * @see ANDROID_JPEG_THUMBNAIL_SIZE
+ */
ANDROID_JPEG_AVAILABLE_THUMBNAIL_SIZES,
+ /** android.jpeg.maxSize [static, int32, system]
+ *
+ * <p>Maximum size in bytes for the compressed
+ * JPEG buffer</p>
+ */
ANDROID_JPEG_MAX_SIZE,
+ /** android.jpeg.size [dynamic, int32, system]
+ *
+ * <p>The size of the compressed JPEG image, in
+ * bytes</p>
+ */
ANDROID_JPEG_SIZE,
ANDROID_JPEG_END,
+ /** android.lens.aperture [dynamic, float, public]
+ *
+ * <p>The desired lens aperture size, as a ratio of lens focal length to the
+ * effective aperture diameter.</p>
+ */
ANDROID_LENS_APERTURE = CameraMetadataSectionStart:ANDROID_LENS_START,
+ /** android.lens.filterDensity [dynamic, float, public]
+ *
+ * <p>The desired setting for the lens neutral density filter(s).</p>
+ */
ANDROID_LENS_FILTER_DENSITY,
+ /** android.lens.focalLength [dynamic, float, public]
+ *
+ * <p>The desired lens focal length; used for optical zoom.</p>
+ */
ANDROID_LENS_FOCAL_LENGTH,
+ /** android.lens.focusDistance [dynamic, float, public]
+ *
+ * <p>Desired distance to plane of sharpest focus,
+ * measured from frontmost surface of the lens.</p>
+ */
ANDROID_LENS_FOCUS_DISTANCE,
+ /** android.lens.opticalStabilizationMode [dynamic, enum, public]
+ *
+ * <p>Sets whether the camera device uses optical image stabilization (OIS)
+ * when capturing images.</p>
+ */
ANDROID_LENS_OPTICAL_STABILIZATION_MODE,
+ /** android.lens.facing [static, enum, public]
+ *
+ * <p>Direction the camera faces relative to
+ * device screen.</p>
+ */
ANDROID_LENS_FACING,
+ /** android.lens.poseRotation [dynamic, float[], public]
+ *
+ * <p>The orientation of the camera relative to the sensor
+ * coordinate system.</p>
+ */
ANDROID_LENS_POSE_ROTATION,
+ /** android.lens.poseTranslation [dynamic, float[], public]
+ *
+ * <p>Position of the camera optical center.</p>
+ */
ANDROID_LENS_POSE_TRANSLATION,
+ /** android.lens.focusRange [dynamic, float[], public]
+ *
+ * <p>The range of scene distances that are in
+ * sharp focus (depth of field).</p>
+ */
ANDROID_LENS_FOCUS_RANGE,
+ /** android.lens.state [dynamic, enum, public]
+ *
+ * <p>Current lens status.</p>
+ */
ANDROID_LENS_STATE,
+ /** android.lens.intrinsicCalibration [dynamic, float[], public]
+ *
+ * <p>The parameters for this camera device's intrinsic
+ * calibration.</p>
+ */
ANDROID_LENS_INTRINSIC_CALIBRATION,
+ /** android.lens.radialDistortion [dynamic, float[], public]
+ *
+ * <p>The correction coefficients to correct for this camera device's
+ * radial and tangential lens distortion.</p>
+ */
ANDROID_LENS_RADIAL_DISTORTION,
ANDROID_LENS_END,
+ /** android.lens.info.availableApertures [static, float[], public]
+ *
+ * <p>List of aperture size values for ANDROID_LENS_APERTURE that are
+ * supported by this camera device.</p>
+ *
+ * @see ANDROID_LENS_APERTURE
+ */
ANDROID_LENS_INFO_AVAILABLE_APERTURES = CameraMetadataSectionStart:ANDROID_LENS_INFO_START,
+ /** android.lens.info.availableFilterDensities [static, float[], public]
+ *
+ * <p>List of neutral density filter values for
+ * ANDROID_LENS_FILTER_DENSITY that are supported by this camera device.</p>
+ *
+ * @see ANDROID_LENS_FILTER_DENSITY
+ */
ANDROID_LENS_INFO_AVAILABLE_FILTER_DENSITIES,
+ /** android.lens.info.availableFocalLengths [static, float[], public]
+ *
+ * <p>List of focal lengths for ANDROID_LENS_FOCAL_LENGTH that are supported by this camera
+ * device.</p>
+ *
+ * @see ANDROID_LENS_FOCAL_LENGTH
+ */
ANDROID_LENS_INFO_AVAILABLE_FOCAL_LENGTHS,
+ /** android.lens.info.availableOpticalStabilization [static, byte[], public]
+ *
+ * <p>List of optical image stabilization (OIS) modes for
+ * ANDROID_LENS_OPTICAL_STABILIZATION_MODE that are supported by this camera device.</p>
+ *
+ * @see ANDROID_LENS_OPTICAL_STABILIZATION_MODE
+ */
ANDROID_LENS_INFO_AVAILABLE_OPTICAL_STABILIZATION,
+ /** android.lens.info.hyperfocalDistance [static, float, public]
+ *
+ * <p>Hyperfocal distance for this lens.</p>
+ */
ANDROID_LENS_INFO_HYPERFOCAL_DISTANCE,
+ /** android.lens.info.minimumFocusDistance [static, float, public]
+ *
+ * <p>Shortest distance from frontmost surface
+ * of the lens that can be brought into sharp focus.</p>
+ */
ANDROID_LENS_INFO_MINIMUM_FOCUS_DISTANCE,
+ /** android.lens.info.shadingMapSize [static, int32[], ndk_public]
+ *
+ * <p>Dimensions of lens shading map.</p>
+ */
ANDROID_LENS_INFO_SHADING_MAP_SIZE,
+ /** android.lens.info.focusDistanceCalibration [static, enum, public]
+ *
+ * <p>The lens focus distance calibration quality.</p>
+ */
ANDROID_LENS_INFO_FOCUS_DISTANCE_CALIBRATION,
ANDROID_LENS_INFO_END,
+ /** android.noiseReduction.mode [dynamic, enum, public]
+ *
+ * <p>Mode of operation for the noise reduction algorithm.</p>
+ */
ANDROID_NOISE_REDUCTION_MODE = CameraMetadataSectionStart:ANDROID_NOISE_REDUCTION_START,
+ /** android.noiseReduction.strength [controls, byte, system]
+ *
+ * <p>Control the amount of noise reduction
+ * applied to the images</p>
+ */
ANDROID_NOISE_REDUCTION_STRENGTH,
+ /** android.noiseReduction.availableNoiseReductionModes [static, byte[], public]
+ *
+ * <p>List of noise reduction modes for ANDROID_NOISE_REDUCTION_MODE that are supported
+ * by this camera device.</p>
+ *
+ * @see ANDROID_NOISE_REDUCTION_MODE
+ */
ANDROID_NOISE_REDUCTION_AVAILABLE_NOISE_REDUCTION_MODES,
ANDROID_NOISE_REDUCTION_END,
+ /** android.quirks.meteringCropRegion [static, byte, system]
+ *
+ * <p>If set to 1, the camera service does not
+ * scale 'normalized' coordinates with respect to the crop
+ * region. This applies to metering input (a{e,f,wb}Region
+ * and output (face rectangles).</p>
+ */
ANDROID_QUIRKS_METERING_CROP_REGION = CameraMetadataSectionStart:ANDROID_QUIRKS_START,
+ /** android.quirks.triggerAfWithAuto [static, byte, system]
+ *
+ * <p>If set to 1, then the camera service always
+ * switches to FOCUS_MODE_AUTO before issuing a AF
+ * trigger.</p>
+ */
ANDROID_QUIRKS_TRIGGER_AF_WITH_AUTO,
+ /** android.quirks.useZslFormat [static, byte, system]
+ *
+ * <p>If set to 1, the camera service uses
+ * CAMERA2_PIXEL_FORMAT_ZSL instead of
+ * HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED for the zero
+ * shutter lag stream</p>
+ */
ANDROID_QUIRKS_USE_ZSL_FORMAT,
+ /** android.quirks.usePartialResult [static, byte, hidden]
+ *
+ * <p>If set to 1, the HAL will always split result
+ * metadata for a single capture into multiple buffers,
+ * returned using multiple process_capture_result calls.</p>
+ */
ANDROID_QUIRKS_USE_PARTIAL_RESULT,
+ /** android.quirks.partialResult [dynamic, enum, hidden]
+ *
+ * <p>Whether a result given to the framework is the
+ * final one for the capture, or only a partial that contains a
+ * subset of the full set of dynamic metadata
+ * values.</p>
+ */
ANDROID_QUIRKS_PARTIAL_RESULT,
ANDROID_QUIRKS_END,
+ /** android.request.frameCount [dynamic, int32, hidden]
+ *
+ * <p>A frame counter set by the framework. This value monotonically
+ * increases with every new result (that is, each new result has a unique
+ * frameCount value).</p>
+ */
ANDROID_REQUEST_FRAME_COUNT = CameraMetadataSectionStart:ANDROID_REQUEST_START,
+ /** android.request.id [dynamic, int32, hidden]
+ *
+ * <p>An application-specified ID for the current
+ * request. Must be maintained unchanged in output
+ * frame</p>
+ */
ANDROID_REQUEST_ID,
+ /** android.request.inputStreams [controls, int32[], system]
+ *
+ * <p>List which camera reprocess stream is used
+ * for the source of reprocessing data.</p>
+ */
ANDROID_REQUEST_INPUT_STREAMS,
+ /** android.request.metadataMode [dynamic, enum, system]
+ *
+ * <p>How much metadata to produce on
+ * output</p>
+ */
ANDROID_REQUEST_METADATA_MODE,
+ /** android.request.outputStreams [dynamic, int32[], system]
+ *
+ * <p>Lists which camera output streams image data
+ * from this capture must be sent to</p>
+ */
ANDROID_REQUEST_OUTPUT_STREAMS,
+ /** android.request.type [controls, enum, system]
+ *
+ * <p>The type of the request; either CAPTURE or
+ * REPROCESS. For legacy HAL3, this tag is redundant.</p>
+ */
ANDROID_REQUEST_TYPE,
+ /** android.request.maxNumOutputStreams [static, int32[], ndk_public]
+ *
+ * <p>The maximum numbers of different types of output streams
+ * that can be configured and used simultaneously by a camera device.</p>
+ */
ANDROID_REQUEST_MAX_NUM_OUTPUT_STREAMS,
+ /** android.request.maxNumReprocessStreams [static, int32[], system]
+ *
+ * <p>How many reprocessing streams of any type
+ * can be allocated at the same time.</p>
+ */
ANDROID_REQUEST_MAX_NUM_REPROCESS_STREAMS,
+ /** android.request.maxNumInputStreams [static, int32, java_public]
+ *
+ * <p>The maximum numbers of any type of input streams
+ * that can be configured and used simultaneously by a camera device.</p>
+ */
ANDROID_REQUEST_MAX_NUM_INPUT_STREAMS,
+ /** android.request.pipelineDepth [dynamic, byte, public]
+ *
+ * <p>Specifies the number of pipeline stages the frame went
+ * through from when it was exposed to when the final completed result
+ * was available to the framework.</p>
+ */
ANDROID_REQUEST_PIPELINE_DEPTH,
+ /** android.request.pipelineMaxDepth [static, byte, public]
+ *
+ * <p>Specifies the number of maximum pipeline stages a frame
+ * has to go through from when it's exposed to when it's available
+ * to the framework.</p>
+ */
ANDROID_REQUEST_PIPELINE_MAX_DEPTH,
+ /** android.request.partialResultCount [static, int32, public]
+ *
+ * <p>Defines how many sub-components
+ * a result will be composed of.</p>
+ */
ANDROID_REQUEST_PARTIAL_RESULT_COUNT,
+ /** android.request.availableCapabilities [static, enum[], public]
+ *
+ * <p>List of capabilities that this camera device
+ * advertises as fully supporting.</p>
+ */
ANDROID_REQUEST_AVAILABLE_CAPABILITIES,
+ /** android.request.availableRequestKeys [static, int32[], ndk_public]
+ *
+ * <p>A list of all keys that the camera device has available
+ * to use with {@link ACaptureRequest }.</p>
+ */
ANDROID_REQUEST_AVAILABLE_REQUEST_KEYS,
+ /** android.request.availableResultKeys [static, int32[], ndk_public]
+ *
+ * <p>A list of all keys that the camera device has available to use with {@link ACameraCaptureSession_captureCallback_result }.</p>
+ */
ANDROID_REQUEST_AVAILABLE_RESULT_KEYS,
+ /** android.request.availableCharacteristicsKeys [static, int32[], ndk_public]
+ *
+ * <p>A list of all keys that the camera device has available to use with {@link ACameraManager_getCameraCharacteristics }.</p>
+ */
ANDROID_REQUEST_AVAILABLE_CHARACTERISTICS_KEYS,
ANDROID_REQUEST_END,
+ /** android.scaler.cropRegion [dynamic, int32[], public]
+ *
+ * <p>The desired region of the sensor to read out for this capture.</p>
+ */
ANDROID_SCALER_CROP_REGION = CameraMetadataSectionStart:ANDROID_SCALER_START,
+ /** android.scaler.availableFormats [static, enum[], hidden]
+ *
+ * <p>The list of image formats that are supported by this
+ * camera device for output streams.</p>
+ */
ANDROID_SCALER_AVAILABLE_FORMATS,
+ /** android.scaler.availableJpegMinDurations [static, int64[], hidden]
+ *
+ * <p>The minimum frame duration that is supported
+ * for each resolution in ANDROID_SCALER_AVAILABLE_JPEG_SIZES.</p>
+ *
+ * @see ANDROID_SCALER_AVAILABLE_JPEG_SIZES
+ */
ANDROID_SCALER_AVAILABLE_JPEG_MIN_DURATIONS,
+ /** android.scaler.availableJpegSizes [static, int32[], hidden]
+ *
+ * <p>The JPEG resolutions that are supported by this camera device.</p>
+ */
ANDROID_SCALER_AVAILABLE_JPEG_SIZES,
+ /** android.scaler.availableMaxDigitalZoom [static, float, public]
+ *
+ * <p>The maximum ratio between both active area width
+ * and crop region width, and active area height and
+ * crop region height, for ANDROID_SCALER_CROP_REGION.</p>
+ *
+ * @see ANDROID_SCALER_CROP_REGION
+ */
ANDROID_SCALER_AVAILABLE_MAX_DIGITAL_ZOOM,
+ /** android.scaler.availableProcessedMinDurations [static, int64[], hidden]
+ *
+ * <p>For each available processed output size (defined in
+ * ANDROID_SCALER_AVAILABLE_PROCESSED_SIZES), this property lists the
+ * minimum supportable frame duration for that size.</p>
+ *
+ * @see ANDROID_SCALER_AVAILABLE_PROCESSED_SIZES
+ */
ANDROID_SCALER_AVAILABLE_PROCESSED_MIN_DURATIONS,
+ /** android.scaler.availableProcessedSizes [static, int32[], hidden]
+ *
+ * <p>The resolutions available for use with
+ * processed output streams, such as YV12, NV12, and
+ * platform opaque YUV/RGB streams to the GPU or video
+ * encoders.</p>
+ */
ANDROID_SCALER_AVAILABLE_PROCESSED_SIZES,
+ /** android.scaler.availableRawMinDurations [static, int64[], system]
+ *
+ * <p>For each available raw output size (defined in
+ * ANDROID_SCALER_AVAILABLE_RAW_SIZES), this property lists the minimum
+ * supportable frame duration for that size.</p>
+ *
+ * @see ANDROID_SCALER_AVAILABLE_RAW_SIZES
+ */
ANDROID_SCALER_AVAILABLE_RAW_MIN_DURATIONS,
+ /** android.scaler.availableRawSizes [static, int32[], system]
+ *
+ * <p>The resolutions available for use with raw
+ * sensor output streams, listed as width,
+ * height</p>
+ */
ANDROID_SCALER_AVAILABLE_RAW_SIZES,
+ /** android.scaler.availableInputOutputFormatsMap [static, int32, hidden]
+ *
+ * <p>The mapping of image formats that are supported by this
+ * camera device for input streams, to their corresponding output formats.</p>
+ */
ANDROID_SCALER_AVAILABLE_INPUT_OUTPUT_FORMATS_MAP,
+ /** android.scaler.availableStreamConfigurations [static, enum[], ndk_public]
+ *
+ * <p>The available stream configurations that this
+ * camera device supports
+ * (i.e. format, width, height, output/input stream).</p>
+ */
ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS,
+ /** android.scaler.availableMinFrameDurations [static, int64[], ndk_public]
+ *
+ * <p>This lists the minimum frame duration for each
+ * format/size combination.</p>
+ */
ANDROID_SCALER_AVAILABLE_MIN_FRAME_DURATIONS,
+ /** android.scaler.availableStallDurations [static, int64[], ndk_public]
+ *
+ * <p>This lists the maximum stall duration for each
+ * output format/size combination.</p>
+ */
ANDROID_SCALER_AVAILABLE_STALL_DURATIONS,
+ /** android.scaler.croppingType [static, enum, public]
+ *
+ * <p>The crop type that this camera device supports.</p>
+ */
ANDROID_SCALER_CROPPING_TYPE,
ANDROID_SCALER_END,
+ /** android.sensor.exposureTime [dynamic, int64, public]
+ *
+ * <p>Duration each pixel is exposed to
+ * light.</p>
+ */
ANDROID_SENSOR_EXPOSURE_TIME = CameraMetadataSectionStart:ANDROID_SENSOR_START,
+ /** android.sensor.frameDuration [dynamic, int64, public]
+ *
+ * <p>Duration from start of frame exposure to
+ * start of next frame exposure.</p>
+ */
ANDROID_SENSOR_FRAME_DURATION,
+ /** android.sensor.sensitivity [dynamic, int32, public]
+ *
+ * <p>The amount of gain applied to sensor data
+ * before processing.</p>
+ */
ANDROID_SENSOR_SENSITIVITY,
+ /** android.sensor.referenceIlluminant1 [static, enum, public]
+ *
+ * <p>The standard reference illuminant used as the scene light source when
+ * calculating the ANDROID_SENSOR_COLOR_TRANSFORM1,
+ * ANDROID_SENSOR_CALIBRATION_TRANSFORM1, and
+ * ANDROID_SENSOR_FORWARD_MATRIX1 matrices.</p>
+ *
+ * @see ANDROID_SENSOR_CALIBRATION_TRANSFORM1
+ * @see ANDROID_SENSOR_COLOR_TRANSFORM1
+ * @see ANDROID_SENSOR_FORWARD_MATRIX1
+ */
ANDROID_SENSOR_REFERENCE_ILLUMINANT1,
+ /** android.sensor.referenceIlluminant2 [static, byte, public]
+ *
+ * <p>The standard reference illuminant used as the scene light source when
+ * calculating the ANDROID_SENSOR_COLOR_TRANSFORM2,
+ * ANDROID_SENSOR_CALIBRATION_TRANSFORM2, and
+ * ANDROID_SENSOR_FORWARD_MATRIX2 matrices.</p>
+ *
+ * @see ANDROID_SENSOR_CALIBRATION_TRANSFORM2
+ * @see ANDROID_SENSOR_COLOR_TRANSFORM2
+ * @see ANDROID_SENSOR_FORWARD_MATRIX2
+ */
ANDROID_SENSOR_REFERENCE_ILLUMINANT2,
+ /** android.sensor.calibrationTransform1 [static, rational[], public]
+ *
+ * <p>A per-device calibration transform matrix that maps from the
+ * reference sensor colorspace to the actual device sensor colorspace.</p>
+ */
ANDROID_SENSOR_CALIBRATION_TRANSFORM1,
+ /** android.sensor.calibrationTransform2 [static, rational[], public]
+ *
+ * <p>A per-device calibration transform matrix that maps from the
+ * reference sensor colorspace to the actual device sensor colorspace
+ * (this is the colorspace of the raw buffer data).</p>
+ */
ANDROID_SENSOR_CALIBRATION_TRANSFORM2,
+ /** android.sensor.colorTransform1 [static, rational[], public]
+ *
+ * <p>A matrix that transforms color values from CIE XYZ color space to
+ * reference sensor color space.</p>
+ */
ANDROID_SENSOR_COLOR_TRANSFORM1,
+ /** android.sensor.colorTransform2 [static, rational[], public]
+ *
+ * <p>A matrix that transforms color values from CIE XYZ color space to
+ * reference sensor color space.</p>
+ */
ANDROID_SENSOR_COLOR_TRANSFORM2,
+ /** android.sensor.forwardMatrix1 [static, rational[], public]
+ *
+ * <p>A matrix that transforms white balanced camera colors from the reference
+ * sensor colorspace to the CIE XYZ colorspace with a D50 whitepoint.</p>
+ */
ANDROID_SENSOR_FORWARD_MATRIX1,
+ /** android.sensor.forwardMatrix2 [static, rational[], public]
+ *
+ * <p>A matrix that transforms white balanced camera colors from the reference
+ * sensor colorspace to the CIE XYZ colorspace with a D50 whitepoint.</p>
+ */
ANDROID_SENSOR_FORWARD_MATRIX2,
+ /** android.sensor.baseGainFactor [static, rational, system]
+ *
+ * <p>Gain factor from electrons to raw units when
+ * ISO=100</p>
+ */
ANDROID_SENSOR_BASE_GAIN_FACTOR,
+ /** android.sensor.blackLevelPattern [static, int32[], public]
+ *
+ * <p>A fixed black level offset for each of the color filter arrangement
+ * (CFA) mosaic channels.</p>
+ */
ANDROID_SENSOR_BLACK_LEVEL_PATTERN,
+ /** android.sensor.maxAnalogSensitivity [static, int32, public]
+ *
+ * <p>Maximum sensitivity that is implemented
+ * purely through analog gain.</p>
+ */
ANDROID_SENSOR_MAX_ANALOG_SENSITIVITY,
+ /** android.sensor.orientation [static, int32, public]
+ *
+ * <p>Clockwise angle through which the output image needs to be rotated to be
+ * upright on the device screen in its native orientation.</p>
+ */
ANDROID_SENSOR_ORIENTATION,
+ /** android.sensor.profileHueSatMapDimensions [static, int32[], system]
+ *
+ * <p>The number of input samples for each dimension of
+ * ANDROID_SENSOR_PROFILE_HUE_SAT_MAP.</p>
+ *
+ * @see ANDROID_SENSOR_PROFILE_HUE_SAT_MAP
+ */
ANDROID_SENSOR_PROFILE_HUE_SAT_MAP_DIMENSIONS,
+ /** android.sensor.timestamp [dynamic, int64, public]
+ *
+ * <p>Time at start of exposure of first
+ * row of the image sensor active array, in nanoseconds.</p>
+ */
ANDROID_SENSOR_TIMESTAMP,
+ /** android.sensor.temperature [dynamic, float, system]
+ *
+ * <p>The temperature of the sensor, sampled at the time
+ * exposure began for this frame.</p>
+ * <p>The thermal diode being queried should be inside the sensor PCB, or
+ * somewhere close to it.</p>
+ */
ANDROID_SENSOR_TEMPERATURE,
+ /** android.sensor.neutralColorPoint [dynamic, rational[], public]
+ *
+ * <p>The estimated camera neutral color in the native sensor colorspace at
+ * the time of capture.</p>
+ */
ANDROID_SENSOR_NEUTRAL_COLOR_POINT,
+ /** android.sensor.noiseProfile [dynamic, double[], public]
+ *
+ * <p>Noise model coefficients for each CFA mosaic channel.</p>
+ */
ANDROID_SENSOR_NOISE_PROFILE,
+ /** android.sensor.profileHueSatMap [dynamic, float[], system]
+ *
+ * <p>A mapping containing a hue shift, saturation scale, and value scale
+ * for each pixel.</p>
+ */
ANDROID_SENSOR_PROFILE_HUE_SAT_MAP,
+ /** android.sensor.profileToneCurve [dynamic, float[], system]
+ *
+ * <p>A list of x,y samples defining a tone-mapping curve for gamma adjustment.</p>
+ */
ANDROID_SENSOR_PROFILE_TONE_CURVE,
+ /** android.sensor.greenSplit [dynamic, float, public]
+ *
+ * <p>The worst-case divergence between Bayer green channels.</p>
+ */
ANDROID_SENSOR_GREEN_SPLIT,
+ /** android.sensor.testPatternData [dynamic, int32[], public]
+ *
+ * <p>A pixel <code>[R, G_even, G_odd, B]</code> that supplies the test pattern
+ * when ANDROID_SENSOR_TEST_PATTERN_MODE is SOLID_COLOR.</p>
+ *
+ * @see ANDROID_SENSOR_TEST_PATTERN_MODE
+ */
ANDROID_SENSOR_TEST_PATTERN_DATA,
+ /** android.sensor.testPatternMode [dynamic, enum, public]
+ *
+ * <p>When enabled, the sensor sends a test pattern instead of
+ * doing a real exposure from the camera.</p>
+ */
ANDROID_SENSOR_TEST_PATTERN_MODE,
+ /** android.sensor.availableTestPatternModes [static, int32[], public]
+ *
+ * <p>List of sensor test pattern modes for ANDROID_SENSOR_TEST_PATTERN_MODE
+ * supported by this camera device.</p>
+ *
+ * @see ANDROID_SENSOR_TEST_PATTERN_MODE
+ */
ANDROID_SENSOR_AVAILABLE_TEST_PATTERN_MODES,
+ /** android.sensor.rollingShutterSkew [dynamic, int64, public]
+ *
+ * <p>Duration between the start of first row exposure
+ * and the start of last row exposure.</p>
+ */
ANDROID_SENSOR_ROLLING_SHUTTER_SKEW,
+ /** android.sensor.opticalBlackRegions [static, int32[], public]
+ *
+ * <p>List of disjoint rectangles indicating the sensor
+ * optically shielded black pixel regions.</p>
+ */
ANDROID_SENSOR_OPTICAL_BLACK_REGIONS,
+ /** android.sensor.dynamicBlackLevel [dynamic, float[], public]
+ *
+ * <p>A per-frame dynamic black level offset for each of the color filter
+ * arrangement (CFA) mosaic channels.</p>
+ */
ANDROID_SENSOR_DYNAMIC_BLACK_LEVEL,
+ /** android.sensor.dynamicWhiteLevel [dynamic, int32, public]
+ *
+ * <p>Maximum raw value output by sensor for this frame.</p>
+ */
ANDROID_SENSOR_DYNAMIC_WHITE_LEVEL,
+ /** android.sensor.opaqueRawSize [static, int32[], system]
+ *
+ * <p>Size in bytes for all the listed opaque RAW buffer sizes</p>
+ */
ANDROID_SENSOR_OPAQUE_RAW_SIZE,
ANDROID_SENSOR_END,
+ /** android.sensor.info.activeArraySize [static, int32[], public]
+ *
+ * <p>The area of the image sensor which corresponds to active pixels after any geometric
+ * distortion correction has been applied.</p>
+ */
ANDROID_SENSOR_INFO_ACTIVE_ARRAY_SIZE = CameraMetadataSectionStart:ANDROID_SENSOR_INFO_START,
+ /** android.sensor.info.sensitivityRange [static, int32[], public]
+ *
+ * <p>Range of sensitivities for ANDROID_SENSOR_SENSITIVITY supported by this
+ * camera device.</p>
+ *
+ * @see ANDROID_SENSOR_SENSITIVITY
+ */
ANDROID_SENSOR_INFO_SENSITIVITY_RANGE,
+ /** android.sensor.info.colorFilterArrangement [static, enum, public]
+ *
+ * <p>The arrangement of color filters on sensor;
+ * represents the colors in the top-left 2x2 section of
+ * the sensor, in reading order.</p>
+ */
ANDROID_SENSOR_INFO_COLOR_FILTER_ARRANGEMENT,
+ /** android.sensor.info.exposureTimeRange [static, int64[], public]
+ *
+ * <p>The range of image exposure times for ANDROID_SENSOR_EXPOSURE_TIME supported
+ * by this camera device.</p>
+ *
+ * @see ANDROID_SENSOR_EXPOSURE_TIME
+ */
ANDROID_SENSOR_INFO_EXPOSURE_TIME_RANGE,
+ /** android.sensor.info.maxFrameDuration [static, int64, public]
+ *
+ * <p>The maximum possible frame duration (minimum frame rate) for
+ * ANDROID_SENSOR_FRAME_DURATION that is supported this camera device.</p>
+ *
+ * @see ANDROID_SENSOR_FRAME_DURATION
+ */
ANDROID_SENSOR_INFO_MAX_FRAME_DURATION,
+ /** android.sensor.info.physicalSize [static, float[], public]
+ *
+ * <p>The physical dimensions of the full pixel
+ * array.</p>
+ */
ANDROID_SENSOR_INFO_PHYSICAL_SIZE,
+ /** android.sensor.info.pixelArraySize [static, int32[], public]
+ *
+ * <p>Dimensions of the full pixel array, possibly
+ * including black calibration pixels.</p>
+ */
ANDROID_SENSOR_INFO_PIXEL_ARRAY_SIZE,
+ /** android.sensor.info.whiteLevel [static, int32, public]
+ *
+ * <p>Maximum raw value output by sensor.</p>
+ */
ANDROID_SENSOR_INFO_WHITE_LEVEL,
+ /** android.sensor.info.timestampSource [static, enum, public]
+ *
+ * <p>The time base source for sensor capture start timestamps.</p>
+ */
ANDROID_SENSOR_INFO_TIMESTAMP_SOURCE,
+ /** android.sensor.info.lensShadingApplied [static, enum, public]
+ *
+ * <p>Whether the RAW images output from this camera device are subject to
+ * lens shading correction.</p>
+ */
ANDROID_SENSOR_INFO_LENS_SHADING_APPLIED,
+ /** android.sensor.info.preCorrectionActiveArraySize [static, int32[], public]
+ *
+ * <p>The area of the image sensor which corresponds to active pixels prior to the
+ * application of any geometric distortion correction.</p>
+ */
ANDROID_SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE,
ANDROID_SENSOR_INFO_END,
+ /** android.shading.mode [dynamic, enum, public]
+ *
+ * <p>Quality of lens shading correction applied
+ * to the image data.</p>
+ */
ANDROID_SHADING_MODE = CameraMetadataSectionStart:ANDROID_SHADING_START,
+ /** android.shading.strength [controls, byte, system]
+ *
+ * <p>Control the amount of shading correction
+ * applied to the images</p>
+ */
ANDROID_SHADING_STRENGTH,
+ /** android.shading.availableModes [static, byte[], public]
+ *
+ * <p>List of lens shading modes for ANDROID_SHADING_MODE that are supported by this camera device.</p>
+ *
+ * @see ANDROID_SHADING_MODE
+ */
ANDROID_SHADING_AVAILABLE_MODES,
ANDROID_SHADING_END,
+ /** android.statistics.faceDetectMode [dynamic, enum, public]
+ *
+ * <p>Operating mode for the face detector
+ * unit.</p>
+ */
ANDROID_STATISTICS_FACE_DETECT_MODE = CameraMetadataSectionStart:ANDROID_STATISTICS_START,
+ /** android.statistics.histogramMode [dynamic, enum, system]
+ *
+ * <p>Operating mode for histogram
+ * generation</p>
+ */
ANDROID_STATISTICS_HISTOGRAM_MODE,
+ /** android.statistics.sharpnessMapMode [dynamic, enum, system]
+ *
+ * <p>Operating mode for sharpness map
+ * generation</p>
+ */
ANDROID_STATISTICS_SHARPNESS_MAP_MODE,
+ /** android.statistics.hotPixelMapMode [dynamic, enum, public]
+ *
+ * <p>Operating mode for hot pixel map generation.</p>
+ */
ANDROID_STATISTICS_HOT_PIXEL_MAP_MODE,
+ /** android.statistics.faceIds [dynamic, int32[], ndk_public]
+ *
+ * <p>List of unique IDs for detected faces.</p>
+ */
ANDROID_STATISTICS_FACE_IDS,
+ /** android.statistics.faceLandmarks [dynamic, int32[], ndk_public]
+ *
+ * <p>List of landmarks for detected
+ * faces.</p>
+ */
ANDROID_STATISTICS_FACE_LANDMARKS,
+ /** android.statistics.faceRectangles [dynamic, int32[], ndk_public]
+ *
+ * <p>List of the bounding rectangles for detected
+ * faces.</p>
+ */
ANDROID_STATISTICS_FACE_RECTANGLES,
+ /** android.statistics.faceScores [dynamic, byte[], ndk_public]
+ *
+ * <p>List of the face confidence scores for
+ * detected faces</p>
+ */
ANDROID_STATISTICS_FACE_SCORES,
+ /** android.statistics.histogram [dynamic, int32[], system]
+ *
+ * <p>A 3-channel histogram based on the raw
+ * sensor data</p>
+ */
ANDROID_STATISTICS_HISTOGRAM,
+ /** android.statistics.sharpnessMap [dynamic, int32[], system]
+ *
+ * <p>A 3-channel sharpness map, based on the raw
+ * sensor data</p>
+ */
ANDROID_STATISTICS_SHARPNESS_MAP,
+ /** android.statistics.lensShadingCorrectionMap [dynamic, byte, java_public]
+ *
+ * <p>The shading map is a low-resolution floating-point map
+ * that lists the coefficients used to correct for vignetting, for each
+ * Bayer color channel.</p>
+ */
ANDROID_STATISTICS_LENS_SHADING_CORRECTION_MAP,
+ /** android.statistics.lensShadingMap [dynamic, float[], ndk_public]
+ *
+ * <p>The shading map is a low-resolution floating-point map
+ * that lists the coefficients used to correct for vignetting and color shading,
+ * for each Bayer color channel of RAW image data.</p>
+ */
ANDROID_STATISTICS_LENS_SHADING_MAP,
+ /** android.statistics.predictedColorGains [dynamic, float[], hidden]
+ *
+ * <p>The best-fit color channel gains calculated
+ * by the camera device's statistics units for the current output frame.</p>
+ */
ANDROID_STATISTICS_PREDICTED_COLOR_GAINS,
+ /** android.statistics.predictedColorTransform [dynamic, rational[], hidden]
+ *
+ * <p>The best-fit color transform matrix estimate
+ * calculated by the camera device's statistics units for the current
+ * output frame.</p>
+ */
ANDROID_STATISTICS_PREDICTED_COLOR_TRANSFORM,
+ /** android.statistics.sceneFlicker [dynamic, enum, public]
+ *
+ * <p>The camera device estimated scene illumination lighting
+ * frequency.</p>
+ */
ANDROID_STATISTICS_SCENE_FLICKER,
+ /** android.statistics.hotPixelMap [dynamic, int32[], public]
+ *
+ * <p>List of <code>(x, y)</code> coordinates of hot/defective pixels on the sensor.</p>
+ */
ANDROID_STATISTICS_HOT_PIXEL_MAP,
+ /** android.statistics.lensShadingMapMode [dynamic, enum, public]
+ *
+ * <p>Whether the camera device will output the lens
+ * shading map in output result metadata.</p>
+ */
ANDROID_STATISTICS_LENS_SHADING_MAP_MODE,
ANDROID_STATISTICS_END,
- ANDROID_STATISTICS_INFO_AVAILABLE_FACE_DETECT_MODES =
- CameraMetadataSectionStart:ANDROID_STATISTICS_INFO_START,
+ /** android.statistics.info.availableFaceDetectModes [static, byte[], public]
+ *
+ * <p>List of face detection modes for ANDROID_STATISTICS_FACE_DETECT_MODE that are
+ * supported by this camera device.</p>
+ *
+ * @see ANDROID_STATISTICS_FACE_DETECT_MODE
+ */
+ ANDROID_STATISTICS_INFO_AVAILABLE_FACE_DETECT_MODES = CameraMetadataSectionStart:ANDROID_STATISTICS_INFO_START,
+ /** android.statistics.info.histogramBucketCount [static, int32, system]
+ *
+ * <p>Number of histogram buckets
+ * supported</p>
+ */
ANDROID_STATISTICS_INFO_HISTOGRAM_BUCKET_COUNT,
+ /** android.statistics.info.maxFaceCount [static, int32, public]
+ *
+ * <p>The maximum number of simultaneously detectable
+ * faces.</p>
+ */
ANDROID_STATISTICS_INFO_MAX_FACE_COUNT,
+ /** android.statistics.info.maxHistogramCount [static, int32, system]
+ *
+ * <p>Maximum value possible for a histogram
+ * bucket</p>
+ */
ANDROID_STATISTICS_INFO_MAX_HISTOGRAM_COUNT,
+ /** android.statistics.info.maxSharpnessMapValue [static, int32, system]
+ *
+ * <p>Maximum value possible for a sharpness map
+ * region.</p>
+ */
ANDROID_STATISTICS_INFO_MAX_SHARPNESS_MAP_VALUE,
+ /** android.statistics.info.sharpnessMapSize [static, int32[], system]
+ *
+ * <p>Dimensions of the sharpness
+ * map</p>
+ */
ANDROID_STATISTICS_INFO_SHARPNESS_MAP_SIZE,
+ /** android.statistics.info.availableHotPixelMapModes [static, byte[], public]
+ *
+ * <p>List of hot pixel map output modes for ANDROID_STATISTICS_HOT_PIXEL_MAP_MODE that are
+ * supported by this camera device.</p>
+ *
+ * @see ANDROID_STATISTICS_HOT_PIXEL_MAP_MODE
+ */
ANDROID_STATISTICS_INFO_AVAILABLE_HOT_PIXEL_MAP_MODES,
+ /** android.statistics.info.availableLensShadingMapModes [static, byte[], public]
+ *
+ * <p>List of lens shading map output modes for ANDROID_STATISTICS_LENS_SHADING_MAP_MODE that
+ * are supported by this camera device.</p>
+ *
+ * @see ANDROID_STATISTICS_LENS_SHADING_MAP_MODE
+ */
ANDROID_STATISTICS_INFO_AVAILABLE_LENS_SHADING_MAP_MODES,
ANDROID_STATISTICS_INFO_END,
+ /** android.tonemap.curveBlue [dynamic, float[], ndk_public]
+ *
+ * <p>Tonemapping / contrast / gamma curve for the blue
+ * channel, to use when ANDROID_TONEMAP_MODE is
+ * CONTRAST_CURVE.</p>
+ *
+ * @see ANDROID_TONEMAP_MODE
+ */
ANDROID_TONEMAP_CURVE_BLUE = CameraMetadataSectionStart:ANDROID_TONEMAP_START,
+ /** android.tonemap.curveGreen [dynamic, float[], ndk_public]
+ *
+ * <p>Tonemapping / contrast / gamma curve for the green
+ * channel, to use when ANDROID_TONEMAP_MODE is
+ * CONTRAST_CURVE.</p>
+ *
+ * @see ANDROID_TONEMAP_MODE
+ */
ANDROID_TONEMAP_CURVE_GREEN,
+ /** android.tonemap.curveRed [dynamic, float[], ndk_public]
+ *
+ * <p>Tonemapping / contrast / gamma curve for the red
+ * channel, to use when ANDROID_TONEMAP_MODE is
+ * CONTRAST_CURVE.</p>
+ *
+ * @see ANDROID_TONEMAP_MODE
+ */
ANDROID_TONEMAP_CURVE_RED,
+ /** android.tonemap.mode [dynamic, enum, public]
+ *
+ * <p>High-level global contrast/gamma/tonemapping control.</p>
+ */
ANDROID_TONEMAP_MODE,
+ /** android.tonemap.maxCurvePoints [static, int32, public]
+ *
+ * <p>Maximum number of supported points in the
+ * tonemap curve that can be used for ANDROID_TONEMAP_CURVE.</p>
+ *
+ * @see ANDROID_TONEMAP_CURVE
+ */
ANDROID_TONEMAP_MAX_CURVE_POINTS,
+ /** android.tonemap.availableToneMapModes [static, byte[], public]
+ *
+ * <p>List of tonemapping modes for ANDROID_TONEMAP_MODE that are supported by this camera
+ * device.</p>
+ *
+ * @see ANDROID_TONEMAP_MODE
+ */
ANDROID_TONEMAP_AVAILABLE_TONE_MAP_MODES,
+ /** android.tonemap.gamma [dynamic, float, public]
+ *
+ * <p>Tonemapping curve to use when ANDROID_TONEMAP_MODE is
+ * GAMMA_VALUE</p>
+ *
+ * @see ANDROID_TONEMAP_MODE
+ */
ANDROID_TONEMAP_GAMMA,
+ /** android.tonemap.presetCurve [dynamic, enum, public]
+ *
+ * <p>Tonemapping curve to use when ANDROID_TONEMAP_MODE is
+ * PRESET_CURVE</p>
+ *
+ * @see ANDROID_TONEMAP_MODE
+ */
ANDROID_TONEMAP_PRESET_CURVE,
ANDROID_TONEMAP_END,
+ /** android.led.transmit [dynamic, enum, hidden]
+ *
+ * <p>This LED is nominally used to indicate to the user
+ * that the camera is powered on and may be streaming images back to the
+ * Application Processor. In certain rare circumstances, the OS may
+ * disable this when video is processed locally and not transmitted to
+ * any untrusted applications.</p>
+ * <p>In particular, the LED <em>must</em> always be on when the data could be
+ * transmitted off the device. The LED <em>should</em> always be on whenever
+ * data is stored locally on the device.</p>
+ * <p>The LED <em>may</em> be off if a trusted application is using the data that
+ * doesn't violate the above rules.</p>
+ */
ANDROID_LED_TRANSMIT = CameraMetadataSectionStart:ANDROID_LED_START,
+ /** android.led.availableLeds [static, enum[], hidden]
+ *
+ * <p>A list of camera LEDs that are available on this system.</p>
+ */
ANDROID_LED_AVAILABLE_LEDS,
ANDROID_LED_END,
+ /** android.info.supportedHardwareLevel [static, enum, public]
+ *
+ * <p>Generally classifies the overall set of the camera device functionality.</p>
+ */
ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL = CameraMetadataSectionStart:ANDROID_INFO_START,
ANDROID_INFO_END,
+ /** android.blackLevel.lock [dynamic, enum, public]
+ *
+ * <p>Whether black-level compensation is locked
+ * to its current values, or is free to vary.</p>
+ */
ANDROID_BLACK_LEVEL_LOCK = CameraMetadataSectionStart:ANDROID_BLACK_LEVEL_START,
ANDROID_BLACK_LEVEL_END,
+ /** android.sync.frameNumber [dynamic, enum, ndk_public]
+ *
+ * <p>The frame number corresponding to the last request
+ * with which the output result (metadata + buffers) has been fully
+ * synchronized.</p>
+ */
ANDROID_SYNC_FRAME_NUMBER = CameraMetadataSectionStart:ANDROID_SYNC_START,
+ /** android.sync.maxLatency [static, enum, public]
+ *
+ * <p>The maximum number of frames that can occur after a request
+ * (different than the previous) has been submitted, and before the
+ * result's state becomes synchronized.</p>
+ */
ANDROID_SYNC_MAX_LATENCY,
ANDROID_SYNC_END,
+ /** android.reprocess.effectiveExposureFactor [dynamic, float, java_public]
+ *
+ * <p>The amount of exposure time increase factor applied to the original output
+ * frame by the application processing before sending for reprocessing.</p>
+ */
ANDROID_REPROCESS_EFFECTIVE_EXPOSURE_FACTOR = CameraMetadataSectionStart:ANDROID_REPROCESS_START,
+ /** android.reprocess.maxCaptureStall [static, int32, java_public]
+ *
+ * <p>The maximal camera capture pipeline stall (in unit of frame count) introduced by a
+ * reprocess capture request.</p>
+ */
ANDROID_REPROCESS_MAX_CAPTURE_STALL,
ANDROID_REPROCESS_END,
+ /** android.depth.maxDepthSamples [static, int32, system]
+ *
+ * <p>Maximum number of points that a depth point cloud may contain.</p>
+ */
ANDROID_DEPTH_MAX_DEPTH_SAMPLES = CameraMetadataSectionStart:ANDROID_DEPTH_START,
+ /** android.depth.availableDepthStreamConfigurations [static, enum[], ndk_public]
+ *
+ * <p>The available depth dataspace stream
+ * configurations that this camera device supports
+ * (i.e. format, width, height, output/input stream).</p>
+ */
ANDROID_DEPTH_AVAILABLE_DEPTH_STREAM_CONFIGURATIONS,
+ /** android.depth.availableDepthMinFrameDurations [static, int64[], ndk_public]
+ *
+ * <p>This lists the minimum frame duration for each
+ * format/size combination for depth output formats.</p>
+ */
ANDROID_DEPTH_AVAILABLE_DEPTH_MIN_FRAME_DURATIONS,
+ /** android.depth.availableDepthStallDurations [static, int64[], ndk_public]
+ *
+ * <p>This lists the maximum stall duration for each
+ * output format/size combination for depth streams.</p>
+ */
ANDROID_DEPTH_AVAILABLE_DEPTH_STALL_DURATIONS,
+ /** android.depth.depthIsExclusive [static, enum, public]
+ *
+ * <p>Indicates whether a capture request may target both a
+ * DEPTH16 / DEPTH_POINT_CLOUD output, and normal color outputs (such as
+ * YUV_420_888, JPEG, or RAW) simultaneously.</p>
+ */
ANDROID_DEPTH_DEPTH_IS_EXCLUSIVE,
ANDROID_DEPTH_END,
};
-/**
+/*
* Enumeration definitions for the various entries that need them
*/
+
+/** android.colorCorrection.mode enumeration values
+ * @see ANDROID_COLOR_CORRECTION_MODE
+ */
enum CameraMetadataEnumAndroidColorCorrectionMode : uint32_t {
ANDROID_COLOR_CORRECTION_MODE_TRANSFORM_MATRIX,
-
ANDROID_COLOR_CORRECTION_MODE_FAST,
-
ANDROID_COLOR_CORRECTION_MODE_HIGH_QUALITY,
-
};
+/** android.colorCorrection.aberrationMode enumeration values
+ * @see ANDROID_COLOR_CORRECTION_ABERRATION_MODE
+ */
enum CameraMetadataEnumAndroidColorCorrectionAberrationMode : uint32_t {
ANDROID_COLOR_CORRECTION_ABERRATION_MODE_OFF,
-
ANDROID_COLOR_CORRECTION_ABERRATION_MODE_FAST,
-
ANDROID_COLOR_CORRECTION_ABERRATION_MODE_HIGH_QUALITY,
-
};
+/** android.control.aeAntibandingMode enumeration values
+ * @see ANDROID_CONTROL_AE_ANTIBANDING_MODE
+ */
enum CameraMetadataEnumAndroidControlAeAntibandingMode : uint32_t {
ANDROID_CONTROL_AE_ANTIBANDING_MODE_OFF,
-
ANDROID_CONTROL_AE_ANTIBANDING_MODE_50HZ,
-
ANDROID_CONTROL_AE_ANTIBANDING_MODE_60HZ,
-
ANDROID_CONTROL_AE_ANTIBANDING_MODE_AUTO,
-
};
+/** android.control.aeLock enumeration values
+ * @see ANDROID_CONTROL_AE_LOCK
+ */
enum CameraMetadataEnumAndroidControlAeLock : uint32_t {
ANDROID_CONTROL_AE_LOCK_OFF,
-
ANDROID_CONTROL_AE_LOCK_ON,
-
};
+/** android.control.aeMode enumeration values
+ * @see ANDROID_CONTROL_AE_MODE
+ */
enum CameraMetadataEnumAndroidControlAeMode : uint32_t {
ANDROID_CONTROL_AE_MODE_OFF,
-
ANDROID_CONTROL_AE_MODE_ON,
-
ANDROID_CONTROL_AE_MODE_ON_AUTO_FLASH,
-
ANDROID_CONTROL_AE_MODE_ON_ALWAYS_FLASH,
-
ANDROID_CONTROL_AE_MODE_ON_AUTO_FLASH_REDEYE,
-
};
+/** android.control.aePrecaptureTrigger enumeration values
+ * @see ANDROID_CONTROL_AE_PRECAPTURE_TRIGGER
+ */
enum CameraMetadataEnumAndroidControlAePrecaptureTrigger : uint32_t {
ANDROID_CONTROL_AE_PRECAPTURE_TRIGGER_IDLE,
-
ANDROID_CONTROL_AE_PRECAPTURE_TRIGGER_START,
-
ANDROID_CONTROL_AE_PRECAPTURE_TRIGGER_CANCEL,
-
};
+/** android.control.afMode enumeration values
+ * @see ANDROID_CONTROL_AF_MODE
+ */
enum CameraMetadataEnumAndroidControlAfMode : uint32_t {
ANDROID_CONTROL_AF_MODE_OFF,
-
ANDROID_CONTROL_AF_MODE_AUTO,
-
ANDROID_CONTROL_AF_MODE_MACRO,
-
ANDROID_CONTROL_AF_MODE_CONTINUOUS_VIDEO,
-
ANDROID_CONTROL_AF_MODE_CONTINUOUS_PICTURE,
-
ANDROID_CONTROL_AF_MODE_EDOF,
-
};
+/** android.control.afTrigger enumeration values
+ * @see ANDROID_CONTROL_AF_TRIGGER
+ */
enum CameraMetadataEnumAndroidControlAfTrigger : uint32_t {
ANDROID_CONTROL_AF_TRIGGER_IDLE,
-
ANDROID_CONTROL_AF_TRIGGER_START,
-
ANDROID_CONTROL_AF_TRIGGER_CANCEL,
-
};
+/** android.control.awbLock enumeration values
+ * @see ANDROID_CONTROL_AWB_LOCK
+ */
enum CameraMetadataEnumAndroidControlAwbLock : uint32_t {
ANDROID_CONTROL_AWB_LOCK_OFF,
-
ANDROID_CONTROL_AWB_LOCK_ON,
-
};
+/** android.control.awbMode enumeration values
+ * @see ANDROID_CONTROL_AWB_MODE
+ */
enum CameraMetadataEnumAndroidControlAwbMode : uint32_t {
ANDROID_CONTROL_AWB_MODE_OFF,
-
ANDROID_CONTROL_AWB_MODE_AUTO,
-
ANDROID_CONTROL_AWB_MODE_INCANDESCENT,
-
ANDROID_CONTROL_AWB_MODE_FLUORESCENT,
-
ANDROID_CONTROL_AWB_MODE_WARM_FLUORESCENT,
-
ANDROID_CONTROL_AWB_MODE_DAYLIGHT,
-
ANDROID_CONTROL_AWB_MODE_CLOUDY_DAYLIGHT,
-
ANDROID_CONTROL_AWB_MODE_TWILIGHT,
-
ANDROID_CONTROL_AWB_MODE_SHADE,
-
};
+/** android.control.captureIntent enumeration values
+ * @see ANDROID_CONTROL_CAPTURE_INTENT
+ */
enum CameraMetadataEnumAndroidControlCaptureIntent : uint32_t {
ANDROID_CONTROL_CAPTURE_INTENT_CUSTOM,
-
ANDROID_CONTROL_CAPTURE_INTENT_PREVIEW,
-
ANDROID_CONTROL_CAPTURE_INTENT_STILL_CAPTURE,
-
ANDROID_CONTROL_CAPTURE_INTENT_VIDEO_RECORD,
-
ANDROID_CONTROL_CAPTURE_INTENT_VIDEO_SNAPSHOT,
-
ANDROID_CONTROL_CAPTURE_INTENT_ZERO_SHUTTER_LAG,
-
ANDROID_CONTROL_CAPTURE_INTENT_MANUAL,
-
};
+/** android.control.effectMode enumeration values
+ * @see ANDROID_CONTROL_EFFECT_MODE
+ */
enum CameraMetadataEnumAndroidControlEffectMode : uint32_t {
ANDROID_CONTROL_EFFECT_MODE_OFF,
-
ANDROID_CONTROL_EFFECT_MODE_MONO,
-
ANDROID_CONTROL_EFFECT_MODE_NEGATIVE,
-
ANDROID_CONTROL_EFFECT_MODE_SOLARIZE,
-
ANDROID_CONTROL_EFFECT_MODE_SEPIA,
-
ANDROID_CONTROL_EFFECT_MODE_POSTERIZE,
-
ANDROID_CONTROL_EFFECT_MODE_WHITEBOARD,
-
ANDROID_CONTROL_EFFECT_MODE_BLACKBOARD,
-
ANDROID_CONTROL_EFFECT_MODE_AQUA,
-
};
+/** android.control.mode enumeration values
+ * @see ANDROID_CONTROL_MODE
+ */
enum CameraMetadataEnumAndroidControlMode : uint32_t {
ANDROID_CONTROL_MODE_OFF,
-
ANDROID_CONTROL_MODE_AUTO,
-
ANDROID_CONTROL_MODE_USE_SCENE_MODE,
-
ANDROID_CONTROL_MODE_OFF_KEEP_STATE,
-
};
+/** android.control.sceneMode enumeration values
+ * @see ANDROID_CONTROL_SCENE_MODE
+ */
enum CameraMetadataEnumAndroidControlSceneMode : uint32_t {
- ANDROID_CONTROL_SCENE_MODE_DISABLED = 0,
-
+ ANDROID_CONTROL_SCENE_MODE_DISABLED = 0,
ANDROID_CONTROL_SCENE_MODE_FACE_PRIORITY,
-
ANDROID_CONTROL_SCENE_MODE_ACTION,
-
ANDROID_CONTROL_SCENE_MODE_PORTRAIT,
-
ANDROID_CONTROL_SCENE_MODE_LANDSCAPE,
-
ANDROID_CONTROL_SCENE_MODE_NIGHT,
-
ANDROID_CONTROL_SCENE_MODE_NIGHT_PORTRAIT,
-
ANDROID_CONTROL_SCENE_MODE_THEATRE,
-
ANDROID_CONTROL_SCENE_MODE_BEACH,
-
ANDROID_CONTROL_SCENE_MODE_SNOW,
-
ANDROID_CONTROL_SCENE_MODE_SUNSET,
-
ANDROID_CONTROL_SCENE_MODE_STEADYPHOTO,
-
ANDROID_CONTROL_SCENE_MODE_FIREWORKS,
-
ANDROID_CONTROL_SCENE_MODE_SPORTS,
-
ANDROID_CONTROL_SCENE_MODE_PARTY,
-
ANDROID_CONTROL_SCENE_MODE_CANDLELIGHT,
-
ANDROID_CONTROL_SCENE_MODE_BARCODE,
-
ANDROID_CONTROL_SCENE_MODE_HIGH_SPEED_VIDEO,
-
ANDROID_CONTROL_SCENE_MODE_HDR,
-
ANDROID_CONTROL_SCENE_MODE_FACE_PRIORITY_LOW_LIGHT,
-
- ANDROID_CONTROL_SCENE_MODE_DEVICE_CUSTOM_START = 100,
-
- ANDROID_CONTROL_SCENE_MODE_DEVICE_CUSTOM_END = 127,
-
+ ANDROID_CONTROL_SCENE_MODE_DEVICE_CUSTOM_START = 100,
+ ANDROID_CONTROL_SCENE_MODE_DEVICE_CUSTOM_END = 127,
};
+/** android.control.videoStabilizationMode enumeration values
+ * @see ANDROID_CONTROL_VIDEO_STABILIZATION_MODE
+ */
enum CameraMetadataEnumAndroidControlVideoStabilizationMode : uint32_t {
ANDROID_CONTROL_VIDEO_STABILIZATION_MODE_OFF,
-
ANDROID_CONTROL_VIDEO_STABILIZATION_MODE_ON,
-
};
+/** android.control.aeState enumeration values
+ * @see ANDROID_CONTROL_AE_STATE
+ */
enum CameraMetadataEnumAndroidControlAeState : uint32_t {
ANDROID_CONTROL_AE_STATE_INACTIVE,
-
ANDROID_CONTROL_AE_STATE_SEARCHING,
-
ANDROID_CONTROL_AE_STATE_CONVERGED,
-
ANDROID_CONTROL_AE_STATE_LOCKED,
-
ANDROID_CONTROL_AE_STATE_FLASH_REQUIRED,
-
ANDROID_CONTROL_AE_STATE_PRECAPTURE,
-
};
+/** android.control.afState enumeration values
+ * @see ANDROID_CONTROL_AF_STATE
+ */
enum CameraMetadataEnumAndroidControlAfState : uint32_t {
ANDROID_CONTROL_AF_STATE_INACTIVE,
-
ANDROID_CONTROL_AF_STATE_PASSIVE_SCAN,
-
ANDROID_CONTROL_AF_STATE_PASSIVE_FOCUSED,
-
ANDROID_CONTROL_AF_STATE_ACTIVE_SCAN,
-
ANDROID_CONTROL_AF_STATE_FOCUSED_LOCKED,
-
ANDROID_CONTROL_AF_STATE_NOT_FOCUSED_LOCKED,
-
ANDROID_CONTROL_AF_STATE_PASSIVE_UNFOCUSED,
-
};
+/** android.control.awbState enumeration values
+ * @see ANDROID_CONTROL_AWB_STATE
+ */
enum CameraMetadataEnumAndroidControlAwbState : uint32_t {
ANDROID_CONTROL_AWB_STATE_INACTIVE,
-
ANDROID_CONTROL_AWB_STATE_SEARCHING,
-
ANDROID_CONTROL_AWB_STATE_CONVERGED,
-
ANDROID_CONTROL_AWB_STATE_LOCKED,
-
};
+/** android.control.aeLockAvailable enumeration values
+ * @see ANDROID_CONTROL_AE_LOCK_AVAILABLE
+ */
enum CameraMetadataEnumAndroidControlAeLockAvailable : uint32_t {
ANDROID_CONTROL_AE_LOCK_AVAILABLE_FALSE,
-
ANDROID_CONTROL_AE_LOCK_AVAILABLE_TRUE,
-
};
+/** android.control.awbLockAvailable enumeration values
+ * @see ANDROID_CONTROL_AWB_LOCK_AVAILABLE
+ */
enum CameraMetadataEnumAndroidControlAwbLockAvailable : uint32_t {
ANDROID_CONTROL_AWB_LOCK_AVAILABLE_FALSE,
-
ANDROID_CONTROL_AWB_LOCK_AVAILABLE_TRUE,
-
};
+/** android.control.enableZsl enumeration values
+ * @see ANDROID_CONTROL_ENABLE_ZSL
+ */
enum CameraMetadataEnumAndroidControlEnableZsl : uint32_t {
ANDROID_CONTROL_ENABLE_ZSL_FALSE,
-
ANDROID_CONTROL_ENABLE_ZSL_TRUE,
-
};
+/** android.demosaic.mode enumeration values
+ * @see ANDROID_DEMOSAIC_MODE
+ */
enum CameraMetadataEnumAndroidDemosaicMode : uint32_t {
ANDROID_DEMOSAIC_MODE_FAST,
-
ANDROID_DEMOSAIC_MODE_HIGH_QUALITY,
-
};
+/** android.edge.mode enumeration values
+ * @see ANDROID_EDGE_MODE
+ */
enum CameraMetadataEnumAndroidEdgeMode : uint32_t {
ANDROID_EDGE_MODE_OFF,
-
ANDROID_EDGE_MODE_FAST,
-
ANDROID_EDGE_MODE_HIGH_QUALITY,
-
ANDROID_EDGE_MODE_ZERO_SHUTTER_LAG,
-
};
+/** android.flash.mode enumeration values
+ * @see ANDROID_FLASH_MODE
+ */
enum CameraMetadataEnumAndroidFlashMode : uint32_t {
ANDROID_FLASH_MODE_OFF,
-
ANDROID_FLASH_MODE_SINGLE,
-
ANDROID_FLASH_MODE_TORCH,
-
};
+/** android.flash.state enumeration values
+ * @see ANDROID_FLASH_STATE
+ */
enum CameraMetadataEnumAndroidFlashState : uint32_t {
ANDROID_FLASH_STATE_UNAVAILABLE,
-
ANDROID_FLASH_STATE_CHARGING,
-
ANDROID_FLASH_STATE_READY,
-
ANDROID_FLASH_STATE_FIRED,
-
ANDROID_FLASH_STATE_PARTIAL,
-
};
+/** android.flash.info.available enumeration values
+ * @see ANDROID_FLASH_INFO_AVAILABLE
+ */
enum CameraMetadataEnumAndroidFlashInfoAvailable : uint32_t {
ANDROID_FLASH_INFO_AVAILABLE_FALSE,
-
ANDROID_FLASH_INFO_AVAILABLE_TRUE,
-
};
+/** android.hotPixel.mode enumeration values
+ * @see ANDROID_HOT_PIXEL_MODE
+ */
enum CameraMetadataEnumAndroidHotPixelMode : uint32_t {
ANDROID_HOT_PIXEL_MODE_OFF,
-
ANDROID_HOT_PIXEL_MODE_FAST,
-
ANDROID_HOT_PIXEL_MODE_HIGH_QUALITY,
-
};
+/** android.lens.opticalStabilizationMode enumeration values
+ * @see ANDROID_LENS_OPTICAL_STABILIZATION_MODE
+ */
enum CameraMetadataEnumAndroidLensOpticalStabilizationMode : uint32_t {
ANDROID_LENS_OPTICAL_STABILIZATION_MODE_OFF,
-
ANDROID_LENS_OPTICAL_STABILIZATION_MODE_ON,
-
};
+/** android.lens.facing enumeration values
+ * @see ANDROID_LENS_FACING
+ */
enum CameraMetadataEnumAndroidLensFacing : uint32_t {
ANDROID_LENS_FACING_FRONT,
-
ANDROID_LENS_FACING_BACK,
-
ANDROID_LENS_FACING_EXTERNAL,
-
};
+/** android.lens.state enumeration values
+ * @see ANDROID_LENS_STATE
+ */
enum CameraMetadataEnumAndroidLensState : uint32_t {
ANDROID_LENS_STATE_STATIONARY,
-
ANDROID_LENS_STATE_MOVING,
-
};
+/** android.lens.info.focusDistanceCalibration enumeration values
+ * @see ANDROID_LENS_INFO_FOCUS_DISTANCE_CALIBRATION
+ */
enum CameraMetadataEnumAndroidLensInfoFocusDistanceCalibration : uint32_t {
ANDROID_LENS_INFO_FOCUS_DISTANCE_CALIBRATION_UNCALIBRATED,
-
ANDROID_LENS_INFO_FOCUS_DISTANCE_CALIBRATION_APPROXIMATE,
-
ANDROID_LENS_INFO_FOCUS_DISTANCE_CALIBRATION_CALIBRATED,
-
};
+/** android.noiseReduction.mode enumeration values
+ * @see ANDROID_NOISE_REDUCTION_MODE
+ */
enum CameraMetadataEnumAndroidNoiseReductionMode : uint32_t {
ANDROID_NOISE_REDUCTION_MODE_OFF,
-
ANDROID_NOISE_REDUCTION_MODE_FAST,
-
ANDROID_NOISE_REDUCTION_MODE_HIGH_QUALITY,
-
ANDROID_NOISE_REDUCTION_MODE_MINIMAL,
-
ANDROID_NOISE_REDUCTION_MODE_ZERO_SHUTTER_LAG,
-
};
+/** android.quirks.partialResult enumeration values
+ * @see ANDROID_QUIRKS_PARTIAL_RESULT
+ */
enum CameraMetadataEnumAndroidQuirksPartialResult : uint32_t {
ANDROID_QUIRKS_PARTIAL_RESULT_FINAL,
-
ANDROID_QUIRKS_PARTIAL_RESULT_PARTIAL,
-
};
+/** android.request.metadataMode enumeration values
+ * @see ANDROID_REQUEST_METADATA_MODE
+ */
enum CameraMetadataEnumAndroidRequestMetadataMode : uint32_t {
ANDROID_REQUEST_METADATA_MODE_NONE,
-
ANDROID_REQUEST_METADATA_MODE_FULL,
-
};
+/** android.request.type enumeration values
+ * @see ANDROID_REQUEST_TYPE
+ */
enum CameraMetadataEnumAndroidRequestType : uint32_t {
ANDROID_REQUEST_TYPE_CAPTURE,
-
ANDROID_REQUEST_TYPE_REPROCESS,
-
};
+/** android.request.availableCapabilities enumeration values
+ * @see ANDROID_REQUEST_AVAILABLE_CAPABILITIES
+ */
enum CameraMetadataEnumAndroidRequestAvailableCapabilities : uint32_t {
ANDROID_REQUEST_AVAILABLE_CAPABILITIES_BACKWARD_COMPATIBLE,
-
ANDROID_REQUEST_AVAILABLE_CAPABILITIES_MANUAL_SENSOR,
-
ANDROID_REQUEST_AVAILABLE_CAPABILITIES_MANUAL_POST_PROCESSING,
-
ANDROID_REQUEST_AVAILABLE_CAPABILITIES_RAW,
-
ANDROID_REQUEST_AVAILABLE_CAPABILITIES_PRIVATE_REPROCESSING,
-
ANDROID_REQUEST_AVAILABLE_CAPABILITIES_READ_SENSOR_SETTINGS,
-
ANDROID_REQUEST_AVAILABLE_CAPABILITIES_BURST_CAPTURE,
-
ANDROID_REQUEST_AVAILABLE_CAPABILITIES_YUV_REPROCESSING,
-
ANDROID_REQUEST_AVAILABLE_CAPABILITIES_DEPTH_OUTPUT,
-
ANDROID_REQUEST_AVAILABLE_CAPABILITIES_CONSTRAINED_HIGH_SPEED_VIDEO,
-
};
+/** android.scaler.availableFormats enumeration values
+ * @see ANDROID_SCALER_AVAILABLE_FORMATS
+ */
enum CameraMetadataEnumAndroidScalerAvailableFormats : uint32_t {
- ANDROID_SCALER_AVAILABLE_FORMATS_RAW16 = 0x20,
-
- ANDROID_SCALER_AVAILABLE_FORMATS_RAW_OPAQUE = 0x24,
-
- ANDROID_SCALER_AVAILABLE_FORMATS_YV12 = 0x32315659,
-
- ANDROID_SCALER_AVAILABLE_FORMATS_YCrCb_420_SP = 0x11,
-
- ANDROID_SCALER_AVAILABLE_FORMATS_IMPLEMENTATION_DEFINED = 0x22,
-
- ANDROID_SCALER_AVAILABLE_FORMATS_YCbCr_420_888 = 0x23,
-
- ANDROID_SCALER_AVAILABLE_FORMATS_BLOB = 0x21,
-
+ ANDROID_SCALER_AVAILABLE_FORMATS_RAW16 = 0x20,
+ ANDROID_SCALER_AVAILABLE_FORMATS_RAW_OPAQUE = 0x24,
+ ANDROID_SCALER_AVAILABLE_FORMATS_YV12 = 0x32315659,
+ ANDROID_SCALER_AVAILABLE_FORMATS_YCrCb_420_SP = 0x11,
+ ANDROID_SCALER_AVAILABLE_FORMATS_IMPLEMENTATION_DEFINED = 0x22,
+ ANDROID_SCALER_AVAILABLE_FORMATS_YCbCr_420_888 = 0x23,
+ ANDROID_SCALER_AVAILABLE_FORMATS_BLOB = 0x21,
};
+/** android.scaler.availableStreamConfigurations enumeration values
+ * @see ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS
+ */
enum CameraMetadataEnumAndroidScalerAvailableStreamConfigurations : uint32_t {
ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT,
-
ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_INPUT,
-
};
+/** android.scaler.croppingType enumeration values
+ * @see ANDROID_SCALER_CROPPING_TYPE
+ */
enum CameraMetadataEnumAndroidScalerCroppingType : uint32_t {
ANDROID_SCALER_CROPPING_TYPE_CENTER_ONLY,
-
ANDROID_SCALER_CROPPING_TYPE_FREEFORM,
-
};
+/** android.sensor.referenceIlluminant1 enumeration values
+ * @see ANDROID_SENSOR_REFERENCE_ILLUMINANT1
+ */
enum CameraMetadataEnumAndroidSensorReferenceIlluminant1 : uint32_t {
- ANDROID_SENSOR_REFERENCE_ILLUMINANT1_DAYLIGHT = 1,
-
- ANDROID_SENSOR_REFERENCE_ILLUMINANT1_FLUORESCENT = 2,
-
- ANDROID_SENSOR_REFERENCE_ILLUMINANT1_TUNGSTEN = 3,
-
- ANDROID_SENSOR_REFERENCE_ILLUMINANT1_FLASH = 4,
-
- ANDROID_SENSOR_REFERENCE_ILLUMINANT1_FINE_WEATHER = 9,
-
- ANDROID_SENSOR_REFERENCE_ILLUMINANT1_CLOUDY_WEATHER = 10,
-
- ANDROID_SENSOR_REFERENCE_ILLUMINANT1_SHADE = 11,
-
- ANDROID_SENSOR_REFERENCE_ILLUMINANT1_DAYLIGHT_FLUORESCENT = 12,
-
- ANDROID_SENSOR_REFERENCE_ILLUMINANT1_DAY_WHITE_FLUORESCENT = 13,
-
+ ANDROID_SENSOR_REFERENCE_ILLUMINANT1_DAYLIGHT = 1,
+ ANDROID_SENSOR_REFERENCE_ILLUMINANT1_FLUORESCENT = 2,
+ ANDROID_SENSOR_REFERENCE_ILLUMINANT1_TUNGSTEN = 3,
+ ANDROID_SENSOR_REFERENCE_ILLUMINANT1_FLASH = 4,
+ ANDROID_SENSOR_REFERENCE_ILLUMINANT1_FINE_WEATHER = 9,
+ ANDROID_SENSOR_REFERENCE_ILLUMINANT1_CLOUDY_WEATHER = 10,
+ ANDROID_SENSOR_REFERENCE_ILLUMINANT1_SHADE = 11,
+ ANDROID_SENSOR_REFERENCE_ILLUMINANT1_DAYLIGHT_FLUORESCENT = 12,
+ ANDROID_SENSOR_REFERENCE_ILLUMINANT1_DAY_WHITE_FLUORESCENT = 13,
ANDROID_SENSOR_REFERENCE_ILLUMINANT1_COOL_WHITE_FLUORESCENT = 14,
-
- ANDROID_SENSOR_REFERENCE_ILLUMINANT1_WHITE_FLUORESCENT = 15,
-
- ANDROID_SENSOR_REFERENCE_ILLUMINANT1_STANDARD_A = 17,
-
- ANDROID_SENSOR_REFERENCE_ILLUMINANT1_STANDARD_B = 18,
-
- ANDROID_SENSOR_REFERENCE_ILLUMINANT1_STANDARD_C = 19,
-
- ANDROID_SENSOR_REFERENCE_ILLUMINANT1_D55 = 20,
-
- ANDROID_SENSOR_REFERENCE_ILLUMINANT1_D65 = 21,
-
- ANDROID_SENSOR_REFERENCE_ILLUMINANT1_D75 = 22,
-
- ANDROID_SENSOR_REFERENCE_ILLUMINANT1_D50 = 23,
-
- ANDROID_SENSOR_REFERENCE_ILLUMINANT1_ISO_STUDIO_TUNGSTEN = 24,
-
+ ANDROID_SENSOR_REFERENCE_ILLUMINANT1_WHITE_FLUORESCENT = 15,
+ ANDROID_SENSOR_REFERENCE_ILLUMINANT1_STANDARD_A = 17,
+ ANDROID_SENSOR_REFERENCE_ILLUMINANT1_STANDARD_B = 18,
+ ANDROID_SENSOR_REFERENCE_ILLUMINANT1_STANDARD_C = 19,
+ ANDROID_SENSOR_REFERENCE_ILLUMINANT1_D55 = 20,
+ ANDROID_SENSOR_REFERENCE_ILLUMINANT1_D65 = 21,
+ ANDROID_SENSOR_REFERENCE_ILLUMINANT1_D75 = 22,
+ ANDROID_SENSOR_REFERENCE_ILLUMINANT1_D50 = 23,
+ ANDROID_SENSOR_REFERENCE_ILLUMINANT1_ISO_STUDIO_TUNGSTEN = 24,
};
+/** android.sensor.testPatternMode enumeration values
+ * @see ANDROID_SENSOR_TEST_PATTERN_MODE
+ */
enum CameraMetadataEnumAndroidSensorTestPatternMode : uint32_t {
ANDROID_SENSOR_TEST_PATTERN_MODE_OFF,
-
ANDROID_SENSOR_TEST_PATTERN_MODE_SOLID_COLOR,
-
ANDROID_SENSOR_TEST_PATTERN_MODE_COLOR_BARS,
-
ANDROID_SENSOR_TEST_PATTERN_MODE_COLOR_BARS_FADE_TO_GRAY,
-
ANDROID_SENSOR_TEST_PATTERN_MODE_PN9,
-
- ANDROID_SENSOR_TEST_PATTERN_MODE_CUSTOM1 = 256,
-
+ ANDROID_SENSOR_TEST_PATTERN_MODE_CUSTOM1 = 256,
};
+/** android.sensor.info.colorFilterArrangement enumeration values
+ * @see ANDROID_SENSOR_INFO_COLOR_FILTER_ARRANGEMENT
+ */
enum CameraMetadataEnumAndroidSensorInfoColorFilterArrangement : uint32_t {
ANDROID_SENSOR_INFO_COLOR_FILTER_ARRANGEMENT_RGGB,
-
ANDROID_SENSOR_INFO_COLOR_FILTER_ARRANGEMENT_GRBG,
-
ANDROID_SENSOR_INFO_COLOR_FILTER_ARRANGEMENT_GBRG,
-
ANDROID_SENSOR_INFO_COLOR_FILTER_ARRANGEMENT_BGGR,
-
ANDROID_SENSOR_INFO_COLOR_FILTER_ARRANGEMENT_RGB,
-
};
+/** android.sensor.info.timestampSource enumeration values
+ * @see ANDROID_SENSOR_INFO_TIMESTAMP_SOURCE
+ */
enum CameraMetadataEnumAndroidSensorInfoTimestampSource : uint32_t {
ANDROID_SENSOR_INFO_TIMESTAMP_SOURCE_UNKNOWN,
-
ANDROID_SENSOR_INFO_TIMESTAMP_SOURCE_REALTIME,
-
};
+/** android.sensor.info.lensShadingApplied enumeration values
+ * @see ANDROID_SENSOR_INFO_LENS_SHADING_APPLIED
+ */
enum CameraMetadataEnumAndroidSensorInfoLensShadingApplied : uint32_t {
ANDROID_SENSOR_INFO_LENS_SHADING_APPLIED_FALSE,
-
ANDROID_SENSOR_INFO_LENS_SHADING_APPLIED_TRUE,
-
};
+/** android.shading.mode enumeration values
+ * @see ANDROID_SHADING_MODE
+ */
enum CameraMetadataEnumAndroidShadingMode : uint32_t {
ANDROID_SHADING_MODE_OFF,
-
ANDROID_SHADING_MODE_FAST,
-
ANDROID_SHADING_MODE_HIGH_QUALITY,
-
};
+/** android.statistics.faceDetectMode enumeration values
+ * @see ANDROID_STATISTICS_FACE_DETECT_MODE
+ */
enum CameraMetadataEnumAndroidStatisticsFaceDetectMode : uint32_t {
ANDROID_STATISTICS_FACE_DETECT_MODE_OFF,
-
ANDROID_STATISTICS_FACE_DETECT_MODE_SIMPLE,
-
ANDROID_STATISTICS_FACE_DETECT_MODE_FULL,
-
};
+/** android.statistics.histogramMode enumeration values
+ * @see ANDROID_STATISTICS_HISTOGRAM_MODE
+ */
enum CameraMetadataEnumAndroidStatisticsHistogramMode : uint32_t {
ANDROID_STATISTICS_HISTOGRAM_MODE_OFF,
-
ANDROID_STATISTICS_HISTOGRAM_MODE_ON,
-
};
+/** android.statistics.sharpnessMapMode enumeration values
+ * @see ANDROID_STATISTICS_SHARPNESS_MAP_MODE
+ */
enum CameraMetadataEnumAndroidStatisticsSharpnessMapMode : uint32_t {
ANDROID_STATISTICS_SHARPNESS_MAP_MODE_OFF,
-
ANDROID_STATISTICS_SHARPNESS_MAP_MODE_ON,
-
};
+/** android.statistics.hotPixelMapMode enumeration values
+ * @see ANDROID_STATISTICS_HOT_PIXEL_MAP_MODE
+ */
enum CameraMetadataEnumAndroidStatisticsHotPixelMapMode : uint32_t {
ANDROID_STATISTICS_HOT_PIXEL_MAP_MODE_OFF,
-
ANDROID_STATISTICS_HOT_PIXEL_MAP_MODE_ON,
-
};
+/** android.statistics.sceneFlicker enumeration values
+ * @see ANDROID_STATISTICS_SCENE_FLICKER
+ */
enum CameraMetadataEnumAndroidStatisticsSceneFlicker : uint32_t {
ANDROID_STATISTICS_SCENE_FLICKER_NONE,
-
ANDROID_STATISTICS_SCENE_FLICKER_50HZ,
-
ANDROID_STATISTICS_SCENE_FLICKER_60HZ,
-
};
+/** android.statistics.lensShadingMapMode enumeration values
+ * @see ANDROID_STATISTICS_LENS_SHADING_MAP_MODE
+ */
enum CameraMetadataEnumAndroidStatisticsLensShadingMapMode : uint32_t {
ANDROID_STATISTICS_LENS_SHADING_MAP_MODE_OFF,
-
ANDROID_STATISTICS_LENS_SHADING_MAP_MODE_ON,
-
};
+/** android.tonemap.mode enumeration values
+ * @see ANDROID_TONEMAP_MODE
+ */
enum CameraMetadataEnumAndroidTonemapMode : uint32_t {
ANDROID_TONEMAP_MODE_CONTRAST_CURVE,
-
ANDROID_TONEMAP_MODE_FAST,
-
ANDROID_TONEMAP_MODE_HIGH_QUALITY,
-
ANDROID_TONEMAP_MODE_GAMMA_VALUE,
-
ANDROID_TONEMAP_MODE_PRESET_CURVE,
-
};
+/** android.tonemap.presetCurve enumeration values
+ * @see ANDROID_TONEMAP_PRESET_CURVE
+ */
enum CameraMetadataEnumAndroidTonemapPresetCurve : uint32_t {
ANDROID_TONEMAP_PRESET_CURVE_SRGB,
-
ANDROID_TONEMAP_PRESET_CURVE_REC709,
-
};
+/** android.led.transmit enumeration values
+ * @see ANDROID_LED_TRANSMIT
+ */
enum CameraMetadataEnumAndroidLedTransmit : uint32_t {
ANDROID_LED_TRANSMIT_OFF,
-
ANDROID_LED_TRANSMIT_ON,
-
};
+/** android.led.availableLeds enumeration values
+ * @see ANDROID_LED_AVAILABLE_LEDS
+ */
enum CameraMetadataEnumAndroidLedAvailableLeds : uint32_t {
ANDROID_LED_AVAILABLE_LEDS_TRANSMIT,
-
};
+/** android.info.supportedHardwareLevel enumeration values
+ * @see ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL
+ */
enum CameraMetadataEnumAndroidInfoSupportedHardwareLevel : uint32_t {
ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED,
-
ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_FULL,
-
ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY,
-
ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_3,
-
};
+/** android.blackLevel.lock enumeration values
+ * @see ANDROID_BLACK_LEVEL_LOCK
+ */
enum CameraMetadataEnumAndroidBlackLevelLock : uint32_t {
ANDROID_BLACK_LEVEL_LOCK_OFF,
-
ANDROID_BLACK_LEVEL_LOCK_ON,
-
};
+/** android.sync.frameNumber enumeration values
+ * @see ANDROID_SYNC_FRAME_NUMBER
+ */
enum CameraMetadataEnumAndroidSyncFrameNumber : uint32_t {
- ANDROID_SYNC_FRAME_NUMBER_CONVERGING = -1,
-
- ANDROID_SYNC_FRAME_NUMBER_UNKNOWN = -2,
-
+ ANDROID_SYNC_FRAME_NUMBER_CONVERGING = -1,
+ ANDROID_SYNC_FRAME_NUMBER_UNKNOWN = -2,
};
+/** android.sync.maxLatency enumeration values
+ * @see ANDROID_SYNC_MAX_LATENCY
+ */
enum CameraMetadataEnumAndroidSyncMaxLatency : uint32_t {
- ANDROID_SYNC_MAX_LATENCY_PER_FRAME_CONTROL = 0,
-
- ANDROID_SYNC_MAX_LATENCY_UNKNOWN = -1,
-
+ ANDROID_SYNC_MAX_LATENCY_PER_FRAME_CONTROL = 0,
+ ANDROID_SYNC_MAX_LATENCY_UNKNOWN = -1,
};
+/** android.depth.availableDepthStreamConfigurations enumeration values
+ * @see ANDROID_DEPTH_AVAILABLE_DEPTH_STREAM_CONFIGURATIONS
+ */
enum CameraMetadataEnumAndroidDepthAvailableDepthStreamConfigurations : uint32_t {
ANDROID_DEPTH_AVAILABLE_DEPTH_STREAM_CONFIGURATIONS_OUTPUT,
-
ANDROID_DEPTH_AVAILABLE_DEPTH_STREAM_CONFIGURATIONS_INPUT,
-
};
+/** android.depth.depthIsExclusive enumeration values
+ * @see ANDROID_DEPTH_DEPTH_IS_EXCLUSIVE
+ */
enum CameraMetadataEnumAndroidDepthDepthIsExclusive : uint32_t {
ANDROID_DEPTH_DEPTH_IS_EXCLUSIVE_FALSE,
-
ANDROID_DEPTH_DEPTH_IS_EXCLUSIVE_TRUE,
-
};
diff --git a/cas/1.0/default/Android.bp b/cas/1.0/default/Android.bp
index 544162b..6da5cc4 100644
--- a/cas/1.0/default/Android.bp
+++ b/cas/1.0/default/Android.bp
@@ -12,6 +12,12 @@
"TypeConvert.cpp",
],
+ product_variables: {
+ treble: {
+ cflags: ["-DUSE_VNDBINDER"],
+ },
+ },
+
compile_multilib: "32",
init_rc: ["android.hardware.cas@1.0-service.rc"],
diff --git a/cas/1.0/default/service.cpp b/cas/1.0/default/service.cpp
index 04a8ad9..3f1df5a 100644
--- a/cas/1.0/default/service.cpp
+++ b/cas/1.0/default/service.cpp
@@ -31,9 +31,11 @@
int main() {
ALOGD("android.hardware.cas@1.0-service starting...");
+#ifdef USE_VNDBINDER
// The CAS HAL may communicate to other vendor components via
// /dev/vndbinder
android::ProcessState::initWithDriver("/dev/vndbinder");
+#endif // USE_VNDBINDER
configureRpcThreadpool(8, true /* callerWillJoin */);
diff --git a/cas/1.0/vts/functional/VtsHalCasV1_0TargetTest.cpp b/cas/1.0/vts/functional/VtsHalCasV1_0TargetTest.cpp
index d3b0f1d..193253a 100644
--- a/cas/1.0/vts/functional/VtsHalCasV1_0TargetTest.cpp
+++ b/cas/1.0/vts/functional/VtsHalCasV1_0TargetTest.cpp
@@ -223,12 +223,26 @@
sp<ICas> mMediaCas;
sp<IDescramblerBase> mDescramblerBase;
sp<MediaCasListener> mCasListener;
+ typedef struct _OobInputTestParams {
+ const SubSample* subSamples;
+ uint32_t numSubSamples;
+ size_t imemSizeActual;
+ uint64_t imemOffset;
+ uint64_t imemSize;
+ uint64_t srcOffset;
+ uint64_t dstOffset;
+ } OobInputTestParams;
::testing::AssertionResult createCasPlugin(int32_t caSystemId);
::testing::AssertionResult openCasSession(std::vector<uint8_t>* sessionId);
- ::testing::AssertionResult descrambleTestInputBuffer(const sp<IDescrambler>& descrambler,
- Status* descrambleStatus,
- sp<IMemory>* hidlInMemory);
+ ::testing::AssertionResult descrambleTestInputBuffer(
+ const sp<IDescrambler>& descrambler,
+ Status* descrambleStatus,
+ sp<IMemory>* hidlInMemory);
+ ::testing::AssertionResult descrambleTestOobInput(
+ const sp<IDescrambler>& descrambler,
+ Status* descrambleStatus,
+ const OobInputTestParams& params);
};
::testing::AssertionResult MediaCasHidlTest::createCasPlugin(int32_t caSystemId) {
@@ -332,6 +346,72 @@
return ::testing::AssertionResult(returnVoid.isOk());
}
+::testing::AssertionResult MediaCasHidlTest::descrambleTestOobInput(
+ const sp<IDescrambler>& descrambler,
+ Status* descrambleStatus,
+ const OobInputTestParams& params) {
+ hidl_vec<SubSample> hidlSubSamples;
+ hidlSubSamples.setToExternal(
+ const_cast<SubSample*>(params.subSamples), params.numSubSamples, false /*own*/);
+
+ sp<MemoryDealer> dealer = new MemoryDealer(params.imemSizeActual, "vts-cas");
+ if (nullptr == dealer.get()) {
+ ALOGE("couldn't get MemoryDealer!");
+ return ::testing::AssertionFailure();
+ }
+
+ sp<IMemory> mem = dealer->allocate(params.imemSizeActual);
+ if (nullptr == mem.get()) {
+ ALOGE("couldn't allocate IMemory!");
+ return ::testing::AssertionFailure();
+ }
+
+ // build hidl_memory from memory heap
+ ssize_t offset;
+ size_t size;
+ sp<IMemoryHeap> heap = mem->getMemory(&offset, &size);
+ if (nullptr == heap.get()) {
+ ALOGE("couldn't get memory heap!");
+ return ::testing::AssertionFailure();
+ }
+
+ native_handle_t* nativeHandle = native_handle_create(1, 0);
+ if (!nativeHandle) {
+ ALOGE("failed to create native handle!");
+ return ::testing::AssertionFailure();
+ }
+ nativeHandle->data[0] = heap->getHeapID();
+
+ SharedBuffer srcBuffer = {
+ .heapBase = hidl_memory("ashmem", hidl_handle(nativeHandle), heap->getSize()),
+ .offset = (uint64_t) offset + params.imemOffset,
+ .size = (uint64_t) params.imemSize,
+ };
+
+ DestinationBuffer dstBuffer;
+ dstBuffer.type = BufferType::SHARED_MEMORY;
+ dstBuffer.nonsecureMemory = srcBuffer;
+
+ uint32_t outBytes;
+ hidl_string detailedError;
+ auto returnVoid = descrambler->descramble(
+ ScramblingControl::EVENKEY /*2*/, hidlSubSamples,
+ srcBuffer,
+ params.srcOffset,
+ dstBuffer,
+ params.dstOffset,
+ [&](Status status, uint32_t bytesWritten, const hidl_string& detailedErr) {
+ *descrambleStatus = status;
+ outBytes = bytesWritten;
+ detailedError = detailedErr;
+ });
+ if (!returnVoid.isOk() || *descrambleStatus != Status::OK) {
+ ALOGI("descramble failed, trans=%s, status=%d, outBytes=%u, error=%s",
+ returnVoid.description().c_str(), *descrambleStatus, outBytes, detailedError.c_str());
+ }
+ return ::testing::AssertionResult(returnVoid.isOk());
+}
+
TEST_F(MediaCasHidlTest, EnumeratePlugins) {
description("Test enumerate plugins");
hidl_vec<HidlCasPluginDescriptor> descriptors;
@@ -613,6 +693,153 @@
EXPECT_FALSE(mDescramblerBase->requiresSecureDecoderComponent("bad"));
}
+TEST_F(MediaCasHidlTest, TestClearKeyOobFails) {
+ description("Test that oob descramble request fails with expected error");
+
+ ASSERT_TRUE(createCasPlugin(CLEAR_KEY_SYSTEM_ID));
+
+ auto returnStatus = mMediaCas->provision(hidl_string(PROVISION_STR));
+ EXPECT_TRUE(returnStatus.isOk());
+ EXPECT_EQ(Status::OK, returnStatus);
+
+ std::vector<uint8_t> sessionId;
+ ASSERT_TRUE(openCasSession(&sessionId));
+
+ returnStatus = mDescramblerBase->setMediaCasSession(sessionId);
+ EXPECT_TRUE(returnStatus.isOk());
+ EXPECT_EQ(Status::OK, returnStatus);
+
+ hidl_vec<uint8_t> hidlEcm;
+ hidlEcm.setToExternal(const_cast<uint8_t*>(kEcmBinaryBuffer), sizeof(kEcmBinaryBuffer));
+ returnStatus = mMediaCas->processEcm(sessionId, hidlEcm);
+ EXPECT_TRUE(returnStatus.isOk());
+ EXPECT_EQ(Status::OK, returnStatus);
+
+ sp<IDescrambler> descrambler = IDescrambler::castFrom(mDescramblerBase);
+ ASSERT_NE(nullptr, descrambler.get());
+
+ Status descrambleStatus = Status::OK;
+
+ // test invalid src buffer offset
+ ASSERT_TRUE(descrambleTestOobInput(
+ descrambler,
+ &descrambleStatus,
+ {
+ .subSamples = kSubSamples,
+ .numSubSamples = sizeof(kSubSamples)/sizeof(SubSample),
+ .imemSizeActual = sizeof(kInBinaryBuffer),
+ .imemOffset = 0xcccccc,
+ .imemSize = sizeof(kInBinaryBuffer),
+ .srcOffset = 0,
+ .dstOffset = 0
+ }));
+ EXPECT_EQ(Status::BAD_VALUE, descrambleStatus);
+
+ // test invalid src buffer size
+ ASSERT_TRUE(descrambleTestOobInput(
+ descrambler,
+ &descrambleStatus,
+ {
+ .subSamples = kSubSamples,
+ .numSubSamples = sizeof(kSubSamples)/sizeof(SubSample),
+ .imemSizeActual = sizeof(kInBinaryBuffer),
+ .imemOffset = 0,
+ .imemSize = 0xcccccc,
+ .srcOffset = 0,
+ .dstOffset = 0
+ }));
+ EXPECT_EQ(Status::BAD_VALUE, descrambleStatus);
+
+ // test invalid src buffer size
+ ASSERT_TRUE(descrambleTestOobInput(
+ descrambler,
+ &descrambleStatus,
+ {
+ .subSamples = kSubSamples,
+ .numSubSamples = sizeof(kSubSamples)/sizeof(SubSample),
+ .imemSizeActual = sizeof(kInBinaryBuffer),
+ .imemOffset = 1,
+ .imemSize = (uint64_t)-1,
+ .srcOffset = 0,
+ .dstOffset = 0
+ }));
+ EXPECT_EQ(Status::BAD_VALUE, descrambleStatus);
+
+ // test invalid srcOffset
+ ASSERT_TRUE(descrambleTestOobInput(
+ descrambler,
+ &descrambleStatus,
+ {
+ .subSamples = kSubSamples,
+ .numSubSamples = sizeof(kSubSamples)/sizeof(SubSample),
+ .imemSizeActual = sizeof(kInBinaryBuffer),
+ .imemOffset = 0,
+ .imemSize = sizeof(kInBinaryBuffer),
+ .srcOffset = 0xcccccc,
+ .dstOffset = 0
+ }));
+ EXPECT_EQ(Status::BAD_VALUE, descrambleStatus);
+
+ // test invalid dstOffset
+ ASSERT_TRUE(descrambleTestOobInput(
+ descrambler,
+ &descrambleStatus,
+ {
+ .subSamples = kSubSamples,
+ .numSubSamples = sizeof(kSubSamples)/sizeof(SubSample),
+ .imemSizeActual = sizeof(kInBinaryBuffer),
+ .imemOffset = 0,
+ .imemSize = sizeof(kInBinaryBuffer),
+ .srcOffset = 0,
+ .dstOffset = 0xcccccc
+ }));
+ EXPECT_EQ(Status::BAD_VALUE, descrambleStatus);
+
+ // test detection of oob subsample sizes
+ const SubSample invalidSubSamples1[] =
+ {{162, 0}, {0, 184}, {0, 0xdddddd}};
+
+ ASSERT_TRUE(descrambleTestOobInput(
+ descrambler,
+ &descrambleStatus,
+ {
+ .subSamples = invalidSubSamples1,
+ .numSubSamples = sizeof(invalidSubSamples1)/sizeof(SubSample),
+ .imemSizeActual = sizeof(kInBinaryBuffer),
+ .imemOffset = 0,
+ .imemSize = sizeof(kInBinaryBuffer),
+ .srcOffset = 0,
+ .dstOffset = 0
+ }));
+ EXPECT_EQ(Status::BAD_VALUE, descrambleStatus);
+
+ // test detection of overflowing subsample sizes
+ const SubSample invalidSubSamples2[] =
+ {{162, 0}, {0, 184}, {2, (uint32_t)-1}};
+
+ ASSERT_TRUE(descrambleTestOobInput(
+ descrambler,
+ &descrambleStatus,
+ {
+ .subSamples = invalidSubSamples2,
+ .numSubSamples = sizeof(invalidSubSamples2)/sizeof(SubSample),
+ .imemSizeActual = sizeof(kInBinaryBuffer),
+ .imemOffset = 0,
+ .imemSize = sizeof(kInBinaryBuffer),
+ .srcOffset = 0,
+ .dstOffset = 0
+ }));
+ EXPECT_EQ(Status::BAD_VALUE, descrambleStatus);
+
+ returnStatus = mDescramblerBase->release();
+ EXPECT_TRUE(returnStatus.isOk());
+ EXPECT_EQ(Status::OK, returnStatus);
+
+ returnStatus = mMediaCas->release();
+ EXPECT_TRUE(returnStatus.isOk());
+ EXPECT_EQ(Status::OK, returnStatus);
+}
+
} // anonymous namespace
int main(int argc, char** argv) {
diff --git a/contexthub/1.0/default/Contexthub.cpp b/contexthub/1.0/default/Contexthub.cpp
index 8d10c75..5f83a22 100644
--- a/contexthub/1.0/default/Contexthub.cpp
+++ b/contexthub/1.0/default/Contexthub.cpp
@@ -281,11 +281,11 @@
result = TransactionResult::FAILURE;
}
+ mIsTransactionPending = false;
if (cb != nullptr) {
cb->handleTxnResult(mTransactionId, result);
}
retVal = 0;
- mIsTransactionPending = false;
break;
}
@@ -383,6 +383,7 @@
msg.appName = rxMsg->app_name.id;
msg.msgType = rxMsg->message_type;
+ msg.hostEndPoint = static_cast<uint16_t>(HostEndPoint::BROADCAST);
msg.msg = std::vector<uint8_t>(static_cast<const uint8_t *>(rxMsg->message),
static_cast<const uint8_t *>(rxMsg->message) +
rxMsg->message_len);
diff --git a/current.txt b/current.txt
index 67d5ee0..4a943b9 100644
--- a/current.txt
+++ b/current.txt
@@ -262,3 +262,4 @@
# ABI preserving changes to HALs during Android P
fb92e2b40f8e9d494e8fd3b4ac18499a3216342e7cff160714c3bbf3660b6e79 android.hardware.gnss@1.0::IGnssConfiguration
d4c10cb28318dba8efb22231a8c23e86ad8853f85775187c40b42a878a5ef4d5 android.hardware.automotive.vehicle@2.0::types
+cf72ff5a52bfa4d08e9e1000cf3ab5952a2d280c7f13cdad5ab7905c08050766 android.hardware.camera.metadata@3.2::types
diff --git a/keymaster/4.0/Android.bp b/keymaster/4.0/Android.bp
index 34997d2..378204a 100644
--- a/keymaster/4.0/Android.bp
+++ b/keymaster/4.0/Android.bp
@@ -16,12 +16,10 @@
],
types: [
"HardwareAuthToken",
- "HardwareAuthTokenMacMethod",
"KeyCharacteristics",
"KeyParameter",
"KeyPurpose",
"Tag",
- "TagType",
],
gen_java: false,
}
diff --git a/power/1.2/Android.bp b/power/1.2/Android.bp
new file mode 100644
index 0000000..0eb73e7
--- /dev/null
+++ b/power/1.2/Android.bp
@@ -0,0 +1,23 @@
+// This file is autogenerated by hidl-gen -Landroidbp.
+
+hidl_interface {
+ name: "android.hardware.power@1.2",
+ root: "android.hardware",
+ vndk: {
+ enabled: true,
+ },
+ srcs: [
+ "types.hal",
+ "IPower.hal",
+ ],
+ interfaces: [
+ "android.hardware.power@1.0",
+ "android.hardware.power@1.1",
+ "android.hidl.base@1.0",
+ ],
+ types: [
+ "PowerHint",
+ ],
+ gen_java: true,
+}
+
diff --git a/power/1.2/IPower.hal b/power/1.2/IPower.hal
new file mode 100644
index 0000000..1c2c7b8
--- /dev/null
+++ b/power/1.2/IPower.hal
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2017 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.power@1.2;
+
+import @1.1::IPower;
+
+interface IPower extends @1.1::IPower {
+ /**
+ * called to pass hints on power requirements which
+ * may result in adjustment of power/performance parameters of the
+ * cpufreq governor and other controls.
+ *
+ * A particular platform may choose to ignore any hint.
+ *
+ * @param hint PowerHint which is passed
+ * @param data contains additional information about the hint
+ * and is described along with the comments for each of the hints.
+ */
+ oneway powerHintAsync_1_2(PowerHint hint, int32_t data);
+};
diff --git a/power/1.2/types.hal b/power/1.2/types.hal
new file mode 100644
index 0000000..f7a6cf6
--- /dev/null
+++ b/power/1.2/types.hal
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2017 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.power@1.2;
+
+import @1.0::PowerHint;
+
+/** Power hint identifiers passed to powerHintAsync_1_2() */
+enum PowerHint : @1.0::PowerHint {
+ /**
+ * This hint indicates that audio stream is being started. Can be used
+ * for device specific optimizations during starting audio stream. The
+ * data parameter is non-zero when stream starts and zero when audio
+ * stream setup is complete.
+ */
+ AUDIO_STREAMING,
+
+ /**
+ * This hint indicates that low latency audio is active. Can be used
+ * for device specific optimizations towards low latency audio. The
+ * data parameter is non-zero when low latency audio starts and
+ * zero when ends.
+ */
+ AUDIO_LOW_LATENCY,
+
+ /**
+ * These hint indicates that camera is being launched. Can be used
+ * for device specific optimizations during camera launch. The data
+ * parameter is non-zero when camera launch starts and zero when launch
+ * is complete.
+ */
+ CAMERA_LAUNCH,
+
+ /**
+ * This hint indicates that camera stream is being started. Can be used
+ * for device specific optimizations during starting camera stream. The
+ * data parameter is non-zero when stream starts and zero when ends.
+ */
+ CAMERA_STREAMING,
+
+ /**
+ * This hint indicates that camera shot is being taken. Can be used
+ * for device specific optimizations during taking camera shot. The
+ * data parameter is non-zero when camera shot starts and zero when ends.
+ */
+ CAMERA_SHOT,
+};
diff --git a/power/1.2/vts/functional/Android.bp b/power/1.2/vts/functional/Android.bp
new file mode 100644
index 0000000..d615e85
--- /dev/null
+++ b/power/1.2/vts/functional/Android.bp
@@ -0,0 +1,26 @@
+//
+// Copyright (C) 2017 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.
+//
+
+cc_test {
+ name: "VtsHalPowerV1_2TargetTest",
+ defaults: ["VtsHalTargetTestDefaults"],
+ srcs: ["VtsHalPowerV1_2TargetTest.cpp"],
+ static_libs: [
+ "android.hardware.power@1.0",
+ "android.hardware.power@1.1",
+ "android.hardware.power@1.2",
+ ],
+}
diff --git a/power/1.2/vts/functional/VtsHalPowerV1_2TargetTest.cpp b/power/1.2/vts/functional/VtsHalPowerV1_2TargetTest.cpp
new file mode 100644
index 0000000..5e92997
--- /dev/null
+++ b/power/1.2/vts/functional/VtsHalPowerV1_2TargetTest.cpp
@@ -0,0 +1,99 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+
+#define LOG_TAG "power_hidl_hal_test"
+#include <android-base/logging.h>
+#include <android/hardware/power/1.2/IPower.h>
+
+#include <VtsHalHidlTargetTestBase.h>
+#include <VtsHalHidlTargetTestEnvBase.h>
+
+using ::android::sp;
+using ::android::hardware::hidl_vec;
+using ::android::hardware::Return;
+using ::android::hardware::power::V1_2::IPower;
+using ::android::hardware::power::V1_2::PowerHint;
+
+// Test environment for Power HIDL HAL.
+class PowerHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
+ public:
+ // get the test environment singleton
+ static PowerHidlEnvironment* Instance() {
+ static PowerHidlEnvironment* instance = new PowerHidlEnvironment;
+ return instance;
+ }
+
+ virtual void registerTestServices() override { registerTestService<IPower>(); }
+};
+
+class PowerHidlTest : public ::testing::VtsHalHidlTargetTestBase {
+ public:
+ virtual void SetUp() override {
+ power = ::testing::VtsHalHidlTargetTestBase::getService<IPower>(
+ PowerHidlEnvironment::Instance()->getServiceName<IPower>());
+ ASSERT_NE(power, nullptr);
+ }
+
+ sp<IPower> power;
+};
+
+// Sanity check Power::PowerHintAsync_1_2 on good and bad inputs.
+TEST_F(PowerHidlTest, PowerHintAsync_1_2) {
+ std::vector<PowerHint> hints;
+ for (uint32_t i = static_cast<uint32_t>(PowerHint::VSYNC);
+ i <= static_cast<uint32_t>(PowerHint::CAMERA_SHOT); ++i) {
+ hints.emplace_back(static_cast<PowerHint>(i));
+ }
+ PowerHint badHint = static_cast<PowerHint>(0xFF);
+ hints.emplace_back(badHint);
+
+ Return<void> ret;
+ for (auto& hint : hints) {
+ ret = power->powerHintAsync_1_2(hint, 30000);
+ ASSERT_TRUE(ret.isOk());
+
+ ret = power->powerHintAsync_1_2(hint, 0);
+ ASSERT_TRUE(ret.isOk());
+ }
+
+ // Turning these hints on in different orders triggers different code paths,
+ // so iterate over possible orderings.
+ std::vector<PowerHint> hints2 = {PowerHint::AUDIO_STREAMING, PowerHint::CAMERA_LAUNCH,
+ PowerHint::CAMERA_STREAMING, PowerHint::CAMERA_SHOT};
+ auto compareHints = [](PowerHint l, PowerHint r) {
+ return static_cast<uint32_t>(l) < static_cast<uint32_t>(r);
+ };
+ std::sort(hints2.begin(), hints2.end(), compareHints);
+ do {
+ for (auto iter = hints2.begin(); iter != hints2.end(); iter++) {
+ ret = power->powerHintAsync_1_2(*iter, 0);
+ ASSERT_TRUE(ret.isOk());
+ }
+ for (auto iter = hints2.begin(); iter != hints2.end(); iter++) {
+ ret = power->powerHintAsync_1_2(*iter, 30000);
+ ASSERT_TRUE(ret.isOk());
+ }
+ } while (std::next_permutation(hints2.begin(), hints2.end(), compareHints));
+}
+
+int main(int argc, char** argv) {
+ ::testing::AddGlobalTestEnvironment(PowerHidlEnvironment::Instance());
+ ::testing::InitGoogleTest(&argc, argv);
+ PowerHidlEnvironment::Instance()->init(&argc, argv);
+ int status = RUN_ALL_TESTS();
+ LOG(INFO) << "Test result = " << status;
+ return status;
+}
diff --git a/tests/memory/1.0/Android.bp b/tests/memory/1.0/Android.bp
index 5038664..cbee247 100644
--- a/tests/memory/1.0/Android.bp
+++ b/tests/memory/1.0/Android.bp
@@ -7,9 +7,9 @@
"IMemoryTest.hal",
],
interfaces: [
- "android.hidl.memory.token@1.0",
- "android.hidl.memory.block@1.0",
"android.hidl.base@1.0",
+ "android.hidl.memory.block@1.0",
+ "android.hidl.memory.token@1.0",
],
gen_java: false,
}
diff --git a/wifi/1.2/default/hidl_callback_util.h b/wifi/1.2/default/hidl_callback_util.h
index 65fe80b..97f312a 100644
--- a/wifi/1.2/default/hidl_callback_util.h
+++ b/wifi/1.2/default/hidl_callback_util.h
@@ -29,22 +29,23 @@
// callbacks stored in HidlCallbackHandler.
template <typename CallbackType>
class HidlDeathHandler : public android::hardware::hidl_death_recipient {
- public:
- HidlDeathHandler(const on_death_cb_function& user_cb_function)
- : cb_function_(user_cb_function) {}
- ~HidlDeathHandler() = default;
+ public:
+ HidlDeathHandler(const on_death_cb_function& user_cb_function)
+ : cb_function_(user_cb_function) {}
+ ~HidlDeathHandler() = default;
- // Death notification for callbacks.
- void serviceDied(
- uint64_t cookie,
- const android::wp<android::hidl::base::V1_0::IBase>& /* who */) override {
- cb_function_(cookie);
- }
+ // Death notification for callbacks.
+ void serviceDied(
+ uint64_t cookie,
+ const android::wp<android::hidl::base::V1_0::IBase>& /* who */)
+ override {
+ cb_function_(cookie);
+ }
- private:
- on_death_cb_function cb_function_;
+ private:
+ on_death_cb_function cb_function_;
- DISALLOW_COPY_AND_ASSIGN(HidlDeathHandler);
+ DISALLOW_COPY_AND_ASSIGN(HidlDeathHandler);
};
} // namespace
@@ -58,58 +59,60 @@
// Provides a class to manage callbacks for the various HIDL interfaces and
// handle the death of the process hosting each callback.
class HidlCallbackHandler {
- public:
- HidlCallbackHandler()
- : death_handler_(new HidlDeathHandler<CallbackType>(
- std::bind(&HidlCallbackHandler::onObjectDeath,
- this,
- std::placeholders::_1))) {}
- ~HidlCallbackHandler() = default;
+ public:
+ HidlCallbackHandler()
+ : death_handler_(new HidlDeathHandler<CallbackType>(
+ std::bind(&HidlCallbackHandler::onObjectDeath, this,
+ std::placeholders::_1))) {}
+ ~HidlCallbackHandler() = default;
- bool addCallback(const sp<CallbackType>& cb) {
- // TODO(b/33818800): Can't compare proxies yet. So, use the cookie
- // (callback proxy's raw pointer) to track the death of individual clients.
- uint64_t cookie = reinterpret_cast<uint64_t>(cb.get());
- if (cb_set_.find(cb) != cb_set_.end()) {
- LOG(WARNING) << "Duplicate death notification registration";
- return true;
+ bool addCallback(const sp<CallbackType>& cb) {
+ // TODO(b/33818800): Can't compare proxies yet. So, use the cookie
+ // (callback proxy's raw pointer) to track the death of individual
+ // clients.
+ uint64_t cookie = reinterpret_cast<uint64_t>(cb.get());
+ if (cb_set_.find(cb) != cb_set_.end()) {
+ LOG(WARNING) << "Duplicate death notification registration";
+ return true;
+ }
+ if (!cb->linkToDeath(death_handler_, cookie)) {
+ LOG(ERROR) << "Failed to register death notification";
+ return false;
+ }
+ cb_set_.insert(cb);
+ return true;
}
- if (!cb->linkToDeath(death_handler_, cookie)) {
- LOG(ERROR) << "Failed to register death notification";
- return false;
+
+ const std::set<android::sp<CallbackType>>& getCallbacks() {
+ return cb_set_;
}
- cb_set_.insert(cb);
- return true;
- }
- const std::set<android::sp<CallbackType>>& getCallbacks() { return cb_set_; }
-
- // Death notification for callbacks.
- void onObjectDeath(uint64_t cookie) {
- CallbackType* cb = reinterpret_cast<CallbackType*>(cookie);
- const auto& iter = cb_set_.find(cb);
- if (iter == cb_set_.end()) {
- LOG(ERROR) << "Unknown callback death notification received";
- return;
+ // Death notification for callbacks.
+ void onObjectDeath(uint64_t cookie) {
+ CallbackType* cb = reinterpret_cast<CallbackType*>(cookie);
+ const auto& iter = cb_set_.find(cb);
+ if (iter == cb_set_.end()) {
+ LOG(ERROR) << "Unknown callback death notification received";
+ return;
+ }
+ cb_set_.erase(iter);
+ LOG(DEBUG) << "Dead callback removed from list";
}
- cb_set_.erase(iter);
- LOG(DEBUG) << "Dead callback removed from list";
- }
- void invalidate() {
- for (const sp<CallbackType>& cb : cb_set_) {
- if (!cb->unlinkToDeath(death_handler_)) {
- LOG(ERROR) << "Failed to deregister death notification";
- }
+ void invalidate() {
+ for (const sp<CallbackType>& cb : cb_set_) {
+ if (!cb->unlinkToDeath(death_handler_)) {
+ LOG(ERROR) << "Failed to deregister death notification";
+ }
+ }
+ cb_set_.clear();
}
- cb_set_.clear();
- }
- private:
- std::set<sp<CallbackType>> cb_set_;
- sp<HidlDeathHandler<CallbackType>> death_handler_;
+ private:
+ std::set<sp<CallbackType>> cb_set_;
+ sp<HidlDeathHandler<CallbackType>> death_handler_;
- DISALLOW_COPY_AND_ASSIGN(HidlCallbackHandler);
+ DISALLOW_COPY_AND_ASSIGN(HidlCallbackHandler);
};
} // namespace hidl_callback_util
diff --git a/wifi/1.2/default/hidl_return_util.h b/wifi/1.2/default/hidl_return_util.h
index 6fe382c..914c1b4 100644
--- a/wifi/1.2/default/hidl_return_util.h
+++ b/wifi/1.2/default/hidl_return_util.h
@@ -41,18 +41,15 @@
// Use for HIDL methods which return only an instance of WifiStatus.
template <typename ObjT, typename WorkFuncT, typename... Args>
Return<void> validateAndCall(
- ObjT* obj,
- WifiStatusCode status_code_if_invalid,
- WorkFuncT&& work,
- const std::function<void(const WifiStatus&)>& hidl_cb,
- Args&&... args) {
- const auto lock = hidl_sync_util::acquireGlobalLock();
- if (obj->isValid()) {
- hidl_cb((obj->*work)(std::forward<Args>(args)...));
- } else {
- hidl_cb(createWifiStatus(status_code_if_invalid));
- }
- return Void();
+ ObjT* obj, WifiStatusCode status_code_if_invalid, WorkFuncT&& work,
+ const std::function<void(const WifiStatus&)>& hidl_cb, Args&&... args) {
+ const auto lock = hidl_sync_util::acquireGlobalLock();
+ if (obj->isValid()) {
+ hidl_cb((obj->*work)(std::forward<Args>(args)...));
+ } else {
+ hidl_cb(createWifiStatus(status_code_if_invalid));
+ }
+ return Void();
}
// Use for HIDL methods which return only an instance of WifiStatus.
@@ -60,71 +57,61 @@
// Note: Only used by IWifi::stop() currently.
template <typename ObjT, typename WorkFuncT, typename... Args>
Return<void> validateAndCallWithLock(
- ObjT* obj,
- WifiStatusCode status_code_if_invalid,
- WorkFuncT&& work,
- const std::function<void(const WifiStatus&)>& hidl_cb,
- Args&&... args) {
- auto lock = hidl_sync_util::acquireGlobalLock();
- if (obj->isValid()) {
- hidl_cb((obj->*work)(&lock, std::forward<Args>(args)...));
- } else {
- hidl_cb(createWifiStatus(status_code_if_invalid));
- }
- return Void();
+ ObjT* obj, WifiStatusCode status_code_if_invalid, WorkFuncT&& work,
+ const std::function<void(const WifiStatus&)>& hidl_cb, Args&&... args) {
+ auto lock = hidl_sync_util::acquireGlobalLock();
+ if (obj->isValid()) {
+ hidl_cb((obj->*work)(&lock, std::forward<Args>(args)...));
+ } else {
+ hidl_cb(createWifiStatus(status_code_if_invalid));
+ }
+ return Void();
}
// Use for HIDL methods which return instance of WifiStatus and a single return
// value.
template <typename ObjT, typename WorkFuncT, typename ReturnT, typename... Args>
Return<void> validateAndCall(
- ObjT* obj,
- WifiStatusCode status_code_if_invalid,
- WorkFuncT&& work,
+ ObjT* obj, WifiStatusCode status_code_if_invalid, WorkFuncT&& work,
const std::function<void(const WifiStatus&, ReturnT)>& hidl_cb,
Args&&... args) {
- const auto lock = hidl_sync_util::acquireGlobalLock();
- if (obj->isValid()) {
- const auto& ret_pair = (obj->*work)(std::forward<Args>(args)...);
- const WifiStatus& status = std::get<0>(ret_pair);
- const auto& ret_value = std::get<1>(ret_pair);
- hidl_cb(status, ret_value);
- } else {
- hidl_cb(createWifiStatus(status_code_if_invalid),
- typename std::remove_reference<ReturnT>::type());
- }
- return Void();
+ const auto lock = hidl_sync_util::acquireGlobalLock();
+ if (obj->isValid()) {
+ const auto& ret_pair = (obj->*work)(std::forward<Args>(args)...);
+ const WifiStatus& status = std::get<0>(ret_pair);
+ const auto& ret_value = std::get<1>(ret_pair);
+ hidl_cb(status, ret_value);
+ } else {
+ hidl_cb(createWifiStatus(status_code_if_invalid),
+ typename std::remove_reference<ReturnT>::type());
+ }
+ return Void();
}
// Use for HIDL methods which return instance of WifiStatus and 2 return
// values.
-template <typename ObjT,
- typename WorkFuncT,
- typename ReturnT1,
- typename ReturnT2,
- typename... Args>
+template <typename ObjT, typename WorkFuncT, typename ReturnT1,
+ typename ReturnT2, typename... Args>
Return<void> validateAndCall(
- ObjT* obj,
- WifiStatusCode status_code_if_invalid,
- WorkFuncT&& work,
+ ObjT* obj, WifiStatusCode status_code_if_invalid, WorkFuncT&& work,
const std::function<void(const WifiStatus&, ReturnT1, ReturnT2)>& hidl_cb,
Args&&... args) {
- const auto lock = hidl_sync_util::acquireGlobalLock();
- if (obj->isValid()) {
- const auto& ret_tuple = (obj->*work)(std::forward<Args>(args)...);
- const WifiStatus& status = std::get<0>(ret_tuple);
- const auto& ret_value1 = std::get<1>(ret_tuple);
- const auto& ret_value2 = std::get<2>(ret_tuple);
- hidl_cb(status, ret_value1, ret_value2);
- } else {
- hidl_cb(createWifiStatus(status_code_if_invalid),
- typename std::remove_reference<ReturnT1>::type(),
- typename std::remove_reference<ReturnT2>::type());
- }
- return Void();
+ const auto lock = hidl_sync_util::acquireGlobalLock();
+ if (obj->isValid()) {
+ const auto& ret_tuple = (obj->*work)(std::forward<Args>(args)...);
+ const WifiStatus& status = std::get<0>(ret_tuple);
+ const auto& ret_value1 = std::get<1>(ret_tuple);
+ const auto& ret_value2 = std::get<2>(ret_tuple);
+ hidl_cb(status, ret_value1, ret_value2);
+ } else {
+ hidl_cb(createWifiStatus(status_code_if_invalid),
+ typename std::remove_reference<ReturnT1>::type(),
+ typename std::remove_reference<ReturnT2>::type());
+ }
+ return Void();
}
-} // namespace hidl_util
+} // namespace hidl_return_util
} // namespace implementation
} // namespace V1_2
} // namespace wifi
diff --git a/wifi/1.2/default/hidl_struct_util.cpp b/wifi/1.2/default/hidl_struct_util.cpp
index 1ad838b..1359498 100644
--- a/wifi/1.2/default/hidl_struct_util.cpp
+++ b/wifi/1.2/default/hidl_struct_util.cpp
@@ -27,2185 +27,2394 @@
namespace hidl_struct_util {
hidl_string safeConvertChar(const char* str, size_t max_len) {
- const char* c = str;
- size_t size = 0;
- while (*c && (unsigned char)*c < 128 && size < max_len) {
- ++size;
- ++c;
- }
- return hidl_string(str, size);
+ const char* c = str;
+ size_t size = 0;
+ while (*c && (unsigned char)*c < 128 && size < max_len) {
+ ++size;
+ ++c;
+ }
+ return hidl_string(str, size);
}
IWifiChip::ChipCapabilityMask convertLegacyLoggerFeatureToHidlChipCapability(
uint32_t feature) {
- using HidlChipCaps = IWifiChip::ChipCapabilityMask;
- switch (feature) {
- case legacy_hal::WIFI_LOGGER_MEMORY_DUMP_SUPPORTED:
- return HidlChipCaps::DEBUG_MEMORY_FIRMWARE_DUMP;
- case legacy_hal::WIFI_LOGGER_DRIVER_DUMP_SUPPORTED:
- return HidlChipCaps::DEBUG_MEMORY_DRIVER_DUMP;
- case legacy_hal::WIFI_LOGGER_CONNECT_EVENT_SUPPORTED:
- return HidlChipCaps::DEBUG_RING_BUFFER_CONNECT_EVENT;
- case legacy_hal::WIFI_LOGGER_POWER_EVENT_SUPPORTED:
- return HidlChipCaps::DEBUG_RING_BUFFER_POWER_EVENT;
- case legacy_hal::WIFI_LOGGER_WAKE_LOCK_SUPPORTED:
- return HidlChipCaps::DEBUG_RING_BUFFER_WAKELOCK_EVENT;
- };
- CHECK(false) << "Unknown legacy feature: " << feature;
- return {};
+ using HidlChipCaps = IWifiChip::ChipCapabilityMask;
+ switch (feature) {
+ case legacy_hal::WIFI_LOGGER_MEMORY_DUMP_SUPPORTED:
+ return HidlChipCaps::DEBUG_MEMORY_FIRMWARE_DUMP;
+ case legacy_hal::WIFI_LOGGER_DRIVER_DUMP_SUPPORTED:
+ return HidlChipCaps::DEBUG_MEMORY_DRIVER_DUMP;
+ case legacy_hal::WIFI_LOGGER_CONNECT_EVENT_SUPPORTED:
+ return HidlChipCaps::DEBUG_RING_BUFFER_CONNECT_EVENT;
+ case legacy_hal::WIFI_LOGGER_POWER_EVENT_SUPPORTED:
+ return HidlChipCaps::DEBUG_RING_BUFFER_POWER_EVENT;
+ case legacy_hal::WIFI_LOGGER_WAKE_LOCK_SUPPORTED:
+ return HidlChipCaps::DEBUG_RING_BUFFER_WAKELOCK_EVENT;
+ };
+ CHECK(false) << "Unknown legacy feature: " << feature;
+ return {};
}
IWifiStaIface::StaIfaceCapabilityMask
convertLegacyLoggerFeatureToHidlStaIfaceCapability(uint32_t feature) {
- using HidlStaIfaceCaps = IWifiStaIface::StaIfaceCapabilityMask;
- switch (feature) {
- case legacy_hal::WIFI_LOGGER_PACKET_FATE_SUPPORTED:
- return HidlStaIfaceCaps::DEBUG_PACKET_FATE;
- };
- CHECK(false) << "Unknown legacy feature: " << feature;
- return {};
+ using HidlStaIfaceCaps = IWifiStaIface::StaIfaceCapabilityMask;
+ switch (feature) {
+ case legacy_hal::WIFI_LOGGER_PACKET_FATE_SUPPORTED:
+ return HidlStaIfaceCaps::DEBUG_PACKET_FATE;
+ };
+ CHECK(false) << "Unknown legacy feature: " << feature;
+ return {};
}
V1_1::IWifiChip::ChipCapabilityMask convertLegacyFeatureToHidlChipCapability(
uint32_t feature) {
- using HidlChipCaps = V1_1::IWifiChip::ChipCapabilityMask;
- switch (feature) {
- case WIFI_FEATURE_SET_TX_POWER_LIMIT:
- return HidlChipCaps::SET_TX_POWER_LIMIT;
- case WIFI_FEATURE_D2D_RTT:
- return HidlChipCaps::D2D_RTT;
- case WIFI_FEATURE_D2AP_RTT:
- return HidlChipCaps::D2AP_RTT;
- };
- CHECK(false) << "Unknown legacy feature: " << feature;
- return {};
+ using HidlChipCaps = V1_1::IWifiChip::ChipCapabilityMask;
+ switch (feature) {
+ case WIFI_FEATURE_SET_TX_POWER_LIMIT:
+ return HidlChipCaps::SET_TX_POWER_LIMIT;
+ case WIFI_FEATURE_D2D_RTT:
+ return HidlChipCaps::D2D_RTT;
+ case WIFI_FEATURE_D2AP_RTT:
+ return HidlChipCaps::D2AP_RTT;
+ };
+ CHECK(false) << "Unknown legacy feature: " << feature;
+ return {};
}
IWifiStaIface::StaIfaceCapabilityMask
convertLegacyFeatureToHidlStaIfaceCapability(uint32_t feature) {
- using HidlStaIfaceCaps = IWifiStaIface::StaIfaceCapabilityMask;
- switch (feature) {
- case WIFI_FEATURE_GSCAN:
- return HidlStaIfaceCaps::BACKGROUND_SCAN;
- case WIFI_FEATURE_LINK_LAYER_STATS:
- return HidlStaIfaceCaps::LINK_LAYER_STATS;
- case WIFI_FEATURE_RSSI_MONITOR:
- return HidlStaIfaceCaps::RSSI_MONITOR;
- case WIFI_FEATURE_CONTROL_ROAMING:
- return HidlStaIfaceCaps::CONTROL_ROAMING;
- case WIFI_FEATURE_IE_WHITELIST:
- return HidlStaIfaceCaps::PROBE_IE_WHITELIST;
- case WIFI_FEATURE_SCAN_RAND:
- return HidlStaIfaceCaps::SCAN_RAND;
- case WIFI_FEATURE_INFRA_5G:
- return HidlStaIfaceCaps::STA_5G;
- case WIFI_FEATURE_HOTSPOT:
- return HidlStaIfaceCaps::HOTSPOT;
- case WIFI_FEATURE_PNO:
- return HidlStaIfaceCaps::PNO;
- case WIFI_FEATURE_TDLS:
- return HidlStaIfaceCaps::TDLS;
- case WIFI_FEATURE_TDLS_OFFCHANNEL:
- return HidlStaIfaceCaps::TDLS_OFFCHANNEL;
- case WIFI_FEATURE_CONFIG_NDO:
- return HidlStaIfaceCaps::ND_OFFLOAD;
- case WIFI_FEATURE_MKEEP_ALIVE:
- return HidlStaIfaceCaps::KEEP_ALIVE;
- };
- CHECK(false) << "Unknown legacy feature: " << feature;
- return {};
+ using HidlStaIfaceCaps = IWifiStaIface::StaIfaceCapabilityMask;
+ switch (feature) {
+ case WIFI_FEATURE_GSCAN:
+ return HidlStaIfaceCaps::BACKGROUND_SCAN;
+ case WIFI_FEATURE_LINK_LAYER_STATS:
+ return HidlStaIfaceCaps::LINK_LAYER_STATS;
+ case WIFI_FEATURE_RSSI_MONITOR:
+ return HidlStaIfaceCaps::RSSI_MONITOR;
+ case WIFI_FEATURE_CONTROL_ROAMING:
+ return HidlStaIfaceCaps::CONTROL_ROAMING;
+ case WIFI_FEATURE_IE_WHITELIST:
+ return HidlStaIfaceCaps::PROBE_IE_WHITELIST;
+ case WIFI_FEATURE_SCAN_RAND:
+ return HidlStaIfaceCaps::SCAN_RAND;
+ case WIFI_FEATURE_INFRA_5G:
+ return HidlStaIfaceCaps::STA_5G;
+ case WIFI_FEATURE_HOTSPOT:
+ return HidlStaIfaceCaps::HOTSPOT;
+ case WIFI_FEATURE_PNO:
+ return HidlStaIfaceCaps::PNO;
+ case WIFI_FEATURE_TDLS:
+ return HidlStaIfaceCaps::TDLS;
+ case WIFI_FEATURE_TDLS_OFFCHANNEL:
+ return HidlStaIfaceCaps::TDLS_OFFCHANNEL;
+ case WIFI_FEATURE_CONFIG_NDO:
+ return HidlStaIfaceCaps::ND_OFFLOAD;
+ case WIFI_FEATURE_MKEEP_ALIVE:
+ return HidlStaIfaceCaps::KEEP_ALIVE;
+ };
+ CHECK(false) << "Unknown legacy feature: " << feature;
+ return {};
}
bool convertLegacyFeaturesToHidlChipCapabilities(
- uint32_t legacy_feature_set,
- uint32_t legacy_logger_feature_set,
+ uint32_t legacy_feature_set, uint32_t legacy_logger_feature_set,
uint32_t* hidl_caps) {
- if (!hidl_caps) {
- return false;
- }
- *hidl_caps = {};
- using HidlChipCaps = IWifiChip::ChipCapabilityMask;
- for (const auto feature : {legacy_hal::WIFI_LOGGER_MEMORY_DUMP_SUPPORTED,
- legacy_hal::WIFI_LOGGER_DRIVER_DUMP_SUPPORTED,
- legacy_hal::WIFI_LOGGER_CONNECT_EVENT_SUPPORTED,
- legacy_hal::WIFI_LOGGER_POWER_EVENT_SUPPORTED,
- legacy_hal::WIFI_LOGGER_WAKE_LOCK_SUPPORTED}) {
- if (feature & legacy_logger_feature_set) {
- *hidl_caps |= convertLegacyLoggerFeatureToHidlChipCapability(feature);
+ if (!hidl_caps) {
+ return false;
}
- }
- for (const auto feature : {WIFI_FEATURE_SET_TX_POWER_LIMIT,
- WIFI_FEATURE_D2D_RTT,
- WIFI_FEATURE_D2AP_RTT}) {
- if (feature & legacy_feature_set) {
- *hidl_caps |= convertLegacyFeatureToHidlChipCapability(feature);
+ *hidl_caps = {};
+ using HidlChipCaps = IWifiChip::ChipCapabilityMask;
+ for (const auto feature : {legacy_hal::WIFI_LOGGER_MEMORY_DUMP_SUPPORTED,
+ legacy_hal::WIFI_LOGGER_DRIVER_DUMP_SUPPORTED,
+ legacy_hal::WIFI_LOGGER_CONNECT_EVENT_SUPPORTED,
+ legacy_hal::WIFI_LOGGER_POWER_EVENT_SUPPORTED,
+ legacy_hal::WIFI_LOGGER_WAKE_LOCK_SUPPORTED}) {
+ if (feature & legacy_logger_feature_set) {
+ *hidl_caps |=
+ convertLegacyLoggerFeatureToHidlChipCapability(feature);
+ }
}
- }
- // There are no flags for these 3 in the legacy feature set. Adding them to
- // the set because all the current devices support it.
- *hidl_caps |= HidlChipCaps::DEBUG_RING_BUFFER_VENDOR_DATA;
- *hidl_caps |= HidlChipCaps::DEBUG_HOST_WAKE_REASON_STATS;
- *hidl_caps |= HidlChipCaps::DEBUG_ERROR_ALERTS;
- return true;
+ for (const auto feature : {WIFI_FEATURE_SET_TX_POWER_LIMIT,
+ WIFI_FEATURE_D2D_RTT, WIFI_FEATURE_D2AP_RTT}) {
+ if (feature & legacy_feature_set) {
+ *hidl_caps |= convertLegacyFeatureToHidlChipCapability(feature);
+ }
+ }
+ // There are no flags for these 3 in the legacy feature set. Adding them to
+ // the set because all the current devices support it.
+ *hidl_caps |= HidlChipCaps::DEBUG_RING_BUFFER_VENDOR_DATA;
+ *hidl_caps |= HidlChipCaps::DEBUG_HOST_WAKE_REASON_STATS;
+ *hidl_caps |= HidlChipCaps::DEBUG_ERROR_ALERTS;
+ return true;
}
WifiDebugRingBufferFlags convertLegacyDebugRingBufferFlagsToHidl(
uint32_t flag) {
- switch (flag) {
- case WIFI_RING_BUFFER_FLAG_HAS_BINARY_ENTRIES:
- return WifiDebugRingBufferFlags::HAS_BINARY_ENTRIES;
- case WIFI_RING_BUFFER_FLAG_HAS_ASCII_ENTRIES:
- return WifiDebugRingBufferFlags::HAS_ASCII_ENTRIES;
- };
- CHECK(false) << "Unknown legacy flag: " << flag;
- return {};
+ switch (flag) {
+ case WIFI_RING_BUFFER_FLAG_HAS_BINARY_ENTRIES:
+ return WifiDebugRingBufferFlags::HAS_BINARY_ENTRIES;
+ case WIFI_RING_BUFFER_FLAG_HAS_ASCII_ENTRIES:
+ return WifiDebugRingBufferFlags::HAS_ASCII_ENTRIES;
+ };
+ CHECK(false) << "Unknown legacy flag: " << flag;
+ return {};
}
bool convertLegacyDebugRingBufferStatusToHidl(
const legacy_hal::wifi_ring_buffer_status& legacy_status,
WifiDebugRingBufferStatus* hidl_status) {
- if (!hidl_status) {
- return false;
- }
- *hidl_status = {};
- hidl_status->ringName = safeConvertChar(reinterpret_cast<const char*>(legacy_status.name),
- sizeof(legacy_status.name));
- hidl_status->flags = 0;
- for (const auto flag : {WIFI_RING_BUFFER_FLAG_HAS_BINARY_ENTRIES,
- WIFI_RING_BUFFER_FLAG_HAS_ASCII_ENTRIES}) {
- if (flag & legacy_status.flags) {
- hidl_status->flags |=
- static_cast<std::underlying_type<WifiDebugRingBufferFlags>::type>(
- convertLegacyDebugRingBufferFlagsToHidl(flag));
+ if (!hidl_status) {
+ return false;
}
- }
- hidl_status->ringId = legacy_status.ring_id;
- hidl_status->sizeInBytes = legacy_status.ring_buffer_byte_size;
- // Calculate free size of the ring the buffer. We don't need to send the
- // exact read/write pointers that were there in the legacy HAL interface.
- if (legacy_status.written_bytes >= legacy_status.read_bytes) {
- hidl_status->freeSizeInBytes =
- legacy_status.ring_buffer_byte_size -
- (legacy_status.written_bytes - legacy_status.read_bytes);
- } else {
- hidl_status->freeSizeInBytes =
- legacy_status.read_bytes - legacy_status.written_bytes;
- }
- hidl_status->verboseLevel = legacy_status.verbose_level;
- return true;
+ *hidl_status = {};
+ hidl_status->ringName =
+ safeConvertChar(reinterpret_cast<const char*>(legacy_status.name),
+ sizeof(legacy_status.name));
+ hidl_status->flags = 0;
+ for (const auto flag : {WIFI_RING_BUFFER_FLAG_HAS_BINARY_ENTRIES,
+ WIFI_RING_BUFFER_FLAG_HAS_ASCII_ENTRIES}) {
+ if (flag & legacy_status.flags) {
+ hidl_status->flags |= static_cast<
+ std::underlying_type<WifiDebugRingBufferFlags>::type>(
+ convertLegacyDebugRingBufferFlagsToHidl(flag));
+ }
+ }
+ hidl_status->ringId = legacy_status.ring_id;
+ hidl_status->sizeInBytes = legacy_status.ring_buffer_byte_size;
+ // Calculate free size of the ring the buffer. We don't need to send the
+ // exact read/write pointers that were there in the legacy HAL interface.
+ if (legacy_status.written_bytes >= legacy_status.read_bytes) {
+ hidl_status->freeSizeInBytes =
+ legacy_status.ring_buffer_byte_size -
+ (legacy_status.written_bytes - legacy_status.read_bytes);
+ } else {
+ hidl_status->freeSizeInBytes =
+ legacy_status.read_bytes - legacy_status.written_bytes;
+ }
+ hidl_status->verboseLevel = legacy_status.verbose_level;
+ return true;
}
bool convertLegacyVectorOfDebugRingBufferStatusToHidl(
const std::vector<legacy_hal::wifi_ring_buffer_status>& legacy_status_vec,
std::vector<WifiDebugRingBufferStatus>* hidl_status_vec) {
- if (!hidl_status_vec) {
- return false;
- }
- *hidl_status_vec = {};
- for (const auto& legacy_status : legacy_status_vec) {
- WifiDebugRingBufferStatus hidl_status;
- if (!convertLegacyDebugRingBufferStatusToHidl(legacy_status,
- &hidl_status)) {
- return false;
+ if (!hidl_status_vec) {
+ return false;
}
- hidl_status_vec->push_back(hidl_status);
- }
- return true;
+ *hidl_status_vec = {};
+ for (const auto& legacy_status : legacy_status_vec) {
+ WifiDebugRingBufferStatus hidl_status;
+ if (!convertLegacyDebugRingBufferStatusToHidl(legacy_status,
+ &hidl_status)) {
+ return false;
+ }
+ hidl_status_vec->push_back(hidl_status);
+ }
+ return true;
}
bool convertLegacyWakeReasonStatsToHidl(
const legacy_hal::WakeReasonStats& legacy_stats,
WifiDebugHostWakeReasonStats* hidl_stats) {
- if (!hidl_stats) {
- return false;
- }
- *hidl_stats = {};
- hidl_stats->totalCmdEventWakeCnt =
- legacy_stats.wake_reason_cnt.total_cmd_event_wake;
- hidl_stats->cmdEventWakeCntPerType = legacy_stats.cmd_event_wake_cnt;
- hidl_stats->totalDriverFwLocalWakeCnt =
- legacy_stats.wake_reason_cnt.total_driver_fw_local_wake;
- hidl_stats->driverFwLocalWakeCntPerType =
- legacy_stats.driver_fw_local_wake_cnt;
- hidl_stats->totalRxPacketWakeCnt =
- legacy_stats.wake_reason_cnt.total_rx_data_wake;
- hidl_stats->rxPktWakeDetails.rxUnicastCnt =
- legacy_stats.wake_reason_cnt.rx_wake_details.rx_unicast_cnt;
- hidl_stats->rxPktWakeDetails.rxMulticastCnt =
- legacy_stats.wake_reason_cnt.rx_wake_details.rx_multicast_cnt;
- hidl_stats->rxPktWakeDetails.rxBroadcastCnt =
- legacy_stats.wake_reason_cnt.rx_wake_details.rx_broadcast_cnt;
- hidl_stats->rxMulticastPkWakeDetails.ipv4RxMulticastAddrCnt =
- legacy_stats.wake_reason_cnt.rx_multicast_wake_pkt_info
- .ipv4_rx_multicast_addr_cnt;
- hidl_stats->rxMulticastPkWakeDetails.ipv6RxMulticastAddrCnt =
- legacy_stats.wake_reason_cnt.rx_multicast_wake_pkt_info
- .ipv6_rx_multicast_addr_cnt;
- hidl_stats->rxMulticastPkWakeDetails.otherRxMulticastAddrCnt =
- legacy_stats.wake_reason_cnt.rx_multicast_wake_pkt_info
- .other_rx_multicast_addr_cnt;
- hidl_stats->rxIcmpPkWakeDetails.icmpPkt =
- legacy_stats.wake_reason_cnt.rx_wake_pkt_classification_info.icmp_pkt;
- hidl_stats->rxIcmpPkWakeDetails.icmp6Pkt =
- legacy_stats.wake_reason_cnt.rx_wake_pkt_classification_info.icmp6_pkt;
- hidl_stats->rxIcmpPkWakeDetails.icmp6Ra =
- legacy_stats.wake_reason_cnt.rx_wake_pkt_classification_info.icmp6_ra;
- hidl_stats->rxIcmpPkWakeDetails.icmp6Na =
- legacy_stats.wake_reason_cnt.rx_wake_pkt_classification_info.icmp6_na;
- hidl_stats->rxIcmpPkWakeDetails.icmp6Ns =
- legacy_stats.wake_reason_cnt.rx_wake_pkt_classification_info.icmp6_ns;
- return true;
+ if (!hidl_stats) {
+ return false;
+ }
+ *hidl_stats = {};
+ hidl_stats->totalCmdEventWakeCnt =
+ legacy_stats.wake_reason_cnt.total_cmd_event_wake;
+ hidl_stats->cmdEventWakeCntPerType = legacy_stats.cmd_event_wake_cnt;
+ hidl_stats->totalDriverFwLocalWakeCnt =
+ legacy_stats.wake_reason_cnt.total_driver_fw_local_wake;
+ hidl_stats->driverFwLocalWakeCntPerType =
+ legacy_stats.driver_fw_local_wake_cnt;
+ hidl_stats->totalRxPacketWakeCnt =
+ legacy_stats.wake_reason_cnt.total_rx_data_wake;
+ hidl_stats->rxPktWakeDetails.rxUnicastCnt =
+ legacy_stats.wake_reason_cnt.rx_wake_details.rx_unicast_cnt;
+ hidl_stats->rxPktWakeDetails.rxMulticastCnt =
+ legacy_stats.wake_reason_cnt.rx_wake_details.rx_multicast_cnt;
+ hidl_stats->rxPktWakeDetails.rxBroadcastCnt =
+ legacy_stats.wake_reason_cnt.rx_wake_details.rx_broadcast_cnt;
+ hidl_stats->rxMulticastPkWakeDetails.ipv4RxMulticastAddrCnt =
+ legacy_stats.wake_reason_cnt.rx_multicast_wake_pkt_info
+ .ipv4_rx_multicast_addr_cnt;
+ hidl_stats->rxMulticastPkWakeDetails.ipv6RxMulticastAddrCnt =
+ legacy_stats.wake_reason_cnt.rx_multicast_wake_pkt_info
+ .ipv6_rx_multicast_addr_cnt;
+ hidl_stats->rxMulticastPkWakeDetails.otherRxMulticastAddrCnt =
+ legacy_stats.wake_reason_cnt.rx_multicast_wake_pkt_info
+ .other_rx_multicast_addr_cnt;
+ hidl_stats->rxIcmpPkWakeDetails.icmpPkt =
+ legacy_stats.wake_reason_cnt.rx_wake_pkt_classification_info.icmp_pkt;
+ hidl_stats->rxIcmpPkWakeDetails.icmp6Pkt =
+ legacy_stats.wake_reason_cnt.rx_wake_pkt_classification_info.icmp6_pkt;
+ hidl_stats->rxIcmpPkWakeDetails.icmp6Ra =
+ legacy_stats.wake_reason_cnt.rx_wake_pkt_classification_info.icmp6_ra;
+ hidl_stats->rxIcmpPkWakeDetails.icmp6Na =
+ legacy_stats.wake_reason_cnt.rx_wake_pkt_classification_info.icmp6_na;
+ hidl_stats->rxIcmpPkWakeDetails.icmp6Ns =
+ legacy_stats.wake_reason_cnt.rx_wake_pkt_classification_info.icmp6_ns;
+ return true;
}
legacy_hal::wifi_power_scenario convertHidlTxPowerScenarioToLegacy(
V1_1::IWifiChip::TxPowerScenario hidl_scenario) {
- switch (hidl_scenario) {
- case V1_1::IWifiChip::TxPowerScenario::VOICE_CALL:
- return legacy_hal::WIFI_POWER_SCENARIO_VOICE_CALL;
- };
- CHECK(false);
+ switch (hidl_scenario) {
+ case V1_1::IWifiChip::TxPowerScenario::VOICE_CALL:
+ return legacy_hal::WIFI_POWER_SCENARIO_VOICE_CALL;
+ };
+ CHECK(false);
}
bool convertLegacyFeaturesToHidlStaCapabilities(
- uint32_t legacy_feature_set,
- uint32_t legacy_logger_feature_set,
+ uint32_t legacy_feature_set, uint32_t legacy_logger_feature_set,
uint32_t* hidl_caps) {
- if (!hidl_caps) {
- return false;
- }
- *hidl_caps = {};
- using HidlStaIfaceCaps = IWifiStaIface::StaIfaceCapabilityMask;
- for (const auto feature : {legacy_hal::WIFI_LOGGER_PACKET_FATE_SUPPORTED}) {
- if (feature & legacy_logger_feature_set) {
- *hidl_caps |= convertLegacyLoggerFeatureToHidlStaIfaceCapability(feature);
+ if (!hidl_caps) {
+ return false;
}
- }
- for (const auto feature : {WIFI_FEATURE_GSCAN,
- WIFI_FEATURE_LINK_LAYER_STATS,
- WIFI_FEATURE_RSSI_MONITOR,
- WIFI_FEATURE_CONTROL_ROAMING,
- WIFI_FEATURE_IE_WHITELIST,
- WIFI_FEATURE_SCAN_RAND,
- WIFI_FEATURE_INFRA_5G,
- WIFI_FEATURE_HOTSPOT,
- WIFI_FEATURE_PNO,
- WIFI_FEATURE_TDLS,
- WIFI_FEATURE_TDLS_OFFCHANNEL,
- WIFI_FEATURE_CONFIG_NDO,
- WIFI_FEATURE_MKEEP_ALIVE}) {
- if (feature & legacy_feature_set) {
- *hidl_caps |= convertLegacyFeatureToHidlStaIfaceCapability(feature);
+ *hidl_caps = {};
+ using HidlStaIfaceCaps = IWifiStaIface::StaIfaceCapabilityMask;
+ for (const auto feature : {legacy_hal::WIFI_LOGGER_PACKET_FATE_SUPPORTED}) {
+ if (feature & legacy_logger_feature_set) {
+ *hidl_caps |=
+ convertLegacyLoggerFeatureToHidlStaIfaceCapability(feature);
+ }
}
- }
- // There is no flag for this one in the legacy feature set. Adding it to the
- // set because all the current devices support it.
- *hidl_caps |= HidlStaIfaceCaps::APF;
- return true;
+ for (const auto feature :
+ {WIFI_FEATURE_GSCAN, WIFI_FEATURE_LINK_LAYER_STATS,
+ WIFI_FEATURE_RSSI_MONITOR, WIFI_FEATURE_CONTROL_ROAMING,
+ WIFI_FEATURE_IE_WHITELIST, WIFI_FEATURE_SCAN_RAND,
+ WIFI_FEATURE_INFRA_5G, WIFI_FEATURE_HOTSPOT, WIFI_FEATURE_PNO,
+ WIFI_FEATURE_TDLS, WIFI_FEATURE_TDLS_OFFCHANNEL,
+ WIFI_FEATURE_CONFIG_NDO, WIFI_FEATURE_MKEEP_ALIVE}) {
+ if (feature & legacy_feature_set) {
+ *hidl_caps |= convertLegacyFeatureToHidlStaIfaceCapability(feature);
+ }
+ }
+ // There is no flag for this one in the legacy feature set. Adding it to the
+ // set because all the current devices support it.
+ *hidl_caps |= HidlStaIfaceCaps::APF;
+ return true;
}
bool convertLegacyApfCapabilitiesToHidl(
const legacy_hal::PacketFilterCapabilities& legacy_caps,
StaApfPacketFilterCapabilities* hidl_caps) {
- if (!hidl_caps) {
- return false;
- }
- *hidl_caps = {};
- hidl_caps->version = legacy_caps.version;
- hidl_caps->maxLength = legacy_caps.max_len;
- return true;
+ if (!hidl_caps) {
+ return false;
+ }
+ *hidl_caps = {};
+ hidl_caps->version = legacy_caps.version;
+ hidl_caps->maxLength = legacy_caps.max_len;
+ return true;
}
uint8_t convertHidlGscanReportEventFlagToLegacy(
StaBackgroundScanBucketEventReportSchemeMask hidl_flag) {
- using HidlFlag = StaBackgroundScanBucketEventReportSchemeMask;
- switch (hidl_flag) {
- case HidlFlag::EACH_SCAN:
- return REPORT_EVENTS_EACH_SCAN;
- case HidlFlag::FULL_RESULTS:
- return REPORT_EVENTS_FULL_RESULTS;
- case HidlFlag::NO_BATCH:
- return REPORT_EVENTS_NO_BATCH;
- };
- CHECK(false);
+ using HidlFlag = StaBackgroundScanBucketEventReportSchemeMask;
+ switch (hidl_flag) {
+ case HidlFlag::EACH_SCAN:
+ return REPORT_EVENTS_EACH_SCAN;
+ case HidlFlag::FULL_RESULTS:
+ return REPORT_EVENTS_FULL_RESULTS;
+ case HidlFlag::NO_BATCH:
+ return REPORT_EVENTS_NO_BATCH;
+ };
+ CHECK(false);
}
StaScanDataFlagMask convertLegacyGscanDataFlagToHidl(uint8_t legacy_flag) {
- switch (legacy_flag) {
- case legacy_hal::WIFI_SCAN_FLAG_INTERRUPTED:
- return StaScanDataFlagMask::INTERRUPTED;
- };
- CHECK(false) << "Unknown legacy flag: " << legacy_flag;
- // To silence the compiler warning about reaching the end of non-void
- // function.
- return {};
+ switch (legacy_flag) {
+ case legacy_hal::WIFI_SCAN_FLAG_INTERRUPTED:
+ return StaScanDataFlagMask::INTERRUPTED;
+ };
+ CHECK(false) << "Unknown legacy flag: " << legacy_flag;
+ // To silence the compiler warning about reaching the end of non-void
+ // function.
+ return {};
}
bool convertLegacyGscanCapabilitiesToHidl(
const legacy_hal::wifi_gscan_capabilities& legacy_caps,
StaBackgroundScanCapabilities* hidl_caps) {
- if (!hidl_caps) {
- return false;
- }
- *hidl_caps = {};
- hidl_caps->maxCacheSize = legacy_caps.max_scan_cache_size;
- hidl_caps->maxBuckets = legacy_caps.max_scan_buckets;
- hidl_caps->maxApCachePerScan = legacy_caps.max_ap_cache_per_scan;
- hidl_caps->maxReportingThreshold = legacy_caps.max_scan_reporting_threshold;
- return true;
+ if (!hidl_caps) {
+ return false;
+ }
+ *hidl_caps = {};
+ hidl_caps->maxCacheSize = legacy_caps.max_scan_cache_size;
+ hidl_caps->maxBuckets = legacy_caps.max_scan_buckets;
+ hidl_caps->maxApCachePerScan = legacy_caps.max_ap_cache_per_scan;
+ hidl_caps->maxReportingThreshold = legacy_caps.max_scan_reporting_threshold;
+ return true;
}
legacy_hal::wifi_band convertHidlWifiBandToLegacy(WifiBand band) {
- switch (band) {
- case WifiBand::BAND_UNSPECIFIED:
- return legacy_hal::WIFI_BAND_UNSPECIFIED;
- case WifiBand::BAND_24GHZ:
- return legacy_hal::WIFI_BAND_BG;
- case WifiBand::BAND_5GHZ:
- return legacy_hal::WIFI_BAND_A;
- case WifiBand::BAND_5GHZ_DFS:
- return legacy_hal::WIFI_BAND_A_DFS;
- case WifiBand::BAND_5GHZ_WITH_DFS:
- return legacy_hal::WIFI_BAND_A_WITH_DFS;
- case WifiBand::BAND_24GHZ_5GHZ:
- return legacy_hal::WIFI_BAND_ABG;
- case WifiBand::BAND_24GHZ_5GHZ_WITH_DFS:
- return legacy_hal::WIFI_BAND_ABG_WITH_DFS;
- };
- CHECK(false);
+ switch (band) {
+ case WifiBand::BAND_UNSPECIFIED:
+ return legacy_hal::WIFI_BAND_UNSPECIFIED;
+ case WifiBand::BAND_24GHZ:
+ return legacy_hal::WIFI_BAND_BG;
+ case WifiBand::BAND_5GHZ:
+ return legacy_hal::WIFI_BAND_A;
+ case WifiBand::BAND_5GHZ_DFS:
+ return legacy_hal::WIFI_BAND_A_DFS;
+ case WifiBand::BAND_5GHZ_WITH_DFS:
+ return legacy_hal::WIFI_BAND_A_WITH_DFS;
+ case WifiBand::BAND_24GHZ_5GHZ:
+ return legacy_hal::WIFI_BAND_ABG;
+ case WifiBand::BAND_24GHZ_5GHZ_WITH_DFS:
+ return legacy_hal::WIFI_BAND_ABG_WITH_DFS;
+ };
+ CHECK(false);
}
bool convertHidlGscanParamsToLegacy(
const StaBackgroundScanParameters& hidl_scan_params,
legacy_hal::wifi_scan_cmd_params* legacy_scan_params) {
- if (!legacy_scan_params) {
- return false;
- }
- *legacy_scan_params = {};
- legacy_scan_params->base_period = hidl_scan_params.basePeriodInMs;
- legacy_scan_params->max_ap_per_scan = hidl_scan_params.maxApPerScan;
- legacy_scan_params->report_threshold_percent =
- hidl_scan_params.reportThresholdPercent;
- legacy_scan_params->report_threshold_num_scans =
- hidl_scan_params.reportThresholdNumScans;
- if (hidl_scan_params.buckets.size() > MAX_BUCKETS) {
- return false;
- }
- legacy_scan_params->num_buckets = hidl_scan_params.buckets.size();
- for (uint32_t bucket_idx = 0; bucket_idx < hidl_scan_params.buckets.size();
- bucket_idx++) {
- const StaBackgroundScanBucketParameters& hidl_bucket_spec =
- hidl_scan_params.buckets[bucket_idx];
- legacy_hal::wifi_scan_bucket_spec& legacy_bucket_spec =
- legacy_scan_params->buckets[bucket_idx];
- if (hidl_bucket_spec.bucketIdx >= MAX_BUCKETS) {
- return false;
+ if (!legacy_scan_params) {
+ return false;
}
- legacy_bucket_spec.bucket = hidl_bucket_spec.bucketIdx;
- legacy_bucket_spec.band =
- convertHidlWifiBandToLegacy(hidl_bucket_spec.band);
- legacy_bucket_spec.period = hidl_bucket_spec.periodInMs;
- legacy_bucket_spec.max_period = hidl_bucket_spec.exponentialMaxPeriodInMs;
- legacy_bucket_spec.base = hidl_bucket_spec.exponentialBase;
- legacy_bucket_spec.step_count = hidl_bucket_spec.exponentialStepCount;
- legacy_bucket_spec.report_events = 0;
- using HidlFlag = StaBackgroundScanBucketEventReportSchemeMask;
- for (const auto flag :
- {HidlFlag::EACH_SCAN, HidlFlag::FULL_RESULTS, HidlFlag::NO_BATCH}) {
- if (hidl_bucket_spec.eventReportScheme &
- static_cast<std::underlying_type<HidlFlag>::type>(flag)) {
- legacy_bucket_spec.report_events |=
- convertHidlGscanReportEventFlagToLegacy(flag);
- }
+ *legacy_scan_params = {};
+ legacy_scan_params->base_period = hidl_scan_params.basePeriodInMs;
+ legacy_scan_params->max_ap_per_scan = hidl_scan_params.maxApPerScan;
+ legacy_scan_params->report_threshold_percent =
+ hidl_scan_params.reportThresholdPercent;
+ legacy_scan_params->report_threshold_num_scans =
+ hidl_scan_params.reportThresholdNumScans;
+ if (hidl_scan_params.buckets.size() > MAX_BUCKETS) {
+ return false;
}
- if (hidl_bucket_spec.frequencies.size() > MAX_CHANNELS) {
- return false;
+ legacy_scan_params->num_buckets = hidl_scan_params.buckets.size();
+ for (uint32_t bucket_idx = 0; bucket_idx < hidl_scan_params.buckets.size();
+ bucket_idx++) {
+ const StaBackgroundScanBucketParameters& hidl_bucket_spec =
+ hidl_scan_params.buckets[bucket_idx];
+ legacy_hal::wifi_scan_bucket_spec& legacy_bucket_spec =
+ legacy_scan_params->buckets[bucket_idx];
+ if (hidl_bucket_spec.bucketIdx >= MAX_BUCKETS) {
+ return false;
+ }
+ legacy_bucket_spec.bucket = hidl_bucket_spec.bucketIdx;
+ legacy_bucket_spec.band =
+ convertHidlWifiBandToLegacy(hidl_bucket_spec.band);
+ legacy_bucket_spec.period = hidl_bucket_spec.periodInMs;
+ legacy_bucket_spec.max_period =
+ hidl_bucket_spec.exponentialMaxPeriodInMs;
+ legacy_bucket_spec.base = hidl_bucket_spec.exponentialBase;
+ legacy_bucket_spec.step_count = hidl_bucket_spec.exponentialStepCount;
+ legacy_bucket_spec.report_events = 0;
+ using HidlFlag = StaBackgroundScanBucketEventReportSchemeMask;
+ for (const auto flag : {HidlFlag::EACH_SCAN, HidlFlag::FULL_RESULTS,
+ HidlFlag::NO_BATCH}) {
+ if (hidl_bucket_spec.eventReportScheme &
+ static_cast<std::underlying_type<HidlFlag>::type>(flag)) {
+ legacy_bucket_spec.report_events |=
+ convertHidlGscanReportEventFlagToLegacy(flag);
+ }
+ }
+ if (hidl_bucket_spec.frequencies.size() > MAX_CHANNELS) {
+ return false;
+ }
+ legacy_bucket_spec.num_channels = hidl_bucket_spec.frequencies.size();
+ for (uint32_t freq_idx = 0;
+ freq_idx < hidl_bucket_spec.frequencies.size(); freq_idx++) {
+ legacy_bucket_spec.channels[freq_idx].channel =
+ hidl_bucket_spec.frequencies[freq_idx];
+ }
}
- legacy_bucket_spec.num_channels = hidl_bucket_spec.frequencies.size();
- for (uint32_t freq_idx = 0; freq_idx < hidl_bucket_spec.frequencies.size();
- freq_idx++) {
- legacy_bucket_spec.channels[freq_idx].channel =
- hidl_bucket_spec.frequencies[freq_idx];
- }
- }
- return true;
+ return true;
}
bool convertLegacyIeToHidl(
const legacy_hal::wifi_information_element& legacy_ie,
WifiInformationElement* hidl_ie) {
- if (!hidl_ie) {
- return false;
- }
- *hidl_ie = {};
- hidl_ie->id = legacy_ie.id;
- hidl_ie->data =
- std::vector<uint8_t>(legacy_ie.data, legacy_ie.data + legacy_ie.len);
- return true;
+ if (!hidl_ie) {
+ return false;
+ }
+ *hidl_ie = {};
+ hidl_ie->id = legacy_ie.id;
+ hidl_ie->data =
+ std::vector<uint8_t>(legacy_ie.data, legacy_ie.data + legacy_ie.len);
+ return true;
}
-bool convertLegacyIeBlobToHidl(const uint8_t* ie_blob,
- uint32_t ie_blob_len,
+bool convertLegacyIeBlobToHidl(const uint8_t* ie_blob, uint32_t ie_blob_len,
std::vector<WifiInformationElement>* hidl_ies) {
- if (!ie_blob || !hidl_ies) {
- return false;
- }
- *hidl_ies = {};
- const uint8_t* ies_begin = ie_blob;
- const uint8_t* ies_end = ie_blob + ie_blob_len;
- const uint8_t* next_ie = ies_begin;
- using wifi_ie = legacy_hal::wifi_information_element;
- constexpr size_t kIeHeaderLen = sizeof(wifi_ie);
- // Each IE should atleast have the header (i.e |id| & |len| fields).
- while (next_ie + kIeHeaderLen <= ies_end) {
- const wifi_ie& legacy_ie = (*reinterpret_cast<const wifi_ie*>(next_ie));
- uint32_t curr_ie_len = kIeHeaderLen + legacy_ie.len;
- if (next_ie + curr_ie_len > ies_end) {
- LOG(ERROR) << "Error parsing IE blob. Next IE: " << (void *)next_ie
- << ", Curr IE len: " << curr_ie_len << ", IEs End: " << (void *)ies_end;
- break;
+ if (!ie_blob || !hidl_ies) {
+ return false;
}
- WifiInformationElement hidl_ie;
- if (!convertLegacyIeToHidl(legacy_ie, &hidl_ie)) {
- LOG(ERROR) << "Error converting IE. Id: " << legacy_ie.id
- << ", len: " << legacy_ie.len;
- break;
+ *hidl_ies = {};
+ const uint8_t* ies_begin = ie_blob;
+ const uint8_t* ies_end = ie_blob + ie_blob_len;
+ const uint8_t* next_ie = ies_begin;
+ using wifi_ie = legacy_hal::wifi_information_element;
+ constexpr size_t kIeHeaderLen = sizeof(wifi_ie);
+ // Each IE should atleast have the header (i.e |id| & |len| fields).
+ while (next_ie + kIeHeaderLen <= ies_end) {
+ const wifi_ie& legacy_ie = (*reinterpret_cast<const wifi_ie*>(next_ie));
+ uint32_t curr_ie_len = kIeHeaderLen + legacy_ie.len;
+ if (next_ie + curr_ie_len > ies_end) {
+ LOG(ERROR) << "Error parsing IE blob. Next IE: " << (void*)next_ie
+ << ", Curr IE len: " << curr_ie_len
+ << ", IEs End: " << (void*)ies_end;
+ break;
+ }
+ WifiInformationElement hidl_ie;
+ if (!convertLegacyIeToHidl(legacy_ie, &hidl_ie)) {
+ LOG(ERROR) << "Error converting IE. Id: " << legacy_ie.id
+ << ", len: " << legacy_ie.len;
+ break;
+ }
+ hidl_ies->push_back(std::move(hidl_ie));
+ next_ie += curr_ie_len;
}
- hidl_ies->push_back(std::move(hidl_ie));
- next_ie += curr_ie_len;
- }
- // Check if the blob has been fully consumed.
- if (next_ie != ies_end) {
- LOG(ERROR) << "Failed to fully parse IE blob. Next IE: " << (void *)next_ie
- << ", IEs End: " << (void *)ies_end;
- }
- return true;
+ // Check if the blob has been fully consumed.
+ if (next_ie != ies_end) {
+ LOG(ERROR) << "Failed to fully parse IE blob. Next IE: "
+ << (void*)next_ie << ", IEs End: " << (void*)ies_end;
+ }
+ return true;
}
bool convertLegacyGscanResultToHidl(
- const legacy_hal::wifi_scan_result& legacy_scan_result,
- bool has_ie_data,
+ const legacy_hal::wifi_scan_result& legacy_scan_result, bool has_ie_data,
StaScanResult* hidl_scan_result) {
- if (!hidl_scan_result) {
- return false;
- }
- *hidl_scan_result = {};
- hidl_scan_result->timeStampInUs = legacy_scan_result.ts;
- hidl_scan_result->ssid = std::vector<uint8_t>(
- legacy_scan_result.ssid,
- legacy_scan_result.ssid + strnlen(legacy_scan_result.ssid,
- sizeof(legacy_scan_result.ssid) - 1));
- memcpy(hidl_scan_result->bssid.data(),
- legacy_scan_result.bssid,
- hidl_scan_result->bssid.size());
- hidl_scan_result->frequency = legacy_scan_result.channel;
- hidl_scan_result->rssi = legacy_scan_result.rssi;
- hidl_scan_result->beaconPeriodInMs = legacy_scan_result.beacon_period;
- hidl_scan_result->capability = legacy_scan_result.capability;
- if (has_ie_data) {
- std::vector<WifiInformationElement> ies;
- if (!convertLegacyIeBlobToHidl(
- reinterpret_cast<const uint8_t*>(legacy_scan_result.ie_data),
- legacy_scan_result.ie_length,
- &ies)) {
- return false;
+ if (!hidl_scan_result) {
+ return false;
}
- hidl_scan_result->informationElements = std::move(ies);
- }
- return true;
+ *hidl_scan_result = {};
+ hidl_scan_result->timeStampInUs = legacy_scan_result.ts;
+ hidl_scan_result->ssid = std::vector<uint8_t>(
+ legacy_scan_result.ssid,
+ legacy_scan_result.ssid + strnlen(legacy_scan_result.ssid,
+ sizeof(legacy_scan_result.ssid) - 1));
+ memcpy(hidl_scan_result->bssid.data(), legacy_scan_result.bssid,
+ hidl_scan_result->bssid.size());
+ hidl_scan_result->frequency = legacy_scan_result.channel;
+ hidl_scan_result->rssi = legacy_scan_result.rssi;
+ hidl_scan_result->beaconPeriodInMs = legacy_scan_result.beacon_period;
+ hidl_scan_result->capability = legacy_scan_result.capability;
+ if (has_ie_data) {
+ std::vector<WifiInformationElement> ies;
+ if (!convertLegacyIeBlobToHidl(
+ reinterpret_cast<const uint8_t*>(legacy_scan_result.ie_data),
+ legacy_scan_result.ie_length, &ies)) {
+ return false;
+ }
+ hidl_scan_result->informationElements = std::move(ies);
+ }
+ return true;
}
bool convertLegacyCachedGscanResultsToHidl(
const legacy_hal::wifi_cached_scan_results& legacy_cached_scan_result,
StaScanData* hidl_scan_data) {
- if (!hidl_scan_data) {
- return false;
- }
- *hidl_scan_data = {};
- hidl_scan_data->flags = 0;
- for (const auto flag : {legacy_hal::WIFI_SCAN_FLAG_INTERRUPTED}) {
- if (legacy_cached_scan_result.flags & flag) {
- hidl_scan_data->flags |=
- static_cast<std::underlying_type<StaScanDataFlagMask>::type>(
- convertLegacyGscanDataFlagToHidl(flag));
+ if (!hidl_scan_data) {
+ return false;
}
- }
- hidl_scan_data->bucketsScanned = legacy_cached_scan_result.buckets_scanned;
+ *hidl_scan_data = {};
+ hidl_scan_data->flags = 0;
+ for (const auto flag : {legacy_hal::WIFI_SCAN_FLAG_INTERRUPTED}) {
+ if (legacy_cached_scan_result.flags & flag) {
+ hidl_scan_data->flags |=
+ static_cast<std::underlying_type<StaScanDataFlagMask>::type>(
+ convertLegacyGscanDataFlagToHidl(flag));
+ }
+ }
+ hidl_scan_data->bucketsScanned = legacy_cached_scan_result.buckets_scanned;
- CHECK(legacy_cached_scan_result.num_results >= 0 &&
- legacy_cached_scan_result.num_results <= MAX_AP_CACHE_PER_SCAN);
- std::vector<StaScanResult> hidl_scan_results;
- for (int32_t result_idx = 0;
- result_idx < legacy_cached_scan_result.num_results;
- result_idx++) {
- StaScanResult hidl_scan_result;
- if (!convertLegacyGscanResultToHidl(
- legacy_cached_scan_result.results[result_idx],
- false,
- &hidl_scan_result)) {
- return false;
+ CHECK(legacy_cached_scan_result.num_results >= 0 &&
+ legacy_cached_scan_result.num_results <= MAX_AP_CACHE_PER_SCAN);
+ std::vector<StaScanResult> hidl_scan_results;
+ for (int32_t result_idx = 0;
+ result_idx < legacy_cached_scan_result.num_results; result_idx++) {
+ StaScanResult hidl_scan_result;
+ if (!convertLegacyGscanResultToHidl(
+ legacy_cached_scan_result.results[result_idx], false,
+ &hidl_scan_result)) {
+ return false;
+ }
+ hidl_scan_results.push_back(hidl_scan_result);
}
- hidl_scan_results.push_back(hidl_scan_result);
- }
- hidl_scan_data->results = std::move(hidl_scan_results);
- return true;
+ hidl_scan_data->results = std::move(hidl_scan_results);
+ return true;
}
bool convertLegacyVectorOfCachedGscanResultsToHidl(
const std::vector<legacy_hal::wifi_cached_scan_results>&
legacy_cached_scan_results,
std::vector<StaScanData>* hidl_scan_datas) {
- if (!hidl_scan_datas) {
- return false;
- }
- *hidl_scan_datas = {};
- for (const auto& legacy_cached_scan_result : legacy_cached_scan_results) {
- StaScanData hidl_scan_data;
- if (!convertLegacyCachedGscanResultsToHidl(legacy_cached_scan_result,
- &hidl_scan_data)) {
- return false;
+ if (!hidl_scan_datas) {
+ return false;
}
- hidl_scan_datas->push_back(hidl_scan_data);
- }
- return true;
+ *hidl_scan_datas = {};
+ for (const auto& legacy_cached_scan_result : legacy_cached_scan_results) {
+ StaScanData hidl_scan_data;
+ if (!convertLegacyCachedGscanResultsToHidl(legacy_cached_scan_result,
+ &hidl_scan_data)) {
+ return false;
+ }
+ hidl_scan_datas->push_back(hidl_scan_data);
+ }
+ return true;
}
WifiDebugTxPacketFate convertLegacyDebugTxPacketFateToHidl(
legacy_hal::wifi_tx_packet_fate fate) {
- switch (fate) {
- case legacy_hal::TX_PKT_FATE_ACKED:
- return WifiDebugTxPacketFate::ACKED;
- case legacy_hal::TX_PKT_FATE_SENT:
- return WifiDebugTxPacketFate::SENT;
- case legacy_hal::TX_PKT_FATE_FW_QUEUED:
- return WifiDebugTxPacketFate::FW_QUEUED;
- case legacy_hal::TX_PKT_FATE_FW_DROP_INVALID:
- return WifiDebugTxPacketFate::FW_DROP_INVALID;
- case legacy_hal::TX_PKT_FATE_FW_DROP_NOBUFS:
- return WifiDebugTxPacketFate::FW_DROP_NOBUFS;
- case legacy_hal::TX_PKT_FATE_FW_DROP_OTHER:
- return WifiDebugTxPacketFate::FW_DROP_OTHER;
- case legacy_hal::TX_PKT_FATE_DRV_QUEUED:
- return WifiDebugTxPacketFate::DRV_QUEUED;
- case legacy_hal::TX_PKT_FATE_DRV_DROP_INVALID:
- return WifiDebugTxPacketFate::DRV_DROP_INVALID;
- case legacy_hal::TX_PKT_FATE_DRV_DROP_NOBUFS:
- return WifiDebugTxPacketFate::DRV_DROP_NOBUFS;
- case legacy_hal::TX_PKT_FATE_DRV_DROP_OTHER:
- return WifiDebugTxPacketFate::DRV_DROP_OTHER;
- };
- CHECK(false) << "Unknown legacy fate type: " << fate;
+ switch (fate) {
+ case legacy_hal::TX_PKT_FATE_ACKED:
+ return WifiDebugTxPacketFate::ACKED;
+ case legacy_hal::TX_PKT_FATE_SENT:
+ return WifiDebugTxPacketFate::SENT;
+ case legacy_hal::TX_PKT_FATE_FW_QUEUED:
+ return WifiDebugTxPacketFate::FW_QUEUED;
+ case legacy_hal::TX_PKT_FATE_FW_DROP_INVALID:
+ return WifiDebugTxPacketFate::FW_DROP_INVALID;
+ case legacy_hal::TX_PKT_FATE_FW_DROP_NOBUFS:
+ return WifiDebugTxPacketFate::FW_DROP_NOBUFS;
+ case legacy_hal::TX_PKT_FATE_FW_DROP_OTHER:
+ return WifiDebugTxPacketFate::FW_DROP_OTHER;
+ case legacy_hal::TX_PKT_FATE_DRV_QUEUED:
+ return WifiDebugTxPacketFate::DRV_QUEUED;
+ case legacy_hal::TX_PKT_FATE_DRV_DROP_INVALID:
+ return WifiDebugTxPacketFate::DRV_DROP_INVALID;
+ case legacy_hal::TX_PKT_FATE_DRV_DROP_NOBUFS:
+ return WifiDebugTxPacketFate::DRV_DROP_NOBUFS;
+ case legacy_hal::TX_PKT_FATE_DRV_DROP_OTHER:
+ return WifiDebugTxPacketFate::DRV_DROP_OTHER;
+ };
+ CHECK(false) << "Unknown legacy fate type: " << fate;
}
WifiDebugRxPacketFate convertLegacyDebugRxPacketFateToHidl(
legacy_hal::wifi_rx_packet_fate fate) {
- switch (fate) {
- case legacy_hal::RX_PKT_FATE_SUCCESS:
- return WifiDebugRxPacketFate::SUCCESS;
- case legacy_hal::RX_PKT_FATE_FW_QUEUED:
- return WifiDebugRxPacketFate::FW_QUEUED;
- case legacy_hal::RX_PKT_FATE_FW_DROP_FILTER:
- return WifiDebugRxPacketFate::FW_DROP_FILTER;
- case legacy_hal::RX_PKT_FATE_FW_DROP_INVALID:
- return WifiDebugRxPacketFate::FW_DROP_INVALID;
- case legacy_hal::RX_PKT_FATE_FW_DROP_NOBUFS:
- return WifiDebugRxPacketFate::FW_DROP_NOBUFS;
- case legacy_hal::RX_PKT_FATE_FW_DROP_OTHER:
- return WifiDebugRxPacketFate::FW_DROP_OTHER;
- case legacy_hal::RX_PKT_FATE_DRV_QUEUED:
- return WifiDebugRxPacketFate::DRV_QUEUED;
- case legacy_hal::RX_PKT_FATE_DRV_DROP_FILTER:
- return WifiDebugRxPacketFate::DRV_DROP_FILTER;
- case legacy_hal::RX_PKT_FATE_DRV_DROP_INVALID:
- return WifiDebugRxPacketFate::DRV_DROP_INVALID;
- case legacy_hal::RX_PKT_FATE_DRV_DROP_NOBUFS:
- return WifiDebugRxPacketFate::DRV_DROP_NOBUFS;
- case legacy_hal::RX_PKT_FATE_DRV_DROP_OTHER:
- return WifiDebugRxPacketFate::DRV_DROP_OTHER;
- };
- CHECK(false) << "Unknown legacy fate type: " << fate;
+ switch (fate) {
+ case legacy_hal::RX_PKT_FATE_SUCCESS:
+ return WifiDebugRxPacketFate::SUCCESS;
+ case legacy_hal::RX_PKT_FATE_FW_QUEUED:
+ return WifiDebugRxPacketFate::FW_QUEUED;
+ case legacy_hal::RX_PKT_FATE_FW_DROP_FILTER:
+ return WifiDebugRxPacketFate::FW_DROP_FILTER;
+ case legacy_hal::RX_PKT_FATE_FW_DROP_INVALID:
+ return WifiDebugRxPacketFate::FW_DROP_INVALID;
+ case legacy_hal::RX_PKT_FATE_FW_DROP_NOBUFS:
+ return WifiDebugRxPacketFate::FW_DROP_NOBUFS;
+ case legacy_hal::RX_PKT_FATE_FW_DROP_OTHER:
+ return WifiDebugRxPacketFate::FW_DROP_OTHER;
+ case legacy_hal::RX_PKT_FATE_DRV_QUEUED:
+ return WifiDebugRxPacketFate::DRV_QUEUED;
+ case legacy_hal::RX_PKT_FATE_DRV_DROP_FILTER:
+ return WifiDebugRxPacketFate::DRV_DROP_FILTER;
+ case legacy_hal::RX_PKT_FATE_DRV_DROP_INVALID:
+ return WifiDebugRxPacketFate::DRV_DROP_INVALID;
+ case legacy_hal::RX_PKT_FATE_DRV_DROP_NOBUFS:
+ return WifiDebugRxPacketFate::DRV_DROP_NOBUFS;
+ case legacy_hal::RX_PKT_FATE_DRV_DROP_OTHER:
+ return WifiDebugRxPacketFate::DRV_DROP_OTHER;
+ };
+ CHECK(false) << "Unknown legacy fate type: " << fate;
}
WifiDebugPacketFateFrameType convertLegacyDebugPacketFateFrameTypeToHidl(
legacy_hal::frame_type type) {
- switch (type) {
- case legacy_hal::FRAME_TYPE_UNKNOWN:
- return WifiDebugPacketFateFrameType::UNKNOWN;
- case legacy_hal::FRAME_TYPE_ETHERNET_II:
- return WifiDebugPacketFateFrameType::ETHERNET_II;
- case legacy_hal::FRAME_TYPE_80211_MGMT:
- return WifiDebugPacketFateFrameType::MGMT_80211;
- };
- CHECK(false) << "Unknown legacy frame type: " << type;
+ switch (type) {
+ case legacy_hal::FRAME_TYPE_UNKNOWN:
+ return WifiDebugPacketFateFrameType::UNKNOWN;
+ case legacy_hal::FRAME_TYPE_ETHERNET_II:
+ return WifiDebugPacketFateFrameType::ETHERNET_II;
+ case legacy_hal::FRAME_TYPE_80211_MGMT:
+ return WifiDebugPacketFateFrameType::MGMT_80211;
+ };
+ CHECK(false) << "Unknown legacy frame type: " << type;
}
bool convertLegacyDebugPacketFateFrameToHidl(
const legacy_hal::frame_info& legacy_frame,
WifiDebugPacketFateFrameInfo* hidl_frame) {
- if (!hidl_frame) {
- return false;
- }
- *hidl_frame = {};
- hidl_frame->frameType =
- convertLegacyDebugPacketFateFrameTypeToHidl(legacy_frame.payload_type);
- hidl_frame->frameLen = legacy_frame.frame_len;
- hidl_frame->driverTimestampUsec = legacy_frame.driver_timestamp_usec;
- hidl_frame->firmwareTimestampUsec = legacy_frame.firmware_timestamp_usec;
- const uint8_t* frame_begin = reinterpret_cast<const uint8_t*>(
- legacy_frame.frame_content.ethernet_ii_bytes);
- hidl_frame->frameContent =
- std::vector<uint8_t>(frame_begin, frame_begin + legacy_frame.frame_len);
- return true;
+ if (!hidl_frame) {
+ return false;
+ }
+ *hidl_frame = {};
+ hidl_frame->frameType =
+ convertLegacyDebugPacketFateFrameTypeToHidl(legacy_frame.payload_type);
+ hidl_frame->frameLen = legacy_frame.frame_len;
+ hidl_frame->driverTimestampUsec = legacy_frame.driver_timestamp_usec;
+ hidl_frame->firmwareTimestampUsec = legacy_frame.firmware_timestamp_usec;
+ const uint8_t* frame_begin = reinterpret_cast<const uint8_t*>(
+ legacy_frame.frame_content.ethernet_ii_bytes);
+ hidl_frame->frameContent =
+ std::vector<uint8_t>(frame_begin, frame_begin + legacy_frame.frame_len);
+ return true;
}
bool convertLegacyDebugTxPacketFateToHidl(
const legacy_hal::wifi_tx_report& legacy_fate,
WifiDebugTxPacketFateReport* hidl_fate) {
- if (!hidl_fate) {
- return false;
- }
- *hidl_fate = {};
- hidl_fate->fate = convertLegacyDebugTxPacketFateToHidl(legacy_fate.fate);
- return convertLegacyDebugPacketFateFrameToHidl(legacy_fate.frame_inf,
- &hidl_fate->frameInfo);
+ if (!hidl_fate) {
+ return false;
+ }
+ *hidl_fate = {};
+ hidl_fate->fate = convertLegacyDebugTxPacketFateToHidl(legacy_fate.fate);
+ return convertLegacyDebugPacketFateFrameToHidl(legacy_fate.frame_inf,
+ &hidl_fate->frameInfo);
}
bool convertLegacyVectorOfDebugTxPacketFateToHidl(
const std::vector<legacy_hal::wifi_tx_report>& legacy_fates,
std::vector<WifiDebugTxPacketFateReport>* hidl_fates) {
- if (!hidl_fates) {
- return false;
- }
- *hidl_fates = {};
- for (const auto& legacy_fate : legacy_fates) {
- WifiDebugTxPacketFateReport hidl_fate;
- if (!convertLegacyDebugTxPacketFateToHidl(legacy_fate, &hidl_fate)) {
- return false;
+ if (!hidl_fates) {
+ return false;
}
- hidl_fates->push_back(hidl_fate);
- }
- return true;
+ *hidl_fates = {};
+ for (const auto& legacy_fate : legacy_fates) {
+ WifiDebugTxPacketFateReport hidl_fate;
+ if (!convertLegacyDebugTxPacketFateToHidl(legacy_fate, &hidl_fate)) {
+ return false;
+ }
+ hidl_fates->push_back(hidl_fate);
+ }
+ return true;
}
bool convertLegacyDebugRxPacketFateToHidl(
const legacy_hal::wifi_rx_report& legacy_fate,
WifiDebugRxPacketFateReport* hidl_fate) {
- if (!hidl_fate) {
- return false;
- }
- *hidl_fate = {};
- hidl_fate->fate = convertLegacyDebugRxPacketFateToHidl(legacy_fate.fate);
- return convertLegacyDebugPacketFateFrameToHidl(legacy_fate.frame_inf,
- &hidl_fate->frameInfo);
+ if (!hidl_fate) {
+ return false;
+ }
+ *hidl_fate = {};
+ hidl_fate->fate = convertLegacyDebugRxPacketFateToHidl(legacy_fate.fate);
+ return convertLegacyDebugPacketFateFrameToHidl(legacy_fate.frame_inf,
+ &hidl_fate->frameInfo);
}
bool convertLegacyVectorOfDebugRxPacketFateToHidl(
const std::vector<legacy_hal::wifi_rx_report>& legacy_fates,
std::vector<WifiDebugRxPacketFateReport>* hidl_fates) {
- if (!hidl_fates) {
- return false;
- }
- *hidl_fates = {};
- for (const auto& legacy_fate : legacy_fates) {
- WifiDebugRxPacketFateReport hidl_fate;
- if (!convertLegacyDebugRxPacketFateToHidl(legacy_fate, &hidl_fate)) {
- return false;
+ if (!hidl_fates) {
+ return false;
}
- hidl_fates->push_back(hidl_fate);
- }
- return true;
+ *hidl_fates = {};
+ for (const auto& legacy_fate : legacy_fates) {
+ WifiDebugRxPacketFateReport hidl_fate;
+ if (!convertLegacyDebugRxPacketFateToHidl(legacy_fate, &hidl_fate)) {
+ return false;
+ }
+ hidl_fates->push_back(hidl_fate);
+ }
+ return true;
}
bool convertLegacyLinkLayerStatsToHidl(
const legacy_hal::LinkLayerStats& legacy_stats,
StaLinkLayerStats* hidl_stats) {
- if (!hidl_stats) {
- return false;
- }
- *hidl_stats = {};
- // iface legacy_stats conversion.
- hidl_stats->iface.beaconRx = legacy_stats.iface.beacon_rx;
- hidl_stats->iface.avgRssiMgmt = legacy_stats.iface.rssi_mgmt;
- hidl_stats->iface.wmeBePktStats.rxMpdu =
- legacy_stats.iface.ac[legacy_hal::WIFI_AC_BE].rx_mpdu;
- hidl_stats->iface.wmeBePktStats.txMpdu =
- legacy_stats.iface.ac[legacy_hal::WIFI_AC_BE].tx_mpdu;
- hidl_stats->iface.wmeBePktStats.lostMpdu =
- legacy_stats.iface.ac[legacy_hal::WIFI_AC_BE].mpdu_lost;
- hidl_stats->iface.wmeBePktStats.retries =
- legacy_stats.iface.ac[legacy_hal::WIFI_AC_BE].retries;
- hidl_stats->iface.wmeBkPktStats.rxMpdu =
- legacy_stats.iface.ac[legacy_hal::WIFI_AC_BK].rx_mpdu;
- hidl_stats->iface.wmeBkPktStats.txMpdu =
- legacy_stats.iface.ac[legacy_hal::WIFI_AC_BK].tx_mpdu;
- hidl_stats->iface.wmeBkPktStats.lostMpdu =
- legacy_stats.iface.ac[legacy_hal::WIFI_AC_BK].mpdu_lost;
- hidl_stats->iface.wmeBkPktStats.retries =
- legacy_stats.iface.ac[legacy_hal::WIFI_AC_BK].retries;
- hidl_stats->iface.wmeViPktStats.rxMpdu =
- legacy_stats.iface.ac[legacy_hal::WIFI_AC_VI].rx_mpdu;
- hidl_stats->iface.wmeViPktStats.txMpdu =
- legacy_stats.iface.ac[legacy_hal::WIFI_AC_VI].tx_mpdu;
- hidl_stats->iface.wmeViPktStats.lostMpdu =
- legacy_stats.iface.ac[legacy_hal::WIFI_AC_VI].mpdu_lost;
- hidl_stats->iface.wmeViPktStats.retries =
- legacy_stats.iface.ac[legacy_hal::WIFI_AC_VI].retries;
- hidl_stats->iface.wmeVoPktStats.rxMpdu =
- legacy_stats.iface.ac[legacy_hal::WIFI_AC_VO].rx_mpdu;
- hidl_stats->iface.wmeVoPktStats.txMpdu =
- legacy_stats.iface.ac[legacy_hal::WIFI_AC_VO].tx_mpdu;
- hidl_stats->iface.wmeVoPktStats.lostMpdu =
- legacy_stats.iface.ac[legacy_hal::WIFI_AC_VO].mpdu_lost;
- hidl_stats->iface.wmeVoPktStats.retries =
- legacy_stats.iface.ac[legacy_hal::WIFI_AC_VO].retries;
- // radio legacy_stats conversion.
- std::vector<StaLinkLayerRadioStats> hidl_radios_stats;
- for (const auto& legacy_radio_stats : legacy_stats.radios) {
- StaLinkLayerRadioStats hidl_radio_stats;
- hidl_radio_stats.onTimeInMs = legacy_radio_stats.stats.on_time;
- hidl_radio_stats.txTimeInMs = legacy_radio_stats.stats.tx_time;
- hidl_radio_stats.rxTimeInMs = legacy_radio_stats.stats.rx_time;
- hidl_radio_stats.onTimeInMsForScan = legacy_radio_stats.stats.on_time_scan;
- hidl_radio_stats.txTimeInMsPerLevel = legacy_radio_stats.tx_time_per_levels;
- hidl_radios_stats.push_back(hidl_radio_stats);
- }
- hidl_stats->radios = hidl_radios_stats;
- // Timestamp in the HAL wrapper here since it's not provided in the legacy
- // HAL API.
- hidl_stats->timeStampInMs = uptimeMillis();
- return true;
+ if (!hidl_stats) {
+ return false;
+ }
+ *hidl_stats = {};
+ // iface legacy_stats conversion.
+ hidl_stats->iface.beaconRx = legacy_stats.iface.beacon_rx;
+ hidl_stats->iface.avgRssiMgmt = legacy_stats.iface.rssi_mgmt;
+ hidl_stats->iface.wmeBePktStats.rxMpdu =
+ legacy_stats.iface.ac[legacy_hal::WIFI_AC_BE].rx_mpdu;
+ hidl_stats->iface.wmeBePktStats.txMpdu =
+ legacy_stats.iface.ac[legacy_hal::WIFI_AC_BE].tx_mpdu;
+ hidl_stats->iface.wmeBePktStats.lostMpdu =
+ legacy_stats.iface.ac[legacy_hal::WIFI_AC_BE].mpdu_lost;
+ hidl_stats->iface.wmeBePktStats.retries =
+ legacy_stats.iface.ac[legacy_hal::WIFI_AC_BE].retries;
+ hidl_stats->iface.wmeBkPktStats.rxMpdu =
+ legacy_stats.iface.ac[legacy_hal::WIFI_AC_BK].rx_mpdu;
+ hidl_stats->iface.wmeBkPktStats.txMpdu =
+ legacy_stats.iface.ac[legacy_hal::WIFI_AC_BK].tx_mpdu;
+ hidl_stats->iface.wmeBkPktStats.lostMpdu =
+ legacy_stats.iface.ac[legacy_hal::WIFI_AC_BK].mpdu_lost;
+ hidl_stats->iface.wmeBkPktStats.retries =
+ legacy_stats.iface.ac[legacy_hal::WIFI_AC_BK].retries;
+ hidl_stats->iface.wmeViPktStats.rxMpdu =
+ legacy_stats.iface.ac[legacy_hal::WIFI_AC_VI].rx_mpdu;
+ hidl_stats->iface.wmeViPktStats.txMpdu =
+ legacy_stats.iface.ac[legacy_hal::WIFI_AC_VI].tx_mpdu;
+ hidl_stats->iface.wmeViPktStats.lostMpdu =
+ legacy_stats.iface.ac[legacy_hal::WIFI_AC_VI].mpdu_lost;
+ hidl_stats->iface.wmeViPktStats.retries =
+ legacy_stats.iface.ac[legacy_hal::WIFI_AC_VI].retries;
+ hidl_stats->iface.wmeVoPktStats.rxMpdu =
+ legacy_stats.iface.ac[legacy_hal::WIFI_AC_VO].rx_mpdu;
+ hidl_stats->iface.wmeVoPktStats.txMpdu =
+ legacy_stats.iface.ac[legacy_hal::WIFI_AC_VO].tx_mpdu;
+ hidl_stats->iface.wmeVoPktStats.lostMpdu =
+ legacy_stats.iface.ac[legacy_hal::WIFI_AC_VO].mpdu_lost;
+ hidl_stats->iface.wmeVoPktStats.retries =
+ legacy_stats.iface.ac[legacy_hal::WIFI_AC_VO].retries;
+ // radio legacy_stats conversion.
+ std::vector<StaLinkLayerRadioStats> hidl_radios_stats;
+ for (const auto& legacy_radio_stats : legacy_stats.radios) {
+ StaLinkLayerRadioStats hidl_radio_stats;
+ hidl_radio_stats.onTimeInMs = legacy_radio_stats.stats.on_time;
+ hidl_radio_stats.txTimeInMs = legacy_radio_stats.stats.tx_time;
+ hidl_radio_stats.rxTimeInMs = legacy_radio_stats.stats.rx_time;
+ hidl_radio_stats.onTimeInMsForScan =
+ legacy_radio_stats.stats.on_time_scan;
+ hidl_radio_stats.txTimeInMsPerLevel =
+ legacy_radio_stats.tx_time_per_levels;
+ hidl_radios_stats.push_back(hidl_radio_stats);
+ }
+ hidl_stats->radios = hidl_radios_stats;
+ // Timestamp in the HAL wrapper here since it's not provided in the legacy
+ // HAL API.
+ hidl_stats->timeStampInMs = uptimeMillis();
+ return true;
}
bool convertLegacyRoamingCapabilitiesToHidl(
const legacy_hal::wifi_roaming_capabilities& legacy_caps,
StaRoamingCapabilities* hidl_caps) {
- if (!hidl_caps) {
- return false;
- }
- *hidl_caps = {};
- hidl_caps->maxBlacklistSize = legacy_caps.max_blacklist_size;
- hidl_caps->maxWhitelistSize = legacy_caps.max_whitelist_size;
- return true;
+ if (!hidl_caps) {
+ return false;
+ }
+ *hidl_caps = {};
+ hidl_caps->maxBlacklistSize = legacy_caps.max_blacklist_size;
+ hidl_caps->maxWhitelistSize = legacy_caps.max_whitelist_size;
+ return true;
}
bool convertHidlRoamingConfigToLegacy(
const StaRoamingConfig& hidl_config,
legacy_hal::wifi_roaming_config* legacy_config) {
- if (!legacy_config) {
- return false;
- }
- *legacy_config = {};
- if (hidl_config.bssidBlacklist.size() > MAX_BLACKLIST_BSSID ||
- hidl_config.ssidWhitelist.size() > MAX_WHITELIST_SSID) {
- return false;
- }
- legacy_config->num_blacklist_bssid = hidl_config.bssidBlacklist.size();
- uint32_t i = 0;
- for (const auto& bssid : hidl_config.bssidBlacklist) {
- CHECK(bssid.size() == sizeof(legacy_hal::mac_addr));
- memcpy(legacy_config->blacklist_bssid[i++], bssid.data(), bssid.size());
- }
- legacy_config->num_whitelist_ssid = hidl_config.ssidWhitelist.size();
- i = 0;
- for (const auto& ssid : hidl_config.ssidWhitelist) {
- CHECK(ssid.size() <= sizeof(legacy_hal::ssid_t::ssid_str));
- legacy_config->whitelist_ssid[i].length = ssid.size();
- memcpy(legacy_config->whitelist_ssid[i].ssid_str, ssid.data(), ssid.size());
- i++;
- }
- return true;
+ if (!legacy_config) {
+ return false;
+ }
+ *legacy_config = {};
+ if (hidl_config.bssidBlacklist.size() > MAX_BLACKLIST_BSSID ||
+ hidl_config.ssidWhitelist.size() > MAX_WHITELIST_SSID) {
+ return false;
+ }
+ legacy_config->num_blacklist_bssid = hidl_config.bssidBlacklist.size();
+ uint32_t i = 0;
+ for (const auto& bssid : hidl_config.bssidBlacklist) {
+ CHECK(bssid.size() == sizeof(legacy_hal::mac_addr));
+ memcpy(legacy_config->blacklist_bssid[i++], bssid.data(), bssid.size());
+ }
+ legacy_config->num_whitelist_ssid = hidl_config.ssidWhitelist.size();
+ i = 0;
+ for (const auto& ssid : hidl_config.ssidWhitelist) {
+ CHECK(ssid.size() <= sizeof(legacy_hal::ssid_t::ssid_str));
+ legacy_config->whitelist_ssid[i].length = ssid.size();
+ memcpy(legacy_config->whitelist_ssid[i].ssid_str, ssid.data(),
+ ssid.size());
+ i++;
+ }
+ return true;
}
legacy_hal::fw_roaming_state_t convertHidlRoamingStateToLegacy(
StaRoamingState state) {
- switch (state) {
- case StaRoamingState::ENABLED:
- return legacy_hal::ROAMING_ENABLE;
- case StaRoamingState::DISABLED:
- return legacy_hal::ROAMING_DISABLE;
- };
- CHECK(false);
+ switch (state) {
+ case StaRoamingState::ENABLED:
+ return legacy_hal::ROAMING_ENABLE;
+ case StaRoamingState::DISABLED:
+ return legacy_hal::ROAMING_DISABLE;
+ };
+ CHECK(false);
}
legacy_hal::NanMatchAlg convertHidlNanMatchAlgToLegacy(NanMatchAlg type) {
- switch (type) {
- case NanMatchAlg::MATCH_ONCE:
- return legacy_hal::NAN_MATCH_ALG_MATCH_ONCE;
- case NanMatchAlg::MATCH_CONTINUOUS:
- return legacy_hal::NAN_MATCH_ALG_MATCH_CONTINUOUS;
- case NanMatchAlg::MATCH_NEVER:
- return legacy_hal::NAN_MATCH_ALG_MATCH_NEVER;
- }
- CHECK(false);
+ switch (type) {
+ case NanMatchAlg::MATCH_ONCE:
+ return legacy_hal::NAN_MATCH_ALG_MATCH_ONCE;
+ case NanMatchAlg::MATCH_CONTINUOUS:
+ return legacy_hal::NAN_MATCH_ALG_MATCH_CONTINUOUS;
+ case NanMatchAlg::MATCH_NEVER:
+ return legacy_hal::NAN_MATCH_ALG_MATCH_NEVER;
+ }
+ CHECK(false);
}
-legacy_hal::NanPublishType convertHidlNanPublishTypeToLegacy(NanPublishType type) {
- switch (type) {
- case NanPublishType::UNSOLICITED:
- return legacy_hal::NAN_PUBLISH_TYPE_UNSOLICITED;
- case NanPublishType::SOLICITED:
- return legacy_hal::NAN_PUBLISH_TYPE_SOLICITED;
- case NanPublishType::UNSOLICITED_SOLICITED:
- return legacy_hal::NAN_PUBLISH_TYPE_UNSOLICITED_SOLICITED;
- }
- CHECK(false);
+legacy_hal::NanPublishType convertHidlNanPublishTypeToLegacy(
+ NanPublishType type) {
+ switch (type) {
+ case NanPublishType::UNSOLICITED:
+ return legacy_hal::NAN_PUBLISH_TYPE_UNSOLICITED;
+ case NanPublishType::SOLICITED:
+ return legacy_hal::NAN_PUBLISH_TYPE_SOLICITED;
+ case NanPublishType::UNSOLICITED_SOLICITED:
+ return legacy_hal::NAN_PUBLISH_TYPE_UNSOLICITED_SOLICITED;
+ }
+ CHECK(false);
}
legacy_hal::NanTxType convertHidlNanTxTypeToLegacy(NanTxType type) {
- switch (type) {
- case NanTxType::BROADCAST:
- return legacy_hal::NAN_TX_TYPE_BROADCAST;
- case NanTxType::UNICAST:
- return legacy_hal::NAN_TX_TYPE_UNICAST;
- }
- CHECK(false);
+ switch (type) {
+ case NanTxType::BROADCAST:
+ return legacy_hal::NAN_TX_TYPE_BROADCAST;
+ case NanTxType::UNICAST:
+ return legacy_hal::NAN_TX_TYPE_UNICAST;
+ }
+ CHECK(false);
}
-legacy_hal::NanSubscribeType convertHidlNanSubscribeTypeToLegacy(NanSubscribeType type) {
- switch (type) {
- case NanSubscribeType::PASSIVE:
- return legacy_hal::NAN_SUBSCRIBE_TYPE_PASSIVE;
- case NanSubscribeType::ACTIVE:
- return legacy_hal::NAN_SUBSCRIBE_TYPE_ACTIVE;
- }
- CHECK(false);
+legacy_hal::NanSubscribeType convertHidlNanSubscribeTypeToLegacy(
+ NanSubscribeType type) {
+ switch (type) {
+ case NanSubscribeType::PASSIVE:
+ return legacy_hal::NAN_SUBSCRIBE_TYPE_PASSIVE;
+ case NanSubscribeType::ACTIVE:
+ return legacy_hal::NAN_SUBSCRIBE_TYPE_ACTIVE;
+ }
+ CHECK(false);
}
legacy_hal::NanSRFType convertHidlNanSrfTypeToLegacy(NanSrfType type) {
- switch (type) {
- case NanSrfType::BLOOM_FILTER:
- return legacy_hal::NAN_SRF_ATTR_BLOOM_FILTER;
- case NanSrfType::PARTIAL_MAC_ADDR:
- return legacy_hal::NAN_SRF_ATTR_PARTIAL_MAC_ADDR;
- }
- CHECK(false);
+ switch (type) {
+ case NanSrfType::BLOOM_FILTER:
+ return legacy_hal::NAN_SRF_ATTR_BLOOM_FILTER;
+ case NanSrfType::PARTIAL_MAC_ADDR:
+ return legacy_hal::NAN_SRF_ATTR_PARTIAL_MAC_ADDR;
+ }
+ CHECK(false);
}
legacy_hal::NanDataPathChannelCfg convertHidlNanDataPathChannelCfgToLegacy(
NanDataPathChannelCfg type) {
- switch (type) {
- case NanDataPathChannelCfg::CHANNEL_NOT_REQUESTED:
- return legacy_hal::NAN_DP_CHANNEL_NOT_REQUESTED;
- case NanDataPathChannelCfg::REQUEST_CHANNEL_SETUP:
- return legacy_hal::NAN_DP_REQUEST_CHANNEL_SETUP;
- case NanDataPathChannelCfg::FORCE_CHANNEL_SETUP:
- return legacy_hal::NAN_DP_FORCE_CHANNEL_SETUP;
- }
- CHECK(false);
+ switch (type) {
+ case NanDataPathChannelCfg::CHANNEL_NOT_REQUESTED:
+ return legacy_hal::NAN_DP_CHANNEL_NOT_REQUESTED;
+ case NanDataPathChannelCfg::REQUEST_CHANNEL_SETUP:
+ return legacy_hal::NAN_DP_REQUEST_CHANNEL_SETUP;
+ case NanDataPathChannelCfg::FORCE_CHANNEL_SETUP:
+ return legacy_hal::NAN_DP_FORCE_CHANNEL_SETUP;
+ }
+ CHECK(false);
}
-NanStatusType convertLegacyNanStatusTypeToHidl(
- legacy_hal::NanStatusType type) {
- switch (type) {
- case legacy_hal::NAN_STATUS_SUCCESS:
- return NanStatusType::SUCCESS;
- case legacy_hal::NAN_STATUS_INTERNAL_FAILURE:
- return NanStatusType::INTERNAL_FAILURE;
- case legacy_hal::NAN_STATUS_PROTOCOL_FAILURE:
- return NanStatusType::PROTOCOL_FAILURE;
- case legacy_hal::NAN_STATUS_INVALID_PUBLISH_SUBSCRIBE_ID:
- return NanStatusType::INVALID_SESSION_ID;
- case legacy_hal::NAN_STATUS_NO_RESOURCE_AVAILABLE:
- return NanStatusType::NO_RESOURCES_AVAILABLE;
- case legacy_hal::NAN_STATUS_INVALID_PARAM:
- return NanStatusType::INVALID_ARGS;
- case legacy_hal::NAN_STATUS_INVALID_REQUESTOR_INSTANCE_ID:
- return NanStatusType::INVALID_PEER_ID;
- case legacy_hal::NAN_STATUS_INVALID_NDP_ID:
- return NanStatusType::INVALID_NDP_ID;
- case legacy_hal::NAN_STATUS_NAN_NOT_ALLOWED:
- return NanStatusType::NAN_NOT_ALLOWED;
- case legacy_hal::NAN_STATUS_NO_OTA_ACK:
- return NanStatusType::NO_OTA_ACK;
- case legacy_hal::NAN_STATUS_ALREADY_ENABLED:
- return NanStatusType::ALREADY_ENABLED;
- case legacy_hal::NAN_STATUS_FOLLOWUP_QUEUE_FULL:
- return NanStatusType::FOLLOWUP_TX_QUEUE_FULL;
- case legacy_hal::NAN_STATUS_UNSUPPORTED_CONCURRENCY_NAN_DISABLED:
- return NanStatusType::UNSUPPORTED_CONCURRENCY_NAN_DISABLED;
- }
- CHECK(false);
+NanStatusType convertLegacyNanStatusTypeToHidl(legacy_hal::NanStatusType type) {
+ switch (type) {
+ case legacy_hal::NAN_STATUS_SUCCESS:
+ return NanStatusType::SUCCESS;
+ case legacy_hal::NAN_STATUS_INTERNAL_FAILURE:
+ return NanStatusType::INTERNAL_FAILURE;
+ case legacy_hal::NAN_STATUS_PROTOCOL_FAILURE:
+ return NanStatusType::PROTOCOL_FAILURE;
+ case legacy_hal::NAN_STATUS_INVALID_PUBLISH_SUBSCRIBE_ID:
+ return NanStatusType::INVALID_SESSION_ID;
+ case legacy_hal::NAN_STATUS_NO_RESOURCE_AVAILABLE:
+ return NanStatusType::NO_RESOURCES_AVAILABLE;
+ case legacy_hal::NAN_STATUS_INVALID_PARAM:
+ return NanStatusType::INVALID_ARGS;
+ case legacy_hal::NAN_STATUS_INVALID_REQUESTOR_INSTANCE_ID:
+ return NanStatusType::INVALID_PEER_ID;
+ case legacy_hal::NAN_STATUS_INVALID_NDP_ID:
+ return NanStatusType::INVALID_NDP_ID;
+ case legacy_hal::NAN_STATUS_NAN_NOT_ALLOWED:
+ return NanStatusType::NAN_NOT_ALLOWED;
+ case legacy_hal::NAN_STATUS_NO_OTA_ACK:
+ return NanStatusType::NO_OTA_ACK;
+ case legacy_hal::NAN_STATUS_ALREADY_ENABLED:
+ return NanStatusType::ALREADY_ENABLED;
+ case legacy_hal::NAN_STATUS_FOLLOWUP_QUEUE_FULL:
+ return NanStatusType::FOLLOWUP_TX_QUEUE_FULL;
+ case legacy_hal::NAN_STATUS_UNSUPPORTED_CONCURRENCY_NAN_DISABLED:
+ return NanStatusType::UNSUPPORTED_CONCURRENCY_NAN_DISABLED;
+ }
+ CHECK(false);
}
-void convertToWifiNanStatus(legacy_hal::NanStatusType type, const char* str, size_t max_len,
- WifiNanStatus* wifiNanStatus) {
- wifiNanStatus->status = convertLegacyNanStatusTypeToHidl(type);
- wifiNanStatus->description = safeConvertChar(str, max_len);
+void convertToWifiNanStatus(legacy_hal::NanStatusType type, const char* str,
+ size_t max_len, WifiNanStatus* wifiNanStatus) {
+ wifiNanStatus->status = convertLegacyNanStatusTypeToHidl(type);
+ wifiNanStatus->description = safeConvertChar(str, max_len);
}
bool convertHidlNanEnableRequestToLegacy(
const NanEnableRequest& hidl_request,
legacy_hal::NanEnableRequest* legacy_request) {
- if (!legacy_request) {
- LOG(ERROR) << "convertHidlNanEnableRequestToLegacy: null legacy_request";
- return false;
- }
- *legacy_request = {};
+ if (!legacy_request) {
+ LOG(ERROR)
+ << "convertHidlNanEnableRequestToLegacy: null legacy_request";
+ return false;
+ }
+ *legacy_request = {};
- legacy_request->config_2dot4g_support = 1;
- legacy_request->support_2dot4g_val = hidl_request.operateInBand[
- (size_t) NanBandIndex::NAN_BAND_24GHZ];
- legacy_request->config_support_5g = 1;
- legacy_request->support_5g_val = hidl_request.operateInBand[(size_t) NanBandIndex::NAN_BAND_5GHZ];
- legacy_request->config_hop_count_limit = 1;
- legacy_request->hop_count_limit_val = hidl_request.hopCountMax;
- legacy_request->master_pref = hidl_request.configParams.masterPref;
- legacy_request->discovery_indication_cfg = 0;
- legacy_request->discovery_indication_cfg |=
- hidl_request.configParams.disableDiscoveryAddressChangeIndication ? 0x1 : 0x0;
- legacy_request->discovery_indication_cfg |=
+ legacy_request->config_2dot4g_support = 1;
+ legacy_request->support_2dot4g_val =
+ hidl_request.operateInBand[(size_t)NanBandIndex::NAN_BAND_24GHZ];
+ legacy_request->config_support_5g = 1;
+ legacy_request->support_5g_val =
+ hidl_request.operateInBand[(size_t)NanBandIndex::NAN_BAND_5GHZ];
+ legacy_request->config_hop_count_limit = 1;
+ legacy_request->hop_count_limit_val = hidl_request.hopCountMax;
+ legacy_request->master_pref = hidl_request.configParams.masterPref;
+ legacy_request->discovery_indication_cfg = 0;
+ legacy_request->discovery_indication_cfg |=
+ hidl_request.configParams.disableDiscoveryAddressChangeIndication ? 0x1
+ : 0x0;
+ legacy_request->discovery_indication_cfg |=
hidl_request.configParams.disableStartedClusterIndication ? 0x2 : 0x0;
- legacy_request->discovery_indication_cfg |=
+ legacy_request->discovery_indication_cfg |=
hidl_request.configParams.disableJoinedClusterIndication ? 0x4 : 0x0;
- legacy_request->config_sid_beacon = 1;
- if (hidl_request.configParams.numberOfPublishServiceIdsInBeacon > 127) {
- LOG(ERROR) << "convertHidlNanEnableRequestToLegacy: numberOfPublishServiceIdsInBeacon > 127";
- return false;
- }
- legacy_request->sid_beacon_val =
- (hidl_request.configParams.includePublishServiceIdsInBeacon ? 0x1 : 0x0)
- | (hidl_request.configParams.numberOfPublishServiceIdsInBeacon << 1);
- legacy_request->config_subscribe_sid_beacon = 1;
- if (hidl_request.configParams.numberOfSubscribeServiceIdsInBeacon > 127) {
- LOG(ERROR) << "convertHidlNanEnableRequestToLegacy: numberOfSubscribeServiceIdsInBeacon > 127";
- return false;
- }
- legacy_request->subscribe_sid_beacon_val =
- (hidl_request.configParams.includeSubscribeServiceIdsInBeacon ? 0x1 : 0x0)
- | (hidl_request.configParams.numberOfSubscribeServiceIdsInBeacon << 1);
- legacy_request->config_rssi_window_size = 1;
- legacy_request->rssi_window_size_val = hidl_request.configParams.rssiWindowSize;
- legacy_request->config_disc_mac_addr_randomization = 1;
- legacy_request->disc_mac_addr_rand_interval_sec =
+ legacy_request->config_sid_beacon = 1;
+ if (hidl_request.configParams.numberOfPublishServiceIdsInBeacon > 127) {
+ LOG(ERROR) << "convertHidlNanEnableRequestToLegacy: "
+ "numberOfPublishServiceIdsInBeacon > 127";
+ return false;
+ }
+ legacy_request->sid_beacon_val =
+ (hidl_request.configParams.includePublishServiceIdsInBeacon ? 0x1
+ : 0x0) |
+ (hidl_request.configParams.numberOfPublishServiceIdsInBeacon << 1);
+ legacy_request->config_subscribe_sid_beacon = 1;
+ if (hidl_request.configParams.numberOfSubscribeServiceIdsInBeacon > 127) {
+ LOG(ERROR) << "convertHidlNanEnableRequestToLegacy: "
+ "numberOfSubscribeServiceIdsInBeacon > 127";
+ return false;
+ }
+ legacy_request->subscribe_sid_beacon_val =
+ (hidl_request.configParams.includeSubscribeServiceIdsInBeacon ? 0x1
+ : 0x0) |
+ (hidl_request.configParams.numberOfSubscribeServiceIdsInBeacon << 1);
+ legacy_request->config_rssi_window_size = 1;
+ legacy_request->rssi_window_size_val =
+ hidl_request.configParams.rssiWindowSize;
+ legacy_request->config_disc_mac_addr_randomization = 1;
+ legacy_request->disc_mac_addr_rand_interval_sec =
hidl_request.configParams.macAddressRandomizationIntervalSec;
- legacy_request->config_2dot4g_rssi_close = 1;
- if (hidl_request.configParams.bandSpecificConfig.size() != 2) {
- LOG(ERROR) << "convertHidlNanEnableRequestToLegacy: bandSpecificConfig.size() != 2";
- return false;
- }
- legacy_request->rssi_close_2dot4g_val =
- hidl_request.configParams.bandSpecificConfig[
- (size_t) NanBandIndex::NAN_BAND_24GHZ].rssiClose;
- legacy_request->config_2dot4g_rssi_middle = 1;
- legacy_request->rssi_middle_2dot4g_val =
- hidl_request.configParams.bandSpecificConfig[
- (size_t) NanBandIndex::NAN_BAND_24GHZ].rssiMiddle;
- legacy_request->config_2dot4g_rssi_proximity = 1;
- legacy_request->rssi_proximity_2dot4g_val =
- hidl_request.configParams.bandSpecificConfig[
- (size_t) NanBandIndex::NAN_BAND_24GHZ].rssiCloseProximity;
- legacy_request->config_scan_params = 1;
- legacy_request->scan_params_val.dwell_time[legacy_hal::NAN_CHANNEL_24G_BAND] =
- hidl_request.configParams.bandSpecificConfig[
- (size_t) NanBandIndex::NAN_BAND_24GHZ].dwellTimeMs;
- legacy_request->scan_params_val.scan_period[legacy_hal::NAN_CHANNEL_24G_BAND] =
- hidl_request.configParams.bandSpecificConfig[
- (size_t) NanBandIndex::NAN_BAND_24GHZ].scanPeriodSec;
- legacy_request->config_dw.config_2dot4g_dw_band = hidl_request.configParams
- .bandSpecificConfig[(size_t) NanBandIndex::NAN_BAND_24GHZ].validDiscoveryWindowIntervalVal;
- legacy_request->config_dw.dw_2dot4g_interval_val = hidl_request.configParams
- .bandSpecificConfig[(size_t) NanBandIndex::NAN_BAND_24GHZ].discoveryWindowIntervalVal;
- legacy_request->config_5g_rssi_close = 1;
- legacy_request->rssi_close_5g_val =
- hidl_request.configParams.bandSpecificConfig[
- (size_t) NanBandIndex::NAN_BAND_5GHZ].rssiClose;
- legacy_request->config_5g_rssi_middle = 1;
- legacy_request->rssi_middle_5g_val =
- hidl_request.configParams.bandSpecificConfig[
- (size_t) NanBandIndex::NAN_BAND_5GHZ].rssiMiddle;
- legacy_request->config_5g_rssi_close_proximity = 1;
- legacy_request->rssi_close_proximity_5g_val =
- hidl_request.configParams.bandSpecificConfig[
- (size_t) NanBandIndex::NAN_BAND_5GHZ].rssiCloseProximity;
- legacy_request->scan_params_val.dwell_time[legacy_hal::NAN_CHANNEL_5G_BAND_LOW] =
- hidl_request.configParams.bandSpecificConfig[
- (size_t) NanBandIndex::NAN_BAND_5GHZ].dwellTimeMs;
- legacy_request->scan_params_val.scan_period[legacy_hal::NAN_CHANNEL_5G_BAND_LOW] =
- hidl_request.configParams.bandSpecificConfig[
- (size_t) NanBandIndex::NAN_BAND_5GHZ].scanPeriodSec;
- legacy_request->scan_params_val.dwell_time[legacy_hal::NAN_CHANNEL_5G_BAND_HIGH] =
- hidl_request.configParams.bandSpecificConfig[
- (size_t) NanBandIndex::NAN_BAND_5GHZ].dwellTimeMs;
- legacy_request->scan_params_val.scan_period[legacy_hal::NAN_CHANNEL_5G_BAND_HIGH] =
- hidl_request.configParams.bandSpecificConfig[
- (size_t) NanBandIndex::NAN_BAND_5GHZ].scanPeriodSec;
- legacy_request->config_dw.config_5g_dw_band = hidl_request.configParams
- .bandSpecificConfig[(size_t) NanBandIndex::NAN_BAND_5GHZ].validDiscoveryWindowIntervalVal;
- legacy_request->config_dw.dw_5g_interval_val = hidl_request.configParams
- .bandSpecificConfig[(size_t) NanBandIndex::NAN_BAND_5GHZ].discoveryWindowIntervalVal;
- if (hidl_request.debugConfigs.validClusterIdVals) {
- legacy_request->cluster_low = hidl_request.debugConfigs.clusterIdBottomRangeVal;
- legacy_request->cluster_high = hidl_request.debugConfigs.clusterIdTopRangeVal;
- } else { // need 'else' since not configurable in legacy HAL
- legacy_request->cluster_low = 0x0000;
- legacy_request->cluster_high = 0xFFFF;
- }
- legacy_request->config_intf_addr = hidl_request.debugConfigs.validIntfAddrVal;
- memcpy(legacy_request->intf_addr_val, hidl_request.debugConfigs.intfAddrVal.data(), 6);
- legacy_request->config_oui = hidl_request.debugConfigs.validOuiVal;
- legacy_request->oui_val = hidl_request.debugConfigs.ouiVal;
- legacy_request->config_random_factor_force = hidl_request.debugConfigs.validRandomFactorForceVal;
- legacy_request->random_factor_force_val = hidl_request.debugConfigs.randomFactorForceVal;
- legacy_request->config_hop_count_force = hidl_request.debugConfigs.validHopCountForceVal;
- legacy_request->hop_count_force_val = hidl_request.debugConfigs.hopCountForceVal;
- legacy_request->config_24g_channel = hidl_request.debugConfigs.validDiscoveryChannelVal;
- legacy_request->channel_24g_val =
- hidl_request.debugConfigs.discoveryChannelMhzVal[(size_t) NanBandIndex::NAN_BAND_24GHZ];
- legacy_request->config_5g_channel = hidl_request.debugConfigs.validDiscoveryChannelVal;
- legacy_request->channel_5g_val = hidl_request.debugConfigs
- .discoveryChannelMhzVal[(size_t) NanBandIndex::NAN_BAND_5GHZ];
- legacy_request->config_2dot4g_beacons = hidl_request.debugConfigs.validUseBeaconsInBandVal;
- legacy_request->beacon_2dot4g_val = hidl_request.debugConfigs
- .useBeaconsInBandVal[(size_t) NanBandIndex::NAN_BAND_24GHZ];
- legacy_request->config_5g_beacons = hidl_request.debugConfigs.validUseBeaconsInBandVal;
- legacy_request->beacon_5g_val = hidl_request.debugConfigs
- .useBeaconsInBandVal[(size_t) NanBandIndex::NAN_BAND_5GHZ];
- legacy_request->config_2dot4g_sdf = hidl_request.debugConfigs.validUseSdfInBandVal;
- legacy_request->sdf_2dot4g_val = hidl_request.debugConfigs
- .useSdfInBandVal[(size_t) NanBandIndex::NAN_BAND_24GHZ];
- legacy_request->config_5g_sdf = hidl_request.debugConfigs.validUseSdfInBandVal;
- legacy_request->sdf_5g_val = hidl_request.debugConfigs
- .useSdfInBandVal[(size_t) NanBandIndex::NAN_BAND_5GHZ];
+ legacy_request->config_2dot4g_rssi_close = 1;
+ if (hidl_request.configParams.bandSpecificConfig.size() != 2) {
+ LOG(ERROR) << "convertHidlNanEnableRequestToLegacy: "
+ "bandSpecificConfig.size() != 2";
+ return false;
+ }
+ legacy_request->rssi_close_2dot4g_val =
+ hidl_request.configParams
+ .bandSpecificConfig[(size_t)NanBandIndex::NAN_BAND_24GHZ]
+ .rssiClose;
+ legacy_request->config_2dot4g_rssi_middle = 1;
+ legacy_request->rssi_middle_2dot4g_val =
+ hidl_request.configParams
+ .bandSpecificConfig[(size_t)NanBandIndex::NAN_BAND_24GHZ]
+ .rssiMiddle;
+ legacy_request->config_2dot4g_rssi_proximity = 1;
+ legacy_request->rssi_proximity_2dot4g_val =
+ hidl_request.configParams
+ .bandSpecificConfig[(size_t)NanBandIndex::NAN_BAND_24GHZ]
+ .rssiCloseProximity;
+ legacy_request->config_scan_params = 1;
+ legacy_request->scan_params_val
+ .dwell_time[legacy_hal::NAN_CHANNEL_24G_BAND] =
+ hidl_request.configParams
+ .bandSpecificConfig[(size_t)NanBandIndex::NAN_BAND_24GHZ]
+ .dwellTimeMs;
+ legacy_request->scan_params_val
+ .scan_period[legacy_hal::NAN_CHANNEL_24G_BAND] =
+ hidl_request.configParams
+ .bandSpecificConfig[(size_t)NanBandIndex::NAN_BAND_24GHZ]
+ .scanPeriodSec;
+ legacy_request->config_dw.config_2dot4g_dw_band =
+ hidl_request.configParams
+ .bandSpecificConfig[(size_t)NanBandIndex::NAN_BAND_24GHZ]
+ .validDiscoveryWindowIntervalVal;
+ legacy_request->config_dw.dw_2dot4g_interval_val =
+ hidl_request.configParams
+ .bandSpecificConfig[(size_t)NanBandIndex::NAN_BAND_24GHZ]
+ .discoveryWindowIntervalVal;
+ legacy_request->config_5g_rssi_close = 1;
+ legacy_request->rssi_close_5g_val =
+ hidl_request.configParams
+ .bandSpecificConfig[(size_t)NanBandIndex::NAN_BAND_5GHZ]
+ .rssiClose;
+ legacy_request->config_5g_rssi_middle = 1;
+ legacy_request->rssi_middle_5g_val =
+ hidl_request.configParams
+ .bandSpecificConfig[(size_t)NanBandIndex::NAN_BAND_5GHZ]
+ .rssiMiddle;
+ legacy_request->config_5g_rssi_close_proximity = 1;
+ legacy_request->rssi_close_proximity_5g_val =
+ hidl_request.configParams
+ .bandSpecificConfig[(size_t)NanBandIndex::NAN_BAND_5GHZ]
+ .rssiCloseProximity;
+ legacy_request->scan_params_val
+ .dwell_time[legacy_hal::NAN_CHANNEL_5G_BAND_LOW] =
+ hidl_request.configParams
+ .bandSpecificConfig[(size_t)NanBandIndex::NAN_BAND_5GHZ]
+ .dwellTimeMs;
+ legacy_request->scan_params_val
+ .scan_period[legacy_hal::NAN_CHANNEL_5G_BAND_LOW] =
+ hidl_request.configParams
+ .bandSpecificConfig[(size_t)NanBandIndex::NAN_BAND_5GHZ]
+ .scanPeriodSec;
+ legacy_request->scan_params_val
+ .dwell_time[legacy_hal::NAN_CHANNEL_5G_BAND_HIGH] =
+ hidl_request.configParams
+ .bandSpecificConfig[(size_t)NanBandIndex::NAN_BAND_5GHZ]
+ .dwellTimeMs;
+ legacy_request->scan_params_val
+ .scan_period[legacy_hal::NAN_CHANNEL_5G_BAND_HIGH] =
+ hidl_request.configParams
+ .bandSpecificConfig[(size_t)NanBandIndex::NAN_BAND_5GHZ]
+ .scanPeriodSec;
+ legacy_request->config_dw.config_5g_dw_band =
+ hidl_request.configParams
+ .bandSpecificConfig[(size_t)NanBandIndex::NAN_BAND_5GHZ]
+ .validDiscoveryWindowIntervalVal;
+ legacy_request->config_dw.dw_5g_interval_val =
+ hidl_request.configParams
+ .bandSpecificConfig[(size_t)NanBandIndex::NAN_BAND_5GHZ]
+ .discoveryWindowIntervalVal;
+ if (hidl_request.debugConfigs.validClusterIdVals) {
+ legacy_request->cluster_low =
+ hidl_request.debugConfigs.clusterIdBottomRangeVal;
+ legacy_request->cluster_high =
+ hidl_request.debugConfigs.clusterIdTopRangeVal;
+ } else { // need 'else' since not configurable in legacy HAL
+ legacy_request->cluster_low = 0x0000;
+ legacy_request->cluster_high = 0xFFFF;
+ }
+ legacy_request->config_intf_addr =
+ hidl_request.debugConfigs.validIntfAddrVal;
+ memcpy(legacy_request->intf_addr_val,
+ hidl_request.debugConfigs.intfAddrVal.data(), 6);
+ legacy_request->config_oui = hidl_request.debugConfigs.validOuiVal;
+ legacy_request->oui_val = hidl_request.debugConfigs.ouiVal;
+ legacy_request->config_random_factor_force =
+ hidl_request.debugConfigs.validRandomFactorForceVal;
+ legacy_request->random_factor_force_val =
+ hidl_request.debugConfigs.randomFactorForceVal;
+ legacy_request->config_hop_count_force =
+ hidl_request.debugConfigs.validHopCountForceVal;
+ legacy_request->hop_count_force_val =
+ hidl_request.debugConfigs.hopCountForceVal;
+ legacy_request->config_24g_channel =
+ hidl_request.debugConfigs.validDiscoveryChannelVal;
+ legacy_request->channel_24g_val =
+ hidl_request.debugConfigs
+ .discoveryChannelMhzVal[(size_t)NanBandIndex::NAN_BAND_24GHZ];
+ legacy_request->config_5g_channel =
+ hidl_request.debugConfigs.validDiscoveryChannelVal;
+ legacy_request->channel_5g_val =
+ hidl_request.debugConfigs
+ .discoveryChannelMhzVal[(size_t)NanBandIndex::NAN_BAND_5GHZ];
+ legacy_request->config_2dot4g_beacons =
+ hidl_request.debugConfigs.validUseBeaconsInBandVal;
+ legacy_request->beacon_2dot4g_val =
+ hidl_request.debugConfigs
+ .useBeaconsInBandVal[(size_t)NanBandIndex::NAN_BAND_24GHZ];
+ legacy_request->config_5g_beacons =
+ hidl_request.debugConfigs.validUseBeaconsInBandVal;
+ legacy_request->beacon_5g_val =
+ hidl_request.debugConfigs
+ .useBeaconsInBandVal[(size_t)NanBandIndex::NAN_BAND_5GHZ];
+ legacy_request->config_2dot4g_sdf =
+ hidl_request.debugConfigs.validUseSdfInBandVal;
+ legacy_request->sdf_2dot4g_val =
+ hidl_request.debugConfigs
+ .useSdfInBandVal[(size_t)NanBandIndex::NAN_BAND_24GHZ];
+ legacy_request->config_5g_sdf =
+ hidl_request.debugConfigs.validUseSdfInBandVal;
+ legacy_request->sdf_5g_val =
+ hidl_request.debugConfigs
+ .useSdfInBandVal[(size_t)NanBandIndex::NAN_BAND_5GHZ];
- return true;
+ return true;
}
bool convertHidlNanPublishRequestToLegacy(
const NanPublishRequest& hidl_request,
legacy_hal::NanPublishRequest* legacy_request) {
- if (!legacy_request) {
- LOG(ERROR) << "convertHidlNanPublishRequestToLegacy: null legacy_request";
- return false;
- }
- *legacy_request = {};
+ if (!legacy_request) {
+ LOG(ERROR)
+ << "convertHidlNanPublishRequestToLegacy: null legacy_request";
+ return false;
+ }
+ *legacy_request = {};
- legacy_request->publish_id = hidl_request.baseConfigs.sessionId;
- legacy_request->ttl = hidl_request.baseConfigs.ttlSec;
- legacy_request->period = hidl_request.baseConfigs.discoveryWindowPeriod;
- legacy_request->publish_count = hidl_request.baseConfigs.discoveryCount;
- legacy_request->service_name_len = hidl_request.baseConfigs.serviceName.size();
- if (legacy_request->service_name_len > NAN_MAX_SERVICE_NAME_LEN) {
- LOG(ERROR) << "convertHidlNanPublishRequestToLegacy: service_name_len too large";
- return false;
- }
- memcpy(legacy_request->service_name, hidl_request.baseConfigs.serviceName.data(),
- legacy_request->service_name_len);
- legacy_request->publish_match_indicator =
- convertHidlNanMatchAlgToLegacy(hidl_request.baseConfigs.discoveryMatchIndicator);
- legacy_request->service_specific_info_len = hidl_request.baseConfigs.serviceSpecificInfo.size();
- if (legacy_request->service_specific_info_len > NAN_MAX_SERVICE_SPECIFIC_INFO_LEN) {
- LOG(ERROR) << "convertHidlNanPublishRequestToLegacy: service_specific_info_len too large";
- return false;
- }
- memcpy(legacy_request->service_specific_info,
- hidl_request.baseConfigs.serviceSpecificInfo.data(),
- legacy_request->service_specific_info_len);
- legacy_request->sdea_service_specific_info_len =
+ legacy_request->publish_id = hidl_request.baseConfigs.sessionId;
+ legacy_request->ttl = hidl_request.baseConfigs.ttlSec;
+ legacy_request->period = hidl_request.baseConfigs.discoveryWindowPeriod;
+ legacy_request->publish_count = hidl_request.baseConfigs.discoveryCount;
+ legacy_request->service_name_len =
+ hidl_request.baseConfigs.serviceName.size();
+ if (legacy_request->service_name_len > NAN_MAX_SERVICE_NAME_LEN) {
+ LOG(ERROR) << "convertHidlNanPublishRequestToLegacy: service_name_len "
+ "too large";
+ return false;
+ }
+ memcpy(legacy_request->service_name,
+ hidl_request.baseConfigs.serviceName.data(),
+ legacy_request->service_name_len);
+ legacy_request->publish_match_indicator = convertHidlNanMatchAlgToLegacy(
+ hidl_request.baseConfigs.discoveryMatchIndicator);
+ legacy_request->service_specific_info_len =
+ hidl_request.baseConfigs.serviceSpecificInfo.size();
+ if (legacy_request->service_specific_info_len >
+ NAN_MAX_SERVICE_SPECIFIC_INFO_LEN) {
+ LOG(ERROR) << "convertHidlNanPublishRequestToLegacy: "
+ "service_specific_info_len too large";
+ return false;
+ }
+ memcpy(legacy_request->service_specific_info,
+ hidl_request.baseConfigs.serviceSpecificInfo.data(),
+ legacy_request->service_specific_info_len);
+ legacy_request->sdea_service_specific_info_len =
hidl_request.baseConfigs.extendedServiceSpecificInfo.size();
- if (legacy_request->sdea_service_specific_info_len > NAN_MAX_SDEA_SERVICE_SPECIFIC_INFO_LEN) {
- LOG(ERROR) << "convertHidlNanPublishRequestToLegacy: sdea_service_specific_info_len too large";
- return false;
- }
- memcpy(legacy_request->sdea_service_specific_info,
- hidl_request.baseConfigs.extendedServiceSpecificInfo.data(),
- legacy_request->sdea_service_specific_info_len);
- legacy_request->rx_match_filter_len = hidl_request.baseConfigs.rxMatchFilter.size();
- if (legacy_request->rx_match_filter_len > NAN_MAX_MATCH_FILTER_LEN) {
- LOG(ERROR) << "convertHidlNanPublishRequestToLegacy: rx_match_filter_len too large";
- return false;
- }
- memcpy(legacy_request->rx_match_filter,
- hidl_request.baseConfigs.rxMatchFilter.data(),
- legacy_request->rx_match_filter_len);
- legacy_request->tx_match_filter_len = hidl_request.baseConfigs.txMatchFilter.size();
- if (legacy_request->tx_match_filter_len > NAN_MAX_MATCH_FILTER_LEN) {
- LOG(ERROR) << "convertHidlNanPublishRequestToLegacy: tx_match_filter_len too large";
- return false;
- }
- memcpy(legacy_request->tx_match_filter,
- hidl_request.baseConfigs.txMatchFilter.data(),
- legacy_request->tx_match_filter_len);
- legacy_request->rssi_threshold_flag = hidl_request.baseConfigs.useRssiThreshold;
- legacy_request->recv_indication_cfg = 0;
- legacy_request->recv_indication_cfg |=
- hidl_request.baseConfigs.disableDiscoveryTerminationIndication ? 0x1 : 0x0;
- legacy_request->recv_indication_cfg |=
+ if (legacy_request->sdea_service_specific_info_len >
+ NAN_MAX_SDEA_SERVICE_SPECIFIC_INFO_LEN) {
+ LOG(ERROR) << "convertHidlNanPublishRequestToLegacy: "
+ "sdea_service_specific_info_len too large";
+ return false;
+ }
+ memcpy(legacy_request->sdea_service_specific_info,
+ hidl_request.baseConfigs.extendedServiceSpecificInfo.data(),
+ legacy_request->sdea_service_specific_info_len);
+ legacy_request->rx_match_filter_len =
+ hidl_request.baseConfigs.rxMatchFilter.size();
+ if (legacy_request->rx_match_filter_len > NAN_MAX_MATCH_FILTER_LEN) {
+ LOG(ERROR) << "convertHidlNanPublishRequestToLegacy: "
+ "rx_match_filter_len too large";
+ return false;
+ }
+ memcpy(legacy_request->rx_match_filter,
+ hidl_request.baseConfigs.rxMatchFilter.data(),
+ legacy_request->rx_match_filter_len);
+ legacy_request->tx_match_filter_len =
+ hidl_request.baseConfigs.txMatchFilter.size();
+ if (legacy_request->tx_match_filter_len > NAN_MAX_MATCH_FILTER_LEN) {
+ LOG(ERROR) << "convertHidlNanPublishRequestToLegacy: "
+ "tx_match_filter_len too large";
+ return false;
+ }
+ memcpy(legacy_request->tx_match_filter,
+ hidl_request.baseConfigs.txMatchFilter.data(),
+ legacy_request->tx_match_filter_len);
+ legacy_request->rssi_threshold_flag =
+ hidl_request.baseConfigs.useRssiThreshold;
+ legacy_request->recv_indication_cfg = 0;
+ legacy_request->recv_indication_cfg |=
+ hidl_request.baseConfigs.disableDiscoveryTerminationIndication ? 0x1
+ : 0x0;
+ legacy_request->recv_indication_cfg |=
hidl_request.baseConfigs.disableMatchExpirationIndication ? 0x2 : 0x0;
- legacy_request->recv_indication_cfg |=
+ legacy_request->recv_indication_cfg |=
hidl_request.baseConfigs.disableFollowupReceivedIndication ? 0x4 : 0x0;
- legacy_request->recv_indication_cfg |= 0x8;
- legacy_request->cipher_type = (unsigned int) hidl_request.baseConfigs.securityConfig.cipherType;
- if (hidl_request.baseConfigs.securityConfig.securityType == NanDataPathSecurityType::PMK) {
- legacy_request->key_info.key_type = legacy_hal::NAN_SECURITY_KEY_INPUT_PMK;
- legacy_request->key_info.body.pmk_info.pmk_len =
- hidl_request.baseConfigs.securityConfig.pmk.size();
- if (legacy_request->key_info.body.pmk_info.pmk_len != NAN_PMK_INFO_LEN) {
- LOG(ERROR) << "convertHidlNanPublishRequestToLegacy: invalid pmk_len";
- return false;
+ legacy_request->recv_indication_cfg |= 0x8;
+ legacy_request->cipher_type =
+ (unsigned int)hidl_request.baseConfigs.securityConfig.cipherType;
+ if (hidl_request.baseConfigs.securityConfig.securityType ==
+ NanDataPathSecurityType::PMK) {
+ legacy_request->key_info.key_type =
+ legacy_hal::NAN_SECURITY_KEY_INPUT_PMK;
+ legacy_request->key_info.body.pmk_info.pmk_len =
+ hidl_request.baseConfigs.securityConfig.pmk.size();
+ if (legacy_request->key_info.body.pmk_info.pmk_len !=
+ NAN_PMK_INFO_LEN) {
+ LOG(ERROR)
+ << "convertHidlNanPublishRequestToLegacy: invalid pmk_len";
+ return false;
+ }
+ memcpy(legacy_request->key_info.body.pmk_info.pmk,
+ hidl_request.baseConfigs.securityConfig.pmk.data(),
+ legacy_request->key_info.body.pmk_info.pmk_len);
}
- memcpy(legacy_request->key_info.body.pmk_info.pmk,
- hidl_request.baseConfigs.securityConfig.pmk.data(),
- legacy_request->key_info.body.pmk_info.pmk_len);
- }
- if (hidl_request.baseConfigs.securityConfig.securityType
- == NanDataPathSecurityType::PASSPHRASE) {
- legacy_request->key_info.key_type = legacy_hal::NAN_SECURITY_KEY_INPUT_PASSPHRASE;
- legacy_request->key_info.body.passphrase_info.passphrase_len =
- hidl_request.baseConfigs.securityConfig.passphrase.size();
- if (legacy_request->key_info.body.passphrase_info.passphrase_len
- < NAN_SECURITY_MIN_PASSPHRASE_LEN) {
- LOG(ERROR) << "convertHidlNanPublishRequestToLegacy: passphrase_len too small";
- return false;
+ if (hidl_request.baseConfigs.securityConfig.securityType ==
+ NanDataPathSecurityType::PASSPHRASE) {
+ legacy_request->key_info.key_type =
+ legacy_hal::NAN_SECURITY_KEY_INPUT_PASSPHRASE;
+ legacy_request->key_info.body.passphrase_info.passphrase_len =
+ hidl_request.baseConfigs.securityConfig.passphrase.size();
+ if (legacy_request->key_info.body.passphrase_info.passphrase_len <
+ NAN_SECURITY_MIN_PASSPHRASE_LEN) {
+ LOG(ERROR) << "convertHidlNanPublishRequestToLegacy: "
+ "passphrase_len too small";
+ return false;
+ }
+ if (legacy_request->key_info.body.passphrase_info.passphrase_len >
+ NAN_SECURITY_MAX_PASSPHRASE_LEN) {
+ LOG(ERROR) << "convertHidlNanPublishRequestToLegacy: "
+ "passphrase_len too large";
+ return false;
+ }
+ memcpy(legacy_request->key_info.body.passphrase_info.passphrase,
+ hidl_request.baseConfigs.securityConfig.passphrase.data(),
+ legacy_request->key_info.body.passphrase_info.passphrase_len);
}
- if (legacy_request->key_info.body.passphrase_info.passphrase_len
- > NAN_SECURITY_MAX_PASSPHRASE_LEN) {
- LOG(ERROR) << "convertHidlNanPublishRequestToLegacy: passphrase_len too large";
- return false;
- }
- memcpy(legacy_request->key_info.body.passphrase_info.passphrase,
- hidl_request.baseConfigs.securityConfig.passphrase.data(),
- legacy_request->key_info.body.passphrase_info.passphrase_len);
- }
- legacy_request->sdea_params.security_cfg = (hidl_request.baseConfigs.securityConfig.securityType
- != NanDataPathSecurityType::OPEN) ? legacy_hal::NAN_DP_CONFIG_SECURITY
+ legacy_request->sdea_params.security_cfg =
+ (hidl_request.baseConfigs.securityConfig.securityType !=
+ NanDataPathSecurityType::OPEN)
+ ? legacy_hal::NAN_DP_CONFIG_SECURITY
: legacy_hal::NAN_DP_CONFIG_NO_SECURITY;
- legacy_request->sdea_params.ranging_state = hidl_request.baseConfigs.rangingRequired ?
- legacy_hal::NAN_RANGING_ENABLE : legacy_hal::NAN_RANGING_DISABLE;
- legacy_request->ranging_cfg.ranging_interval_msec = hidl_request.baseConfigs.rangingIntervalMsec;
- legacy_request->ranging_cfg.config_ranging_indications =
+ legacy_request->sdea_params.ranging_state =
+ hidl_request.baseConfigs.rangingRequired
+ ? legacy_hal::NAN_RANGING_ENABLE
+ : legacy_hal::NAN_RANGING_DISABLE;
+ legacy_request->ranging_cfg.ranging_interval_msec =
+ hidl_request.baseConfigs.rangingIntervalMsec;
+ legacy_request->ranging_cfg.config_ranging_indications =
hidl_request.baseConfigs.configRangingIndications;
- legacy_request->ranging_cfg.distance_ingress_cm = hidl_request.baseConfigs.distanceIngressCm;
- legacy_request->ranging_cfg.distance_egress_cm = hidl_request.baseConfigs.distanceEgressCm;
- legacy_request->ranging_auto_response = hidl_request.baseConfigs.rangingRequired ?
- legacy_hal::NAN_RANGING_AUTO_RESPONSE_ENABLE : legacy_hal::NAN_RANGING_AUTO_RESPONSE_DISABLE;
- legacy_request->sdea_params.range_report = legacy_hal::NAN_DISABLE_RANGE_REPORT;
- legacy_request->publish_type = convertHidlNanPublishTypeToLegacy(hidl_request.publishType);
- legacy_request->tx_type = convertHidlNanTxTypeToLegacy(hidl_request.txType);
- legacy_request->service_responder_policy = hidl_request.autoAcceptDataPathRequests ?
- legacy_hal::NAN_SERVICE_ACCEPT_POLICY_ALL : legacy_hal::NAN_SERVICE_ACCEPT_POLICY_NONE;
+ legacy_request->ranging_cfg.distance_ingress_cm =
+ hidl_request.baseConfigs.distanceIngressCm;
+ legacy_request->ranging_cfg.distance_egress_cm =
+ hidl_request.baseConfigs.distanceEgressCm;
+ legacy_request->ranging_auto_response =
+ hidl_request.baseConfigs.rangingRequired
+ ? legacy_hal::NAN_RANGING_AUTO_RESPONSE_ENABLE
+ : legacy_hal::NAN_RANGING_AUTO_RESPONSE_DISABLE;
+ legacy_request->sdea_params.range_report =
+ legacy_hal::NAN_DISABLE_RANGE_REPORT;
+ legacy_request->publish_type =
+ convertHidlNanPublishTypeToLegacy(hidl_request.publishType);
+ legacy_request->tx_type = convertHidlNanTxTypeToLegacy(hidl_request.txType);
+ legacy_request->service_responder_policy =
+ hidl_request.autoAcceptDataPathRequests
+ ? legacy_hal::NAN_SERVICE_ACCEPT_POLICY_ALL
+ : legacy_hal::NAN_SERVICE_ACCEPT_POLICY_NONE;
- return true;
+ return true;
}
bool convertHidlNanSubscribeRequestToLegacy(
const NanSubscribeRequest& hidl_request,
legacy_hal::NanSubscribeRequest* legacy_request) {
- if (!legacy_request) {
- LOG(ERROR) << "convertHidlNanSubscribeRequestToLegacy: legacy_request is null";
- return false;
- }
- *legacy_request = {};
+ if (!legacy_request) {
+ LOG(ERROR)
+ << "convertHidlNanSubscribeRequestToLegacy: legacy_request is null";
+ return false;
+ }
+ *legacy_request = {};
- legacy_request->subscribe_id = hidl_request.baseConfigs.sessionId;
- legacy_request->ttl = hidl_request.baseConfigs.ttlSec;
- legacy_request->period = hidl_request.baseConfigs.discoveryWindowPeriod;
- legacy_request->subscribe_count = hidl_request.baseConfigs.discoveryCount;
- legacy_request->service_name_len = hidl_request.baseConfigs.serviceName.size();
- if (legacy_request->service_name_len > NAN_MAX_SERVICE_NAME_LEN) {
- LOG(ERROR) << "convertHidlNanSubscribeRequestToLegacy: service_name_len too large";
- return false;
- }
- memcpy(legacy_request->service_name, hidl_request.baseConfigs.serviceName.data(),
- legacy_request->service_name_len);
- legacy_request->subscribe_match_indicator =
- convertHidlNanMatchAlgToLegacy(hidl_request.baseConfigs.discoveryMatchIndicator);
- legacy_request->service_specific_info_len = hidl_request.baseConfigs.serviceSpecificInfo.size();
- if (legacy_request->service_specific_info_len > NAN_MAX_SERVICE_SPECIFIC_INFO_LEN) {
- LOG(ERROR) << "convertHidlNanSubscribeRequestToLegacy: service_specific_info_len too large";
- return false;
- }
- memcpy(legacy_request->service_specific_info,
- hidl_request.baseConfigs.serviceSpecificInfo.data(),
- legacy_request->service_specific_info_len);
- legacy_request->sdea_service_specific_info_len =
+ legacy_request->subscribe_id = hidl_request.baseConfigs.sessionId;
+ legacy_request->ttl = hidl_request.baseConfigs.ttlSec;
+ legacy_request->period = hidl_request.baseConfigs.discoveryWindowPeriod;
+ legacy_request->subscribe_count = hidl_request.baseConfigs.discoveryCount;
+ legacy_request->service_name_len =
+ hidl_request.baseConfigs.serviceName.size();
+ if (legacy_request->service_name_len > NAN_MAX_SERVICE_NAME_LEN) {
+ LOG(ERROR) << "convertHidlNanSubscribeRequestToLegacy: "
+ "service_name_len too large";
+ return false;
+ }
+ memcpy(legacy_request->service_name,
+ hidl_request.baseConfigs.serviceName.data(),
+ legacy_request->service_name_len);
+ legacy_request->subscribe_match_indicator = convertHidlNanMatchAlgToLegacy(
+ hidl_request.baseConfigs.discoveryMatchIndicator);
+ legacy_request->service_specific_info_len =
+ hidl_request.baseConfigs.serviceSpecificInfo.size();
+ if (legacy_request->service_specific_info_len >
+ NAN_MAX_SERVICE_SPECIFIC_INFO_LEN) {
+ LOG(ERROR) << "convertHidlNanSubscribeRequestToLegacy: "
+ "service_specific_info_len too large";
+ return false;
+ }
+ memcpy(legacy_request->service_specific_info,
+ hidl_request.baseConfigs.serviceSpecificInfo.data(),
+ legacy_request->service_specific_info_len);
+ legacy_request->sdea_service_specific_info_len =
hidl_request.baseConfigs.extendedServiceSpecificInfo.size();
- if (legacy_request->sdea_service_specific_info_len > NAN_MAX_SDEA_SERVICE_SPECIFIC_INFO_LEN) {
- LOG(ERROR) <<
- "convertHidlNanSubscribeRequestToLegacy: sdea_service_specific_info_len too large";
- return false;
- }
- memcpy(legacy_request->sdea_service_specific_info,
- hidl_request.baseConfigs.extendedServiceSpecificInfo.data(),
- legacy_request->sdea_service_specific_info_len);
- legacy_request->rx_match_filter_len = hidl_request.baseConfigs.rxMatchFilter.size();
- if (legacy_request->rx_match_filter_len > NAN_MAX_MATCH_FILTER_LEN) {
- LOG(ERROR) << "convertHidlNanSubscribeRequestToLegacy: rx_match_filter_len too large";
- return false;
- }
- memcpy(legacy_request->rx_match_filter,
- hidl_request.baseConfigs.rxMatchFilter.data(),
- legacy_request->rx_match_filter_len);
- legacy_request->tx_match_filter_len = hidl_request.baseConfigs.txMatchFilter.size();
- if (legacy_request->tx_match_filter_len > NAN_MAX_MATCH_FILTER_LEN) {
- LOG(ERROR) << "convertHidlNanSubscribeRequestToLegacy: tx_match_filter_len too large";
- return false;
- }
- memcpy(legacy_request->tx_match_filter,
- hidl_request.baseConfigs.txMatchFilter.data(),
- legacy_request->tx_match_filter_len);
- legacy_request->rssi_threshold_flag = hidl_request.baseConfigs.useRssiThreshold;
- legacy_request->recv_indication_cfg = 0;
- legacy_request->recv_indication_cfg |=
- hidl_request.baseConfigs.disableDiscoveryTerminationIndication ? 0x1 : 0x0;
- legacy_request->recv_indication_cfg |=
+ if (legacy_request->sdea_service_specific_info_len >
+ NAN_MAX_SDEA_SERVICE_SPECIFIC_INFO_LEN) {
+ LOG(ERROR) << "convertHidlNanSubscribeRequestToLegacy: "
+ "sdea_service_specific_info_len too large";
+ return false;
+ }
+ memcpy(legacy_request->sdea_service_specific_info,
+ hidl_request.baseConfigs.extendedServiceSpecificInfo.data(),
+ legacy_request->sdea_service_specific_info_len);
+ legacy_request->rx_match_filter_len =
+ hidl_request.baseConfigs.rxMatchFilter.size();
+ if (legacy_request->rx_match_filter_len > NAN_MAX_MATCH_FILTER_LEN) {
+ LOG(ERROR) << "convertHidlNanSubscribeRequestToLegacy: "
+ "rx_match_filter_len too large";
+ return false;
+ }
+ memcpy(legacy_request->rx_match_filter,
+ hidl_request.baseConfigs.rxMatchFilter.data(),
+ legacy_request->rx_match_filter_len);
+ legacy_request->tx_match_filter_len =
+ hidl_request.baseConfigs.txMatchFilter.size();
+ if (legacy_request->tx_match_filter_len > NAN_MAX_MATCH_FILTER_LEN) {
+ LOG(ERROR) << "convertHidlNanSubscribeRequestToLegacy: "
+ "tx_match_filter_len too large";
+ return false;
+ }
+ memcpy(legacy_request->tx_match_filter,
+ hidl_request.baseConfigs.txMatchFilter.data(),
+ legacy_request->tx_match_filter_len);
+ legacy_request->rssi_threshold_flag =
+ hidl_request.baseConfigs.useRssiThreshold;
+ legacy_request->recv_indication_cfg = 0;
+ legacy_request->recv_indication_cfg |=
+ hidl_request.baseConfigs.disableDiscoveryTerminationIndication ? 0x1
+ : 0x0;
+ legacy_request->recv_indication_cfg |=
hidl_request.baseConfigs.disableMatchExpirationIndication ? 0x2 : 0x0;
- legacy_request->recv_indication_cfg |=
+ legacy_request->recv_indication_cfg |=
hidl_request.baseConfigs.disableFollowupReceivedIndication ? 0x4 : 0x0;
- legacy_request->cipher_type = (unsigned int) hidl_request.baseConfigs.securityConfig.cipherType;
- if (hidl_request.baseConfigs.securityConfig.securityType == NanDataPathSecurityType::PMK) {
- legacy_request->key_info.key_type = legacy_hal::NAN_SECURITY_KEY_INPUT_PMK;
- legacy_request->key_info.body.pmk_info.pmk_len =
- hidl_request.baseConfigs.securityConfig.pmk.size();
- if (legacy_request->key_info.body.pmk_info.pmk_len != NAN_PMK_INFO_LEN) {
- LOG(ERROR) << "convertHidlNanSubscribeRequestToLegacy: invalid pmk_len";
- return false;
+ legacy_request->cipher_type =
+ (unsigned int)hidl_request.baseConfigs.securityConfig.cipherType;
+ if (hidl_request.baseConfigs.securityConfig.securityType ==
+ NanDataPathSecurityType::PMK) {
+ legacy_request->key_info.key_type =
+ legacy_hal::NAN_SECURITY_KEY_INPUT_PMK;
+ legacy_request->key_info.body.pmk_info.pmk_len =
+ hidl_request.baseConfigs.securityConfig.pmk.size();
+ if (legacy_request->key_info.body.pmk_info.pmk_len !=
+ NAN_PMK_INFO_LEN) {
+ LOG(ERROR)
+ << "convertHidlNanSubscribeRequestToLegacy: invalid pmk_len";
+ return false;
+ }
+ memcpy(legacy_request->key_info.body.pmk_info.pmk,
+ hidl_request.baseConfigs.securityConfig.pmk.data(),
+ legacy_request->key_info.body.pmk_info.pmk_len);
}
- memcpy(legacy_request->key_info.body.pmk_info.pmk,
- hidl_request.baseConfigs.securityConfig.pmk.data(),
- legacy_request->key_info.body.pmk_info.pmk_len);
- }
- if (hidl_request.baseConfigs.securityConfig.securityType == NanDataPathSecurityType::PASSPHRASE) {
- legacy_request->key_info.key_type = legacy_hal::NAN_SECURITY_KEY_INPUT_PASSPHRASE;
- legacy_request->key_info.body.passphrase_info.passphrase_len =
- hidl_request.baseConfigs.securityConfig.passphrase.size();
- if (legacy_request->key_info.body.passphrase_info.passphrase_len
- < NAN_SECURITY_MIN_PASSPHRASE_LEN) {
- LOG(ERROR) << "convertHidlNanSubscribeRequestToLegacy: passphrase_len too small";
- return false;
+ if (hidl_request.baseConfigs.securityConfig.securityType ==
+ NanDataPathSecurityType::PASSPHRASE) {
+ legacy_request->key_info.key_type =
+ legacy_hal::NAN_SECURITY_KEY_INPUT_PASSPHRASE;
+ legacy_request->key_info.body.passphrase_info.passphrase_len =
+ hidl_request.baseConfigs.securityConfig.passphrase.size();
+ if (legacy_request->key_info.body.passphrase_info.passphrase_len <
+ NAN_SECURITY_MIN_PASSPHRASE_LEN) {
+ LOG(ERROR) << "convertHidlNanSubscribeRequestToLegacy: "
+ "passphrase_len too small";
+ return false;
+ }
+ if (legacy_request->key_info.body.passphrase_info.passphrase_len >
+ NAN_SECURITY_MAX_PASSPHRASE_LEN) {
+ LOG(ERROR) << "convertHidlNanSubscribeRequestToLegacy: "
+ "passphrase_len too large";
+ return false;
+ }
+ memcpy(legacy_request->key_info.body.passphrase_info.passphrase,
+ hidl_request.baseConfigs.securityConfig.passphrase.data(),
+ legacy_request->key_info.body.passphrase_info.passphrase_len);
}
- if (legacy_request->key_info.body.passphrase_info.passphrase_len
- > NAN_SECURITY_MAX_PASSPHRASE_LEN) {
- LOG(ERROR) << "convertHidlNanSubscribeRequestToLegacy: passphrase_len too large";
- return false;
- }
- memcpy(legacy_request->key_info.body.passphrase_info.passphrase,
- hidl_request.baseConfigs.securityConfig.passphrase.data(),
- legacy_request->key_info.body.passphrase_info.passphrase_len);
- }
- legacy_request->sdea_params.security_cfg = (hidl_request.baseConfigs.securityConfig.securityType
- != NanDataPathSecurityType::OPEN) ? legacy_hal::NAN_DP_CONFIG_SECURITY
- : legacy_hal::NAN_DP_CONFIG_NO_SECURITY;
- legacy_request->sdea_params.ranging_state = hidl_request.baseConfigs.rangingRequired ?
- legacy_hal::NAN_RANGING_ENABLE : legacy_hal::NAN_RANGING_DISABLE;
- legacy_request->ranging_cfg.ranging_interval_msec = hidl_request.baseConfigs.rangingIntervalMsec;
- legacy_request->ranging_cfg.config_ranging_indications =
+ legacy_request->sdea_params.security_cfg =
+ (hidl_request.baseConfigs.securityConfig.securityType !=
+ NanDataPathSecurityType::OPEN)
+ ? legacy_hal::NAN_DP_CONFIG_SECURITY
+ : legacy_hal::NAN_DP_CONFIG_NO_SECURITY;
+ legacy_request->sdea_params.ranging_state =
+ hidl_request.baseConfigs.rangingRequired
+ ? legacy_hal::NAN_RANGING_ENABLE
+ : legacy_hal::NAN_RANGING_DISABLE;
+ legacy_request->ranging_cfg.ranging_interval_msec =
+ hidl_request.baseConfigs.rangingIntervalMsec;
+ legacy_request->ranging_cfg.config_ranging_indications =
hidl_request.baseConfigs.configRangingIndications;
- legacy_request->ranging_cfg.distance_ingress_cm = hidl_request.baseConfigs.distanceIngressCm;
- legacy_request->ranging_cfg.distance_egress_cm = hidl_request.baseConfigs.distanceEgressCm;
- legacy_request->ranging_auto_response = hidl_request.baseConfigs.rangingRequired ?
- legacy_hal::NAN_RANGING_AUTO_RESPONSE_ENABLE : legacy_hal::NAN_RANGING_AUTO_RESPONSE_DISABLE;
- legacy_request->sdea_params.range_report = legacy_hal::NAN_DISABLE_RANGE_REPORT;
- legacy_request->subscribe_type = convertHidlNanSubscribeTypeToLegacy(hidl_request.subscribeType);
- legacy_request->serviceResponseFilter = convertHidlNanSrfTypeToLegacy(hidl_request.srfType);
- legacy_request->serviceResponseInclude = hidl_request.srfRespondIfInAddressSet ?
- legacy_hal::NAN_SRF_INCLUDE_RESPOND : legacy_hal::NAN_SRF_INCLUDE_DO_NOT_RESPOND;
- legacy_request->useServiceResponseFilter = hidl_request.shouldUseSrf ?
- legacy_hal::NAN_USE_SRF : legacy_hal::NAN_DO_NOT_USE_SRF;
- legacy_request->ssiRequiredForMatchIndication = hidl_request.isSsiRequiredForMatch ?
- legacy_hal::NAN_SSI_REQUIRED_IN_MATCH_IND : legacy_hal::NAN_SSI_NOT_REQUIRED_IN_MATCH_IND;
- legacy_request->num_intf_addr_present = hidl_request.intfAddr.size();
- if (legacy_request->num_intf_addr_present > NAN_MAX_SUBSCRIBE_MAX_ADDRESS) {
- LOG(ERROR) << "convertHidlNanSubscribeRequestToLegacy: num_intf_addr_present - too many";
- return false;
- }
- for (int i = 0; i < legacy_request->num_intf_addr_present; i++) {
- memcpy(legacy_request->intf_addr[i], hidl_request.intfAddr[i].data(), 6);
- }
+ legacy_request->ranging_cfg.distance_ingress_cm =
+ hidl_request.baseConfigs.distanceIngressCm;
+ legacy_request->ranging_cfg.distance_egress_cm =
+ hidl_request.baseConfigs.distanceEgressCm;
+ legacy_request->ranging_auto_response =
+ hidl_request.baseConfigs.rangingRequired
+ ? legacy_hal::NAN_RANGING_AUTO_RESPONSE_ENABLE
+ : legacy_hal::NAN_RANGING_AUTO_RESPONSE_DISABLE;
+ legacy_request->sdea_params.range_report =
+ legacy_hal::NAN_DISABLE_RANGE_REPORT;
+ legacy_request->subscribe_type =
+ convertHidlNanSubscribeTypeToLegacy(hidl_request.subscribeType);
+ legacy_request->serviceResponseFilter =
+ convertHidlNanSrfTypeToLegacy(hidl_request.srfType);
+ legacy_request->serviceResponseInclude =
+ hidl_request.srfRespondIfInAddressSet
+ ? legacy_hal::NAN_SRF_INCLUDE_RESPOND
+ : legacy_hal::NAN_SRF_INCLUDE_DO_NOT_RESPOND;
+ legacy_request->useServiceResponseFilter =
+ hidl_request.shouldUseSrf ? legacy_hal::NAN_USE_SRF
+ : legacy_hal::NAN_DO_NOT_USE_SRF;
+ legacy_request->ssiRequiredForMatchIndication =
+ hidl_request.isSsiRequiredForMatch
+ ? legacy_hal::NAN_SSI_REQUIRED_IN_MATCH_IND
+ : legacy_hal::NAN_SSI_NOT_REQUIRED_IN_MATCH_IND;
+ legacy_request->num_intf_addr_present = hidl_request.intfAddr.size();
+ if (legacy_request->num_intf_addr_present > NAN_MAX_SUBSCRIBE_MAX_ADDRESS) {
+ LOG(ERROR) << "convertHidlNanSubscribeRequestToLegacy: "
+ "num_intf_addr_present - too many";
+ return false;
+ }
+ for (int i = 0; i < legacy_request->num_intf_addr_present; i++) {
+ memcpy(legacy_request->intf_addr[i], hidl_request.intfAddr[i].data(),
+ 6);
+ }
- return true;
+ return true;
}
bool convertHidlNanTransmitFollowupRequestToLegacy(
const NanTransmitFollowupRequest& hidl_request,
legacy_hal::NanTransmitFollowupRequest* legacy_request) {
- if (!legacy_request) {
- LOG(ERROR) << "convertHidlNanTransmitFollowupRequestToLegacy: legacy_request is null";
- return false;
- }
- *legacy_request = {};
+ if (!legacy_request) {
+ LOG(ERROR) << "convertHidlNanTransmitFollowupRequestToLegacy: "
+ "legacy_request is null";
+ return false;
+ }
+ *legacy_request = {};
- legacy_request->publish_subscribe_id = hidl_request.discoverySessionId;
- legacy_request->requestor_instance_id = hidl_request.peerId;
- memcpy(legacy_request->addr, hidl_request.addr.data(), 6);
- legacy_request->priority = hidl_request.isHighPriority ?
- legacy_hal::NAN_TX_PRIORITY_HIGH : legacy_hal::NAN_TX_PRIORITY_NORMAL;
- legacy_request->dw_or_faw = hidl_request.shouldUseDiscoveryWindow ?
- legacy_hal::NAN_TRANSMIT_IN_DW : legacy_hal::NAN_TRANSMIT_IN_FAW;
- legacy_request->service_specific_info_len = hidl_request.serviceSpecificInfo.size();
- if (legacy_request->service_specific_info_len > NAN_MAX_SERVICE_SPECIFIC_INFO_LEN) {
- LOG(ERROR) <<
- "convertHidlNanTransmitFollowupRequestToLegacy: service_specific_info_len too large";
- return false;
- }
- memcpy(legacy_request->service_specific_info,
- hidl_request.serviceSpecificInfo.data(),
- legacy_request->service_specific_info_len);
- legacy_request->sdea_service_specific_info_len = hidl_request.extendedServiceSpecificInfo.size();
- if (legacy_request->sdea_service_specific_info_len > NAN_MAX_SDEA_SERVICE_SPECIFIC_INFO_LEN) {
- LOG(ERROR) <<
- "convertHidlNanTransmitFollowupRequestToLegacy: sdea_service_specific_info_len too large";
- return false;
- }
- memcpy(legacy_request->sdea_service_specific_info,
- hidl_request.extendedServiceSpecificInfo.data(),
- legacy_request->sdea_service_specific_info_len);
- legacy_request->recv_indication_cfg = hidl_request.disableFollowupResultIndication ? 0x1 : 0x0;
+ legacy_request->publish_subscribe_id = hidl_request.discoverySessionId;
+ legacy_request->requestor_instance_id = hidl_request.peerId;
+ memcpy(legacy_request->addr, hidl_request.addr.data(), 6);
+ legacy_request->priority = hidl_request.isHighPriority
+ ? legacy_hal::NAN_TX_PRIORITY_HIGH
+ : legacy_hal::NAN_TX_PRIORITY_NORMAL;
+ legacy_request->dw_or_faw = hidl_request.shouldUseDiscoveryWindow
+ ? legacy_hal::NAN_TRANSMIT_IN_DW
+ : legacy_hal::NAN_TRANSMIT_IN_FAW;
+ legacy_request->service_specific_info_len =
+ hidl_request.serviceSpecificInfo.size();
+ if (legacy_request->service_specific_info_len >
+ NAN_MAX_SERVICE_SPECIFIC_INFO_LEN) {
+ LOG(ERROR) << "convertHidlNanTransmitFollowupRequestToLegacy: "
+ "service_specific_info_len too large";
+ return false;
+ }
+ memcpy(legacy_request->service_specific_info,
+ hidl_request.serviceSpecificInfo.data(),
+ legacy_request->service_specific_info_len);
+ legacy_request->sdea_service_specific_info_len =
+ hidl_request.extendedServiceSpecificInfo.size();
+ if (legacy_request->sdea_service_specific_info_len >
+ NAN_MAX_SDEA_SERVICE_SPECIFIC_INFO_LEN) {
+ LOG(ERROR) << "convertHidlNanTransmitFollowupRequestToLegacy: "
+ "sdea_service_specific_info_len too large";
+ return false;
+ }
+ memcpy(legacy_request->sdea_service_specific_info,
+ hidl_request.extendedServiceSpecificInfo.data(),
+ legacy_request->sdea_service_specific_info_len);
+ legacy_request->recv_indication_cfg =
+ hidl_request.disableFollowupResultIndication ? 0x1 : 0x0;
- return true;
+ return true;
}
bool convertHidlNanConfigRequestToLegacy(
const NanConfigRequest& hidl_request,
legacy_hal::NanConfigRequest* legacy_request) {
- if (!legacy_request) {
- LOG(ERROR) << "convertHidlNanConfigRequestToLegacy: legacy_request is null";
- return false;
- }
- *legacy_request = {};
+ if (!legacy_request) {
+ LOG(ERROR)
+ << "convertHidlNanConfigRequestToLegacy: legacy_request is null";
+ return false;
+ }
+ *legacy_request = {};
- // TODO: b/34059183 tracks missing configurations in legacy HAL or uknown defaults
- legacy_request->master_pref = hidl_request.masterPref;
- legacy_request->discovery_indication_cfg = 0;
- legacy_request->discovery_indication_cfg |=
+ // TODO: b/34059183 tracks missing configurations in legacy HAL or uknown
+ // defaults
+ legacy_request->master_pref = hidl_request.masterPref;
+ legacy_request->discovery_indication_cfg = 0;
+ legacy_request->discovery_indication_cfg |=
hidl_request.disableDiscoveryAddressChangeIndication ? 0x1 : 0x0;
- legacy_request->discovery_indication_cfg |=
+ legacy_request->discovery_indication_cfg |=
hidl_request.disableStartedClusterIndication ? 0x2 : 0x0;
- legacy_request->discovery_indication_cfg |=
+ legacy_request->discovery_indication_cfg |=
hidl_request.disableJoinedClusterIndication ? 0x4 : 0x0;
- legacy_request->config_sid_beacon = 1;
- if (hidl_request.numberOfPublishServiceIdsInBeacon > 127) {
- LOG(ERROR) << "convertHidlNanConfigRequestToLegacy: numberOfPublishServiceIdsInBeacon > 127";
- return false;
- }
- legacy_request->sid_beacon = (hidl_request.includePublishServiceIdsInBeacon ? 0x1 : 0x0)
- | (hidl_request.numberOfPublishServiceIdsInBeacon << 1);
- legacy_request->config_subscribe_sid_beacon = 1;
- if (hidl_request.numberOfSubscribeServiceIdsInBeacon > 127) {
- LOG(ERROR) << "convertHidlNanConfigRequestToLegacy: numberOfSubscribeServiceIdsInBeacon > 127";
- return false;
- }
- legacy_request->subscribe_sid_beacon_val =
- (hidl_request.includeSubscribeServiceIdsInBeacon ? 0x1 : 0x0)
- | (hidl_request.numberOfSubscribeServiceIdsInBeacon << 1);
- legacy_request->config_rssi_window_size = 1;
- legacy_request->rssi_window_size_val = hidl_request.rssiWindowSize;
- legacy_request->config_disc_mac_addr_randomization = 1;
- legacy_request->disc_mac_addr_rand_interval_sec =
+ legacy_request->config_sid_beacon = 1;
+ if (hidl_request.numberOfPublishServiceIdsInBeacon > 127) {
+ LOG(ERROR) << "convertHidlNanConfigRequestToLegacy: "
+ "numberOfPublishServiceIdsInBeacon > 127";
+ return false;
+ }
+ legacy_request->sid_beacon =
+ (hidl_request.includePublishServiceIdsInBeacon ? 0x1 : 0x0) |
+ (hidl_request.numberOfPublishServiceIdsInBeacon << 1);
+ legacy_request->config_subscribe_sid_beacon = 1;
+ if (hidl_request.numberOfSubscribeServiceIdsInBeacon > 127) {
+ LOG(ERROR) << "convertHidlNanConfigRequestToLegacy: "
+ "numberOfSubscribeServiceIdsInBeacon > 127";
+ return false;
+ }
+ legacy_request->subscribe_sid_beacon_val =
+ (hidl_request.includeSubscribeServiceIdsInBeacon ? 0x1 : 0x0) |
+ (hidl_request.numberOfSubscribeServiceIdsInBeacon << 1);
+ legacy_request->config_rssi_window_size = 1;
+ legacy_request->rssi_window_size_val = hidl_request.rssiWindowSize;
+ legacy_request->config_disc_mac_addr_randomization = 1;
+ legacy_request->disc_mac_addr_rand_interval_sec =
hidl_request.macAddressRandomizationIntervalSec;
- /* TODO : missing
- legacy_request->config_2dot4g_rssi_close = 1;
- legacy_request->rssi_close_2dot4g_val =
- hidl_request.bandSpecificConfig[
- (size_t) NanBandIndex::NAN_BAND_24GHZ].rssiClose;
- legacy_request->config_2dot4g_rssi_middle = 1;
- legacy_request->rssi_middle_2dot4g_val =
- hidl_request.bandSpecificConfig[
- (size_t) NanBandIndex::NAN_BAND_24GHZ].rssiMiddle;
- legacy_request->config_2dot4g_rssi_proximity = 1;
- legacy_request->rssi_proximity_2dot4g_val =
- hidl_request.bandSpecificConfig[
- (size_t) NanBandIndex::NAN_BAND_24GHZ].rssiCloseProximity;
- */
- legacy_request->config_scan_params = 1;
- legacy_request->scan_params_val.dwell_time[legacy_hal::NAN_CHANNEL_24G_BAND] =
- hidl_request.bandSpecificConfig[
- (size_t) NanBandIndex::NAN_BAND_24GHZ].dwellTimeMs;
- legacy_request->scan_params_val.scan_period[legacy_hal::NAN_CHANNEL_24G_BAND] =
- hidl_request.bandSpecificConfig[
- (size_t) NanBandIndex::NAN_BAND_24GHZ].scanPeriodSec;
- legacy_request->config_dw.config_2dot4g_dw_band = hidl_request
- .bandSpecificConfig[(size_t) NanBandIndex::NAN_BAND_24GHZ].validDiscoveryWindowIntervalVal;
- legacy_request->config_dw.dw_2dot4g_interval_val = hidl_request
- .bandSpecificConfig[(size_t) NanBandIndex::NAN_BAND_24GHZ].discoveryWindowIntervalVal;
- /* TODO: missing
- legacy_request->config_5g_rssi_close = 1;
- legacy_request->rssi_close_5g_val =
- hidl_request.bandSpecificConfig[
- (size_t) NanBandIndex::NAN_BAND_5GHZ].rssiClose;
- legacy_request->config_5g_rssi_middle = 1;
- legacy_request->rssi_middle_5g_val =
- hidl_request.bandSpecificConfig[
- (size_t) NanBandIndex::NAN_BAND_5GHZ].rssiMiddle;
- */
- legacy_request->config_5g_rssi_close_proximity = 1;
- legacy_request->rssi_close_proximity_5g_val =
- hidl_request.bandSpecificConfig[
- (size_t) NanBandIndex::NAN_BAND_5GHZ].rssiCloseProximity;
- legacy_request->scan_params_val.dwell_time[legacy_hal::NAN_CHANNEL_5G_BAND_LOW] =
- hidl_request.bandSpecificConfig[
- (size_t) NanBandIndex::NAN_BAND_5GHZ].dwellTimeMs;
- legacy_request->scan_params_val.scan_period[legacy_hal::NAN_CHANNEL_5G_BAND_LOW] =
- hidl_request.bandSpecificConfig[
- (size_t) NanBandIndex::NAN_BAND_5GHZ].scanPeriodSec;
- legacy_request->scan_params_val.dwell_time[legacy_hal::NAN_CHANNEL_5G_BAND_HIGH] =
- hidl_request.bandSpecificConfig[
- (size_t) NanBandIndex::NAN_BAND_5GHZ].dwellTimeMs;
- legacy_request->scan_params_val.scan_period[legacy_hal::NAN_CHANNEL_5G_BAND_HIGH] =
- hidl_request.bandSpecificConfig[
- (size_t) NanBandIndex::NAN_BAND_5GHZ].scanPeriodSec;
- legacy_request->config_dw.config_5g_dw_band = hidl_request
- .bandSpecificConfig[(size_t) NanBandIndex::NAN_BAND_5GHZ].validDiscoveryWindowIntervalVal;
- legacy_request->config_dw.dw_5g_interval_val = hidl_request
- .bandSpecificConfig[(size_t) NanBandIndex::NAN_BAND_5GHZ].discoveryWindowIntervalVal;
+ /* TODO : missing
+ legacy_request->config_2dot4g_rssi_close = 1;
+ legacy_request->rssi_close_2dot4g_val =
+ hidl_request.bandSpecificConfig[
+ (size_t) NanBandIndex::NAN_BAND_24GHZ].rssiClose;
+ legacy_request->config_2dot4g_rssi_middle = 1;
+ legacy_request->rssi_middle_2dot4g_val =
+ hidl_request.bandSpecificConfig[
+ (size_t) NanBandIndex::NAN_BAND_24GHZ].rssiMiddle;
+ legacy_request->config_2dot4g_rssi_proximity = 1;
+ legacy_request->rssi_proximity_2dot4g_val =
+ hidl_request.bandSpecificConfig[
+ (size_t) NanBandIndex::NAN_BAND_24GHZ].rssiCloseProximity;
+ */
+ legacy_request->config_scan_params = 1;
+ legacy_request->scan_params_val
+ .dwell_time[legacy_hal::NAN_CHANNEL_24G_BAND] =
+ hidl_request.bandSpecificConfig[(size_t)NanBandIndex::NAN_BAND_24GHZ]
+ .dwellTimeMs;
+ legacy_request->scan_params_val
+ .scan_period[legacy_hal::NAN_CHANNEL_24G_BAND] =
+ hidl_request.bandSpecificConfig[(size_t)NanBandIndex::NAN_BAND_24GHZ]
+ .scanPeriodSec;
+ legacy_request->config_dw.config_2dot4g_dw_band =
+ hidl_request.bandSpecificConfig[(size_t)NanBandIndex::NAN_BAND_24GHZ]
+ .validDiscoveryWindowIntervalVal;
+ legacy_request->config_dw.dw_2dot4g_interval_val =
+ hidl_request.bandSpecificConfig[(size_t)NanBandIndex::NAN_BAND_24GHZ]
+ .discoveryWindowIntervalVal;
+ /* TODO: missing
+ legacy_request->config_5g_rssi_close = 1;
+ legacy_request->rssi_close_5g_val =
+ hidl_request.bandSpecificConfig[
+ (size_t) NanBandIndex::NAN_BAND_5GHZ].rssiClose;
+ legacy_request->config_5g_rssi_middle = 1;
+ legacy_request->rssi_middle_5g_val =
+ hidl_request.bandSpecificConfig[
+ (size_t) NanBandIndex::NAN_BAND_5GHZ].rssiMiddle;
+ */
+ legacy_request->config_5g_rssi_close_proximity = 1;
+ legacy_request->rssi_close_proximity_5g_val =
+ hidl_request.bandSpecificConfig[(size_t)NanBandIndex::NAN_BAND_5GHZ]
+ .rssiCloseProximity;
+ legacy_request->scan_params_val
+ .dwell_time[legacy_hal::NAN_CHANNEL_5G_BAND_LOW] =
+ hidl_request.bandSpecificConfig[(size_t)NanBandIndex::NAN_BAND_5GHZ]
+ .dwellTimeMs;
+ legacy_request->scan_params_val
+ .scan_period[legacy_hal::NAN_CHANNEL_5G_BAND_LOW] =
+ hidl_request.bandSpecificConfig[(size_t)NanBandIndex::NAN_BAND_5GHZ]
+ .scanPeriodSec;
+ legacy_request->scan_params_val
+ .dwell_time[legacy_hal::NAN_CHANNEL_5G_BAND_HIGH] =
+ hidl_request.bandSpecificConfig[(size_t)NanBandIndex::NAN_BAND_5GHZ]
+ .dwellTimeMs;
+ legacy_request->scan_params_val
+ .scan_period[legacy_hal::NAN_CHANNEL_5G_BAND_HIGH] =
+ hidl_request.bandSpecificConfig[(size_t)NanBandIndex::NAN_BAND_5GHZ]
+ .scanPeriodSec;
+ legacy_request->config_dw.config_5g_dw_band =
+ hidl_request.bandSpecificConfig[(size_t)NanBandIndex::NAN_BAND_5GHZ]
+ .validDiscoveryWindowIntervalVal;
+ legacy_request->config_dw.dw_5g_interval_val =
+ hidl_request.bandSpecificConfig[(size_t)NanBandIndex::NAN_BAND_5GHZ]
+ .discoveryWindowIntervalVal;
- return true;
+ return true;
}
bool convertHidlNanDataPathInitiatorRequestToLegacy(
const NanInitiateDataPathRequest& hidl_request,
legacy_hal::NanDataPathInitiatorRequest* legacy_request) {
- if (!legacy_request) {
- LOG(ERROR) << "convertHidlNanDataPathInitiatorRequestToLegacy: legacy_request is null";
- return false;
- }
- *legacy_request = {};
+ if (!legacy_request) {
+ LOG(ERROR) << "convertHidlNanDataPathInitiatorRequestToLegacy: "
+ "legacy_request is null";
+ return false;
+ }
+ *legacy_request = {};
- legacy_request->requestor_instance_id = hidl_request.peerId;
- memcpy(legacy_request->peer_disc_mac_addr, hidl_request.peerDiscMacAddr.data(), 6);
- legacy_request->channel_request_type =
- convertHidlNanDataPathChannelCfgToLegacy(hidl_request.channelRequestType);
- legacy_request->channel = hidl_request.channel;
- strcpy(legacy_request->ndp_iface, hidl_request.ifaceName.c_str());
- legacy_request->ndp_cfg.security_cfg = (hidl_request.securityConfig.securityType
- != NanDataPathSecurityType::OPEN) ? legacy_hal::NAN_DP_CONFIG_SECURITY
+ legacy_request->requestor_instance_id = hidl_request.peerId;
+ memcpy(legacy_request->peer_disc_mac_addr,
+ hidl_request.peerDiscMacAddr.data(), 6);
+ legacy_request->channel_request_type =
+ convertHidlNanDataPathChannelCfgToLegacy(
+ hidl_request.channelRequestType);
+ legacy_request->channel = hidl_request.channel;
+ strcpy(legacy_request->ndp_iface, hidl_request.ifaceName.c_str());
+ legacy_request->ndp_cfg.security_cfg =
+ (hidl_request.securityConfig.securityType !=
+ NanDataPathSecurityType::OPEN)
+ ? legacy_hal::NAN_DP_CONFIG_SECURITY
: legacy_hal::NAN_DP_CONFIG_NO_SECURITY;
- legacy_request->app_info.ndp_app_info_len = hidl_request.appInfo.size();
- if (legacy_request->app_info.ndp_app_info_len > NAN_DP_MAX_APP_INFO_LEN) {
- LOG(ERROR) << "convertHidlNanDataPathInitiatorRequestToLegacy: ndp_app_info_len too large";
- return false;
- }
- memcpy(legacy_request->app_info.ndp_app_info, hidl_request.appInfo.data(),
- legacy_request->app_info.ndp_app_info_len);
- legacy_request->cipher_type = (unsigned int) hidl_request.securityConfig.cipherType;
- if (hidl_request.securityConfig.securityType == NanDataPathSecurityType::PMK) {
- legacy_request->key_info.key_type = legacy_hal::NAN_SECURITY_KEY_INPUT_PMK;
- legacy_request->key_info.body.pmk_info.pmk_len = hidl_request.securityConfig.pmk.size();
- if (legacy_request->key_info.body.pmk_info.pmk_len != NAN_PMK_INFO_LEN) {
- LOG(ERROR) << "convertHidlNanDataPathInitiatorRequestToLegacy: invalid pmk_len";
- return false;
+ legacy_request->app_info.ndp_app_info_len = hidl_request.appInfo.size();
+ if (legacy_request->app_info.ndp_app_info_len > NAN_DP_MAX_APP_INFO_LEN) {
+ LOG(ERROR) << "convertHidlNanDataPathInitiatorRequestToLegacy: "
+ "ndp_app_info_len too large";
+ return false;
}
- memcpy(legacy_request->key_info.body.pmk_info.pmk,
- hidl_request.securityConfig.pmk.data(),
- legacy_request->key_info.body.pmk_info.pmk_len);
- }
- if (hidl_request.securityConfig.securityType == NanDataPathSecurityType::PASSPHRASE) {
- legacy_request->key_info.key_type = legacy_hal::NAN_SECURITY_KEY_INPUT_PASSPHRASE;
- legacy_request->key_info.body.passphrase_info.passphrase_len =
- hidl_request.securityConfig.passphrase.size();
- if (legacy_request->key_info.body.passphrase_info.passphrase_len
- < NAN_SECURITY_MIN_PASSPHRASE_LEN) {
- LOG(ERROR) << "convertHidlNanDataPathInitiatorRequestToLegacy: passphrase_len too small";
- return false;
+ memcpy(legacy_request->app_info.ndp_app_info, hidl_request.appInfo.data(),
+ legacy_request->app_info.ndp_app_info_len);
+ legacy_request->cipher_type =
+ (unsigned int)hidl_request.securityConfig.cipherType;
+ if (hidl_request.securityConfig.securityType ==
+ NanDataPathSecurityType::PMK) {
+ legacy_request->key_info.key_type =
+ legacy_hal::NAN_SECURITY_KEY_INPUT_PMK;
+ legacy_request->key_info.body.pmk_info.pmk_len =
+ hidl_request.securityConfig.pmk.size();
+ if (legacy_request->key_info.body.pmk_info.pmk_len !=
+ NAN_PMK_INFO_LEN) {
+ LOG(ERROR) << "convertHidlNanDataPathInitiatorRequestToLegacy: "
+ "invalid pmk_len";
+ return false;
+ }
+ memcpy(legacy_request->key_info.body.pmk_info.pmk,
+ hidl_request.securityConfig.pmk.data(),
+ legacy_request->key_info.body.pmk_info.pmk_len);
}
- if (legacy_request->key_info.body.passphrase_info.passphrase_len
- > NAN_SECURITY_MAX_PASSPHRASE_LEN) {
- LOG(ERROR) << "convertHidlNanDataPathInitiatorRequestToLegacy: passphrase_len too large";
- return false;
+ if (hidl_request.securityConfig.securityType ==
+ NanDataPathSecurityType::PASSPHRASE) {
+ legacy_request->key_info.key_type =
+ legacy_hal::NAN_SECURITY_KEY_INPUT_PASSPHRASE;
+ legacy_request->key_info.body.passphrase_info.passphrase_len =
+ hidl_request.securityConfig.passphrase.size();
+ if (legacy_request->key_info.body.passphrase_info.passphrase_len <
+ NAN_SECURITY_MIN_PASSPHRASE_LEN) {
+ LOG(ERROR) << "convertHidlNanDataPathInitiatorRequestToLegacy: "
+ "passphrase_len too small";
+ return false;
+ }
+ if (legacy_request->key_info.body.passphrase_info.passphrase_len >
+ NAN_SECURITY_MAX_PASSPHRASE_LEN) {
+ LOG(ERROR) << "convertHidlNanDataPathInitiatorRequestToLegacy: "
+ "passphrase_len too large";
+ return false;
+ }
+ memcpy(legacy_request->key_info.body.passphrase_info.passphrase,
+ hidl_request.securityConfig.passphrase.data(),
+ legacy_request->key_info.body.passphrase_info.passphrase_len);
}
- memcpy(legacy_request->key_info.body.passphrase_info.passphrase,
- hidl_request.securityConfig.passphrase.data(),
- legacy_request->key_info.body.passphrase_info.passphrase_len);
- }
- legacy_request->service_name_len = hidl_request.serviceNameOutOfBand.size();
- if (legacy_request->service_name_len > NAN_MAX_SERVICE_NAME_LEN) {
- LOG(ERROR) << "convertHidlNanDataPathInitiatorRequestToLegacy: service_name_len too large";
- return false;
- }
- memcpy(legacy_request->service_name, hidl_request.serviceNameOutOfBand.data(),
- legacy_request->service_name_len);
+ legacy_request->service_name_len = hidl_request.serviceNameOutOfBand.size();
+ if (legacy_request->service_name_len > NAN_MAX_SERVICE_NAME_LEN) {
+ LOG(ERROR) << "convertHidlNanDataPathInitiatorRequestToLegacy: "
+ "service_name_len too large";
+ return false;
+ }
+ memcpy(legacy_request->service_name,
+ hidl_request.serviceNameOutOfBand.data(),
+ legacy_request->service_name_len);
- return true;
+ return true;
}
bool convertHidlNanDataPathIndicationResponseToLegacy(
const NanRespondToDataPathIndicationRequest& hidl_request,
legacy_hal::NanDataPathIndicationResponse* legacy_request) {
- if (!legacy_request) {
- LOG(ERROR) << "convertHidlNanDataPathIndicationResponseToLegacy: legacy_request is null";
- return false;
- }
- *legacy_request = {};
+ if (!legacy_request) {
+ LOG(ERROR) << "convertHidlNanDataPathIndicationResponseToLegacy: "
+ "legacy_request is null";
+ return false;
+ }
+ *legacy_request = {};
- legacy_request->rsp_code = hidl_request.acceptRequest ?
- legacy_hal::NAN_DP_REQUEST_ACCEPT : legacy_hal::NAN_DP_REQUEST_REJECT;
- legacy_request->ndp_instance_id = hidl_request.ndpInstanceId;
- strcpy(legacy_request->ndp_iface, hidl_request.ifaceName.c_str());
- legacy_request->ndp_cfg.security_cfg = (hidl_request.securityConfig.securityType
- != NanDataPathSecurityType::OPEN) ? legacy_hal::NAN_DP_CONFIG_SECURITY
+ legacy_request->rsp_code = hidl_request.acceptRequest
+ ? legacy_hal::NAN_DP_REQUEST_ACCEPT
+ : legacy_hal::NAN_DP_REQUEST_REJECT;
+ legacy_request->ndp_instance_id = hidl_request.ndpInstanceId;
+ strcpy(legacy_request->ndp_iface, hidl_request.ifaceName.c_str());
+ legacy_request->ndp_cfg.security_cfg =
+ (hidl_request.securityConfig.securityType !=
+ NanDataPathSecurityType::OPEN)
+ ? legacy_hal::NAN_DP_CONFIG_SECURITY
: legacy_hal::NAN_DP_CONFIG_NO_SECURITY;
- legacy_request->app_info.ndp_app_info_len = hidl_request.appInfo.size();
- if (legacy_request->app_info.ndp_app_info_len > NAN_DP_MAX_APP_INFO_LEN) {
- LOG(ERROR) << "convertHidlNanDataPathIndicationResponseToLegacy: ndp_app_info_len too large";
- return false;
- }
- memcpy(legacy_request->app_info.ndp_app_info, hidl_request.appInfo.data(),
- legacy_request->app_info.ndp_app_info_len);
- legacy_request->cipher_type = (unsigned int) hidl_request.securityConfig.cipherType;
- if (hidl_request.securityConfig.securityType == NanDataPathSecurityType::PMK) {
- legacy_request->key_info.key_type = legacy_hal::NAN_SECURITY_KEY_INPUT_PMK;
- legacy_request->key_info.body.pmk_info.pmk_len = hidl_request.securityConfig.pmk.size();
- if (legacy_request->key_info.body.pmk_info.pmk_len != NAN_PMK_INFO_LEN) {
- LOG(ERROR) << "convertHidlNanDataPathIndicationResponseToLegacy: invalid pmk_len";
- return false;
+ legacy_request->app_info.ndp_app_info_len = hidl_request.appInfo.size();
+ if (legacy_request->app_info.ndp_app_info_len > NAN_DP_MAX_APP_INFO_LEN) {
+ LOG(ERROR) << "convertHidlNanDataPathIndicationResponseToLegacy: "
+ "ndp_app_info_len too large";
+ return false;
}
- memcpy(legacy_request->key_info.body.pmk_info.pmk,
- hidl_request.securityConfig.pmk.data(),
- legacy_request->key_info.body.pmk_info.pmk_len);
- }
- if (hidl_request.securityConfig.securityType == NanDataPathSecurityType::PASSPHRASE) {
- legacy_request->key_info.key_type = legacy_hal::NAN_SECURITY_KEY_INPUT_PASSPHRASE;
- legacy_request->key_info.body.passphrase_info.passphrase_len =
- hidl_request.securityConfig.passphrase.size();
- if (legacy_request->key_info.body.passphrase_info.passphrase_len
- < NAN_SECURITY_MIN_PASSPHRASE_LEN) {
- LOG(ERROR) << "convertHidlNanDataPathIndicationResponseToLegacy: passphrase_len too small";
- return false;
+ memcpy(legacy_request->app_info.ndp_app_info, hidl_request.appInfo.data(),
+ legacy_request->app_info.ndp_app_info_len);
+ legacy_request->cipher_type =
+ (unsigned int)hidl_request.securityConfig.cipherType;
+ if (hidl_request.securityConfig.securityType ==
+ NanDataPathSecurityType::PMK) {
+ legacy_request->key_info.key_type =
+ legacy_hal::NAN_SECURITY_KEY_INPUT_PMK;
+ legacy_request->key_info.body.pmk_info.pmk_len =
+ hidl_request.securityConfig.pmk.size();
+ if (legacy_request->key_info.body.pmk_info.pmk_len !=
+ NAN_PMK_INFO_LEN) {
+ LOG(ERROR) << "convertHidlNanDataPathIndicationResponseToLegacy: "
+ "invalid pmk_len";
+ return false;
+ }
+ memcpy(legacy_request->key_info.body.pmk_info.pmk,
+ hidl_request.securityConfig.pmk.data(),
+ legacy_request->key_info.body.pmk_info.pmk_len);
}
- if (legacy_request->key_info.body.passphrase_info.passphrase_len
- > NAN_SECURITY_MAX_PASSPHRASE_LEN) {
- LOG(ERROR) << "convertHidlNanDataPathIndicationResponseToLegacy: passphrase_len too large";
- return false;
+ if (hidl_request.securityConfig.securityType ==
+ NanDataPathSecurityType::PASSPHRASE) {
+ legacy_request->key_info.key_type =
+ legacy_hal::NAN_SECURITY_KEY_INPUT_PASSPHRASE;
+ legacy_request->key_info.body.passphrase_info.passphrase_len =
+ hidl_request.securityConfig.passphrase.size();
+ if (legacy_request->key_info.body.passphrase_info.passphrase_len <
+ NAN_SECURITY_MIN_PASSPHRASE_LEN) {
+ LOG(ERROR) << "convertHidlNanDataPathIndicationResponseToLegacy: "
+ "passphrase_len too small";
+ return false;
+ }
+ if (legacy_request->key_info.body.passphrase_info.passphrase_len >
+ NAN_SECURITY_MAX_PASSPHRASE_LEN) {
+ LOG(ERROR) << "convertHidlNanDataPathIndicationResponseToLegacy: "
+ "passphrase_len too large";
+ return false;
+ }
+ memcpy(legacy_request->key_info.body.passphrase_info.passphrase,
+ hidl_request.securityConfig.passphrase.data(),
+ legacy_request->key_info.body.passphrase_info.passphrase_len);
}
- memcpy(legacy_request->key_info.body.passphrase_info.passphrase,
- hidl_request.securityConfig.passphrase.data(),
- legacy_request->key_info.body.passphrase_info.passphrase_len);
- }
- legacy_request->service_name_len = hidl_request.serviceNameOutOfBand.size();
- if (legacy_request->service_name_len > NAN_MAX_SERVICE_NAME_LEN) {
- LOG(ERROR) << "convertHidlNanDataPathIndicationResponseToLegacy: service_name_len too large";
- return false;
- }
- memcpy(legacy_request->service_name, hidl_request.serviceNameOutOfBand.data(),
- legacy_request->service_name_len);
+ legacy_request->service_name_len = hidl_request.serviceNameOutOfBand.size();
+ if (legacy_request->service_name_len > NAN_MAX_SERVICE_NAME_LEN) {
+ LOG(ERROR) << "convertHidlNanDataPathIndicationResponseToLegacy: "
+ "service_name_len too large";
+ return false;
+ }
+ memcpy(legacy_request->service_name,
+ hidl_request.serviceNameOutOfBand.data(),
+ legacy_request->service_name_len);
- return true;
+ return true;
}
bool convertLegacyNanResponseHeaderToHidl(
const legacy_hal::NanResponseMsg& legacy_response,
WifiNanStatus* wifiNanStatus) {
- if (!wifiNanStatus) {
- LOG(ERROR) << "convertLegacyNanResponseHeaderToHidl: wifiNanStatus is null";
- return false;
- }
- *wifiNanStatus = {};
+ if (!wifiNanStatus) {
+ LOG(ERROR)
+ << "convertLegacyNanResponseHeaderToHidl: wifiNanStatus is null";
+ return false;
+ }
+ *wifiNanStatus = {};
- convertToWifiNanStatus(legacy_response.status, legacy_response.nan_error,
- sizeof(legacy_response.nan_error), wifiNanStatus);
- return true;
+ convertToWifiNanStatus(legacy_response.status, legacy_response.nan_error,
+ sizeof(legacy_response.nan_error), wifiNanStatus);
+ return true;
}
bool convertLegacyNanCapabilitiesResponseToHidl(
const legacy_hal::NanCapabilities& legacy_response,
NanCapabilities* hidl_response) {
- if (!hidl_response) {
- LOG(ERROR) << "convertLegacyNanCapabilitiesResponseToHidl: hidl_response is null";
- return false;
- }
- *hidl_response = {};
+ if (!hidl_response) {
+ LOG(ERROR) << "convertLegacyNanCapabilitiesResponseToHidl: "
+ "hidl_response is null";
+ return false;
+ }
+ *hidl_response = {};
- hidl_response->maxConcurrentClusters = legacy_response.max_concurrent_nan_clusters;
- hidl_response->maxPublishes = legacy_response.max_publishes;
- hidl_response->maxSubscribes = legacy_response.max_subscribes;
- hidl_response->maxServiceNameLen = legacy_response.max_service_name_len;
- hidl_response->maxMatchFilterLen = legacy_response.max_match_filter_len;
- hidl_response->maxTotalMatchFilterLen = legacy_response.max_total_match_filter_len;
- hidl_response->maxServiceSpecificInfoLen = legacy_response.max_service_specific_info_len;
- hidl_response->maxExtendedServiceSpecificInfoLen =
- legacy_response.max_sdea_service_specific_info_len;
- hidl_response->maxNdiInterfaces = legacy_response.max_ndi_interfaces;
- hidl_response->maxNdpSessions = legacy_response.max_ndp_sessions;
- hidl_response->maxAppInfoLen = legacy_response.max_app_info_len;
- hidl_response->maxQueuedTransmitFollowupMsgs = legacy_response.max_queued_transmit_followup_msgs;
- hidl_response->maxSubscribeInterfaceAddresses = legacy_response.max_subscribe_address;
- hidl_response->supportedCipherSuites = legacy_response.cipher_suites_supported;
+ hidl_response->maxConcurrentClusters =
+ legacy_response.max_concurrent_nan_clusters;
+ hidl_response->maxPublishes = legacy_response.max_publishes;
+ hidl_response->maxSubscribes = legacy_response.max_subscribes;
+ hidl_response->maxServiceNameLen = legacy_response.max_service_name_len;
+ hidl_response->maxMatchFilterLen = legacy_response.max_match_filter_len;
+ hidl_response->maxTotalMatchFilterLen =
+ legacy_response.max_total_match_filter_len;
+ hidl_response->maxServiceSpecificInfoLen =
+ legacy_response.max_service_specific_info_len;
+ hidl_response->maxExtendedServiceSpecificInfoLen =
+ legacy_response.max_sdea_service_specific_info_len;
+ hidl_response->maxNdiInterfaces = legacy_response.max_ndi_interfaces;
+ hidl_response->maxNdpSessions = legacy_response.max_ndp_sessions;
+ hidl_response->maxAppInfoLen = legacy_response.max_app_info_len;
+ hidl_response->maxQueuedTransmitFollowupMsgs =
+ legacy_response.max_queued_transmit_followup_msgs;
+ hidl_response->maxSubscribeInterfaceAddresses =
+ legacy_response.max_subscribe_address;
+ hidl_response->supportedCipherSuites =
+ legacy_response.cipher_suites_supported;
- return true;
+ return true;
}
-bool convertLegacyNanMatchIndToHidl(
- const legacy_hal::NanMatchInd& legacy_ind,
- NanMatchInd* hidl_ind) {
- if (!hidl_ind) {
- LOG(ERROR) << "convertLegacyNanMatchIndToHidl: hidl_ind is null";
- return false;
- }
- *hidl_ind = {};
+bool convertLegacyNanMatchIndToHidl(const legacy_hal::NanMatchInd& legacy_ind,
+ NanMatchInd* hidl_ind) {
+ if (!hidl_ind) {
+ LOG(ERROR) << "convertLegacyNanMatchIndToHidl: hidl_ind is null";
+ return false;
+ }
+ *hidl_ind = {};
- hidl_ind->discoverySessionId = legacy_ind.publish_subscribe_id;
- hidl_ind->peerId = legacy_ind.requestor_instance_id;
- hidl_ind->addr = hidl_array<uint8_t, 6>(legacy_ind.addr);
- hidl_ind->serviceSpecificInfo = std::vector<uint8_t>(legacy_ind.service_specific_info,
- legacy_ind.service_specific_info + legacy_ind.service_specific_info_len);
- hidl_ind->extendedServiceSpecificInfo = std::vector<uint8_t>(
- legacy_ind.sdea_service_specific_info,
- legacy_ind.sdea_service_specific_info + legacy_ind.sdea_service_specific_info_len);
- hidl_ind->matchFilter = std::vector<uint8_t>(legacy_ind.sdf_match_filter,
+ hidl_ind->discoverySessionId = legacy_ind.publish_subscribe_id;
+ hidl_ind->peerId = legacy_ind.requestor_instance_id;
+ hidl_ind->addr = hidl_array<uint8_t, 6>(legacy_ind.addr);
+ hidl_ind->serviceSpecificInfo =
+ std::vector<uint8_t>(legacy_ind.service_specific_info,
+ legacy_ind.service_specific_info +
+ legacy_ind.service_specific_info_len);
+ hidl_ind->extendedServiceSpecificInfo =
+ std::vector<uint8_t>(legacy_ind.sdea_service_specific_info,
+ legacy_ind.sdea_service_specific_info +
+ legacy_ind.sdea_service_specific_info_len);
+ hidl_ind->matchFilter = std::vector<uint8_t>(
+ legacy_ind.sdf_match_filter,
legacy_ind.sdf_match_filter + legacy_ind.sdf_match_filter_len);
- hidl_ind->matchOccuredInBeaconFlag = legacy_ind.match_occured_flag == 1;
- hidl_ind->outOfResourceFlag = legacy_ind.out_of_resource_flag == 1;
- hidl_ind->rssiValue = legacy_ind.rssi_value;
- hidl_ind->peerCipherType = (NanCipherSuiteType) legacy_ind.peer_cipher_type;
- hidl_ind->peerRequiresSecurityEnabledInNdp =
- legacy_ind.peer_sdea_params.security_cfg == legacy_hal::NAN_DP_CONFIG_SECURITY;
- hidl_ind->peerRequiresRanging =
- legacy_ind.peer_sdea_params.ranging_state == legacy_hal::NAN_RANGING_ENABLE;
- hidl_ind->rangingMeasurementInCm = legacy_ind.range_info.range_measurement_cm;
- hidl_ind->rangingIndicationType = legacy_ind.range_info.ranging_event_type;
+ hidl_ind->matchOccuredInBeaconFlag = legacy_ind.match_occured_flag == 1;
+ hidl_ind->outOfResourceFlag = legacy_ind.out_of_resource_flag == 1;
+ hidl_ind->rssiValue = legacy_ind.rssi_value;
+ hidl_ind->peerCipherType = (NanCipherSuiteType)legacy_ind.peer_cipher_type;
+ hidl_ind->peerRequiresSecurityEnabledInNdp =
+ legacy_ind.peer_sdea_params.security_cfg ==
+ legacy_hal::NAN_DP_CONFIG_SECURITY;
+ hidl_ind->peerRequiresRanging = legacy_ind.peer_sdea_params.ranging_state ==
+ legacy_hal::NAN_RANGING_ENABLE;
+ hidl_ind->rangingMeasurementInCm =
+ legacy_ind.range_info.range_measurement_cm;
+ hidl_ind->rangingIndicationType = legacy_ind.range_info.ranging_event_type;
- return true;
+ return true;
}
bool convertLegacyNanFollowupIndToHidl(
const legacy_hal::NanFollowupInd& legacy_ind,
NanFollowupReceivedInd* hidl_ind) {
- if (!hidl_ind) {
- LOG(ERROR) << "convertLegacyNanFollowupIndToHidl: hidl_ind is null";
- return false;
- }
- *hidl_ind = {};
+ if (!hidl_ind) {
+ LOG(ERROR) << "convertLegacyNanFollowupIndToHidl: hidl_ind is null";
+ return false;
+ }
+ *hidl_ind = {};
- hidl_ind->discoverySessionId = legacy_ind.publish_subscribe_id;
- hidl_ind->peerId = legacy_ind.requestor_instance_id;
- hidl_ind->addr = hidl_array<uint8_t, 6>(legacy_ind.addr);
- hidl_ind->receivedInFaw = legacy_ind.dw_or_faw == 1;
- hidl_ind->serviceSpecificInfo = std::vector<uint8_t>(legacy_ind.service_specific_info,
- legacy_ind.service_specific_info + legacy_ind.service_specific_info_len);
- hidl_ind->extendedServiceSpecificInfo = std::vector<uint8_t>(
- legacy_ind.sdea_service_specific_info,
- legacy_ind.sdea_service_specific_info + legacy_ind.sdea_service_specific_info_len);
+ hidl_ind->discoverySessionId = legacy_ind.publish_subscribe_id;
+ hidl_ind->peerId = legacy_ind.requestor_instance_id;
+ hidl_ind->addr = hidl_array<uint8_t, 6>(legacy_ind.addr);
+ hidl_ind->receivedInFaw = legacy_ind.dw_or_faw == 1;
+ hidl_ind->serviceSpecificInfo =
+ std::vector<uint8_t>(legacy_ind.service_specific_info,
+ legacy_ind.service_specific_info +
+ legacy_ind.service_specific_info_len);
+ hidl_ind->extendedServiceSpecificInfo =
+ std::vector<uint8_t>(legacy_ind.sdea_service_specific_info,
+ legacy_ind.sdea_service_specific_info +
+ legacy_ind.sdea_service_specific_info_len);
- return true;
+ return true;
}
bool convertLegacyNanDataPathRequestIndToHidl(
const legacy_hal::NanDataPathRequestInd& legacy_ind,
NanDataPathRequestInd* hidl_ind) {
- if (!hidl_ind) {
- LOG(ERROR) << "convertLegacyNanDataPathRequestIndToHidl: hidl_ind is null";
- return false;
- }
- *hidl_ind = {};
+ if (!hidl_ind) {
+ LOG(ERROR)
+ << "convertLegacyNanDataPathRequestIndToHidl: hidl_ind is null";
+ return false;
+ }
+ *hidl_ind = {};
- hidl_ind->discoverySessionId = legacy_ind.service_instance_id;
- hidl_ind->peerDiscMacAddr = hidl_array<uint8_t, 6>(legacy_ind.peer_disc_mac_addr);
- hidl_ind->ndpInstanceId = legacy_ind.ndp_instance_id;
- hidl_ind->securityRequired =
+ hidl_ind->discoverySessionId = legacy_ind.service_instance_id;
+ hidl_ind->peerDiscMacAddr =
+ hidl_array<uint8_t, 6>(legacy_ind.peer_disc_mac_addr);
+ hidl_ind->ndpInstanceId = legacy_ind.ndp_instance_id;
+ hidl_ind->securityRequired =
legacy_ind.ndp_cfg.security_cfg == legacy_hal::NAN_DP_CONFIG_SECURITY;
- hidl_ind->appInfo = std::vector<uint8_t>(legacy_ind.app_info.ndp_app_info,
- legacy_ind.app_info.ndp_app_info + legacy_ind.app_info.ndp_app_info_len);
+ hidl_ind->appInfo =
+ std::vector<uint8_t>(legacy_ind.app_info.ndp_app_info,
+ legacy_ind.app_info.ndp_app_info +
+ legacy_ind.app_info.ndp_app_info_len);
- return true;
+ return true;
}
bool convertLegacyNanDataPathConfirmIndToHidl(
const legacy_hal::NanDataPathConfirmInd& legacy_ind,
NanDataPathConfirmInd* hidl_ind) {
- if (!hidl_ind) {
- LOG(ERROR) << "convertLegacyNanDataPathConfirmIndToHidl: hidl_ind is null";
- return false;
- }
- *hidl_ind = {};
+ if (!hidl_ind) {
+ LOG(ERROR)
+ << "convertLegacyNanDataPathConfirmIndToHidl: hidl_ind is null";
+ return false;
+ }
+ *hidl_ind = {};
- hidl_ind->ndpInstanceId = legacy_ind.ndp_instance_id;
- hidl_ind->dataPathSetupSuccess = legacy_ind.rsp_code == legacy_hal::NAN_DP_REQUEST_ACCEPT;
- hidl_ind->peerNdiMacAddr = hidl_array<uint8_t, 6>(legacy_ind.peer_ndi_mac_addr);
- hidl_ind->appInfo = std::vector<uint8_t>(legacy_ind.app_info.ndp_app_info,
- legacy_ind.app_info.ndp_app_info + legacy_ind.app_info.ndp_app_info_len);
- hidl_ind->status.status = convertLegacyNanStatusTypeToHidl(legacy_ind.reason_code);
- hidl_ind->status.description = ""; // TODO: b/34059183
+ hidl_ind->ndpInstanceId = legacy_ind.ndp_instance_id;
+ hidl_ind->dataPathSetupSuccess =
+ legacy_ind.rsp_code == legacy_hal::NAN_DP_REQUEST_ACCEPT;
+ hidl_ind->peerNdiMacAddr =
+ hidl_array<uint8_t, 6>(legacy_ind.peer_ndi_mac_addr);
+ hidl_ind->appInfo =
+ std::vector<uint8_t>(legacy_ind.app_info.ndp_app_info,
+ legacy_ind.app_info.ndp_app_info +
+ legacy_ind.app_info.ndp_app_info_len);
+ hidl_ind->status.status =
+ convertLegacyNanStatusTypeToHidl(legacy_ind.reason_code);
+ hidl_ind->status.description = ""; // TODO: b/34059183
- return true;
+ return true;
}
legacy_hal::wifi_rtt_type convertHidlRttTypeToLegacy(RttType type) {
- switch (type) {
- case RttType::ONE_SIDED:
- return legacy_hal::RTT_TYPE_1_SIDED;
- case RttType::TWO_SIDED:
- return legacy_hal::RTT_TYPE_2_SIDED;
- };
- CHECK(false);
+ switch (type) {
+ case RttType::ONE_SIDED:
+ return legacy_hal::RTT_TYPE_1_SIDED;
+ case RttType::TWO_SIDED:
+ return legacy_hal::RTT_TYPE_2_SIDED;
+ };
+ CHECK(false);
}
RttType convertLegacyRttTypeToHidl(legacy_hal::wifi_rtt_type type) {
- switch (type) {
- case legacy_hal::RTT_TYPE_1_SIDED:
- return RttType::ONE_SIDED;
- case legacy_hal::RTT_TYPE_2_SIDED:
- return RttType::TWO_SIDED;
- };
- CHECK(false) << "Unknown legacy type: " << type;
+ switch (type) {
+ case legacy_hal::RTT_TYPE_1_SIDED:
+ return RttType::ONE_SIDED;
+ case legacy_hal::RTT_TYPE_2_SIDED:
+ return RttType::TWO_SIDED;
+ };
+ CHECK(false) << "Unknown legacy type: " << type;
}
legacy_hal::rtt_peer_type convertHidlRttPeerTypeToLegacy(RttPeerType type) {
- switch (type) {
- case RttPeerType::AP:
- return legacy_hal::RTT_PEER_AP;
- case RttPeerType::STA:
- return legacy_hal::RTT_PEER_STA;
- case RttPeerType::P2P_GO:
- return legacy_hal::RTT_PEER_P2P_GO;
- case RttPeerType::P2P_CLIENT:
- return legacy_hal::RTT_PEER_P2P_CLIENT;
- case RttPeerType::NAN:
- return legacy_hal::RTT_PEER_NAN;
- };
- CHECK(false);
+ switch (type) {
+ case RttPeerType::AP:
+ return legacy_hal::RTT_PEER_AP;
+ case RttPeerType::STA:
+ return legacy_hal::RTT_PEER_STA;
+ case RttPeerType::P2P_GO:
+ return legacy_hal::RTT_PEER_P2P_GO;
+ case RttPeerType::P2P_CLIENT:
+ return legacy_hal::RTT_PEER_P2P_CLIENT;
+ case RttPeerType::NAN:
+ return legacy_hal::RTT_PEER_NAN;
+ };
+ CHECK(false);
}
legacy_hal::wifi_channel_width convertHidlWifiChannelWidthToLegacy(
WifiChannelWidthInMhz type) {
- switch (type) {
- case WifiChannelWidthInMhz::WIDTH_20:
- return legacy_hal::WIFI_CHAN_WIDTH_20;
- case WifiChannelWidthInMhz::WIDTH_40:
- return legacy_hal::WIFI_CHAN_WIDTH_40;
- case WifiChannelWidthInMhz::WIDTH_80:
- return legacy_hal::WIFI_CHAN_WIDTH_80;
- case WifiChannelWidthInMhz::WIDTH_160:
- return legacy_hal::WIFI_CHAN_WIDTH_160;
- case WifiChannelWidthInMhz::WIDTH_80P80:
- return legacy_hal::WIFI_CHAN_WIDTH_80P80;
- case WifiChannelWidthInMhz::WIDTH_5:
- return legacy_hal::WIFI_CHAN_WIDTH_5;
- case WifiChannelWidthInMhz::WIDTH_10:
- return legacy_hal::WIFI_CHAN_WIDTH_10;
- case WifiChannelWidthInMhz::WIDTH_INVALID:
- return legacy_hal::WIFI_CHAN_WIDTH_INVALID;
- };
- CHECK(false);
+ switch (type) {
+ case WifiChannelWidthInMhz::WIDTH_20:
+ return legacy_hal::WIFI_CHAN_WIDTH_20;
+ case WifiChannelWidthInMhz::WIDTH_40:
+ return legacy_hal::WIFI_CHAN_WIDTH_40;
+ case WifiChannelWidthInMhz::WIDTH_80:
+ return legacy_hal::WIFI_CHAN_WIDTH_80;
+ case WifiChannelWidthInMhz::WIDTH_160:
+ return legacy_hal::WIFI_CHAN_WIDTH_160;
+ case WifiChannelWidthInMhz::WIDTH_80P80:
+ return legacy_hal::WIFI_CHAN_WIDTH_80P80;
+ case WifiChannelWidthInMhz::WIDTH_5:
+ return legacy_hal::WIFI_CHAN_WIDTH_5;
+ case WifiChannelWidthInMhz::WIDTH_10:
+ return legacy_hal::WIFI_CHAN_WIDTH_10;
+ case WifiChannelWidthInMhz::WIDTH_INVALID:
+ return legacy_hal::WIFI_CHAN_WIDTH_INVALID;
+ };
+ CHECK(false);
}
WifiChannelWidthInMhz convertLegacyWifiChannelWidthToHidl(
legacy_hal::wifi_channel_width type) {
- switch (type) {
- case legacy_hal::WIFI_CHAN_WIDTH_20:
- return WifiChannelWidthInMhz::WIDTH_20;
- case legacy_hal::WIFI_CHAN_WIDTH_40:
- return WifiChannelWidthInMhz::WIDTH_40;
- case legacy_hal::WIFI_CHAN_WIDTH_80:
- return WifiChannelWidthInMhz::WIDTH_80;
- case legacy_hal::WIFI_CHAN_WIDTH_160:
- return WifiChannelWidthInMhz::WIDTH_160;
- case legacy_hal::WIFI_CHAN_WIDTH_80P80:
- return WifiChannelWidthInMhz::WIDTH_80P80;
- case legacy_hal::WIFI_CHAN_WIDTH_5:
- return WifiChannelWidthInMhz::WIDTH_5;
- case legacy_hal::WIFI_CHAN_WIDTH_10:
- return WifiChannelWidthInMhz::WIDTH_10;
- case legacy_hal::WIFI_CHAN_WIDTH_INVALID:
- return WifiChannelWidthInMhz::WIDTH_INVALID;
- };
- CHECK(false) << "Unknown legacy type: " << type;
+ switch (type) {
+ case legacy_hal::WIFI_CHAN_WIDTH_20:
+ return WifiChannelWidthInMhz::WIDTH_20;
+ case legacy_hal::WIFI_CHAN_WIDTH_40:
+ return WifiChannelWidthInMhz::WIDTH_40;
+ case legacy_hal::WIFI_CHAN_WIDTH_80:
+ return WifiChannelWidthInMhz::WIDTH_80;
+ case legacy_hal::WIFI_CHAN_WIDTH_160:
+ return WifiChannelWidthInMhz::WIDTH_160;
+ case legacy_hal::WIFI_CHAN_WIDTH_80P80:
+ return WifiChannelWidthInMhz::WIDTH_80P80;
+ case legacy_hal::WIFI_CHAN_WIDTH_5:
+ return WifiChannelWidthInMhz::WIDTH_5;
+ case legacy_hal::WIFI_CHAN_WIDTH_10:
+ return WifiChannelWidthInMhz::WIDTH_10;
+ case legacy_hal::WIFI_CHAN_WIDTH_INVALID:
+ return WifiChannelWidthInMhz::WIDTH_INVALID;
+ };
+ CHECK(false) << "Unknown legacy type: " << type;
}
legacy_hal::wifi_rtt_preamble convertHidlRttPreambleToLegacy(RttPreamble type) {
- switch (type) {
- case RttPreamble::LEGACY:
- return legacy_hal::WIFI_RTT_PREAMBLE_LEGACY;
- case RttPreamble::HT:
- return legacy_hal::WIFI_RTT_PREAMBLE_HT;
- case RttPreamble::VHT:
- return legacy_hal::WIFI_RTT_PREAMBLE_VHT;
- };
- CHECK(false);
+ switch (type) {
+ case RttPreamble::LEGACY:
+ return legacy_hal::WIFI_RTT_PREAMBLE_LEGACY;
+ case RttPreamble::HT:
+ return legacy_hal::WIFI_RTT_PREAMBLE_HT;
+ case RttPreamble::VHT:
+ return legacy_hal::WIFI_RTT_PREAMBLE_VHT;
+ };
+ CHECK(false);
}
RttPreamble convertLegacyRttPreambleToHidl(legacy_hal::wifi_rtt_preamble type) {
- switch (type) {
- case legacy_hal::WIFI_RTT_PREAMBLE_LEGACY:
- return RttPreamble::LEGACY;
- case legacy_hal::WIFI_RTT_PREAMBLE_HT:
- return RttPreamble::HT;
- case legacy_hal::WIFI_RTT_PREAMBLE_VHT:
- return RttPreamble::VHT;
- };
- CHECK(false) << "Unknown legacy type: " << type;
+ switch (type) {
+ case legacy_hal::WIFI_RTT_PREAMBLE_LEGACY:
+ return RttPreamble::LEGACY;
+ case legacy_hal::WIFI_RTT_PREAMBLE_HT:
+ return RttPreamble::HT;
+ case legacy_hal::WIFI_RTT_PREAMBLE_VHT:
+ return RttPreamble::VHT;
+ };
+ CHECK(false) << "Unknown legacy type: " << type;
}
legacy_hal::wifi_rtt_bw convertHidlRttBwToLegacy(RttBw type) {
- switch (type) {
- case RttBw::BW_5MHZ:
- return legacy_hal::WIFI_RTT_BW_5;
- case RttBw::BW_10MHZ:
- return legacy_hal::WIFI_RTT_BW_10;
- case RttBw::BW_20MHZ:
- return legacy_hal::WIFI_RTT_BW_20;
- case RttBw::BW_40MHZ:
- return legacy_hal::WIFI_RTT_BW_40;
- case RttBw::BW_80MHZ:
- return legacy_hal::WIFI_RTT_BW_80;
- case RttBw::BW_160MHZ:
- return legacy_hal::WIFI_RTT_BW_160;
- };
- CHECK(false);
+ switch (type) {
+ case RttBw::BW_5MHZ:
+ return legacy_hal::WIFI_RTT_BW_5;
+ case RttBw::BW_10MHZ:
+ return legacy_hal::WIFI_RTT_BW_10;
+ case RttBw::BW_20MHZ:
+ return legacy_hal::WIFI_RTT_BW_20;
+ case RttBw::BW_40MHZ:
+ return legacy_hal::WIFI_RTT_BW_40;
+ case RttBw::BW_80MHZ:
+ return legacy_hal::WIFI_RTT_BW_80;
+ case RttBw::BW_160MHZ:
+ return legacy_hal::WIFI_RTT_BW_160;
+ };
+ CHECK(false);
}
RttBw convertLegacyRttBwToHidl(legacy_hal::wifi_rtt_bw type) {
- switch (type) {
- case legacy_hal::WIFI_RTT_BW_5:
- return RttBw::BW_5MHZ;
- case legacy_hal::WIFI_RTT_BW_10:
- return RttBw::BW_10MHZ;
- case legacy_hal::WIFI_RTT_BW_20:
- return RttBw::BW_20MHZ;
- case legacy_hal::WIFI_RTT_BW_40:
- return RttBw::BW_40MHZ;
- case legacy_hal::WIFI_RTT_BW_80:
- return RttBw::BW_80MHZ;
- case legacy_hal::WIFI_RTT_BW_160:
- return RttBw::BW_160MHZ;
- };
- CHECK(false) << "Unknown legacy type: " << type;
+ switch (type) {
+ case legacy_hal::WIFI_RTT_BW_5:
+ return RttBw::BW_5MHZ;
+ case legacy_hal::WIFI_RTT_BW_10:
+ return RttBw::BW_10MHZ;
+ case legacy_hal::WIFI_RTT_BW_20:
+ return RttBw::BW_20MHZ;
+ case legacy_hal::WIFI_RTT_BW_40:
+ return RttBw::BW_40MHZ;
+ case legacy_hal::WIFI_RTT_BW_80:
+ return RttBw::BW_80MHZ;
+ case legacy_hal::WIFI_RTT_BW_160:
+ return RttBw::BW_160MHZ;
+ };
+ CHECK(false) << "Unknown legacy type: " << type;
}
legacy_hal::wifi_motion_pattern convertHidlRttMotionPatternToLegacy(
RttMotionPattern type) {
- switch (type) {
- case RttMotionPattern::NOT_EXPECTED:
- return legacy_hal::WIFI_MOTION_NOT_EXPECTED;
- case RttMotionPattern::EXPECTED:
- return legacy_hal::WIFI_MOTION_EXPECTED;
- case RttMotionPattern::UNKNOWN:
- return legacy_hal::WIFI_MOTION_UNKNOWN;
- };
- CHECK(false);
+ switch (type) {
+ case RttMotionPattern::NOT_EXPECTED:
+ return legacy_hal::WIFI_MOTION_NOT_EXPECTED;
+ case RttMotionPattern::EXPECTED:
+ return legacy_hal::WIFI_MOTION_EXPECTED;
+ case RttMotionPattern::UNKNOWN:
+ return legacy_hal::WIFI_MOTION_UNKNOWN;
+ };
+ CHECK(false);
}
WifiRatePreamble convertLegacyWifiRatePreambleToHidl(uint8_t preamble) {
- switch (preamble) {
- case 0:
- return WifiRatePreamble::OFDM;
- case 1:
- return WifiRatePreamble::CCK;
- case 2:
- return WifiRatePreamble::HT;
- case 3:
- return WifiRatePreamble::VHT;
- default:
- return WifiRatePreamble::RESERVED;
- };
- CHECK(false) << "Unknown legacy preamble: " << preamble;
+ switch (preamble) {
+ case 0:
+ return WifiRatePreamble::OFDM;
+ case 1:
+ return WifiRatePreamble::CCK;
+ case 2:
+ return WifiRatePreamble::HT;
+ case 3:
+ return WifiRatePreamble::VHT;
+ default:
+ return WifiRatePreamble::RESERVED;
+ };
+ CHECK(false) << "Unknown legacy preamble: " << preamble;
}
WifiRateNss convertLegacyWifiRateNssToHidl(uint8_t nss) {
- switch (nss) {
- case 0:
- return WifiRateNss::NSS_1x1;
- case 1:
- return WifiRateNss::NSS_2x2;
- case 2:
- return WifiRateNss::NSS_3x3;
- case 3:
- return WifiRateNss::NSS_4x4;
- };
- CHECK(false) << "Unknown legacy nss: " << nss;
- return {};
+ switch (nss) {
+ case 0:
+ return WifiRateNss::NSS_1x1;
+ case 1:
+ return WifiRateNss::NSS_2x2;
+ case 2:
+ return WifiRateNss::NSS_3x3;
+ case 3:
+ return WifiRateNss::NSS_4x4;
+ };
+ CHECK(false) << "Unknown legacy nss: " << nss;
+ return {};
}
RttStatus convertLegacyRttStatusToHidl(legacy_hal::wifi_rtt_status status) {
- switch (status) {
- case legacy_hal::RTT_STATUS_SUCCESS:
- return RttStatus::SUCCESS;
- case legacy_hal::RTT_STATUS_FAILURE:
- return RttStatus::FAILURE;
- case legacy_hal::RTT_STATUS_FAIL_NO_RSP:
- return RttStatus::FAIL_NO_RSP;
- case legacy_hal::RTT_STATUS_FAIL_REJECTED:
- return RttStatus::FAIL_REJECTED;
- case legacy_hal::RTT_STATUS_FAIL_NOT_SCHEDULED_YET:
- return RttStatus::FAIL_NOT_SCHEDULED_YET;
- case legacy_hal::RTT_STATUS_FAIL_TM_TIMEOUT:
- return RttStatus::FAIL_TM_TIMEOUT;
- case legacy_hal::RTT_STATUS_FAIL_AP_ON_DIFF_CHANNEL:
- return RttStatus::FAIL_AP_ON_DIFF_CHANNEL;
- case legacy_hal::RTT_STATUS_FAIL_NO_CAPABILITY:
- return RttStatus::FAIL_NO_CAPABILITY;
- case legacy_hal::RTT_STATUS_ABORTED:
- return RttStatus::ABORTED;
- case legacy_hal::RTT_STATUS_FAIL_INVALID_TS:
- return RttStatus::FAIL_INVALID_TS;
- case legacy_hal::RTT_STATUS_FAIL_PROTOCOL:
- return RttStatus::FAIL_PROTOCOL;
- case legacy_hal::RTT_STATUS_FAIL_SCHEDULE:
- return RttStatus::FAIL_SCHEDULE;
- case legacy_hal::RTT_STATUS_FAIL_BUSY_TRY_LATER:
- return RttStatus::FAIL_BUSY_TRY_LATER;
- case legacy_hal::RTT_STATUS_INVALID_REQ:
- return RttStatus::INVALID_REQ;
- case legacy_hal::RTT_STATUS_NO_WIFI:
- return RttStatus::NO_WIFI;
- case legacy_hal::RTT_STATUS_FAIL_FTM_PARAM_OVERRIDE:
- return RttStatus::FAIL_FTM_PARAM_OVERRIDE;
- };
- CHECK(false) << "Unknown legacy status: " << status;
+ switch (status) {
+ case legacy_hal::RTT_STATUS_SUCCESS:
+ return RttStatus::SUCCESS;
+ case legacy_hal::RTT_STATUS_FAILURE:
+ return RttStatus::FAILURE;
+ case legacy_hal::RTT_STATUS_FAIL_NO_RSP:
+ return RttStatus::FAIL_NO_RSP;
+ case legacy_hal::RTT_STATUS_FAIL_REJECTED:
+ return RttStatus::FAIL_REJECTED;
+ case legacy_hal::RTT_STATUS_FAIL_NOT_SCHEDULED_YET:
+ return RttStatus::FAIL_NOT_SCHEDULED_YET;
+ case legacy_hal::RTT_STATUS_FAIL_TM_TIMEOUT:
+ return RttStatus::FAIL_TM_TIMEOUT;
+ case legacy_hal::RTT_STATUS_FAIL_AP_ON_DIFF_CHANNEL:
+ return RttStatus::FAIL_AP_ON_DIFF_CHANNEL;
+ case legacy_hal::RTT_STATUS_FAIL_NO_CAPABILITY:
+ return RttStatus::FAIL_NO_CAPABILITY;
+ case legacy_hal::RTT_STATUS_ABORTED:
+ return RttStatus::ABORTED;
+ case legacy_hal::RTT_STATUS_FAIL_INVALID_TS:
+ return RttStatus::FAIL_INVALID_TS;
+ case legacy_hal::RTT_STATUS_FAIL_PROTOCOL:
+ return RttStatus::FAIL_PROTOCOL;
+ case legacy_hal::RTT_STATUS_FAIL_SCHEDULE:
+ return RttStatus::FAIL_SCHEDULE;
+ case legacy_hal::RTT_STATUS_FAIL_BUSY_TRY_LATER:
+ return RttStatus::FAIL_BUSY_TRY_LATER;
+ case legacy_hal::RTT_STATUS_INVALID_REQ:
+ return RttStatus::INVALID_REQ;
+ case legacy_hal::RTT_STATUS_NO_WIFI:
+ return RttStatus::NO_WIFI;
+ case legacy_hal::RTT_STATUS_FAIL_FTM_PARAM_OVERRIDE:
+ return RttStatus::FAIL_FTM_PARAM_OVERRIDE;
+ };
+ CHECK(false) << "Unknown legacy status: " << status;
}
bool convertHidlWifiChannelInfoToLegacy(
const WifiChannelInfo& hidl_info,
legacy_hal::wifi_channel_info* legacy_info) {
- if (!legacy_info) {
- return false;
- }
- *legacy_info = {};
- legacy_info->width = convertHidlWifiChannelWidthToLegacy(hidl_info.width);
- legacy_info->center_freq = hidl_info.centerFreq;
- legacy_info->center_freq0 = hidl_info.centerFreq0;
- legacy_info->center_freq1 = hidl_info.centerFreq1;
- return true;
+ if (!legacy_info) {
+ return false;
+ }
+ *legacy_info = {};
+ legacy_info->width = convertHidlWifiChannelWidthToLegacy(hidl_info.width);
+ legacy_info->center_freq = hidl_info.centerFreq;
+ legacy_info->center_freq0 = hidl_info.centerFreq0;
+ legacy_info->center_freq1 = hidl_info.centerFreq1;
+ return true;
}
bool convertLegacyWifiChannelInfoToHidl(
const legacy_hal::wifi_channel_info& legacy_info,
WifiChannelInfo* hidl_info) {
- if (!hidl_info) {
- return false;
- }
- *hidl_info = {};
- hidl_info->width = convertLegacyWifiChannelWidthToHidl(legacy_info.width);
- hidl_info->centerFreq = legacy_info.center_freq;
- hidl_info->centerFreq0 = legacy_info.center_freq0;
- hidl_info->centerFreq1 = legacy_info.center_freq1;
- return true;
+ if (!hidl_info) {
+ return false;
+ }
+ *hidl_info = {};
+ hidl_info->width = convertLegacyWifiChannelWidthToHidl(legacy_info.width);
+ hidl_info->centerFreq = legacy_info.center_freq;
+ hidl_info->centerFreq0 = legacy_info.center_freq0;
+ hidl_info->centerFreq1 = legacy_info.center_freq1;
+ return true;
}
bool convertHidlRttConfigToLegacy(const RttConfig& hidl_config,
legacy_hal::wifi_rtt_config* legacy_config) {
- if (!legacy_config) {
- return false;
- }
- *legacy_config = {};
- CHECK(hidl_config.addr.size() == sizeof(legacy_config->addr));
- memcpy(legacy_config->addr, hidl_config.addr.data(), hidl_config.addr.size());
- legacy_config->type = convertHidlRttTypeToLegacy(hidl_config.type);
- legacy_config->peer = convertHidlRttPeerTypeToLegacy(hidl_config.peer);
- if (!convertHidlWifiChannelInfoToLegacy(hidl_config.channel,
- &legacy_config->channel)) {
- return false;
- }
- legacy_config->burst_period = hidl_config.burstPeriod;
- legacy_config->num_burst = hidl_config.numBurst;
- legacy_config->num_frames_per_burst = hidl_config.numFramesPerBurst;
- legacy_config->num_retries_per_rtt_frame = hidl_config.numRetriesPerRttFrame;
- legacy_config->num_retries_per_ftmr = hidl_config.numRetriesPerFtmr;
- legacy_config->LCI_request = hidl_config.mustRequestLci;
- legacy_config->LCR_request = hidl_config.mustRequestLcr;
- legacy_config->burst_duration = hidl_config.burstDuration;
- legacy_config->preamble =
- convertHidlRttPreambleToLegacy(hidl_config.preamble);
- legacy_config->bw = convertHidlRttBwToLegacy(hidl_config.bw);
- return true;
+ if (!legacy_config) {
+ return false;
+ }
+ *legacy_config = {};
+ CHECK(hidl_config.addr.size() == sizeof(legacy_config->addr));
+ memcpy(legacy_config->addr, hidl_config.addr.data(),
+ hidl_config.addr.size());
+ legacy_config->type = convertHidlRttTypeToLegacy(hidl_config.type);
+ legacy_config->peer = convertHidlRttPeerTypeToLegacy(hidl_config.peer);
+ if (!convertHidlWifiChannelInfoToLegacy(hidl_config.channel,
+ &legacy_config->channel)) {
+ return false;
+ }
+ legacy_config->burst_period = hidl_config.burstPeriod;
+ legacy_config->num_burst = hidl_config.numBurst;
+ legacy_config->num_frames_per_burst = hidl_config.numFramesPerBurst;
+ legacy_config->num_retries_per_rtt_frame =
+ hidl_config.numRetriesPerRttFrame;
+ legacy_config->num_retries_per_ftmr = hidl_config.numRetriesPerFtmr;
+ legacy_config->LCI_request = hidl_config.mustRequestLci;
+ legacy_config->LCR_request = hidl_config.mustRequestLcr;
+ legacy_config->burst_duration = hidl_config.burstDuration;
+ legacy_config->preamble =
+ convertHidlRttPreambleToLegacy(hidl_config.preamble);
+ legacy_config->bw = convertHidlRttBwToLegacy(hidl_config.bw);
+ return true;
}
bool convertHidlVectorOfRttConfigToLegacy(
const std::vector<RttConfig>& hidl_configs,
std::vector<legacy_hal::wifi_rtt_config>* legacy_configs) {
- if (!legacy_configs) {
- return false;
- }
- *legacy_configs = {};
- for (const auto& hidl_config : hidl_configs) {
- legacy_hal::wifi_rtt_config legacy_config;
- if (!convertHidlRttConfigToLegacy(hidl_config, &legacy_config)) {
- return false;
+ if (!legacy_configs) {
+ return false;
}
- legacy_configs->push_back(legacy_config);
- }
- return true;
+ *legacy_configs = {};
+ for (const auto& hidl_config : hidl_configs) {
+ legacy_hal::wifi_rtt_config legacy_config;
+ if (!convertHidlRttConfigToLegacy(hidl_config, &legacy_config)) {
+ return false;
+ }
+ legacy_configs->push_back(legacy_config);
+ }
+ return true;
}
bool convertHidlRttLciInformationToLegacy(
const RttLciInformation& hidl_info,
legacy_hal::wifi_lci_information* legacy_info) {
- if (!legacy_info) {
- return false;
- }
- *legacy_info = {};
- legacy_info->latitude = hidl_info.latitude;
- legacy_info->longitude = hidl_info.longitude;
- legacy_info->altitude = hidl_info.altitude;
- legacy_info->latitude_unc = hidl_info.latitudeUnc;
- legacy_info->longitude_unc = hidl_info.longitudeUnc;
- legacy_info->altitude_unc = hidl_info.altitudeUnc;
- legacy_info->motion_pattern =
- convertHidlRttMotionPatternToLegacy(hidl_info.motionPattern);
- legacy_info->floor = hidl_info.floor;
- legacy_info->height_above_floor = hidl_info.heightAboveFloor;
- legacy_info->height_unc = hidl_info.heightUnc;
- return true;
+ if (!legacy_info) {
+ return false;
+ }
+ *legacy_info = {};
+ legacy_info->latitude = hidl_info.latitude;
+ legacy_info->longitude = hidl_info.longitude;
+ legacy_info->altitude = hidl_info.altitude;
+ legacy_info->latitude_unc = hidl_info.latitudeUnc;
+ legacy_info->longitude_unc = hidl_info.longitudeUnc;
+ legacy_info->altitude_unc = hidl_info.altitudeUnc;
+ legacy_info->motion_pattern =
+ convertHidlRttMotionPatternToLegacy(hidl_info.motionPattern);
+ legacy_info->floor = hidl_info.floor;
+ legacy_info->height_above_floor = hidl_info.heightAboveFloor;
+ legacy_info->height_unc = hidl_info.heightUnc;
+ return true;
}
bool convertHidlRttLcrInformationToLegacy(
const RttLcrInformation& hidl_info,
legacy_hal::wifi_lcr_information* legacy_info) {
- if (!legacy_info) {
- return false;
- }
- *legacy_info = {};
- CHECK(hidl_info.countryCode.size() == sizeof(legacy_info->country_code));
- memcpy(legacy_info->country_code,
- hidl_info.countryCode.data(),
- hidl_info.countryCode.size());
- if (hidl_info.civicInfo.size() > sizeof(legacy_info->civic_info)) {
- return false;
- }
- legacy_info->length = hidl_info.civicInfo.size();
- memcpy(legacy_info->civic_info,
- hidl_info.civicInfo.c_str(),
- hidl_info.civicInfo.size());
- return true;
+ if (!legacy_info) {
+ return false;
+ }
+ *legacy_info = {};
+ CHECK(hidl_info.countryCode.size() == sizeof(legacy_info->country_code));
+ memcpy(legacy_info->country_code, hidl_info.countryCode.data(),
+ hidl_info.countryCode.size());
+ if (hidl_info.civicInfo.size() > sizeof(legacy_info->civic_info)) {
+ return false;
+ }
+ legacy_info->length = hidl_info.civicInfo.size();
+ memcpy(legacy_info->civic_info, hidl_info.civicInfo.c_str(),
+ hidl_info.civicInfo.size());
+ return true;
}
bool convertHidlRttResponderToLegacy(
const RttResponder& hidl_responder,
legacy_hal::wifi_rtt_responder* legacy_responder) {
- if (!legacy_responder) {
- return false;
- }
- *legacy_responder = {};
- if (!convertHidlWifiChannelInfoToLegacy(hidl_responder.channel,
- &legacy_responder->channel)) {
- return false;
- }
- legacy_responder->preamble =
- convertHidlRttPreambleToLegacy(hidl_responder.preamble);
- return true;
+ if (!legacy_responder) {
+ return false;
+ }
+ *legacy_responder = {};
+ if (!convertHidlWifiChannelInfoToLegacy(hidl_responder.channel,
+ &legacy_responder->channel)) {
+ return false;
+ }
+ legacy_responder->preamble =
+ convertHidlRttPreambleToLegacy(hidl_responder.preamble);
+ return true;
}
bool convertLegacyRttResponderToHidl(
const legacy_hal::wifi_rtt_responder& legacy_responder,
RttResponder* hidl_responder) {
- if (!hidl_responder) {
- return false;
- }
- *hidl_responder = {};
- if (!convertLegacyWifiChannelInfoToHidl(legacy_responder.channel,
- &hidl_responder->channel)) {
- return false;
- }
- hidl_responder->preamble =
- convertLegacyRttPreambleToHidl(legacy_responder.preamble);
- return true;
+ if (!hidl_responder) {
+ return false;
+ }
+ *hidl_responder = {};
+ if (!convertLegacyWifiChannelInfoToHidl(legacy_responder.channel,
+ &hidl_responder->channel)) {
+ return false;
+ }
+ hidl_responder->preamble =
+ convertLegacyRttPreambleToHidl(legacy_responder.preamble);
+ return true;
}
bool convertLegacyRttCapabilitiesToHidl(
const legacy_hal::wifi_rtt_capabilities& legacy_capabilities,
RttCapabilities* hidl_capabilities) {
- if (!hidl_capabilities) {
- return false;
- }
- *hidl_capabilities = {};
- hidl_capabilities->rttOneSidedSupported =
- legacy_capabilities.rtt_one_sided_supported;
- hidl_capabilities->rttFtmSupported = legacy_capabilities.rtt_ftm_supported;
- hidl_capabilities->lciSupported = legacy_capabilities.lci_support;
- hidl_capabilities->lcrSupported = legacy_capabilities.lcr_support;
- hidl_capabilities->responderSupported =
- legacy_capabilities.responder_supported;
- hidl_capabilities->preambleSupport = 0;
- for (const auto flag : {legacy_hal::WIFI_RTT_PREAMBLE_LEGACY,
- legacy_hal::WIFI_RTT_PREAMBLE_HT,
- legacy_hal::WIFI_RTT_PREAMBLE_VHT}) {
- if (legacy_capabilities.preamble_support & flag) {
- hidl_capabilities->preambleSupport |=
- static_cast<std::underlying_type<RttPreamble>::type>(
- convertLegacyRttPreambleToHidl(flag));
+ if (!hidl_capabilities) {
+ return false;
}
- }
- hidl_capabilities->bwSupport = 0;
- for (const auto flag : {legacy_hal::WIFI_RTT_BW_5,
- legacy_hal::WIFI_RTT_BW_10,
- legacy_hal::WIFI_RTT_BW_20,
- legacy_hal::WIFI_RTT_BW_40,
- legacy_hal::WIFI_RTT_BW_80,
- legacy_hal::WIFI_RTT_BW_160}) {
- if (legacy_capabilities.bw_support & flag) {
- hidl_capabilities->bwSupport |=
- static_cast<std::underlying_type<RttBw>::type>(
- convertLegacyRttBwToHidl(flag));
+ *hidl_capabilities = {};
+ hidl_capabilities->rttOneSidedSupported =
+ legacy_capabilities.rtt_one_sided_supported;
+ hidl_capabilities->rttFtmSupported = legacy_capabilities.rtt_ftm_supported;
+ hidl_capabilities->lciSupported = legacy_capabilities.lci_support;
+ hidl_capabilities->lcrSupported = legacy_capabilities.lcr_support;
+ hidl_capabilities->responderSupported =
+ legacy_capabilities.responder_supported;
+ hidl_capabilities->preambleSupport = 0;
+ for (const auto flag : {legacy_hal::WIFI_RTT_PREAMBLE_LEGACY,
+ legacy_hal::WIFI_RTT_PREAMBLE_HT,
+ legacy_hal::WIFI_RTT_PREAMBLE_VHT}) {
+ if (legacy_capabilities.preamble_support & flag) {
+ hidl_capabilities->preambleSupport |=
+ static_cast<std::underlying_type<RttPreamble>::type>(
+ convertLegacyRttPreambleToHidl(flag));
+ }
}
- }
- hidl_capabilities->mcVersion = legacy_capabilities.mc_version;
- return true;
+ hidl_capabilities->bwSupport = 0;
+ for (const auto flag :
+ {legacy_hal::WIFI_RTT_BW_5, legacy_hal::WIFI_RTT_BW_10,
+ legacy_hal::WIFI_RTT_BW_20, legacy_hal::WIFI_RTT_BW_40,
+ legacy_hal::WIFI_RTT_BW_80, legacy_hal::WIFI_RTT_BW_160}) {
+ if (legacy_capabilities.bw_support & flag) {
+ hidl_capabilities->bwSupport |=
+ static_cast<std::underlying_type<RttBw>::type>(
+ convertLegacyRttBwToHidl(flag));
+ }
+ }
+ hidl_capabilities->mcVersion = legacy_capabilities.mc_version;
+ return true;
}
bool convertLegacyWifiRateInfoToHidl(const legacy_hal::wifi_rate& legacy_rate,
WifiRateInfo* hidl_rate) {
- if (!hidl_rate) {
- return false;
- }
- *hidl_rate = {};
- hidl_rate->preamble =
- convertLegacyWifiRatePreambleToHidl(legacy_rate.preamble);
- hidl_rate->nss = convertLegacyWifiRateNssToHidl(legacy_rate.nss);
- hidl_rate->bw = convertLegacyWifiChannelWidthToHidl(
- static_cast<legacy_hal::wifi_channel_width>(legacy_rate.bw));
- hidl_rate->rateMcsIdx = legacy_rate.rateMcsIdx;
- hidl_rate->bitRateInKbps = legacy_rate.bitrate;
- return true;
+ if (!hidl_rate) {
+ return false;
+ }
+ *hidl_rate = {};
+ hidl_rate->preamble =
+ convertLegacyWifiRatePreambleToHidl(legacy_rate.preamble);
+ hidl_rate->nss = convertLegacyWifiRateNssToHidl(legacy_rate.nss);
+ hidl_rate->bw = convertLegacyWifiChannelWidthToHidl(
+ static_cast<legacy_hal::wifi_channel_width>(legacy_rate.bw));
+ hidl_rate->rateMcsIdx = legacy_rate.rateMcsIdx;
+ hidl_rate->bitRateInKbps = legacy_rate.bitrate;
+ return true;
}
bool convertLegacyRttResultToHidl(
const legacy_hal::wifi_rtt_result& legacy_result, RttResult* hidl_result) {
- if (!hidl_result) {
- return false;
- }
- *hidl_result = {};
- CHECK(sizeof(legacy_result.addr) == hidl_result->addr.size());
- memcpy(
- hidl_result->addr.data(), legacy_result.addr, sizeof(legacy_result.addr));
- hidl_result->burstNum = legacy_result.burst_num;
- hidl_result->measurementNumber = legacy_result.measurement_number;
- hidl_result->successNumber = legacy_result.success_number;
- hidl_result->numberPerBurstPeer = legacy_result.number_per_burst_peer;
- hidl_result->status = convertLegacyRttStatusToHidl(legacy_result.status);
- hidl_result->retryAfterDuration = legacy_result.retry_after_duration;
- hidl_result->type = convertLegacyRttTypeToHidl(legacy_result.type);
- hidl_result->rssi = legacy_result.rssi;
- hidl_result->rssiSpread = legacy_result.rssi_spread;
- if (!convertLegacyWifiRateInfoToHidl(legacy_result.tx_rate,
- &hidl_result->txRate)) {
- return false;
- }
- if (!convertLegacyWifiRateInfoToHidl(legacy_result.rx_rate,
- &hidl_result->rxRate)) {
- return false;
- }
- hidl_result->rtt = legacy_result.rtt;
- hidl_result->rttSd = legacy_result.rtt_sd;
- hidl_result->rttSpread = legacy_result.rtt_spread;
- hidl_result->distanceInMm = legacy_result.distance_mm;
- hidl_result->distanceSdInMm = legacy_result.distance_sd_mm;
- hidl_result->distanceSpreadInMm = legacy_result.distance_spread_mm;
- hidl_result->timeStampInUs = legacy_result.ts;
- hidl_result->burstDurationInMs = legacy_result.burst_duration;
- hidl_result->negotiatedBurstNum = legacy_result.negotiated_burst_num;
- if (legacy_result.LCI && !convertLegacyIeToHidl(*legacy_result.LCI,
- &hidl_result->lci)) {
- return false;
- }
- if (legacy_result.LCR && !convertLegacyIeToHidl(*legacy_result.LCR,
- &hidl_result->lcr)) {
- return false;
- }
- return true;
+ if (!hidl_result) {
+ return false;
+ }
+ *hidl_result = {};
+ CHECK(sizeof(legacy_result.addr) == hidl_result->addr.size());
+ memcpy(hidl_result->addr.data(), legacy_result.addr,
+ sizeof(legacy_result.addr));
+ hidl_result->burstNum = legacy_result.burst_num;
+ hidl_result->measurementNumber = legacy_result.measurement_number;
+ hidl_result->successNumber = legacy_result.success_number;
+ hidl_result->numberPerBurstPeer = legacy_result.number_per_burst_peer;
+ hidl_result->status = convertLegacyRttStatusToHidl(legacy_result.status);
+ hidl_result->retryAfterDuration = legacy_result.retry_after_duration;
+ hidl_result->type = convertLegacyRttTypeToHidl(legacy_result.type);
+ hidl_result->rssi = legacy_result.rssi;
+ hidl_result->rssiSpread = legacy_result.rssi_spread;
+ if (!convertLegacyWifiRateInfoToHidl(legacy_result.tx_rate,
+ &hidl_result->txRate)) {
+ return false;
+ }
+ if (!convertLegacyWifiRateInfoToHidl(legacy_result.rx_rate,
+ &hidl_result->rxRate)) {
+ return false;
+ }
+ hidl_result->rtt = legacy_result.rtt;
+ hidl_result->rttSd = legacy_result.rtt_sd;
+ hidl_result->rttSpread = legacy_result.rtt_spread;
+ hidl_result->distanceInMm = legacy_result.distance_mm;
+ hidl_result->distanceSdInMm = legacy_result.distance_sd_mm;
+ hidl_result->distanceSpreadInMm = legacy_result.distance_spread_mm;
+ hidl_result->timeStampInUs = legacy_result.ts;
+ hidl_result->burstDurationInMs = legacy_result.burst_duration;
+ hidl_result->negotiatedBurstNum = legacy_result.negotiated_burst_num;
+ if (legacy_result.LCI &&
+ !convertLegacyIeToHidl(*legacy_result.LCI, &hidl_result->lci)) {
+ return false;
+ }
+ if (legacy_result.LCR &&
+ !convertLegacyIeToHidl(*legacy_result.LCR, &hidl_result->lcr)) {
+ return false;
+ }
+ return true;
}
bool convertLegacyVectorOfRttResultToHidl(
const std::vector<const legacy_hal::wifi_rtt_result*>& legacy_results,
std::vector<RttResult>* hidl_results) {
- if (!hidl_results) {
- return false;
- }
- *hidl_results = {};
- for (const auto legacy_result : legacy_results) {
- RttResult hidl_result;
- if (!convertLegacyRttResultToHidl(*legacy_result, &hidl_result)) {
- return false;
+ if (!hidl_results) {
+ return false;
}
- hidl_results->push_back(hidl_result);
- }
- return true;
+ *hidl_results = {};
+ for (const auto legacy_result : legacy_results) {
+ RttResult hidl_result;
+ if (!convertLegacyRttResultToHidl(*legacy_result, &hidl_result)) {
+ return false;
+ }
+ hidl_results->push_back(hidl_result);
+ }
+ return true;
}
} // namespace hidl_struct_util
} // namespace implementation
diff --git a/wifi/1.2/default/hidl_struct_util.h b/wifi/1.2/default/hidl_struct_util.h
index ee5cbe0..6766b0f 100644
--- a/wifi/1.2/default/hidl_struct_util.h
+++ b/wifi/1.2/default/hidl_struct_util.h
@@ -19,8 +19,8 @@
#include <vector>
-#include <android/hardware/wifi/1.0/types.h>
#include <android/hardware/wifi/1.0/IWifiChip.h>
+#include <android/hardware/wifi/1.0/types.h>
#include <android/hardware/wifi/1.1/IWifiChip.h>
#include "wifi_legacy_hal.h"
@@ -41,8 +41,7 @@
// Chip conversion methods.
bool convertLegacyFeaturesToHidlChipCapabilities(
- uint32_t legacy_feature_set,
- uint32_t legacy_logger_feature_set,
+ uint32_t legacy_feature_set, uint32_t legacy_logger_feature_set,
uint32_t* hidl_caps);
bool convertLegacyDebugRingBufferStatusToHidl(
const legacy_hal::wifi_ring_buffer_status& legacy_status,
@@ -58,8 +57,7 @@
// STA iface conversion methods.
bool convertLegacyFeaturesToHidlStaCapabilities(
- uint32_t legacy_feature_set,
- uint32_t legacy_logger_feature_set,
+ uint32_t legacy_feature_set, uint32_t legacy_logger_feature_set,
uint32_t* hidl_caps);
bool convertLegacyApfCapabilitiesToHidl(
const legacy_hal::PacketFilterCapabilities& legacy_caps,
@@ -74,8 +72,7 @@
// |has_ie_data| indicates whether or not the wifi_scan_result includes 802.11
// Information Elements (IEs)
bool convertLegacyGscanResultToHidl(
- const legacy_hal::wifi_scan_result& legacy_scan_result,
- bool has_ie_data,
+ const legacy_hal::wifi_scan_result& legacy_scan_result, bool has_ie_data,
StaScanResult* hidl_scan_result);
// |cached_results| is assumed to not include IEs.
bool convertLegacyVectorOfCachedGscanResultsToHidl(
@@ -101,8 +98,8 @@
std::vector<WifiDebugRxPacketFateReport>* hidl_fates);
// NAN iface conversion methods.
-void convertToWifiNanStatus(legacy_hal::NanStatusType type, const char* str, size_t max_len,
- WifiNanStatus* wifiNanStatus);
+void convertToWifiNanStatus(legacy_hal::NanStatusType type, const char* str,
+ size_t max_len, WifiNanStatus* wifiNanStatus);
bool convertHidlNanEnableRequestToLegacy(
const NanEnableRequest& hidl_request,
legacy_hal::NanEnableRequest* legacy_request);
@@ -133,7 +130,8 @@
bool convertLegacyNanMatchIndToHidl(const legacy_hal::NanMatchInd& legacy_ind,
NanMatchInd* hidl_ind);
bool convertLegacyNanFollowupIndToHidl(
- const legacy_hal::NanFollowupInd& legacy_ind, NanFollowupReceivedInd* hidl_ind);
+ const legacy_hal::NanFollowupInd& legacy_ind,
+ NanFollowupReceivedInd* hidl_ind);
bool convertLegacyNanDataPathRequestIndToHidl(
const legacy_hal::NanDataPathRequestInd& legacy_ind,
NanDataPathRequestInd* hidl_ind);
diff --git a/wifi/1.2/default/hidl_sync_util.cpp b/wifi/1.2/default/hidl_sync_util.cpp
index 0ee47b4..ad8448a 100644
--- a/wifi/1.2/default/hidl_sync_util.cpp
+++ b/wifi/1.2/default/hidl_sync_util.cpp
@@ -28,7 +28,7 @@
namespace hidl_sync_util {
std::unique_lock<std::recursive_mutex> acquireGlobalLock() {
- return std::unique_lock<std::recursive_mutex>{g_mutex};
+ return std::unique_lock<std::recursive_mutex>{g_mutex};
}
} // namespace hidl_sync_util
diff --git a/wifi/1.2/default/service.cpp b/wifi/1.2/default/service.cpp
index 2a6c324..6297cf2 100644
--- a/wifi/1.2/default/service.cpp
+++ b/wifi/1.2/default/service.cpp
@@ -25,20 +25,20 @@
using android::hardware::joinRpcThreadpool;
int main(int /*argc*/, char** argv) {
- android::base::InitLogging(argv,
- android::base::LogdLogger(android::base::SYSTEM));
- LOG(INFO) << "Wifi Hal is booting up...";
+ android::base::InitLogging(
+ argv, android::base::LogdLogger(android::base::SYSTEM));
+ LOG(INFO) << "Wifi Hal is booting up...";
- configureRpcThreadpool(1, true /* callerWillJoin */);
+ configureRpcThreadpool(1, true /* callerWillJoin */);
- // Setup hwbinder service
- android::sp<android::hardware::wifi::V1_2::IWifi> service =
- new android::hardware::wifi::V1_2::implementation::Wifi();
- CHECK_EQ(service->registerAsService(), android::NO_ERROR)
- << "Failed to register wifi HAL";
+ // Setup hwbinder service
+ android::sp<android::hardware::wifi::V1_2::IWifi> service =
+ new android::hardware::wifi::V1_2::implementation::Wifi();
+ CHECK_EQ(service->registerAsService(), android::NO_ERROR)
+ << "Failed to register wifi HAL";
- joinRpcThreadpool();
+ joinRpcThreadpool();
- LOG(INFO) << "Wifi Hal is terminating...";
- return 0;
+ LOG(INFO) << "Wifi Hal is terminating...";
+ return 0;
}
diff --git a/wifi/1.2/default/wifi.cpp b/wifi/1.2/default/wifi.cpp
index 67fcb65..a2d8f9f 100644
--- a/wifi/1.2/default/wifi.cpp
+++ b/wifi/1.2/default/wifi.cpp
@@ -39,164 +39,153 @@
run_state_(RunState::STOPPED) {}
bool Wifi::isValid() {
- // This object is always valid.
- return true;
+ // This object is always valid.
+ return true;
}
Return<void> Wifi::registerEventCallback(
const sp<IWifiEventCallback>& event_callback,
registerEventCallback_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_UNKNOWN,
- &Wifi::registerEventCallbackInternal,
- hidl_status_cb,
- event_callback);
+ return validateAndCall(this, WifiStatusCode::ERROR_UNKNOWN,
+ &Wifi::registerEventCallbackInternal, hidl_status_cb,
+ event_callback);
}
-Return<bool> Wifi::isStarted() {
- return run_state_ != RunState::STOPPED;
-}
+Return<bool> Wifi::isStarted() { return run_state_ != RunState::STOPPED; }
Return<void> Wifi::start(start_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_UNKNOWN,
- &Wifi::startInternal,
- hidl_status_cb);
+ return validateAndCall(this, WifiStatusCode::ERROR_UNKNOWN,
+ &Wifi::startInternal, hidl_status_cb);
}
Return<void> Wifi::stop(stop_cb hidl_status_cb) {
- return validateAndCallWithLock(this, WifiStatusCode::ERROR_UNKNOWN,
- &Wifi::stopInternal, hidl_status_cb);
+ return validateAndCallWithLock(this, WifiStatusCode::ERROR_UNKNOWN,
+ &Wifi::stopInternal, hidl_status_cb);
}
Return<void> Wifi::getChipIds(getChipIds_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_UNKNOWN,
- &Wifi::getChipIdsInternal,
- hidl_status_cb);
+ return validateAndCall(this, WifiStatusCode::ERROR_UNKNOWN,
+ &Wifi::getChipIdsInternal, hidl_status_cb);
}
Return<void> Wifi::getChip(ChipId chip_id, getChip_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_UNKNOWN,
- &Wifi::getChipInternal,
- hidl_status_cb,
- chip_id);
+ return validateAndCall(this, WifiStatusCode::ERROR_UNKNOWN,
+ &Wifi::getChipInternal, hidl_status_cb, chip_id);
}
WifiStatus Wifi::registerEventCallbackInternal(
const sp<IWifiEventCallback>& event_callback) {
- if (!event_cb_handler_.addCallback(event_callback)) {
- return createWifiStatus(WifiStatusCode::ERROR_UNKNOWN);
- }
- return createWifiStatus(WifiStatusCode::SUCCESS);
+ if (!event_cb_handler_.addCallback(event_callback)) {
+ return createWifiStatus(WifiStatusCode::ERROR_UNKNOWN);
+ }
+ return createWifiStatus(WifiStatusCode::SUCCESS);
}
WifiStatus Wifi::startInternal() {
- if (run_state_ == RunState::STARTED) {
- return createWifiStatus(WifiStatusCode::SUCCESS);
- } else if (run_state_ == RunState::STOPPING) {
- return createWifiStatus(WifiStatusCode::ERROR_NOT_AVAILABLE,
- "HAL is stopping");
- }
- WifiStatus wifi_status = initializeLegacyHal();
- if (wifi_status.code == WifiStatusCode::SUCCESS) {
- // Create the chip instance once the HAL is started.
- chip_ = new WifiChip(kChipId, legacy_hal_, mode_controller_);
- run_state_ = RunState::STARTED;
- for (const auto& callback : event_cb_handler_.getCallbacks()) {
- if (!callback->onStart().isOk()) {
- LOG(ERROR) << "Failed to invoke onStart callback";
- };
+ if (run_state_ == RunState::STARTED) {
+ return createWifiStatus(WifiStatusCode::SUCCESS);
+ } else if (run_state_ == RunState::STOPPING) {
+ return createWifiStatus(WifiStatusCode::ERROR_NOT_AVAILABLE,
+ "HAL is stopping");
}
- LOG(INFO) << "Wifi HAL started";
- } else {
- for (const auto& callback : event_cb_handler_.getCallbacks()) {
- if (!callback->onFailure(wifi_status).isOk()) {
- LOG(ERROR) << "Failed to invoke onFailure callback";
- }
+ WifiStatus wifi_status = initializeLegacyHal();
+ if (wifi_status.code == WifiStatusCode::SUCCESS) {
+ // Create the chip instance once the HAL is started.
+ chip_ = new WifiChip(kChipId, legacy_hal_, mode_controller_);
+ run_state_ = RunState::STARTED;
+ for (const auto& callback : event_cb_handler_.getCallbacks()) {
+ if (!callback->onStart().isOk()) {
+ LOG(ERROR) << "Failed to invoke onStart callback";
+ };
+ }
+ LOG(INFO) << "Wifi HAL started";
+ } else {
+ for (const auto& callback : event_cb_handler_.getCallbacks()) {
+ if (!callback->onFailure(wifi_status).isOk()) {
+ LOG(ERROR) << "Failed to invoke onFailure callback";
+ }
+ }
+ LOG(ERROR) << "Wifi HAL start failed";
}
- LOG(ERROR) << "Wifi HAL start failed";
- }
- return wifi_status;
+ return wifi_status;
}
WifiStatus Wifi::stopInternal(
/* NONNULL */ std::unique_lock<std::recursive_mutex>* lock) {
- if (run_state_ == RunState::STOPPED) {
- return createWifiStatus(WifiStatusCode::SUCCESS);
- } else if (run_state_ == RunState::STOPPING) {
- return createWifiStatus(WifiStatusCode::ERROR_NOT_AVAILABLE,
- "HAL is stopping");
- }
- // Clear the chip object and its child objects since the HAL is now
- // stopped.
- if (chip_.get()) {
- chip_->invalidate();
- chip_.clear();
- }
- WifiStatus wifi_status = stopLegacyHalAndDeinitializeModeController(lock);
- if (wifi_status.code == WifiStatusCode::SUCCESS) {
- for (const auto& callback : event_cb_handler_.getCallbacks()) {
- if (!callback->onStop().isOk()) {
- LOG(ERROR) << "Failed to invoke onStop callback";
- };
+ if (run_state_ == RunState::STOPPED) {
+ return createWifiStatus(WifiStatusCode::SUCCESS);
+ } else if (run_state_ == RunState::STOPPING) {
+ return createWifiStatus(WifiStatusCode::ERROR_NOT_AVAILABLE,
+ "HAL is stopping");
}
- LOG(INFO) << "Wifi HAL stopped";
- } else {
- for (const auto& callback : event_cb_handler_.getCallbacks()) {
- if (!callback->onFailure(wifi_status).isOk()) {
- LOG(ERROR) << "Failed to invoke onFailure callback";
- }
+ // Clear the chip object and its child objects since the HAL is now
+ // stopped.
+ if (chip_.get()) {
+ chip_->invalidate();
+ chip_.clear();
}
- LOG(ERROR) << "Wifi HAL stop failed";
- }
- return wifi_status;
+ WifiStatus wifi_status = stopLegacyHalAndDeinitializeModeController(lock);
+ if (wifi_status.code == WifiStatusCode::SUCCESS) {
+ for (const auto& callback : event_cb_handler_.getCallbacks()) {
+ if (!callback->onStop().isOk()) {
+ LOG(ERROR) << "Failed to invoke onStop callback";
+ };
+ }
+ LOG(INFO) << "Wifi HAL stopped";
+ } else {
+ for (const auto& callback : event_cb_handler_.getCallbacks()) {
+ if (!callback->onFailure(wifi_status).isOk()) {
+ LOG(ERROR) << "Failed to invoke onFailure callback";
+ }
+ }
+ LOG(ERROR) << "Wifi HAL stop failed";
+ }
+ return wifi_status;
}
std::pair<WifiStatus, std::vector<ChipId>> Wifi::getChipIdsInternal() {
- std::vector<ChipId> chip_ids;
- if (chip_.get()) {
- chip_ids.emplace_back(kChipId);
- }
- return {createWifiStatus(WifiStatusCode::SUCCESS), std::move(chip_ids)};
+ std::vector<ChipId> chip_ids;
+ if (chip_.get()) {
+ chip_ids.emplace_back(kChipId);
+ }
+ return {createWifiStatus(WifiStatusCode::SUCCESS), std::move(chip_ids)};
}
std::pair<WifiStatus, sp<IWifiChip>> Wifi::getChipInternal(ChipId chip_id) {
- if (!chip_.get()) {
- return {createWifiStatus(WifiStatusCode::ERROR_NOT_STARTED), nullptr};
- }
- if (chip_id != kChipId) {
- return {createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS), nullptr};
- }
- return {createWifiStatus(WifiStatusCode::SUCCESS), chip_};
+ if (!chip_.get()) {
+ return {createWifiStatus(WifiStatusCode::ERROR_NOT_STARTED), nullptr};
+ }
+ if (chip_id != kChipId) {
+ return {createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS), nullptr};
+ }
+ return {createWifiStatus(WifiStatusCode::SUCCESS), chip_};
}
WifiStatus Wifi::initializeLegacyHal() {
- legacy_hal::wifi_error legacy_status = legacy_hal_->initialize();
- if (legacy_status != legacy_hal::WIFI_SUCCESS) {
- LOG(ERROR) << "Failed to initialize legacy HAL: "
- << legacyErrorToString(legacy_status);
- return createWifiStatusFromLegacyError(legacy_status);
- }
- return createWifiStatus(WifiStatusCode::SUCCESS);
+ legacy_hal::wifi_error legacy_status = legacy_hal_->initialize();
+ if (legacy_status != legacy_hal::WIFI_SUCCESS) {
+ LOG(ERROR) << "Failed to initialize legacy HAL: "
+ << legacyErrorToString(legacy_status);
+ return createWifiStatusFromLegacyError(legacy_status);
+ }
+ return createWifiStatus(WifiStatusCode::SUCCESS);
}
WifiStatus Wifi::stopLegacyHalAndDeinitializeModeController(
/* NONNULL */ std::unique_lock<std::recursive_mutex>* lock) {
- run_state_ = RunState::STOPPING;
- legacy_hal::wifi_error legacy_status =
- legacy_hal_->stop(lock, [&]() { run_state_ = RunState::STOPPED; });
- if (legacy_status != legacy_hal::WIFI_SUCCESS) {
- LOG(ERROR) << "Failed to stop legacy HAL: "
- << legacyErrorToString(legacy_status);
- return createWifiStatusFromLegacyError(legacy_status);
- }
- if (!mode_controller_->deinitialize()) {
- LOG(ERROR) << "Failed to deinitialize firmware mode controller";
- return createWifiStatus(WifiStatusCode::ERROR_UNKNOWN);
- }
- return createWifiStatus(WifiStatusCode::SUCCESS);
+ run_state_ = RunState::STOPPING;
+ legacy_hal::wifi_error legacy_status =
+ legacy_hal_->stop(lock, [&]() { run_state_ = RunState::STOPPED; });
+ if (legacy_status != legacy_hal::WIFI_SUCCESS) {
+ LOG(ERROR) << "Failed to stop legacy HAL: "
+ << legacyErrorToString(legacy_status);
+ return createWifiStatusFromLegacyError(legacy_status);
+ }
+ if (!mode_controller_->deinitialize()) {
+ LOG(ERROR) << "Failed to deinitialize firmware mode controller";
+ return createWifiStatus(WifiStatusCode::ERROR_UNKNOWN);
+ }
+ return createWifiStatus(WifiStatusCode::SUCCESS);
}
} // namespace implementation
} // namespace V1_2
diff --git a/wifi/1.2/default/wifi.h b/wifi/1.2/default/wifi.h
index 95ae58f..114d774 100644
--- a/wifi/1.2/default/wifi.h
+++ b/wifi/1.2/default/wifi.h
@@ -38,45 +38,46 @@
* Root HIDL interface object used to control the Wifi HAL.
*/
class Wifi : public V1_2::IWifi {
- public:
- Wifi();
+ public:
+ Wifi();
- bool isValid();
+ bool isValid();
- // HIDL methods exposed.
- Return<void> registerEventCallback(
- const sp<IWifiEventCallback>& event_callback,
- registerEventCallback_cb hidl_status_cb) override;
- Return<bool> isStarted() override;
- Return<void> start(start_cb hidl_status_cb) override;
- Return<void> stop(stop_cb hidl_status_cb) override;
- Return<void> getChipIds(getChipIds_cb hidl_status_cb) override;
- Return<void> getChip(ChipId chip_id, getChip_cb hidl_status_cb) override;
+ // HIDL methods exposed.
+ Return<void> registerEventCallback(
+ const sp<IWifiEventCallback>& event_callback,
+ registerEventCallback_cb hidl_status_cb) override;
+ Return<bool> isStarted() override;
+ Return<void> start(start_cb hidl_status_cb) override;
+ Return<void> stop(stop_cb hidl_status_cb) override;
+ Return<void> getChipIds(getChipIds_cb hidl_status_cb) override;
+ Return<void> getChip(ChipId chip_id, getChip_cb hidl_status_cb) override;
- private:
- enum class RunState { STOPPED, STARTED, STOPPING };
+ private:
+ enum class RunState { STOPPED, STARTED, STOPPING };
- // Corresponding worker functions for the HIDL methods.
- WifiStatus registerEventCallbackInternal(
- const sp<IWifiEventCallback>& event_callback);
- WifiStatus startInternal();
- WifiStatus stopInternal(std::unique_lock<std::recursive_mutex>* lock);
- std::pair<WifiStatus, std::vector<ChipId>> getChipIdsInternal();
- std::pair<WifiStatus, sp<IWifiChip>> getChipInternal(ChipId chip_id);
+ // Corresponding worker functions for the HIDL methods.
+ WifiStatus registerEventCallbackInternal(
+ const sp<IWifiEventCallback>& event_callback);
+ WifiStatus startInternal();
+ WifiStatus stopInternal(std::unique_lock<std::recursive_mutex>* lock);
+ std::pair<WifiStatus, std::vector<ChipId>> getChipIdsInternal();
+ std::pair<WifiStatus, sp<IWifiChip>> getChipInternal(ChipId chip_id);
- WifiStatus initializeLegacyHal();
- WifiStatus stopLegacyHalAndDeinitializeModeController(
- std::unique_lock<std::recursive_mutex>* lock);
+ WifiStatus initializeLegacyHal();
+ WifiStatus stopLegacyHalAndDeinitializeModeController(
+ std::unique_lock<std::recursive_mutex>* lock);
- // Instance is created in this root level |IWifi| HIDL interface object
- // and shared with all the child HIDL interface objects.
- std::shared_ptr<legacy_hal::WifiLegacyHal> legacy_hal_;
- std::shared_ptr<mode_controller::WifiModeController> mode_controller_;
- RunState run_state_;
- sp<WifiChip> chip_;
- hidl_callback_util::HidlCallbackHandler<IWifiEventCallback> event_cb_handler_;
+ // Instance is created in this root level |IWifi| HIDL interface object
+ // and shared with all the child HIDL interface objects.
+ std::shared_ptr<legacy_hal::WifiLegacyHal> legacy_hal_;
+ std::shared_ptr<mode_controller::WifiModeController> mode_controller_;
+ RunState run_state_;
+ sp<WifiChip> chip_;
+ hidl_callback_util::HidlCallbackHandler<IWifiEventCallback>
+ event_cb_handler_;
- DISALLOW_COPY_AND_ASSIGN(Wifi);
+ DISALLOW_COPY_AND_ASSIGN(Wifi);
};
} // namespace implementation
diff --git a/wifi/1.2/default/wifi_ap_iface.cpp b/wifi/1.2/default/wifi_ap_iface.cpp
index 347ffc6..284f9b9 100644
--- a/wifi/1.2/default/wifi_ap_iface.cpp
+++ b/wifi/1.2/default/wifi_ap_iface.cpp
@@ -34,70 +34,61 @@
: ifname_(ifname), legacy_hal_(legacy_hal), is_valid_(true) {}
void WifiApIface::invalidate() {
- legacy_hal_.reset();
- is_valid_ = false;
+ legacy_hal_.reset();
+ is_valid_ = false;
}
-bool WifiApIface::isValid() {
- return is_valid_;
-}
+bool WifiApIface::isValid() { return is_valid_; }
Return<void> WifiApIface::getName(getName_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
- &WifiApIface::getNameInternal,
- hidl_status_cb);
+ return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
+ &WifiApIface::getNameInternal, hidl_status_cb);
}
Return<void> WifiApIface::getType(getType_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
- &WifiApIface::getTypeInternal,
- hidl_status_cb);
+ return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
+ &WifiApIface::getTypeInternal, hidl_status_cb);
}
Return<void> WifiApIface::setCountryCode(const hidl_array<int8_t, 2>& code,
setCountryCode_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
- &WifiApIface::setCountryCodeInternal,
- hidl_status_cb,
- code);
+ return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
+ &WifiApIface::setCountryCodeInternal, hidl_status_cb,
+ code);
}
Return<void> WifiApIface::getValidFrequenciesForBand(
WifiBand band, getValidFrequenciesForBand_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
- &WifiApIface::getValidFrequenciesForBandInternal,
- hidl_status_cb,
- band);
+ return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
+ &WifiApIface::getValidFrequenciesForBandInternal,
+ hidl_status_cb, band);
}
std::pair<WifiStatus, std::string> WifiApIface::getNameInternal() {
- return {createWifiStatus(WifiStatusCode::SUCCESS), ifname_};
+ return {createWifiStatus(WifiStatusCode::SUCCESS), ifname_};
}
std::pair<WifiStatus, IfaceType> WifiApIface::getTypeInternal() {
- return {createWifiStatus(WifiStatusCode::SUCCESS), IfaceType::AP};
+ return {createWifiStatus(WifiStatusCode::SUCCESS), IfaceType::AP};
}
WifiStatus WifiApIface::setCountryCodeInternal(
const std::array<int8_t, 2>& code) {
- legacy_hal::wifi_error legacy_status =
- legacy_hal_.lock()->setCountryCode(code);
- return createWifiStatusFromLegacyError(legacy_status);
+ legacy_hal::wifi_error legacy_status =
+ legacy_hal_.lock()->setCountryCode(ifname_, code);
+ return createWifiStatusFromLegacyError(legacy_status);
}
std::pair<WifiStatus, std::vector<WifiChannelInMhz>>
WifiApIface::getValidFrequenciesForBandInternal(WifiBand band) {
- static_assert(sizeof(WifiChannelInMhz) == sizeof(uint32_t), "Size mismatch");
- legacy_hal::wifi_error legacy_status;
- std::vector<uint32_t> valid_frequencies;
- std::tie(legacy_status, valid_frequencies) =
- legacy_hal_.lock()->getValidFrequenciesForBand(
- hidl_struct_util::convertHidlWifiBandToLegacy(band));
- return {createWifiStatusFromLegacyError(legacy_status), valid_frequencies};
+ static_assert(sizeof(WifiChannelInMhz) == sizeof(uint32_t),
+ "Size mismatch");
+ legacy_hal::wifi_error legacy_status;
+ std::vector<uint32_t> valid_frequencies;
+ std::tie(legacy_status, valid_frequencies) =
+ legacy_hal_.lock()->getValidFrequenciesForBand(
+ ifname_, hidl_struct_util::convertHidlWifiBandToLegacy(band));
+ return {createWifiStatusFromLegacyError(legacy_status), valid_frequencies};
}
} // namespace implementation
} // namespace V1_2
diff --git a/wifi/1.2/default/wifi_ap_iface.h b/wifi/1.2/default/wifi_ap_iface.h
index b46425b..6375121 100644
--- a/wifi/1.2/default/wifi_ap_iface.h
+++ b/wifi/1.2/default/wifi_ap_iface.h
@@ -33,34 +33,34 @@
* HIDL interface object used to control a AP Iface instance.
*/
class WifiApIface : public V1_0::IWifiApIface {
- public:
- WifiApIface(const std::string& ifname,
- const std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal);
- // Refer to |WifiChip::invalidate()|.
- void invalidate();
- bool isValid();
+ public:
+ WifiApIface(const std::string& ifname,
+ const std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal);
+ // Refer to |WifiChip::invalidate()|.
+ void invalidate();
+ bool isValid();
- // HIDL methods exposed.
- Return<void> getName(getName_cb hidl_status_cb) override;
- Return<void> getType(getType_cb hidl_status_cb) override;
- Return<void> setCountryCode(const hidl_array<int8_t, 2>& code,
- setCountryCode_cb hidl_status_cb) override;
- Return<void> getValidFrequenciesForBand(
- WifiBand band, getValidFrequenciesForBand_cb hidl_status_cb) override;
+ // HIDL methods exposed.
+ Return<void> getName(getName_cb hidl_status_cb) override;
+ Return<void> getType(getType_cb hidl_status_cb) override;
+ Return<void> setCountryCode(const hidl_array<int8_t, 2>& code,
+ setCountryCode_cb hidl_status_cb) override;
+ Return<void> getValidFrequenciesForBand(
+ WifiBand band, getValidFrequenciesForBand_cb hidl_status_cb) override;
- private:
- // Corresponding worker functions for the HIDL methods.
- std::pair<WifiStatus, std::string> getNameInternal();
- std::pair<WifiStatus, IfaceType> getTypeInternal();
- WifiStatus setCountryCodeInternal(const std::array<int8_t, 2>& code);
- std::pair<WifiStatus, std::vector<WifiChannelInMhz>>
- getValidFrequenciesForBandInternal(WifiBand band);
+ private:
+ // Corresponding worker functions for the HIDL methods.
+ std::pair<WifiStatus, std::string> getNameInternal();
+ std::pair<WifiStatus, IfaceType> getTypeInternal();
+ WifiStatus setCountryCodeInternal(const std::array<int8_t, 2>& code);
+ std::pair<WifiStatus, std::vector<WifiChannelInMhz>>
+ getValidFrequenciesForBandInternal(WifiBand band);
- std::string ifname_;
- std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal_;
- bool is_valid_;
+ std::string ifname_;
+ std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal_;
+ bool is_valid_;
- DISALLOW_COPY_AND_ASSIGN(WifiApIface);
+ DISALLOW_COPY_AND_ASSIGN(WifiApIface);
};
} // namespace implementation
diff --git a/wifi/1.2/default/wifi_chip.cpp b/wifi/1.2/default/wifi_chip.cpp
index 63d17a2..4e2191d 100644
--- a/wifi/1.2/default/wifi_chip.cpp
+++ b/wifi/1.2/default/wifi_chip.cpp
@@ -15,6 +15,7 @@
*/
#include <android-base/logging.h>
+#include <cutils/properties.h>
#include "hidl_return_util.h"
#include "hidl_struct_util.h"
@@ -23,12 +24,12 @@
#include "wifi_status_util.h"
namespace {
-using android::sp;
-using android::hardware::hidl_vec;
using android::hardware::hidl_string;
+using android::hardware::hidl_vec;
using android::hardware::wifi::V1_0::ChipModeId;
using android::hardware::wifi::V1_0::IWifiChip;
using android::hardware::wifi::V1_0::IfaceType;
+using android::sp;
constexpr ChipModeId kStaChipModeId = 0;
constexpr ChipModeId kApChipModeId = 1;
@@ -36,12 +37,33 @@
template <typename Iface>
void invalidateAndClear(sp<Iface>& iface) {
- if (iface.get()) {
- iface->invalidate();
- iface.clear();
- }
+ if (iface.get()) {
+ iface->invalidate();
+ iface.clear();
+ }
}
-} // namepsace
+
+std::string getWlan0IfaceName() {
+ std::array<char, PROPERTY_VALUE_MAX> buffer;
+ property_get("wifi.interface", buffer.data(), "wlan0");
+ return buffer.data();
+}
+
+/** Not used yet.
+std::string getWlan1IfaceName() {
+ std::array<char, PROPERTY_VALUE_MAX> buffer;
+ property_get("wifi.concurrent.interface", buffer.data(), "wlan1");
+ return buffer.data();
+}
+*/
+
+std::string getP2pIfaceName() {
+ std::array<char, PROPERTY_VALUE_MAX> buffer;
+ property_get("wifi.direct.interface", buffer.data(), "p2p0");
+ return buffer.data();
+}
+
+} // namespace
namespace android {
namespace hardware {
@@ -49,10 +71,10 @@
namespace V1_2 {
namespace implementation {
using hidl_return_util::validateAndCall;
+using hidl_return_util::validateAndCallWithLock;
WifiChip::WifiChip(
- ChipId chip_id,
- const std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal,
+ ChipId chip_id, const std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal,
const std::weak_ptr<mode_controller::WifiModeController> mode_controller)
: chip_id_(chip_id),
legacy_hal_(legacy_hal),
@@ -62,844 +84,791 @@
debug_ring_buffer_cb_registered_(false) {}
void WifiChip::invalidate() {
- invalidateAndRemoveAllIfaces();
- legacy_hal_.reset();
- event_cb_handler_.invalidate();
- is_valid_ = false;
+ invalidateAndRemoveAllIfaces();
+ legacy_hal_.reset();
+ event_cb_handler_.invalidate();
+ is_valid_ = false;
}
-bool WifiChip::isValid() {
- return is_valid_;
-}
+bool WifiChip::isValid() { return is_valid_; }
std::set<sp<IWifiChipEventCallback>> WifiChip::getEventCallbacks() {
- return event_cb_handler_.getCallbacks();
+ return event_cb_handler_.getCallbacks();
}
Return<void> WifiChip::getId(getId_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
- &WifiChip::getIdInternal,
- hidl_status_cb);
+ return validateAndCall(this, WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
+ &WifiChip::getIdInternal, hidl_status_cb);
}
Return<void> WifiChip::registerEventCallback(
const sp<IWifiChipEventCallback>& event_callback,
registerEventCallback_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
- &WifiChip::registerEventCallbackInternal,
- hidl_status_cb,
- event_callback);
+ return validateAndCall(this, WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
+ &WifiChip::registerEventCallbackInternal,
+ hidl_status_cb, event_callback);
}
Return<void> WifiChip::getCapabilities(getCapabilities_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
- &WifiChip::getCapabilitiesInternal,
- hidl_status_cb);
+ return validateAndCall(this, WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
+ &WifiChip::getCapabilitiesInternal, hidl_status_cb);
}
Return<void> WifiChip::getAvailableModes(getAvailableModes_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
- &WifiChip::getAvailableModesInternal,
- hidl_status_cb);
+ return validateAndCall(this, WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
+ &WifiChip::getAvailableModesInternal,
+ hidl_status_cb);
}
Return<void> WifiChip::configureChip(ChipModeId mode_id,
configureChip_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
- &WifiChip::configureChipInternal,
- hidl_status_cb,
- mode_id);
+ return validateAndCallWithLock(
+ this, WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
+ &WifiChip::configureChipInternal, hidl_status_cb, mode_id);
}
Return<void> WifiChip::getMode(getMode_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
- &WifiChip::getModeInternal,
- hidl_status_cb);
+ return validateAndCall(this, WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
+ &WifiChip::getModeInternal, hidl_status_cb);
}
Return<void> WifiChip::requestChipDebugInfo(
requestChipDebugInfo_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
- &WifiChip::requestChipDebugInfoInternal,
- hidl_status_cb);
+ return validateAndCall(this, WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
+ &WifiChip::requestChipDebugInfoInternal,
+ hidl_status_cb);
}
Return<void> WifiChip::requestDriverDebugDump(
requestDriverDebugDump_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
- &WifiChip::requestDriverDebugDumpInternal,
- hidl_status_cb);
+ return validateAndCall(this, WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
+ &WifiChip::requestDriverDebugDumpInternal,
+ hidl_status_cb);
}
Return<void> WifiChip::requestFirmwareDebugDump(
requestFirmwareDebugDump_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
- &WifiChip::requestFirmwareDebugDumpInternal,
- hidl_status_cb);
+ return validateAndCall(this, WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
+ &WifiChip::requestFirmwareDebugDumpInternal,
+ hidl_status_cb);
}
Return<void> WifiChip::createApIface(createApIface_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
- &WifiChip::createApIfaceInternal,
- hidl_status_cb);
+ return validateAndCall(this, WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
+ &WifiChip::createApIfaceInternal, hidl_status_cb);
}
Return<void> WifiChip::getApIfaceNames(getApIfaceNames_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
- &WifiChip::getApIfaceNamesInternal,
- hidl_status_cb);
+ return validateAndCall(this, WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
+ &WifiChip::getApIfaceNamesInternal, hidl_status_cb);
}
Return<void> WifiChip::getApIface(const hidl_string& ifname,
getApIface_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
- &WifiChip::getApIfaceInternal,
- hidl_status_cb,
- ifname);
+ return validateAndCall(this, WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
+ &WifiChip::getApIfaceInternal, hidl_status_cb,
+ ifname);
}
Return<void> WifiChip::removeApIface(const hidl_string& ifname,
removeApIface_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
- &WifiChip::removeApIfaceInternal,
- hidl_status_cb,
- ifname);
+ return validateAndCall(this, WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
+ &WifiChip::removeApIfaceInternal, hidl_status_cb,
+ ifname);
}
Return<void> WifiChip::createNanIface(createNanIface_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
- &WifiChip::createNanIfaceInternal,
- hidl_status_cb);
+ return validateAndCall(this, WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
+ &WifiChip::createNanIfaceInternal, hidl_status_cb);
}
Return<void> WifiChip::getNanIfaceNames(getNanIfaceNames_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
- &WifiChip::getNanIfaceNamesInternal,
- hidl_status_cb);
+ return validateAndCall(this, WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
+ &WifiChip::getNanIfaceNamesInternal, hidl_status_cb);
}
Return<void> WifiChip::getNanIface(const hidl_string& ifname,
getNanIface_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
- &WifiChip::getNanIfaceInternal,
- hidl_status_cb,
- ifname);
+ return validateAndCall(this, WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
+ &WifiChip::getNanIfaceInternal, hidl_status_cb,
+ ifname);
}
Return<void> WifiChip::removeNanIface(const hidl_string& ifname,
removeNanIface_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
- &WifiChip::removeNanIfaceInternal,
- hidl_status_cb,
- ifname);
+ return validateAndCall(this, WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
+ &WifiChip::removeNanIfaceInternal, hidl_status_cb,
+ ifname);
}
Return<void> WifiChip::createP2pIface(createP2pIface_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
- &WifiChip::createP2pIfaceInternal,
- hidl_status_cb);
+ return validateAndCall(this, WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
+ &WifiChip::createP2pIfaceInternal, hidl_status_cb);
}
Return<void> WifiChip::getP2pIfaceNames(getP2pIfaceNames_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
- &WifiChip::getP2pIfaceNamesInternal,
- hidl_status_cb);
+ return validateAndCall(this, WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
+ &WifiChip::getP2pIfaceNamesInternal, hidl_status_cb);
}
Return<void> WifiChip::getP2pIface(const hidl_string& ifname,
getP2pIface_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
- &WifiChip::getP2pIfaceInternal,
- hidl_status_cb,
- ifname);
+ return validateAndCall(this, WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
+ &WifiChip::getP2pIfaceInternal, hidl_status_cb,
+ ifname);
}
Return<void> WifiChip::removeP2pIface(const hidl_string& ifname,
removeP2pIface_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
- &WifiChip::removeP2pIfaceInternal,
- hidl_status_cb,
- ifname);
+ return validateAndCall(this, WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
+ &WifiChip::removeP2pIfaceInternal, hidl_status_cb,
+ ifname);
}
Return<void> WifiChip::createStaIface(createStaIface_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
- &WifiChip::createStaIfaceInternal,
- hidl_status_cb);
+ return validateAndCall(this, WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
+ &WifiChip::createStaIfaceInternal, hidl_status_cb);
}
Return<void> WifiChip::getStaIfaceNames(getStaIfaceNames_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
- &WifiChip::getStaIfaceNamesInternal,
- hidl_status_cb);
+ return validateAndCall(this, WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
+ &WifiChip::getStaIfaceNamesInternal, hidl_status_cb);
}
Return<void> WifiChip::getStaIface(const hidl_string& ifname,
getStaIface_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
- &WifiChip::getStaIfaceInternal,
- hidl_status_cb,
- ifname);
+ return validateAndCall(this, WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
+ &WifiChip::getStaIfaceInternal, hidl_status_cb,
+ ifname);
}
Return<void> WifiChip::removeStaIface(const hidl_string& ifname,
removeStaIface_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
- &WifiChip::removeStaIfaceInternal,
- hidl_status_cb,
- ifname);
+ return validateAndCall(this, WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
+ &WifiChip::removeStaIfaceInternal, hidl_status_cb,
+ ifname);
}
Return<void> WifiChip::createRttController(
const sp<IWifiIface>& bound_iface, createRttController_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
- &WifiChip::createRttControllerInternal,
- hidl_status_cb,
- bound_iface);
+ return validateAndCall(this, WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
+ &WifiChip::createRttControllerInternal,
+ hidl_status_cb, bound_iface);
}
Return<void> WifiChip::getDebugRingBuffersStatus(
getDebugRingBuffersStatus_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
- &WifiChip::getDebugRingBuffersStatusInternal,
- hidl_status_cb);
+ return validateAndCall(this, WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
+ &WifiChip::getDebugRingBuffersStatusInternal,
+ hidl_status_cb);
}
Return<void> WifiChip::startLoggingToDebugRingBuffer(
- const hidl_string& ring_name,
- WifiDebugRingBufferVerboseLevel verbose_level,
- uint32_t max_interval_in_sec,
- uint32_t min_data_size_in_bytes,
+ const hidl_string& ring_name, WifiDebugRingBufferVerboseLevel verbose_level,
+ uint32_t max_interval_in_sec, uint32_t min_data_size_in_bytes,
startLoggingToDebugRingBuffer_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
- &WifiChip::startLoggingToDebugRingBufferInternal,
- hidl_status_cb,
- ring_name,
- verbose_level,
- max_interval_in_sec,
- min_data_size_in_bytes);
+ return validateAndCall(this, WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
+ &WifiChip::startLoggingToDebugRingBufferInternal,
+ hidl_status_cb, ring_name, verbose_level,
+ max_interval_in_sec, min_data_size_in_bytes);
}
Return<void> WifiChip::forceDumpToDebugRingBuffer(
const hidl_string& ring_name,
forceDumpToDebugRingBuffer_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
- &WifiChip::forceDumpToDebugRingBufferInternal,
- hidl_status_cb,
- ring_name);
+ return validateAndCall(this, WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
+ &WifiChip::forceDumpToDebugRingBufferInternal,
+ hidl_status_cb, ring_name);
}
Return<void> WifiChip::stopLoggingToDebugRingBuffer(
stopLoggingToDebugRingBuffer_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
- &WifiChip::stopLoggingToDebugRingBufferInternal,
- hidl_status_cb);
+ return validateAndCall(this, WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
+ &WifiChip::stopLoggingToDebugRingBufferInternal,
+ hidl_status_cb);
}
Return<void> WifiChip::getDebugHostWakeReasonStats(
getDebugHostWakeReasonStats_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
- &WifiChip::getDebugHostWakeReasonStatsInternal,
- hidl_status_cb);
+ return validateAndCall(this, WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
+ &WifiChip::getDebugHostWakeReasonStatsInternal,
+ hidl_status_cb);
}
Return<void> WifiChip::enableDebugErrorAlerts(
bool enable, enableDebugErrorAlerts_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
- &WifiChip::enableDebugErrorAlertsInternal,
- hidl_status_cb,
- enable);
+ return validateAndCall(this, WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
+ &WifiChip::enableDebugErrorAlertsInternal,
+ hidl_status_cb, enable);
}
Return<void> WifiChip::selectTxPowerScenario(
TxPowerScenario scenario, selectTxPowerScenario_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
- &WifiChip::selectTxPowerScenarioInternal,
- hidl_status_cb,
- scenario);
+ return validateAndCall(this, WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
+ &WifiChip::selectTxPowerScenarioInternal,
+ hidl_status_cb, scenario);
}
Return<void> WifiChip::resetTxPowerScenario(
resetTxPowerScenario_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
- &WifiChip::resetTxPowerScenarioInternal,
- hidl_status_cb);
+ return validateAndCall(this, WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
+ &WifiChip::resetTxPowerScenarioInternal,
+ hidl_status_cb);
}
void WifiChip::invalidateAndRemoveAllIfaces() {
- invalidateAndClear(ap_iface_);
- invalidateAndClear(nan_iface_);
- invalidateAndClear(p2p_iface_);
- invalidateAndClear(sta_iface_);
- // Since all the ifaces are invalid now, all RTT controller objects
- // using those ifaces also need to be invalidated.
- for (const auto& rtt : rtt_controllers_) {
- rtt->invalidate();
- }
- rtt_controllers_.clear();
+ invalidateAndClear(ap_iface_);
+ invalidateAndClear(nan_iface_);
+ invalidateAndClear(p2p_iface_);
+ invalidateAndClear(sta_iface_);
+ // Since all the ifaces are invalid now, all RTT controller objects
+ // using those ifaces also need to be invalidated.
+ for (const auto& rtt : rtt_controllers_) {
+ rtt->invalidate();
+ }
+ rtt_controllers_.clear();
}
std::pair<WifiStatus, ChipId> WifiChip::getIdInternal() {
- return {createWifiStatus(WifiStatusCode::SUCCESS), chip_id_};
+ return {createWifiStatus(WifiStatusCode::SUCCESS), chip_id_};
}
WifiStatus WifiChip::registerEventCallbackInternal(
const sp<IWifiChipEventCallback>& event_callback) {
- if (!event_cb_handler_.addCallback(event_callback)) {
- return createWifiStatus(WifiStatusCode::ERROR_UNKNOWN);
- }
- return createWifiStatus(WifiStatusCode::SUCCESS);
+ if (!event_cb_handler_.addCallback(event_callback)) {
+ return createWifiStatus(WifiStatusCode::ERROR_UNKNOWN);
+ }
+ return createWifiStatus(WifiStatusCode::SUCCESS);
}
std::pair<WifiStatus, uint32_t> WifiChip::getCapabilitiesInternal() {
- legacy_hal::wifi_error legacy_status;
- uint32_t legacy_feature_set;
- uint32_t legacy_logger_feature_set;
- std::tie(legacy_status, legacy_feature_set) =
- legacy_hal_.lock()->getSupportedFeatureSet();
- if (legacy_status != legacy_hal::WIFI_SUCCESS) {
- return {createWifiStatusFromLegacyError(legacy_status), 0};
- }
- std::tie(legacy_status, legacy_logger_feature_set) =
- legacy_hal_.lock()->getLoggerSupportedFeatureSet();
- if (legacy_status != legacy_hal::WIFI_SUCCESS) {
- return {createWifiStatusFromLegacyError(legacy_status), 0};
- }
- uint32_t hidl_caps;
- if (!hidl_struct_util::convertLegacyFeaturesToHidlChipCapabilities(
- legacy_feature_set, legacy_logger_feature_set, &hidl_caps)) {
- return {createWifiStatus(WifiStatusCode::ERROR_UNKNOWN), 0};
- }
- return {createWifiStatus(WifiStatusCode::SUCCESS), hidl_caps};
+ legacy_hal::wifi_error legacy_status;
+ uint32_t legacy_feature_set;
+ uint32_t legacy_logger_feature_set;
+ std::tie(legacy_status, legacy_feature_set) =
+ legacy_hal_.lock()->getSupportedFeatureSet(getWlan0IfaceName());
+ if (legacy_status != legacy_hal::WIFI_SUCCESS) {
+ return {createWifiStatusFromLegacyError(legacy_status), 0};
+ }
+ std::tie(legacy_status, legacy_logger_feature_set) =
+ legacy_hal_.lock()->getLoggerSupportedFeatureSet(getWlan0IfaceName());
+ if (legacy_status != legacy_hal::WIFI_SUCCESS) {
+ return {createWifiStatusFromLegacyError(legacy_status), 0};
+ }
+ uint32_t hidl_caps;
+ if (!hidl_struct_util::convertLegacyFeaturesToHidlChipCapabilities(
+ legacy_feature_set, legacy_logger_feature_set, &hidl_caps)) {
+ return {createWifiStatus(WifiStatusCode::ERROR_UNKNOWN), 0};
+ }
+ return {createWifiStatus(WifiStatusCode::SUCCESS), hidl_caps};
}
std::pair<WifiStatus, std::vector<IWifiChip::ChipMode>>
WifiChip::getAvailableModesInternal() {
- // The chip combination supported for current devices is fixed for now with
- // 2 separate modes of operation:
- // Mode 1 (STA mode): Will support 1 STA and 1 P2P or NAN iface operations
- // concurrently [NAN conditional on wifiHidlFeatureAware]
- // Mode 2 (AP mode): Will support 1 AP iface operations.
- // TODO (b/32997844): Read this from some device specific flags in the
- // makefile.
- // STA mode iface combinations.
- const IWifiChip::ChipIfaceCombinationLimit
- sta_chip_iface_combination_limit_1 = {{IfaceType::STA}, 1};
- IWifiChip::ChipIfaceCombinationLimit sta_chip_iface_combination_limit_2;
- if (WifiFeatureFlags::wifiHidlFeatureAware) {
- sta_chip_iface_combination_limit_2 = {{IfaceType::P2P, IfaceType::NAN},
- 1};
- } else {
- sta_chip_iface_combination_limit_2 = {{IfaceType::P2P},
- 1};
- }
- const IWifiChip::ChipIfaceCombination sta_chip_iface_combination = {
- {sta_chip_iface_combination_limit_1, sta_chip_iface_combination_limit_2}};
- const IWifiChip::ChipMode sta_chip_mode = {kStaChipModeId,
- {sta_chip_iface_combination}};
- // AP mode iface combinations.
- const IWifiChip::ChipIfaceCombinationLimit ap_chip_iface_combination_limit = {
- {IfaceType::AP}, 1};
- const IWifiChip::ChipIfaceCombination ap_chip_iface_combination = {
- {ap_chip_iface_combination_limit}};
- const IWifiChip::ChipMode ap_chip_mode = {kApChipModeId,
- {ap_chip_iface_combination}};
- return {createWifiStatus(WifiStatusCode::SUCCESS),
- {sta_chip_mode, ap_chip_mode}};
+ // The chip combination supported for current devices is fixed for now with
+ // 2 separate modes of operation:
+ // Mode 1 (STA mode): Will support 1 STA and 1 P2P or NAN iface operations
+ // concurrently [NAN conditional on wifiHidlFeatureAware]
+ // Mode 2 (AP mode): Will support 1 AP iface operations.
+ // TODO (b/32997844): Read this from some device specific flags in the
+ // makefile.
+ // STA mode iface combinations.
+ const IWifiChip::ChipIfaceCombinationLimit
+ sta_chip_iface_combination_limit_1 = {{IfaceType::STA}, 1};
+ IWifiChip::ChipIfaceCombinationLimit sta_chip_iface_combination_limit_2;
+ if (WifiFeatureFlags::wifiHidlFeatureAware) {
+ sta_chip_iface_combination_limit_2 = {{IfaceType::P2P, IfaceType::NAN},
+ 1};
+ } else {
+ sta_chip_iface_combination_limit_2 = {{IfaceType::P2P}, 1};
+ }
+ const IWifiChip::ChipIfaceCombination sta_chip_iface_combination = {
+ {sta_chip_iface_combination_limit_1,
+ sta_chip_iface_combination_limit_2}};
+ const IWifiChip::ChipMode sta_chip_mode = {kStaChipModeId,
+ {sta_chip_iface_combination}};
+ // AP mode iface combinations.
+ const IWifiChip::ChipIfaceCombinationLimit ap_chip_iface_combination_limit =
+ {{IfaceType::AP}, 1};
+ const IWifiChip::ChipIfaceCombination ap_chip_iface_combination = {
+ {ap_chip_iface_combination_limit}};
+ const IWifiChip::ChipMode ap_chip_mode = {kApChipModeId,
+ {ap_chip_iface_combination}};
+ return {createWifiStatus(WifiStatusCode::SUCCESS),
+ {sta_chip_mode, ap_chip_mode}};
}
-WifiStatus WifiChip::configureChipInternal(ChipModeId mode_id) {
- if (mode_id != kStaChipModeId && mode_id != kApChipModeId) {
- return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
- }
- if (mode_id == current_mode_id_) {
- LOG(DEBUG) << "Already in the specified mode " << mode_id;
- return createWifiStatus(WifiStatusCode::SUCCESS);
- }
- WifiStatus status = handleChipConfiguration(mode_id);
- if (status.code != WifiStatusCode::SUCCESS) {
+WifiStatus WifiChip::configureChipInternal(
+ /* NONNULL */ std::unique_lock<std::recursive_mutex>* lock,
+ ChipModeId mode_id) {
+ if (mode_id != kStaChipModeId && mode_id != kApChipModeId) {
+ return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
+ }
+ if (mode_id == current_mode_id_) {
+ LOG(DEBUG) << "Already in the specified mode " << mode_id;
+ return createWifiStatus(WifiStatusCode::SUCCESS);
+ }
+ WifiStatus status = handleChipConfiguration(lock, mode_id);
+ if (status.code != WifiStatusCode::SUCCESS) {
+ for (const auto& callback : event_cb_handler_.getCallbacks()) {
+ if (!callback->onChipReconfigureFailure(status).isOk()) {
+ LOG(ERROR)
+ << "Failed to invoke onChipReconfigureFailure callback";
+ }
+ }
+ return status;
+ }
for (const auto& callback : event_cb_handler_.getCallbacks()) {
- if (!callback->onChipReconfigureFailure(status).isOk()) {
- LOG(ERROR) << "Failed to invoke onChipReconfigureFailure callback";
- }
+ if (!callback->onChipReconfigured(mode_id).isOk()) {
+ LOG(ERROR) << "Failed to invoke onChipReconfigured callback";
+ }
}
+ current_mode_id_ = mode_id;
+ LOG(INFO) << "Configured chip in mode " << mode_id;
return status;
- }
- for (const auto& callback : event_cb_handler_.getCallbacks()) {
- if (!callback->onChipReconfigured(mode_id).isOk()) {
- LOG(ERROR) << "Failed to invoke onChipReconfigured callback";
- }
- }
- current_mode_id_ = mode_id;
- return status;
}
std::pair<WifiStatus, uint32_t> WifiChip::getModeInternal() {
- if (current_mode_id_ == kInvalidModeId) {
- return {createWifiStatus(WifiStatusCode::ERROR_NOT_AVAILABLE),
- current_mode_id_};
- }
- return {createWifiStatus(WifiStatusCode::SUCCESS), current_mode_id_};
+ if (current_mode_id_ == kInvalidModeId) {
+ return {createWifiStatus(WifiStatusCode::ERROR_NOT_AVAILABLE),
+ current_mode_id_};
+ }
+ return {createWifiStatus(WifiStatusCode::SUCCESS), current_mode_id_};
}
std::pair<WifiStatus, IWifiChip::ChipDebugInfo>
WifiChip::requestChipDebugInfoInternal() {
- IWifiChip::ChipDebugInfo result;
- legacy_hal::wifi_error legacy_status;
- std::string driver_desc;
- std::tie(legacy_status, driver_desc) = legacy_hal_.lock()->getDriverVersion();
- if (legacy_status != legacy_hal::WIFI_SUCCESS) {
- LOG(ERROR) << "Failed to get driver version: "
- << legacyErrorToString(legacy_status);
- WifiStatus status = createWifiStatusFromLegacyError(
- legacy_status, "failed to get driver version");
- return {status, result};
- }
- result.driverDescription = driver_desc.c_str();
+ IWifiChip::ChipDebugInfo result;
+ legacy_hal::wifi_error legacy_status;
+ std::string driver_desc;
+ std::tie(legacy_status, driver_desc) =
+ legacy_hal_.lock()->getDriverVersion(getWlan0IfaceName());
+ if (legacy_status != legacy_hal::WIFI_SUCCESS) {
+ LOG(ERROR) << "Failed to get driver version: "
+ << legacyErrorToString(legacy_status);
+ WifiStatus status = createWifiStatusFromLegacyError(
+ legacy_status, "failed to get driver version");
+ return {status, result};
+ }
+ result.driverDescription = driver_desc.c_str();
- std::string firmware_desc;
- std::tie(legacy_status, firmware_desc) =
- legacy_hal_.lock()->getFirmwareVersion();
- if (legacy_status != legacy_hal::WIFI_SUCCESS) {
- LOG(ERROR) << "Failed to get firmware version: "
- << legacyErrorToString(legacy_status);
- WifiStatus status = createWifiStatusFromLegacyError(
- legacy_status, "failed to get firmware version");
- return {status, result};
- }
- result.firmwareDescription = firmware_desc.c_str();
+ std::string firmware_desc;
+ std::tie(legacy_status, firmware_desc) =
+ legacy_hal_.lock()->getFirmwareVersion(getWlan0IfaceName());
+ if (legacy_status != legacy_hal::WIFI_SUCCESS) {
+ LOG(ERROR) << "Failed to get firmware version: "
+ << legacyErrorToString(legacy_status);
+ WifiStatus status = createWifiStatusFromLegacyError(
+ legacy_status, "failed to get firmware version");
+ return {status, result};
+ }
+ result.firmwareDescription = firmware_desc.c_str();
- return {createWifiStatus(WifiStatusCode::SUCCESS), result};
+ return {createWifiStatus(WifiStatusCode::SUCCESS), result};
}
std::pair<WifiStatus, std::vector<uint8_t>>
WifiChip::requestDriverDebugDumpInternal() {
- legacy_hal::wifi_error legacy_status;
- std::vector<uint8_t> driver_dump;
- std::tie(legacy_status, driver_dump) =
- legacy_hal_.lock()->requestDriverMemoryDump();
- if (legacy_status != legacy_hal::WIFI_SUCCESS) {
- LOG(ERROR) << "Failed to get driver debug dump: "
- << legacyErrorToString(legacy_status);
- return {createWifiStatusFromLegacyError(legacy_status),
- std::vector<uint8_t>()};
- }
- return {createWifiStatus(WifiStatusCode::SUCCESS), driver_dump};
+ legacy_hal::wifi_error legacy_status;
+ std::vector<uint8_t> driver_dump;
+ std::tie(legacy_status, driver_dump) =
+ legacy_hal_.lock()->requestDriverMemoryDump(getWlan0IfaceName());
+ if (legacy_status != legacy_hal::WIFI_SUCCESS) {
+ LOG(ERROR) << "Failed to get driver debug dump: "
+ << legacyErrorToString(legacy_status);
+ return {createWifiStatusFromLegacyError(legacy_status),
+ std::vector<uint8_t>()};
+ }
+ return {createWifiStatus(WifiStatusCode::SUCCESS), driver_dump};
}
std::pair<WifiStatus, std::vector<uint8_t>>
WifiChip::requestFirmwareDebugDumpInternal() {
- legacy_hal::wifi_error legacy_status;
- std::vector<uint8_t> firmware_dump;
- std::tie(legacy_status, firmware_dump) =
- legacy_hal_.lock()->requestFirmwareMemoryDump();
- if (legacy_status != legacy_hal::WIFI_SUCCESS) {
- LOG(ERROR) << "Failed to get firmware debug dump: "
- << legacyErrorToString(legacy_status);
- return {createWifiStatusFromLegacyError(legacy_status), {}};
- }
- return {createWifiStatus(WifiStatusCode::SUCCESS), firmware_dump};
+ legacy_hal::wifi_error legacy_status;
+ std::vector<uint8_t> firmware_dump;
+ std::tie(legacy_status, firmware_dump) =
+ legacy_hal_.lock()->requestFirmwareMemoryDump(getWlan0IfaceName());
+ if (legacy_status != legacy_hal::WIFI_SUCCESS) {
+ LOG(ERROR) << "Failed to get firmware debug dump: "
+ << legacyErrorToString(legacy_status);
+ return {createWifiStatusFromLegacyError(legacy_status), {}};
+ }
+ return {createWifiStatus(WifiStatusCode::SUCCESS), firmware_dump};
}
std::pair<WifiStatus, sp<IWifiApIface>> WifiChip::createApIfaceInternal() {
- if (current_mode_id_ != kApChipModeId || ap_iface_.get()) {
- return {createWifiStatus(WifiStatusCode::ERROR_NOT_AVAILABLE), {}};
- }
- std::string ifname = legacy_hal_.lock()->getApIfaceName();
- ap_iface_ = new WifiApIface(ifname, legacy_hal_);
- for (const auto& callback : event_cb_handler_.getCallbacks()) {
- if (!callback->onIfaceAdded(IfaceType::AP, ifname).isOk()) {
- LOG(ERROR) << "Failed to invoke onIfaceAdded callback";
+ if (current_mode_id_ != kApChipModeId || ap_iface_.get()) {
+ return {createWifiStatus(WifiStatusCode::ERROR_NOT_AVAILABLE), {}};
}
- }
- return {createWifiStatus(WifiStatusCode::SUCCESS), ap_iface_};
+ std::string ifname = getWlan0IfaceName();
+ ap_iface_ = new WifiApIface(ifname, legacy_hal_);
+ for (const auto& callback : event_cb_handler_.getCallbacks()) {
+ if (!callback->onIfaceAdded(IfaceType::AP, ifname).isOk()) {
+ LOG(ERROR) << "Failed to invoke onIfaceAdded callback";
+ }
+ }
+ return {createWifiStatus(WifiStatusCode::SUCCESS), ap_iface_};
}
std::pair<WifiStatus, std::vector<hidl_string>>
WifiChip::getApIfaceNamesInternal() {
- if (!ap_iface_.get()) {
- return {createWifiStatus(WifiStatusCode::SUCCESS), {}};
- }
- return {createWifiStatus(WifiStatusCode::SUCCESS),
- {legacy_hal_.lock()->getApIfaceName()}};
+ if (!ap_iface_.get()) {
+ return {createWifiStatus(WifiStatusCode::SUCCESS), {}};
+ }
+ return {createWifiStatus(WifiStatusCode::SUCCESS), {getWlan0IfaceName()}};
}
std::pair<WifiStatus, sp<IWifiApIface>> WifiChip::getApIfaceInternal(
const std::string& ifname) {
- if (!ap_iface_.get() || (ifname != legacy_hal_.lock()->getApIfaceName())) {
- return {createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS), nullptr};
- }
- return {createWifiStatus(WifiStatusCode::SUCCESS), ap_iface_};
+ if (!ap_iface_.get() || (ifname != getWlan0IfaceName())) {
+ return {createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS), nullptr};
+ }
+ return {createWifiStatus(WifiStatusCode::SUCCESS), ap_iface_};
}
WifiStatus WifiChip::removeApIfaceInternal(const std::string& ifname) {
- if (!ap_iface_.get() || (ifname != legacy_hal_.lock()->getApIfaceName())) {
- return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
- }
- invalidateAndClear(ap_iface_);
- for (const auto& callback : event_cb_handler_.getCallbacks()) {
- if (!callback->onIfaceRemoved(IfaceType::AP, ifname).isOk()) {
- LOG(ERROR) << "Failed to invoke onIfaceRemoved callback";
+ if (!ap_iface_.get() || (ifname != getWlan0IfaceName())) {
+ return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
}
- }
- return createWifiStatus(WifiStatusCode::SUCCESS);
+ invalidateAndClear(ap_iface_);
+ for (const auto& callback : event_cb_handler_.getCallbacks()) {
+ if (!callback->onIfaceRemoved(IfaceType::AP, ifname).isOk()) {
+ LOG(ERROR) << "Failed to invoke onIfaceRemoved callback";
+ }
+ }
+ return createWifiStatus(WifiStatusCode::SUCCESS);
}
std::pair<WifiStatus, sp<IWifiNanIface>> WifiChip::createNanIfaceInternal() {
- // Only 1 of NAN or P2P iface can be active at a time.
- if (WifiFeatureFlags::wifiHidlFeatureAware) {
- if (current_mode_id_ != kStaChipModeId || nan_iface_.get() ||
- p2p_iface_.get()) {
- return {createWifiStatus(WifiStatusCode::ERROR_NOT_AVAILABLE), {}};
+ // Only 1 of NAN or P2P iface can be active at a time.
+ if (WifiFeatureFlags::wifiHidlFeatureAware) {
+ if (current_mode_id_ != kStaChipModeId || nan_iface_.get() ||
+ p2p_iface_.get()) {
+ return {createWifiStatus(WifiStatusCode::ERROR_NOT_AVAILABLE), {}};
+ }
+ std::string ifname = getWlan0IfaceName();
+ nan_iface_ = new WifiNanIface(ifname, legacy_hal_);
+ for (const auto& callback : event_cb_handler_.getCallbacks()) {
+ if (!callback->onIfaceAdded(IfaceType::NAN, ifname).isOk()) {
+ LOG(ERROR) << "Failed to invoke onIfaceAdded callback";
+ }
+ }
+ return {createWifiStatus(WifiStatusCode::SUCCESS), nan_iface_};
+ } else {
+ return {createWifiStatus(WifiStatusCode::ERROR_NOT_AVAILABLE), {}};
}
- std::string ifname = legacy_hal_.lock()->getNanIfaceName();
- nan_iface_ = new WifiNanIface(ifname, legacy_hal_);
- for (const auto& callback : event_cb_handler_.getCallbacks()) {
- if (!callback->onIfaceAdded(IfaceType::NAN, ifname).isOk()) {
- LOG(ERROR) << "Failed to invoke onIfaceAdded callback";
- }
- }
- return {createWifiStatus(WifiStatusCode::SUCCESS), nan_iface_};
- } else {
- return {createWifiStatus(WifiStatusCode::ERROR_NOT_AVAILABLE), {}};
- }
}
std::pair<WifiStatus, std::vector<hidl_string>>
WifiChip::getNanIfaceNamesInternal() {
- if (!nan_iface_.get()) {
- return {createWifiStatus(WifiStatusCode::SUCCESS), {}};
- }
- return {createWifiStatus(WifiStatusCode::SUCCESS),
- {legacy_hal_.lock()->getNanIfaceName()}};
+ if (!nan_iface_.get()) {
+ return {createWifiStatus(WifiStatusCode::SUCCESS), {}};
+ }
+ return {createWifiStatus(WifiStatusCode::SUCCESS), {getWlan0IfaceName()}};
}
std::pair<WifiStatus, sp<IWifiNanIface>> WifiChip::getNanIfaceInternal(
const std::string& ifname) {
- if (!nan_iface_.get() || (ifname != legacy_hal_.lock()->getNanIfaceName())) {
- return {createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS), nullptr};
- }
- return {createWifiStatus(WifiStatusCode::SUCCESS), nan_iface_};
+ if (!nan_iface_.get() || (ifname != getWlan0IfaceName())) {
+ return {createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS), nullptr};
+ }
+ return {createWifiStatus(WifiStatusCode::SUCCESS), nan_iface_};
}
WifiStatus WifiChip::removeNanIfaceInternal(const std::string& ifname) {
- if (!nan_iface_.get() || (ifname != legacy_hal_.lock()->getNanIfaceName())) {
- return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
- }
- invalidateAndClear(nan_iface_);
- for (const auto& callback : event_cb_handler_.getCallbacks()) {
- if (!callback->onIfaceRemoved(IfaceType::NAN, ifname).isOk()) {
- LOG(ERROR) << "Failed to invoke onIfaceAdded callback";
+ if (!nan_iface_.get() || (ifname != getWlan0IfaceName())) {
+ return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
}
- }
- return createWifiStatus(WifiStatusCode::SUCCESS);
+ invalidateAndClear(nan_iface_);
+ for (const auto& callback : event_cb_handler_.getCallbacks()) {
+ if (!callback->onIfaceRemoved(IfaceType::NAN, ifname).isOk()) {
+ LOG(ERROR) << "Failed to invoke onIfaceAdded callback";
+ }
+ }
+ return createWifiStatus(WifiStatusCode::SUCCESS);
}
std::pair<WifiStatus, sp<IWifiP2pIface>> WifiChip::createP2pIfaceInternal() {
- // Only 1 of NAN or P2P iface can be active at a time.
- if (current_mode_id_ != kStaChipModeId || p2p_iface_.get() ||
- nan_iface_.get()) {
- return {createWifiStatus(WifiStatusCode::ERROR_NOT_AVAILABLE), {}};
- }
- std::string ifname = legacy_hal_.lock()->getP2pIfaceName();
- p2p_iface_ = new WifiP2pIface(ifname, legacy_hal_);
- for (const auto& callback : event_cb_handler_.getCallbacks()) {
- if (!callback->onIfaceAdded(IfaceType::P2P, ifname).isOk()) {
- LOG(ERROR) << "Failed to invoke onIfaceAdded callback";
+ // Only 1 of NAN or P2P iface can be active at a time.
+ if (current_mode_id_ != kStaChipModeId || p2p_iface_.get() ||
+ nan_iface_.get()) {
+ return {createWifiStatus(WifiStatusCode::ERROR_NOT_AVAILABLE), {}};
}
- }
- return {createWifiStatus(WifiStatusCode::SUCCESS), p2p_iface_};
+ std::string ifname = getP2pIfaceName();
+ p2p_iface_ = new WifiP2pIface(ifname, legacy_hal_);
+ for (const auto& callback : event_cb_handler_.getCallbacks()) {
+ if (!callback->onIfaceAdded(IfaceType::P2P, ifname).isOk()) {
+ LOG(ERROR) << "Failed to invoke onIfaceAdded callback";
+ }
+ }
+ return {createWifiStatus(WifiStatusCode::SUCCESS), p2p_iface_};
}
std::pair<WifiStatus, std::vector<hidl_string>>
WifiChip::getP2pIfaceNamesInternal() {
- if (!p2p_iface_.get()) {
- return {createWifiStatus(WifiStatusCode::SUCCESS), {}};
- }
- return {createWifiStatus(WifiStatusCode::SUCCESS),
- {legacy_hal_.lock()->getP2pIfaceName()}};
+ if (!p2p_iface_.get()) {
+ return {createWifiStatus(WifiStatusCode::SUCCESS), {}};
+ }
+ return {createWifiStatus(WifiStatusCode::SUCCESS), {getP2pIfaceName()}};
}
std::pair<WifiStatus, sp<IWifiP2pIface>> WifiChip::getP2pIfaceInternal(
const std::string& ifname) {
- if (!p2p_iface_.get() || (ifname != legacy_hal_.lock()->getP2pIfaceName())) {
- return {createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS), nullptr};
- }
- return {createWifiStatus(WifiStatusCode::SUCCESS), p2p_iface_};
+ if (!p2p_iface_.get() || (ifname != getP2pIfaceName())) {
+ return {createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS), nullptr};
+ }
+ return {createWifiStatus(WifiStatusCode::SUCCESS), p2p_iface_};
}
WifiStatus WifiChip::removeP2pIfaceInternal(const std::string& ifname) {
- if (!p2p_iface_.get() || (ifname != legacy_hal_.lock()->getP2pIfaceName())) {
- return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
- }
- invalidateAndClear(p2p_iface_);
- for (const auto& callback : event_cb_handler_.getCallbacks()) {
- if (!callback->onIfaceRemoved(IfaceType::P2P, ifname).isOk()) {
- LOG(ERROR) << "Failed to invoke onIfaceRemoved callback";
+ if (!p2p_iface_.get() || (ifname != getP2pIfaceName())) {
+ return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
}
- }
- return createWifiStatus(WifiStatusCode::SUCCESS);
+ invalidateAndClear(p2p_iface_);
+ for (const auto& callback : event_cb_handler_.getCallbacks()) {
+ if (!callback->onIfaceRemoved(IfaceType::P2P, ifname).isOk()) {
+ LOG(ERROR) << "Failed to invoke onIfaceRemoved callback";
+ }
+ }
+ return createWifiStatus(WifiStatusCode::SUCCESS);
}
std::pair<WifiStatus, sp<IWifiStaIface>> WifiChip::createStaIfaceInternal() {
- if (current_mode_id_ != kStaChipModeId || sta_iface_.get()) {
- return {createWifiStatus(WifiStatusCode::ERROR_NOT_AVAILABLE), {}};
- }
- std::string ifname = legacy_hal_.lock()->getStaIfaceName();
- sta_iface_ = new WifiStaIface(ifname, legacy_hal_);
- for (const auto& callback : event_cb_handler_.getCallbacks()) {
- if (!callback->onIfaceAdded(IfaceType::STA, ifname).isOk()) {
- LOG(ERROR) << "Failed to invoke onIfaceAdded callback";
+ if (current_mode_id_ != kStaChipModeId || sta_iface_.get()) {
+ return {createWifiStatus(WifiStatusCode::ERROR_NOT_AVAILABLE), {}};
}
- }
- return {createWifiStatus(WifiStatusCode::SUCCESS), sta_iface_};
+ std::string ifname = getWlan0IfaceName();
+ sta_iface_ = new WifiStaIface(ifname, legacy_hal_);
+ for (const auto& callback : event_cb_handler_.getCallbacks()) {
+ if (!callback->onIfaceAdded(IfaceType::STA, ifname).isOk()) {
+ LOG(ERROR) << "Failed to invoke onIfaceAdded callback";
+ }
+ }
+ return {createWifiStatus(WifiStatusCode::SUCCESS), sta_iface_};
}
std::pair<WifiStatus, std::vector<hidl_string>>
WifiChip::getStaIfaceNamesInternal() {
- if (!sta_iface_.get()) {
- return {createWifiStatus(WifiStatusCode::SUCCESS), {}};
- }
- return {createWifiStatus(WifiStatusCode::SUCCESS),
- {legacy_hal_.lock()->getStaIfaceName()}};
+ if (!sta_iface_.get()) {
+ return {createWifiStatus(WifiStatusCode::SUCCESS), {}};
+ }
+ return {createWifiStatus(WifiStatusCode::SUCCESS), {getWlan0IfaceName()}};
}
std::pair<WifiStatus, sp<IWifiStaIface>> WifiChip::getStaIfaceInternal(
const std::string& ifname) {
- if (!sta_iface_.get() || (ifname != legacy_hal_.lock()->getStaIfaceName())) {
- return {createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS), nullptr};
- }
- return {createWifiStatus(WifiStatusCode::SUCCESS), sta_iface_};
+ if (!sta_iface_.get() || (ifname != getWlan0IfaceName())) {
+ return {createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS), nullptr};
+ }
+ return {createWifiStatus(WifiStatusCode::SUCCESS), sta_iface_};
}
WifiStatus WifiChip::removeStaIfaceInternal(const std::string& ifname) {
- if (!sta_iface_.get() || (ifname != legacy_hal_.lock()->getStaIfaceName())) {
- return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
- }
- invalidateAndClear(sta_iface_);
- for (const auto& callback : event_cb_handler_.getCallbacks()) {
- if (!callback->onIfaceRemoved(IfaceType::STA, ifname).isOk()) {
- LOG(ERROR) << "Failed to invoke onIfaceRemoved callback";
+ if (!sta_iface_.get() || (ifname != getWlan0IfaceName())) {
+ return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
}
- }
- return createWifiStatus(WifiStatusCode::SUCCESS);
+ invalidateAndClear(sta_iface_);
+ for (const auto& callback : event_cb_handler_.getCallbacks()) {
+ if (!callback->onIfaceRemoved(IfaceType::STA, ifname).isOk()) {
+ LOG(ERROR) << "Failed to invoke onIfaceRemoved callback";
+ }
+ }
+ return createWifiStatus(WifiStatusCode::SUCCESS);
}
std::pair<WifiStatus, sp<IWifiRttController>>
WifiChip::createRttControllerInternal(const sp<IWifiIface>& bound_iface) {
- sp<WifiRttController> rtt = new WifiRttController(bound_iface, legacy_hal_);
- rtt_controllers_.emplace_back(rtt);
- return {createWifiStatus(WifiStatusCode::SUCCESS), rtt};
+ sp<WifiRttController> rtt =
+ new WifiRttController(getWlan0IfaceName(), bound_iface, legacy_hal_);
+ rtt_controllers_.emplace_back(rtt);
+ return {createWifiStatus(WifiStatusCode::SUCCESS), rtt};
}
std::pair<WifiStatus, std::vector<WifiDebugRingBufferStatus>>
WifiChip::getDebugRingBuffersStatusInternal() {
- legacy_hal::wifi_error legacy_status;
- std::vector<legacy_hal::wifi_ring_buffer_status>
- legacy_ring_buffer_status_vec;
- std::tie(legacy_status, legacy_ring_buffer_status_vec) =
- legacy_hal_.lock()->getRingBuffersStatus();
- if (legacy_status != legacy_hal::WIFI_SUCCESS) {
- return {createWifiStatusFromLegacyError(legacy_status), {}};
- }
- std::vector<WifiDebugRingBufferStatus> hidl_ring_buffer_status_vec;
- if (!hidl_struct_util::convertLegacyVectorOfDebugRingBufferStatusToHidl(
- legacy_ring_buffer_status_vec, &hidl_ring_buffer_status_vec)) {
- return {createWifiStatus(WifiStatusCode::ERROR_UNKNOWN), {}};
- }
- return {createWifiStatus(WifiStatusCode::SUCCESS),
- hidl_ring_buffer_status_vec};
+ legacy_hal::wifi_error legacy_status;
+ std::vector<legacy_hal::wifi_ring_buffer_status>
+ legacy_ring_buffer_status_vec;
+ std::tie(legacy_status, legacy_ring_buffer_status_vec) =
+ legacy_hal_.lock()->getRingBuffersStatus(getWlan0IfaceName());
+ if (legacy_status != legacy_hal::WIFI_SUCCESS) {
+ return {createWifiStatusFromLegacyError(legacy_status), {}};
+ }
+ std::vector<WifiDebugRingBufferStatus> hidl_ring_buffer_status_vec;
+ if (!hidl_struct_util::convertLegacyVectorOfDebugRingBufferStatusToHidl(
+ legacy_ring_buffer_status_vec, &hidl_ring_buffer_status_vec)) {
+ return {createWifiStatus(WifiStatusCode::ERROR_UNKNOWN), {}};
+ }
+ return {createWifiStatus(WifiStatusCode::SUCCESS),
+ hidl_ring_buffer_status_vec};
}
WifiStatus WifiChip::startLoggingToDebugRingBufferInternal(
- const hidl_string& ring_name,
- WifiDebugRingBufferVerboseLevel verbose_level,
- uint32_t max_interval_in_sec,
- uint32_t min_data_size_in_bytes) {
- WifiStatus status = registerDebugRingBufferCallback();
- if (status.code != WifiStatusCode::SUCCESS) {
- return status;
- }
- legacy_hal::wifi_error legacy_status =
- legacy_hal_.lock()->startRingBufferLogging(
- ring_name,
- static_cast<
- std::underlying_type<WifiDebugRingBufferVerboseLevel>::type>(
- verbose_level),
- max_interval_in_sec,
- min_data_size_in_bytes);
- return createWifiStatusFromLegacyError(legacy_status);
+ const hidl_string& ring_name, WifiDebugRingBufferVerboseLevel verbose_level,
+ uint32_t max_interval_in_sec, uint32_t min_data_size_in_bytes) {
+ WifiStatus status = registerDebugRingBufferCallback();
+ if (status.code != WifiStatusCode::SUCCESS) {
+ return status;
+ }
+ legacy_hal::wifi_error legacy_status =
+ legacy_hal_.lock()->startRingBufferLogging(
+ getWlan0IfaceName(), ring_name,
+ static_cast<
+ std::underlying_type<WifiDebugRingBufferVerboseLevel>::type>(
+ verbose_level),
+ max_interval_in_sec, min_data_size_in_bytes);
+ return createWifiStatusFromLegacyError(legacy_status);
}
WifiStatus WifiChip::forceDumpToDebugRingBufferInternal(
const hidl_string& ring_name) {
- WifiStatus status = registerDebugRingBufferCallback();
- if (status.code != WifiStatusCode::SUCCESS) {
- return status;
- }
- legacy_hal::wifi_error legacy_status =
- legacy_hal_.lock()->getRingBufferData(ring_name);
- return createWifiStatusFromLegacyError(legacy_status);
+ WifiStatus status = registerDebugRingBufferCallback();
+ if (status.code != WifiStatusCode::SUCCESS) {
+ return status;
+ }
+ legacy_hal::wifi_error legacy_status =
+ legacy_hal_.lock()->getRingBufferData(getWlan0IfaceName(), ring_name);
+ return createWifiStatusFromLegacyError(legacy_status);
}
WifiStatus WifiChip::stopLoggingToDebugRingBufferInternal() {
- legacy_hal::wifi_error legacy_status =
- legacy_hal_.lock()->deregisterRingBufferCallbackHandler();
- return createWifiStatusFromLegacyError(legacy_status);
+ legacy_hal::wifi_error legacy_status =
+ legacy_hal_.lock()->deregisterRingBufferCallbackHandler(
+ getWlan0IfaceName());
+ return createWifiStatusFromLegacyError(legacy_status);
}
std::pair<WifiStatus, WifiDebugHostWakeReasonStats>
WifiChip::getDebugHostWakeReasonStatsInternal() {
- legacy_hal::wifi_error legacy_status;
- legacy_hal::WakeReasonStats legacy_stats;
- std::tie(legacy_status, legacy_stats) =
- legacy_hal_.lock()->getWakeReasonStats();
- if (legacy_status != legacy_hal::WIFI_SUCCESS) {
- return {createWifiStatusFromLegacyError(legacy_status), {}};
- }
- WifiDebugHostWakeReasonStats hidl_stats;
- if (!hidl_struct_util::convertLegacyWakeReasonStatsToHidl(legacy_stats,
- &hidl_stats)) {
- return {createWifiStatus(WifiStatusCode::ERROR_UNKNOWN), {}};
- }
- return {createWifiStatus(WifiStatusCode::SUCCESS), hidl_stats};
+ legacy_hal::wifi_error legacy_status;
+ legacy_hal::WakeReasonStats legacy_stats;
+ std::tie(legacy_status, legacy_stats) =
+ legacy_hal_.lock()->getWakeReasonStats(getWlan0IfaceName());
+ if (legacy_status != legacy_hal::WIFI_SUCCESS) {
+ return {createWifiStatusFromLegacyError(legacy_status), {}};
+ }
+ WifiDebugHostWakeReasonStats hidl_stats;
+ if (!hidl_struct_util::convertLegacyWakeReasonStatsToHidl(legacy_stats,
+ &hidl_stats)) {
+ return {createWifiStatus(WifiStatusCode::ERROR_UNKNOWN), {}};
+ }
+ return {createWifiStatus(WifiStatusCode::SUCCESS), hidl_stats};
}
WifiStatus WifiChip::enableDebugErrorAlertsInternal(bool enable) {
- legacy_hal::wifi_error legacy_status;
- if (enable) {
- android::wp<WifiChip> weak_ptr_this(this);
- const auto& on_alert_callback = [weak_ptr_this](
- int32_t error_code, std::vector<uint8_t> debug_data) {
- const auto shared_ptr_this = weak_ptr_this.promote();
- if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
- LOG(ERROR) << "Callback invoked on an invalid object";
- return;
- }
- for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
- if (!callback->onDebugErrorAlert(error_code, debug_data).isOk()) {
- LOG(ERROR) << "Failed to invoke onDebugErrorAlert callback";
- }
- }
- };
- legacy_status = legacy_hal_.lock()->registerErrorAlertCallbackHandler(
- on_alert_callback);
- } else {
- legacy_status = legacy_hal_.lock()->deregisterErrorAlertCallbackHandler();
- }
- return createWifiStatusFromLegacyError(legacy_status);
+ legacy_hal::wifi_error legacy_status;
+ if (enable) {
+ android::wp<WifiChip> weak_ptr_this(this);
+ const auto& on_alert_callback = [weak_ptr_this](
+ int32_t error_code,
+ std::vector<uint8_t> debug_data) {
+ const auto shared_ptr_this = weak_ptr_this.promote();
+ if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
+ LOG(ERROR) << "Callback invoked on an invalid object";
+ return;
+ }
+ for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
+ if (!callback->onDebugErrorAlert(error_code, debug_data)
+ .isOk()) {
+ LOG(ERROR) << "Failed to invoke onDebugErrorAlert callback";
+ }
+ }
+ };
+ legacy_status = legacy_hal_.lock()->registerErrorAlertCallbackHandler(
+ getWlan0IfaceName(), on_alert_callback);
+ } else {
+ legacy_status = legacy_hal_.lock()->deregisterErrorAlertCallbackHandler(
+ getWlan0IfaceName());
+ }
+ return createWifiStatusFromLegacyError(legacy_status);
}
WifiStatus WifiChip::selectTxPowerScenarioInternal(TxPowerScenario scenario) {
- auto legacy_status = legacy_hal_.lock()->selectTxPowerScenario(
- hidl_struct_util::convertHidlTxPowerScenarioToLegacy(scenario));
- return createWifiStatusFromLegacyError(legacy_status);
+ auto legacy_status = legacy_hal_.lock()->selectTxPowerScenario(
+ getWlan0IfaceName(),
+ hidl_struct_util::convertHidlTxPowerScenarioToLegacy(scenario));
+ return createWifiStatusFromLegacyError(legacy_status);
}
WifiStatus WifiChip::resetTxPowerScenarioInternal() {
- auto legacy_status = legacy_hal_.lock()->resetTxPowerScenario();
- return createWifiStatusFromLegacyError(legacy_status);
+ auto legacy_status =
+ legacy_hal_.lock()->resetTxPowerScenario(getWlan0IfaceName());
+ return createWifiStatusFromLegacyError(legacy_status);
}
-WifiStatus WifiChip::handleChipConfiguration(ChipModeId mode_id) {
- // If the chip is already configured in a different mode, stop
- // the legacy HAL and then start it after firmware mode change.
- // Currently the underlying implementation has a deadlock issue.
- // We should return ERROR_NOT_SUPPORTED if chip is already configured in
- // a different mode.
- if (current_mode_id_ != kInvalidModeId) {
- // TODO(b/37446050): Fix the deadlock.
- return createWifiStatus(WifiStatusCode::ERROR_NOT_SUPPORTED);
- }
- bool success;
- if (mode_id == kStaChipModeId) {
- success = mode_controller_.lock()->changeFirmwareMode(IfaceType::STA);
- } else {
- success = mode_controller_.lock()->changeFirmwareMode(IfaceType::AP);
- }
- if (!success) {
- return createWifiStatus(WifiStatusCode::ERROR_UNKNOWN);
- }
- legacy_hal::wifi_error legacy_status = legacy_hal_.lock()->start();
- if (legacy_status != legacy_hal::WIFI_SUCCESS) {
- LOG(ERROR) << "Failed to start legacy HAL: "
- << legacyErrorToString(legacy_status);
- return createWifiStatusFromLegacyError(legacy_status);
- }
- return createWifiStatus(WifiStatusCode::SUCCESS);
+WifiStatus WifiChip::handleChipConfiguration(
+ /* NONNULL */ std::unique_lock<std::recursive_mutex>* lock,
+ ChipModeId mode_id) {
+ // If the chip is already configured in a different mode, stop
+ // the legacy HAL and then start it after firmware mode change.
+ if (current_mode_id_ != kInvalidModeId) {
+ LOG(INFO) << "Reconfiguring chip from mode " << current_mode_id_
+ << " to mode " << mode_id;
+ invalidateAndRemoveAllIfaces();
+ legacy_hal::wifi_error legacy_status =
+ legacy_hal_.lock()->stop(lock, []() {});
+ if (legacy_status != legacy_hal::WIFI_SUCCESS) {
+ LOG(ERROR) << "Failed to stop legacy HAL: "
+ << legacyErrorToString(legacy_status);
+ return createWifiStatusFromLegacyError(legacy_status);
+ }
+ }
+ bool success;
+ if (mode_id == kStaChipModeId) {
+ success = mode_controller_.lock()->changeFirmwareMode(IfaceType::STA);
+ } else {
+ success = mode_controller_.lock()->changeFirmwareMode(IfaceType::AP);
+ }
+ if (!success) {
+ return createWifiStatus(WifiStatusCode::ERROR_UNKNOWN);
+ }
+ legacy_hal::wifi_error legacy_status = legacy_hal_.lock()->start();
+ if (legacy_status != legacy_hal::WIFI_SUCCESS) {
+ LOG(ERROR) << "Failed to start legacy HAL: "
+ << legacyErrorToString(legacy_status);
+ return createWifiStatusFromLegacyError(legacy_status);
+ }
+ return createWifiStatus(WifiStatusCode::SUCCESS);
}
WifiStatus WifiChip::registerDebugRingBufferCallback() {
- if (debug_ring_buffer_cb_registered_) {
- return createWifiStatus(WifiStatusCode::SUCCESS);
- }
-
- android::wp<WifiChip> weak_ptr_this(this);
- const auto& on_ring_buffer_data_callback = [weak_ptr_this](
- const std::string& /* name */,
- const std::vector<uint8_t>& data,
- const legacy_hal::wifi_ring_buffer_status& status) {
- const auto shared_ptr_this = weak_ptr_this.promote();
- if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
- LOG(ERROR) << "Callback invoked on an invalid object";
- return;
+ if (debug_ring_buffer_cb_registered_) {
+ return createWifiStatus(WifiStatusCode::SUCCESS);
}
- WifiDebugRingBufferStatus hidl_status;
- if (!hidl_struct_util::convertLegacyDebugRingBufferStatusToHidl(
- status, &hidl_status)) {
- LOG(ERROR) << "Error converting ring buffer status";
- return;
- }
- for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
- if (!callback->onDebugRingBufferDataAvailable(hidl_status, data).isOk()) {
- LOG(ERROR) << "Failed to invoke onDebugRingBufferDataAvailable"
- << " callback on: " << toString(callback);
- }
- }
- };
- legacy_hal::wifi_error legacy_status =
- legacy_hal_.lock()->registerRingBufferCallbackHandler(
- on_ring_buffer_data_callback);
+ android::wp<WifiChip> weak_ptr_this(this);
+ const auto& on_ring_buffer_data_callback =
+ [weak_ptr_this](const std::string& /* name */,
+ const std::vector<uint8_t>& data,
+ const legacy_hal::wifi_ring_buffer_status& status) {
+ const auto shared_ptr_this = weak_ptr_this.promote();
+ if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
+ LOG(ERROR) << "Callback invoked on an invalid object";
+ return;
+ }
+ WifiDebugRingBufferStatus hidl_status;
+ if (!hidl_struct_util::convertLegacyDebugRingBufferStatusToHidl(
+ status, &hidl_status)) {
+ LOG(ERROR) << "Error converting ring buffer status";
+ return;
+ }
+ for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
+ if (!callback->onDebugRingBufferDataAvailable(hidl_status, data)
+ .isOk()) {
+ LOG(ERROR)
+ << "Failed to invoke onDebugRingBufferDataAvailable"
+ << " callback on: " << toString(callback);
+ }
+ }
+ };
+ legacy_hal::wifi_error legacy_status =
+ legacy_hal_.lock()->registerRingBufferCallbackHandler(
+ getWlan0IfaceName(), on_ring_buffer_data_callback);
- if (legacy_status == legacy_hal::WIFI_SUCCESS) {
- debug_ring_buffer_cb_registered_ = true;
- }
- return createWifiStatusFromLegacyError(legacy_status);
+ if (legacy_status == legacy_hal::WIFI_SUCCESS) {
+ debug_ring_buffer_cb_registered_ = true;
+ }
+ return createWifiStatusFromLegacyError(legacy_status);
}
} // namespace implementation
diff --git a/wifi/1.2/default/wifi_chip.h b/wifi/1.2/default/wifi_chip.h
index 2b9ca64..ac59d59 100644
--- a/wifi/1.2/default/wifi_chip.h
+++ b/wifi/1.2/default/wifi_chip.h
@@ -44,168 +44,170 @@
* identifying handle information stored here.
*/
class WifiChip : public V1_1::IWifiChip {
- public:
- WifiChip(
- ChipId chip_id,
- const std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal,
- const std::weak_ptr<mode_controller::WifiModeController> mode_controller);
- // HIDL does not provide a built-in mechanism to let the server invalidate
- // a HIDL interface object after creation. If any client process holds onto
- // a reference to the object in their context, any method calls on that
- // reference will continue to be directed to the server.
- //
- // However Wifi HAL needs to control the lifetime of these objects. So, add
- // a public |invalidate| method to |WifiChip| and it's child objects. This
- // will be used to mark an object invalid when either:
- // a) Wifi HAL is stopped, or
- // b) Wifi Chip is reconfigured.
- //
- // All HIDL method implementations should check if the object is still marked
- // valid before processing them.
- void invalidate();
- bool isValid();
- std::set<sp<IWifiChipEventCallback>> getEventCallbacks();
+ public:
+ WifiChip(ChipId chip_id,
+ const std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal,
+ const std::weak_ptr<mode_controller::WifiModeController>
+ mode_controller);
+ // HIDL does not provide a built-in mechanism to let the server invalidate
+ // a HIDL interface object after creation. If any client process holds onto
+ // a reference to the object in their context, any method calls on that
+ // reference will continue to be directed to the server.
+ //
+ // However Wifi HAL needs to control the lifetime of these objects. So, add
+ // a public |invalidate| method to |WifiChip| and it's child objects. This
+ // will be used to mark an object invalid when either:
+ // a) Wifi HAL is stopped, or
+ // b) Wifi Chip is reconfigured.
+ //
+ // All HIDL method implementations should check if the object is still
+ // marked valid before processing them.
+ void invalidate();
+ bool isValid();
+ std::set<sp<IWifiChipEventCallback>> getEventCallbacks();
- // HIDL methods exposed.
- Return<void> getId(getId_cb hidl_status_cb) override;
- Return<void> registerEventCallback(
- const sp<IWifiChipEventCallback>& event_callback,
- registerEventCallback_cb hidl_status_cb) override;
- Return<void> getCapabilities(getCapabilities_cb hidl_status_cb) override;
- Return<void> getAvailableModes(getAvailableModes_cb hidl_status_cb) override;
- Return<void> configureChip(ChipModeId mode_id,
- configureChip_cb hidl_status_cb) override;
- Return<void> getMode(getMode_cb hidl_status_cb) override;
- Return<void> requestChipDebugInfo(
- requestChipDebugInfo_cb hidl_status_cb) override;
- Return<void> requestDriverDebugDump(
- requestDriverDebugDump_cb hidl_status_cb) override;
- Return<void> requestFirmwareDebugDump(
- requestFirmwareDebugDump_cb hidl_status_cb) override;
- Return<void> createApIface(createApIface_cb hidl_status_cb) override;
- Return<void> getApIfaceNames(getApIfaceNames_cb hidl_status_cb) override;
- Return<void> getApIface(const hidl_string& ifname,
- getApIface_cb hidl_status_cb) override;
- Return<void> removeApIface(const hidl_string& ifname,
- removeApIface_cb hidl_status_cb) override;
- Return<void> createNanIface(createNanIface_cb hidl_status_cb) override;
- Return<void> getNanIfaceNames(getNanIfaceNames_cb hidl_status_cb) override;
- Return<void> getNanIface(const hidl_string& ifname,
- getNanIface_cb hidl_status_cb) override;
- Return<void> removeNanIface(const hidl_string& ifname,
- removeNanIface_cb hidl_status_cb) override;
- Return<void> createP2pIface(createP2pIface_cb hidl_status_cb) override;
- Return<void> getP2pIfaceNames(getP2pIfaceNames_cb hidl_status_cb) override;
- Return<void> getP2pIface(const hidl_string& ifname,
- getP2pIface_cb hidl_status_cb) override;
- Return<void> removeP2pIface(const hidl_string& ifname,
- removeP2pIface_cb hidl_status_cb) override;
- Return<void> createStaIface(createStaIface_cb hidl_status_cb) override;
- Return<void> getStaIfaceNames(getStaIfaceNames_cb hidl_status_cb) override;
- Return<void> getStaIface(const hidl_string& ifname,
- getStaIface_cb hidl_status_cb) override;
- Return<void> removeStaIface(const hidl_string& ifname,
- removeStaIface_cb hidl_status_cb) override;
- Return<void> createRttController(
- const sp<IWifiIface>& bound_iface,
- createRttController_cb hidl_status_cb) override;
- Return<void> getDebugRingBuffersStatus(
- getDebugRingBuffersStatus_cb hidl_status_cb) override;
- Return<void> startLoggingToDebugRingBuffer(
- const hidl_string& ring_name,
- WifiDebugRingBufferVerboseLevel verbose_level,
- uint32_t max_interval_in_sec,
- uint32_t min_data_size_in_bytes,
- startLoggingToDebugRingBuffer_cb hidl_status_cb) override;
- Return<void> forceDumpToDebugRingBuffer(
- const hidl_string& ring_name,
- forceDumpToDebugRingBuffer_cb hidl_status_cb) override;
- Return<void> stopLoggingToDebugRingBuffer(
- stopLoggingToDebugRingBuffer_cb hidl_status_cb) override;
- Return<void> getDebugHostWakeReasonStats(
- getDebugHostWakeReasonStats_cb hidl_status_cb) override;
- Return<void> enableDebugErrorAlerts(
- bool enable, enableDebugErrorAlerts_cb hidl_status_cb) override;
- Return<void> selectTxPowerScenario(
- TxPowerScenario scenario,
- selectTxPowerScenario_cb hidl_status_cb) override;
- Return<void> resetTxPowerScenario(
- resetTxPowerScenario_cb hidl_status_cb) override;
+ // HIDL methods exposed.
+ Return<void> getId(getId_cb hidl_status_cb) override;
+ Return<void> registerEventCallback(
+ const sp<IWifiChipEventCallback>& event_callback,
+ registerEventCallback_cb hidl_status_cb) override;
+ Return<void> getCapabilities(getCapabilities_cb hidl_status_cb) override;
+ Return<void> getAvailableModes(
+ getAvailableModes_cb hidl_status_cb) override;
+ Return<void> configureChip(ChipModeId mode_id,
+ configureChip_cb hidl_status_cb) override;
+ Return<void> getMode(getMode_cb hidl_status_cb) override;
+ Return<void> requestChipDebugInfo(
+ requestChipDebugInfo_cb hidl_status_cb) override;
+ Return<void> requestDriverDebugDump(
+ requestDriverDebugDump_cb hidl_status_cb) override;
+ Return<void> requestFirmwareDebugDump(
+ requestFirmwareDebugDump_cb hidl_status_cb) override;
+ Return<void> createApIface(createApIface_cb hidl_status_cb) override;
+ Return<void> getApIfaceNames(getApIfaceNames_cb hidl_status_cb) override;
+ Return<void> getApIface(const hidl_string& ifname,
+ getApIface_cb hidl_status_cb) override;
+ Return<void> removeApIface(const hidl_string& ifname,
+ removeApIface_cb hidl_status_cb) override;
+ Return<void> createNanIface(createNanIface_cb hidl_status_cb) override;
+ Return<void> getNanIfaceNames(getNanIfaceNames_cb hidl_status_cb) override;
+ Return<void> getNanIface(const hidl_string& ifname,
+ getNanIface_cb hidl_status_cb) override;
+ Return<void> removeNanIface(const hidl_string& ifname,
+ removeNanIface_cb hidl_status_cb) override;
+ Return<void> createP2pIface(createP2pIface_cb hidl_status_cb) override;
+ Return<void> getP2pIfaceNames(getP2pIfaceNames_cb hidl_status_cb) override;
+ Return<void> getP2pIface(const hidl_string& ifname,
+ getP2pIface_cb hidl_status_cb) override;
+ Return<void> removeP2pIface(const hidl_string& ifname,
+ removeP2pIface_cb hidl_status_cb) override;
+ Return<void> createStaIface(createStaIface_cb hidl_status_cb) override;
+ Return<void> getStaIfaceNames(getStaIfaceNames_cb hidl_status_cb) override;
+ Return<void> getStaIface(const hidl_string& ifname,
+ getStaIface_cb hidl_status_cb) override;
+ Return<void> removeStaIface(const hidl_string& ifname,
+ removeStaIface_cb hidl_status_cb) override;
+ Return<void> createRttController(
+ const sp<IWifiIface>& bound_iface,
+ createRttController_cb hidl_status_cb) override;
+ Return<void> getDebugRingBuffersStatus(
+ getDebugRingBuffersStatus_cb hidl_status_cb) override;
+ Return<void> startLoggingToDebugRingBuffer(
+ const hidl_string& ring_name,
+ WifiDebugRingBufferVerboseLevel verbose_level,
+ uint32_t max_interval_in_sec, uint32_t min_data_size_in_bytes,
+ startLoggingToDebugRingBuffer_cb hidl_status_cb) override;
+ Return<void> forceDumpToDebugRingBuffer(
+ const hidl_string& ring_name,
+ forceDumpToDebugRingBuffer_cb hidl_status_cb) override;
+ Return<void> stopLoggingToDebugRingBuffer(
+ stopLoggingToDebugRingBuffer_cb hidl_status_cb) override;
+ Return<void> getDebugHostWakeReasonStats(
+ getDebugHostWakeReasonStats_cb hidl_status_cb) override;
+ Return<void> enableDebugErrorAlerts(
+ bool enable, enableDebugErrorAlerts_cb hidl_status_cb) override;
+ Return<void> selectTxPowerScenario(
+ TxPowerScenario scenario,
+ selectTxPowerScenario_cb hidl_status_cb) override;
+ Return<void> resetTxPowerScenario(
+ resetTxPowerScenario_cb hidl_status_cb) override;
- private:
- void invalidateAndRemoveAllIfaces();
+ private:
+ void invalidateAndRemoveAllIfaces();
- // Corresponding worker functions for the HIDL methods.
- std::pair<WifiStatus, ChipId> getIdInternal();
- WifiStatus registerEventCallbackInternal(
- const sp<IWifiChipEventCallback>& event_callback);
- std::pair<WifiStatus, uint32_t> getCapabilitiesInternal();
- std::pair<WifiStatus, std::vector<ChipMode>> getAvailableModesInternal();
- WifiStatus configureChipInternal(ChipModeId mode_id);
- std::pair<WifiStatus, uint32_t> getModeInternal();
- std::pair<WifiStatus, IWifiChip::ChipDebugInfo>
- requestChipDebugInfoInternal();
- std::pair<WifiStatus, std::vector<uint8_t>> requestDriverDebugDumpInternal();
- std::pair<WifiStatus, std::vector<uint8_t>>
- requestFirmwareDebugDumpInternal();
- std::pair<WifiStatus, sp<IWifiApIface>> createApIfaceInternal();
- std::pair<WifiStatus, std::vector<hidl_string>> getApIfaceNamesInternal();
- std::pair<WifiStatus, sp<IWifiApIface>> getApIfaceInternal(
- const std::string& ifname);
- WifiStatus removeApIfaceInternal(const std::string& ifname);
- std::pair<WifiStatus, sp<IWifiNanIface>> createNanIfaceInternal();
- std::pair<WifiStatus, std::vector<hidl_string>> getNanIfaceNamesInternal();
- std::pair<WifiStatus, sp<IWifiNanIface>> getNanIfaceInternal(
- const std::string& ifname);
- WifiStatus removeNanIfaceInternal(const std::string& ifname);
- std::pair<WifiStatus, sp<IWifiP2pIface>> createP2pIfaceInternal();
- std::pair<WifiStatus, std::vector<hidl_string>> getP2pIfaceNamesInternal();
- std::pair<WifiStatus, sp<IWifiP2pIface>> getP2pIfaceInternal(
- const std::string& ifname);
- WifiStatus removeP2pIfaceInternal(const std::string& ifname);
- std::pair<WifiStatus, sp<IWifiStaIface>> createStaIfaceInternal();
- std::pair<WifiStatus, std::vector<hidl_string>> getStaIfaceNamesInternal();
- std::pair<WifiStatus, sp<IWifiStaIface>> getStaIfaceInternal(
- const std::string& ifname);
- WifiStatus removeStaIfaceInternal(const std::string& ifname);
- std::pair<WifiStatus, sp<IWifiRttController>> createRttControllerInternal(
- const sp<IWifiIface>& bound_iface);
- std::pair<WifiStatus, std::vector<WifiDebugRingBufferStatus>>
- getDebugRingBuffersStatusInternal();
- WifiStatus startLoggingToDebugRingBufferInternal(
- const hidl_string& ring_name,
- WifiDebugRingBufferVerboseLevel verbose_level,
- uint32_t max_interval_in_sec,
- uint32_t min_data_size_in_bytes);
- WifiStatus forceDumpToDebugRingBufferInternal(const hidl_string& ring_name);
- WifiStatus stopLoggingToDebugRingBufferInternal();
- std::pair<WifiStatus, WifiDebugHostWakeReasonStats>
- getDebugHostWakeReasonStatsInternal();
- WifiStatus enableDebugErrorAlertsInternal(bool enable);
- WifiStatus selectTxPowerScenarioInternal(TxPowerScenario scenario);
- WifiStatus resetTxPowerScenarioInternal();
+ // Corresponding worker functions for the HIDL methods.
+ std::pair<WifiStatus, ChipId> getIdInternal();
+ WifiStatus registerEventCallbackInternal(
+ const sp<IWifiChipEventCallback>& event_callback);
+ std::pair<WifiStatus, uint32_t> getCapabilitiesInternal();
+ std::pair<WifiStatus, std::vector<ChipMode>> getAvailableModesInternal();
+ WifiStatus configureChipInternal(
+ std::unique_lock<std::recursive_mutex>* lock, ChipModeId mode_id);
+ std::pair<WifiStatus, uint32_t> getModeInternal();
+ std::pair<WifiStatus, IWifiChip::ChipDebugInfo>
+ requestChipDebugInfoInternal();
+ std::pair<WifiStatus, std::vector<uint8_t>>
+ requestDriverDebugDumpInternal();
+ std::pair<WifiStatus, std::vector<uint8_t>>
+ requestFirmwareDebugDumpInternal();
+ std::pair<WifiStatus, sp<IWifiApIface>> createApIfaceInternal();
+ std::pair<WifiStatus, std::vector<hidl_string>> getApIfaceNamesInternal();
+ std::pair<WifiStatus, sp<IWifiApIface>> getApIfaceInternal(
+ const std::string& ifname);
+ WifiStatus removeApIfaceInternal(const std::string& ifname);
+ std::pair<WifiStatus, sp<IWifiNanIface>> createNanIfaceInternal();
+ std::pair<WifiStatus, std::vector<hidl_string>> getNanIfaceNamesInternal();
+ std::pair<WifiStatus, sp<IWifiNanIface>> getNanIfaceInternal(
+ const std::string& ifname);
+ WifiStatus removeNanIfaceInternal(const std::string& ifname);
+ std::pair<WifiStatus, sp<IWifiP2pIface>> createP2pIfaceInternal();
+ std::pair<WifiStatus, std::vector<hidl_string>> getP2pIfaceNamesInternal();
+ std::pair<WifiStatus, sp<IWifiP2pIface>> getP2pIfaceInternal(
+ const std::string& ifname);
+ WifiStatus removeP2pIfaceInternal(const std::string& ifname);
+ std::pair<WifiStatus, sp<IWifiStaIface>> createStaIfaceInternal();
+ std::pair<WifiStatus, std::vector<hidl_string>> getStaIfaceNamesInternal();
+ std::pair<WifiStatus, sp<IWifiStaIface>> getStaIfaceInternal(
+ const std::string& ifname);
+ WifiStatus removeStaIfaceInternal(const std::string& ifname);
+ std::pair<WifiStatus, sp<IWifiRttController>> createRttControllerInternal(
+ const sp<IWifiIface>& bound_iface);
+ std::pair<WifiStatus, std::vector<WifiDebugRingBufferStatus>>
+ getDebugRingBuffersStatusInternal();
+ WifiStatus startLoggingToDebugRingBufferInternal(
+ const hidl_string& ring_name,
+ WifiDebugRingBufferVerboseLevel verbose_level,
+ uint32_t max_interval_in_sec, uint32_t min_data_size_in_bytes);
+ WifiStatus forceDumpToDebugRingBufferInternal(const hidl_string& ring_name);
+ WifiStatus stopLoggingToDebugRingBufferInternal();
+ std::pair<WifiStatus, WifiDebugHostWakeReasonStats>
+ getDebugHostWakeReasonStatsInternal();
+ WifiStatus enableDebugErrorAlertsInternal(bool enable);
+ WifiStatus selectTxPowerScenarioInternal(TxPowerScenario scenario);
+ WifiStatus resetTxPowerScenarioInternal();
- WifiStatus handleChipConfiguration(ChipModeId mode_id);
- WifiStatus registerDebugRingBufferCallback();
+ WifiStatus handleChipConfiguration(
+ std::unique_lock<std::recursive_mutex>* lock, ChipModeId mode_id);
+ WifiStatus registerDebugRingBufferCallback();
- ChipId chip_id_;
- std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal_;
- std::weak_ptr<mode_controller::WifiModeController> mode_controller_;
- sp<WifiApIface> ap_iface_;
- sp<WifiNanIface> nan_iface_;
- sp<WifiP2pIface> p2p_iface_;
- sp<WifiStaIface> sta_iface_;
- std::vector<sp<WifiRttController>> rtt_controllers_;
- bool is_valid_;
- uint32_t current_mode_id_;
- // The legacy ring buffer callback API has only a global callback
- // registration mechanism. Use this to check if we have already
- // registered a callback.
- bool debug_ring_buffer_cb_registered_;
- hidl_callback_util::HidlCallbackHandler<IWifiChipEventCallback>
- event_cb_handler_;
+ ChipId chip_id_;
+ std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal_;
+ std::weak_ptr<mode_controller::WifiModeController> mode_controller_;
+ sp<WifiApIface> ap_iface_;
+ sp<WifiNanIface> nan_iface_;
+ sp<WifiP2pIface> p2p_iface_;
+ sp<WifiStaIface> sta_iface_;
+ std::vector<sp<WifiRttController>> rtt_controllers_;
+ bool is_valid_;
+ uint32_t current_mode_id_;
+ // The legacy ring buffer callback API has only a global callback
+ // registration mechanism. Use this to check if we have already
+ // registered a callback.
+ bool debug_ring_buffer_cb_registered_;
+ hidl_callback_util::HidlCallbackHandler<IWifiChipEventCallback>
+ event_cb_handler_;
- DISALLOW_COPY_AND_ASSIGN(WifiChip);
+ DISALLOW_COPY_AND_ASSIGN(WifiChip);
};
} // namespace implementation
diff --git a/wifi/1.2/default/wifi_feature_flags.h b/wifi/1.2/default/wifi_feature_flags.h
index c692cd9..da4ca37 100644
--- a/wifi/1.2/default/wifi_feature_flags.h
+++ b/wifi/1.2/default/wifi_feature_flags.h
@@ -24,12 +24,12 @@
namespace implementation {
class WifiFeatureFlags {
- public:
+ public:
#ifdef WIFI_HIDL_FEATURE_AWARE
- static const bool wifiHidlFeatureAware = true;
+ static const bool wifiHidlFeatureAware = true;
#else
- static const bool wifiHidlFeatureAware = false;
-#endif // WIFI_HIDL_FEATURE_AWARE
+ static const bool wifiHidlFeatureAware = false;
+#endif // WIFI_HIDL_FEATURE_AWARE
};
} // namespace implementation
diff --git a/wifi/1.2/default/wifi_legacy_hal.cpp b/wifi/1.2/default/wifi_legacy_hal.cpp
index 54d9ca0..8289c67 100644
--- a/wifi/1.2/default/wifi_legacy_hal.cpp
+++ b/wifi/1.2/default/wifi_legacy_hal.cpp
@@ -18,7 +18,6 @@
#include <chrono>
#include <android-base/logging.h>
-#include <cutils/properties.h>
#include "hidl_sync_util.h"
#include "wifi_legacy_hal.h"
@@ -39,10 +38,10 @@
// Helper function to create a non-const char* for legacy Hal API's.
std::vector<char> makeCharVec(const std::string& str) {
- std::vector<char> vec(str.size() + 1);
- vec.assign(str.begin(), str.end());
- vec.push_back('\0');
- return vec;
+ std::vector<char> vec(str.size() + 1);
+ vec.assign(str.begin(), str.end());
+ vec.push_back('\0');
+ return vec;
}
} // namespace
@@ -59,116 +58,107 @@
// Callback to be invoked once |stop| is complete
std::function<void(wifi_handle handle)> on_stop_complete_internal_callback;
void onAsyncStopComplete(wifi_handle handle) {
- const auto lock = hidl_sync_util::acquireGlobalLock();
- if (on_stop_complete_internal_callback) {
- on_stop_complete_internal_callback(handle);
- // Invalidate this callback since we don't want this firing again.
- on_stop_complete_internal_callback = nullptr;
- }
+ const auto lock = hidl_sync_util::acquireGlobalLock();
+ if (on_stop_complete_internal_callback) {
+ on_stop_complete_internal_callback(handle);
+ // Invalidate this callback since we don't want this firing again.
+ on_stop_complete_internal_callback = nullptr;
+ }
}
// Callback to be invoked for driver dump.
std::function<void(char*, int)> on_driver_memory_dump_internal_callback;
void onSyncDriverMemoryDump(char* buffer, int buffer_size) {
- if (on_driver_memory_dump_internal_callback) {
- on_driver_memory_dump_internal_callback(buffer, buffer_size);
- }
+ if (on_driver_memory_dump_internal_callback) {
+ on_driver_memory_dump_internal_callback(buffer, buffer_size);
+ }
}
// Callback to be invoked for firmware dump.
std::function<void(char*, int)> on_firmware_memory_dump_internal_callback;
void onSyncFirmwareMemoryDump(char* buffer, int buffer_size) {
- if (on_firmware_memory_dump_internal_callback) {
- on_firmware_memory_dump_internal_callback(buffer, buffer_size);
- }
+ if (on_firmware_memory_dump_internal_callback) {
+ on_firmware_memory_dump_internal_callback(buffer, buffer_size);
+ }
}
// Callback to be invoked for Gscan events.
std::function<void(wifi_request_id, wifi_scan_event)>
on_gscan_event_internal_callback;
void onAsyncGscanEvent(wifi_request_id id, wifi_scan_event event) {
- const auto lock = hidl_sync_util::acquireGlobalLock();
- if (on_gscan_event_internal_callback) {
- on_gscan_event_internal_callback(id, event);
- }
+ const auto lock = hidl_sync_util::acquireGlobalLock();
+ if (on_gscan_event_internal_callback) {
+ on_gscan_event_internal_callback(id, event);
+ }
}
// Callback to be invoked for Gscan full results.
std::function<void(wifi_request_id, wifi_scan_result*, uint32_t)>
on_gscan_full_result_internal_callback;
-void onAsyncGscanFullResult(wifi_request_id id,
- wifi_scan_result* result,
+void onAsyncGscanFullResult(wifi_request_id id, wifi_scan_result* result,
uint32_t buckets_scanned) {
- const auto lock = hidl_sync_util::acquireGlobalLock();
- if (on_gscan_full_result_internal_callback) {
- on_gscan_full_result_internal_callback(id, result, buckets_scanned);
- }
+ const auto lock = hidl_sync_util::acquireGlobalLock();
+ if (on_gscan_full_result_internal_callback) {
+ on_gscan_full_result_internal_callback(id, result, buckets_scanned);
+ }
}
// Callback to be invoked for link layer stats results.
std::function<void((wifi_request_id, wifi_iface_stat*, int, wifi_radio_stat*))>
on_link_layer_stats_result_internal_callback;
-void onSyncLinkLayerStatsResult(wifi_request_id id,
- wifi_iface_stat* iface_stat,
- int num_radios,
- wifi_radio_stat* radio_stat) {
- if (on_link_layer_stats_result_internal_callback) {
- on_link_layer_stats_result_internal_callback(
- id, iface_stat, num_radios, radio_stat);
- }
+void onSyncLinkLayerStatsResult(wifi_request_id id, wifi_iface_stat* iface_stat,
+ int num_radios, wifi_radio_stat* radio_stat) {
+ if (on_link_layer_stats_result_internal_callback) {
+ on_link_layer_stats_result_internal_callback(id, iface_stat, num_radios,
+ radio_stat);
+ }
}
// Callback to be invoked for rssi threshold breach.
std::function<void((wifi_request_id, uint8_t*, int8_t))>
on_rssi_threshold_breached_internal_callback;
-void onAsyncRssiThresholdBreached(wifi_request_id id,
- uint8_t* bssid,
+void onAsyncRssiThresholdBreached(wifi_request_id id, uint8_t* bssid,
int8_t rssi) {
- const auto lock = hidl_sync_util::acquireGlobalLock();
- if (on_rssi_threshold_breached_internal_callback) {
- on_rssi_threshold_breached_internal_callback(id, bssid, rssi);
- }
+ const auto lock = hidl_sync_util::acquireGlobalLock();
+ if (on_rssi_threshold_breached_internal_callback) {
+ on_rssi_threshold_breached_internal_callback(id, bssid, rssi);
+ }
}
// Callback to be invoked for ring buffer data indication.
std::function<void(char*, char*, int, wifi_ring_buffer_status*)>
on_ring_buffer_data_internal_callback;
-void onAsyncRingBufferData(char* ring_name,
- char* buffer,
- int buffer_size,
+void onAsyncRingBufferData(char* ring_name, char* buffer, int buffer_size,
wifi_ring_buffer_status* status) {
- const auto lock = hidl_sync_util::acquireGlobalLock();
- if (on_ring_buffer_data_internal_callback) {
- on_ring_buffer_data_internal_callback(
- ring_name, buffer, buffer_size, status);
- }
+ const auto lock = hidl_sync_util::acquireGlobalLock();
+ if (on_ring_buffer_data_internal_callback) {
+ on_ring_buffer_data_internal_callback(ring_name, buffer, buffer_size,
+ status);
+ }
}
// Callback to be invoked for error alert indication.
std::function<void(wifi_request_id, char*, int, int)>
on_error_alert_internal_callback;
-void onAsyncErrorAlert(wifi_request_id id,
- char* buffer,
- int buffer_size,
+void onAsyncErrorAlert(wifi_request_id id, char* buffer, int buffer_size,
int err_code) {
- const auto lock = hidl_sync_util::acquireGlobalLock();
- if (on_error_alert_internal_callback) {
- on_error_alert_internal_callback(id, buffer, buffer_size, err_code);
- }
+ const auto lock = hidl_sync_util::acquireGlobalLock();
+ if (on_error_alert_internal_callback) {
+ on_error_alert_internal_callback(id, buffer, buffer_size, err_code);
+ }
}
// Callback to be invoked for rtt results results.
-std::function<void(
- wifi_request_id, unsigned num_results, wifi_rtt_result* rtt_results[])>
+std::function<void(wifi_request_id, unsigned num_results,
+ wifi_rtt_result* rtt_results[])>
on_rtt_results_internal_callback;
-void onAsyncRttResults(wifi_request_id id,
- unsigned num_results,
+void onAsyncRttResults(wifi_request_id id, unsigned num_results,
wifi_rtt_result* rtt_results[]) {
- const auto lock = hidl_sync_util::acquireGlobalLock();
- if (on_rtt_results_internal_callback) {
- on_rtt_results_internal_callback(id, num_results, rtt_results);
- on_rtt_results_internal_callback = nullptr;
- }
+ const auto lock = hidl_sync_util::acquireGlobalLock();
+ if (on_rtt_results_internal_callback) {
+ on_rtt_results_internal_callback(id, num_results, rtt_results);
+ on_rtt_results_internal_callback = nullptr;
+ }
}
// Callbacks for the various NAN operations.
@@ -178,1044 +168,1040 @@
std::function<void(transaction_id, const NanResponseMsg&)>
on_nan_notify_response_user_callback;
void onAysncNanNotifyResponse(transaction_id id, NanResponseMsg* msg) {
- const auto lock = hidl_sync_util::acquireGlobalLock();
- if (on_nan_notify_response_user_callback && msg) {
- on_nan_notify_response_user_callback(id, *msg);
- }
+ const auto lock = hidl_sync_util::acquireGlobalLock();
+ if (on_nan_notify_response_user_callback && msg) {
+ on_nan_notify_response_user_callback(id, *msg);
+ }
}
std::function<void(const NanPublishRepliedInd&)>
on_nan_event_publish_replied_user_callback;
void onAysncNanEventPublishReplied(NanPublishRepliedInd* /* event */) {
- LOG(ERROR) << "onAysncNanEventPublishReplied triggered";
+ LOG(ERROR) << "onAysncNanEventPublishReplied triggered";
}
std::function<void(const NanPublishTerminatedInd&)>
on_nan_event_publish_terminated_user_callback;
void onAysncNanEventPublishTerminated(NanPublishTerminatedInd* event) {
- const auto lock = hidl_sync_util::acquireGlobalLock();
- if (on_nan_event_publish_terminated_user_callback && event) {
- on_nan_event_publish_terminated_user_callback(*event);
- }
+ const auto lock = hidl_sync_util::acquireGlobalLock();
+ if (on_nan_event_publish_terminated_user_callback && event) {
+ on_nan_event_publish_terminated_user_callback(*event);
+ }
}
std::function<void(const NanMatchInd&)> on_nan_event_match_user_callback;
void onAysncNanEventMatch(NanMatchInd* event) {
- const auto lock = hidl_sync_util::acquireGlobalLock();
- if (on_nan_event_match_user_callback && event) {
- on_nan_event_match_user_callback(*event);
- }
+ const auto lock = hidl_sync_util::acquireGlobalLock();
+ if (on_nan_event_match_user_callback && event) {
+ on_nan_event_match_user_callback(*event);
+ }
}
std::function<void(const NanMatchExpiredInd&)>
on_nan_event_match_expired_user_callback;
void onAysncNanEventMatchExpired(NanMatchExpiredInd* event) {
- const auto lock = hidl_sync_util::acquireGlobalLock();
- if (on_nan_event_match_expired_user_callback && event) {
- on_nan_event_match_expired_user_callback(*event);
- }
+ const auto lock = hidl_sync_util::acquireGlobalLock();
+ if (on_nan_event_match_expired_user_callback && event) {
+ on_nan_event_match_expired_user_callback(*event);
+ }
}
std::function<void(const NanSubscribeTerminatedInd&)>
on_nan_event_subscribe_terminated_user_callback;
void onAysncNanEventSubscribeTerminated(NanSubscribeTerminatedInd* event) {
- const auto lock = hidl_sync_util::acquireGlobalLock();
- if (on_nan_event_subscribe_terminated_user_callback && event) {
- on_nan_event_subscribe_terminated_user_callback(*event);
- }
+ const auto lock = hidl_sync_util::acquireGlobalLock();
+ if (on_nan_event_subscribe_terminated_user_callback && event) {
+ on_nan_event_subscribe_terminated_user_callback(*event);
+ }
}
std::function<void(const NanFollowupInd&)> on_nan_event_followup_user_callback;
void onAysncNanEventFollowup(NanFollowupInd* event) {
- const auto lock = hidl_sync_util::acquireGlobalLock();
- if (on_nan_event_followup_user_callback && event) {
- on_nan_event_followup_user_callback(*event);
- }
+ const auto lock = hidl_sync_util::acquireGlobalLock();
+ if (on_nan_event_followup_user_callback && event) {
+ on_nan_event_followup_user_callback(*event);
+ }
}
std::function<void(const NanDiscEngEventInd&)>
on_nan_event_disc_eng_event_user_callback;
void onAysncNanEventDiscEngEvent(NanDiscEngEventInd* event) {
- const auto lock = hidl_sync_util::acquireGlobalLock();
- if (on_nan_event_disc_eng_event_user_callback && event) {
- on_nan_event_disc_eng_event_user_callback(*event);
- }
+ const auto lock = hidl_sync_util::acquireGlobalLock();
+ if (on_nan_event_disc_eng_event_user_callback && event) {
+ on_nan_event_disc_eng_event_user_callback(*event);
+ }
}
std::function<void(const NanDisabledInd&)> on_nan_event_disabled_user_callback;
void onAysncNanEventDisabled(NanDisabledInd* event) {
- const auto lock = hidl_sync_util::acquireGlobalLock();
- if (on_nan_event_disabled_user_callback && event) {
- on_nan_event_disabled_user_callback(*event);
- }
+ const auto lock = hidl_sync_util::acquireGlobalLock();
+ if (on_nan_event_disabled_user_callback && event) {
+ on_nan_event_disabled_user_callback(*event);
+ }
}
std::function<void(const NanTCAInd&)> on_nan_event_tca_user_callback;
void onAysncNanEventTca(NanTCAInd* event) {
- const auto lock = hidl_sync_util::acquireGlobalLock();
- if (on_nan_event_tca_user_callback && event) {
- on_nan_event_tca_user_callback(*event);
- }
+ const auto lock = hidl_sync_util::acquireGlobalLock();
+ if (on_nan_event_tca_user_callback && event) {
+ on_nan_event_tca_user_callback(*event);
+ }
}
std::function<void(const NanBeaconSdfPayloadInd&)>
on_nan_event_beacon_sdf_payload_user_callback;
void onAysncNanEventBeaconSdfPayload(NanBeaconSdfPayloadInd* event) {
- const auto lock = hidl_sync_util::acquireGlobalLock();
- if (on_nan_event_beacon_sdf_payload_user_callback && event) {
- on_nan_event_beacon_sdf_payload_user_callback(*event);
- }
+ const auto lock = hidl_sync_util::acquireGlobalLock();
+ if (on_nan_event_beacon_sdf_payload_user_callback && event) {
+ on_nan_event_beacon_sdf_payload_user_callback(*event);
+ }
}
std::function<void(const NanDataPathRequestInd&)>
on_nan_event_data_path_request_user_callback;
void onAysncNanEventDataPathRequest(NanDataPathRequestInd* event) {
- const auto lock = hidl_sync_util::acquireGlobalLock();
- if (on_nan_event_data_path_request_user_callback && event) {
- on_nan_event_data_path_request_user_callback(*event);
- }
+ const auto lock = hidl_sync_util::acquireGlobalLock();
+ if (on_nan_event_data_path_request_user_callback && event) {
+ on_nan_event_data_path_request_user_callback(*event);
+ }
}
std::function<void(const NanDataPathConfirmInd&)>
on_nan_event_data_path_confirm_user_callback;
void onAysncNanEventDataPathConfirm(NanDataPathConfirmInd* event) {
- const auto lock = hidl_sync_util::acquireGlobalLock();
- if (on_nan_event_data_path_confirm_user_callback && event) {
- on_nan_event_data_path_confirm_user_callback(*event);
- }
+ const auto lock = hidl_sync_util::acquireGlobalLock();
+ if (on_nan_event_data_path_confirm_user_callback && event) {
+ on_nan_event_data_path_confirm_user_callback(*event);
+ }
}
std::function<void(const NanDataPathEndInd&)>
on_nan_event_data_path_end_user_callback;
void onAysncNanEventDataPathEnd(NanDataPathEndInd* event) {
- const auto lock = hidl_sync_util::acquireGlobalLock();
- if (on_nan_event_data_path_end_user_callback && event) {
- on_nan_event_data_path_end_user_callback(*event);
- }
+ const auto lock = hidl_sync_util::acquireGlobalLock();
+ if (on_nan_event_data_path_end_user_callback && event) {
+ on_nan_event_data_path_end_user_callback(*event);
+ }
}
std::function<void(const NanTransmitFollowupInd&)>
on_nan_event_transmit_follow_up_user_callback;
void onAysncNanEventTransmitFollowUp(NanTransmitFollowupInd* event) {
- const auto lock = hidl_sync_util::acquireGlobalLock();
- if (on_nan_event_transmit_follow_up_user_callback && event) {
- on_nan_event_transmit_follow_up_user_callback(*event);
- }
+ const auto lock = hidl_sync_util::acquireGlobalLock();
+ if (on_nan_event_transmit_follow_up_user_callback && event) {
+ on_nan_event_transmit_follow_up_user_callback(*event);
+ }
}
std::function<void(const NanRangeRequestInd&)>
on_nan_event_range_request_user_callback;
void onAysncNanEventRangeRequest(NanRangeRequestInd* event) {
- const auto lock = hidl_sync_util::acquireGlobalLock();
- if (on_nan_event_range_request_user_callback && event) {
- on_nan_event_range_request_user_callback(*event);
- }
+ const auto lock = hidl_sync_util::acquireGlobalLock();
+ if (on_nan_event_range_request_user_callback && event) {
+ on_nan_event_range_request_user_callback(*event);
+ }
}
std::function<void(const NanRangeReportInd&)>
on_nan_event_range_report_user_callback;
void onAysncNanEventRangeReport(NanRangeReportInd* event) {
- const auto lock = hidl_sync_util::acquireGlobalLock();
- if (on_nan_event_range_report_user_callback && event) {
- on_nan_event_range_report_user_callback(*event);
- }
+ const auto lock = hidl_sync_util::acquireGlobalLock();
+ if (on_nan_event_range_report_user_callback && event) {
+ on_nan_event_range_report_user_callback(*event);
+ }
}
// End of the free-standing "C" style callbacks.
WifiLegacyHal::WifiLegacyHal()
: global_handle_(nullptr),
- wlan_interface_handle_(nullptr),
awaiting_event_loop_termination_(false),
is_started_(false) {}
wifi_error WifiLegacyHal::initialize() {
- LOG(DEBUG) << "Initialize legacy HAL";
- // TODO: Add back the HAL Tool if we need to. All we need from the HAL tool
- // for now is this function call which we can directly call.
- if (!initHalFuncTableWithStubs(&global_func_table_)) {
- LOG(ERROR) << "Failed to initialize legacy hal function table with stubs";
- return WIFI_ERROR_UNKNOWN;
- }
- wifi_error status = init_wifi_vendor_hal_func_table(&global_func_table_);
- if (status != WIFI_SUCCESS) {
- LOG(ERROR) << "Failed to initialize legacy hal function table";
- }
- return status;
+ LOG(DEBUG) << "Initialize legacy HAL";
+ // TODO: Add back the HAL Tool if we need to. All we need from the HAL tool
+ // for now is this function call which we can directly call.
+ if (!initHalFuncTableWithStubs(&global_func_table_)) {
+ LOG(ERROR)
+ << "Failed to initialize legacy hal function table with stubs";
+ return WIFI_ERROR_UNKNOWN;
+ }
+ wifi_error status = init_wifi_vendor_hal_func_table(&global_func_table_);
+ if (status != WIFI_SUCCESS) {
+ LOG(ERROR) << "Failed to initialize legacy hal function table";
+ }
+ return status;
}
wifi_error WifiLegacyHal::start() {
- // Ensure that we're starting in a good state.
- CHECK(global_func_table_.wifi_initialize && !global_handle_ &&
- !wlan_interface_handle_ && !awaiting_event_loop_termination_);
- if (is_started_) {
- LOG(DEBUG) << "Legacy HAL already started";
+ // Ensure that we're starting in a good state.
+ CHECK(global_func_table_.wifi_initialize && !global_handle_ &&
+ iface_name_to_handle_.empty() && !awaiting_event_loop_termination_);
+ if (is_started_) {
+ LOG(DEBUG) << "Legacy HAL already started";
+ return WIFI_SUCCESS;
+ }
+ LOG(DEBUG) << "Starting legacy HAL";
+ if (!iface_tool_.SetWifiUpState(true)) {
+ LOG(ERROR) << "Failed to set WiFi interface up";
+ return WIFI_ERROR_UNKNOWN;
+ }
+ wifi_error status = global_func_table_.wifi_initialize(&global_handle_);
+ if (status != WIFI_SUCCESS || !global_handle_) {
+ LOG(ERROR) << "Failed to retrieve global handle";
+ return status;
+ }
+ std::thread(&WifiLegacyHal::runEventLoop, this).detach();
+ status = retrieveIfaceHandles();
+ if (status != WIFI_SUCCESS || iface_name_to_handle_.empty()) {
+ LOG(ERROR) << "Failed to retrieve wlan interface handle";
+ return status;
+ }
+ LOG(DEBUG) << "Legacy HAL start complete";
+ is_started_ = true;
return WIFI_SUCCESS;
- }
- LOG(DEBUG) << "Starting legacy HAL";
- if (!iface_tool_.SetWifiUpState(true)) {
- LOG(ERROR) << "Failed to set WiFi interface up";
- return WIFI_ERROR_UNKNOWN;
- }
- wifi_error status = global_func_table_.wifi_initialize(&global_handle_);
- if (status != WIFI_SUCCESS || !global_handle_) {
- LOG(ERROR) << "Failed to retrieve global handle";
- return status;
- }
- std::thread(&WifiLegacyHal::runEventLoop, this).detach();
- status = retrieveWlanInterfaceHandle();
- if (status != WIFI_SUCCESS || !wlan_interface_handle_) {
- LOG(ERROR) << "Failed to retrieve wlan interface handle";
- return status;
- }
- LOG(DEBUG) << "Legacy HAL start complete";
- is_started_ = true;
- return WIFI_SUCCESS;
}
wifi_error WifiLegacyHal::stop(
/* NONNULL */ std::unique_lock<std::recursive_mutex>* lock,
const std::function<void()>& on_stop_complete_user_callback) {
- if (!is_started_) {
- LOG(DEBUG) << "Legacy HAL already stopped";
- on_stop_complete_user_callback();
+ if (!is_started_) {
+ LOG(DEBUG) << "Legacy HAL already stopped";
+ on_stop_complete_user_callback();
+ return WIFI_SUCCESS;
+ }
+ LOG(DEBUG) << "Stopping legacy HAL";
+ on_stop_complete_internal_callback = [on_stop_complete_user_callback,
+ this](wifi_handle handle) {
+ CHECK_EQ(global_handle_, handle) << "Handle mismatch";
+ LOG(INFO) << "Legacy HAL stop complete callback received";
+ // Invalidate all the internal pointers now that the HAL is
+ // stopped.
+ invalidate();
+ iface_tool_.SetWifiUpState(false);
+ on_stop_complete_user_callback();
+ is_started_ = false;
+ };
+ awaiting_event_loop_termination_ = true;
+ global_func_table_.wifi_cleanup(global_handle_, onAsyncStopComplete);
+ const auto status = stop_wait_cv_.wait_for(
+ *lock, std::chrono::milliseconds(kMaxStopCompleteWaitMs),
+ [this] { return !awaiting_event_loop_termination_; });
+ if (!status) {
+ LOG(ERROR) << "Legacy HAL stop failed or timed out";
+ return WIFI_ERROR_UNKNOWN;
+ }
+ LOG(DEBUG) << "Legacy HAL stop complete";
return WIFI_SUCCESS;
- }
- LOG(DEBUG) << "Stopping legacy HAL";
- on_stop_complete_internal_callback =
- [on_stop_complete_user_callback, this](wifi_handle handle) {
- CHECK_EQ(global_handle_, handle) << "Handle mismatch";
- LOG(INFO) << "Legacy HAL stop complete callback received";
- // Invalidate all the internal pointers now that the HAL is
- // stopped.
- invalidate();
- iface_tool_.SetWifiUpState(false);
- on_stop_complete_user_callback();
- is_started_ = false;
- };
- awaiting_event_loop_termination_ = true;
- global_func_table_.wifi_cleanup(global_handle_, onAsyncStopComplete);
- const auto status = stop_wait_cv_.wait_for(
- *lock, std::chrono::milliseconds(kMaxStopCompleteWaitMs),
- [this] { return !awaiting_event_loop_termination_; });
- if (!status) {
- LOG(ERROR) << "Legacy HAL stop failed or timed out";
- return WIFI_ERROR_UNKNOWN;
- }
- LOG(DEBUG) << "Legacy HAL stop complete";
- return WIFI_SUCCESS;
}
-std::string WifiLegacyHal::getApIfaceName() {
- // Fake name. This interface does not exist in legacy HAL
- // API's.
- return "ap0";
+std::pair<wifi_error, std::string> WifiLegacyHal::getDriverVersion(
+ const std::string& iface_name) {
+ std::array<char, kMaxVersionStringLength> buffer;
+ buffer.fill(0);
+ wifi_error status = global_func_table_.wifi_get_driver_version(
+ getIfaceHandle(iface_name), buffer.data(), buffer.size());
+ return {status, buffer.data()};
}
-std::string WifiLegacyHal::getNanIfaceName() {
- // Fake name. This interface does not exist in legacy HAL
- // API's.
- return "nan0";
-}
-
-std::string WifiLegacyHal::getP2pIfaceName() {
- std::array<char, PROPERTY_VALUE_MAX> buffer;
- property_get("wifi.direct.interface", buffer.data(), "p2p0");
- return buffer.data();
-}
-
-std::string WifiLegacyHal::getStaIfaceName() {
- std::array<char, PROPERTY_VALUE_MAX> buffer;
- property_get("wifi.interface", buffer.data(), "wlan0");
- return buffer.data();
-}
-
-std::pair<wifi_error, std::string> WifiLegacyHal::getDriverVersion() {
- std::array<char, kMaxVersionStringLength> buffer;
- buffer.fill(0);
- wifi_error status = global_func_table_.wifi_get_driver_version(
- wlan_interface_handle_, buffer.data(), buffer.size());
- return {status, buffer.data()};
-}
-
-std::pair<wifi_error, std::string> WifiLegacyHal::getFirmwareVersion() {
- std::array<char, kMaxVersionStringLength> buffer;
- buffer.fill(0);
- wifi_error status = global_func_table_.wifi_get_firmware_version(
- wlan_interface_handle_, buffer.data(), buffer.size());
- return {status, buffer.data()};
+std::pair<wifi_error, std::string> WifiLegacyHal::getFirmwareVersion(
+ const std::string& iface_name) {
+ std::array<char, kMaxVersionStringLength> buffer;
+ buffer.fill(0);
+ wifi_error status = global_func_table_.wifi_get_firmware_version(
+ getIfaceHandle(iface_name), buffer.data(), buffer.size());
+ return {status, buffer.data()};
}
std::pair<wifi_error, std::vector<uint8_t>>
-WifiLegacyHal::requestDriverMemoryDump() {
- std::vector<uint8_t> driver_dump;
- on_driver_memory_dump_internal_callback = [&driver_dump](char* buffer,
- int buffer_size) {
- driver_dump.insert(driver_dump.end(),
- reinterpret_cast<uint8_t*>(buffer),
- reinterpret_cast<uint8_t*>(buffer) + buffer_size);
- };
- wifi_error status = global_func_table_.wifi_get_driver_memory_dump(
- wlan_interface_handle_, {onSyncDriverMemoryDump});
- on_driver_memory_dump_internal_callback = nullptr;
- return {status, std::move(driver_dump)};
+WifiLegacyHal::requestDriverMemoryDump(const std::string& iface_name) {
+ std::vector<uint8_t> driver_dump;
+ on_driver_memory_dump_internal_callback = [&driver_dump](char* buffer,
+ int buffer_size) {
+ driver_dump.insert(driver_dump.end(),
+ reinterpret_cast<uint8_t*>(buffer),
+ reinterpret_cast<uint8_t*>(buffer) + buffer_size);
+ };
+ wifi_error status = global_func_table_.wifi_get_driver_memory_dump(
+ getIfaceHandle(iface_name), {onSyncDriverMemoryDump});
+ on_driver_memory_dump_internal_callback = nullptr;
+ return {status, std::move(driver_dump)};
}
std::pair<wifi_error, std::vector<uint8_t>>
-WifiLegacyHal::requestFirmwareMemoryDump() {
- std::vector<uint8_t> firmware_dump;
- on_firmware_memory_dump_internal_callback = [&firmware_dump](
- char* buffer, int buffer_size) {
- firmware_dump.insert(firmware_dump.end(),
- reinterpret_cast<uint8_t*>(buffer),
- reinterpret_cast<uint8_t*>(buffer) + buffer_size);
- };
- wifi_error status = global_func_table_.wifi_get_firmware_memory_dump(
- wlan_interface_handle_, {onSyncFirmwareMemoryDump});
- on_firmware_memory_dump_internal_callback = nullptr;
- return {status, std::move(firmware_dump)};
+WifiLegacyHal::requestFirmwareMemoryDump(const std::string& iface_name) {
+ std::vector<uint8_t> firmware_dump;
+ on_firmware_memory_dump_internal_callback =
+ [&firmware_dump](char* buffer, int buffer_size) {
+ firmware_dump.insert(
+ firmware_dump.end(), reinterpret_cast<uint8_t*>(buffer),
+ reinterpret_cast<uint8_t*>(buffer) + buffer_size);
+ };
+ wifi_error status = global_func_table_.wifi_get_firmware_memory_dump(
+ getIfaceHandle(iface_name), {onSyncFirmwareMemoryDump});
+ on_firmware_memory_dump_internal_callback = nullptr;
+ return {status, std::move(firmware_dump)};
}
-std::pair<wifi_error, uint32_t> WifiLegacyHal::getSupportedFeatureSet() {
- feature_set set;
- static_assert(sizeof(set) == sizeof(uint32_t),
- "Some features can not be represented in output");
- wifi_error status = global_func_table_.wifi_get_supported_feature_set(
- wlan_interface_handle_, &set);
- return {status, static_cast<uint32_t>(set)};
+std::pair<wifi_error, uint32_t> WifiLegacyHal::getSupportedFeatureSet(
+ const std::string& iface_name) {
+ feature_set set;
+ static_assert(sizeof(set) == sizeof(uint32_t),
+ "Some features can not be represented in output");
+ wifi_error status = global_func_table_.wifi_get_supported_feature_set(
+ getIfaceHandle(iface_name), &set);
+ return {status, static_cast<uint32_t>(set)};
}
std::pair<wifi_error, PacketFilterCapabilities>
-WifiLegacyHal::getPacketFilterCapabilities() {
- PacketFilterCapabilities caps;
- wifi_error status = global_func_table_.wifi_get_packet_filter_capabilities(
- wlan_interface_handle_, &caps.version, &caps.max_len);
- return {status, caps};
+WifiLegacyHal::getPacketFilterCapabilities(const std::string& iface_name) {
+ PacketFilterCapabilities caps;
+ wifi_error status = global_func_table_.wifi_get_packet_filter_capabilities(
+ getIfaceHandle(iface_name), &caps.version, &caps.max_len);
+ return {status, caps};
}
-wifi_error WifiLegacyHal::setPacketFilter(const std::vector<uint8_t>& program) {
- return global_func_table_.wifi_set_packet_filter(
- wlan_interface_handle_, program.data(), program.size());
+wifi_error WifiLegacyHal::setPacketFilter(const std::string& iface_name,
+ const std::vector<uint8_t>& program) {
+ return global_func_table_.wifi_set_packet_filter(
+ getIfaceHandle(iface_name), program.data(), program.size());
}
std::pair<wifi_error, wifi_gscan_capabilities>
-WifiLegacyHal::getGscanCapabilities() {
- wifi_gscan_capabilities caps;
- wifi_error status = global_func_table_.wifi_get_gscan_capabilities(
- wlan_interface_handle_, &caps);
- return {status, caps};
+WifiLegacyHal::getGscanCapabilities(const std::string& iface_name) {
+ wifi_gscan_capabilities caps;
+ wifi_error status = global_func_table_.wifi_get_gscan_capabilities(
+ getIfaceHandle(iface_name), &caps);
+ return {status, caps};
}
wifi_error WifiLegacyHal::startGscan(
- wifi_request_id id,
+ const std::string& iface_name, wifi_request_id id,
const wifi_scan_cmd_params& params,
const std::function<void(wifi_request_id)>& on_failure_user_callback,
const on_gscan_results_callback& on_results_user_callback,
const on_gscan_full_result_callback& on_full_result_user_callback) {
- // If there is already an ongoing background scan, reject new scan requests.
- if (on_gscan_event_internal_callback ||
- on_gscan_full_result_internal_callback) {
- return WIFI_ERROR_NOT_AVAILABLE;
- }
-
- // This callback will be used to either trigger |on_results_user_callback| or
- // |on_failure_user_callback|.
- on_gscan_event_internal_callback =
- [on_failure_user_callback, on_results_user_callback, this](
- wifi_request_id id, wifi_scan_event event) {
- switch (event) {
- case WIFI_SCAN_RESULTS_AVAILABLE:
- case WIFI_SCAN_THRESHOLD_NUM_SCANS:
- case WIFI_SCAN_THRESHOLD_PERCENT: {
- wifi_error status;
- std::vector<wifi_cached_scan_results> cached_scan_results;
- std::tie(status, cached_scan_results) = getGscanCachedResults();
- if (status == WIFI_SUCCESS) {
- on_results_user_callback(id, cached_scan_results);
- return;
- }
- }
- // Fall through if failed. Failure to retrieve cached scan results
- // should trigger a background scan failure.
- case WIFI_SCAN_FAILED:
- on_failure_user_callback(id);
- on_gscan_event_internal_callback = nullptr;
- on_gscan_full_result_internal_callback = nullptr;
- return;
- }
- LOG(FATAL) << "Unexpected gscan event received: " << event;
- };
-
- on_gscan_full_result_internal_callback = [on_full_result_user_callback](
- wifi_request_id id, wifi_scan_result* result, uint32_t buckets_scanned) {
- if (result) {
- on_full_result_user_callback(id, result, buckets_scanned);
+ // If there is already an ongoing background scan, reject new scan requests.
+ if (on_gscan_event_internal_callback ||
+ on_gscan_full_result_internal_callback) {
+ return WIFI_ERROR_NOT_AVAILABLE;
}
- };
- wifi_scan_result_handler handler = {onAsyncGscanFullResult,
- onAsyncGscanEvent};
- wifi_error status = global_func_table_.wifi_start_gscan(
- id, wlan_interface_handle_, params, handler);
- if (status != WIFI_SUCCESS) {
- on_gscan_event_internal_callback = nullptr;
- on_gscan_full_result_internal_callback = nullptr;
- }
- return status;
+ // This callback will be used to either trigger |on_results_user_callback|
+ // or |on_failure_user_callback|.
+ on_gscan_event_internal_callback =
+ [iface_name, on_failure_user_callback, on_results_user_callback, this](
+ wifi_request_id id, wifi_scan_event event) {
+ switch (event) {
+ case WIFI_SCAN_RESULTS_AVAILABLE:
+ case WIFI_SCAN_THRESHOLD_NUM_SCANS:
+ case WIFI_SCAN_THRESHOLD_PERCENT: {
+ wifi_error status;
+ std::vector<wifi_cached_scan_results> cached_scan_results;
+ std::tie(status, cached_scan_results) =
+ getGscanCachedResults(iface_name);
+ if (status == WIFI_SUCCESS) {
+ on_results_user_callback(id, cached_scan_results);
+ return;
+ }
+ }
+ // Fall through if failed. Failure to retrieve cached scan
+ // results should trigger a background scan failure.
+ case WIFI_SCAN_FAILED:
+ on_failure_user_callback(id);
+ on_gscan_event_internal_callback = nullptr;
+ on_gscan_full_result_internal_callback = nullptr;
+ return;
+ }
+ LOG(FATAL) << "Unexpected gscan event received: " << event;
+ };
+
+ on_gscan_full_result_internal_callback = [on_full_result_user_callback](
+ wifi_request_id id,
+ wifi_scan_result* result,
+ uint32_t buckets_scanned) {
+ if (result) {
+ on_full_result_user_callback(id, result, buckets_scanned);
+ }
+ };
+
+ wifi_scan_result_handler handler = {onAsyncGscanFullResult,
+ onAsyncGscanEvent};
+ wifi_error status = global_func_table_.wifi_start_gscan(
+ id, getIfaceHandle(iface_name), params, handler);
+ if (status != WIFI_SUCCESS) {
+ on_gscan_event_internal_callback = nullptr;
+ on_gscan_full_result_internal_callback = nullptr;
+ }
+ return status;
}
-wifi_error WifiLegacyHal::stopGscan(wifi_request_id id) {
- // If there is no an ongoing background scan, reject stop requests.
- // TODO(b/32337212): This needs to be handled by the HIDL object because we
- // need to return the NOT_STARTED error code.
- if (!on_gscan_event_internal_callback &&
- !on_gscan_full_result_internal_callback) {
- return WIFI_ERROR_NOT_AVAILABLE;
- }
- wifi_error status =
- global_func_table_.wifi_stop_gscan(id, wlan_interface_handle_);
- // If the request Id is wrong, don't stop the ongoing background scan. Any
- // other error should be treated as the end of background scan.
- if (status != WIFI_ERROR_INVALID_REQUEST_ID) {
- on_gscan_event_internal_callback = nullptr;
- on_gscan_full_result_internal_callback = nullptr;
- }
- return status;
+wifi_error WifiLegacyHal::stopGscan(const std::string& iface_name,
+ wifi_request_id id) {
+ // If there is no an ongoing background scan, reject stop requests.
+ // TODO(b/32337212): This needs to be handled by the HIDL object because we
+ // need to return the NOT_STARTED error code.
+ if (!on_gscan_event_internal_callback &&
+ !on_gscan_full_result_internal_callback) {
+ return WIFI_ERROR_NOT_AVAILABLE;
+ }
+ wifi_error status =
+ global_func_table_.wifi_stop_gscan(id, getIfaceHandle(iface_name));
+ // If the request Id is wrong, don't stop the ongoing background scan. Any
+ // other error should be treated as the end of background scan.
+ if (status != WIFI_ERROR_INVALID_REQUEST_ID) {
+ on_gscan_event_internal_callback = nullptr;
+ on_gscan_full_result_internal_callback = nullptr;
+ }
+ return status;
}
std::pair<wifi_error, std::vector<uint32_t>>
-WifiLegacyHal::getValidFrequenciesForBand(wifi_band band) {
- static_assert(sizeof(uint32_t) >= sizeof(wifi_channel),
- "Wifi Channel cannot be represented in output");
- std::vector<uint32_t> freqs;
- freqs.resize(kMaxGscanFrequenciesForBand);
- int32_t num_freqs = 0;
- wifi_error status = global_func_table_.wifi_get_valid_channels(
- wlan_interface_handle_,
- band,
- freqs.size(),
- reinterpret_cast<wifi_channel*>(freqs.data()),
- &num_freqs);
- CHECK(num_freqs >= 0 &&
- static_cast<uint32_t>(num_freqs) <= kMaxGscanFrequenciesForBand);
- freqs.resize(num_freqs);
- return {status, std::move(freqs)};
+WifiLegacyHal::getValidFrequenciesForBand(const std::string& iface_name,
+ wifi_band band) {
+ static_assert(sizeof(uint32_t) >= sizeof(wifi_channel),
+ "Wifi Channel cannot be represented in output");
+ std::vector<uint32_t> freqs;
+ freqs.resize(kMaxGscanFrequenciesForBand);
+ int32_t num_freqs = 0;
+ wifi_error status = global_func_table_.wifi_get_valid_channels(
+ getIfaceHandle(iface_name), band, freqs.size(),
+ reinterpret_cast<wifi_channel*>(freqs.data()), &num_freqs);
+ CHECK(num_freqs >= 0 &&
+ static_cast<uint32_t>(num_freqs) <= kMaxGscanFrequenciesForBand);
+ freqs.resize(num_freqs);
+ return {status, std::move(freqs)};
}
-wifi_error WifiLegacyHal::setDfsFlag(bool dfs_on) {
- return global_func_table_.wifi_set_nodfs_flag(
- wlan_interface_handle_, dfs_on ? 0 : 1);
+wifi_error WifiLegacyHal::setDfsFlag(const std::string& iface_name,
+ bool dfs_on) {
+ return global_func_table_.wifi_set_nodfs_flag(getIfaceHandle(iface_name),
+ dfs_on ? 0 : 1);
}
-wifi_error WifiLegacyHal::enableLinkLayerStats(bool debug) {
- wifi_link_layer_params params;
- params.mpdu_size_threshold = kLinkLayerStatsDataMpduSizeThreshold;
- params.aggressive_statistics_gathering = debug;
- return global_func_table_.wifi_set_link_stats(wlan_interface_handle_, params);
+wifi_error WifiLegacyHal::enableLinkLayerStats(const std::string& iface_name,
+ bool debug) {
+ wifi_link_layer_params params;
+ params.mpdu_size_threshold = kLinkLayerStatsDataMpduSizeThreshold;
+ params.aggressive_statistics_gathering = debug;
+ return global_func_table_.wifi_set_link_stats(getIfaceHandle(iface_name),
+ params);
}
-wifi_error WifiLegacyHal::disableLinkLayerStats() {
- // TODO: Do we care about these responses?
- uint32_t clear_mask_rsp;
- uint8_t stop_rsp;
- return global_func_table_.wifi_clear_link_stats(
- wlan_interface_handle_, 0xFFFFFFFF, &clear_mask_rsp, 1, &stop_rsp);
+wifi_error WifiLegacyHal::disableLinkLayerStats(const std::string& iface_name) {
+ // TODO: Do we care about these responses?
+ uint32_t clear_mask_rsp;
+ uint8_t stop_rsp;
+ return global_func_table_.wifi_clear_link_stats(
+ getIfaceHandle(iface_name), 0xFFFFFFFF, &clear_mask_rsp, 1, &stop_rsp);
}
-std::pair<wifi_error, LinkLayerStats> WifiLegacyHal::getLinkLayerStats() {
- LinkLayerStats link_stats{};
- LinkLayerStats* link_stats_ptr = &link_stats;
+std::pair<wifi_error, LinkLayerStats> WifiLegacyHal::getLinkLayerStats(
+ const std::string& iface_name) {
+ LinkLayerStats link_stats{};
+ LinkLayerStats* link_stats_ptr = &link_stats;
- on_link_layer_stats_result_internal_callback =
- [&link_stats_ptr](wifi_request_id /* id */,
- wifi_iface_stat* iface_stats_ptr,
- int num_radios,
- wifi_radio_stat* radio_stats_ptr) {
- if (iface_stats_ptr != nullptr) {
- link_stats_ptr->iface = *iface_stats_ptr;
- link_stats_ptr->iface.num_peers = 0;
- } else {
- LOG(ERROR) << "Invalid iface stats in link layer stats";
- }
- if (num_radios <= 0 || radio_stats_ptr == nullptr) {
- LOG(ERROR) << "Invalid radio stats in link layer stats";
- return;
- }
- for (int i = 0; i < num_radios; i++) {
- LinkLayerRadioStats radio;
- radio.stats = radio_stats_ptr[i];
- // Copy over the tx level array to the separate vector.
- if (radio_stats_ptr[i].num_tx_levels > 0 &&
- radio_stats_ptr[i].tx_time_per_levels != nullptr) {
- radio.tx_time_per_levels.assign(
- radio_stats_ptr[i].tx_time_per_levels,
- radio_stats_ptr[i].tx_time_per_levels +
- radio_stats_ptr[i].num_tx_levels);
- }
- radio.stats.num_tx_levels = 0;
- radio.stats.tx_time_per_levels = nullptr;
- link_stats_ptr->radios.push_back(radio);
- }
- };
+ on_link_layer_stats_result_internal_callback =
+ [&link_stats_ptr](wifi_request_id /* id */,
+ wifi_iface_stat* iface_stats_ptr, int num_radios,
+ wifi_radio_stat* radio_stats_ptr) {
+ if (iface_stats_ptr != nullptr) {
+ link_stats_ptr->iface = *iface_stats_ptr;
+ link_stats_ptr->iface.num_peers = 0;
+ } else {
+ LOG(ERROR) << "Invalid iface stats in link layer stats";
+ }
+ if (num_radios <= 0 || radio_stats_ptr == nullptr) {
+ LOG(ERROR) << "Invalid radio stats in link layer stats";
+ return;
+ }
+ for (int i = 0; i < num_radios; i++) {
+ LinkLayerRadioStats radio;
+ radio.stats = radio_stats_ptr[i];
+ // Copy over the tx level array to the separate vector.
+ if (radio_stats_ptr[i].num_tx_levels > 0 &&
+ radio_stats_ptr[i].tx_time_per_levels != nullptr) {
+ radio.tx_time_per_levels.assign(
+ radio_stats_ptr[i].tx_time_per_levels,
+ radio_stats_ptr[i].tx_time_per_levels +
+ radio_stats_ptr[i].num_tx_levels);
+ }
+ radio.stats.num_tx_levels = 0;
+ radio.stats.tx_time_per_levels = nullptr;
+ link_stats_ptr->radios.push_back(radio);
+ }
+ };
- wifi_error status = global_func_table_.wifi_get_link_stats(
- 0, wlan_interface_handle_, {onSyncLinkLayerStatsResult});
- on_link_layer_stats_result_internal_callback = nullptr;
- return {status, link_stats};
+ wifi_error status = global_func_table_.wifi_get_link_stats(
+ 0, getIfaceHandle(iface_name), {onSyncLinkLayerStatsResult});
+ on_link_layer_stats_result_internal_callback = nullptr;
+ return {status, link_stats};
}
wifi_error WifiLegacyHal::startRssiMonitoring(
- wifi_request_id id,
- int8_t max_rssi,
+ const std::string& iface_name, wifi_request_id id, int8_t max_rssi,
int8_t min_rssi,
const on_rssi_threshold_breached_callback&
on_threshold_breached_user_callback) {
- if (on_rssi_threshold_breached_internal_callback) {
- return WIFI_ERROR_NOT_AVAILABLE;
- }
- on_rssi_threshold_breached_internal_callback =
- [on_threshold_breached_user_callback](
- wifi_request_id id, uint8_t* bssid_ptr, int8_t rssi) {
- if (!bssid_ptr) {
- return;
- }
- std::array<uint8_t, 6> bssid_arr;
- // |bssid_ptr| pointer is assumed to have 6 bytes for the mac address.
- std::copy(bssid_ptr, bssid_ptr + 6, std::begin(bssid_arr));
- on_threshold_breached_user_callback(id, bssid_arr, rssi);
- };
- wifi_error status = global_func_table_.wifi_start_rssi_monitoring(
- id,
- wlan_interface_handle_,
- max_rssi,
- min_rssi,
- {onAsyncRssiThresholdBreached});
- if (status != WIFI_SUCCESS) {
- on_rssi_threshold_breached_internal_callback = nullptr;
- }
- return status;
+ if (on_rssi_threshold_breached_internal_callback) {
+ return WIFI_ERROR_NOT_AVAILABLE;
+ }
+ on_rssi_threshold_breached_internal_callback =
+ [on_threshold_breached_user_callback](wifi_request_id id,
+ uint8_t* bssid_ptr, int8_t rssi) {
+ if (!bssid_ptr) {
+ return;
+ }
+ std::array<uint8_t, 6> bssid_arr;
+ // |bssid_ptr| pointer is assumed to have 6 bytes for the mac
+ // address.
+ std::copy(bssid_ptr, bssid_ptr + 6, std::begin(bssid_arr));
+ on_threshold_breached_user_callback(id, bssid_arr, rssi);
+ };
+ wifi_error status = global_func_table_.wifi_start_rssi_monitoring(
+ id, getIfaceHandle(iface_name), max_rssi, min_rssi,
+ {onAsyncRssiThresholdBreached});
+ if (status != WIFI_SUCCESS) {
+ on_rssi_threshold_breached_internal_callback = nullptr;
+ }
+ return status;
}
-wifi_error WifiLegacyHal::stopRssiMonitoring(wifi_request_id id) {
- if (!on_rssi_threshold_breached_internal_callback) {
- return WIFI_ERROR_NOT_AVAILABLE;
- }
- wifi_error status =
- global_func_table_.wifi_stop_rssi_monitoring(id, wlan_interface_handle_);
- // If the request Id is wrong, don't stop the ongoing rssi monitoring. Any
- // other error should be treated as the end of background scan.
- if (status != WIFI_ERROR_INVALID_REQUEST_ID) {
- on_rssi_threshold_breached_internal_callback = nullptr;
- }
- return status;
+wifi_error WifiLegacyHal::stopRssiMonitoring(const std::string& iface_name,
+ wifi_request_id id) {
+ if (!on_rssi_threshold_breached_internal_callback) {
+ return WIFI_ERROR_NOT_AVAILABLE;
+ }
+ wifi_error status = global_func_table_.wifi_stop_rssi_monitoring(
+ id, getIfaceHandle(iface_name));
+ // If the request Id is wrong, don't stop the ongoing rssi monitoring. Any
+ // other error should be treated as the end of background scan.
+ if (status != WIFI_ERROR_INVALID_REQUEST_ID) {
+ on_rssi_threshold_breached_internal_callback = nullptr;
+ }
+ return status;
}
std::pair<wifi_error, wifi_roaming_capabilities>
-WifiLegacyHal::getRoamingCapabilities() {
- wifi_roaming_capabilities caps;
- wifi_error status = global_func_table_.wifi_get_roaming_capabilities(
- wlan_interface_handle_, &caps);
- return {status, caps};
+WifiLegacyHal::getRoamingCapabilities(const std::string& iface_name) {
+ wifi_roaming_capabilities caps;
+ wifi_error status = global_func_table_.wifi_get_roaming_capabilities(
+ getIfaceHandle(iface_name), &caps);
+ return {status, caps};
}
-wifi_error WifiLegacyHal::configureRoaming(const wifi_roaming_config& config) {
- wifi_roaming_config config_internal = config;
- return global_func_table_.wifi_configure_roaming(wlan_interface_handle_,
- &config_internal);
+wifi_error WifiLegacyHal::configureRoaming(const std::string& iface_name,
+ const wifi_roaming_config& config) {
+ wifi_roaming_config config_internal = config;
+ return global_func_table_.wifi_configure_roaming(getIfaceHandle(iface_name),
+ &config_internal);
}
-wifi_error WifiLegacyHal::enableFirmwareRoaming(fw_roaming_state_t state) {
- return global_func_table_.wifi_enable_firmware_roaming(wlan_interface_handle_,
- state);
+wifi_error WifiLegacyHal::enableFirmwareRoaming(const std::string& iface_name,
+ fw_roaming_state_t state) {
+ return global_func_table_.wifi_enable_firmware_roaming(
+ getIfaceHandle(iface_name), state);
}
-wifi_error WifiLegacyHal::configureNdOffload(bool enable) {
- return global_func_table_.wifi_configure_nd_offload(wlan_interface_handle_,
- enable);
+wifi_error WifiLegacyHal::configureNdOffload(const std::string& iface_name,
+ bool enable) {
+ return global_func_table_.wifi_configure_nd_offload(
+ getIfaceHandle(iface_name), enable);
}
wifi_error WifiLegacyHal::startSendingOffloadedPacket(
- uint32_t cmd_id,
+ const std::string& iface_name, uint32_t cmd_id,
const std::vector<uint8_t>& ip_packet_data,
const std::array<uint8_t, 6>& src_address,
- const std::array<uint8_t, 6>& dst_address,
- uint32_t period_in_ms) {
- std::vector<uint8_t> ip_packet_data_internal(ip_packet_data);
- std::vector<uint8_t> src_address_internal(
- src_address.data(), src_address.data() + src_address.size());
- std::vector<uint8_t> dst_address_internal(
- dst_address.data(), dst_address.data() + dst_address.size());
- return global_func_table_.wifi_start_sending_offloaded_packet(
- cmd_id,
- wlan_interface_handle_,
- ip_packet_data_internal.data(),
- ip_packet_data_internal.size(),
- src_address_internal.data(),
- dst_address_internal.data(),
- period_in_ms);
+ const std::array<uint8_t, 6>& dst_address, uint32_t period_in_ms) {
+ std::vector<uint8_t> ip_packet_data_internal(ip_packet_data);
+ std::vector<uint8_t> src_address_internal(
+ src_address.data(), src_address.data() + src_address.size());
+ std::vector<uint8_t> dst_address_internal(
+ dst_address.data(), dst_address.data() + dst_address.size());
+ return global_func_table_.wifi_start_sending_offloaded_packet(
+ cmd_id, getIfaceHandle(iface_name), ip_packet_data_internal.data(),
+ ip_packet_data_internal.size(), src_address_internal.data(),
+ dst_address_internal.data(), period_in_ms);
}
-wifi_error WifiLegacyHal::stopSendingOffloadedPacket(uint32_t cmd_id) {
- return global_func_table_.wifi_stop_sending_offloaded_packet(
- cmd_id, wlan_interface_handle_);
+wifi_error WifiLegacyHal::stopSendingOffloadedPacket(
+ const std::string& iface_name, uint32_t cmd_id) {
+ return global_func_table_.wifi_stop_sending_offloaded_packet(
+ cmd_id, getIfaceHandle(iface_name));
}
-wifi_error WifiLegacyHal::setScanningMacOui(const std::array<uint8_t, 3>& oui) {
- std::vector<uint8_t> oui_internal(oui.data(), oui.data() + oui.size());
- return global_func_table_.wifi_set_scanning_mac_oui(wlan_interface_handle_,
- oui_internal.data());
+wifi_error WifiLegacyHal::setScanningMacOui(const std::string& iface_name,
+ const std::array<uint8_t, 3>& oui) {
+ std::vector<uint8_t> oui_internal(oui.data(), oui.data() + oui.size());
+ return global_func_table_.wifi_set_scanning_mac_oui(
+ getIfaceHandle(iface_name), oui_internal.data());
}
-wifi_error WifiLegacyHal::selectTxPowerScenario(wifi_power_scenario scenario) {
- return global_func_table_.wifi_select_tx_power_scenario(
- wlan_interface_handle_, scenario);
+wifi_error WifiLegacyHal::selectTxPowerScenario(const std::string& iface_name,
+ wifi_power_scenario scenario) {
+ return global_func_table_.wifi_select_tx_power_scenario(
+ getIfaceHandle(iface_name), scenario);
}
-wifi_error WifiLegacyHal::resetTxPowerScenario() {
- return global_func_table_.wifi_reset_tx_power_scenario(wlan_interface_handle_);
+wifi_error WifiLegacyHal::resetTxPowerScenario(const std::string& iface_name) {
+ return global_func_table_.wifi_reset_tx_power_scenario(
+ getIfaceHandle(iface_name));
}
-std::pair<wifi_error, uint32_t> WifiLegacyHal::getLoggerSupportedFeatureSet() {
- uint32_t supported_features;
- wifi_error status = global_func_table_.wifi_get_logger_supported_feature_set(
- wlan_interface_handle_, &supported_features);
- return {status, supported_features};
+std::pair<wifi_error, uint32_t> WifiLegacyHal::getLoggerSupportedFeatureSet(
+ const std::string& iface_name) {
+ uint32_t supported_features;
+ wifi_error status =
+ global_func_table_.wifi_get_logger_supported_feature_set(
+ getIfaceHandle(iface_name), &supported_features);
+ return {status, supported_features};
}
-wifi_error WifiLegacyHal::startPktFateMonitoring() {
- return global_func_table_.wifi_start_pkt_fate_monitoring(
- wlan_interface_handle_);
+wifi_error WifiLegacyHal::startPktFateMonitoring(
+ const std::string& iface_name) {
+ return global_func_table_.wifi_start_pkt_fate_monitoring(
+ getIfaceHandle(iface_name));
}
-std::pair<wifi_error, std::vector<wifi_tx_report>>
-WifiLegacyHal::getTxPktFates() {
- std::vector<wifi_tx_report> tx_pkt_fates;
- tx_pkt_fates.resize(MAX_FATE_LOG_LEN);
- size_t num_fates = 0;
- wifi_error status =
- global_func_table_.wifi_get_tx_pkt_fates(wlan_interface_handle_,
- tx_pkt_fates.data(),
- tx_pkt_fates.size(),
- &num_fates);
- CHECK(num_fates <= MAX_FATE_LOG_LEN);
- tx_pkt_fates.resize(num_fates);
- return {status, std::move(tx_pkt_fates)};
+std::pair<wifi_error, std::vector<wifi_tx_report>> WifiLegacyHal::getTxPktFates(
+ const std::string& iface_name) {
+ std::vector<wifi_tx_report> tx_pkt_fates;
+ tx_pkt_fates.resize(MAX_FATE_LOG_LEN);
+ size_t num_fates = 0;
+ wifi_error status = global_func_table_.wifi_get_tx_pkt_fates(
+ getIfaceHandle(iface_name), tx_pkt_fates.data(), tx_pkt_fates.size(),
+ &num_fates);
+ CHECK(num_fates <= MAX_FATE_LOG_LEN);
+ tx_pkt_fates.resize(num_fates);
+ return {status, std::move(tx_pkt_fates)};
}
-std::pair<wifi_error, std::vector<wifi_rx_report>>
-WifiLegacyHal::getRxPktFates() {
- std::vector<wifi_rx_report> rx_pkt_fates;
- rx_pkt_fates.resize(MAX_FATE_LOG_LEN);
- size_t num_fates = 0;
- wifi_error status =
- global_func_table_.wifi_get_rx_pkt_fates(wlan_interface_handle_,
- rx_pkt_fates.data(),
- rx_pkt_fates.size(),
- &num_fates);
- CHECK(num_fates <= MAX_FATE_LOG_LEN);
- rx_pkt_fates.resize(num_fates);
- return {status, std::move(rx_pkt_fates)};
+std::pair<wifi_error, std::vector<wifi_rx_report>> WifiLegacyHal::getRxPktFates(
+ const std::string& iface_name) {
+ std::vector<wifi_rx_report> rx_pkt_fates;
+ rx_pkt_fates.resize(MAX_FATE_LOG_LEN);
+ size_t num_fates = 0;
+ wifi_error status = global_func_table_.wifi_get_rx_pkt_fates(
+ getIfaceHandle(iface_name), rx_pkt_fates.data(), rx_pkt_fates.size(),
+ &num_fates);
+ CHECK(num_fates <= MAX_FATE_LOG_LEN);
+ rx_pkt_fates.resize(num_fates);
+ return {status, std::move(rx_pkt_fates)};
}
-std::pair<wifi_error, WakeReasonStats> WifiLegacyHal::getWakeReasonStats() {
- WakeReasonStats stats;
- stats.cmd_event_wake_cnt.resize(kMaxWakeReasonStatsArraySize);
- stats.driver_fw_local_wake_cnt.resize(kMaxWakeReasonStatsArraySize);
+std::pair<wifi_error, WakeReasonStats> WifiLegacyHal::getWakeReasonStats(
+ const std::string& iface_name) {
+ WakeReasonStats stats;
+ stats.cmd_event_wake_cnt.resize(kMaxWakeReasonStatsArraySize);
+ stats.driver_fw_local_wake_cnt.resize(kMaxWakeReasonStatsArraySize);
- // This legacy struct needs separate memory to store the variable sized wake
- // reason types.
- stats.wake_reason_cnt.cmd_event_wake_cnt =
- reinterpret_cast<int32_t*>(stats.cmd_event_wake_cnt.data());
- stats.wake_reason_cnt.cmd_event_wake_cnt_sz = stats.cmd_event_wake_cnt.size();
- stats.wake_reason_cnt.cmd_event_wake_cnt_used = 0;
- stats.wake_reason_cnt.driver_fw_local_wake_cnt =
- reinterpret_cast<int32_t*>(stats.driver_fw_local_wake_cnt.data());
- stats.wake_reason_cnt.driver_fw_local_wake_cnt_sz =
- stats.driver_fw_local_wake_cnt.size();
- stats.wake_reason_cnt.driver_fw_local_wake_cnt_used = 0;
+ // This legacy struct needs separate memory to store the variable sized wake
+ // reason types.
+ stats.wake_reason_cnt.cmd_event_wake_cnt =
+ reinterpret_cast<int32_t*>(stats.cmd_event_wake_cnt.data());
+ stats.wake_reason_cnt.cmd_event_wake_cnt_sz =
+ stats.cmd_event_wake_cnt.size();
+ stats.wake_reason_cnt.cmd_event_wake_cnt_used = 0;
+ stats.wake_reason_cnt.driver_fw_local_wake_cnt =
+ reinterpret_cast<int32_t*>(stats.driver_fw_local_wake_cnt.data());
+ stats.wake_reason_cnt.driver_fw_local_wake_cnt_sz =
+ stats.driver_fw_local_wake_cnt.size();
+ stats.wake_reason_cnt.driver_fw_local_wake_cnt_used = 0;
- wifi_error status = global_func_table_.wifi_get_wake_reason_stats(
- wlan_interface_handle_, &stats.wake_reason_cnt);
+ wifi_error status = global_func_table_.wifi_get_wake_reason_stats(
+ getIfaceHandle(iface_name), &stats.wake_reason_cnt);
- CHECK(stats.wake_reason_cnt.cmd_event_wake_cnt_used >= 0 &&
+ CHECK(
+ stats.wake_reason_cnt.cmd_event_wake_cnt_used >= 0 &&
static_cast<uint32_t>(stats.wake_reason_cnt.cmd_event_wake_cnt_used) <=
kMaxWakeReasonStatsArraySize);
- stats.cmd_event_wake_cnt.resize(
- stats.wake_reason_cnt.cmd_event_wake_cnt_used);
- stats.wake_reason_cnt.cmd_event_wake_cnt = nullptr;
+ stats.cmd_event_wake_cnt.resize(
+ stats.wake_reason_cnt.cmd_event_wake_cnt_used);
+ stats.wake_reason_cnt.cmd_event_wake_cnt = nullptr;
- CHECK(stats.wake_reason_cnt.driver_fw_local_wake_cnt_used >= 0 &&
- static_cast<uint32_t>(
- stats.wake_reason_cnt.driver_fw_local_wake_cnt_used) <=
- kMaxWakeReasonStatsArraySize);
- stats.driver_fw_local_wake_cnt.resize(
- stats.wake_reason_cnt.driver_fw_local_wake_cnt_used);
- stats.wake_reason_cnt.driver_fw_local_wake_cnt = nullptr;
+ CHECK(stats.wake_reason_cnt.driver_fw_local_wake_cnt_used >= 0 &&
+ static_cast<uint32_t>(
+ stats.wake_reason_cnt.driver_fw_local_wake_cnt_used) <=
+ kMaxWakeReasonStatsArraySize);
+ stats.driver_fw_local_wake_cnt.resize(
+ stats.wake_reason_cnt.driver_fw_local_wake_cnt_used);
+ stats.wake_reason_cnt.driver_fw_local_wake_cnt = nullptr;
- return {status, stats};
+ return {status, stats};
}
wifi_error WifiLegacyHal::registerRingBufferCallbackHandler(
+ const std::string& iface_name,
const on_ring_buffer_data_callback& on_user_data_callback) {
- if (on_ring_buffer_data_internal_callback) {
- return WIFI_ERROR_NOT_AVAILABLE;
- }
- on_ring_buffer_data_internal_callback = [on_user_data_callback](
- char* ring_name,
- char* buffer,
- int buffer_size,
- wifi_ring_buffer_status* status) {
- if (status && buffer) {
- std::vector<uint8_t> buffer_vector(
- reinterpret_cast<uint8_t*>(buffer),
- reinterpret_cast<uint8_t*>(buffer) + buffer_size);
- on_user_data_callback(ring_name, buffer_vector, *status);
+ if (on_ring_buffer_data_internal_callback) {
+ return WIFI_ERROR_NOT_AVAILABLE;
}
- };
- wifi_error status = global_func_table_.wifi_set_log_handler(
- 0, wlan_interface_handle_, {onAsyncRingBufferData});
- if (status != WIFI_SUCCESS) {
- on_ring_buffer_data_internal_callback = nullptr;
- }
- return status;
+ on_ring_buffer_data_internal_callback =
+ [on_user_data_callback](char* ring_name, char* buffer, int buffer_size,
+ wifi_ring_buffer_status* status) {
+ if (status && buffer) {
+ std::vector<uint8_t> buffer_vector(
+ reinterpret_cast<uint8_t*>(buffer),
+ reinterpret_cast<uint8_t*>(buffer) + buffer_size);
+ on_user_data_callback(ring_name, buffer_vector, *status);
+ }
+ };
+ wifi_error status = global_func_table_.wifi_set_log_handler(
+ 0, getIfaceHandle(iface_name), {onAsyncRingBufferData});
+ if (status != WIFI_SUCCESS) {
+ on_ring_buffer_data_internal_callback = nullptr;
+ }
+ return status;
}
-wifi_error WifiLegacyHal::deregisterRingBufferCallbackHandler() {
- if (!on_ring_buffer_data_internal_callback) {
- return WIFI_ERROR_NOT_AVAILABLE;
- }
- on_ring_buffer_data_internal_callback = nullptr;
- return global_func_table_.wifi_reset_log_handler(0, wlan_interface_handle_);
+wifi_error WifiLegacyHal::deregisterRingBufferCallbackHandler(
+ const std::string& iface_name) {
+ if (!on_ring_buffer_data_internal_callback) {
+ return WIFI_ERROR_NOT_AVAILABLE;
+ }
+ on_ring_buffer_data_internal_callback = nullptr;
+ return global_func_table_.wifi_reset_log_handler(
+ 0, getIfaceHandle(iface_name));
}
std::pair<wifi_error, std::vector<wifi_ring_buffer_status>>
-WifiLegacyHal::getRingBuffersStatus() {
- std::vector<wifi_ring_buffer_status> ring_buffers_status;
- ring_buffers_status.resize(kMaxRingBuffers);
- uint32_t num_rings = kMaxRingBuffers;
- wifi_error status = global_func_table_.wifi_get_ring_buffers_status(
- wlan_interface_handle_, &num_rings, ring_buffers_status.data());
- CHECK(num_rings <= kMaxRingBuffers);
- ring_buffers_status.resize(num_rings);
- return {status, std::move(ring_buffers_status)};
+WifiLegacyHal::getRingBuffersStatus(const std::string& iface_name) {
+ std::vector<wifi_ring_buffer_status> ring_buffers_status;
+ ring_buffers_status.resize(kMaxRingBuffers);
+ uint32_t num_rings = kMaxRingBuffers;
+ wifi_error status = global_func_table_.wifi_get_ring_buffers_status(
+ getIfaceHandle(iface_name), &num_rings, ring_buffers_status.data());
+ CHECK(num_rings <= kMaxRingBuffers);
+ ring_buffers_status.resize(num_rings);
+ return {status, std::move(ring_buffers_status)};
}
-wifi_error WifiLegacyHal::startRingBufferLogging(const std::string& ring_name,
+wifi_error WifiLegacyHal::startRingBufferLogging(const std::string& iface_name,
+ const std::string& ring_name,
uint32_t verbose_level,
uint32_t max_interval_sec,
uint32_t min_data_size) {
- return global_func_table_.wifi_start_logging(wlan_interface_handle_,
- verbose_level,
- 0,
- max_interval_sec,
- min_data_size,
- makeCharVec(ring_name).data());
+ return global_func_table_.wifi_start_logging(
+ getIfaceHandle(iface_name), verbose_level, 0, max_interval_sec,
+ min_data_size, makeCharVec(ring_name).data());
}
-wifi_error WifiLegacyHal::getRingBufferData(const std::string& ring_name) {
- return global_func_table_.wifi_get_ring_data(wlan_interface_handle_,
- makeCharVec(ring_name).data());
+wifi_error WifiLegacyHal::getRingBufferData(const std::string& iface_name,
+ const std::string& ring_name) {
+ return global_func_table_.wifi_get_ring_data(getIfaceHandle(iface_name),
+ makeCharVec(ring_name).data());
}
wifi_error WifiLegacyHal::registerErrorAlertCallbackHandler(
+ const std::string& iface_name,
const on_error_alert_callback& on_user_alert_callback) {
- if (on_error_alert_internal_callback) {
- return WIFI_ERROR_NOT_AVAILABLE;
- }
- on_error_alert_internal_callback = [on_user_alert_callback](
- wifi_request_id id, char* buffer, int buffer_size, int err_code) {
- if (buffer) {
- CHECK(id == 0);
- on_user_alert_callback(
- err_code,
- std::vector<uint8_t>(
- reinterpret_cast<uint8_t*>(buffer),
- reinterpret_cast<uint8_t*>(buffer) + buffer_size));
+ if (on_error_alert_internal_callback) {
+ return WIFI_ERROR_NOT_AVAILABLE;
}
- };
- wifi_error status = global_func_table_.wifi_set_alert_handler(
- 0, wlan_interface_handle_, {onAsyncErrorAlert});
- if (status != WIFI_SUCCESS) {
- on_error_alert_internal_callback = nullptr;
- }
- return status;
+ on_error_alert_internal_callback = [on_user_alert_callback](
+ wifi_request_id id, char* buffer,
+ int buffer_size, int err_code) {
+ if (buffer) {
+ CHECK(id == 0);
+ on_user_alert_callback(
+ err_code,
+ std::vector<uint8_t>(
+ reinterpret_cast<uint8_t*>(buffer),
+ reinterpret_cast<uint8_t*>(buffer) + buffer_size));
+ }
+ };
+ wifi_error status = global_func_table_.wifi_set_alert_handler(
+ 0, getIfaceHandle(iface_name), {onAsyncErrorAlert});
+ if (status != WIFI_SUCCESS) {
+ on_error_alert_internal_callback = nullptr;
+ }
+ return status;
}
-wifi_error WifiLegacyHal::deregisterErrorAlertCallbackHandler() {
- if (!on_error_alert_internal_callback) {
- return WIFI_ERROR_NOT_AVAILABLE;
- }
- on_error_alert_internal_callback = nullptr;
- return global_func_table_.wifi_reset_alert_handler(0, wlan_interface_handle_);
+wifi_error WifiLegacyHal::deregisterErrorAlertCallbackHandler(
+ const std::string& iface_name) {
+ if (!on_error_alert_internal_callback) {
+ return WIFI_ERROR_NOT_AVAILABLE;
+ }
+ on_error_alert_internal_callback = nullptr;
+ return global_func_table_.wifi_reset_alert_handler(
+ 0, getIfaceHandle(iface_name));
}
wifi_error WifiLegacyHal::startRttRangeRequest(
- wifi_request_id id,
+ const std::string& iface_name, wifi_request_id id,
const std::vector<wifi_rtt_config>& rtt_configs,
const on_rtt_results_callback& on_results_user_callback) {
- if (on_rtt_results_internal_callback) {
- return WIFI_ERROR_NOT_AVAILABLE;
- }
-
- on_rtt_results_internal_callback = [on_results_user_callback](
- wifi_request_id id,
- unsigned num_results,
- wifi_rtt_result* rtt_results[]) {
- if (num_results > 0 && !rtt_results) {
- LOG(ERROR) << "Unexpected nullptr in RTT results";
- return;
+ if (on_rtt_results_internal_callback) {
+ return WIFI_ERROR_NOT_AVAILABLE;
}
- std::vector<const wifi_rtt_result*> rtt_results_vec;
- std::copy_if(
- rtt_results,
- rtt_results + num_results,
- back_inserter(rtt_results_vec),
- [](wifi_rtt_result* rtt_result) { return rtt_result != nullptr; });
- on_results_user_callback(id, rtt_results_vec);
- };
- std::vector<wifi_rtt_config> rtt_configs_internal(rtt_configs);
- wifi_error status =
- global_func_table_.wifi_rtt_range_request(id,
- wlan_interface_handle_,
- rtt_configs.size(),
- rtt_configs_internal.data(),
- {onAsyncRttResults});
- if (status != WIFI_SUCCESS) {
- on_rtt_results_internal_callback = nullptr;
- }
- return status;
+ on_rtt_results_internal_callback =
+ [on_results_user_callback](wifi_request_id id, unsigned num_results,
+ wifi_rtt_result* rtt_results[]) {
+ if (num_results > 0 && !rtt_results) {
+ LOG(ERROR) << "Unexpected nullptr in RTT results";
+ return;
+ }
+ std::vector<const wifi_rtt_result*> rtt_results_vec;
+ std::copy_if(rtt_results, rtt_results + num_results,
+ back_inserter(rtt_results_vec),
+ [](wifi_rtt_result* rtt_result) {
+ return rtt_result != nullptr;
+ });
+ on_results_user_callback(id, rtt_results_vec);
+ };
+
+ std::vector<wifi_rtt_config> rtt_configs_internal(rtt_configs);
+ wifi_error status = global_func_table_.wifi_rtt_range_request(
+ id, getIfaceHandle(iface_name), rtt_configs.size(),
+ rtt_configs_internal.data(), {onAsyncRttResults});
+ if (status != WIFI_SUCCESS) {
+ on_rtt_results_internal_callback = nullptr;
+ }
+ return status;
}
wifi_error WifiLegacyHal::cancelRttRangeRequest(
- wifi_request_id id, const std::vector<std::array<uint8_t, 6>>& mac_addrs) {
- if (!on_rtt_results_internal_callback) {
- return WIFI_ERROR_NOT_AVAILABLE;
- }
- static_assert(sizeof(mac_addr) == sizeof(std::array<uint8_t, 6>),
- "MAC address size mismatch");
- // TODO: How do we handle partial cancels (i.e only a subset of enabled mac
- // addressed are cancelled).
- std::vector<std::array<uint8_t, 6>> mac_addrs_internal(mac_addrs);
- wifi_error status = global_func_table_.wifi_rtt_range_cancel(
- id,
- wlan_interface_handle_,
- mac_addrs.size(),
- reinterpret_cast<mac_addr*>(mac_addrs_internal.data()));
- // If the request Id is wrong, don't stop the ongoing range request. Any
- // other error should be treated as the end of rtt ranging.
- if (status != WIFI_ERROR_INVALID_REQUEST_ID) {
- on_rtt_results_internal_callback = nullptr;
- }
- return status;
+ const std::string& iface_name, wifi_request_id id,
+ const std::vector<std::array<uint8_t, 6>>& mac_addrs) {
+ if (!on_rtt_results_internal_callback) {
+ return WIFI_ERROR_NOT_AVAILABLE;
+ }
+ static_assert(sizeof(mac_addr) == sizeof(std::array<uint8_t, 6>),
+ "MAC address size mismatch");
+ // TODO: How do we handle partial cancels (i.e only a subset of enabled mac
+ // addressed are cancelled).
+ std::vector<std::array<uint8_t, 6>> mac_addrs_internal(mac_addrs);
+ wifi_error status = global_func_table_.wifi_rtt_range_cancel(
+ id, getIfaceHandle(iface_name), mac_addrs.size(),
+ reinterpret_cast<mac_addr*>(mac_addrs_internal.data()));
+ // If the request Id is wrong, don't stop the ongoing range request. Any
+ // other error should be treated as the end of rtt ranging.
+ if (status != WIFI_ERROR_INVALID_REQUEST_ID) {
+ on_rtt_results_internal_callback = nullptr;
+ }
+ return status;
}
-std::pair<wifi_error, wifi_rtt_capabilities>
-WifiLegacyHal::getRttCapabilities() {
- wifi_rtt_capabilities rtt_caps;
- wifi_error status = global_func_table_.wifi_get_rtt_capabilities(
- wlan_interface_handle_, &rtt_caps);
- return {status, rtt_caps};
+std::pair<wifi_error, wifi_rtt_capabilities> WifiLegacyHal::getRttCapabilities(
+ const std::string& iface_name) {
+ wifi_rtt_capabilities rtt_caps;
+ wifi_error status = global_func_table_.wifi_get_rtt_capabilities(
+ getIfaceHandle(iface_name), &rtt_caps);
+ return {status, rtt_caps};
}
-std::pair<wifi_error, wifi_rtt_responder> WifiLegacyHal::getRttResponderInfo() {
- wifi_rtt_responder rtt_responder;
- wifi_error status = global_func_table_.wifi_rtt_get_responder_info(
- wlan_interface_handle_, &rtt_responder);
- return {status, rtt_responder};
+std::pair<wifi_error, wifi_rtt_responder> WifiLegacyHal::getRttResponderInfo(
+ const std::string& iface_name) {
+ wifi_rtt_responder rtt_responder;
+ wifi_error status = global_func_table_.wifi_rtt_get_responder_info(
+ getIfaceHandle(iface_name), &rtt_responder);
+ return {status, rtt_responder};
}
wifi_error WifiLegacyHal::enableRttResponder(
- wifi_request_id id,
- const wifi_channel_info& channel_hint,
- uint32_t max_duration_secs,
+ const std::string& iface_name, wifi_request_id id,
+ const wifi_channel_info& channel_hint, uint32_t max_duration_secs,
const wifi_rtt_responder& info) {
- wifi_rtt_responder info_internal(info);
- return global_func_table_.wifi_enable_responder(id,
- wlan_interface_handle_,
- channel_hint,
- max_duration_secs,
- &info_internal);
+ wifi_rtt_responder info_internal(info);
+ return global_func_table_.wifi_enable_responder(
+ id, getIfaceHandle(iface_name), channel_hint, max_duration_secs,
+ &info_internal);
}
-wifi_error WifiLegacyHal::disableRttResponder(wifi_request_id id) {
- return global_func_table_.wifi_disable_responder(id, wlan_interface_handle_);
+wifi_error WifiLegacyHal::disableRttResponder(const std::string& iface_name,
+ wifi_request_id id) {
+ return global_func_table_.wifi_disable_responder(
+ id, getIfaceHandle(iface_name));
}
-wifi_error WifiLegacyHal::setRttLci(wifi_request_id id,
+wifi_error WifiLegacyHal::setRttLci(const std::string& iface_name,
+ wifi_request_id id,
const wifi_lci_information& info) {
- wifi_lci_information info_internal(info);
- return global_func_table_.wifi_set_lci(
- id, wlan_interface_handle_, &info_internal);
+ wifi_lci_information info_internal(info);
+ return global_func_table_.wifi_set_lci(id, getIfaceHandle(iface_name),
+ &info_internal);
}
-wifi_error WifiLegacyHal::setRttLcr(wifi_request_id id,
+wifi_error WifiLegacyHal::setRttLcr(const std::string& iface_name,
+ wifi_request_id id,
const wifi_lcr_information& info) {
- wifi_lcr_information info_internal(info);
- return global_func_table_.wifi_set_lcr(
- id, wlan_interface_handle_, &info_internal);
+ wifi_lcr_information info_internal(info);
+ return global_func_table_.wifi_set_lcr(id, getIfaceHandle(iface_name),
+ &info_internal);
}
wifi_error WifiLegacyHal::nanRegisterCallbackHandlers(
- const NanCallbackHandlers& user_callbacks) {
- on_nan_notify_response_user_callback = user_callbacks.on_notify_response;
- on_nan_event_publish_terminated_user_callback =
- user_callbacks.on_event_publish_terminated;
- on_nan_event_match_user_callback = user_callbacks.on_event_match;
- on_nan_event_match_expired_user_callback =
- user_callbacks.on_event_match_expired;
- on_nan_event_subscribe_terminated_user_callback =
- user_callbacks.on_event_subscribe_terminated;
- on_nan_event_followup_user_callback = user_callbacks.on_event_followup;
- on_nan_event_disc_eng_event_user_callback =
- user_callbacks.on_event_disc_eng_event;
- on_nan_event_disabled_user_callback = user_callbacks.on_event_disabled;
- on_nan_event_tca_user_callback = user_callbacks.on_event_tca;
- on_nan_event_beacon_sdf_payload_user_callback =
- user_callbacks.on_event_beacon_sdf_payload;
- on_nan_event_data_path_request_user_callback =
- user_callbacks.on_event_data_path_request;
- on_nan_event_data_path_confirm_user_callback =
- user_callbacks.on_event_data_path_confirm;
- on_nan_event_data_path_end_user_callback =
- user_callbacks.on_event_data_path_end;
- on_nan_event_transmit_follow_up_user_callback =
- user_callbacks.on_event_transmit_follow_up;
- 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;
+ const std::string& iface_name, const NanCallbackHandlers& user_callbacks) {
+ on_nan_notify_response_user_callback = user_callbacks.on_notify_response;
+ on_nan_event_publish_terminated_user_callback =
+ user_callbacks.on_event_publish_terminated;
+ on_nan_event_match_user_callback = user_callbacks.on_event_match;
+ on_nan_event_match_expired_user_callback =
+ user_callbacks.on_event_match_expired;
+ on_nan_event_subscribe_terminated_user_callback =
+ user_callbacks.on_event_subscribe_terminated;
+ on_nan_event_followup_user_callback = user_callbacks.on_event_followup;
+ on_nan_event_disc_eng_event_user_callback =
+ user_callbacks.on_event_disc_eng_event;
+ on_nan_event_disabled_user_callback = user_callbacks.on_event_disabled;
+ on_nan_event_tca_user_callback = user_callbacks.on_event_tca;
+ on_nan_event_beacon_sdf_payload_user_callback =
+ user_callbacks.on_event_beacon_sdf_payload;
+ on_nan_event_data_path_request_user_callback =
+ user_callbacks.on_event_data_path_request;
+ on_nan_event_data_path_confirm_user_callback =
+ user_callbacks.on_event_data_path_confirm;
+ on_nan_event_data_path_end_user_callback =
+ user_callbacks.on_event_data_path_end;
+ on_nan_event_transmit_follow_up_user_callback =
+ user_callbacks.on_event_transmit_follow_up;
+ 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;
- return global_func_table_.wifi_nan_register_handler(
- wlan_interface_handle_,
- {onAysncNanNotifyResponse,
- onAysncNanEventPublishReplied,
- onAysncNanEventPublishTerminated,
- onAysncNanEventMatch,
- onAysncNanEventMatchExpired,
- onAysncNanEventSubscribeTerminated,
- onAysncNanEventFollowup,
- onAysncNanEventDiscEngEvent,
- onAysncNanEventDisabled,
- onAysncNanEventTca,
- onAysncNanEventBeaconSdfPayload,
- onAysncNanEventDataPathRequest,
- onAysncNanEventDataPathConfirm,
- onAysncNanEventDataPathEnd,
- onAysncNanEventTransmitFollowUp,
- onAysncNanEventRangeRequest,
- onAysncNanEventRangeReport});
+ return global_func_table_.wifi_nan_register_handler(
+ getIfaceHandle(iface_name),
+ {onAysncNanNotifyResponse, onAysncNanEventPublishReplied,
+ onAysncNanEventPublishTerminated, onAysncNanEventMatch,
+ onAysncNanEventMatchExpired, onAysncNanEventSubscribeTerminated,
+ onAysncNanEventFollowup, onAysncNanEventDiscEngEvent,
+ onAysncNanEventDisabled, onAysncNanEventTca,
+ onAysncNanEventBeaconSdfPayload, onAysncNanEventDataPathRequest,
+ onAysncNanEventDataPathConfirm, onAysncNanEventDataPathEnd,
+ onAysncNanEventTransmitFollowUp, onAysncNanEventRangeRequest,
+ onAysncNanEventRangeReport});
}
-wifi_error WifiLegacyHal::nanEnableRequest(transaction_id id,
+wifi_error WifiLegacyHal::nanEnableRequest(const std::string& iface_name,
+ transaction_id id,
const NanEnableRequest& msg) {
- NanEnableRequest msg_internal(msg);
- return global_func_table_.wifi_nan_enable_request(
- id, wlan_interface_handle_, &msg_internal);
+ NanEnableRequest msg_internal(msg);
+ return global_func_table_.wifi_nan_enable_request(
+ id, getIfaceHandle(iface_name), &msg_internal);
}
-wifi_error WifiLegacyHal::nanDisableRequest(transaction_id id) {
- return global_func_table_.wifi_nan_disable_request(id,
- wlan_interface_handle_);
+wifi_error WifiLegacyHal::nanDisableRequest(const std::string& iface_name,
+ transaction_id id) {
+ return global_func_table_.wifi_nan_disable_request(
+ id, getIfaceHandle(iface_name));
}
-wifi_error WifiLegacyHal::nanPublishRequest(transaction_id id,
+wifi_error WifiLegacyHal::nanPublishRequest(const std::string& iface_name,
+ transaction_id id,
const NanPublishRequest& msg) {
- NanPublishRequest msg_internal(msg);
- return global_func_table_.wifi_nan_publish_request(
- id, wlan_interface_handle_, &msg_internal);
+ NanPublishRequest msg_internal(msg);
+ return global_func_table_.wifi_nan_publish_request(
+ id, getIfaceHandle(iface_name), &msg_internal);
}
wifi_error WifiLegacyHal::nanPublishCancelRequest(
- transaction_id id, const NanPublishCancelRequest& msg) {
- NanPublishCancelRequest msg_internal(msg);
- return global_func_table_.wifi_nan_publish_cancel_request(
- id, wlan_interface_handle_, &msg_internal);
+ const std::string& iface_name, transaction_id id,
+ const NanPublishCancelRequest& msg) {
+ NanPublishCancelRequest msg_internal(msg);
+ return global_func_table_.wifi_nan_publish_cancel_request(
+ id, getIfaceHandle(iface_name), &msg_internal);
}
-wifi_error WifiLegacyHal::nanSubscribeRequest(transaction_id id,
+wifi_error WifiLegacyHal::nanSubscribeRequest(const std::string& iface_name,
+ transaction_id id,
const NanSubscribeRequest& msg) {
- NanSubscribeRequest msg_internal(msg);
- return global_func_table_.wifi_nan_subscribe_request(
- id, wlan_interface_handle_, &msg_internal);
+ NanSubscribeRequest msg_internal(msg);
+ return global_func_table_.wifi_nan_subscribe_request(
+ id, getIfaceHandle(iface_name), &msg_internal);
}
wifi_error WifiLegacyHal::nanSubscribeCancelRequest(
- transaction_id id, const NanSubscribeCancelRequest& msg) {
- NanSubscribeCancelRequest msg_internal(msg);
- return global_func_table_.wifi_nan_subscribe_cancel_request(
- id, wlan_interface_handle_, &msg_internal);
+ const std::string& iface_name, transaction_id id,
+ const NanSubscribeCancelRequest& msg) {
+ NanSubscribeCancelRequest msg_internal(msg);
+ return global_func_table_.wifi_nan_subscribe_cancel_request(
+ id, getIfaceHandle(iface_name), &msg_internal);
}
wifi_error WifiLegacyHal::nanTransmitFollowupRequest(
- transaction_id id, const NanTransmitFollowupRequest& msg) {
- NanTransmitFollowupRequest msg_internal(msg);
- return global_func_table_.wifi_nan_transmit_followup_request(
- id, wlan_interface_handle_, &msg_internal);
+ const std::string& iface_name, transaction_id id,
+ const NanTransmitFollowupRequest& msg) {
+ NanTransmitFollowupRequest msg_internal(msg);
+ return global_func_table_.wifi_nan_transmit_followup_request(
+ id, getIfaceHandle(iface_name), &msg_internal);
}
-wifi_error WifiLegacyHal::nanStatsRequest(transaction_id id,
+wifi_error WifiLegacyHal::nanStatsRequest(const std::string& iface_name,
+ transaction_id id,
const NanStatsRequest& msg) {
- NanStatsRequest msg_internal(msg);
- return global_func_table_.wifi_nan_stats_request(
- id, wlan_interface_handle_, &msg_internal);
+ NanStatsRequest msg_internal(msg);
+ return global_func_table_.wifi_nan_stats_request(
+ id, getIfaceHandle(iface_name), &msg_internal);
}
-wifi_error WifiLegacyHal::nanConfigRequest(transaction_id id,
+wifi_error WifiLegacyHal::nanConfigRequest(const std::string& iface_name,
+ transaction_id id,
const NanConfigRequest& msg) {
- NanConfigRequest msg_internal(msg);
- return global_func_table_.wifi_nan_config_request(
- id, wlan_interface_handle_, &msg_internal);
+ NanConfigRequest msg_internal(msg);
+ return global_func_table_.wifi_nan_config_request(
+ id, getIfaceHandle(iface_name), &msg_internal);
}
-wifi_error WifiLegacyHal::nanTcaRequest(transaction_id id,
+wifi_error WifiLegacyHal::nanTcaRequest(const std::string& iface_name,
+ transaction_id id,
const NanTCARequest& msg) {
- NanTCARequest msg_internal(msg);
- return global_func_table_.wifi_nan_tca_request(
- id, wlan_interface_handle_, &msg_internal);
+ NanTCARequest msg_internal(msg);
+ return global_func_table_.wifi_nan_tca_request(
+ id, getIfaceHandle(iface_name), &msg_internal);
}
wifi_error WifiLegacyHal::nanBeaconSdfPayloadRequest(
- transaction_id id, const NanBeaconSdfPayloadRequest& msg) {
- NanBeaconSdfPayloadRequest msg_internal(msg);
- return global_func_table_.wifi_nan_beacon_sdf_payload_request(
- id, wlan_interface_handle_, &msg_internal);
+ const std::string& iface_name, transaction_id id,
+ const NanBeaconSdfPayloadRequest& msg) {
+ NanBeaconSdfPayloadRequest msg_internal(msg);
+ return global_func_table_.wifi_nan_beacon_sdf_payload_request(
+ id, getIfaceHandle(iface_name), &msg_internal);
}
std::pair<wifi_error, NanVersion> WifiLegacyHal::nanGetVersion() {
- NanVersion version;
- wifi_error status =
- global_func_table_.wifi_nan_get_version(global_handle_, &version);
- return {status, version};
+ NanVersion version;
+ wifi_error status =
+ global_func_table_.wifi_nan_get_version(global_handle_, &version);
+ return {status, version};
}
-wifi_error WifiLegacyHal::nanGetCapabilities(transaction_id id) {
- return global_func_table_.wifi_nan_get_capabilities(id,
- wlan_interface_handle_);
+wifi_error WifiLegacyHal::nanGetCapabilities(const std::string& iface_name,
+ transaction_id id) {
+ return global_func_table_.wifi_nan_get_capabilities(
+ id, getIfaceHandle(iface_name));
}
wifi_error WifiLegacyHal::nanDataInterfaceCreate(
- transaction_id id, const std::string& iface_name) {
- return global_func_table_.wifi_nan_data_interface_create(
- id, wlan_interface_handle_, makeCharVec(iface_name).data());
+ const std::string& iface_name, transaction_id id,
+ const std::string& data_iface_name) {
+ return global_func_table_.wifi_nan_data_interface_create(
+ id, getIfaceHandle(iface_name), makeCharVec(data_iface_name).data());
}
wifi_error WifiLegacyHal::nanDataInterfaceDelete(
- transaction_id id, const std::string& iface_name) {
- return global_func_table_.wifi_nan_data_interface_delete(
- id, wlan_interface_handle_, makeCharVec(iface_name).data());
+ const std::string& iface_name, transaction_id id,
+ const std::string& data_iface_name) {
+ return global_func_table_.wifi_nan_data_interface_delete(
+ id, getIfaceHandle(iface_name), makeCharVec(data_iface_name).data());
}
wifi_error WifiLegacyHal::nanDataRequestInitiator(
- transaction_id id, const NanDataPathInitiatorRequest& msg) {
- NanDataPathInitiatorRequest msg_internal(msg);
- return global_func_table_.wifi_nan_data_request_initiator(
- id, wlan_interface_handle_, &msg_internal);
+ const std::string& iface_name, transaction_id id,
+ const NanDataPathInitiatorRequest& msg) {
+ NanDataPathInitiatorRequest msg_internal(msg);
+ return global_func_table_.wifi_nan_data_request_initiator(
+ id, getIfaceHandle(iface_name), &msg_internal);
}
wifi_error WifiLegacyHal::nanDataIndicationResponse(
- transaction_id id, const NanDataPathIndicationResponse& msg) {
- NanDataPathIndicationResponse msg_internal(msg);
- return global_func_table_.wifi_nan_data_indication_response(
- id, wlan_interface_handle_, &msg_internal);
+ const std::string& iface_name, transaction_id id,
+ const NanDataPathIndicationResponse& msg) {
+ NanDataPathIndicationResponse msg_internal(msg);
+ return global_func_table_.wifi_nan_data_indication_response(
+ id, getIfaceHandle(iface_name), &msg_internal);
}
typedef struct {
@@ -1223,118 +1209,127 @@
NanDataPathId ndp_instance_id;
} NanDataPathEndSingleNdpIdRequest;
-wifi_error WifiLegacyHal::nanDataEnd(transaction_id id,
+wifi_error WifiLegacyHal::nanDataEnd(const std::string& iface_name,
+ transaction_id id,
uint32_t ndpInstanceId) {
- NanDataPathEndSingleNdpIdRequest msg;
- msg.num_ndp_instances = 1;
- msg.ndp_instance_id = ndpInstanceId;
- wifi_error status = global_func_table_.wifi_nan_data_end(
- id, wlan_interface_handle_, (NanDataPathEndRequest*)&msg);
- return status;
-}
-
-wifi_error WifiLegacyHal::setCountryCode(std::array<int8_t, 2> code) {
- std::string code_str(code.data(), code.data() + code.size());
- return global_func_table_.wifi_set_country_code(wlan_interface_handle_,
- code_str.c_str());
-}
-
-wifi_error WifiLegacyHal::retrieveWlanInterfaceHandle() {
- const std::string& ifname_to_find = getStaIfaceName();
- wifi_interface_handle* iface_handles = nullptr;
- int num_iface_handles = 0;
- wifi_error status = global_func_table_.wifi_get_ifaces(
- global_handle_, &num_iface_handles, &iface_handles);
- if (status != WIFI_SUCCESS) {
- LOG(ERROR) << "Failed to enumerate interface handles";
+ NanDataPathEndSingleNdpIdRequest msg;
+ msg.num_ndp_instances = 1;
+ msg.ndp_instance_id = ndpInstanceId;
+ wifi_error status = global_func_table_.wifi_nan_data_end(
+ id, getIfaceHandle(iface_name), (NanDataPathEndRequest*)&msg);
return status;
- }
- for (int i = 0; i < num_iface_handles; ++i) {
- std::array<char, IFNAMSIZ> current_ifname;
- current_ifname.fill(0);
- status = global_func_table_.wifi_get_iface_name(
- iface_handles[i], current_ifname.data(), current_ifname.size());
+}
+
+wifi_error WifiLegacyHal::setCountryCode(const std::string& iface_name,
+ std::array<int8_t, 2> code) {
+ std::string code_str(code.data(), code.data() + code.size());
+ return global_func_table_.wifi_set_country_code(getIfaceHandle(iface_name),
+ code_str.c_str());
+}
+
+wifi_error WifiLegacyHal::retrieveIfaceHandles() {
+ wifi_interface_handle* iface_handles = nullptr;
+ int num_iface_handles = 0;
+ wifi_error status = global_func_table_.wifi_get_ifaces(
+ global_handle_, &num_iface_handles, &iface_handles);
if (status != WIFI_SUCCESS) {
- LOG(WARNING) << "Failed to get interface handle name";
- continue;
+ LOG(ERROR) << "Failed to enumerate interface handles";
+ return status;
}
- if (ifname_to_find == current_ifname.data()) {
- wlan_interface_handle_ = iface_handles[i];
- return WIFI_SUCCESS;
+ for (int i = 0; i < num_iface_handles; ++i) {
+ std::array<char, IFNAMSIZ> iface_name_arr = {};
+ status = global_func_table_.wifi_get_iface_name(
+ iface_handles[i], iface_name_arr.data(), iface_name_arr.size());
+ if (status != WIFI_SUCCESS) {
+ LOG(WARNING) << "Failed to get interface handle name";
+ continue;
+ }
+ // Assuming the interface name is null terminated since the legacy HAL
+ // API does not return a size.
+ std::string iface_name(iface_name_arr.data());
+ LOG(INFO) << "Adding interface handle for " << iface_name;
+ iface_name_to_handle_[iface_name] = iface_handles[i];
}
- }
- return WIFI_ERROR_UNKNOWN;
+ return WIFI_SUCCESS;
+}
+
+wifi_interface_handle WifiLegacyHal::getIfaceHandle(
+ const std::string& iface_name) {
+ const auto iface_handle_iter = iface_name_to_handle_.find(iface_name);
+ if (iface_handle_iter == iface_name_to_handle_.end()) {
+ LOG(ERROR) << "Unknown iface name: " << iface_name;
+ return nullptr;
+ }
+ return iface_handle_iter->second;
}
void WifiLegacyHal::runEventLoop() {
- LOG(DEBUG) << "Starting legacy HAL event loop";
- global_func_table_.wifi_event_loop(global_handle_);
- const auto lock = hidl_sync_util::acquireGlobalLock();
- if (!awaiting_event_loop_termination_) {
- LOG(FATAL) << "Legacy HAL event loop terminated, but HAL was not stopping";
- }
- LOG(DEBUG) << "Legacy HAL event loop terminated";
- awaiting_event_loop_termination_ = false;
- stop_wait_cv_.notify_one();
+ LOG(DEBUG) << "Starting legacy HAL event loop";
+ global_func_table_.wifi_event_loop(global_handle_);
+ const auto lock = hidl_sync_util::acquireGlobalLock();
+ if (!awaiting_event_loop_termination_) {
+ LOG(FATAL)
+ << "Legacy HAL event loop terminated, but HAL was not stopping";
+ }
+ LOG(DEBUG) << "Legacy HAL event loop terminated";
+ awaiting_event_loop_termination_ = false;
+ stop_wait_cv_.notify_one();
}
std::pair<wifi_error, std::vector<wifi_cached_scan_results>>
-WifiLegacyHal::getGscanCachedResults() {
- std::vector<wifi_cached_scan_results> cached_scan_results;
- cached_scan_results.resize(kMaxCachedGscanResults);
- int32_t num_results = 0;
- wifi_error status = global_func_table_.wifi_get_cached_gscan_results(
- wlan_interface_handle_,
- true /* always flush */,
- cached_scan_results.size(),
- cached_scan_results.data(),
- &num_results);
- CHECK(num_results >= 0 &&
- static_cast<uint32_t>(num_results) <= kMaxCachedGscanResults);
- cached_scan_results.resize(num_results);
- // Check for invalid IE lengths in these cached scan results and correct it.
- for (auto& cached_scan_result : cached_scan_results) {
- int num_scan_results = cached_scan_result.num_results;
- for (int i = 0; i < num_scan_results; i++) {
- auto& scan_result = cached_scan_result.results[i];
- if (scan_result.ie_length > 0) {
- LOG(DEBUG) << "Cached scan result has non-zero IE length "
- << scan_result.ie_length;
- scan_result.ie_length = 0;
- }
+WifiLegacyHal::getGscanCachedResults(const std::string& iface_name) {
+ std::vector<wifi_cached_scan_results> cached_scan_results;
+ cached_scan_results.resize(kMaxCachedGscanResults);
+ int32_t num_results = 0;
+ wifi_error status = global_func_table_.wifi_get_cached_gscan_results(
+ getIfaceHandle(iface_name), true /* always flush */,
+ cached_scan_results.size(), cached_scan_results.data(), &num_results);
+ CHECK(num_results >= 0 &&
+ static_cast<uint32_t>(num_results) <= kMaxCachedGscanResults);
+ cached_scan_results.resize(num_results);
+ // Check for invalid IE lengths in these cached scan results and correct it.
+ for (auto& cached_scan_result : cached_scan_results) {
+ int num_scan_results = cached_scan_result.num_results;
+ for (int i = 0; i < num_scan_results; i++) {
+ auto& scan_result = cached_scan_result.results[i];
+ if (scan_result.ie_length > 0) {
+ LOG(DEBUG) << "Cached scan result has non-zero IE length "
+ << scan_result.ie_length;
+ scan_result.ie_length = 0;
+ }
+ }
}
- }
- return {status, std::move(cached_scan_results)};
+ return {status, std::move(cached_scan_results)};
}
void WifiLegacyHal::invalidate() {
- global_handle_ = nullptr;
- wlan_interface_handle_ = nullptr;
- on_driver_memory_dump_internal_callback = nullptr;
- on_firmware_memory_dump_internal_callback = nullptr;
- on_gscan_event_internal_callback = nullptr;
- on_gscan_full_result_internal_callback = nullptr;
- on_link_layer_stats_result_internal_callback = nullptr;
- on_rssi_threshold_breached_internal_callback = nullptr;
- on_ring_buffer_data_internal_callback = nullptr;
- on_error_alert_internal_callback = nullptr;
- on_rtt_results_internal_callback = nullptr;
- on_nan_notify_response_user_callback = nullptr;
- on_nan_event_publish_terminated_user_callback = nullptr;
- on_nan_event_match_user_callback = nullptr;
- on_nan_event_match_expired_user_callback = nullptr;
- on_nan_event_subscribe_terminated_user_callback = nullptr;
- on_nan_event_followup_user_callback = nullptr;
- on_nan_event_disc_eng_event_user_callback = nullptr;
- on_nan_event_disabled_user_callback = nullptr;
- on_nan_event_tca_user_callback = nullptr;
- on_nan_event_beacon_sdf_payload_user_callback = nullptr;
- on_nan_event_data_path_request_user_callback = nullptr;
- on_nan_event_data_path_confirm_user_callback = nullptr;
- on_nan_event_data_path_end_user_callback = nullptr;
- on_nan_event_transmit_follow_up_user_callback = nullptr;
- on_nan_event_range_request_user_callback = nullptr;
- on_nan_event_range_report_user_callback = nullptr;
+ global_handle_ = nullptr;
+ iface_name_to_handle_.clear();
+ on_driver_memory_dump_internal_callback = nullptr;
+ on_firmware_memory_dump_internal_callback = nullptr;
+ on_gscan_event_internal_callback = nullptr;
+ on_gscan_full_result_internal_callback = nullptr;
+ on_link_layer_stats_result_internal_callback = nullptr;
+ on_rssi_threshold_breached_internal_callback = nullptr;
+ on_ring_buffer_data_internal_callback = nullptr;
+ on_error_alert_internal_callback = nullptr;
+ on_rtt_results_internal_callback = nullptr;
+ on_nan_notify_response_user_callback = nullptr;
+ on_nan_event_publish_terminated_user_callback = nullptr;
+ on_nan_event_match_user_callback = nullptr;
+ on_nan_event_match_expired_user_callback = nullptr;
+ on_nan_event_subscribe_terminated_user_callback = nullptr;
+ on_nan_event_followup_user_callback = nullptr;
+ on_nan_event_disc_eng_event_user_callback = nullptr;
+ on_nan_event_disabled_user_callback = nullptr;
+ on_nan_event_tca_user_callback = nullptr;
+ on_nan_event_beacon_sdf_payload_user_callback = nullptr;
+ on_nan_event_data_path_request_user_callback = nullptr;
+ on_nan_event_data_path_confirm_user_callback = nullptr;
+ on_nan_event_data_path_end_user_callback = nullptr;
+ on_nan_event_transmit_follow_up_user_callback = nullptr;
+ on_nan_event_range_request_user_callback = nullptr;
+ on_nan_event_range_report_user_callback = nullptr;
}
} // namespace legacy_hal
diff --git a/wifi/1.2/default/wifi_legacy_hal.h b/wifi/1.2/default/wifi_legacy_hal.h
index d7be1ee..193928b 100644
--- a/wifi/1.2/default/wifi_legacy_hal.h
+++ b/wifi/1.2/default/wifi_legacy_hal.h
@@ -17,10 +17,11 @@
#ifndef WIFI_LEGACY_HAL_H_
#define WIFI_LEGACY_HAL_H_
+#include <condition_variable>
#include <functional>
+#include <map>
#include <thread>
#include <vector>
-#include <condition_variable>
#include <wifi_system/interface_tool.h>
@@ -38,8 +39,8 @@
// APF capabilities supported by the iface.
struct PacketFilterCapabilities {
- uint32_t version;
- uint32_t max_len;
+ uint32_t version;
+ uint32_t max_len;
};
// WARNING: We don't care about the variable sized members of either
@@ -51,13 +52,13 @@
// |wifi_radio_stat| structure in the legacy HAL API. Separate that out
// into a separate return element to avoid passing pointers around.
struct LinkLayerRadioStats {
- wifi_radio_stat stats;
- std::vector<uint32_t> tx_time_per_levels;
+ wifi_radio_stat stats;
+ std::vector<uint32_t> tx_time_per_levels;
};
struct LinkLayerStats {
- wifi_iface_stat iface;
- std::vector<LinkLayerRadioStats> radios;
+ wifi_iface_stat iface;
+ std::vector<LinkLayerRadioStats> radios;
};
#pragma GCC diagnostic pop
@@ -67,37 +68,38 @@
// API. Separate that out into a separate return elements to avoid passing
// pointers around.
struct WakeReasonStats {
- WLAN_DRIVER_WAKE_REASON_CNT wake_reason_cnt;
- std::vector<uint32_t> cmd_event_wake_cnt;
- std::vector<uint32_t> driver_fw_local_wake_cnt;
+ WLAN_DRIVER_WAKE_REASON_CNT wake_reason_cnt;
+ std::vector<uint32_t> cmd_event_wake_cnt;
+ std::vector<uint32_t> driver_fw_local_wake_cnt;
};
// NAN response and event callbacks struct.
struct NanCallbackHandlers {
- // NotifyResponse invoked to notify the status of the Request.
- std::function<void(transaction_id, const NanResponseMsg&)> on_notify_response;
- // Various event callbacks.
- std::function<void(const NanPublishTerminatedInd&)>
- on_event_publish_terminated;
- std::function<void(const NanMatchInd&)> on_event_match;
- std::function<void(const NanMatchExpiredInd&)> on_event_match_expired;
- std::function<void(const NanSubscribeTerminatedInd&)>
- on_event_subscribe_terminated;
- std::function<void(const NanFollowupInd&)> on_event_followup;
- std::function<void(const NanDiscEngEventInd&)> on_event_disc_eng_event;
- std::function<void(const NanDisabledInd&)> on_event_disabled;
- std::function<void(const NanTCAInd&)> on_event_tca;
- std::function<void(const NanBeaconSdfPayloadInd&)>
- on_event_beacon_sdf_payload;
- std::function<void(const NanDataPathRequestInd&)> on_event_data_path_request;
- std::function<void(const NanDataPathConfirmInd&)> on_event_data_path_confirm;
- std::function<void(const NanDataPathEndInd&)> on_event_data_path_end;
- std::function<void(const NanTransmitFollowupInd&)>
- on_event_transmit_follow_up;
- std::function<void(const NanRangeRequestInd&)>
- on_event_range_request;
- std::function<void(const NanRangeReportInd&)>
- on_event_range_report;
+ // NotifyResponse invoked to notify the status of the Request.
+ std::function<void(transaction_id, const NanResponseMsg&)>
+ on_notify_response;
+ // Various event callbacks.
+ std::function<void(const NanPublishTerminatedInd&)>
+ on_event_publish_terminated;
+ std::function<void(const NanMatchInd&)> on_event_match;
+ std::function<void(const NanMatchExpiredInd&)> on_event_match_expired;
+ std::function<void(const NanSubscribeTerminatedInd&)>
+ on_event_subscribe_terminated;
+ std::function<void(const NanFollowupInd&)> on_event_followup;
+ std::function<void(const NanDiscEngEventInd&)> on_event_disc_eng_event;
+ std::function<void(const NanDisabledInd&)> on_event_disabled;
+ std::function<void(const NanTCAInd&)> on_event_tca;
+ std::function<void(const NanBeaconSdfPayloadInd&)>
+ on_event_beacon_sdf_payload;
+ std::function<void(const NanDataPathRequestInd&)>
+ on_event_data_path_request;
+ std::function<void(const NanDataPathConfirmInd&)>
+ on_event_data_path_confirm;
+ std::function<void(const NanDataPathEndInd&)> on_event_data_path_end;
+ std::function<void(const NanTransmitFollowupInd&)>
+ on_event_transmit_follow_up;
+ std::function<void(const NanRangeRequestInd&)> on_event_range_request;
+ std::function<void(const NanRangeReportInd&)> on_event_range_report;
};
// Full scan results contain IE info and are hence passed by reference, to
@@ -123,8 +125,7 @@
// Callback for ring buffer data.
using on_ring_buffer_data_callback =
- std::function<void(const std::string&,
- const std::vector<uint8_t>&,
+ std::function<void(const std::string&, const std::vector<uint8_t>&,
const wifi_ring_buffer_status&)>;
// Callback for alerts.
@@ -138,168 +139,218 @@
* object and will be valid for the lifetime of the process.
*/
class WifiLegacyHal {
- public:
- WifiLegacyHal();
- // Names to use for the different types of iface.
- std::string getApIfaceName();
- std::string getNanIfaceName();
- std::string getP2pIfaceName();
- std::string getStaIfaceName();
+ public:
+ WifiLegacyHal();
- // Initialize the legacy HAL function table.
- wifi_error initialize();
- // Start the legacy HAL and the event looper thread.
- wifi_error start();
- // Deinitialize the legacy HAL and wait for the event loop thread to exit
- // using a predefined timeout.
- wifi_error stop(std::unique_lock<std::recursive_mutex>* lock,
- const std::function<void()>& on_complete_callback);
- // Wrappers for all the functions in the legacy HAL function table.
- std::pair<wifi_error, std::string> getDriverVersion();
- std::pair<wifi_error, std::string> getFirmwareVersion();
- std::pair<wifi_error, std::vector<uint8_t>> requestDriverMemoryDump();
- std::pair<wifi_error, std::vector<uint8_t>> requestFirmwareMemoryDump();
- std::pair<wifi_error, uint32_t> getSupportedFeatureSet();
- // APF functions.
- std::pair<wifi_error, PacketFilterCapabilities> getPacketFilterCapabilities();
- wifi_error setPacketFilter(const std::vector<uint8_t>& program);
- // Gscan functions.
- std::pair<wifi_error, wifi_gscan_capabilities> getGscanCapabilities();
- // These API's provides a simplified interface over the legacy Gscan API's:
- // a) All scan events from the legacy HAL API other than the
- // |WIFI_SCAN_FAILED| are treated as notification of results.
- // This method then retrieves the cached scan results from the legacy
- // HAL API and triggers the externally provided |on_results_user_callback|
- // on success.
- // b) |WIFI_SCAN_FAILED| scan event or failure to retrieve cached scan results
- // triggers the externally provided |on_failure_user_callback|.
- // c) Full scan result event triggers the externally provided
- // |on_full_result_user_callback|.
- wifi_error startGscan(
- wifi_request_id id,
- const wifi_scan_cmd_params& params,
- const std::function<void(wifi_request_id)>& on_failure_callback,
- const on_gscan_results_callback& on_results_callback,
- const on_gscan_full_result_callback& on_full_result_callback);
- wifi_error stopGscan(wifi_request_id id);
- std::pair<wifi_error, std::vector<uint32_t>> getValidFrequenciesForBand(
- wifi_band band);
- wifi_error setDfsFlag(bool dfs_on);
- // Link layer stats functions.
- wifi_error enableLinkLayerStats(bool debug);
- wifi_error disableLinkLayerStats();
- std::pair<wifi_error, LinkLayerStats> getLinkLayerStats();
- // RSSI monitor functions.
- wifi_error startRssiMonitoring(wifi_request_id id,
- int8_t max_rssi,
- int8_t min_rssi,
- const on_rssi_threshold_breached_callback&
- on_threshold_breached_callback);
- wifi_error stopRssiMonitoring(wifi_request_id id);
- std::pair<wifi_error, wifi_roaming_capabilities> getRoamingCapabilities();
- wifi_error configureRoaming(const wifi_roaming_config& config);
- wifi_error enableFirmwareRoaming(fw_roaming_state_t state);
- wifi_error configureNdOffload(bool enable);
- wifi_error startSendingOffloadedPacket(
- uint32_t cmd_id,
- const std::vector<uint8_t>& ip_packet_data,
- const std::array<uint8_t, 6>& src_address,
- const std::array<uint8_t, 6>& dst_address,
- uint32_t period_in_ms);
- wifi_error stopSendingOffloadedPacket(uint32_t cmd_id);
- wifi_error setScanningMacOui(const std::array<uint8_t, 3>& oui);
- wifi_error selectTxPowerScenario(wifi_power_scenario scenario);
- wifi_error resetTxPowerScenario();
- // Logger/debug functions.
- std::pair<wifi_error, uint32_t> getLoggerSupportedFeatureSet();
- wifi_error startPktFateMonitoring();
- std::pair<wifi_error, std::vector<wifi_tx_report>> getTxPktFates();
- std::pair<wifi_error, std::vector<wifi_rx_report>> getRxPktFates();
- std::pair<wifi_error, WakeReasonStats> getWakeReasonStats();
- wifi_error registerRingBufferCallbackHandler(
- const on_ring_buffer_data_callback& on_data_callback);
- wifi_error deregisterRingBufferCallbackHandler();
- std::pair<wifi_error, std::vector<wifi_ring_buffer_status>>
- getRingBuffersStatus();
- wifi_error startRingBufferLogging(const std::string& ring_name,
- uint32_t verbose_level,
- uint32_t max_interval_sec,
- uint32_t min_data_size);
- wifi_error getRingBufferData(const std::string& ring_name);
- wifi_error registerErrorAlertCallbackHandler(
- const on_error_alert_callback& on_alert_callback);
- wifi_error deregisterErrorAlertCallbackHandler();
- // RTT functions.
- wifi_error startRttRangeRequest(
- wifi_request_id id,
- const std::vector<wifi_rtt_config>& rtt_configs,
- const on_rtt_results_callback& on_results_callback);
- wifi_error cancelRttRangeRequest(
- wifi_request_id id, const std::vector<std::array<uint8_t, 6>>& mac_addrs);
- std::pair<wifi_error, wifi_rtt_capabilities> getRttCapabilities();
- std::pair<wifi_error, wifi_rtt_responder> getRttResponderInfo();
- wifi_error enableRttResponder(wifi_request_id id,
- const wifi_channel_info& channel_hint,
- uint32_t max_duration_secs,
- const wifi_rtt_responder& info);
- wifi_error disableRttResponder(wifi_request_id id);
- wifi_error setRttLci(wifi_request_id id, const wifi_lci_information& info);
- wifi_error setRttLcr(wifi_request_id id, const wifi_lcr_information& info);
- // NAN functions.
- wifi_error nanRegisterCallbackHandlers(const NanCallbackHandlers& callbacks);
- wifi_error nanEnableRequest(transaction_id id, const NanEnableRequest& msg);
- wifi_error nanDisableRequest(transaction_id id);
- wifi_error nanPublishRequest(transaction_id id, const NanPublishRequest& msg);
- wifi_error nanPublishCancelRequest(transaction_id id,
- const NanPublishCancelRequest& msg);
- wifi_error nanSubscribeRequest(transaction_id id,
- const NanSubscribeRequest& msg);
- wifi_error nanSubscribeCancelRequest(transaction_id id,
- const NanSubscribeCancelRequest& msg);
- wifi_error nanTransmitFollowupRequest(transaction_id id,
- const NanTransmitFollowupRequest& msg);
- wifi_error nanStatsRequest(transaction_id id, const NanStatsRequest& msg);
- wifi_error nanConfigRequest(transaction_id id, const NanConfigRequest& msg);
- wifi_error nanTcaRequest(transaction_id id, const NanTCARequest& msg);
- wifi_error nanBeaconSdfPayloadRequest(transaction_id id,
- const NanBeaconSdfPayloadRequest& msg);
- std::pair<wifi_error, NanVersion> nanGetVersion();
- wifi_error nanGetCapabilities(transaction_id id);
- wifi_error nanDataInterfaceCreate(transaction_id id,
- const std::string& iface_name);
- wifi_error nanDataInterfaceDelete(transaction_id id,
- const std::string& iface_name);
- wifi_error nanDataRequestInitiator(transaction_id id,
- const NanDataPathInitiatorRequest& msg);
- wifi_error nanDataIndicationResponse(
- transaction_id id, const NanDataPathIndicationResponse& msg);
- wifi_error nanDataEnd(transaction_id id, uint32_t ndpInstanceId);
- // AP functions.
- wifi_error setCountryCode(std::array<int8_t, 2> code);
+ // Initialize the legacy HAL function table.
+ wifi_error initialize();
+ // Start the legacy HAL and the event looper thread.
+ wifi_error start();
+ // Deinitialize the legacy HAL and wait for the event loop thread to exit
+ // using a predefined timeout.
+ wifi_error stop(std::unique_lock<std::recursive_mutex>* lock,
+ const std::function<void()>& on_complete_callback);
+ // Wrappers for all the functions in the legacy HAL function table.
+ std::pair<wifi_error, std::string> getDriverVersion(
+ const std::string& iface_name);
+ std::pair<wifi_error, std::string> getFirmwareVersion(
+ const std::string& iface_name);
+ std::pair<wifi_error, std::vector<uint8_t>> requestDriverMemoryDump(
+ const std::string& iface_name);
+ std::pair<wifi_error, std::vector<uint8_t>> requestFirmwareMemoryDump(
+ const std::string& iface_name);
+ std::pair<wifi_error, uint32_t> getSupportedFeatureSet(
+ const std::string& iface_name);
+ // APF functions.
+ std::pair<wifi_error, PacketFilterCapabilities> getPacketFilterCapabilities(
+ const std::string& iface_name);
+ wifi_error setPacketFilter(const std::string& iface_name,
+ const std::vector<uint8_t>& program);
+ // Gscan functions.
+ std::pair<wifi_error, wifi_gscan_capabilities> getGscanCapabilities(
+ const std::string& iface_name);
+ // These API's provides a simplified interface over the legacy Gscan API's:
+ // a) All scan events from the legacy HAL API other than the
+ // |WIFI_SCAN_FAILED| are treated as notification of results.
+ // This method then retrieves the cached scan results from the legacy
+ // HAL API and triggers the externally provided
+ // |on_results_user_callback| on success.
+ // b) |WIFI_SCAN_FAILED| scan event or failure to retrieve cached scan
+ // results
+ // triggers the externally provided |on_failure_user_callback|.
+ // c) Full scan result event triggers the externally provided
+ // |on_full_result_user_callback|.
+ wifi_error startGscan(
+ const std::string& iface_name, wifi_request_id id,
+ const wifi_scan_cmd_params& params,
+ const std::function<void(wifi_request_id)>& on_failure_callback,
+ const on_gscan_results_callback& on_results_callback,
+ const on_gscan_full_result_callback& on_full_result_callback);
+ wifi_error stopGscan(const std::string& iface_name, wifi_request_id id);
+ std::pair<wifi_error, std::vector<uint32_t>> getValidFrequenciesForBand(
+ const std::string& iface_name, wifi_band band);
+ wifi_error setDfsFlag(const std::string& iface_name, bool dfs_on);
+ // Link layer stats functions.
+ wifi_error enableLinkLayerStats(const std::string& iface_name, bool debug);
+ wifi_error disableLinkLayerStats(const std::string& iface_name);
+ std::pair<wifi_error, LinkLayerStats> getLinkLayerStats(
+ const std::string& iface_name);
+ // RSSI monitor functions.
+ wifi_error startRssiMonitoring(const std::string& iface_name,
+ wifi_request_id id, int8_t max_rssi,
+ int8_t min_rssi,
+ const on_rssi_threshold_breached_callback&
+ on_threshold_breached_callback);
+ wifi_error stopRssiMonitoring(const std::string& iface_name,
+ wifi_request_id id);
+ std::pair<wifi_error, wifi_roaming_capabilities> getRoamingCapabilities(
+ const std::string& iface_name);
+ wifi_error configureRoaming(const std::string& iface_name,
+ const wifi_roaming_config& config);
+ wifi_error enableFirmwareRoaming(const std::string& iface_name,
+ fw_roaming_state_t state);
+ wifi_error configureNdOffload(const std::string& iface_name, bool enable);
+ wifi_error startSendingOffloadedPacket(
+ const std::string& iface_name, uint32_t cmd_id,
+ const std::vector<uint8_t>& ip_packet_data,
+ const std::array<uint8_t, 6>& src_address,
+ const std::array<uint8_t, 6>& dst_address, uint32_t period_in_ms);
+ wifi_error stopSendingOffloadedPacket(const std::string& iface_name,
+ uint32_t cmd_id);
+ wifi_error setScanningMacOui(const std::string& iface_name,
+ const std::array<uint8_t, 3>& oui);
+ wifi_error selectTxPowerScenario(const std::string& iface_name,
+ wifi_power_scenario scenario);
+ wifi_error resetTxPowerScenario(const std::string& iface_name);
+ // Logger/debug functions.
+ std::pair<wifi_error, uint32_t> getLoggerSupportedFeatureSet(
+ const std::string& iface_name);
+ wifi_error startPktFateMonitoring(const std::string& iface_name);
+ std::pair<wifi_error, std::vector<wifi_tx_report>> getTxPktFates(
+ const std::string& iface_name);
+ std::pair<wifi_error, std::vector<wifi_rx_report>> getRxPktFates(
+ const std::string& iface_name);
+ std::pair<wifi_error, WakeReasonStats> getWakeReasonStats(
+ const std::string& iface_name);
+ wifi_error registerRingBufferCallbackHandler(
+ const std::string& iface_name,
+ const on_ring_buffer_data_callback& on_data_callback);
+ wifi_error deregisterRingBufferCallbackHandler(
+ const std::string& iface_name);
+ std::pair<wifi_error, std::vector<wifi_ring_buffer_status>>
+ getRingBuffersStatus(const std::string& iface_name);
+ wifi_error startRingBufferLogging(const std::string& iface_name,
+ const std::string& ring_name,
+ uint32_t verbose_level,
+ uint32_t max_interval_sec,
+ uint32_t min_data_size);
+ wifi_error getRingBufferData(const std::string& iface_name,
+ const std::string& ring_name);
+ wifi_error registerErrorAlertCallbackHandler(
+ const std::string& iface_name,
+ const on_error_alert_callback& on_alert_callback);
+ wifi_error deregisterErrorAlertCallbackHandler(
+ const std::string& iface_name);
+ // RTT functions.
+ wifi_error startRttRangeRequest(
+ const std::string& iface_name, wifi_request_id id,
+ const std::vector<wifi_rtt_config>& rtt_configs,
+ const on_rtt_results_callback& on_results_callback);
+ wifi_error cancelRttRangeRequest(
+ const std::string& iface_name, wifi_request_id id,
+ const std::vector<std::array<uint8_t, 6>>& mac_addrs);
+ std::pair<wifi_error, wifi_rtt_capabilities> getRttCapabilities(
+ const std::string& iface_name);
+ std::pair<wifi_error, wifi_rtt_responder> getRttResponderInfo(
+ const std::string& iface_name);
+ wifi_error enableRttResponder(const std::string& iface_name,
+ wifi_request_id id,
+ const wifi_channel_info& channel_hint,
+ uint32_t max_duration_secs,
+ const wifi_rtt_responder& info);
+ wifi_error disableRttResponder(const std::string& iface_name,
+ wifi_request_id id);
+ wifi_error setRttLci(const std::string& iface_name, wifi_request_id id,
+ const wifi_lci_information& info);
+ wifi_error setRttLcr(const std::string& iface_name, wifi_request_id id,
+ const wifi_lcr_information& info);
+ // NAN functions.
+ wifi_error nanRegisterCallbackHandlers(
+ const std::string& iface_name, const NanCallbackHandlers& callbacks);
+ wifi_error nanEnableRequest(const std::string& iface_name,
+ transaction_id id, const NanEnableRequest& msg);
+ wifi_error nanDisableRequest(const std::string& iface_name,
+ transaction_id id);
+ wifi_error nanPublishRequest(const std::string& iface_name,
+ transaction_id id,
+ const NanPublishRequest& msg);
+ wifi_error nanPublishCancelRequest(const std::string& iface_name,
+ transaction_id id,
+ const NanPublishCancelRequest& msg);
+ wifi_error nanSubscribeRequest(const std::string& iface_name,
+ transaction_id id,
+ const NanSubscribeRequest& msg);
+ wifi_error nanSubscribeCancelRequest(const std::string& iface_name,
+ transaction_id id,
+ const NanSubscribeCancelRequest& msg);
+ wifi_error nanTransmitFollowupRequest(
+ const std::string& iface_name, transaction_id id,
+ const NanTransmitFollowupRequest& msg);
+ wifi_error nanStatsRequest(const std::string& iface_name, transaction_id id,
+ const NanStatsRequest& msg);
+ wifi_error nanConfigRequest(const std::string& iface_name,
+ transaction_id id, const NanConfigRequest& msg);
+ wifi_error nanTcaRequest(const std::string& iface_name, transaction_id id,
+ const NanTCARequest& msg);
+ wifi_error nanBeaconSdfPayloadRequest(
+ const std::string& iface_name, transaction_id id,
+ const NanBeaconSdfPayloadRequest& msg);
+ std::pair<wifi_error, NanVersion> nanGetVersion();
+ wifi_error nanGetCapabilities(const std::string& iface_name,
+ transaction_id id);
+ wifi_error nanDataInterfaceCreate(const std::string& iface_name,
+ transaction_id id,
+ const std::string& data_iface_name);
+ wifi_error nanDataInterfaceDelete(const std::string& iface_name,
+ transaction_id id,
+ const std::string& data_iface_name);
+ wifi_error nanDataRequestInitiator(const std::string& iface_name,
+ transaction_id id,
+ const NanDataPathInitiatorRequest& msg);
+ wifi_error nanDataIndicationResponse(
+ const std::string& iface_name, transaction_id id,
+ const NanDataPathIndicationResponse& msg);
+ wifi_error nanDataEnd(const std::string& iface_name, transaction_id id,
+ uint32_t ndpInstanceId);
+ // AP functions.
+ wifi_error setCountryCode(const std::string& iface_name,
+ std::array<int8_t, 2> code);
- private:
- // Retrieve the interface handle to be used for the "wlan" interface.
- wifi_error retrieveWlanInterfaceHandle();
- // Run the legacy HAL event loop thread.
- void runEventLoop();
- // Retrieve the cached gscan results to pass the results back to the external
- // callbacks.
- std::pair<wifi_error, std::vector<wifi_cached_scan_results>>
- getGscanCachedResults();
- void invalidate();
+ private:
+ // Retrieve interface handles for all the available interfaces.
+ wifi_error retrieveIfaceHandles();
+ wifi_interface_handle getIfaceHandle(const std::string& iface_name);
+ // Run the legacy HAL event loop thread.
+ void runEventLoop();
+ // Retrieve the cached gscan results to pass the results back to the
+ // external callbacks.
+ std::pair<wifi_error, std::vector<wifi_cached_scan_results>>
+ getGscanCachedResults(const std::string& iface_name);
+ void invalidate();
- // Global function table of legacy HAL.
- wifi_hal_fn global_func_table_;
- // Opaque handle to be used for all global operations.
- wifi_handle global_handle_;
- // Opaque handle to be used for all wlan0 interface specific operations.
- wifi_interface_handle wlan_interface_handle_;
- // Flag to indicate if we have initiated the cleanup of legacy HAL.
- std::atomic<bool> awaiting_event_loop_termination_;
- std::condition_variable_any stop_wait_cv_;
- // Flag to indicate if the legacy HAL has been started.
- bool is_started_;
- wifi_system::InterfaceTool iface_tool_;
+ // Global function table of legacy HAL.
+ wifi_hal_fn global_func_table_;
+ // Opaque handle to be used for all global operations.
+ wifi_handle global_handle_;
+ // Map of interface name to handle that is to be used for all interface
+ // specific operations.
+ std::map<std::string, wifi_interface_handle> iface_name_to_handle_;
+ // Flag to indicate if we have initiated the cleanup of legacy HAL.
+ std::atomic<bool> awaiting_event_loop_termination_;
+ std::condition_variable_any stop_wait_cv_;
+ // Flag to indicate if the legacy HAL has been started.
+ bool is_started_;
+ wifi_system::InterfaceTool iface_tool_;
};
} // namespace legacy_hal
diff --git a/wifi/1.2/default/wifi_legacy_hal_stubs.cpp b/wifi/1.2/default/wifi_legacy_hal_stubs.cpp
index 48fce6d..28972cb 100644
--- a/wifi/1.2/default/wifi_legacy_hal_stubs.cpp
+++ b/wifi/1.2/default/wifi_legacy_hal_stubs.cpp
@@ -28,113 +28,113 @@
template <typename R, typename... Args>
struct stubFunction<R (*)(Args...)> {
- static constexpr R invoke(Args...) { return WIFI_ERROR_NOT_SUPPORTED; }
+ static constexpr R invoke(Args...) { return WIFI_ERROR_NOT_SUPPORTED; }
};
template <typename... Args>
struct stubFunction<void (*)(Args...)> {
- static constexpr void invoke(Args...) {}
+ static constexpr void invoke(Args...) {}
};
template <typename T>
void populateStubFor(T* val) {
- *val = &stubFunction<T>::invoke;
+ *val = &stubFunction<T>::invoke;
}
bool initHalFuncTableWithStubs(wifi_hal_fn* hal_fn) {
- if (hal_fn == nullptr) {
- return false;
- }
- populateStubFor(&hal_fn->wifi_initialize);
- populateStubFor(&hal_fn->wifi_cleanup);
- populateStubFor(&hal_fn->wifi_event_loop);
- populateStubFor(&hal_fn->wifi_get_error_info);
- populateStubFor(&hal_fn->wifi_get_supported_feature_set);
- populateStubFor(&hal_fn->wifi_get_concurrency_matrix);
- populateStubFor(&hal_fn->wifi_set_scanning_mac_oui);
- populateStubFor(&hal_fn->wifi_get_supported_channels);
- populateStubFor(&hal_fn->wifi_is_epr_supported);
- populateStubFor(&hal_fn->wifi_get_ifaces);
- populateStubFor(&hal_fn->wifi_get_iface_name);
- populateStubFor(&hal_fn->wifi_set_iface_event_handler);
- populateStubFor(&hal_fn->wifi_reset_iface_event_handler);
- populateStubFor(&hal_fn->wifi_start_gscan);
- populateStubFor(&hal_fn->wifi_stop_gscan);
- populateStubFor(&hal_fn->wifi_get_cached_gscan_results);
- populateStubFor(&hal_fn->wifi_set_bssid_hotlist);
- populateStubFor(&hal_fn->wifi_reset_bssid_hotlist);
- populateStubFor(&hal_fn->wifi_set_significant_change_handler);
- populateStubFor(&hal_fn->wifi_reset_significant_change_handler);
- populateStubFor(&hal_fn->wifi_get_gscan_capabilities);
- populateStubFor(&hal_fn->wifi_set_link_stats);
- populateStubFor(&hal_fn->wifi_get_link_stats);
- populateStubFor(&hal_fn->wifi_clear_link_stats);
- populateStubFor(&hal_fn->wifi_get_valid_channels);
- populateStubFor(&hal_fn->wifi_rtt_range_request);
- populateStubFor(&hal_fn->wifi_rtt_range_cancel);
- populateStubFor(&hal_fn->wifi_get_rtt_capabilities);
- populateStubFor(&hal_fn->wifi_rtt_get_responder_info);
- populateStubFor(&hal_fn->wifi_enable_responder);
- populateStubFor(&hal_fn->wifi_disable_responder);
- populateStubFor(&hal_fn->wifi_set_nodfs_flag);
- populateStubFor(&hal_fn->wifi_start_logging);
- populateStubFor(&hal_fn->wifi_set_epno_list);
- populateStubFor(&hal_fn->wifi_reset_epno_list);
- populateStubFor(&hal_fn->wifi_set_country_code);
- populateStubFor(&hal_fn->wifi_get_firmware_memory_dump);
- populateStubFor(&hal_fn->wifi_set_log_handler);
- populateStubFor(&hal_fn->wifi_reset_log_handler);
- populateStubFor(&hal_fn->wifi_set_alert_handler);
- populateStubFor(&hal_fn->wifi_reset_alert_handler);
- populateStubFor(&hal_fn->wifi_get_firmware_version);
- populateStubFor(&hal_fn->wifi_get_ring_buffers_status);
- populateStubFor(&hal_fn->wifi_get_logger_supported_feature_set);
- populateStubFor(&hal_fn->wifi_get_ring_data);
- populateStubFor(&hal_fn->wifi_enable_tdls);
- populateStubFor(&hal_fn->wifi_disable_tdls);
- populateStubFor(&hal_fn->wifi_get_tdls_status);
- populateStubFor(&hal_fn->wifi_get_tdls_capabilities);
- populateStubFor(&hal_fn->wifi_get_driver_version);
- populateStubFor(&hal_fn->wifi_set_passpoint_list);
- populateStubFor(&hal_fn->wifi_reset_passpoint_list);
- populateStubFor(&hal_fn->wifi_set_lci);
- populateStubFor(&hal_fn->wifi_set_lcr);
- populateStubFor(&hal_fn->wifi_start_sending_offloaded_packet);
- populateStubFor(&hal_fn->wifi_stop_sending_offloaded_packet);
- populateStubFor(&hal_fn->wifi_start_rssi_monitoring);
- populateStubFor(&hal_fn->wifi_stop_rssi_monitoring);
- populateStubFor(&hal_fn->wifi_get_wake_reason_stats);
- populateStubFor(&hal_fn->wifi_configure_nd_offload);
- populateStubFor(&hal_fn->wifi_get_driver_memory_dump);
- populateStubFor(&hal_fn->wifi_start_pkt_fate_monitoring);
- populateStubFor(&hal_fn->wifi_get_tx_pkt_fates);
- populateStubFor(&hal_fn->wifi_get_rx_pkt_fates);
- populateStubFor(&hal_fn->wifi_nan_enable_request);
- populateStubFor(&hal_fn->wifi_nan_disable_request);
- populateStubFor(&hal_fn->wifi_nan_publish_request);
- populateStubFor(&hal_fn->wifi_nan_publish_cancel_request);
- populateStubFor(&hal_fn->wifi_nan_subscribe_request);
- populateStubFor(&hal_fn->wifi_nan_subscribe_cancel_request);
- populateStubFor(&hal_fn->wifi_nan_transmit_followup_request);
- populateStubFor(&hal_fn->wifi_nan_stats_request);
- populateStubFor(&hal_fn->wifi_nan_config_request);
- populateStubFor(&hal_fn->wifi_nan_tca_request);
- populateStubFor(&hal_fn->wifi_nan_beacon_sdf_payload_request);
- populateStubFor(&hal_fn->wifi_nan_register_handler);
- populateStubFor(&hal_fn->wifi_nan_get_version);
- populateStubFor(&hal_fn->wifi_nan_get_capabilities);
- populateStubFor(&hal_fn->wifi_nan_data_interface_create);
- populateStubFor(&hal_fn->wifi_nan_data_interface_delete);
- populateStubFor(&hal_fn->wifi_nan_data_request_initiator);
- populateStubFor(&hal_fn->wifi_nan_data_indication_response);
- populateStubFor(&hal_fn->wifi_nan_data_end);
- populateStubFor(&hal_fn->wifi_get_packet_filter_capabilities);
- populateStubFor(&hal_fn->wifi_set_packet_filter);
- populateStubFor(&hal_fn->wifi_get_roaming_capabilities);
- populateStubFor(&hal_fn->wifi_enable_firmware_roaming);
- populateStubFor(&hal_fn->wifi_configure_roaming);
- populateStubFor(&hal_fn->wifi_select_tx_power_scenario);
- populateStubFor(&hal_fn->wifi_reset_tx_power_scenario);
- return true;
+ if (hal_fn == nullptr) {
+ return false;
+ }
+ populateStubFor(&hal_fn->wifi_initialize);
+ populateStubFor(&hal_fn->wifi_cleanup);
+ populateStubFor(&hal_fn->wifi_event_loop);
+ populateStubFor(&hal_fn->wifi_get_error_info);
+ populateStubFor(&hal_fn->wifi_get_supported_feature_set);
+ populateStubFor(&hal_fn->wifi_get_concurrency_matrix);
+ populateStubFor(&hal_fn->wifi_set_scanning_mac_oui);
+ populateStubFor(&hal_fn->wifi_get_supported_channels);
+ populateStubFor(&hal_fn->wifi_is_epr_supported);
+ populateStubFor(&hal_fn->wifi_get_ifaces);
+ populateStubFor(&hal_fn->wifi_get_iface_name);
+ populateStubFor(&hal_fn->wifi_set_iface_event_handler);
+ populateStubFor(&hal_fn->wifi_reset_iface_event_handler);
+ populateStubFor(&hal_fn->wifi_start_gscan);
+ populateStubFor(&hal_fn->wifi_stop_gscan);
+ populateStubFor(&hal_fn->wifi_get_cached_gscan_results);
+ populateStubFor(&hal_fn->wifi_set_bssid_hotlist);
+ populateStubFor(&hal_fn->wifi_reset_bssid_hotlist);
+ populateStubFor(&hal_fn->wifi_set_significant_change_handler);
+ populateStubFor(&hal_fn->wifi_reset_significant_change_handler);
+ populateStubFor(&hal_fn->wifi_get_gscan_capabilities);
+ populateStubFor(&hal_fn->wifi_set_link_stats);
+ populateStubFor(&hal_fn->wifi_get_link_stats);
+ populateStubFor(&hal_fn->wifi_clear_link_stats);
+ populateStubFor(&hal_fn->wifi_get_valid_channels);
+ populateStubFor(&hal_fn->wifi_rtt_range_request);
+ populateStubFor(&hal_fn->wifi_rtt_range_cancel);
+ populateStubFor(&hal_fn->wifi_get_rtt_capabilities);
+ populateStubFor(&hal_fn->wifi_rtt_get_responder_info);
+ populateStubFor(&hal_fn->wifi_enable_responder);
+ populateStubFor(&hal_fn->wifi_disable_responder);
+ populateStubFor(&hal_fn->wifi_set_nodfs_flag);
+ populateStubFor(&hal_fn->wifi_start_logging);
+ populateStubFor(&hal_fn->wifi_set_epno_list);
+ populateStubFor(&hal_fn->wifi_reset_epno_list);
+ populateStubFor(&hal_fn->wifi_set_country_code);
+ populateStubFor(&hal_fn->wifi_get_firmware_memory_dump);
+ populateStubFor(&hal_fn->wifi_set_log_handler);
+ populateStubFor(&hal_fn->wifi_reset_log_handler);
+ populateStubFor(&hal_fn->wifi_set_alert_handler);
+ populateStubFor(&hal_fn->wifi_reset_alert_handler);
+ populateStubFor(&hal_fn->wifi_get_firmware_version);
+ populateStubFor(&hal_fn->wifi_get_ring_buffers_status);
+ populateStubFor(&hal_fn->wifi_get_logger_supported_feature_set);
+ populateStubFor(&hal_fn->wifi_get_ring_data);
+ populateStubFor(&hal_fn->wifi_enable_tdls);
+ populateStubFor(&hal_fn->wifi_disable_tdls);
+ populateStubFor(&hal_fn->wifi_get_tdls_status);
+ populateStubFor(&hal_fn->wifi_get_tdls_capabilities);
+ populateStubFor(&hal_fn->wifi_get_driver_version);
+ populateStubFor(&hal_fn->wifi_set_passpoint_list);
+ populateStubFor(&hal_fn->wifi_reset_passpoint_list);
+ populateStubFor(&hal_fn->wifi_set_lci);
+ populateStubFor(&hal_fn->wifi_set_lcr);
+ populateStubFor(&hal_fn->wifi_start_sending_offloaded_packet);
+ populateStubFor(&hal_fn->wifi_stop_sending_offloaded_packet);
+ populateStubFor(&hal_fn->wifi_start_rssi_monitoring);
+ populateStubFor(&hal_fn->wifi_stop_rssi_monitoring);
+ populateStubFor(&hal_fn->wifi_get_wake_reason_stats);
+ populateStubFor(&hal_fn->wifi_configure_nd_offload);
+ populateStubFor(&hal_fn->wifi_get_driver_memory_dump);
+ populateStubFor(&hal_fn->wifi_start_pkt_fate_monitoring);
+ populateStubFor(&hal_fn->wifi_get_tx_pkt_fates);
+ populateStubFor(&hal_fn->wifi_get_rx_pkt_fates);
+ populateStubFor(&hal_fn->wifi_nan_enable_request);
+ populateStubFor(&hal_fn->wifi_nan_disable_request);
+ populateStubFor(&hal_fn->wifi_nan_publish_request);
+ populateStubFor(&hal_fn->wifi_nan_publish_cancel_request);
+ populateStubFor(&hal_fn->wifi_nan_subscribe_request);
+ populateStubFor(&hal_fn->wifi_nan_subscribe_cancel_request);
+ populateStubFor(&hal_fn->wifi_nan_transmit_followup_request);
+ populateStubFor(&hal_fn->wifi_nan_stats_request);
+ populateStubFor(&hal_fn->wifi_nan_config_request);
+ populateStubFor(&hal_fn->wifi_nan_tca_request);
+ populateStubFor(&hal_fn->wifi_nan_beacon_sdf_payload_request);
+ populateStubFor(&hal_fn->wifi_nan_register_handler);
+ populateStubFor(&hal_fn->wifi_nan_get_version);
+ populateStubFor(&hal_fn->wifi_nan_get_capabilities);
+ populateStubFor(&hal_fn->wifi_nan_data_interface_create);
+ populateStubFor(&hal_fn->wifi_nan_data_interface_delete);
+ populateStubFor(&hal_fn->wifi_nan_data_request_initiator);
+ populateStubFor(&hal_fn->wifi_nan_data_indication_response);
+ populateStubFor(&hal_fn->wifi_nan_data_end);
+ populateStubFor(&hal_fn->wifi_get_packet_filter_capabilities);
+ populateStubFor(&hal_fn->wifi_set_packet_filter);
+ populateStubFor(&hal_fn->wifi_get_roaming_capabilities);
+ populateStubFor(&hal_fn->wifi_enable_firmware_roaming);
+ populateStubFor(&hal_fn->wifi_configure_roaming);
+ populateStubFor(&hal_fn->wifi_select_tx_power_scenario);
+ populateStubFor(&hal_fn->wifi_reset_tx_power_scenario);
+ return true;
}
} // namespace legacy_hal
} // namespace implementation
diff --git a/wifi/1.2/default/wifi_mode_controller.cpp b/wifi/1.2/default/wifi_mode_controller.cpp
index 6d184ca..8a89e81 100644
--- a/wifi/1.2/default/wifi_mode_controller.cpp
+++ b/wifi/1.2/default/wifi_mode_controller.cpp
@@ -25,25 +25,25 @@
namespace {
int convertIfaceTypeToFirmwareMode(IfaceType type) {
- int mode;
- switch (type) {
- case IfaceType::AP:
- mode = DriverTool::kFirmwareModeAp;
- break;
- case IfaceType::P2P:
- mode = DriverTool::kFirmwareModeP2p;
- break;
- case IfaceType::NAN:
- // NAN is exposed in STA mode currently.
- mode = DriverTool::kFirmwareModeSta;
- break;
- case IfaceType::STA:
- mode = DriverTool::kFirmwareModeSta;
- break;
- }
- return mode;
+ int mode;
+ switch (type) {
+ case IfaceType::AP:
+ mode = DriverTool::kFirmwareModeAp;
+ break;
+ case IfaceType::P2P:
+ mode = DriverTool::kFirmwareModeP2p;
+ break;
+ case IfaceType::NAN:
+ // NAN is exposed in STA mode currently.
+ mode = DriverTool::kFirmwareModeSta;
+ break;
+ case IfaceType::STA:
+ mode = DriverTool::kFirmwareModeSta;
+ break;
+ }
+ return mode;
}
-}
+} // namespace
namespace android {
namespace hardware {
@@ -55,28 +55,29 @@
WifiModeController::WifiModeController() : driver_tool_(new DriverTool) {}
bool WifiModeController::isFirmwareModeChangeNeeded(IfaceType type) {
- return driver_tool_->IsFirmwareModeChangeNeeded(
- convertIfaceTypeToFirmwareMode(type));
+ return driver_tool_->IsFirmwareModeChangeNeeded(
+ convertIfaceTypeToFirmwareMode(type));
}
bool WifiModeController::changeFirmwareMode(IfaceType type) {
- if (!driver_tool_->LoadDriver()) {
- LOG(ERROR) << "Failed to load WiFi driver";
- return false;
- }
- if (!driver_tool_->ChangeFirmwareMode(convertIfaceTypeToFirmwareMode(type))) {
- LOG(ERROR) << "Failed to change firmware mode";
- return false;
- }
- return true;
+ if (!driver_tool_->LoadDriver()) {
+ LOG(ERROR) << "Failed to load WiFi driver";
+ return false;
+ }
+ if (!driver_tool_->ChangeFirmwareMode(
+ convertIfaceTypeToFirmwareMode(type))) {
+ LOG(ERROR) << "Failed to change firmware mode";
+ return false;
+ }
+ return true;
}
bool WifiModeController::deinitialize() {
- if (!driver_tool_->UnloadDriver()) {
- LOG(ERROR) << "Failed to unload WiFi driver";
- return false;
- }
- return true;
+ if (!driver_tool_->UnloadDriver()) {
+ LOG(ERROR) << "Failed to unload WiFi driver";
+ return false;
+ }
+ return true;
}
} // namespace mode_controller
} // namespace implementation
diff --git a/wifi/1.2/default/wifi_mode_controller.h b/wifi/1.2/default/wifi_mode_controller.h
index 5619f67..839bf9e 100644
--- a/wifi/1.2/default/wifi_mode_controller.h
+++ b/wifi/1.2/default/wifi_mode_controller.h
@@ -35,20 +35,20 @@
* required state (essentially a wrapper over DriverTool).
*/
class WifiModeController {
- public:
- WifiModeController();
+ public:
+ WifiModeController();
- // Checks if a firmware mode change is necessary to support the specified
- // iface type operations.
- bool isFirmwareModeChangeNeeded(IfaceType type);
- // Change the firmware mode to support the specified iface type operations.
- bool changeFirmwareMode(IfaceType type);
- // Unload the driver. This should be invoked whenever |IWifi.stop()| is
- // invoked.
- bool deinitialize();
+ // Checks if a firmware mode change is necessary to support the specified
+ // iface type operations.
+ bool isFirmwareModeChangeNeeded(IfaceType type);
+ // Change the firmware mode to support the specified iface type operations.
+ bool changeFirmwareMode(IfaceType type);
+ // Unload the driver. This should be invoked whenever |IWifi.stop()| is
+ // invoked.
+ bool deinitialize();
- private:
- std::unique_ptr<wifi_hal::DriverTool> driver_tool_;
+ private:
+ std::unique_ptr<wifi_hal::DriverTool> driver_tool_;
};
} // namespace mode_controller
diff --git a/wifi/1.2/default/wifi_nan_iface.cpp b/wifi/1.2/default/wifi_nan_iface.cpp
index 93b8902..1d786e3 100644
--- a/wifi/1.2/default/wifi_nan_iface.cpp
+++ b/wifi/1.2/default/wifi_nan_iface.cpp
@@ -32,734 +32,745 @@
const std::string& ifname,
const std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal)
: ifname_(ifname), legacy_hal_(legacy_hal), is_valid_(true) {
- // Register all the callbacks here. these should be valid for the lifetime
- // of the object. Whenever the mode changes legacy HAL will remove
- // all of these callbacks.
- legacy_hal::NanCallbackHandlers callback_handlers;
- android::wp<WifiNanIface> weak_ptr_this(this);
+ // Register all the callbacks here. these should be valid for the lifetime
+ // of the object. Whenever the mode changes legacy HAL will remove
+ // all of these callbacks.
+ legacy_hal::NanCallbackHandlers callback_handlers;
+ android::wp<WifiNanIface> weak_ptr_this(this);
- // Callback for response.
- callback_handlers.on_notify_response = [weak_ptr_this](
- legacy_hal::transaction_id id, const legacy_hal::NanResponseMsg& msg) {
- const auto shared_ptr_this = weak_ptr_this.promote();
- if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
- LOG(ERROR) << "Callback invoked on an invalid object";
- return;
- }
- WifiNanStatus wifiNanStatus;
- if (!hidl_struct_util::convertLegacyNanResponseHeaderToHidl(msg,
- &wifiNanStatus)) {
- LOG(ERROR) << "Failed to convert nan response header";
- return;
- }
-
- switch (msg.response_type) {
- case legacy_hal::NAN_RESPONSE_ENABLED: {
- for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
- if (!callback->notifyEnableResponse(id, wifiNanStatus).isOk()) {
- LOG(ERROR) << "Failed to invoke the callback";
- }
- }
- break;
- }
- case legacy_hal::NAN_RESPONSE_DISABLED: {
- for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
- if (!callback->notifyDisableResponse(id, wifiNanStatus).isOk()) {
- LOG(ERROR) << "Failed to invoke the callback";
- }
- }
- break;
- }
- case legacy_hal::NAN_RESPONSE_PUBLISH: {
- for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
- if (!callback->notifyStartPublishResponse(id, wifiNanStatus,
- msg.body.publish_response.publish_id).isOk()) {
- LOG(ERROR) << "Failed to invoke the callback";
- }
- }
- break;
- }
- case legacy_hal::NAN_RESPONSE_PUBLISH_CANCEL: {
- for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
- if (!callback->notifyStopPublishResponse(id, wifiNanStatus).isOk()) {
- LOG(ERROR) << "Failed to invoke the callback";
- }
- }
- break;
- }
- case legacy_hal::NAN_RESPONSE_TRANSMIT_FOLLOWUP: {
- for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
- if (!callback->notifyTransmitFollowupResponse(id, wifiNanStatus).isOk()) {
- LOG(ERROR) << "Failed to invoke the callback";
- }
- }
- break;
- }
- case legacy_hal::NAN_RESPONSE_SUBSCRIBE: {
- for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
- if (!callback->notifyStartSubscribeResponse(id, wifiNanStatus,
- msg.body.subscribe_response.subscribe_id).isOk()) {
- LOG(ERROR) << "Failed to invoke the callback";
- }
- }
- break;
- }
- case legacy_hal::NAN_RESPONSE_SUBSCRIBE_CANCEL: {
- for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
- if (!callback->notifyStopSubscribeResponse(id, wifiNanStatus).isOk()) {
- LOG(ERROR) << "Failed to invoke the callback";
- }
- }
- break;
- }
- case legacy_hal::NAN_RESPONSE_CONFIG: {
- for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
- if (!callback->notifyConfigResponse(id, wifiNanStatus).isOk()) {
- LOG(ERROR) << "Failed to invoke the callback";
- }
- }
- break;
- }
- case legacy_hal::NAN_GET_CAPABILITIES: {
- NanCapabilities hidl_struct;
- if (!hidl_struct_util::convertLegacyNanCapabilitiesResponseToHidl(
- msg.body.nan_capabilities, &hidl_struct)) {
- LOG(ERROR) << "Failed to convert nan capabilities response";
+ // Callback for response.
+ callback_handlers
+ .on_notify_response = [weak_ptr_this](
+ legacy_hal::transaction_id id,
+ const legacy_hal::NanResponseMsg& msg) {
+ const auto shared_ptr_this = weak_ptr_this.promote();
+ if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
+ LOG(ERROR) << "Callback invoked on an invalid object";
return;
}
- for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
- if (!callback->notifyCapabilitiesResponse(id, wifiNanStatus,
- hidl_struct).isOk()) {
- LOG(ERROR) << "Failed to invoke the callback";
- }
+ WifiNanStatus wifiNanStatus;
+ if (!hidl_struct_util::convertLegacyNanResponseHeaderToHidl(
+ msg, &wifiNanStatus)) {
+ LOG(ERROR) << "Failed to convert nan response header";
+ return;
}
- break;
- }
- case legacy_hal::NAN_DP_INTERFACE_CREATE: {
- for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
- if (!callback->notifyCreateDataInterfaceResponse(id, wifiNanStatus).isOk()) {
- LOG(ERROR) << "Failed to invoke the callback";
- }
- }
- break;
- }
- case legacy_hal::NAN_DP_INTERFACE_DELETE: {
- for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
- if (!callback->notifyDeleteDataInterfaceResponse(id, wifiNanStatus).isOk()) {
- LOG(ERROR) << "Failed to invoke the callback";
- }
- }
- break;
- }
- case legacy_hal::NAN_DP_INITIATOR_RESPONSE: {
- for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
- if (!callback->notifyInitiateDataPathResponse(id, wifiNanStatus,
- msg.body.data_request_response.ndp_instance_id).isOk()) {
- LOG(ERROR) << "Failed to invoke the callback";
- }
- }
- break;
- }
- case legacy_hal::NAN_DP_RESPONDER_RESPONSE: {
- for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
- if (!callback->notifyRespondToDataPathIndicationResponse(id, wifiNanStatus).isOk()) {
- LOG(ERROR) << "Failed to invoke the callback";
- }
- }
- break;
- }
- case legacy_hal::NAN_DP_END: {
- for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
- if (!callback->notifyTerminateDataPathResponse(id, wifiNanStatus).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:
- /* fall through */
- case legacy_hal::NAN_RESPONSE_STATS:
- /* fall through */
- case legacy_hal::NAN_RESPONSE_ERROR:
- /* fall through */
- default:
- LOG(ERROR) << "Unknown or unhandled response type: " << msg.response_type;
- return;
- }
- };
- callback_handlers.on_event_disc_eng_event = [weak_ptr_this](
- const legacy_hal::NanDiscEngEventInd& msg) {
- const auto shared_ptr_this = weak_ptr_this.promote();
- if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
- LOG(ERROR) << "Callback invoked on an invalid object";
- return;
- }
- NanClusterEventInd hidl_struct;
- // event types defined identically - hence can be cast
- hidl_struct.eventType = (NanClusterEventType) msg.event_type;
- hidl_struct.addr = msg.data.mac_addr.addr;
-
- for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
- if (!callback->eventClusterEvent(hidl_struct).isOk()) {
- LOG(ERROR) << "Failed to invoke the callback";
- }
- }
- };
-
- callback_handlers.on_event_disabled = [weak_ptr_this](
- const legacy_hal::NanDisabledInd& msg) {
- const auto shared_ptr_this = weak_ptr_this.promote();
- if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
- LOG(ERROR) << "Callback invoked on an invalid object";
- return;
- }
- WifiNanStatus status;
- hidl_struct_util::convertToWifiNanStatus(msg.reason, msg.nan_reason, sizeof(msg.nan_reason),
- &status);
-
- for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
- if (!callback->eventDisabled(status).isOk()) {
- LOG(ERROR) << "Failed to invoke the callback";
- }
- }
- };
-
- callback_handlers.on_event_publish_terminated = [weak_ptr_this](
- const legacy_hal::NanPublishTerminatedInd& msg) {
- const auto shared_ptr_this = weak_ptr_this.promote();
- if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
- LOG(ERROR) << "Callback invoked on an invalid object";
- return;
- }
- WifiNanStatus status;
- hidl_struct_util::convertToWifiNanStatus(msg.reason, msg.nan_reason, sizeof(msg.nan_reason),
- &status);
-
- for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
- if (!callback->eventPublishTerminated(msg.publish_id, status).isOk()) {
- LOG(ERROR) << "Failed to invoke the callback";
- }
- }
- };
-
- callback_handlers.on_event_subscribe_terminated = [weak_ptr_this](
- const legacy_hal::NanSubscribeTerminatedInd& msg) {
- const auto shared_ptr_this = weak_ptr_this.promote();
- if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
- LOG(ERROR) << "Callback invoked on an invalid object";
- return;
- }
- WifiNanStatus status;
- hidl_struct_util::convertToWifiNanStatus(msg.reason, msg.nan_reason, sizeof(msg.nan_reason),
- &status);
-
- for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
- if (!callback->eventSubscribeTerminated(msg.subscribe_id, status).isOk()) {
- LOG(ERROR) << "Failed to invoke the callback";
- }
- }
- };
-
- callback_handlers.on_event_match = [weak_ptr_this](
- const legacy_hal::NanMatchInd& msg) {
- const auto shared_ptr_this = weak_ptr_this.promote();
- if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
- LOG(ERROR) << "Callback invoked on an invalid object";
- return;
- }
- NanMatchInd hidl_struct;
- if (!hidl_struct_util::convertLegacyNanMatchIndToHidl(
- msg, &hidl_struct)) {
- LOG(ERROR) << "Failed to convert nan capabilities response";
- return;
- }
-
- for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
- if (!callback->eventMatch(hidl_struct).isOk()) {
- LOG(ERROR) << "Failed to invoke the callback";
- }
- }
- };
-
- callback_handlers.on_event_match_expired = [weak_ptr_this](
- const legacy_hal::NanMatchExpiredInd& msg) {
- const auto shared_ptr_this = weak_ptr_this.promote();
- if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
- LOG(ERROR) << "Callback invoked on an invalid object";
- return;
- }
- for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
- if (!callback->eventMatchExpired(msg.publish_subscribe_id,
- msg.requestor_instance_id).isOk()) {
- LOG(ERROR) << "Failed to invoke the callback";
- }
- }
- };
-
- callback_handlers.on_event_followup = [weak_ptr_this](
- const legacy_hal::NanFollowupInd& msg) {
- const auto shared_ptr_this = weak_ptr_this.promote();
- if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
- LOG(ERROR) << "Callback invoked on an invalid object";
- return;
- }
- NanFollowupReceivedInd hidl_struct;
- if (!hidl_struct_util::convertLegacyNanFollowupIndToHidl(
- msg, &hidl_struct)) {
- LOG(ERROR) << "Failed to convert nan capabilities response";
- return;
- }
-
- for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
- if (!callback->eventFollowupReceived(hidl_struct).isOk()) {
- LOG(ERROR) << "Failed to invoke the callback";
- }
- }
- };
-
- callback_handlers.on_event_transmit_follow_up = [weak_ptr_this](
- const legacy_hal::NanTransmitFollowupInd& msg) {
- const auto shared_ptr_this = weak_ptr_this.promote();
- if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
- LOG(ERROR) << "Callback invoked on an invalid object";
- return;
- }
- WifiNanStatus status;
- hidl_struct_util::convertToWifiNanStatus(msg.reason, msg.nan_reason, sizeof(msg.nan_reason),
- &status);
-
- for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
- if (!callback->eventTransmitFollowup(msg.id, status).isOk()) {
- LOG(ERROR) << "Failed to invoke the callback";
- }
- }
- };
-
- callback_handlers.on_event_data_path_request = [weak_ptr_this](
- const legacy_hal::NanDataPathRequestInd& msg) {
- const auto shared_ptr_this = weak_ptr_this.promote();
- if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
- LOG(ERROR) << "Callback invoked on an invalid object";
- return;
- }
- NanDataPathRequestInd hidl_struct;
- if (!hidl_struct_util::convertLegacyNanDataPathRequestIndToHidl(
- msg, &hidl_struct)) {
- LOG(ERROR) << "Failed to convert nan capabilities response";
- return;
- }
-
- for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
- if (!callback->eventDataPathRequest(hidl_struct).isOk()) {
- LOG(ERROR) << "Failed to invoke the callback";
- }
- }
- };
-
- callback_handlers.on_event_data_path_confirm = [weak_ptr_this](
- const legacy_hal::NanDataPathConfirmInd& msg) {
- const auto shared_ptr_this = weak_ptr_this.promote();
- if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
- LOG(ERROR) << "Callback invoked on an invalid object";
- return;
- }
- NanDataPathConfirmInd hidl_struct;
- if (!hidl_struct_util::convertLegacyNanDataPathConfirmIndToHidl(
- msg, &hidl_struct)) {
- LOG(ERROR) << "Failed to convert nan capabilities response";
- return;
- }
-
- for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
- if (!callback->eventDataPathConfirm(hidl_struct).isOk()) {
- LOG(ERROR) << "Failed to invoke the callback";
- }
- }
- };
-
- callback_handlers.on_event_data_path_end = [weak_ptr_this](
- const legacy_hal::NanDataPathEndInd& msg) {
- const auto shared_ptr_this = weak_ptr_this.promote();
- if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
- LOG(ERROR) << "Callback invoked on an invalid object";
- return;
- }
- for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
- for (int i = 0; i < msg.num_ndp_instances; ++i) {
- if (!callback->eventDataPathTerminated(msg.ndp_instance_id[i]).isOk()) {
- LOG(ERROR) << "Failed to invoke the callback";
+ switch (msg.response_type) {
+ case legacy_hal::NAN_RESPONSE_ENABLED: {
+ for (const auto& callback :
+ shared_ptr_this->getEventCallbacks()) {
+ if (!callback->notifyEnableResponse(id, wifiNanStatus)
+ .isOk()) {
+ LOG(ERROR) << "Failed to invoke the callback";
+ }
+ }
+ break;
}
+ case legacy_hal::NAN_RESPONSE_DISABLED: {
+ for (const auto& callback :
+ shared_ptr_this->getEventCallbacks()) {
+ if (!callback->notifyDisableResponse(id, wifiNanStatus)
+ .isOk()) {
+ LOG(ERROR) << "Failed to invoke the callback";
+ }
+ }
+ break;
+ }
+ case legacy_hal::NAN_RESPONSE_PUBLISH: {
+ for (const auto& callback :
+ shared_ptr_this->getEventCallbacks()) {
+ if (!callback
+ ->notifyStartPublishResponse(
+ id, wifiNanStatus,
+ msg.body.publish_response.publish_id)
+ .isOk()) {
+ LOG(ERROR) << "Failed to invoke the callback";
+ }
+ }
+ break;
+ }
+ case legacy_hal::NAN_RESPONSE_PUBLISH_CANCEL: {
+ for (const auto& callback :
+ shared_ptr_this->getEventCallbacks()) {
+ if (!callback->notifyStopPublishResponse(id, wifiNanStatus)
+ .isOk()) {
+ LOG(ERROR) << "Failed to invoke the callback";
+ }
+ }
+ break;
+ }
+ case legacy_hal::NAN_RESPONSE_TRANSMIT_FOLLOWUP: {
+ for (const auto& callback :
+ shared_ptr_this->getEventCallbacks()) {
+ if (!callback
+ ->notifyTransmitFollowupResponse(id, wifiNanStatus)
+ .isOk()) {
+ LOG(ERROR) << "Failed to invoke the callback";
+ }
+ }
+ break;
+ }
+ case legacy_hal::NAN_RESPONSE_SUBSCRIBE: {
+ for (const auto& callback :
+ shared_ptr_this->getEventCallbacks()) {
+ if (!callback
+ ->notifyStartSubscribeResponse(
+ id, wifiNanStatus,
+ msg.body.subscribe_response.subscribe_id)
+ .isOk()) {
+ LOG(ERROR) << "Failed to invoke the callback";
+ }
+ }
+ break;
+ }
+ case legacy_hal::NAN_RESPONSE_SUBSCRIBE_CANCEL: {
+ for (const auto& callback :
+ shared_ptr_this->getEventCallbacks()) {
+ if (!callback
+ ->notifyStopSubscribeResponse(id, wifiNanStatus)
+ .isOk()) {
+ LOG(ERROR) << "Failed to invoke the callback";
+ }
+ }
+ break;
+ }
+ case legacy_hal::NAN_RESPONSE_CONFIG: {
+ for (const auto& callback :
+ shared_ptr_this->getEventCallbacks()) {
+ if (!callback->notifyConfigResponse(id, wifiNanStatus)
+ .isOk()) {
+ LOG(ERROR) << "Failed to invoke the callback";
+ }
+ }
+ break;
+ }
+ case legacy_hal::NAN_GET_CAPABILITIES: {
+ NanCapabilities hidl_struct;
+ if (!hidl_struct_util::
+ convertLegacyNanCapabilitiesResponseToHidl(
+ msg.body.nan_capabilities, &hidl_struct)) {
+ LOG(ERROR) << "Failed to convert nan capabilities response";
+ return;
+ }
+ for (const auto& callback :
+ shared_ptr_this->getEventCallbacks()) {
+ if (!callback
+ ->notifyCapabilitiesResponse(id, wifiNanStatus,
+ hidl_struct)
+ .isOk()) {
+ LOG(ERROR) << "Failed to invoke the callback";
+ }
+ }
+ break;
+ }
+ case legacy_hal::NAN_DP_INTERFACE_CREATE: {
+ for (const auto& callback :
+ shared_ptr_this->getEventCallbacks()) {
+ if (!callback
+ ->notifyCreateDataInterfaceResponse(id,
+ wifiNanStatus)
+ .isOk()) {
+ LOG(ERROR) << "Failed to invoke the callback";
+ }
+ }
+ break;
+ }
+ case legacy_hal::NAN_DP_INTERFACE_DELETE: {
+ for (const auto& callback :
+ shared_ptr_this->getEventCallbacks()) {
+ if (!callback
+ ->notifyDeleteDataInterfaceResponse(id,
+ wifiNanStatus)
+ .isOk()) {
+ LOG(ERROR) << "Failed to invoke the callback";
+ }
+ }
+ break;
+ }
+ case legacy_hal::NAN_DP_INITIATOR_RESPONSE: {
+ for (const auto& callback :
+ shared_ptr_this->getEventCallbacks()) {
+ if (!callback
+ ->notifyInitiateDataPathResponse(
+ id, wifiNanStatus,
+ msg.body.data_request_response.ndp_instance_id)
+ .isOk()) {
+ LOG(ERROR) << "Failed to invoke the callback";
+ }
+ }
+ break;
+ }
+ case legacy_hal::NAN_DP_RESPONDER_RESPONSE: {
+ for (const auto& callback :
+ shared_ptr_this->getEventCallbacks()) {
+ if (!callback
+ ->notifyRespondToDataPathIndicationResponse(
+ id, wifiNanStatus)
+ .isOk()) {
+ LOG(ERROR) << "Failed to invoke the callback";
+ }
+ }
+ break;
+ }
+ case legacy_hal::NAN_DP_END: {
+ for (const auto& callback :
+ shared_ptr_this->getEventCallbacks()) {
+ if (!callback
+ ->notifyTerminateDataPathResponse(id,
+ wifiNanStatus)
+ .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:
+ /* fall through */
+ case legacy_hal::NAN_RESPONSE_STATS:
+ /* fall through */
+ case legacy_hal::NAN_RESPONSE_ERROR:
+ /* fall through */
+ default:
+ LOG(ERROR) << "Unknown or unhandled response type: "
+ << msg.response_type;
+ return;
}
- }
- };
+ };
- callback_handlers.on_event_beacon_sdf_payload = [weak_ptr_this](
- const legacy_hal::NanBeaconSdfPayloadInd& /* msg */) {
- LOG(ERROR) << "on_event_beacon_sdf_payload - should not be called";
- };
+ callback_handlers.on_event_disc_eng_event =
+ [weak_ptr_this](const legacy_hal::NanDiscEngEventInd& msg) {
+ const auto shared_ptr_this = weak_ptr_this.promote();
+ if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
+ LOG(ERROR) << "Callback invoked on an invalid object";
+ return;
+ }
+ NanClusterEventInd hidl_struct;
+ // event types defined identically - hence can be cast
+ hidl_struct.eventType = (NanClusterEventType)msg.event_type;
+ hidl_struct.addr = msg.data.mac_addr.addr;
- callback_handlers.on_event_range_request = [weak_ptr_this](
- const legacy_hal::NanRangeRequestInd& /* msg */) {
- LOG(ERROR) << "on_event_range_request - should not be called";
- };
+ for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
+ if (!callback->eventClusterEvent(hidl_struct).isOk()) {
+ LOG(ERROR) << "Failed to invoke the callback";
+ }
+ }
+ };
- callback_handlers.on_event_range_report = [weak_ptr_this](
- const legacy_hal::NanRangeReportInd& /* msg */) {
- LOG(ERROR) << "on_event_range_report - should not be called";
- };
+ callback_handlers.on_event_disabled =
+ [weak_ptr_this](const legacy_hal::NanDisabledInd& msg) {
+ const auto shared_ptr_this = weak_ptr_this.promote();
+ if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
+ LOG(ERROR) << "Callback invoked on an invalid object";
+ return;
+ }
+ WifiNanStatus status;
+ hidl_struct_util::convertToWifiNanStatus(
+ msg.reason, msg.nan_reason, sizeof(msg.nan_reason), &status);
- legacy_hal::wifi_error legacy_status =
- legacy_hal_.lock()->nanRegisterCallbackHandlers(callback_handlers);
- if (legacy_status != legacy_hal::WIFI_SUCCESS) {
- LOG(ERROR) << "Failed to register nan callbacks. Invalidating object";
- invalidate();
- }
+ for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
+ if (!callback->eventDisabled(status).isOk()) {
+ LOG(ERROR) << "Failed to invoke the callback";
+ }
+ }
+ };
+
+ callback_handlers.on_event_publish_terminated =
+ [weak_ptr_this](const legacy_hal::NanPublishTerminatedInd& msg) {
+ const auto shared_ptr_this = weak_ptr_this.promote();
+ if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
+ LOG(ERROR) << "Callback invoked on an invalid object";
+ return;
+ }
+ WifiNanStatus status;
+ hidl_struct_util::convertToWifiNanStatus(
+ msg.reason, msg.nan_reason, sizeof(msg.nan_reason), &status);
+
+ for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
+ if (!callback->eventPublishTerminated(msg.publish_id, status)
+ .isOk()) {
+ LOG(ERROR) << "Failed to invoke the callback";
+ }
+ }
+ };
+
+ callback_handlers.on_event_subscribe_terminated =
+ [weak_ptr_this](const legacy_hal::NanSubscribeTerminatedInd& msg) {
+ const auto shared_ptr_this = weak_ptr_this.promote();
+ if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
+ LOG(ERROR) << "Callback invoked on an invalid object";
+ return;
+ }
+ WifiNanStatus status;
+ hidl_struct_util::convertToWifiNanStatus(
+ msg.reason, msg.nan_reason, sizeof(msg.nan_reason), &status);
+
+ for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
+ if (!callback
+ ->eventSubscribeTerminated(msg.subscribe_id, status)
+ .isOk()) {
+ LOG(ERROR) << "Failed to invoke the callback";
+ }
+ }
+ };
+
+ callback_handlers.on_event_match =
+ [weak_ptr_this](const legacy_hal::NanMatchInd& msg) {
+ const auto shared_ptr_this = weak_ptr_this.promote();
+ if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
+ LOG(ERROR) << "Callback invoked on an invalid object";
+ return;
+ }
+ NanMatchInd hidl_struct;
+ if (!hidl_struct_util::convertLegacyNanMatchIndToHidl(
+ msg, &hidl_struct)) {
+ LOG(ERROR) << "Failed to convert nan capabilities response";
+ return;
+ }
+
+ for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
+ if (!callback->eventMatch(hidl_struct).isOk()) {
+ LOG(ERROR) << "Failed to invoke the callback";
+ }
+ }
+ };
+
+ callback_handlers.on_event_match_expired =
+ [weak_ptr_this](const legacy_hal::NanMatchExpiredInd& msg) {
+ const auto shared_ptr_this = weak_ptr_this.promote();
+ if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
+ LOG(ERROR) << "Callback invoked on an invalid object";
+ return;
+ }
+ for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
+ if (!callback
+ ->eventMatchExpired(msg.publish_subscribe_id,
+ msg.requestor_instance_id)
+ .isOk()) {
+ LOG(ERROR) << "Failed to invoke the callback";
+ }
+ }
+ };
+
+ callback_handlers.on_event_followup =
+ [weak_ptr_this](const legacy_hal::NanFollowupInd& msg) {
+ const auto shared_ptr_this = weak_ptr_this.promote();
+ if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
+ LOG(ERROR) << "Callback invoked on an invalid object";
+ return;
+ }
+ NanFollowupReceivedInd hidl_struct;
+ if (!hidl_struct_util::convertLegacyNanFollowupIndToHidl(
+ msg, &hidl_struct)) {
+ LOG(ERROR) << "Failed to convert nan capabilities response";
+ return;
+ }
+
+ for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
+ if (!callback->eventFollowupReceived(hidl_struct).isOk()) {
+ LOG(ERROR) << "Failed to invoke the callback";
+ }
+ }
+ };
+
+ callback_handlers.on_event_transmit_follow_up =
+ [weak_ptr_this](const legacy_hal::NanTransmitFollowupInd& msg) {
+ const auto shared_ptr_this = weak_ptr_this.promote();
+ if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
+ LOG(ERROR) << "Callback invoked on an invalid object";
+ return;
+ }
+ WifiNanStatus status;
+ hidl_struct_util::convertToWifiNanStatus(
+ msg.reason, msg.nan_reason, sizeof(msg.nan_reason), &status);
+
+ for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
+ if (!callback->eventTransmitFollowup(msg.id, status).isOk()) {
+ LOG(ERROR) << "Failed to invoke the callback";
+ }
+ }
+ };
+
+ callback_handlers.on_event_data_path_request =
+ [weak_ptr_this](const legacy_hal::NanDataPathRequestInd& msg) {
+ const auto shared_ptr_this = weak_ptr_this.promote();
+ if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
+ LOG(ERROR) << "Callback invoked on an invalid object";
+ return;
+ }
+ NanDataPathRequestInd hidl_struct;
+ if (!hidl_struct_util::convertLegacyNanDataPathRequestIndToHidl(
+ msg, &hidl_struct)) {
+ LOG(ERROR) << "Failed to convert nan capabilities response";
+ return;
+ }
+
+ for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
+ if (!callback->eventDataPathRequest(hidl_struct).isOk()) {
+ LOG(ERROR) << "Failed to invoke the callback";
+ }
+ }
+ };
+
+ callback_handlers.on_event_data_path_confirm =
+ [weak_ptr_this](const legacy_hal::NanDataPathConfirmInd& msg) {
+ const auto shared_ptr_this = weak_ptr_this.promote();
+ if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
+ LOG(ERROR) << "Callback invoked on an invalid object";
+ return;
+ }
+ NanDataPathConfirmInd hidl_struct;
+ if (!hidl_struct_util::convertLegacyNanDataPathConfirmIndToHidl(
+ msg, &hidl_struct)) {
+ LOG(ERROR) << "Failed to convert nan capabilities response";
+ return;
+ }
+
+ for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
+ if (!callback->eventDataPathConfirm(hidl_struct).isOk()) {
+ LOG(ERROR) << "Failed to invoke the callback";
+ }
+ }
+ };
+
+ callback_handlers.on_event_data_path_end =
+ [weak_ptr_this](const legacy_hal::NanDataPathEndInd& msg) {
+ const auto shared_ptr_this = weak_ptr_this.promote();
+ if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
+ LOG(ERROR) << "Callback invoked on an invalid object";
+ return;
+ }
+ for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
+ for (int i = 0; i < msg.num_ndp_instances; ++i) {
+ if (!callback
+ ->eventDataPathTerminated(msg.ndp_instance_id[i])
+ .isOk()) {
+ LOG(ERROR) << "Failed to invoke the callback";
+ }
+ }
+ }
+ };
+
+ callback_handlers.on_event_beacon_sdf_payload =
+ [weak_ptr_this](const legacy_hal::NanBeaconSdfPayloadInd& /* msg */) {
+ LOG(ERROR) << "on_event_beacon_sdf_payload - should not be called";
+ };
+
+ callback_handlers.on_event_range_request =
+ [weak_ptr_this](const legacy_hal::NanRangeRequestInd& /* msg */) {
+ LOG(ERROR) << "on_event_range_request - should not be called";
+ };
+
+ callback_handlers.on_event_range_report =
+ [weak_ptr_this](const legacy_hal::NanRangeReportInd& /* msg */) {
+ LOG(ERROR) << "on_event_range_report - should not be called";
+ };
+
+ legacy_hal::wifi_error legacy_status =
+ legacy_hal_.lock()->nanRegisterCallbackHandlers(ifname_,
+ callback_handlers);
+ if (legacy_status != legacy_hal::WIFI_SUCCESS) {
+ LOG(ERROR) << "Failed to register nan callbacks. Invalidating object";
+ invalidate();
+ }
}
void WifiNanIface::invalidate() {
- // send commands to HAL to actually disable and destroy interfaces
- legacy_hal_.lock()->nanDisableRequest(0xFFFF);
- legacy_hal_.lock()->nanDataInterfaceDelete(0xFFFE, "aware_data0");
- legacy_hal_.lock()->nanDataInterfaceDelete(0xFFFD, "aware_data1");
+ // send commands to HAL to actually disable and destroy interfaces
+ legacy_hal_.lock()->nanDisableRequest(ifname_, 0xFFFF);
+ legacy_hal_.lock()->nanDataInterfaceDelete(ifname_, 0xFFFE, "aware_data0");
+ legacy_hal_.lock()->nanDataInterfaceDelete(ifname_, 0xFFFD, "aware_data1");
- legacy_hal_.reset();
- event_cb_handler_.invalidate();
- is_valid_ = false;
+ legacy_hal_.reset();
+ event_cb_handler_.invalidate();
+ is_valid_ = false;
}
-bool WifiNanIface::isValid() {
- return is_valid_;
-}
+bool WifiNanIface::isValid() { return is_valid_; }
std::set<sp<IWifiNanIfaceEventCallback>> WifiNanIface::getEventCallbacks() {
- return event_cb_handler_.getCallbacks();
+ return event_cb_handler_.getCallbacks();
}
Return<void> WifiNanIface::getName(getName_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
- &WifiNanIface::getNameInternal,
- hidl_status_cb);
+ return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
+ &WifiNanIface::getNameInternal, hidl_status_cb);
}
Return<void> WifiNanIface::getType(getType_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
- &WifiNanIface::getTypeInternal,
- hidl_status_cb);
+ return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
+ &WifiNanIface::getTypeInternal, hidl_status_cb);
}
Return<void> WifiNanIface::registerEventCallback(
const sp<IWifiNanIfaceEventCallback>& callback,
registerEventCallback_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
- &WifiNanIface::registerEventCallbackInternal,
- hidl_status_cb,
- callback);
+ return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
+ &WifiNanIface::registerEventCallbackInternal,
+ hidl_status_cb, callback);
}
-Return<void> WifiNanIface::getCapabilitiesRequest(uint16_t cmd_id,
- getCapabilitiesRequest_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
- &WifiNanIface::getCapabilitiesRequestInternal,
- hidl_status_cb,
- cmd_id);
+Return<void> WifiNanIface::getCapabilitiesRequest(
+ uint16_t cmd_id, getCapabilitiesRequest_cb hidl_status_cb) {
+ return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
+ &WifiNanIface::getCapabilitiesRequestInternal,
+ hidl_status_cb, cmd_id);
}
Return<void> WifiNanIface::enableRequest(uint16_t cmd_id,
const NanEnableRequest& msg,
enableRequest_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
- &WifiNanIface::enableRequestInternal,
- hidl_status_cb,
- cmd_id,
- msg);
+ return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
+ &WifiNanIface::enableRequestInternal, hidl_status_cb,
+ cmd_id, msg);
}
Return<void> WifiNanIface::configRequest(uint16_t cmd_id,
const NanConfigRequest& msg,
configRequest_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
- &WifiNanIface::configRequestInternal,
- hidl_status_cb,
- cmd_id,
- msg);
+ return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
+ &WifiNanIface::configRequestInternal, hidl_status_cb,
+ cmd_id, msg);
}
Return<void> WifiNanIface::disableRequest(uint16_t cmd_id,
disableRequest_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
- &WifiNanIface::disableRequestInternal,
- hidl_status_cb,
- cmd_id);
+ return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
+ &WifiNanIface::disableRequestInternal,
+ hidl_status_cb, cmd_id);
}
-Return<void> WifiNanIface::startPublishRequest(uint16_t cmd_id,
- const NanPublishRequest& msg,
- startPublishRequest_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
- &WifiNanIface::startPublishRequestInternal,
- hidl_status_cb,
- cmd_id,
- msg);
+Return<void> WifiNanIface::startPublishRequest(
+ uint16_t cmd_id, const NanPublishRequest& msg,
+ startPublishRequest_cb hidl_status_cb) {
+ return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
+ &WifiNanIface::startPublishRequestInternal,
+ hidl_status_cb, cmd_id, msg);
}
Return<void> WifiNanIface::stopPublishRequest(
- uint16_t cmd_id,
- uint8_t sessionId,
- stopPublishRequest_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
- &WifiNanIface::stopPublishRequestInternal,
- hidl_status_cb,
- cmd_id,
- sessionId);
+ uint16_t cmd_id, uint8_t sessionId, stopPublishRequest_cb hidl_status_cb) {
+ return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
+ &WifiNanIface::stopPublishRequestInternal,
+ hidl_status_cb, cmd_id, sessionId);
}
Return<void> WifiNanIface::startSubscribeRequest(
- uint16_t cmd_id,
- const NanSubscribeRequest& msg,
+ uint16_t cmd_id, const NanSubscribeRequest& msg,
startSubscribeRequest_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
- &WifiNanIface::startSubscribeRequestInternal,
- hidl_status_cb,
- cmd_id,
- msg);
+ return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
+ &WifiNanIface::startSubscribeRequestInternal,
+ hidl_status_cb, cmd_id, msg);
}
Return<void> WifiNanIface::stopSubscribeRequest(
- uint16_t cmd_id,
- uint8_t sessionId,
+ uint16_t cmd_id, uint8_t sessionId,
stopSubscribeRequest_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
- &WifiNanIface::stopSubscribeRequestInternal,
- hidl_status_cb,
- cmd_id,
- sessionId);
+ return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
+ &WifiNanIface::stopSubscribeRequestInternal,
+ hidl_status_cb, cmd_id, sessionId);
}
Return<void> WifiNanIface::transmitFollowupRequest(
- uint16_t cmd_id,
- const NanTransmitFollowupRequest& msg,
+ uint16_t cmd_id, const NanTransmitFollowupRequest& msg,
transmitFollowupRequest_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
- &WifiNanIface::transmitFollowupRequestInternal,
- hidl_status_cb,
- cmd_id,
- msg);
+ return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
+ &WifiNanIface::transmitFollowupRequestInternal,
+ hidl_status_cb, cmd_id, msg);
}
Return<void> WifiNanIface::createDataInterfaceRequest(
- uint16_t cmd_id,
- const hidl_string& iface_name,
+ uint16_t cmd_id, const hidl_string& iface_name,
createDataInterfaceRequest_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
- &WifiNanIface::createDataInterfaceRequestInternal,
- hidl_status_cb,
- cmd_id,
- iface_name);
+ return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
+ &WifiNanIface::createDataInterfaceRequestInternal,
+ hidl_status_cb, cmd_id, iface_name);
}
Return<void> WifiNanIface::deleteDataInterfaceRequest(
- uint16_t cmd_id,
- const hidl_string& iface_name,
+ uint16_t cmd_id, const hidl_string& iface_name,
deleteDataInterfaceRequest_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
- &WifiNanIface::deleteDataInterfaceRequestInternal,
- hidl_status_cb,
- cmd_id,
- iface_name);
+ return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
+ &WifiNanIface::deleteDataInterfaceRequestInternal,
+ hidl_status_cb, cmd_id, iface_name);
}
Return<void> WifiNanIface::initiateDataPathRequest(
- uint16_t cmd_id,
- const NanInitiateDataPathRequest& msg,
+ uint16_t cmd_id, const NanInitiateDataPathRequest& msg,
initiateDataPathRequest_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
- &WifiNanIface::initiateDataPathRequestInternal,
- hidl_status_cb,
- cmd_id,
- msg);
+ return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
+ &WifiNanIface::initiateDataPathRequestInternal,
+ hidl_status_cb, cmd_id, msg);
}
Return<void> WifiNanIface::respondToDataPathIndicationRequest(
- uint16_t cmd_id,
- const NanRespondToDataPathIndicationRequest& msg,
+ uint16_t cmd_id, const NanRespondToDataPathIndicationRequest& msg,
respondToDataPathIndicationRequest_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
- &WifiNanIface::respondToDataPathIndicationRequestInternal,
- hidl_status_cb,
- cmd_id,
- msg);
+ return validateAndCall(
+ this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
+ &WifiNanIface::respondToDataPathIndicationRequestInternal,
+ hidl_status_cb, cmd_id, msg);
}
-Return<void> WifiNanIface::terminateDataPathRequest(uint16_t cmd_id, uint32_t ndpInstanceId,
+Return<void> WifiNanIface::terminateDataPathRequest(
+ uint16_t cmd_id, uint32_t ndpInstanceId,
terminateDataPathRequest_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
- &WifiNanIface::terminateDataPathRequestInternal,
- hidl_status_cb,
- cmd_id,
- ndpInstanceId);
+ return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
+ &WifiNanIface::terminateDataPathRequestInternal,
+ hidl_status_cb, cmd_id, ndpInstanceId);
}
std::pair<WifiStatus, std::string> WifiNanIface::getNameInternal() {
- return {createWifiStatus(WifiStatusCode::SUCCESS), ifname_};
+ return {createWifiStatus(WifiStatusCode::SUCCESS), ifname_};
}
std::pair<WifiStatus, IfaceType> WifiNanIface::getTypeInternal() {
- return {createWifiStatus(WifiStatusCode::SUCCESS), IfaceType::NAN};
+ return {createWifiStatus(WifiStatusCode::SUCCESS), IfaceType::NAN};
}
WifiStatus WifiNanIface::registerEventCallbackInternal(
const sp<IWifiNanIfaceEventCallback>& callback) {
- if (!event_cb_handler_.addCallback(callback)) {
- return createWifiStatus(WifiStatusCode::ERROR_UNKNOWN);
- }
- return createWifiStatus(WifiStatusCode::SUCCESS);
+ if (!event_cb_handler_.addCallback(callback)) {
+ return createWifiStatus(WifiStatusCode::ERROR_UNKNOWN);
+ }
+ return createWifiStatus(WifiStatusCode::SUCCESS);
}
WifiStatus WifiNanIface::getCapabilitiesRequestInternal(uint16_t cmd_id) {
- legacy_hal::wifi_error legacy_status =
- legacy_hal_.lock()->nanGetCapabilities(cmd_id);
- return createWifiStatusFromLegacyError(legacy_status);
+ legacy_hal::wifi_error legacy_status =
+ legacy_hal_.lock()->nanGetCapabilities(ifname_, cmd_id);
+ return createWifiStatusFromLegacyError(legacy_status);
}
WifiStatus WifiNanIface::enableRequestInternal(uint16_t cmd_id,
const NanEnableRequest& msg) {
- legacy_hal::NanEnableRequest legacy_msg;
- if (!hidl_struct_util::convertHidlNanEnableRequestToLegacy(msg, &legacy_msg)) {
- return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
- }
- legacy_hal::wifi_error legacy_status =
- legacy_hal_.lock()->nanEnableRequest(cmd_id, legacy_msg);
- return createWifiStatusFromLegacyError(legacy_status);
+ legacy_hal::NanEnableRequest legacy_msg;
+ if (!hidl_struct_util::convertHidlNanEnableRequestToLegacy(msg,
+ &legacy_msg)) {
+ return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
+ }
+ legacy_hal::wifi_error legacy_status =
+ legacy_hal_.lock()->nanEnableRequest(ifname_, cmd_id, legacy_msg);
+ return createWifiStatusFromLegacyError(legacy_status);
}
-WifiStatus WifiNanIface::configRequestInternal(
- uint16_t cmd_id, const NanConfigRequest& msg) {
- legacy_hal::NanConfigRequest legacy_msg;
- if (!hidl_struct_util::convertHidlNanConfigRequestToLegacy(msg,
- &legacy_msg)) {
- return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
- }
- legacy_hal::wifi_error legacy_status =
- legacy_hal_.lock()->nanConfigRequest(cmd_id, legacy_msg);
- return createWifiStatusFromLegacyError(legacy_status);
+WifiStatus WifiNanIface::configRequestInternal(uint16_t cmd_id,
+ const NanConfigRequest& msg) {
+ legacy_hal::NanConfigRequest legacy_msg;
+ if (!hidl_struct_util::convertHidlNanConfigRequestToLegacy(msg,
+ &legacy_msg)) {
+ return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
+ }
+ legacy_hal::wifi_error legacy_status =
+ legacy_hal_.lock()->nanConfigRequest(ifname_, cmd_id, legacy_msg);
+ return createWifiStatusFromLegacyError(legacy_status);
}
WifiStatus WifiNanIface::disableRequestInternal(uint16_t cmd_id) {
- legacy_hal::wifi_error legacy_status =
- legacy_hal_.lock()->nanDisableRequest(cmd_id);
- return createWifiStatusFromLegacyError(legacy_status);
+ legacy_hal::wifi_error legacy_status =
+ legacy_hal_.lock()->nanDisableRequest(ifname_, cmd_id);
+ return createWifiStatusFromLegacyError(legacy_status);
}
-WifiStatus WifiNanIface::startPublishRequestInternal(uint16_t cmd_id,
- const NanPublishRequest& msg) {
- legacy_hal::NanPublishRequest legacy_msg;
- if (!hidl_struct_util::convertHidlNanPublishRequestToLegacy(msg,
- &legacy_msg)) {
- return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
- }
- legacy_hal::wifi_error legacy_status =
- legacy_hal_.lock()->nanPublishRequest(cmd_id, legacy_msg);
- return createWifiStatusFromLegacyError(legacy_status);
+WifiStatus WifiNanIface::startPublishRequestInternal(
+ uint16_t cmd_id, const NanPublishRequest& msg) {
+ legacy_hal::NanPublishRequest legacy_msg;
+ if (!hidl_struct_util::convertHidlNanPublishRequestToLegacy(msg,
+ &legacy_msg)) {
+ return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
+ }
+ legacy_hal::wifi_error legacy_status =
+ legacy_hal_.lock()->nanPublishRequest(ifname_, cmd_id, legacy_msg);
+ return createWifiStatusFromLegacyError(legacy_status);
}
-WifiStatus WifiNanIface::stopPublishRequestInternal(
- uint16_t cmd_id, uint8_t sessionId) {
- legacy_hal::NanPublishCancelRequest legacy_msg;
- legacy_msg.publish_id = sessionId;
- legacy_hal::wifi_error legacy_status =
- legacy_hal_.lock()->nanPublishCancelRequest(cmd_id, legacy_msg);
- return createWifiStatusFromLegacyError(legacy_status);
+WifiStatus WifiNanIface::stopPublishRequestInternal(uint16_t cmd_id,
+ uint8_t sessionId) {
+ legacy_hal::NanPublishCancelRequest legacy_msg;
+ legacy_msg.publish_id = sessionId;
+ legacy_hal::wifi_error legacy_status =
+ legacy_hal_.lock()->nanPublishCancelRequest(ifname_, cmd_id,
+ legacy_msg);
+ return createWifiStatusFromLegacyError(legacy_status);
}
WifiStatus WifiNanIface::startSubscribeRequestInternal(
uint16_t cmd_id, const NanSubscribeRequest& msg) {
- legacy_hal::NanSubscribeRequest legacy_msg;
- if (!hidl_struct_util::convertHidlNanSubscribeRequestToLegacy(msg,
- &legacy_msg)) {
- return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
- }
- legacy_hal::wifi_error legacy_status =
- legacy_hal_.lock()->nanSubscribeRequest(cmd_id, legacy_msg);
- return createWifiStatusFromLegacyError(legacy_status);
+ legacy_hal::NanSubscribeRequest legacy_msg;
+ if (!hidl_struct_util::convertHidlNanSubscribeRequestToLegacy(
+ msg, &legacy_msg)) {
+ return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
+ }
+ legacy_hal::wifi_error legacy_status =
+ legacy_hal_.lock()->nanSubscribeRequest(ifname_, cmd_id, legacy_msg);
+ return createWifiStatusFromLegacyError(legacy_status);
}
-WifiStatus WifiNanIface::stopSubscribeRequestInternal(
- uint16_t cmd_id, uint8_t sessionId) {
- legacy_hal::NanSubscribeCancelRequest legacy_msg;
- legacy_msg.subscribe_id = sessionId;
- legacy_hal::wifi_error legacy_status =
- legacy_hal_.lock()->nanSubscribeCancelRequest(cmd_id, legacy_msg);
- return createWifiStatusFromLegacyError(legacy_status);
+WifiStatus WifiNanIface::stopSubscribeRequestInternal(uint16_t cmd_id,
+ uint8_t sessionId) {
+ legacy_hal::NanSubscribeCancelRequest legacy_msg;
+ legacy_msg.subscribe_id = sessionId;
+ legacy_hal::wifi_error legacy_status =
+ legacy_hal_.lock()->nanSubscribeCancelRequest(ifname_, cmd_id,
+ legacy_msg);
+ return createWifiStatusFromLegacyError(legacy_status);
}
WifiStatus WifiNanIface::transmitFollowupRequestInternal(
uint16_t cmd_id, const NanTransmitFollowupRequest& msg) {
- legacy_hal::NanTransmitFollowupRequest legacy_msg;
- if (!hidl_struct_util::convertHidlNanTransmitFollowupRequestToLegacy(msg, &legacy_msg)) {
- return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
- }
- legacy_hal::wifi_error legacy_status =
- legacy_hal_.lock()->nanTransmitFollowupRequest(cmd_id, legacy_msg);
- return createWifiStatusFromLegacyError(legacy_status);
+ legacy_hal::NanTransmitFollowupRequest legacy_msg;
+ if (!hidl_struct_util::convertHidlNanTransmitFollowupRequestToLegacy(
+ msg, &legacy_msg)) {
+ return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
+ }
+ legacy_hal::wifi_error legacy_status =
+ legacy_hal_.lock()->nanTransmitFollowupRequest(ifname_, cmd_id,
+ legacy_msg);
+ return createWifiStatusFromLegacyError(legacy_status);
}
WifiStatus WifiNanIface::createDataInterfaceRequestInternal(
uint16_t cmd_id, const std::string& iface_name) {
- legacy_hal::wifi_error legacy_status =
- legacy_hal_.lock()->nanDataInterfaceCreate(cmd_id, iface_name);
- return createWifiStatusFromLegacyError(legacy_status);
+ legacy_hal::wifi_error legacy_status =
+ legacy_hal_.lock()->nanDataInterfaceCreate(ifname_, cmd_id, iface_name);
+ return createWifiStatusFromLegacyError(legacy_status);
}
WifiStatus WifiNanIface::deleteDataInterfaceRequestInternal(
uint16_t cmd_id, const std::string& iface_name) {
- legacy_hal::wifi_error legacy_status =
- legacy_hal_.lock()->nanDataInterfaceDelete(cmd_id, iface_name);
- return createWifiStatusFromLegacyError(legacy_status);
+ legacy_hal::wifi_error legacy_status =
+ legacy_hal_.lock()->nanDataInterfaceDelete(ifname_, cmd_id, iface_name);
+ return createWifiStatusFromLegacyError(legacy_status);
}
WifiStatus WifiNanIface::initiateDataPathRequestInternal(
uint16_t cmd_id, const NanInitiateDataPathRequest& msg) {
- legacy_hal::NanDataPathInitiatorRequest legacy_msg;
- if (!hidl_struct_util::convertHidlNanDataPathInitiatorRequestToLegacy(msg, &legacy_msg)) {
- return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
- }
- legacy_hal::wifi_error legacy_status =
- legacy_hal_.lock()->nanDataRequestInitiator(cmd_id, legacy_msg);
- return createWifiStatusFromLegacyError(legacy_status);
+ legacy_hal::NanDataPathInitiatorRequest legacy_msg;
+ if (!hidl_struct_util::convertHidlNanDataPathInitiatorRequestToLegacy(
+ msg, &legacy_msg)) {
+ return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
+ }
+ legacy_hal::wifi_error legacy_status =
+ legacy_hal_.lock()->nanDataRequestInitiator(ifname_, cmd_id,
+ legacy_msg);
+ return createWifiStatusFromLegacyError(legacy_status);
}
WifiStatus WifiNanIface::respondToDataPathIndicationRequestInternal(
uint16_t cmd_id, const NanRespondToDataPathIndicationRequest& msg) {
- legacy_hal::NanDataPathIndicationResponse legacy_msg;
- if (!hidl_struct_util::convertHidlNanDataPathIndicationResponseToLegacy(msg, &legacy_msg)) {
- return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
- }
- legacy_hal::wifi_error legacy_status =
- legacy_hal_.lock()->nanDataIndicationResponse(cmd_id, legacy_msg);
- return createWifiStatusFromLegacyError(legacy_status);
+ legacy_hal::NanDataPathIndicationResponse legacy_msg;
+ if (!hidl_struct_util::convertHidlNanDataPathIndicationResponseToLegacy(
+ msg, &legacy_msg)) {
+ return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
+ }
+ legacy_hal::wifi_error legacy_status =
+ legacy_hal_.lock()->nanDataIndicationResponse(ifname_, cmd_id,
+ legacy_msg);
+ return createWifiStatusFromLegacyError(legacy_status);
}
WifiStatus WifiNanIface::terminateDataPathRequestInternal(
uint16_t cmd_id, uint32_t ndpInstanceId) {
- legacy_hal::wifi_error legacy_status =
- legacy_hal_.lock()->nanDataEnd(cmd_id, ndpInstanceId);
- return createWifiStatusFromLegacyError(legacy_status);
+ legacy_hal::wifi_error legacy_status =
+ legacy_hal_.lock()->nanDataEnd(ifname_, cmd_id, ndpInstanceId);
+ return createWifiStatusFromLegacyError(legacy_status);
}
} // namespace implementation
diff --git a/wifi/1.2/default/wifi_nan_iface.h b/wifi/1.2/default/wifi_nan_iface.h
index 34552ea..2ca2e45 100644
--- a/wifi/1.2/default/wifi_nan_iface.h
+++ b/wifi/1.2/default/wifi_nan_iface.h
@@ -35,101 +35,98 @@
* HIDL interface object used to control a NAN Iface instance.
*/
class WifiNanIface : public V1_0::IWifiNanIface {
- public:
- WifiNanIface(const std::string& ifname,
- const std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal);
- // Refer to |WifiChip::invalidate()|.
- void invalidate();
- bool isValid();
+ public:
+ WifiNanIface(const std::string& ifname,
+ const std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal);
+ // Refer to |WifiChip::invalidate()|.
+ void invalidate();
+ bool isValid();
- // HIDL methods exposed.
- Return<void> getName(getName_cb hidl_status_cb) override;
- Return<void> getType(getType_cb hidl_status_cb) override;
- Return<void> registerEventCallback(
- const sp<IWifiNanIfaceEventCallback>& callback,
- registerEventCallback_cb hidl_status_cb) override;
- Return<void> getCapabilitiesRequest(uint16_t cmd_id,
- getCapabilitiesRequest_cb hidl_status_cb) override;
- Return<void> enableRequest(uint16_t cmd_id,
- const NanEnableRequest& msg,
- enableRequest_cb hidl_status_cb) override;
- Return<void> configRequest(uint16_t cmd_id,
- const NanConfigRequest& msg,
- configRequest_cb hidl_status_cb) override;
- Return<void> disableRequest(uint16_t cmd_id,
- disableRequest_cb hidl_status_cb) override;
- Return<void> startPublishRequest(uint16_t cmd_id,
- const NanPublishRequest& msg,
- startPublishRequest_cb hidl_status_cb) override;
- Return<void> stopPublishRequest(uint16_t cmd_id,
- uint8_t sessionId,
- stopPublishRequest_cb hidl_status_cb) override;
- Return<void> startSubscribeRequest(uint16_t cmd_id,
- const NanSubscribeRequest& msg,
- startSubscribeRequest_cb hidl_status_cb) override;
- Return<void> stopSubscribeRequest(uint16_t cmd_id,
- uint8_t sessionId,
- stopSubscribeRequest_cb hidl_status_cb) override;
- Return<void> transmitFollowupRequest(uint16_t cmd_id,
- const NanTransmitFollowupRequest& msg,
- transmitFollowupRequest_cb hidl_status_cb) override;
- Return<void> createDataInterfaceRequest(uint16_t cmd_id,
- const hidl_string& iface_name,
- createDataInterfaceRequest_cb hidl_status_cb) override;
- Return<void> deleteDataInterfaceRequest(uint16_t cmd_id,
- const hidl_string& iface_name,
- deleteDataInterfaceRequest_cb hidl_status_cb) override;
- Return<void> initiateDataPathRequest(uint16_t cmd_id,
- const NanInitiateDataPathRequest& msg,
- initiateDataPathRequest_cb hidl_status_cb) override;
- Return<void> respondToDataPathIndicationRequest(
- uint16_t cmd_id,
- const NanRespondToDataPathIndicationRequest& msg,
- respondToDataPathIndicationRequest_cb hidl_status_cb) override;
- Return<void> terminateDataPathRequest(uint16_t cmd_id,
- uint32_t ndpInstanceId,
- terminateDataPathRequest_cb hidl_status_cb) override;
+ // HIDL methods exposed.
+ Return<void> getName(getName_cb hidl_status_cb) override;
+ Return<void> getType(getType_cb hidl_status_cb) override;
+ Return<void> registerEventCallback(
+ const sp<IWifiNanIfaceEventCallback>& callback,
+ registerEventCallback_cb hidl_status_cb) override;
+ Return<void> getCapabilitiesRequest(
+ uint16_t cmd_id, getCapabilitiesRequest_cb hidl_status_cb) override;
+ Return<void> enableRequest(uint16_t cmd_id, const NanEnableRequest& msg,
+ enableRequest_cb hidl_status_cb) override;
+ Return<void> configRequest(uint16_t cmd_id, const NanConfigRequest& msg,
+ configRequest_cb hidl_status_cb) override;
+ Return<void> disableRequest(uint16_t cmd_id,
+ disableRequest_cb hidl_status_cb) override;
+ Return<void> startPublishRequest(
+ uint16_t cmd_id, const NanPublishRequest& msg,
+ startPublishRequest_cb hidl_status_cb) override;
+ Return<void> stopPublishRequest(
+ uint16_t cmd_id, uint8_t sessionId,
+ stopPublishRequest_cb hidl_status_cb) override;
+ Return<void> startSubscribeRequest(
+ uint16_t cmd_id, const NanSubscribeRequest& msg,
+ startSubscribeRequest_cb hidl_status_cb) override;
+ Return<void> stopSubscribeRequest(
+ uint16_t cmd_id, uint8_t sessionId,
+ stopSubscribeRequest_cb hidl_status_cb) override;
+ Return<void> transmitFollowupRequest(
+ uint16_t cmd_id, const NanTransmitFollowupRequest& msg,
+ transmitFollowupRequest_cb hidl_status_cb) override;
+ Return<void> createDataInterfaceRequest(
+ uint16_t cmd_id, const hidl_string& iface_name,
+ createDataInterfaceRequest_cb hidl_status_cb) override;
+ Return<void> deleteDataInterfaceRequest(
+ uint16_t cmd_id, const hidl_string& iface_name,
+ deleteDataInterfaceRequest_cb hidl_status_cb) override;
+ Return<void> initiateDataPathRequest(
+ uint16_t cmd_id, const NanInitiateDataPathRequest& msg,
+ initiateDataPathRequest_cb hidl_status_cb) override;
+ Return<void> respondToDataPathIndicationRequest(
+ uint16_t cmd_id, const NanRespondToDataPathIndicationRequest& msg,
+ respondToDataPathIndicationRequest_cb hidl_status_cb) override;
+ Return<void> terminateDataPathRequest(
+ uint16_t cmd_id, uint32_t ndpInstanceId,
+ terminateDataPathRequest_cb hidl_status_cb) override;
- private:
- // Corresponding worker functions for the HIDL methods.
- std::pair<WifiStatus, std::string> getNameInternal();
- std::pair<WifiStatus, IfaceType> getTypeInternal();
- WifiStatus registerEventCallbackInternal(
- const sp<IWifiNanIfaceEventCallback>& callback);
- WifiStatus getCapabilitiesRequestInternal(uint16_t cmd_id);
- WifiStatus enableRequestInternal(uint16_t cmd_id,
- const NanEnableRequest& msg);
- WifiStatus configRequestInternal(uint16_t cmd_id,
- const NanConfigRequest& msg);
- WifiStatus disableRequestInternal(uint16_t cmd_id);
- WifiStatus startPublishRequestInternal(uint16_t cmd_id,
- const NanPublishRequest& msg);
- WifiStatus stopPublishRequestInternal(uint16_t cmd_id, uint8_t sessionId);
- WifiStatus startSubscribeRequestInternal(uint16_t cmd_id,
- const NanSubscribeRequest& msg);
- WifiStatus stopSubscribeRequestInternal(uint16_t cmd_id, uint8_t sessionId);
- WifiStatus transmitFollowupRequestInternal(
- uint16_t cmd_id, const NanTransmitFollowupRequest& msg);
- WifiStatus createDataInterfaceRequestInternal(uint16_t cmd_id,
- const std::string& iface_name);
- WifiStatus deleteDataInterfaceRequestInternal(uint16_t cmd_id,
- const std::string& iface_name);
- WifiStatus initiateDataPathRequestInternal(
- uint16_t cmd_id, const NanInitiateDataPathRequest& msg);
- WifiStatus respondToDataPathIndicationRequestInternal(
- uint16_t cmd_id, const NanRespondToDataPathIndicationRequest& msg);
- WifiStatus terminateDataPathRequestInternal(
- uint16_t cmd_id, uint32_t ndpInstanceId);
+ private:
+ // Corresponding worker functions for the HIDL methods.
+ std::pair<WifiStatus, std::string> getNameInternal();
+ std::pair<WifiStatus, IfaceType> getTypeInternal();
+ WifiStatus registerEventCallbackInternal(
+ const sp<IWifiNanIfaceEventCallback>& callback);
+ WifiStatus getCapabilitiesRequestInternal(uint16_t cmd_id);
+ WifiStatus enableRequestInternal(uint16_t cmd_id,
+ const NanEnableRequest& msg);
+ WifiStatus configRequestInternal(uint16_t cmd_id,
+ const NanConfigRequest& msg);
+ WifiStatus disableRequestInternal(uint16_t cmd_id);
+ WifiStatus startPublishRequestInternal(uint16_t cmd_id,
+ const NanPublishRequest& msg);
+ WifiStatus stopPublishRequestInternal(uint16_t cmd_id, uint8_t sessionId);
+ WifiStatus startSubscribeRequestInternal(uint16_t cmd_id,
+ const NanSubscribeRequest& msg);
+ WifiStatus stopSubscribeRequestInternal(uint16_t cmd_id, uint8_t sessionId);
+ WifiStatus transmitFollowupRequestInternal(
+ uint16_t cmd_id, const NanTransmitFollowupRequest& msg);
+ WifiStatus createDataInterfaceRequestInternal(
+ uint16_t cmd_id, const std::string& iface_name);
+ WifiStatus deleteDataInterfaceRequestInternal(
+ uint16_t cmd_id, const std::string& iface_name);
+ WifiStatus initiateDataPathRequestInternal(
+ uint16_t cmd_id, const NanInitiateDataPathRequest& msg);
+ WifiStatus respondToDataPathIndicationRequestInternal(
+ uint16_t cmd_id, const NanRespondToDataPathIndicationRequest& msg);
+ WifiStatus terminateDataPathRequestInternal(uint16_t cmd_id,
+ uint32_t ndpInstanceId);
- std::set<sp<IWifiNanIfaceEventCallback>> getEventCallbacks();
+ std::set<sp<IWifiNanIfaceEventCallback>> getEventCallbacks();
- std::string ifname_;
- std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal_;
- bool is_valid_;
- hidl_callback_util::HidlCallbackHandler<IWifiNanIfaceEventCallback>
- event_cb_handler_;
+ std::string ifname_;
+ std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal_;
+ bool is_valid_;
+ hidl_callback_util::HidlCallbackHandler<IWifiNanIfaceEventCallback>
+ event_cb_handler_;
- DISALLOW_COPY_AND_ASSIGN(WifiNanIface);
+ DISALLOW_COPY_AND_ASSIGN(WifiNanIface);
};
} // namespace implementation
diff --git a/wifi/1.2/default/wifi_p2p_iface.cpp b/wifi/1.2/default/wifi_p2p_iface.cpp
index 41c8d0a..f1fbf2c 100644
--- a/wifi/1.2/default/wifi_p2p_iface.cpp
+++ b/wifi/1.2/default/wifi_p2p_iface.cpp
@@ -33,34 +33,28 @@
: ifname_(ifname), legacy_hal_(legacy_hal), is_valid_(true) {}
void WifiP2pIface::invalidate() {
- legacy_hal_.reset();
- is_valid_ = false;
+ legacy_hal_.reset();
+ is_valid_ = false;
}
-bool WifiP2pIface::isValid() {
- return is_valid_;
-}
+bool WifiP2pIface::isValid() { return is_valid_; }
Return<void> WifiP2pIface::getName(getName_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
- &WifiP2pIface::getNameInternal,
- hidl_status_cb);
+ return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
+ &WifiP2pIface::getNameInternal, hidl_status_cb);
}
Return<void> WifiP2pIface::getType(getType_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
- &WifiP2pIface::getTypeInternal,
- hidl_status_cb);
+ return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
+ &WifiP2pIface::getTypeInternal, hidl_status_cb);
}
std::pair<WifiStatus, std::string> WifiP2pIface::getNameInternal() {
- return {createWifiStatus(WifiStatusCode::SUCCESS), ifname_};
+ return {createWifiStatus(WifiStatusCode::SUCCESS), ifname_};
}
std::pair<WifiStatus, IfaceType> WifiP2pIface::getTypeInternal() {
- return {createWifiStatus(WifiStatusCode::SUCCESS), IfaceType::P2P};
+ return {createWifiStatus(WifiStatusCode::SUCCESS), IfaceType::P2P};
}
} // namespace implementation
diff --git a/wifi/1.2/default/wifi_p2p_iface.h b/wifi/1.2/default/wifi_p2p_iface.h
index 6b85188..839d3c3 100644
--- a/wifi/1.2/default/wifi_p2p_iface.h
+++ b/wifi/1.2/default/wifi_p2p_iface.h
@@ -33,27 +33,27 @@
* HIDL interface object used to control a P2P Iface instance.
*/
class WifiP2pIface : public V1_0::IWifiP2pIface {
- public:
- WifiP2pIface(const std::string& ifname,
- const std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal);
- // Refer to |WifiChip::invalidate()|.
- void invalidate();
- bool isValid();
+ public:
+ WifiP2pIface(const std::string& ifname,
+ const std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal);
+ // Refer to |WifiChip::invalidate()|.
+ void invalidate();
+ bool isValid();
- // HIDL methods exposed.
- Return<void> getName(getName_cb hidl_status_cb) override;
- Return<void> getType(getType_cb hidl_status_cb) override;
+ // HIDL methods exposed.
+ Return<void> getName(getName_cb hidl_status_cb) override;
+ Return<void> getType(getType_cb hidl_status_cb) override;
- private:
- // Corresponding worker functions for the HIDL methods.
- std::pair<WifiStatus, std::string> getNameInternal();
- std::pair<WifiStatus, IfaceType> getTypeInternal();
+ private:
+ // Corresponding worker functions for the HIDL methods.
+ std::pair<WifiStatus, std::string> getNameInternal();
+ std::pair<WifiStatus, IfaceType> getTypeInternal();
- std::string ifname_;
- std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal_;
- bool is_valid_;
+ std::string ifname_;
+ std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal_;
+ bool is_valid_;
- DISALLOW_COPY_AND_ASSIGN(WifiP2pIface);
+ DISALLOW_COPY_AND_ASSIGN(WifiP2pIface);
};
} // namespace implementation
diff --git a/wifi/1.2/default/wifi_rtt_controller.cpp b/wifi/1.2/default/wifi_rtt_controller.cpp
index 2fab06c..b68445b 100644
--- a/wifi/1.2/default/wifi_rtt_controller.cpp
+++ b/wifi/1.2/default/wifi_rtt_controller.cpp
@@ -29,266 +29,244 @@
using hidl_return_util::validateAndCall;
WifiRttController::WifiRttController(
- const sp<IWifiIface>& bound_iface,
+ const std::string& iface_name, const sp<IWifiIface>& bound_iface,
const std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal)
- : bound_iface_(bound_iface), legacy_hal_(legacy_hal), is_valid_(true) {}
+ : ifname_(iface_name),
+ bound_iface_(bound_iface),
+ legacy_hal_(legacy_hal),
+ is_valid_(true) {}
void WifiRttController::invalidate() {
- legacy_hal_.reset();
- event_callbacks_.clear();
- is_valid_ = false;
+ legacy_hal_.reset();
+ event_callbacks_.clear();
+ is_valid_ = false;
}
-bool WifiRttController::isValid() {
- return is_valid_;
-}
+bool WifiRttController::isValid() { return is_valid_; }
std::vector<sp<IWifiRttControllerEventCallback>>
WifiRttController::getEventCallbacks() {
- return event_callbacks_;
+ return event_callbacks_;
}
Return<void> WifiRttController::getBoundIface(getBoundIface_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_RTT_CONTROLLER_INVALID,
- &WifiRttController::getBoundIfaceInternal,
- hidl_status_cb);
+ return validateAndCall(
+ this, WifiStatusCode::ERROR_WIFI_RTT_CONTROLLER_INVALID,
+ &WifiRttController::getBoundIfaceInternal, hidl_status_cb);
}
Return<void> WifiRttController::registerEventCallback(
const sp<IWifiRttControllerEventCallback>& callback,
registerEventCallback_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_RTT_CONTROLLER_INVALID,
- &WifiRttController::registerEventCallbackInternal,
- hidl_status_cb,
- callback);
+ return validateAndCall(this,
+ WifiStatusCode::ERROR_WIFI_RTT_CONTROLLER_INVALID,
+ &WifiRttController::registerEventCallbackInternal,
+ hidl_status_cb, callback);
}
Return<void> WifiRttController::rangeRequest(
- uint32_t cmd_id,
- const hidl_vec<RttConfig>& rtt_configs,
+ uint32_t cmd_id, const hidl_vec<RttConfig>& rtt_configs,
rangeRequest_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_RTT_CONTROLLER_INVALID,
- &WifiRttController::rangeRequestInternal,
- hidl_status_cb,
- cmd_id,
- rtt_configs);
+ return validateAndCall(this,
+ WifiStatusCode::ERROR_WIFI_RTT_CONTROLLER_INVALID,
+ &WifiRttController::rangeRequestInternal,
+ hidl_status_cb, cmd_id, rtt_configs);
}
Return<void> WifiRttController::rangeCancel(
- uint32_t cmd_id,
- const hidl_vec<hidl_array<uint8_t, 6>>& addrs,
+ uint32_t cmd_id, const hidl_vec<hidl_array<uint8_t, 6>>& addrs,
rangeCancel_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_RTT_CONTROLLER_INVALID,
- &WifiRttController::rangeCancelInternal,
- hidl_status_cb,
- cmd_id,
- addrs);
+ return validateAndCall(
+ this, WifiStatusCode::ERROR_WIFI_RTT_CONTROLLER_INVALID,
+ &WifiRttController::rangeCancelInternal, hidl_status_cb, cmd_id, addrs);
}
Return<void> WifiRttController::getCapabilities(
getCapabilities_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_RTT_CONTROLLER_INVALID,
- &WifiRttController::getCapabilitiesInternal,
- hidl_status_cb);
+ return validateAndCall(
+ this, WifiStatusCode::ERROR_WIFI_RTT_CONTROLLER_INVALID,
+ &WifiRttController::getCapabilitiesInternal, hidl_status_cb);
}
Return<void> WifiRttController::setLci(uint32_t cmd_id,
const RttLciInformation& lci,
setLci_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_RTT_CONTROLLER_INVALID,
- &WifiRttController::setLciInternal,
- hidl_status_cb,
- cmd_id,
- lci);
+ return validateAndCall(
+ this, WifiStatusCode::ERROR_WIFI_RTT_CONTROLLER_INVALID,
+ &WifiRttController::setLciInternal, hidl_status_cb, cmd_id, lci);
}
Return<void> WifiRttController::setLcr(uint32_t cmd_id,
const RttLcrInformation& lcr,
setLcr_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_RTT_CONTROLLER_INVALID,
- &WifiRttController::setLcrInternal,
- hidl_status_cb,
- cmd_id,
- lcr);
+ return validateAndCall(
+ this, WifiStatusCode::ERROR_WIFI_RTT_CONTROLLER_INVALID,
+ &WifiRttController::setLcrInternal, hidl_status_cb, cmd_id, lcr);
}
Return<void> WifiRttController::getResponderInfo(
getResponderInfo_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_RTT_CONTROLLER_INVALID,
- &WifiRttController::getResponderInfoInternal,
- hidl_status_cb);
+ return validateAndCall(
+ this, WifiStatusCode::ERROR_WIFI_RTT_CONTROLLER_INVALID,
+ &WifiRttController::getResponderInfoInternal, hidl_status_cb);
}
Return<void> WifiRttController::enableResponder(
- uint32_t cmd_id,
- const WifiChannelInfo& channel_hint,
- uint32_t max_duration_seconds,
- const RttResponder& info,
+ uint32_t cmd_id, const WifiChannelInfo& channel_hint,
+ uint32_t max_duration_seconds, const RttResponder& info,
enableResponder_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_RTT_CONTROLLER_INVALID,
- &WifiRttController::enableResponderInternal,
- hidl_status_cb,
- cmd_id,
- channel_hint,
- max_duration_seconds,
- info);
+ return validateAndCall(
+ this, WifiStatusCode::ERROR_WIFI_RTT_CONTROLLER_INVALID,
+ &WifiRttController::enableResponderInternal, hidl_status_cb, cmd_id,
+ channel_hint, max_duration_seconds, info);
}
Return<void> WifiRttController::disableResponder(
uint32_t cmd_id, disableResponder_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_RTT_CONTROLLER_INVALID,
- &WifiRttController::disableResponderInternal,
- hidl_status_cb,
- cmd_id);
+ return validateAndCall(
+ this, WifiStatusCode::ERROR_WIFI_RTT_CONTROLLER_INVALID,
+ &WifiRttController::disableResponderInternal, hidl_status_cb, cmd_id);
}
std::pair<WifiStatus, sp<IWifiIface>>
WifiRttController::getBoundIfaceInternal() {
- return {createWifiStatus(WifiStatusCode::SUCCESS), bound_iface_};
+ return {createWifiStatus(WifiStatusCode::SUCCESS), bound_iface_};
}
WifiStatus WifiRttController::registerEventCallbackInternal(
const sp<IWifiRttControllerEventCallback>& callback) {
- // TODO(b/31632518): remove the callback when the client is destroyed
- event_callbacks_.emplace_back(callback);
- return createWifiStatus(WifiStatusCode::SUCCESS);
+ // TODO(b/31632518): remove the callback when the client is destroyed
+ event_callbacks_.emplace_back(callback);
+ return createWifiStatus(WifiStatusCode::SUCCESS);
}
WifiStatus WifiRttController::rangeRequestInternal(
uint32_t cmd_id, const std::vector<RttConfig>& rtt_configs) {
- std::vector<legacy_hal::wifi_rtt_config> legacy_configs;
- if (!hidl_struct_util::convertHidlVectorOfRttConfigToLegacy(
- rtt_configs, &legacy_configs)) {
- return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
- }
- android::wp<WifiRttController> weak_ptr_this(this);
- const auto& on_results_callback = [weak_ptr_this](
- legacy_hal::wifi_request_id id,
- const std::vector<const legacy_hal::wifi_rtt_result*>& results) {
- const auto shared_ptr_this = weak_ptr_this.promote();
- if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
- LOG(ERROR) << "Callback invoked on an invalid object";
- return;
+ std::vector<legacy_hal::wifi_rtt_config> legacy_configs;
+ if (!hidl_struct_util::convertHidlVectorOfRttConfigToLegacy(
+ rtt_configs, &legacy_configs)) {
+ return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
}
- std::vector<RttResult> hidl_results;
- if (!hidl_struct_util::convertLegacyVectorOfRttResultToHidl(
- results, &hidl_results)) {
- LOG(ERROR) << "Failed to convert rtt results to HIDL structs";
- return;
- }
- for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
- callback->onResults(id, hidl_results);
- }
- };
- legacy_hal::wifi_error legacy_status =
- legacy_hal_.lock()->startRttRangeRequest(
- cmd_id, legacy_configs, on_results_callback);
- return createWifiStatusFromLegacyError(legacy_status);
+ android::wp<WifiRttController> weak_ptr_this(this);
+ const auto& on_results_callback =
+ [weak_ptr_this](
+ legacy_hal::wifi_request_id id,
+ const std::vector<const legacy_hal::wifi_rtt_result*>& results) {
+ const auto shared_ptr_this = weak_ptr_this.promote();
+ if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
+ LOG(ERROR) << "Callback invoked on an invalid object";
+ return;
+ }
+ std::vector<RttResult> hidl_results;
+ if (!hidl_struct_util::convertLegacyVectorOfRttResultToHidl(
+ results, &hidl_results)) {
+ LOG(ERROR) << "Failed to convert rtt results to HIDL structs";
+ return;
+ }
+ for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
+ callback->onResults(id, hidl_results);
+ }
+ };
+ legacy_hal::wifi_error legacy_status =
+ legacy_hal_.lock()->startRttRangeRequest(
+ ifname_, cmd_id, legacy_configs, on_results_callback);
+ return createWifiStatusFromLegacyError(legacy_status);
}
WifiStatus WifiRttController::rangeCancelInternal(
uint32_t cmd_id, const std::vector<hidl_array<uint8_t, 6>>& addrs) {
- std::vector<std::array<uint8_t, 6>> legacy_addrs;
- for (const auto& addr : addrs) {
- legacy_addrs.push_back(addr);
- }
- legacy_hal::wifi_error legacy_status =
- legacy_hal_.lock()->cancelRttRangeRequest(cmd_id, legacy_addrs);
- return createWifiStatusFromLegacyError(legacy_status);
+ std::vector<std::array<uint8_t, 6>> legacy_addrs;
+ for (const auto& addr : addrs) {
+ legacy_addrs.push_back(addr);
+ }
+ legacy_hal::wifi_error legacy_status =
+ legacy_hal_.lock()->cancelRttRangeRequest(ifname_, cmd_id,
+ legacy_addrs);
+ return createWifiStatusFromLegacyError(legacy_status);
}
std::pair<WifiStatus, RttCapabilities>
WifiRttController::getCapabilitiesInternal() {
- legacy_hal::wifi_error legacy_status;
- legacy_hal::wifi_rtt_capabilities legacy_caps;
- std::tie(legacy_status, legacy_caps) =
- legacy_hal_.lock()->getRttCapabilities();
- if (legacy_status != legacy_hal::WIFI_SUCCESS) {
- return {createWifiStatusFromLegacyError(legacy_status), {}};
- }
- RttCapabilities hidl_caps;
- if (!hidl_struct_util::convertLegacyRttCapabilitiesToHidl(legacy_caps,
- &hidl_caps)) {
- return {createWifiStatus(WifiStatusCode::ERROR_UNKNOWN), {}};
- }
- return {createWifiStatus(WifiStatusCode::SUCCESS), hidl_caps};
+ legacy_hal::wifi_error legacy_status;
+ legacy_hal::wifi_rtt_capabilities legacy_caps;
+ std::tie(legacy_status, legacy_caps) =
+ legacy_hal_.lock()->getRttCapabilities(ifname_);
+ if (legacy_status != legacy_hal::WIFI_SUCCESS) {
+ return {createWifiStatusFromLegacyError(legacy_status), {}};
+ }
+ RttCapabilities hidl_caps;
+ if (!hidl_struct_util::convertLegacyRttCapabilitiesToHidl(legacy_caps,
+ &hidl_caps)) {
+ return {createWifiStatus(WifiStatusCode::ERROR_UNKNOWN), {}};
+ }
+ return {createWifiStatus(WifiStatusCode::SUCCESS), hidl_caps};
}
WifiStatus WifiRttController::setLciInternal(uint32_t cmd_id,
const RttLciInformation& lci) {
- legacy_hal::wifi_lci_information legacy_lci;
- if (!hidl_struct_util::convertHidlRttLciInformationToLegacy(lci,
- &legacy_lci)) {
- return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
- }
- legacy_hal::wifi_error legacy_status =
- legacy_hal_.lock()->setRttLci(cmd_id, legacy_lci);
- return createWifiStatusFromLegacyError(legacy_status);
+ legacy_hal::wifi_lci_information legacy_lci;
+ if (!hidl_struct_util::convertHidlRttLciInformationToLegacy(lci,
+ &legacy_lci)) {
+ return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
+ }
+ legacy_hal::wifi_error legacy_status =
+ legacy_hal_.lock()->setRttLci(ifname_, cmd_id, legacy_lci);
+ return createWifiStatusFromLegacyError(legacy_status);
}
WifiStatus WifiRttController::setLcrInternal(uint32_t cmd_id,
const RttLcrInformation& lcr) {
- legacy_hal::wifi_lcr_information legacy_lcr;
- if (!hidl_struct_util::convertHidlRttLcrInformationToLegacy(lcr,
- &legacy_lcr)) {
- return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
- }
- legacy_hal::wifi_error legacy_status =
- legacy_hal_.lock()->setRttLcr(cmd_id, legacy_lcr);
- return createWifiStatusFromLegacyError(legacy_status);
+ legacy_hal::wifi_lcr_information legacy_lcr;
+ if (!hidl_struct_util::convertHidlRttLcrInformationToLegacy(lcr,
+ &legacy_lcr)) {
+ return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
+ }
+ legacy_hal::wifi_error legacy_status =
+ legacy_hal_.lock()->setRttLcr(ifname_, cmd_id, legacy_lcr);
+ return createWifiStatusFromLegacyError(legacy_status);
}
std::pair<WifiStatus, RttResponder>
WifiRttController::getResponderInfoInternal() {
- legacy_hal::wifi_error legacy_status;
- legacy_hal::wifi_rtt_responder legacy_responder;
- std::tie(legacy_status, legacy_responder) =
- legacy_hal_.lock()->getRttResponderInfo();
- if (legacy_status != legacy_hal::WIFI_SUCCESS) {
- return {createWifiStatusFromLegacyError(legacy_status), {}};
- }
- RttResponder hidl_responder;
- if (!hidl_struct_util::convertLegacyRttResponderToHidl(legacy_responder,
- &hidl_responder)) {
- return {createWifiStatus(WifiStatusCode::ERROR_UNKNOWN), {}};
- }
- return {createWifiStatus(WifiStatusCode::SUCCESS), hidl_responder};
+ legacy_hal::wifi_error legacy_status;
+ legacy_hal::wifi_rtt_responder legacy_responder;
+ std::tie(legacy_status, legacy_responder) =
+ legacy_hal_.lock()->getRttResponderInfo(ifname_);
+ if (legacy_status != legacy_hal::WIFI_SUCCESS) {
+ return {createWifiStatusFromLegacyError(legacy_status), {}};
+ }
+ RttResponder hidl_responder;
+ if (!hidl_struct_util::convertLegacyRttResponderToHidl(legacy_responder,
+ &hidl_responder)) {
+ return {createWifiStatus(WifiStatusCode::ERROR_UNKNOWN), {}};
+ }
+ return {createWifiStatus(WifiStatusCode::SUCCESS), hidl_responder};
}
WifiStatus WifiRttController::enableResponderInternal(
- uint32_t cmd_id,
- const WifiChannelInfo& channel_hint,
- uint32_t max_duration_seconds,
- const RttResponder& info) {
- legacy_hal::wifi_channel_info legacy_channel_info;
- if (!hidl_struct_util::convertHidlWifiChannelInfoToLegacy(
- channel_hint, &legacy_channel_info)) {
- return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
- }
- legacy_hal::wifi_rtt_responder legacy_responder;
- if (!hidl_struct_util::convertHidlRttResponderToLegacy(info,
- &legacy_responder)) {
- return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
- }
- legacy_hal::wifi_error legacy_status = legacy_hal_.lock()->enableRttResponder(
- cmd_id, legacy_channel_info, max_duration_seconds, legacy_responder);
- return createWifiStatusFromLegacyError(legacy_status);
+ uint32_t cmd_id, const WifiChannelInfo& channel_hint,
+ uint32_t max_duration_seconds, const RttResponder& info) {
+ legacy_hal::wifi_channel_info legacy_channel_info;
+ if (!hidl_struct_util::convertHidlWifiChannelInfoToLegacy(
+ channel_hint, &legacy_channel_info)) {
+ return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
+ }
+ legacy_hal::wifi_rtt_responder legacy_responder;
+ if (!hidl_struct_util::convertHidlRttResponderToLegacy(info,
+ &legacy_responder)) {
+ return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
+ }
+ legacy_hal::wifi_error legacy_status =
+ legacy_hal_.lock()->enableRttResponder(
+ ifname_, cmd_id, legacy_channel_info, max_duration_seconds,
+ legacy_responder);
+ return createWifiStatusFromLegacyError(legacy_status);
}
WifiStatus WifiRttController::disableResponderInternal(uint32_t cmd_id) {
- legacy_hal::wifi_error legacy_status =
- legacy_hal_.lock()->disableRttResponder(cmd_id);
- return createWifiStatusFromLegacyError(legacy_status);
+ legacy_hal::wifi_error legacy_status =
+ legacy_hal_.lock()->disableRttResponder(ifname_, cmd_id);
+ return createWifiStatusFromLegacyError(legacy_status);
}
} // namespace implementation
} // namespace V1_2
diff --git a/wifi/1.2/default/wifi_rtt_controller.h b/wifi/1.2/default/wifi_rtt_controller.h
index f1a55da..1ab01e1 100644
--- a/wifi/1.2/default/wifi_rtt_controller.h
+++ b/wifi/1.2/default/wifi_rtt_controller.h
@@ -34,66 +34,66 @@
* HIDL interface object used to control all RTT operations.
*/
class WifiRttController : public V1_0::IWifiRttController {
- public:
- WifiRttController(const sp<IWifiIface>& bound_iface,
- const std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal);
- // Refer to |WifiChip::invalidate()|.
- void invalidate();
- bool isValid();
- std::vector<sp<IWifiRttControllerEventCallback>> getEventCallbacks();
+ public:
+ WifiRttController(
+ const std::string& iface_name, const sp<IWifiIface>& bound_iface,
+ const std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal);
+ // Refer to |WifiChip::invalidate()|.
+ void invalidate();
+ bool isValid();
+ std::vector<sp<IWifiRttControllerEventCallback>> getEventCallbacks();
- // HIDL methods exposed.
- Return<void> getBoundIface(getBoundIface_cb hidl_status_cb) override;
- Return<void> registerEventCallback(
- const sp<IWifiRttControllerEventCallback>& callback,
- registerEventCallback_cb hidl_status_cb) override;
- Return<void> rangeRequest(uint32_t cmd_id,
- const hidl_vec<RttConfig>& rtt_configs,
- rangeRequest_cb hidl_status_cb) override;
- Return<void> rangeCancel(uint32_t cmd_id,
- const hidl_vec<hidl_array<uint8_t, 6>>& addrs,
- rangeCancel_cb hidl_status_cb) override;
- Return<void> getCapabilities(getCapabilities_cb hidl_status_cb) override;
- Return<void> setLci(uint32_t cmd_id,
- const RttLciInformation& lci,
- setLci_cb hidl_status_cb) override;
- Return<void> setLcr(uint32_t cmd_id,
- const RttLcrInformation& lcr,
- setLcr_cb hidl_status_cb) override;
- Return<void> getResponderInfo(getResponderInfo_cb hidl_status_cb) override;
- Return<void> enableResponder(uint32_t cmd_id,
- const WifiChannelInfo& channel_hint,
- uint32_t max_duration_seconds,
- const RttResponder& info,
- enableResponder_cb hidl_status_cb) override;
- Return<void> disableResponder(uint32_t cmd_id,
- disableResponder_cb hidl_status_cb) override;
+ // HIDL methods exposed.
+ Return<void> getBoundIface(getBoundIface_cb hidl_status_cb) override;
+ Return<void> registerEventCallback(
+ const sp<IWifiRttControllerEventCallback>& callback,
+ registerEventCallback_cb hidl_status_cb) override;
+ Return<void> rangeRequest(uint32_t cmd_id,
+ const hidl_vec<RttConfig>& rtt_configs,
+ rangeRequest_cb hidl_status_cb) override;
+ Return<void> rangeCancel(uint32_t cmd_id,
+ const hidl_vec<hidl_array<uint8_t, 6>>& addrs,
+ rangeCancel_cb hidl_status_cb) override;
+ Return<void> getCapabilities(getCapabilities_cb hidl_status_cb) override;
+ Return<void> setLci(uint32_t cmd_id, const RttLciInformation& lci,
+ setLci_cb hidl_status_cb) override;
+ Return<void> setLcr(uint32_t cmd_id, const RttLcrInformation& lcr,
+ setLcr_cb hidl_status_cb) override;
+ Return<void> getResponderInfo(getResponderInfo_cb hidl_status_cb) override;
+ Return<void> enableResponder(uint32_t cmd_id,
+ const WifiChannelInfo& channel_hint,
+ uint32_t max_duration_seconds,
+ const RttResponder& info,
+ enableResponder_cb hidl_status_cb) override;
+ Return<void> disableResponder(uint32_t cmd_id,
+ disableResponder_cb hidl_status_cb) override;
- private:
- // Corresponding worker functions for the HIDL methods.
- std::pair<WifiStatus, sp<IWifiIface>> getBoundIfaceInternal();
- WifiStatus registerEventCallbackInternal(
- const sp<IWifiRttControllerEventCallback>& callback);
- WifiStatus rangeRequestInternal(uint32_t cmd_id,
- const std::vector<RttConfig>& rtt_configs);
- WifiStatus rangeCancelInternal(
- uint32_t cmd_id, const std::vector<hidl_array<uint8_t, 6>>& addrs);
- std::pair<WifiStatus, RttCapabilities> getCapabilitiesInternal();
- WifiStatus setLciInternal(uint32_t cmd_id, const RttLciInformation& lci);
- WifiStatus setLcrInternal(uint32_t cmd_id, const RttLcrInformation& lcr);
- std::pair<WifiStatus, RttResponder> getResponderInfoInternal();
- WifiStatus enableResponderInternal(uint32_t cmd_id,
- const WifiChannelInfo& channel_hint,
- uint32_t max_duration_seconds,
- const RttResponder& info);
- WifiStatus disableResponderInternal(uint32_t cmd_id);
+ private:
+ // Corresponding worker functions for the HIDL methods.
+ std::pair<WifiStatus, sp<IWifiIface>> getBoundIfaceInternal();
+ WifiStatus registerEventCallbackInternal(
+ const sp<IWifiRttControllerEventCallback>& callback);
+ WifiStatus rangeRequestInternal(uint32_t cmd_id,
+ const std::vector<RttConfig>& rtt_configs);
+ WifiStatus rangeCancelInternal(
+ uint32_t cmd_id, const std::vector<hidl_array<uint8_t, 6>>& addrs);
+ std::pair<WifiStatus, RttCapabilities> getCapabilitiesInternal();
+ WifiStatus setLciInternal(uint32_t cmd_id, const RttLciInformation& lci);
+ WifiStatus setLcrInternal(uint32_t cmd_id, const RttLcrInformation& lcr);
+ std::pair<WifiStatus, RttResponder> getResponderInfoInternal();
+ WifiStatus enableResponderInternal(uint32_t cmd_id,
+ const WifiChannelInfo& channel_hint,
+ uint32_t max_duration_seconds,
+ const RttResponder& info);
+ WifiStatus disableResponderInternal(uint32_t cmd_id);
- sp<IWifiIface> bound_iface_;
- std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal_;
- std::vector<sp<IWifiRttControllerEventCallback>> event_callbacks_;
- bool is_valid_;
+ std::string ifname_;
+ sp<IWifiIface> bound_iface_;
+ std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal_;
+ std::vector<sp<IWifiRttControllerEventCallback>> event_callbacks_;
+ bool is_valid_;
- DISALLOW_COPY_AND_ASSIGN(WifiRttController);
+ DISALLOW_COPY_AND_ASSIGN(WifiRttController);
};
} // namespace implementation
diff --git a/wifi/1.2/default/wifi_sta_iface.cpp b/wifi/1.2/default/wifi_sta_iface.cpp
index 3622805..c8605ee 100644
--- a/wifi/1.2/default/wifi_sta_iface.cpp
+++ b/wifi/1.2/default/wifi_sta_iface.cpp
@@ -32,594 +32,548 @@
const std::string& ifname,
const std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal)
: ifname_(ifname), legacy_hal_(legacy_hal), is_valid_(true) {
- // Turn on DFS channel usage for STA iface.
- legacy_hal::wifi_error legacy_status =
- legacy_hal_.lock()->setDfsFlag(true);
- if (legacy_status != legacy_hal::WIFI_SUCCESS) {
- LOG(ERROR) << "Failed to set DFS flag; DFS channels may be unavailable.";
- }
+ // Turn on DFS channel usage for STA iface.
+ legacy_hal::wifi_error legacy_status =
+ legacy_hal_.lock()->setDfsFlag(ifname_, true);
+ if (legacy_status != legacy_hal::WIFI_SUCCESS) {
+ LOG(ERROR)
+ << "Failed to set DFS flag; DFS channels may be unavailable.";
+ }
}
void WifiStaIface::invalidate() {
- legacy_hal_.reset();
- event_cb_handler_.invalidate();
- is_valid_ = false;
+ legacy_hal_.reset();
+ event_cb_handler_.invalidate();
+ is_valid_ = false;
}
-bool WifiStaIface::isValid() {
- return is_valid_;
-}
+bool WifiStaIface::isValid() { return is_valid_; }
std::set<sp<IWifiStaIfaceEventCallback>> WifiStaIface::getEventCallbacks() {
- return event_cb_handler_.getCallbacks();
+ return event_cb_handler_.getCallbacks();
}
Return<void> WifiStaIface::getName(getName_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
- &WifiStaIface::getNameInternal,
- hidl_status_cb);
+ return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
+ &WifiStaIface::getNameInternal, hidl_status_cb);
}
Return<void> WifiStaIface::getType(getType_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
- &WifiStaIface::getTypeInternal,
- hidl_status_cb);
+ return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
+ &WifiStaIface::getTypeInternal, hidl_status_cb);
}
Return<void> WifiStaIface::registerEventCallback(
const sp<IWifiStaIfaceEventCallback>& callback,
registerEventCallback_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
- &WifiStaIface::registerEventCallbackInternal,
- hidl_status_cb,
- callback);
+ return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
+ &WifiStaIface::registerEventCallbackInternal,
+ hidl_status_cb, callback);
}
Return<void> WifiStaIface::getCapabilities(getCapabilities_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
- &WifiStaIface::getCapabilitiesInternal,
- hidl_status_cb);
+ return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
+ &WifiStaIface::getCapabilitiesInternal,
+ hidl_status_cb);
}
Return<void> WifiStaIface::getApfPacketFilterCapabilities(
getApfPacketFilterCapabilities_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
- &WifiStaIface::getApfPacketFilterCapabilitiesInternal,
- hidl_status_cb);
+ return validateAndCall(
+ this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
+ &WifiStaIface::getApfPacketFilterCapabilitiesInternal, hidl_status_cb);
}
Return<void> WifiStaIface::installApfPacketFilter(
- uint32_t cmd_id,
- const hidl_vec<uint8_t>& program,
+ uint32_t cmd_id, const hidl_vec<uint8_t>& program,
installApfPacketFilter_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
- &WifiStaIface::installApfPacketFilterInternal,
- hidl_status_cb,
- cmd_id,
- program);
+ return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
+ &WifiStaIface::installApfPacketFilterInternal,
+ hidl_status_cb, cmd_id, program);
}
Return<void> WifiStaIface::getBackgroundScanCapabilities(
getBackgroundScanCapabilities_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
- &WifiStaIface::getBackgroundScanCapabilitiesInternal,
- hidl_status_cb);
+ return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
+ &WifiStaIface::getBackgroundScanCapabilitiesInternal,
+ hidl_status_cb);
}
Return<void> WifiStaIface::getValidFrequenciesForBand(
WifiBand band, getValidFrequenciesForBand_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
- &WifiStaIface::getValidFrequenciesForBandInternal,
- hidl_status_cb,
- band);
+ return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
+ &WifiStaIface::getValidFrequenciesForBandInternal,
+ hidl_status_cb, band);
}
Return<void> WifiStaIface::startBackgroundScan(
- uint32_t cmd_id,
- const StaBackgroundScanParameters& params,
+ uint32_t cmd_id, const StaBackgroundScanParameters& params,
startBackgroundScan_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
- &WifiStaIface::startBackgroundScanInternal,
- hidl_status_cb,
- cmd_id,
- params);
+ return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
+ &WifiStaIface::startBackgroundScanInternal,
+ hidl_status_cb, cmd_id, params);
}
Return<void> WifiStaIface::stopBackgroundScan(
uint32_t cmd_id, stopBackgroundScan_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
- &WifiStaIface::stopBackgroundScanInternal,
- hidl_status_cb,
- cmd_id);
+ return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
+ &WifiStaIface::stopBackgroundScanInternal,
+ hidl_status_cb, cmd_id);
}
Return<void> WifiStaIface::enableLinkLayerStatsCollection(
bool debug, enableLinkLayerStatsCollection_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
- &WifiStaIface::enableLinkLayerStatsCollectionInternal,
- hidl_status_cb,
- debug);
+ return validateAndCall(
+ this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
+ &WifiStaIface::enableLinkLayerStatsCollectionInternal, hidl_status_cb,
+ debug);
}
Return<void> WifiStaIface::disableLinkLayerStatsCollection(
disableLinkLayerStatsCollection_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
- &WifiStaIface::disableLinkLayerStatsCollectionInternal,
- hidl_status_cb);
+ return validateAndCall(
+ this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
+ &WifiStaIface::disableLinkLayerStatsCollectionInternal, hidl_status_cb);
}
Return<void> WifiStaIface::getLinkLayerStats(
getLinkLayerStats_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
- &WifiStaIface::getLinkLayerStatsInternal,
- hidl_status_cb);
+ return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
+ &WifiStaIface::getLinkLayerStatsInternal,
+ hidl_status_cb);
}
Return<void> WifiStaIface::startRssiMonitoring(
- uint32_t cmd_id,
- int32_t max_rssi,
- int32_t min_rssi,
+ uint32_t cmd_id, int32_t max_rssi, int32_t min_rssi,
startRssiMonitoring_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
- &WifiStaIface::startRssiMonitoringInternal,
- hidl_status_cb,
- cmd_id,
- max_rssi,
- min_rssi);
+ return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
+ &WifiStaIface::startRssiMonitoringInternal,
+ hidl_status_cb, cmd_id, max_rssi, min_rssi);
}
Return<void> WifiStaIface::stopRssiMonitoring(
uint32_t cmd_id, stopRssiMonitoring_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
- &WifiStaIface::stopRssiMonitoringInternal,
- hidl_status_cb,
- cmd_id);
+ return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
+ &WifiStaIface::stopRssiMonitoringInternal,
+ hidl_status_cb, cmd_id);
}
Return<void> WifiStaIface::getRoamingCapabilities(
getRoamingCapabilities_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
- &WifiStaIface::getRoamingCapabilitiesInternal,
- hidl_status_cb);
+ return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
+ &WifiStaIface::getRoamingCapabilitiesInternal,
+ hidl_status_cb);
}
Return<void> WifiStaIface::configureRoaming(
const StaRoamingConfig& config, configureRoaming_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
- &WifiStaIface::configureRoamingInternal,
- hidl_status_cb,
- config);
+ return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
+ &WifiStaIface::configureRoamingInternal,
+ hidl_status_cb, config);
}
Return<void> WifiStaIface::setRoamingState(StaRoamingState state,
setRoamingState_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
- &WifiStaIface::setRoamingStateInternal,
- hidl_status_cb,
- state);
+ return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
+ &WifiStaIface::setRoamingStateInternal,
+ hidl_status_cb, state);
}
Return<void> WifiStaIface::enableNdOffload(bool enable,
enableNdOffload_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
- &WifiStaIface::enableNdOffloadInternal,
- hidl_status_cb,
- enable);
+ return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
+ &WifiStaIface::enableNdOffloadInternal,
+ hidl_status_cb, enable);
}
Return<void> WifiStaIface::startSendingKeepAlivePackets(
- uint32_t cmd_id,
- const hidl_vec<uint8_t>& ip_packet_data,
- uint16_t ether_type,
- const hidl_array<uint8_t, 6>& src_address,
- const hidl_array<uint8_t, 6>& dst_address,
- uint32_t period_in_ms,
+ uint32_t cmd_id, const hidl_vec<uint8_t>& ip_packet_data,
+ uint16_t ether_type, const hidl_array<uint8_t, 6>& src_address,
+ const hidl_array<uint8_t, 6>& dst_address, uint32_t period_in_ms,
startSendingKeepAlivePackets_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
- &WifiStaIface::startSendingKeepAlivePacketsInternal,
- hidl_status_cb,
- cmd_id,
- ip_packet_data,
- ether_type,
- src_address,
- dst_address,
- period_in_ms);
+ return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
+ &WifiStaIface::startSendingKeepAlivePacketsInternal,
+ hidl_status_cb, cmd_id, ip_packet_data, ether_type,
+ src_address, dst_address, period_in_ms);
}
Return<void> WifiStaIface::stopSendingKeepAlivePackets(
uint32_t cmd_id, stopSendingKeepAlivePackets_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
- &WifiStaIface::stopSendingKeepAlivePacketsInternal,
- hidl_status_cb,
- cmd_id);
+ return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
+ &WifiStaIface::stopSendingKeepAlivePacketsInternal,
+ hidl_status_cb, cmd_id);
}
Return<void> WifiStaIface::setScanningMacOui(
const hidl_array<uint8_t, 3>& oui, setScanningMacOui_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
- &WifiStaIface::setScanningMacOuiInternal,
- hidl_status_cb,
- oui);
+ return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
+ &WifiStaIface::setScanningMacOuiInternal,
+ hidl_status_cb, oui);
}
Return<void> WifiStaIface::startDebugPacketFateMonitoring(
startDebugPacketFateMonitoring_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
- &WifiStaIface::startDebugPacketFateMonitoringInternal,
- hidl_status_cb);
+ return validateAndCall(
+ this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
+ &WifiStaIface::startDebugPacketFateMonitoringInternal, hidl_status_cb);
}
Return<void> WifiStaIface::getDebugTxPacketFates(
getDebugTxPacketFates_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
- &WifiStaIface::getDebugTxPacketFatesInternal,
- hidl_status_cb);
+ return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
+ &WifiStaIface::getDebugTxPacketFatesInternal,
+ hidl_status_cb);
}
Return<void> WifiStaIface::getDebugRxPacketFates(
getDebugRxPacketFates_cb hidl_status_cb) {
- return validateAndCall(this,
- WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
- &WifiStaIface::getDebugRxPacketFatesInternal,
- hidl_status_cb);
+ return validateAndCall(this, WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
+ &WifiStaIface::getDebugRxPacketFatesInternal,
+ hidl_status_cb);
}
std::pair<WifiStatus, std::string> WifiStaIface::getNameInternal() {
- return {createWifiStatus(WifiStatusCode::SUCCESS), ifname_};
+ return {createWifiStatus(WifiStatusCode::SUCCESS), ifname_};
}
std::pair<WifiStatus, IfaceType> WifiStaIface::getTypeInternal() {
- return {createWifiStatus(WifiStatusCode::SUCCESS), IfaceType::STA};
+ return {createWifiStatus(WifiStatusCode::SUCCESS), IfaceType::STA};
}
WifiStatus WifiStaIface::registerEventCallbackInternal(
const sp<IWifiStaIfaceEventCallback>& callback) {
- if (!event_cb_handler_.addCallback(callback)) {
- return createWifiStatus(WifiStatusCode::ERROR_UNKNOWN);
- }
- return createWifiStatus(WifiStatusCode::SUCCESS);
+ if (!event_cb_handler_.addCallback(callback)) {
+ return createWifiStatus(WifiStatusCode::ERROR_UNKNOWN);
+ }
+ return createWifiStatus(WifiStatusCode::SUCCESS);
}
std::pair<WifiStatus, uint32_t> WifiStaIface::getCapabilitiesInternal() {
- legacy_hal::wifi_error legacy_status;
- uint32_t legacy_feature_set;
- std::tie(legacy_status, legacy_feature_set) =
- legacy_hal_.lock()->getSupportedFeatureSet();
- if (legacy_status != legacy_hal::WIFI_SUCCESS) {
- return {createWifiStatusFromLegacyError(legacy_status), 0};
- }
- uint32_t legacy_logger_feature_set;
- std::tie(legacy_status, legacy_logger_feature_set) =
- legacy_hal_.lock()->getLoggerSupportedFeatureSet();
- if (legacy_status != legacy_hal::WIFI_SUCCESS) {
- // some devices don't support querying logger feature set
- legacy_logger_feature_set = 0;
- }
- uint32_t hidl_caps;
- if (!hidl_struct_util::convertLegacyFeaturesToHidlStaCapabilities(
- legacy_feature_set, legacy_logger_feature_set, &hidl_caps)) {
- return {createWifiStatus(WifiStatusCode::ERROR_UNKNOWN), 0};
- }
- return {createWifiStatus(WifiStatusCode::SUCCESS), hidl_caps};
+ legacy_hal::wifi_error legacy_status;
+ uint32_t legacy_feature_set;
+ std::tie(legacy_status, legacy_feature_set) =
+ legacy_hal_.lock()->getSupportedFeatureSet(ifname_);
+ if (legacy_status != legacy_hal::WIFI_SUCCESS) {
+ return {createWifiStatusFromLegacyError(legacy_status), 0};
+ }
+ uint32_t legacy_logger_feature_set;
+ std::tie(legacy_status, legacy_logger_feature_set) =
+ legacy_hal_.lock()->getLoggerSupportedFeatureSet(ifname_);
+ if (legacy_status != legacy_hal::WIFI_SUCCESS) {
+ // some devices don't support querying logger feature set
+ legacy_logger_feature_set = 0;
+ }
+ uint32_t hidl_caps;
+ if (!hidl_struct_util::convertLegacyFeaturesToHidlStaCapabilities(
+ legacy_feature_set, legacy_logger_feature_set, &hidl_caps)) {
+ return {createWifiStatus(WifiStatusCode::ERROR_UNKNOWN), 0};
+ }
+ return {createWifiStatus(WifiStatusCode::SUCCESS), hidl_caps};
}
std::pair<WifiStatus, StaApfPacketFilterCapabilities>
WifiStaIface::getApfPacketFilterCapabilitiesInternal() {
- legacy_hal::wifi_error legacy_status;
- legacy_hal::PacketFilterCapabilities legacy_caps;
- std::tie(legacy_status, legacy_caps) =
- legacy_hal_.lock()->getPacketFilterCapabilities();
- if (legacy_status != legacy_hal::WIFI_SUCCESS) {
- return {createWifiStatusFromLegacyError(legacy_status), {}};
- }
- StaApfPacketFilterCapabilities hidl_caps;
- if (!hidl_struct_util::convertLegacyApfCapabilitiesToHidl(legacy_caps,
- &hidl_caps)) {
- return {createWifiStatus(WifiStatusCode::ERROR_UNKNOWN), {}};
- }
- return {createWifiStatus(WifiStatusCode::SUCCESS), hidl_caps};
+ legacy_hal::wifi_error legacy_status;
+ legacy_hal::PacketFilterCapabilities legacy_caps;
+ std::tie(legacy_status, legacy_caps) =
+ legacy_hal_.lock()->getPacketFilterCapabilities(ifname_);
+ if (legacy_status != legacy_hal::WIFI_SUCCESS) {
+ return {createWifiStatusFromLegacyError(legacy_status), {}};
+ }
+ StaApfPacketFilterCapabilities hidl_caps;
+ if (!hidl_struct_util::convertLegacyApfCapabilitiesToHidl(legacy_caps,
+ &hidl_caps)) {
+ return {createWifiStatus(WifiStatusCode::ERROR_UNKNOWN), {}};
+ }
+ return {createWifiStatus(WifiStatusCode::SUCCESS), hidl_caps};
}
WifiStatus WifiStaIface::installApfPacketFilterInternal(
uint32_t /* cmd_id */, const std::vector<uint8_t>& program) {
- legacy_hal::wifi_error legacy_status =
- legacy_hal_.lock()->setPacketFilter(program);
- return createWifiStatusFromLegacyError(legacy_status);
+ legacy_hal::wifi_error legacy_status =
+ legacy_hal_.lock()->setPacketFilter(ifname_, program);
+ return createWifiStatusFromLegacyError(legacy_status);
}
std::pair<WifiStatus, StaBackgroundScanCapabilities>
WifiStaIface::getBackgroundScanCapabilitiesInternal() {
- legacy_hal::wifi_error legacy_status;
- legacy_hal::wifi_gscan_capabilities legacy_caps;
- std::tie(legacy_status, legacy_caps) =
- legacy_hal_.lock()->getGscanCapabilities();
- if (legacy_status != legacy_hal::WIFI_SUCCESS) {
- return {createWifiStatusFromLegacyError(legacy_status), {}};
- }
- StaBackgroundScanCapabilities hidl_caps;
- if (!hidl_struct_util::convertLegacyGscanCapabilitiesToHidl(legacy_caps,
- &hidl_caps)) {
- return {createWifiStatus(WifiStatusCode::ERROR_UNKNOWN), {}};
- }
- return {createWifiStatus(WifiStatusCode::SUCCESS), hidl_caps};
+ legacy_hal::wifi_error legacy_status;
+ legacy_hal::wifi_gscan_capabilities legacy_caps;
+ std::tie(legacy_status, legacy_caps) =
+ legacy_hal_.lock()->getGscanCapabilities(ifname_);
+ if (legacy_status != legacy_hal::WIFI_SUCCESS) {
+ return {createWifiStatusFromLegacyError(legacy_status), {}};
+ }
+ StaBackgroundScanCapabilities hidl_caps;
+ if (!hidl_struct_util::convertLegacyGscanCapabilitiesToHidl(legacy_caps,
+ &hidl_caps)) {
+ return {createWifiStatus(WifiStatusCode::ERROR_UNKNOWN), {}};
+ }
+ return {createWifiStatus(WifiStatusCode::SUCCESS), hidl_caps};
}
std::pair<WifiStatus, std::vector<WifiChannelInMhz>>
WifiStaIface::getValidFrequenciesForBandInternal(WifiBand band) {
- static_assert(sizeof(WifiChannelInMhz) == sizeof(uint32_t), "Size mismatch");
- legacy_hal::wifi_error legacy_status;
- std::vector<uint32_t> valid_frequencies;
- std::tie(legacy_status, valid_frequencies) =
- legacy_hal_.lock()->getValidFrequenciesForBand(
- hidl_struct_util::convertHidlWifiBandToLegacy(band));
- return {createWifiStatusFromLegacyError(legacy_status), valid_frequencies};
+ static_assert(sizeof(WifiChannelInMhz) == sizeof(uint32_t),
+ "Size mismatch");
+ legacy_hal::wifi_error legacy_status;
+ std::vector<uint32_t> valid_frequencies;
+ std::tie(legacy_status, valid_frequencies) =
+ legacy_hal_.lock()->getValidFrequenciesForBand(
+ ifname_, hidl_struct_util::convertHidlWifiBandToLegacy(band));
+ return {createWifiStatusFromLegacyError(legacy_status), valid_frequencies};
}
WifiStatus WifiStaIface::startBackgroundScanInternal(
uint32_t cmd_id, const StaBackgroundScanParameters& params) {
- legacy_hal::wifi_scan_cmd_params legacy_params;
- if (!hidl_struct_util::convertHidlGscanParamsToLegacy(params,
- &legacy_params)) {
- return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
- }
- android::wp<WifiStaIface> weak_ptr_this(this);
- const auto& on_failure_callback =
- [weak_ptr_this](legacy_hal::wifi_request_id id) {
+ legacy_hal::wifi_scan_cmd_params legacy_params;
+ if (!hidl_struct_util::convertHidlGscanParamsToLegacy(params,
+ &legacy_params)) {
+ return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
+ }
+ android::wp<WifiStaIface> weak_ptr_this(this);
+ const auto& on_failure_callback =
+ [weak_ptr_this](legacy_hal::wifi_request_id id) {
+ const auto shared_ptr_this = weak_ptr_this.promote();
+ if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
+ LOG(ERROR) << "Callback invoked on an invalid object";
+ return;
+ }
+ for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
+ if (!callback->onBackgroundScanFailure(id).isOk()) {
+ LOG(ERROR)
+ << "Failed to invoke onBackgroundScanFailure callback";
+ }
+ }
+ };
+ const auto& on_results_callback =
+ [weak_ptr_this](
+ legacy_hal::wifi_request_id id,
+ const std::vector<legacy_hal::wifi_cached_scan_results>& results) {
+ const auto shared_ptr_this = weak_ptr_this.promote();
+ if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
+ LOG(ERROR) << "Callback invoked on an invalid object";
+ return;
+ }
+ std::vector<StaScanData> hidl_scan_datas;
+ if (!hidl_struct_util::
+ convertLegacyVectorOfCachedGscanResultsToHidl(
+ results, &hidl_scan_datas)) {
+ LOG(ERROR) << "Failed to convert scan results to HIDL structs";
+ return;
+ }
+ for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
+ if (!callback->onBackgroundScanResults(id, hidl_scan_datas)
+ .isOk()) {
+ LOG(ERROR)
+ << "Failed to invoke onBackgroundScanResults callback";
+ }
+ }
+ };
+ const auto& on_full_result_callback = [weak_ptr_this](
+ legacy_hal::wifi_request_id id,
+ const legacy_hal::
+ wifi_scan_result* result,
+ uint32_t buckets_scanned) {
const auto shared_ptr_this = weak_ptr_this.promote();
if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
- LOG(ERROR) << "Callback invoked on an invalid object";
- return;
+ LOG(ERROR) << "Callback invoked on an invalid object";
+ return;
+ }
+ StaScanResult hidl_scan_result;
+ if (!hidl_struct_util::convertLegacyGscanResultToHidl(
+ *result, true, &hidl_scan_result)) {
+ LOG(ERROR) << "Failed to convert full scan results to HIDL structs";
+ return;
}
for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
- if (!callback->onBackgroundScanFailure(id).isOk()) {
- LOG(ERROR) << "Failed to invoke onBackgroundScanFailure callback";
- }
+ if (!callback
+ ->onBackgroundFullScanResult(id, buckets_scanned,
+ hidl_scan_result)
+ .isOk()) {
+ LOG(ERROR)
+ << "Failed to invoke onBackgroundFullScanResult callback";
+ }
}
- };
- const auto& on_results_callback = [weak_ptr_this](
- legacy_hal::wifi_request_id id,
- const std::vector<legacy_hal::wifi_cached_scan_results>& results) {
- const auto shared_ptr_this = weak_ptr_this.promote();
- if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
- LOG(ERROR) << "Callback invoked on an invalid object";
- return;
- }
- std::vector<StaScanData> hidl_scan_datas;
- if (!hidl_struct_util::convertLegacyVectorOfCachedGscanResultsToHidl(
- results, &hidl_scan_datas)) {
- LOG(ERROR) << "Failed to convert scan results to HIDL structs";
- return;
- }
- for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
- if (!callback->onBackgroundScanResults(id, hidl_scan_datas).isOk()) {
- LOG(ERROR) << "Failed to invoke onBackgroundScanResults callback";
- }
- }
- };
- const auto& on_full_result_callback = [weak_ptr_this](
- legacy_hal::wifi_request_id id,
- const legacy_hal::wifi_scan_result* result,
- uint32_t buckets_scanned) {
- const auto shared_ptr_this = weak_ptr_this.promote();
- if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
- LOG(ERROR) << "Callback invoked on an invalid object";
- return;
- }
- StaScanResult hidl_scan_result;
- if (!hidl_struct_util::convertLegacyGscanResultToHidl(
- *result, true, &hidl_scan_result)) {
- LOG(ERROR) << "Failed to convert full scan results to HIDL structs";
- return;
- }
- for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
- if (!callback->onBackgroundFullScanResult(
- id, buckets_scanned, hidl_scan_result).isOk()) {
- LOG(ERROR) << "Failed to invoke onBackgroundFullScanResult callback";
- }
- }
- };
- legacy_hal::wifi_error legacy_status =
- legacy_hal_.lock()->startGscan(cmd_id,
- legacy_params,
- on_failure_callback,
- on_results_callback,
- on_full_result_callback);
- return createWifiStatusFromLegacyError(legacy_status);
+ };
+ legacy_hal::wifi_error legacy_status = legacy_hal_.lock()->startGscan(
+ ifname_, cmd_id, legacy_params, on_failure_callback,
+ on_results_callback, on_full_result_callback);
+ return createWifiStatusFromLegacyError(legacy_status);
}
WifiStatus WifiStaIface::stopBackgroundScanInternal(uint32_t cmd_id) {
- legacy_hal::wifi_error legacy_status = legacy_hal_.lock()->stopGscan(cmd_id);
- return createWifiStatusFromLegacyError(legacy_status);
+ legacy_hal::wifi_error legacy_status =
+ legacy_hal_.lock()->stopGscan(ifname_, cmd_id);
+ return createWifiStatusFromLegacyError(legacy_status);
}
WifiStatus WifiStaIface::enableLinkLayerStatsCollectionInternal(bool debug) {
- legacy_hal::wifi_error legacy_status =
- legacy_hal_.lock()->enableLinkLayerStats(debug);
- return createWifiStatusFromLegacyError(legacy_status);
+ legacy_hal::wifi_error legacy_status =
+ legacy_hal_.lock()->enableLinkLayerStats(ifname_, debug);
+ return createWifiStatusFromLegacyError(legacy_status);
}
WifiStatus WifiStaIface::disableLinkLayerStatsCollectionInternal() {
- legacy_hal::wifi_error legacy_status =
- legacy_hal_.lock()->disableLinkLayerStats();
- return createWifiStatusFromLegacyError(legacy_status);
+ legacy_hal::wifi_error legacy_status =
+ legacy_hal_.lock()->disableLinkLayerStats(ifname_);
+ return createWifiStatusFromLegacyError(legacy_status);
}
std::pair<WifiStatus, StaLinkLayerStats>
WifiStaIface::getLinkLayerStatsInternal() {
- legacy_hal::wifi_error legacy_status;
- legacy_hal::LinkLayerStats legacy_stats;
- std::tie(legacy_status, legacy_stats) =
- legacy_hal_.lock()->getLinkLayerStats();
- if (legacy_status != legacy_hal::WIFI_SUCCESS) {
- return {createWifiStatusFromLegacyError(legacy_status), {}};
- }
- StaLinkLayerStats hidl_stats;
- if (!hidl_struct_util::convertLegacyLinkLayerStatsToHidl(legacy_stats,
- &hidl_stats)) {
- return {createWifiStatus(WifiStatusCode::ERROR_UNKNOWN), {}};
- }
- return {createWifiStatus(WifiStatusCode::SUCCESS), hidl_stats};
+ legacy_hal::wifi_error legacy_status;
+ legacy_hal::LinkLayerStats legacy_stats;
+ std::tie(legacy_status, legacy_stats) =
+ legacy_hal_.lock()->getLinkLayerStats(ifname_);
+ if (legacy_status != legacy_hal::WIFI_SUCCESS) {
+ return {createWifiStatusFromLegacyError(legacy_status), {}};
+ }
+ StaLinkLayerStats hidl_stats;
+ if (!hidl_struct_util::convertLegacyLinkLayerStatsToHidl(legacy_stats,
+ &hidl_stats)) {
+ return {createWifiStatus(WifiStatusCode::ERROR_UNKNOWN), {}};
+ }
+ return {createWifiStatus(WifiStatusCode::SUCCESS), hidl_stats};
}
WifiStatus WifiStaIface::startRssiMonitoringInternal(uint32_t cmd_id,
int32_t max_rssi,
int32_t min_rssi) {
- android::wp<WifiStaIface> weak_ptr_this(this);
- const auto& on_threshold_breached_callback = [weak_ptr_this](
- legacy_hal::wifi_request_id id,
- std::array<uint8_t, 6> bssid,
- int8_t rssi) {
- const auto shared_ptr_this = weak_ptr_this.promote();
- if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
- LOG(ERROR) << "Callback invoked on an invalid object";
- return;
- }
- for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
- if (!callback->onRssiThresholdBreached(id, bssid, rssi).isOk()) {
- LOG(ERROR) << "Failed to invoke onRssiThresholdBreached callback";
- }
- }
- };
- legacy_hal::wifi_error legacy_status =
- legacy_hal_.lock()->startRssiMonitoring(
- cmd_id, max_rssi, min_rssi, on_threshold_breached_callback);
- return createWifiStatusFromLegacyError(legacy_status);
+ android::wp<WifiStaIface> weak_ptr_this(this);
+ const auto& on_threshold_breached_callback =
+ [weak_ptr_this](legacy_hal::wifi_request_id id,
+ std::array<uint8_t, 6> bssid, int8_t rssi) {
+ const auto shared_ptr_this = weak_ptr_this.promote();
+ if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) {
+ LOG(ERROR) << "Callback invoked on an invalid object";
+ return;
+ }
+ for (const auto& callback : shared_ptr_this->getEventCallbacks()) {
+ if (!callback->onRssiThresholdBreached(id, bssid, rssi)
+ .isOk()) {
+ LOG(ERROR)
+ << "Failed to invoke onRssiThresholdBreached callback";
+ }
+ }
+ };
+ legacy_hal::wifi_error legacy_status =
+ legacy_hal_.lock()->startRssiMonitoring(ifname_, cmd_id, max_rssi,
+ min_rssi,
+ on_threshold_breached_callback);
+ return createWifiStatusFromLegacyError(legacy_status);
}
WifiStatus WifiStaIface::stopRssiMonitoringInternal(uint32_t cmd_id) {
- legacy_hal::wifi_error legacy_status =
- legacy_hal_.lock()->stopRssiMonitoring(cmd_id);
- return createWifiStatusFromLegacyError(legacy_status);
+ legacy_hal::wifi_error legacy_status =
+ legacy_hal_.lock()->stopRssiMonitoring(ifname_, cmd_id);
+ return createWifiStatusFromLegacyError(legacy_status);
}
std::pair<WifiStatus, StaRoamingCapabilities>
WifiStaIface::getRoamingCapabilitiesInternal() {
- legacy_hal::wifi_error legacy_status;
- legacy_hal::wifi_roaming_capabilities legacy_caps;
- std::tie(legacy_status, legacy_caps) =
- legacy_hal_.lock()->getRoamingCapabilities();
- if (legacy_status != legacy_hal::WIFI_SUCCESS) {
- return {createWifiStatusFromLegacyError(legacy_status), {}};
- }
- StaRoamingCapabilities hidl_caps;
- if (!hidl_struct_util::convertLegacyRoamingCapabilitiesToHidl(legacy_caps,
- &hidl_caps)) {
- return {createWifiStatus(WifiStatusCode::ERROR_UNKNOWN), {}};
- }
- return {createWifiStatus(WifiStatusCode::SUCCESS), hidl_caps};
+ legacy_hal::wifi_error legacy_status;
+ legacy_hal::wifi_roaming_capabilities legacy_caps;
+ std::tie(legacy_status, legacy_caps) =
+ legacy_hal_.lock()->getRoamingCapabilities(ifname_);
+ if (legacy_status != legacy_hal::WIFI_SUCCESS) {
+ return {createWifiStatusFromLegacyError(legacy_status), {}};
+ }
+ StaRoamingCapabilities hidl_caps;
+ if (!hidl_struct_util::convertLegacyRoamingCapabilitiesToHidl(legacy_caps,
+ &hidl_caps)) {
+ return {createWifiStatus(WifiStatusCode::ERROR_UNKNOWN), {}};
+ }
+ return {createWifiStatus(WifiStatusCode::SUCCESS), hidl_caps};
}
WifiStatus WifiStaIface::configureRoamingInternal(
const StaRoamingConfig& config) {
- legacy_hal::wifi_roaming_config legacy_config;
- if (!hidl_struct_util::convertHidlRoamingConfigToLegacy(config,
- &legacy_config)) {
- return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
- }
- legacy_hal::wifi_error legacy_status =
- legacy_hal_.lock()->configureRoaming(legacy_config);
- return createWifiStatusFromLegacyError(legacy_status);
+ legacy_hal::wifi_roaming_config legacy_config;
+ if (!hidl_struct_util::convertHidlRoamingConfigToLegacy(config,
+ &legacy_config)) {
+ return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
+ }
+ legacy_hal::wifi_error legacy_status =
+ legacy_hal_.lock()->configureRoaming(ifname_, legacy_config);
+ return createWifiStatusFromLegacyError(legacy_status);
}
WifiStatus WifiStaIface::setRoamingStateInternal(StaRoamingState state) {
- legacy_hal::wifi_error legacy_status =
- legacy_hal_.lock()->enableFirmwareRoaming(
- hidl_struct_util::convertHidlRoamingStateToLegacy(state));
- return createWifiStatusFromLegacyError(legacy_status);
+ legacy_hal::wifi_error legacy_status =
+ legacy_hal_.lock()->enableFirmwareRoaming(
+ ifname_, hidl_struct_util::convertHidlRoamingStateToLegacy(state));
+ return createWifiStatusFromLegacyError(legacy_status);
}
WifiStatus WifiStaIface::enableNdOffloadInternal(bool enable) {
- legacy_hal::wifi_error legacy_status =
- legacy_hal_.lock()->configureNdOffload(enable);
- return createWifiStatusFromLegacyError(legacy_status);
+ legacy_hal::wifi_error legacy_status =
+ legacy_hal_.lock()->configureNdOffload(ifname_, enable);
+ return createWifiStatusFromLegacyError(legacy_status);
}
WifiStatus WifiStaIface::startSendingKeepAlivePacketsInternal(
- uint32_t cmd_id,
- const std::vector<uint8_t>& ip_packet_data,
- uint16_t /* ether_type */,
- const std::array<uint8_t, 6>& src_address,
- const std::array<uint8_t, 6>& dst_address,
- uint32_t period_in_ms) {
- legacy_hal::wifi_error legacy_status =
- legacy_hal_.lock()->startSendingOffloadedPacket(
- cmd_id, ip_packet_data, src_address, dst_address, period_in_ms);
- return createWifiStatusFromLegacyError(legacy_status);
+ uint32_t cmd_id, const std::vector<uint8_t>& ip_packet_data,
+ uint16_t /* ether_type */, const std::array<uint8_t, 6>& src_address,
+ const std::array<uint8_t, 6>& dst_address, uint32_t period_in_ms) {
+ legacy_hal::wifi_error legacy_status =
+ legacy_hal_.lock()->startSendingOffloadedPacket(
+ ifname_, cmd_id, ip_packet_data, src_address, dst_address,
+ period_in_ms);
+ return createWifiStatusFromLegacyError(legacy_status);
}
WifiStatus WifiStaIface::stopSendingKeepAlivePacketsInternal(uint32_t cmd_id) {
- legacy_hal::wifi_error legacy_status =
- legacy_hal_.lock()->stopSendingOffloadedPacket(cmd_id);
- return createWifiStatusFromLegacyError(legacy_status);
+ legacy_hal::wifi_error legacy_status =
+ legacy_hal_.lock()->stopSendingOffloadedPacket(ifname_, cmd_id);
+ return createWifiStatusFromLegacyError(legacy_status);
}
WifiStatus WifiStaIface::setScanningMacOuiInternal(
const std::array<uint8_t, 3>& oui) {
- legacy_hal::wifi_error legacy_status =
- legacy_hal_.lock()->setScanningMacOui(oui);
- return createWifiStatusFromLegacyError(legacy_status);
+ legacy_hal::wifi_error legacy_status =
+ legacy_hal_.lock()->setScanningMacOui(ifname_, oui);
+ return createWifiStatusFromLegacyError(legacy_status);
}
WifiStatus WifiStaIface::startDebugPacketFateMonitoringInternal() {
- legacy_hal::wifi_error legacy_status =
- legacy_hal_.lock()->startPktFateMonitoring();
- return createWifiStatusFromLegacyError(legacy_status);
+ legacy_hal::wifi_error legacy_status =
+ legacy_hal_.lock()->startPktFateMonitoring(ifname_);
+ return createWifiStatusFromLegacyError(legacy_status);
}
std::pair<WifiStatus, std::vector<WifiDebugTxPacketFateReport>>
WifiStaIface::getDebugTxPacketFatesInternal() {
- legacy_hal::wifi_error legacy_status;
- std::vector<legacy_hal::wifi_tx_report> legacy_fates;
- std::tie(legacy_status, legacy_fates) = legacy_hal_.lock()->getTxPktFates();
- if (legacy_status != legacy_hal::WIFI_SUCCESS) {
- return {createWifiStatusFromLegacyError(legacy_status), {}};
- }
- std::vector<WifiDebugTxPacketFateReport> hidl_fates;
- if (!hidl_struct_util::convertLegacyVectorOfDebugTxPacketFateToHidl(
- legacy_fates, &hidl_fates)) {
- return {createWifiStatus(WifiStatusCode::ERROR_UNKNOWN), {}};
- }
- return {createWifiStatus(WifiStatusCode::SUCCESS), hidl_fates};
+ legacy_hal::wifi_error legacy_status;
+ std::vector<legacy_hal::wifi_tx_report> legacy_fates;
+ std::tie(legacy_status, legacy_fates) =
+ legacy_hal_.lock()->getTxPktFates(ifname_);
+ if (legacy_status != legacy_hal::WIFI_SUCCESS) {
+ return {createWifiStatusFromLegacyError(legacy_status), {}};
+ }
+ std::vector<WifiDebugTxPacketFateReport> hidl_fates;
+ if (!hidl_struct_util::convertLegacyVectorOfDebugTxPacketFateToHidl(
+ legacy_fates, &hidl_fates)) {
+ return {createWifiStatus(WifiStatusCode::ERROR_UNKNOWN), {}};
+ }
+ return {createWifiStatus(WifiStatusCode::SUCCESS), hidl_fates};
}
std::pair<WifiStatus, std::vector<WifiDebugRxPacketFateReport>>
WifiStaIface::getDebugRxPacketFatesInternal() {
- legacy_hal::wifi_error legacy_status;
- std::vector<legacy_hal::wifi_rx_report> legacy_fates;
- std::tie(legacy_status, legacy_fates) = legacy_hal_.lock()->getRxPktFates();
- if (legacy_status != legacy_hal::WIFI_SUCCESS) {
- return {createWifiStatusFromLegacyError(legacy_status), {}};
- }
- std::vector<WifiDebugRxPacketFateReport> hidl_fates;
- if (!hidl_struct_util::convertLegacyVectorOfDebugRxPacketFateToHidl(
- legacy_fates, &hidl_fates)) {
- return {createWifiStatus(WifiStatusCode::ERROR_UNKNOWN), {}};
- }
- return {createWifiStatus(WifiStatusCode::SUCCESS), hidl_fates};
+ legacy_hal::wifi_error legacy_status;
+ std::vector<legacy_hal::wifi_rx_report> legacy_fates;
+ std::tie(legacy_status, legacy_fates) =
+ legacy_hal_.lock()->getRxPktFates(ifname_);
+ if (legacy_status != legacy_hal::WIFI_SUCCESS) {
+ return {createWifiStatusFromLegacyError(legacy_status), {}};
+ }
+ std::vector<WifiDebugRxPacketFateReport> hidl_fates;
+ if (!hidl_struct_util::convertLegacyVectorOfDebugRxPacketFateToHidl(
+ legacy_fates, &hidl_fates)) {
+ return {createWifiStatus(WifiStatusCode::ERROR_UNKNOWN), {}};
+ }
+ return {createWifiStatus(WifiStatusCode::SUCCESS), hidl_fates};
}
} // namespace implementation
diff --git a/wifi/1.2/default/wifi_sta_iface.h b/wifi/1.2/default/wifi_sta_iface.h
index a8d11a7..6731864 100644
--- a/wifi/1.2/default/wifi_sta_iface.h
+++ b/wifi/1.2/default/wifi_sta_iface.h
@@ -35,128 +35,120 @@
* HIDL interface object used to control a STA Iface instance.
*/
class WifiStaIface : public V1_0::IWifiStaIface {
- public:
- WifiStaIface(const std::string& ifname,
- const std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal);
- // Refer to |WifiChip::invalidate()|.
- void invalidate();
- bool isValid();
- std::set<sp<IWifiStaIfaceEventCallback>> getEventCallbacks();
+ public:
+ WifiStaIface(const std::string& ifname,
+ const std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal);
+ // Refer to |WifiChip::invalidate()|.
+ void invalidate();
+ bool isValid();
+ std::set<sp<IWifiStaIfaceEventCallback>> getEventCallbacks();
- // HIDL methods exposed.
- Return<void> getName(getName_cb hidl_status_cb) override;
- Return<void> getType(getType_cb hidl_status_cb) override;
- Return<void> registerEventCallback(
- const sp<IWifiStaIfaceEventCallback>& callback,
- registerEventCallback_cb hidl_status_cb) override;
- Return<void> getCapabilities(getCapabilities_cb hidl_status_cb) override;
- Return<void> getApfPacketFilterCapabilities(
- getApfPacketFilterCapabilities_cb hidl_status_cb) override;
- Return<void> installApfPacketFilter(
- uint32_t cmd_id,
- const hidl_vec<uint8_t>& program,
- installApfPacketFilter_cb hidl_status_cb) override;
- Return<void> getBackgroundScanCapabilities(
- getBackgroundScanCapabilities_cb hidl_status_cb) override;
- Return<void> getValidFrequenciesForBand(
- WifiBand band, getValidFrequenciesForBand_cb hidl_status_cb) override;
- Return<void> startBackgroundScan(
- uint32_t cmd_id,
- const StaBackgroundScanParameters& params,
- startBackgroundScan_cb hidl_status_cb) override;
- Return<void> stopBackgroundScan(
- uint32_t cmd_id, stopBackgroundScan_cb hidl_status_cb) override;
- Return<void> enableLinkLayerStatsCollection(
- bool debug, enableLinkLayerStatsCollection_cb hidl_status_cb) override;
- Return<void> disableLinkLayerStatsCollection(
- disableLinkLayerStatsCollection_cb hidl_status_cb) override;
- Return<void> getLinkLayerStats(getLinkLayerStats_cb hidl_status_cb) override;
- Return<void> startRssiMonitoring(
- uint32_t cmd_id,
- int32_t max_rssi,
- int32_t min_rssi,
- startRssiMonitoring_cb hidl_status_cb) override;
- Return<void> stopRssiMonitoring(
- uint32_t cmd_id, stopRssiMonitoring_cb hidl_status_cb) override;
- Return<void> getRoamingCapabilities(
- getRoamingCapabilities_cb hidl_status_cb) override;
- Return<void> configureRoaming(const StaRoamingConfig& config,
- configureRoaming_cb hidl_status_cb) override;
- Return<void> setRoamingState(StaRoamingState state,
- setRoamingState_cb hidl_status_cb) override;
- Return<void> enableNdOffload(bool enable,
- enableNdOffload_cb hidl_status_cb) override;
- Return<void> startSendingKeepAlivePackets(
- uint32_t cmd_id,
- const hidl_vec<uint8_t>& ip_packet_data,
- uint16_t ether_type,
- const hidl_array<uint8_t, 6>& src_address,
- const hidl_array<uint8_t, 6>& dst_address,
- uint32_t period_in_ms,
- startSendingKeepAlivePackets_cb hidl_status_cb) override;
- Return<void> stopSendingKeepAlivePackets(
- uint32_t cmd_id, stopSendingKeepAlivePackets_cb hidl_status_cb) override;
- Return<void> setScanningMacOui(const hidl_array<uint8_t, 3>& oui,
- setScanningMacOui_cb hidl_status_cb) override;
- Return<void> startDebugPacketFateMonitoring(
- startDebugPacketFateMonitoring_cb hidl_status_cb) override;
- Return<void> getDebugTxPacketFates(
- getDebugTxPacketFates_cb hidl_status_cb) override;
- Return<void> getDebugRxPacketFates(
- getDebugRxPacketFates_cb hidl_status_cb) override;
+ // HIDL methods exposed.
+ Return<void> getName(getName_cb hidl_status_cb) override;
+ Return<void> getType(getType_cb hidl_status_cb) override;
+ Return<void> registerEventCallback(
+ const sp<IWifiStaIfaceEventCallback>& callback,
+ registerEventCallback_cb hidl_status_cb) override;
+ Return<void> getCapabilities(getCapabilities_cb hidl_status_cb) override;
+ Return<void> getApfPacketFilterCapabilities(
+ getApfPacketFilterCapabilities_cb hidl_status_cb) override;
+ Return<void> installApfPacketFilter(
+ uint32_t cmd_id, const hidl_vec<uint8_t>& program,
+ installApfPacketFilter_cb hidl_status_cb) override;
+ Return<void> getBackgroundScanCapabilities(
+ getBackgroundScanCapabilities_cb hidl_status_cb) override;
+ Return<void> getValidFrequenciesForBand(
+ WifiBand band, getValidFrequenciesForBand_cb hidl_status_cb) override;
+ Return<void> startBackgroundScan(
+ uint32_t cmd_id, const StaBackgroundScanParameters& params,
+ startBackgroundScan_cb hidl_status_cb) override;
+ Return<void> stopBackgroundScan(
+ uint32_t cmd_id, stopBackgroundScan_cb hidl_status_cb) override;
+ Return<void> enableLinkLayerStatsCollection(
+ bool debug, enableLinkLayerStatsCollection_cb hidl_status_cb) override;
+ Return<void> disableLinkLayerStatsCollection(
+ disableLinkLayerStatsCollection_cb hidl_status_cb) override;
+ Return<void> getLinkLayerStats(
+ getLinkLayerStats_cb hidl_status_cb) override;
+ Return<void> startRssiMonitoring(
+ uint32_t cmd_id, int32_t max_rssi, int32_t min_rssi,
+ startRssiMonitoring_cb hidl_status_cb) override;
+ Return<void> stopRssiMonitoring(
+ uint32_t cmd_id, stopRssiMonitoring_cb hidl_status_cb) override;
+ Return<void> getRoamingCapabilities(
+ getRoamingCapabilities_cb hidl_status_cb) override;
+ Return<void> configureRoaming(const StaRoamingConfig& config,
+ configureRoaming_cb hidl_status_cb) override;
+ Return<void> setRoamingState(StaRoamingState state,
+ setRoamingState_cb hidl_status_cb) override;
+ Return<void> enableNdOffload(bool enable,
+ enableNdOffload_cb hidl_status_cb) override;
+ Return<void> startSendingKeepAlivePackets(
+ uint32_t cmd_id, const hidl_vec<uint8_t>& ip_packet_data,
+ uint16_t ether_type, const hidl_array<uint8_t, 6>& src_address,
+ const hidl_array<uint8_t, 6>& dst_address, uint32_t period_in_ms,
+ startSendingKeepAlivePackets_cb hidl_status_cb) override;
+ Return<void> stopSendingKeepAlivePackets(
+ uint32_t cmd_id,
+ stopSendingKeepAlivePackets_cb hidl_status_cb) override;
+ Return<void> setScanningMacOui(
+ const hidl_array<uint8_t, 3>& oui,
+ setScanningMacOui_cb hidl_status_cb) override;
+ Return<void> startDebugPacketFateMonitoring(
+ startDebugPacketFateMonitoring_cb hidl_status_cb) override;
+ Return<void> getDebugTxPacketFates(
+ getDebugTxPacketFates_cb hidl_status_cb) override;
+ Return<void> getDebugRxPacketFates(
+ getDebugRxPacketFates_cb hidl_status_cb) override;
- private:
- // Corresponding worker functions for the HIDL methods.
- std::pair<WifiStatus, std::string> getNameInternal();
- std::pair<WifiStatus, IfaceType> getTypeInternal();
- WifiStatus registerEventCallbackInternal(
- const sp<IWifiStaIfaceEventCallback>& callback);
- std::pair<WifiStatus, uint32_t> getCapabilitiesInternal();
- std::pair<WifiStatus, StaApfPacketFilterCapabilities>
- getApfPacketFilterCapabilitiesInternal();
- WifiStatus installApfPacketFilterInternal(
- uint32_t cmd_id, const std::vector<uint8_t>& program);
- std::pair<WifiStatus, StaBackgroundScanCapabilities>
- getBackgroundScanCapabilitiesInternal();
- std::pair<WifiStatus, std::vector<WifiChannelInMhz>>
- getValidFrequenciesForBandInternal(WifiBand band);
- WifiStatus startBackgroundScanInternal(
- uint32_t cmd_id, const StaBackgroundScanParameters& params);
- WifiStatus stopBackgroundScanInternal(uint32_t cmd_id);
- WifiStatus enableLinkLayerStatsCollectionInternal(bool debug);
- WifiStatus disableLinkLayerStatsCollectionInternal();
- std::pair<WifiStatus, StaLinkLayerStats> getLinkLayerStatsInternal();
- WifiStatus startRssiMonitoringInternal(uint32_t cmd_id,
- int32_t max_rssi,
- int32_t min_rssi);
- WifiStatus stopRssiMonitoringInternal(uint32_t cmd_id);
- std::pair<WifiStatus, StaRoamingCapabilities>
- getRoamingCapabilitiesInternal();
- WifiStatus configureRoamingInternal(const StaRoamingConfig& config);
- WifiStatus setRoamingStateInternal(StaRoamingState state);
- WifiStatus enableNdOffloadInternal(bool enable);
- WifiStatus startSendingKeepAlivePacketsInternal(
- uint32_t cmd_id,
- const std::vector<uint8_t>& ip_packet_data,
- uint16_t ether_type,
- const std::array<uint8_t, 6>& src_address,
- const std::array<uint8_t, 6>& dst_address,
- uint32_t period_in_ms);
- WifiStatus stopSendingKeepAlivePacketsInternal(uint32_t cmd_id);
- WifiStatus setScanningMacOuiInternal(const std::array<uint8_t, 3>& oui);
- WifiStatus startDebugPacketFateMonitoringInternal();
- std::pair<WifiStatus, std::vector<WifiDebugTxPacketFateReport>>
- getDebugTxPacketFatesInternal();
- std::pair<WifiStatus, std::vector<WifiDebugRxPacketFateReport>>
- getDebugRxPacketFatesInternal();
+ private:
+ // Corresponding worker functions for the HIDL methods.
+ std::pair<WifiStatus, std::string> getNameInternal();
+ std::pair<WifiStatus, IfaceType> getTypeInternal();
+ WifiStatus registerEventCallbackInternal(
+ const sp<IWifiStaIfaceEventCallback>& callback);
+ std::pair<WifiStatus, uint32_t> getCapabilitiesInternal();
+ std::pair<WifiStatus, StaApfPacketFilterCapabilities>
+ getApfPacketFilterCapabilitiesInternal();
+ WifiStatus installApfPacketFilterInternal(
+ uint32_t cmd_id, const std::vector<uint8_t>& program);
+ std::pair<WifiStatus, StaBackgroundScanCapabilities>
+ getBackgroundScanCapabilitiesInternal();
+ std::pair<WifiStatus, std::vector<WifiChannelInMhz>>
+ getValidFrequenciesForBandInternal(WifiBand band);
+ WifiStatus startBackgroundScanInternal(
+ uint32_t cmd_id, const StaBackgroundScanParameters& params);
+ WifiStatus stopBackgroundScanInternal(uint32_t cmd_id);
+ WifiStatus enableLinkLayerStatsCollectionInternal(bool debug);
+ WifiStatus disableLinkLayerStatsCollectionInternal();
+ std::pair<WifiStatus, StaLinkLayerStats> getLinkLayerStatsInternal();
+ WifiStatus startRssiMonitoringInternal(uint32_t cmd_id, int32_t max_rssi,
+ int32_t min_rssi);
+ WifiStatus stopRssiMonitoringInternal(uint32_t cmd_id);
+ std::pair<WifiStatus, StaRoamingCapabilities>
+ getRoamingCapabilitiesInternal();
+ WifiStatus configureRoamingInternal(const StaRoamingConfig& config);
+ WifiStatus setRoamingStateInternal(StaRoamingState state);
+ WifiStatus enableNdOffloadInternal(bool enable);
+ WifiStatus startSendingKeepAlivePacketsInternal(
+ uint32_t cmd_id, const std::vector<uint8_t>& ip_packet_data,
+ uint16_t ether_type, const std::array<uint8_t, 6>& src_address,
+ const std::array<uint8_t, 6>& dst_address, uint32_t period_in_ms);
+ WifiStatus stopSendingKeepAlivePacketsInternal(uint32_t cmd_id);
+ WifiStatus setScanningMacOuiInternal(const std::array<uint8_t, 3>& oui);
+ WifiStatus startDebugPacketFateMonitoringInternal();
+ std::pair<WifiStatus, std::vector<WifiDebugTxPacketFateReport>>
+ getDebugTxPacketFatesInternal();
+ std::pair<WifiStatus, std::vector<WifiDebugRxPacketFateReport>>
+ getDebugRxPacketFatesInternal();
- std::string ifname_;
- std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal_;
- bool is_valid_;
- hidl_callback_util::HidlCallbackHandler<IWifiStaIfaceEventCallback>
- event_cb_handler_;
+ std::string ifname_;
+ std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal_;
+ bool is_valid_;
+ hidl_callback_util::HidlCallbackHandler<IWifiStaIfaceEventCallback>
+ event_cb_handler_;
- DISALLOW_COPY_AND_ASSIGN(WifiStaIface);
+ DISALLOW_COPY_AND_ASSIGN(WifiStaIface);
};
} // namespace implementation
diff --git a/wifi/1.2/default/wifi_status_util.cpp b/wifi/1.2/default/wifi_status_util.cpp
index 992eb10..dd37b6b 100644
--- a/wifi/1.2/default/wifi_status_util.cpp
+++ b/wifi/1.2/default/wifi_status_util.cpp
@@ -23,80 +23,80 @@
namespace implementation {
std::string legacyErrorToString(legacy_hal::wifi_error error) {
- switch (error) {
- case legacy_hal::WIFI_SUCCESS:
- return "SUCCESS";
- case legacy_hal::WIFI_ERROR_UNINITIALIZED:
- return "UNINITIALIZED";
- case legacy_hal::WIFI_ERROR_NOT_AVAILABLE:
- return "NOT_AVAILABLE";
- case legacy_hal::WIFI_ERROR_NOT_SUPPORTED:
- return "NOT_SUPPORTED";
- case legacy_hal::WIFI_ERROR_INVALID_ARGS:
- return "INVALID_ARGS";
- case legacy_hal::WIFI_ERROR_INVALID_REQUEST_ID:
- return "INVALID_REQUEST_ID";
- case legacy_hal::WIFI_ERROR_TIMED_OUT:
- return "TIMED_OUT";
- case legacy_hal::WIFI_ERROR_TOO_MANY_REQUESTS:
- return "TOO_MANY_REQUESTS";
- case legacy_hal::WIFI_ERROR_OUT_OF_MEMORY:
- return "OUT_OF_MEMORY";
- case legacy_hal::WIFI_ERROR_BUSY:
- return "BUSY";
- case legacy_hal::WIFI_ERROR_UNKNOWN:
- return "UNKNOWN";
- }
+ switch (error) {
+ case legacy_hal::WIFI_SUCCESS:
+ return "SUCCESS";
+ case legacy_hal::WIFI_ERROR_UNINITIALIZED:
+ return "UNINITIALIZED";
+ case legacy_hal::WIFI_ERROR_NOT_AVAILABLE:
+ return "NOT_AVAILABLE";
+ case legacy_hal::WIFI_ERROR_NOT_SUPPORTED:
+ return "NOT_SUPPORTED";
+ case legacy_hal::WIFI_ERROR_INVALID_ARGS:
+ return "INVALID_ARGS";
+ case legacy_hal::WIFI_ERROR_INVALID_REQUEST_ID:
+ return "INVALID_REQUEST_ID";
+ case legacy_hal::WIFI_ERROR_TIMED_OUT:
+ return "TIMED_OUT";
+ case legacy_hal::WIFI_ERROR_TOO_MANY_REQUESTS:
+ return "TOO_MANY_REQUESTS";
+ case legacy_hal::WIFI_ERROR_OUT_OF_MEMORY:
+ return "OUT_OF_MEMORY";
+ case legacy_hal::WIFI_ERROR_BUSY:
+ return "BUSY";
+ case legacy_hal::WIFI_ERROR_UNKNOWN:
+ return "UNKNOWN";
+ }
}
WifiStatus createWifiStatus(WifiStatusCode code,
const std::string& description) {
- return {code, description};
+ return {code, description};
}
WifiStatus createWifiStatus(WifiStatusCode code) {
- return createWifiStatus(code, "");
+ return createWifiStatus(code, "");
}
WifiStatus createWifiStatusFromLegacyError(legacy_hal::wifi_error error,
const std::string& desc) {
- switch (error) {
- case legacy_hal::WIFI_ERROR_UNINITIALIZED:
- case legacy_hal::WIFI_ERROR_NOT_AVAILABLE:
- return createWifiStatus(WifiStatusCode::ERROR_NOT_AVAILABLE, desc);
+ switch (error) {
+ case legacy_hal::WIFI_ERROR_UNINITIALIZED:
+ case legacy_hal::WIFI_ERROR_NOT_AVAILABLE:
+ return createWifiStatus(WifiStatusCode::ERROR_NOT_AVAILABLE, desc);
- case legacy_hal::WIFI_ERROR_NOT_SUPPORTED:
- return createWifiStatus(WifiStatusCode::ERROR_NOT_SUPPORTED, desc);
+ case legacy_hal::WIFI_ERROR_NOT_SUPPORTED:
+ return createWifiStatus(WifiStatusCode::ERROR_NOT_SUPPORTED, desc);
- case legacy_hal::WIFI_ERROR_INVALID_ARGS:
- case legacy_hal::WIFI_ERROR_INVALID_REQUEST_ID:
- return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS, desc);
+ case legacy_hal::WIFI_ERROR_INVALID_ARGS:
+ case legacy_hal::WIFI_ERROR_INVALID_REQUEST_ID:
+ return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS, desc);
- case legacy_hal::WIFI_ERROR_TIMED_OUT:
- return createWifiStatus(WifiStatusCode::ERROR_UNKNOWN,
- desc + ", timed out");
+ case legacy_hal::WIFI_ERROR_TIMED_OUT:
+ return createWifiStatus(WifiStatusCode::ERROR_UNKNOWN,
+ desc + ", timed out");
- case legacy_hal::WIFI_ERROR_TOO_MANY_REQUESTS:
- return createWifiStatus(WifiStatusCode::ERROR_UNKNOWN,
- desc + ", too many requests");
+ case legacy_hal::WIFI_ERROR_TOO_MANY_REQUESTS:
+ return createWifiStatus(WifiStatusCode::ERROR_UNKNOWN,
+ desc + ", too many requests");
- case legacy_hal::WIFI_ERROR_OUT_OF_MEMORY:
- return createWifiStatus(WifiStatusCode::ERROR_UNKNOWN,
- desc + ", out of memory");
+ case legacy_hal::WIFI_ERROR_OUT_OF_MEMORY:
+ return createWifiStatus(WifiStatusCode::ERROR_UNKNOWN,
+ desc + ", out of memory");
- case legacy_hal::WIFI_ERROR_BUSY:
- return createWifiStatus(WifiStatusCode::ERROR_BUSY);
+ case legacy_hal::WIFI_ERROR_BUSY:
+ return createWifiStatus(WifiStatusCode::ERROR_BUSY);
- case legacy_hal::WIFI_ERROR_NONE:
- return createWifiStatus(WifiStatusCode::SUCCESS, desc);
+ case legacy_hal::WIFI_ERROR_NONE:
+ return createWifiStatus(WifiStatusCode::SUCCESS, desc);
- case legacy_hal::WIFI_ERROR_UNKNOWN:
- return createWifiStatus(WifiStatusCode::ERROR_UNKNOWN, "unknown");
- }
+ case legacy_hal::WIFI_ERROR_UNKNOWN:
+ return createWifiStatus(WifiStatusCode::ERROR_UNKNOWN, "unknown");
+ }
}
WifiStatus createWifiStatusFromLegacyError(legacy_hal::wifi_error error) {
- return createWifiStatusFromLegacyError(error, "");
+ return createWifiStatusFromLegacyError(error, "");
}
} // namespace implementation