Merge changes from topic "fixCoexRestrictions"
* changes:
Add VTS test for IWifiChip::setCoexUnsafeChannels
[WifiCoex] Add enum for wifi coex restrictions
diff --git a/OWNERS b/OWNERS
index 433bbb7..3a1a038 100644
--- a/OWNERS
+++ b/OWNERS
@@ -1,9 +1,14 @@
per-file *.hal,*.aidl,OWNERS = set noparent
-per-file *.hal,*.aidl,OWNERS = elsk@google.com,malchev@google.com,smoreland@google.com
+per-file *.hal,*.aidl,OWNERS = devinmoore@google.com,elsk@google.com,malchev@google.com,smoreland@google.com
+# Android Native API Council
+devinmoore@google.com
elsk@google.com
-maco@google.com
malchev@google.com
smoreland@google.com
-yim@google.com # vts tests
-guangzhu@google.com # vts tests
+
+# historical/backup
+maco@google.com
+
+# vts tests
+guangzhu@google.com
diff --git a/audio/common/all-versions/default/HidlUtils.h b/audio/common/all-versions/default/HidlUtils.h
index c420a2f..a0bd1bc 100644
--- a/audio/common/all-versions/default/HidlUtils.h
+++ b/audio/common/all-versions/default/HidlUtils.h
@@ -76,19 +76,7 @@
const char* halDeviceAddress, DeviceAddress* device);
#endif
-#if MAJOR_VERSION <= 6
- // Temporary versions for compatibility with forks of the default implementation.
- // Will be removed, do not use!
- static status_t audioConfigFromHal(const audio_config_t& halConfig, AudioConfig* config) {
- return audioConfigFromHal(halConfig, false /*isInput--ignored*/, config);
- }
- static std::unique_ptr<audio_port_config[]> audioPortConfigsToHal(
- const hidl_vec<AudioPortConfig>& configs) {
- std::unique_ptr<audio_port_config[]> halConfigs;
- (void)audioPortConfigsToHal(configs, &halConfigs);
- return halConfigs;
- }
-#else // V7 and above
+#if MAJOR_VERSION >= 7
static status_t audioChannelMaskFromHal(audio_channel_mask_t halChannelMask, bool isInput,
AudioChannelMask* channelMask);
static status_t audioChannelMasksFromHal(const std::vector<std::string>& halChannelMasks,
@@ -138,7 +126,7 @@
struct audio_port_config_device_ext* device,
struct audio_port_config_mix_ext* mix,
struct audio_port_config_session_ext* session);
-#endif
+#endif // MAJOR_VERSION >= 7
// V4 and below have DeviceAddress defined in the 'core' interface.
// To avoid duplicating code, the implementations of deviceAddressTo/FromHal
diff --git a/memtrack/aidl/aidl_api/android.hardware.memtrack/current/android/hardware/memtrack/DeviceInfo.aidl b/automotive/audiocontrol/aidl/aidl_api/android.hardware.automotive.audiocontrol/current/android/hardware/automotive/audiocontrol/DuckingInfo.aidl
similarity index 84%
rename from memtrack/aidl/aidl_api/android.hardware.memtrack/current/android/hardware/memtrack/DeviceInfo.aidl
rename to automotive/audiocontrol/aidl/aidl_api/android.hardware.automotive.audiocontrol/current/android/hardware/automotive/audiocontrol/DuckingInfo.aidl
index 00abff9..6d729e2 100644
--- a/memtrack/aidl/aidl_api/android.hardware.memtrack/current/android/hardware/memtrack/DeviceInfo.aidl
+++ b/automotive/audiocontrol/aidl/aidl_api/android.hardware.automotive.audiocontrol/current/android/hardware/automotive/audiocontrol/DuckingInfo.aidl
@@ -15,9 +15,11 @@
// with such a backward incompatible change, it has a high risk of breaking
// later when a module using the interface is updated, e.g., Mainline modules.
-package android.hardware.memtrack;
+package android.hardware.automotive.audiocontrol;
@VintfStability
-parcelable DeviceInfo {
- int id;
- @utf8InCpp String name;
+parcelable DuckingInfo {
+ int zoneId;
+ String[] deviceAddressesToDuck;
+ String[] deviceAddressesToUnduck;
+ String[] usagesHoldingFocus;
}
diff --git a/automotive/audiocontrol/aidl/aidl_api/android.hardware.automotive.audiocontrol/current/android/hardware/automotive/audiocontrol/IAudioControl.aidl b/automotive/audiocontrol/aidl/aidl_api/android.hardware.automotive.audiocontrol/current/android/hardware/automotive/audiocontrol/IAudioControl.aidl
index 6916846..e5a0451 100644
--- a/automotive/audiocontrol/aidl/aidl_api/android.hardware.automotive.audiocontrol/current/android/hardware/automotive/audiocontrol/IAudioControl.aidl
+++ b/automotive/audiocontrol/aidl/aidl_api/android.hardware.automotive.audiocontrol/current/android/hardware/automotive/audiocontrol/IAudioControl.aidl
@@ -19,6 +19,7 @@
@VintfStability
interface IAudioControl {
oneway void onAudioFocusChange(in String usage, in int zoneId, in android.hardware.automotive.audiocontrol.AudioFocusChange focusChange);
+ oneway void onDevicesToDuckChange(in android.hardware.automotive.audiocontrol.DuckingInfo[] duckingInfos);
oneway void registerFocusListener(in android.hardware.automotive.audiocontrol.IFocusListener listener);
oneway void setBalanceTowardRight(in float value);
oneway void setFadeTowardFront(in float value);
diff --git a/automotive/audiocontrol/aidl/android/hardware/automotive/audiocontrol/DuckingInfo.aidl b/automotive/audiocontrol/aidl/android/hardware/automotive/audiocontrol/DuckingInfo.aidl
new file mode 100644
index 0000000..e95fe9b
--- /dev/null
+++ b/automotive/audiocontrol/aidl/android/hardware/automotive/audiocontrol/DuckingInfo.aidl
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2020 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.automotive.audiocontrol;
+
+ /**
+ * The current ducking information for a single audio zone.
+ *
+ * <p>This includes devices to duck, as well as unduck based on the contents of a previous
+ * {@link DuckingInfo}. Additionally, the current usages holding focus in the specified zone are
+ * included, which were used to determine which addresses to duck.
+ */
+ @VintfStability
+ parcelable DuckingInfo {
+ /**
+ * ID of the associated audio zone
+ */
+ int zoneId;
+
+ /**
+ * List of addresses for audio output devices that should be ducked.
+ *
+ * <p>The provided address strings are defined in audio_policy_configuration.xml.
+ */
+ String[] deviceAddressesToDuck;
+
+ /**
+ * List of addresses for audio output devices that were previously be ducked and should now be
+ * unducked.
+ *
+ * <p>The provided address strings are defined in audio_policy_configuration.xml.
+ */
+ String[] deviceAddressesToUnduck;
+
+ /**
+ * List of usages currently holding focus for this audio zone.
+ *
+ * <p> See {@code audioUsage} in audio_policy_configuration.xsd for the list of allowed values.
+ */
+ String[] usagesHoldingFocus;
+ }
\ No newline at end of file
diff --git a/automotive/audiocontrol/aidl/android/hardware/automotive/audiocontrol/IAudioControl.aidl b/automotive/audiocontrol/aidl/android/hardware/automotive/audiocontrol/IAudioControl.aidl
index 0641691..4b03af1 100644
--- a/automotive/audiocontrol/aidl/android/hardware/automotive/audiocontrol/IAudioControl.aidl
+++ b/automotive/audiocontrol/aidl/android/hardware/automotive/audiocontrol/IAudioControl.aidl
@@ -17,6 +17,7 @@
package android.hardware.automotive.audiocontrol;
import android.hardware.automotive.audiocontrol.AudioFocusChange;
+import android.hardware.automotive.audiocontrol.DuckingInfo;
import android.hardware.automotive.audiocontrol.IFocusListener;
/**
@@ -42,6 +43,17 @@
oneway void onAudioFocusChange(in String usage, in int zoneId, in AudioFocusChange focusChange);
/**
+ * Notifies HAL of changes in output devices that the HAL should apply ducking to.
+ *
+ * This will be called in response to changes in audio focus, and will include a
+ * {@link DuckingInfo} object per audio zone that experienced a change in audo focus.
+ *
+ * @param duckingInfos an array of {@link DuckingInfo} objects for the audio zones where audio
+ * focus has changed.
+ */
+ oneway void onDevicesToDuckChange(in DuckingInfo[] duckingInfos);
+
+ /**
* Registers focus listener to be used by HAL for requesting and abandoning audio focus.
*
* It is expected that there will only ever be a single focus listener registered. If the
diff --git a/automotive/audiocontrol/aidl/default/AudioControl.cpp b/automotive/audiocontrol/aidl/default/AudioControl.cpp
index 5e09b4f..748947c 100644
--- a/automotive/audiocontrol/aidl/default/AudioControl.cpp
+++ b/automotive/audiocontrol/aidl/default/AudioControl.cpp
@@ -17,6 +17,7 @@
#include "AudioControl.h"
#include <aidl/android/hardware/automotive/audiocontrol/AudioFocusChange.h>
+#include <aidl/android/hardware/automotive/audiocontrol/DuckingInfo.h>
#include <aidl/android/hardware/automotive/audiocontrol/IFocusListener.h>
#include <android-base/logging.h>
@@ -102,6 +103,27 @@
return ndk::ScopedAStatus::ok();
}
+ndk::ScopedAStatus AudioControl::onDevicesToDuckChange(
+ const std::vector<DuckingInfo>& in_duckingInfos) {
+ LOG(INFO) << "AudioControl::onDevicesToDuckChange";
+ for (const DuckingInfo& duckingInfo : in_duckingInfos) {
+ LOG(INFO) << "zone: " << duckingInfo.zoneId;
+ LOG(INFO) << "Devices to duck:";
+ for (auto& addressToDuck : duckingInfo.deviceAddressesToDuck) {
+ LOG(INFO) << addressToDuck;
+ }
+ LOG(INFO) << "Devices to unduck:";
+ for (auto& addressToUnduck : duckingInfo.deviceAddressesToUnduck) {
+ LOG(INFO) << addressToUnduck;
+ }
+ LOG(INFO) << "Usages holding focus:";
+ for (auto& usage : duckingInfo.usagesHoldingFocus) {
+ LOG(INFO) << usage;
+ }
+ }
+ return ndk::ScopedAStatus::ok();
+}
+
binder_status_t AudioControl::dump(int fd, const char** args, uint32_t numArgs) {
if (numArgs == 0) {
return dumpsys(fd);
diff --git a/automotive/audiocontrol/aidl/default/AudioControl.h b/automotive/audiocontrol/aidl/default/AudioControl.h
index a77da3e..cf56947 100644
--- a/automotive/audiocontrol/aidl/default/AudioControl.h
+++ b/automotive/audiocontrol/aidl/default/AudioControl.h
@@ -18,6 +18,7 @@
#include <aidl/android/hardware/automotive/audiocontrol/AudioFocusChange.h>
#include <aidl/android/hardware/automotive/audiocontrol/BnAudioControl.h>
+#include <aidl/android/hardware/automotive/audiocontrol/DuckingInfo.h>
namespace aidl::android::hardware::automotive::audiocontrol {
@@ -27,6 +28,8 @@
public:
ndk::ScopedAStatus onAudioFocusChange(const std::string& in_usage, int32_t in_zoneId,
AudioFocusChange in_focusChange) override;
+ ndk::ScopedAStatus onDevicesToDuckChange(
+ const std::vector<DuckingInfo>& in_duckingInfos) override;
ndk::ScopedAStatus registerFocusListener(
const shared_ptr<IFocusListener>& in_listener) override;
ndk::ScopedAStatus setBalanceTowardRight(float in_value) override;
diff --git a/automotive/audiocontrol/aidl/vts/VtsHalAudioControlTargetTest.cpp b/automotive/audiocontrol/aidl/vts/VtsHalAudioControlTargetTest.cpp
index f33b8a5..f23280d 100644
--- a/automotive/audiocontrol/aidl/vts/VtsHalAudioControlTargetTest.cpp
+++ b/automotive/audiocontrol/aidl/vts/VtsHalAudioControlTargetTest.cpp
@@ -31,6 +31,7 @@
using android::binder::Status;
using android::hardware::automotive::audiocontrol::AudioFocusChange;
using android::hardware::automotive::audiocontrol::BnFocusListener;
+using android::hardware::automotive::audiocontrol::DuckingInfo;
using android::hardware::automotive::audiocontrol::IAudioControl;
#include "android_audio_policy_configuration_V7_0.h"
@@ -129,6 +130,22 @@
audioControl->onAudioFocusChange(usage, 0, AudioFocusChange::GAIN_TRANSIENT).isOk());
};
+TEST_P(AudioControlAidl, DuckChangeExercise) {
+ ALOGI("Duck change test");
+
+ DuckingInfo duckingInfo;
+ duckingInfo.zoneId = 0;
+ duckingInfo.deviceAddressesToDuck = {String16("address 1"), String16("address 2")};
+ duckingInfo.deviceAddressesToUnduck = {String16("address 3"), String16("address 4")};
+ duckingInfo.usagesHoldingFocus = {
+ String16(xsd::toString(xsd::AudioUsage::AUDIO_USAGE_MEDIA).c_str()),
+ String16(xsd::toString(xsd::AudioUsage::AUDIO_USAGE_ASSISTANCE_NAVIGATION_GUIDANCE)
+ .c_str())};
+ std::vector<DuckingInfo> duckingInfos = {duckingInfo};
+ ALOGI("Duck change test start");
+ ASSERT_TRUE(audioControl->onDevicesToDuckChange(duckingInfos).isOk());
+}
+
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(AudioControlAidl);
INSTANTIATE_TEST_SUITE_P(
Audiocontrol, AudioControlAidl,
diff --git a/biometrics/face/aidl/default/Face.cpp b/biometrics/face/aidl/default/Face.cpp
index d3883d6..773359e 100644
--- a/biometrics/face/aidl/default/Face.cpp
+++ b/biometrics/face/aidl/default/Face.cpp
@@ -19,7 +19,7 @@
namespace aidl::android::hardware::biometrics::face {
-const int kSensorId = 0;
+const int kSensorId = 4;
const common::SensorStrength kSensorStrength = common::SensorStrength::STRONG;
const int kMaxEnrollmentsPerUser = 5;
const FaceSensorType kSensorType = FaceSensorType::RGB;
diff --git a/bluetooth/audio/2.1/default/BluetoothAudioProvider.cpp b/bluetooth/audio/2.1/default/BluetoothAudioProvider.cpp
index 092038b..73fe06c 100644
--- a/bluetooth/audio/2.1/default/BluetoothAudioProvider.cpp
+++ b/bluetooth/audio/2.1/default/BluetoothAudioProvider.cpp
@@ -57,14 +57,14 @@
if (audioConfig.getDiscriminator() ==
V2_0::AudioConfiguration::hidl_discriminator::pcmConfig) {
- audioConfig_2_1.pcmConfig() = {
+ audioConfig_2_1.pcmConfig({
.sampleRate =
static_cast<SampleRate>(audioConfig.pcmConfig().sampleRate),
.channelMode = audioConfig.pcmConfig().channelMode,
.bitsPerSample = audioConfig.pcmConfig().bitsPerSample,
- .dataIntervalUs = 0};
+ .dataIntervalUs = 0});
} else {
- audioConfig_2_1.codecConfig() = audioConfig.codecConfig();
+ audioConfig_2_1.codecConfig(audioConfig.codecConfig());
}
return startSession_2_1(hostIf, audioConfig_2_1, _hidl_cb);
diff --git a/common/TEST_MAPPING b/common/TEST_MAPPING
new file mode 100644
index 0000000..7dd29e5
--- /dev/null
+++ b/common/TEST_MAPPING
@@ -0,0 +1,7 @@
+{
+ "presubmit": [
+ {
+ "name": "libaidlcommonsupport_test"
+ }
+ ]
+}
diff --git a/common/support/Android.bp b/common/support/Android.bp
new file mode 100644
index 0000000..3bb4804
--- /dev/null
+++ b/common/support/Android.bp
@@ -0,0 +1,27 @@
+cc_library_static {
+ name: "libaidlcommonsupport",
+ vendor_available: true,
+ host_supported: true,
+ defaults: ["libbinder_ndk_host_user"],
+ srcs: ["NativeHandle.cpp"],
+ export_include_dirs: ["include"],
+ shared_libs: [
+ "android.hardware.common-unstable-ndk_platform",
+ "libcutils",
+ ],
+}
+
+cc_test {
+ name: "libaidlcommonsupport_test",
+ host_supported: true,
+ defaults: ["libbinder_ndk_host_user"],
+ srcs: ["test.cpp"],
+ static_libs: [
+ "libaidlcommonsupport",
+ ],
+ shared_libs: [
+ "android.hardware.common-unstable-ndk_platform",
+ "libcutils",
+ ],
+ test_suites: ["general-tests"],
+}
diff --git a/common/support/NativeHandle.cpp b/common/support/NativeHandle.cpp
new file mode 100644
index 0000000..321d7a8
--- /dev/null
+++ b/common/support/NativeHandle.cpp
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2020 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.
+ */
+
+#include <aidlcommonsupport/NativeHandle.h>
+
+#include <fcntl.h>
+
+namespace android {
+
+using aidl::android::hardware::common::NativeHandle;
+
+static native_handle_t* fromAidl(const NativeHandle& handle, bool doDup) {
+ native_handle_t* to = native_handle_create(handle.fds.size(), handle.ints.size());
+ if (!to) return nullptr;
+
+ for (size_t i = 0; i < handle.fds.size(); i++) {
+ int fd = handle.fds[i].get();
+ to->data[i] = doDup ? fcntl(fd, F_DUPFD_CLOEXEC, 0) : fd;
+ }
+ memcpy(to->data + handle.fds.size(), handle.ints.data(), handle.ints.size() * sizeof(int));
+ return to;
+}
+
+native_handle_t* makeFromAidl(const NativeHandle& handle) {
+ return fromAidl(handle, false /* doDup */);
+}
+native_handle_t* dupFromAidl(const NativeHandle& handle) {
+ return fromAidl(handle, true /* doDup */);
+}
+
+static NativeHandle toAidl(const native_handle_t* handle, bool doDup) {
+ NativeHandle to;
+
+ to.fds = std::vector<ndk::ScopedFileDescriptor>(handle->numFds);
+ for (size_t i = 0; i < handle->numFds; i++) {
+ int fd = handle->data[i];
+ to.fds.at(i).set(doDup ? fcntl(fd, F_DUPFD_CLOEXEC, 0) : fd);
+ }
+
+ to.ints = std::vector<int32_t>(handle->data + handle->numFds,
+ handle->data + handle->numFds + handle->numInts);
+ return to;
+}
+
+NativeHandle makeToAidl(const native_handle_t* handle) {
+ return toAidl(handle, false /* doDup */);
+}
+
+NativeHandle dupToAidl(const native_handle_t* handle) {
+ return toAidl(handle, true /* doDup */);
+}
+
+} // namespace android
diff --git a/common/support/include/aidlcommonsupport/NativeHandle.h b/common/support/include/aidlcommonsupport/NativeHandle.h
new file mode 100644
index 0000000..10eecba
--- /dev/null
+++ b/common/support/include/aidlcommonsupport/NativeHandle.h
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2020 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.
+ */
+
+#pragma once
+
+#include <aidl/android/hardware/common/NativeHandle.h>
+#include <cutils/native_handle.h>
+
+namespace android {
+
+/**
+ * Creates a libcutils native handle from an AIDL native handle, but it does not
+ * dup internally, so it will contain the same FDs as the handle itself. The
+ * result should be deleted with native_handle_delete.
+ */
+native_handle_t* makeFromAidl(const aidl::android::hardware::common::NativeHandle& handle);
+
+/**
+ * Creates a libcutils native handle from an AIDL native handle with a dup
+ * internally. It's expected the handle is cleaned up with native_handle_close
+ * and native_handle_delete.
+ */
+native_handle_t* dupFromAidl(const aidl::android::hardware::common::NativeHandle& handle);
+
+/**
+ * Creates an AIDL native handle from a libcutils native handle, but does not
+ * dup internally, so the result will contain the same FDs as the handle itself.
+ *
+ * Warning: this passes ownership of the FDs to the ScopedFileDescriptor
+ * objects.
+ */
+aidl::android::hardware::common::NativeHandle makeToAidl(const native_handle_t* handle);
+
+/**
+ * Creates an AIDL native handle from a libcutils native handle with a dup
+ * internally.
+ */
+aidl::android::hardware::common::NativeHandle dupToAidl(const native_handle_t* handle);
+
+} // namespace android
diff --git a/common/support/test.cpp b/common/support/test.cpp
new file mode 100644
index 0000000..2359277
--- /dev/null
+++ b/common/support/test.cpp
@@ -0,0 +1,138 @@
+/*
+ * Copyright (C) 2020 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.
+ */
+
+#include <aidlcommonsupport/NativeHandle.h>
+#include <gtest/gtest.h>
+
+namespace android {
+
+using aidl::android::hardware::common::NativeHandle;
+using ndk::ScopedFileDescriptor;
+
+static void checkEq(const NativeHandle& aidl, native_handle_t* libcutils, bool exceptFds) {
+ ASSERT_NE(libcutils, nullptr);
+ ASSERT_EQ(libcutils->numFds, aidl.fds.size());
+
+ for (size_t i = 0; i < libcutils->numFds; i++) {
+ int afd = aidl.fds.at(i).get();
+ int lfd = libcutils->data[i];
+
+ EXPECT_GE(afd, 0) << "Invalid fd at index " << i;
+ EXPECT_GE(lfd, 0) << "Invalid fd at index " << i;
+
+ if (exceptFds) {
+ EXPECT_NE(afd, lfd) << "Index matched at " << i << " but should be dup'd fd";
+ } else {
+ EXPECT_EQ(afd, lfd) << "Index mismatched at " << i << " but should be same fd";
+ }
+ }
+
+ ASSERT_EQ(libcutils->numInts, aidl.ints.size());
+
+ for (size_t i = 0; i < libcutils->numInts; i++) {
+ int afd = aidl.ints.at(i);
+ int lfd = libcutils->data[libcutils->numFds + i];
+
+ EXPECT_EQ(afd, lfd) << "Index mismatch at " << i;
+ }
+}
+
+static NativeHandle makeTestAidlHandle() {
+ NativeHandle handle = {
+ .fds = std::vector<ScopedFileDescriptor>(2),
+ .ints = {1, 2, 3, 4},
+ };
+ handle.fds[0].set(dup(0));
+ handle.fds[1].set(dup(0));
+ return handle;
+}
+
+TEST(ConvertNativeHandle, MakeFromAidlEmpty) {
+ NativeHandle handle;
+ native_handle_t* to = makeFromAidl(handle);
+ checkEq(handle, to, false /*exceptFds*/);
+ // no native_handle_close b/c fds are owned by NativeHandle
+ EXPECT_EQ(0, native_handle_delete(to));
+}
+
+TEST(ConvertNativeHandle, MakeFromAidl) {
+ NativeHandle handle = makeTestAidlHandle();
+ native_handle_t* to = makeFromAidl(handle);
+ checkEq(handle, to, false /*exceptFds*/);
+ // no native_handle_close b/c fds are owned by NativeHandle
+ EXPECT_EQ(0, native_handle_delete(to));
+}
+
+TEST(ConvertNativeHandle, DupFromAidlEmpty) {
+ NativeHandle handle;
+ native_handle_t* to = dupFromAidl(handle);
+ checkEq(handle, to, true /*exceptFds*/);
+ EXPECT_EQ(0, native_handle_close(to));
+ EXPECT_EQ(0, native_handle_delete(to));
+}
+
+TEST(ConvertNativeHandle, DupFromAidl) {
+ NativeHandle handle = makeTestAidlHandle();
+ native_handle_t* to = dupFromAidl(handle);
+ checkEq(handle, to, true /*exceptFds*/);
+ EXPECT_EQ(0, native_handle_close(to));
+ EXPECT_EQ(0, native_handle_delete(to));
+}
+
+static native_handle_t* makeTestLibcutilsHandle() {
+ native_handle_t* handle = native_handle_create(2, 4);
+ handle->data[0] = dup(0);
+ handle->data[1] = dup(0);
+ handle->data[2] = 1;
+ handle->data[3] = 2;
+ handle->data[4] = 3;
+ handle->data[5] = 4;
+ return handle;
+}
+
+TEST(ConvertNativeHandle, MakeToAidlEmpty) {
+ native_handle_t* handle = native_handle_create(0, 0);
+ NativeHandle to = makeToAidl(handle);
+ checkEq(to, handle, false /*exceptFds*/);
+ // no native_handle_close b/c fds are owned by NativeHandle now
+ EXPECT_EQ(0, native_handle_delete(handle));
+}
+
+TEST(ConvertNativeHandle, MakeToAidl) {
+ native_handle_t* handle = makeTestLibcutilsHandle();
+ NativeHandle to = makeToAidl(handle);
+ checkEq(to, handle, false /*exceptFds*/);
+ // no native_handle_close b/c fds are owned by NativeHandle now
+ EXPECT_EQ(0, native_handle_delete(handle));
+}
+
+TEST(ConvertNativeHandle, DupToAidlEmpty) {
+ native_handle_t* handle = native_handle_create(0, 0);
+ NativeHandle to = dupToAidl(handle);
+ checkEq(to, handle, true /*exceptFds*/);
+ EXPECT_EQ(0, native_handle_close(handle));
+ EXPECT_EQ(0, native_handle_delete(handle));
+}
+
+TEST(ConvertNativeHandle, DupToAidl) {
+ native_handle_t* handle = makeTestLibcutilsHandle();
+ NativeHandle to = dupToAidl(handle);
+ checkEq(to, handle, true /*exceptFds*/);
+ EXPECT_EQ(0, native_handle_close(handle));
+ EXPECT_EQ(0, native_handle_delete(handle));
+}
+
+} // namespace android
diff --git a/compatibility_matrices/compatibility_matrix.current.xml b/compatibility_matrices/compatibility_matrix.current.xml
index e12d920..b16ae40 100644
--- a/compatibility_matrices/compatibility_matrix.current.xml
+++ b/compatibility_matrices/compatibility_matrix.current.xml
@@ -354,13 +354,6 @@
<instance>default</instance>
</interface>
</hal>
- <hal format="aidl" optional="true">
- <name>android.hardware.memtrack</name>
- <interface>
- <name>IMemtrack</name>
- <instance>default</instance>
- </interface>
- </hal>
<hal format="hidl" optional="true">
<name>android.hardware.memtrack</name>
<version>1.0</version>
diff --git a/gnss/aidl/aidl_api/android.hardware.gnss/current/android/hardware/gnss/GnssMeasurement.aidl b/gnss/aidl/aidl_api/android.hardware.gnss/current/android/hardware/gnss/GnssMeasurement.aidl
index 7d15855..73d8a86 100644
--- a/gnss/aidl/aidl_api/android.hardware.gnss/current/android/hardware/gnss/GnssMeasurement.aidl
+++ b/gnss/aidl/aidl_api/android.hardware.gnss/current/android/hardware/gnss/GnssMeasurement.aidl
@@ -32,7 +32,6 @@
int accumulatedDeltaRangeState;
double accumulatedDeltaRangeM;
double accumulatedDeltaRangeUncertaintyM;
- float carrierFrequencyHz;
long carrierCycles;
double carrierPhase;
double carrierPhaseUncertainty;
diff --git a/gnss/aidl/aidl_api/android.hardware.gnss/current/android/hardware/gnss/GnssSignalType.aidl b/gnss/aidl/aidl_api/android.hardware.gnss/current/android/hardware/gnss/GnssSignalType.aidl
index 3e66c4a..f10b943 100644
--- a/gnss/aidl/aidl_api/android.hardware.gnss/current/android/hardware/gnss/GnssSignalType.aidl
+++ b/gnss/aidl/aidl_api/android.hardware.gnss/current/android/hardware/gnss/GnssSignalType.aidl
@@ -20,21 +20,21 @@
parcelable GnssSignalType {
android.hardware.gnss.GnssConstellationType constellation;
double carrierFrequencyHz;
- String codeType;
- const String CODE_TYPE_A = "A";
- const String CODE_TYPE_B = "B";
- const String CODE_TYPE_C = "C";
- const String CODE_TYPE_D = "D";
- const String CODE_TYPE_I = "I";
- const String CODE_TYPE_L = "L";
- const String CODE_TYPE_M = "M";
- const String CODE_TYPE_N = "N";
- const String CODE_TYPE_P = "P";
- const String CODE_TYPE_Q = "Q";
- const String CODE_TYPE_S = "S";
- const String CODE_TYPE_W = "W";
- const String CODE_TYPE_X = "X";
- const String CODE_TYPE_Y = "Y";
- const String CODE_TYPE_Z = "Z";
- const String CODE_TYPE_UNKNOWN = "UNKNOWN";
+ @utf8InCpp String codeType;
+ const @utf8InCpp String CODE_TYPE_A = "A";
+ const @utf8InCpp String CODE_TYPE_B = "B";
+ const @utf8InCpp String CODE_TYPE_C = "C";
+ const @utf8InCpp String CODE_TYPE_D = "D";
+ const @utf8InCpp String CODE_TYPE_I = "I";
+ const @utf8InCpp String CODE_TYPE_L = "L";
+ const @utf8InCpp String CODE_TYPE_M = "M";
+ const @utf8InCpp String CODE_TYPE_N = "N";
+ const @utf8InCpp String CODE_TYPE_P = "P";
+ const @utf8InCpp String CODE_TYPE_Q = "Q";
+ const @utf8InCpp String CODE_TYPE_S = "S";
+ const @utf8InCpp String CODE_TYPE_W = "W";
+ const @utf8InCpp String CODE_TYPE_X = "X";
+ const @utf8InCpp String CODE_TYPE_Y = "Y";
+ const @utf8InCpp String CODE_TYPE_Z = "Z";
+ const @utf8InCpp String CODE_TYPE_UNKNOWN = "UNKNOWN";
}
diff --git a/gnss/aidl/android/hardware/gnss/GnssMeasurement.aidl b/gnss/aidl/android/hardware/gnss/GnssMeasurement.aidl
index fae862b..ce88647 100644
--- a/gnss/aidl/android/hardware/gnss/GnssMeasurement.aidl
+++ b/gnss/aidl/android/hardware/gnss/GnssMeasurement.aidl
@@ -16,7 +16,6 @@
package android.hardware.gnss;
-import android.hardware.gnss.GnssConstellationType;
import android.hardware.gnss.GnssSignalType;
import android.hardware.gnss.GnssMultipathIndicator;
@@ -477,24 +476,6 @@
double accumulatedDeltaRangeUncertaintyM;
/**
- * Carrier frequency of the signal tracked, for example it can be the
- * GPS central frequency for L1 = 1575.45 MHz, or L2 = 1227.60 MHz, L5 =
- * 1176.45 MHz, varying GLO channels, etc. If the field is not set, it
- * is the primary common use central frequency, e.g. L1 = 1575.45 MHz
- * for GPS.
- *
- * For an L1, L5 receiver tracking a satellite on L1 and L5 at the same
- * time, two raw measurement structs must be reported for this same
- * satellite, in one of the measurement structs, all the values related
- * to L1 must be filled, and in the other all of the values related to
- * L5 must be filled.
- *
- * If the data is available, gnssMeasurementFlags must contain
- * HAS_CARRIER_FREQUENCY.
- */
- float carrierFrequencyHz;
-
- /**
* The number of full carrier cycles between the satellite and the
* receiver. The reference frequency is given by the field
* 'carrierFrequencyHz'. Indications of possible cycle slips and
diff --git a/gnss/aidl/android/hardware/gnss/GnssSignalType.aidl b/gnss/aidl/android/hardware/gnss/GnssSignalType.aidl
index a284fed..9c68db1 100644
--- a/gnss/aidl/android/hardware/gnss/GnssSignalType.aidl
+++ b/gnss/aidl/android/hardware/gnss/GnssSignalType.aidl
@@ -46,67 +46,67 @@
/**
* GNSS signal code type "A" representing GALILEO E1A, GALILEO E6A, IRNSS L5A, IRNSS SA.
*/
- const String CODE_TYPE_A = "A";
+ const @utf8InCpp String CODE_TYPE_A = "A";
/**
* GNSS signal code type "B" representing GALILEO E1B, GALILEO E6B, IRNSS L5B, IRNSS SB.
*/
- const String CODE_TYPE_B = "B";
+ const @utf8InCpp String CODE_TYPE_B = "B";
/**
* GNSS signal code type "C" representing GPS L1 C/A, GPS L2 C/A, GLONASS G1 C/A,
* GLONASS G2 C/A, GALILEO E1C, GALILEO E6C, SBAS L1 C/A, QZSS L1 C/A, IRNSS L5C.
*/
- const String CODE_TYPE_C = "C";
+ const @utf8InCpp String CODE_TYPE_C = "C";
/**
* GNSS signal code type "D" representing BDS B1C D.
*/
- const String CODE_TYPE_D = "D";
+ const @utf8InCpp String CODE_TYPE_D = "D";
/**
* GNSS signal code type "I" representing GPS L5 I, GLONASS G3 I, GALILEO E5a I, GALILEO E5b I,
* GALILEO E5a+b I, SBAS L5 I, QZSS L5 I, BDS B1 I, BDS B2 I, BDS B3 I.
*/
- const String CODE_TYPE_I = "I";
+ const @utf8InCpp String CODE_TYPE_I = "I";
/**
* GNSS signal code type "L" representing GPS L1C (P), GPS L2C (L), QZSS L1C (P), QZSS L2C (L),
* LEX(6) L.
*/
- const String CODE_TYPE_L = "L";
+ const @utf8InCpp String CODE_TYPE_L = "L";
/**
* GNSS signal code type "M" representing GPS L1M, GPS L2M.
*/
- const String CODE_TYPE_M = "M";
+ const @utf8InCpp String CODE_TYPE_M = "M";
/**
* GNSS signal code type "N" representing GPS L1 codeless, GPS L2 codeless.
*/
- const String CODE_TYPE_N = "N";
+ const @utf8InCpp String CODE_TYPE_N = "N";
/**
* GNSS signal code type "P" representing GPS L1P, GPS L2P, GLONASS G1P, GLONASS G2P, BDS B1C P.
*/
- const String CODE_TYPE_P = "P";
+ const @utf8InCpp String CODE_TYPE_P = "P";
/**
* GNSS signal code type "Q" representing GPS L5 Q, GLONASS G3 Q, GALILEO E5a Q, GALILEO E5b Q,
* GALILEO E5a+b Q, SBAS L5 Q, QZSS L5 Q, BDS B1 Q, BDS B2 Q, BDS B3 Q.
*/
- const String CODE_TYPE_Q = "Q";
+ const @utf8InCpp String CODE_TYPE_Q = "Q";
/**
* GNSS signal code type "S" represents GPS L1C (D), GPS L2C (M), QZSS L1C (D), QZSS L2C (M),
* LEX(6) S.
*/
- const String CODE_TYPE_S = "S";
+ const @utf8InCpp String CODE_TYPE_S = "S";
/**
* GNSS signal code type "W" representing GPS L1 Z-tracking, GPS L2 Z-tracking.
*/
- const String CODE_TYPE_W = "W";
+ const @utf8InCpp String CODE_TYPE_W = "W";
/**
* GNSS signal code type "X" representing GPS L1C (D+P), GPS L2C (M+L), GPS L5 (I+Q),
@@ -114,22 +114,22 @@
* GALILEO E6 (B+C), SBAS L5 (I+Q), QZSS L1C (D+P), QZSS L2C (M+L), QZSS L5 (I+Q),
* LEX(6) (S+L), BDS B1 (I+Q), BDS B1C (D+P), BDS B2 (I+Q), BDS B3 (I+Q), IRNSS L5 (B+C).
*/
- const String CODE_TYPE_X = "X";
+ const @utf8InCpp String CODE_TYPE_X = "X";
/**
* GNSS signal code type "Y" representing GPS L1Y, GPS L2Y.
*/
- const String CODE_TYPE_Y = "Y";
+ const @utf8InCpp String CODE_TYPE_Y = "Y";
/**
* GNSS signal code type "Z" representing GALILEO E1 (A+B+C), GALILEO E6 (A+B+C), QZSS L1-SAIF.
*/
- const String CODE_TYPE_Z = "Z";
+ const @utf8InCpp String CODE_TYPE_Z = "Z";
/**
* GNSS signal code type "UNKNOWN" representing the GNSS Measurement's code type is unknown.
*/
- const String CODE_TYPE_UNKNOWN = "UNKNOWN";
+ const @utf8InCpp String CODE_TYPE_UNKNOWN = "UNKNOWN";
/**
* The type of code that is currently being tracked in the GNSS signal.
@@ -145,5 +145,5 @@
* "A channel"). In the future, if for instance a code "G" was added in the official RINEX
* standard, "G" could be specified here.
*/
- String codeType;
+ @utf8InCpp String codeType;
}
diff --git a/gnss/common/utils/default/Utils.cpp b/gnss/common/utils/default/Utils.cpp
index dd932d4..e383d51 100644
--- a/gnss/common/utils/default/Utils.cpp
+++ b/gnss/common/utils/default/Utils.cpp
@@ -25,14 +25,17 @@
namespace gnss {
namespace common {
-using IGnss = aidl::android::hardware::gnss::IGnss;
-using IGnssMeasurementCallback = aidl::android::hardware::gnss::IGnssMeasurementCallback;
-using GnssMeasurement = aidl::android::hardware::gnss::GnssMeasurement;
+using aidl::android::hardware::gnss::ElapsedRealtime;
+using aidl::android::hardware::gnss::GnssClock;
+using aidl::android::hardware::gnss::GnssData;
+using aidl::android::hardware::gnss::GnssMeasurement;
+using aidl::android::hardware::gnss::IGnss;
+using aidl::android::hardware::gnss::IGnssMeasurementCallback;
+
using GnssSvFlags = V1_0::IGnssCallback::GnssSvFlags;
using GnssMeasurementFlagsV1_0 = V1_0::IGnssMeasurementCallback::GnssMeasurementFlags;
using GnssMeasurementFlagsV2_1 = V2_1::IGnssMeasurementCallback::GnssMeasurementFlags;
using GnssMeasurementStateV2_0 = V2_0::IGnssMeasurementCallback::GnssMeasurementState;
-using ElapsedRealtime = aidl::android::hardware::gnss::ElapsedRealtime;
using ElapsedRealtimeFlags = V2_0::ElapsedRealtimeFlags;
using GnssConstellationTypeV2_0 = V2_0::GnssConstellationType;
using IGnssMeasurementCallbackV2_0 = V2_0::IGnssMeasurementCallback;
@@ -137,38 +140,53 @@
return gnssData;
}
-aidl::android::hardware::gnss::GnssData Utils::getMockMeasurement() {
+GnssData Utils::getMockMeasurement() {
aidl::android::hardware::gnss::GnssSignalType signalType = {
.constellation = aidl::android::hardware::gnss::GnssConstellationType::GLONASS,
.carrierFrequencyHz = 1.59975e+09,
.codeType = aidl::android::hardware::gnss::GnssSignalType::CODE_TYPE_C,
};
- aidl::android::hardware::gnss::GnssMeasurement measurement = {
- .flags = GnssMeasurement::HAS_CARRIER_FREQUENCY,
- .svid = 6,
+ GnssMeasurement measurement = {
+ .flags = GnssMeasurement::HAS_AUTOMATIC_GAIN_CONTROL |
+ GnssMeasurement::HAS_CARRIER_FREQUENCY | GnssMeasurement::HAS_CARRIER_PHASE |
+ GnssMeasurement::HAS_CARRIER_PHASE_UNCERTAINTY |
+ GnssMeasurement::HAS_FULL_ISB | GnssMeasurement::HAS_FULL_ISB_UNCERTAINTY |
+ GnssMeasurement::HAS_SATELLITE_ISB |
+ GnssMeasurement::HAS_SATELLITE_ISB_UNCERTAINTY,
+ .svid = 13,
.signalType = signalType,
.timeOffsetNs = 0.0,
.receivedSvTimeInNs = 8195997131077,
.receivedSvTimeUncertaintyInNs = 15,
.antennaCN0DbHz = 30.0,
+ .basebandCN0DbHz = 26.5,
+ .agcLevelDb = 2.3,
.pseudorangeRateMps = -484.13739013671875,
.pseudorangeRateUncertaintyMps = 1.0379999876022339,
.accumulatedDeltaRangeState = GnssMeasurement::ADR_STATE_UNKNOWN,
- .accumulatedDeltaRangeM = 0.0,
- .accumulatedDeltaRangeUncertaintyM = 0.0,
+ .accumulatedDeltaRangeM = 1.52,
+ .accumulatedDeltaRangeUncertaintyM = 2.43,
.multipathIndicator = aidl::android::hardware::gnss::GnssMultipathIndicator::UNKNOWN,
.state = GnssMeasurement::STATE_CODE_LOCK | GnssMeasurement::STATE_BIT_SYNC |
GnssMeasurement::STATE_SUBFRAME_SYNC | GnssMeasurement::STATE_TOW_DECODED |
GnssMeasurement::STATE_GLO_STRING_SYNC |
- GnssMeasurement::STATE_GLO_TOD_DECODED};
+ GnssMeasurement::STATE_GLO_TOD_DECODED,
+ .fullInterSignalBiasNs = 21.5,
+ .fullInterSignalBiasUncertaintyNs = 792.0,
+ .satelliteInterSignalBiasNs = 233.9,
+ .satelliteInterSignalBiasUncertaintyNs = 921.2,
+ };
- aidl::android::hardware::gnss::GnssClock clock = {.timeNs = 2713545000000,
- .fullBiasNs = -1226701900521857520,
- .biasNs = 0.59689998626708984,
- .biasUncertaintyNs = 47514.989972114563,
- .driftNsps = -51.757811607455452,
- .driftUncertaintyNsps = 310.64968328491528,
- .hwClockDiscontinuityCount = 1};
+ GnssClock clock = {.gnssClockFlags = GnssClock::HAS_FULL_BIAS | GnssClock::HAS_FULL_BIAS |
+ GnssClock::HAS_BIAS_UNCERTAINTY | GnssClock::HAS_DRIFT |
+ GnssClock::HAS_DRIFT_UNCERTAINTY,
+ .timeNs = 35854545000000,
+ .fullBiasNs = -234621900521857520,
+ .biasNs = 0.2352389998626708984,
+ .biasUncertaintyNs = 274.989972114563,
+ .driftNsps = -124.3742360,
+ .driftUncertaintyNsps = 239.6234285828,
+ .hwClockDiscontinuityCount = 999};
ElapsedRealtime timestamp = {
.flags = ElapsedRealtime::HAS_TIMESTAMP_NS | ElapsedRealtime::HAS_TIME_UNCERTAINTY_NS,
@@ -176,9 +194,9 @@
// This is an hardcoded value indicating a 1ms of uncertainty between the two clocks.
// In an actual implementation provide an estimate of the synchronization uncertainty
// or don't set the field.
- .timeUncertaintyNs = 1000000};
+ .timeUncertaintyNs = 1020400};
- aidl::android::hardware::gnss::GnssData gnssData = {
+ GnssData gnssData = {
.measurements = {measurement}, .clock = clock, .elapsedRealtime = timestamp};
return gnssData;
}
diff --git a/memtrack/aidl/Android.bp b/memtrack/aidl/Android.bp
deleted file mode 100644
index fe4d01b..0000000
--- a/memtrack/aidl/Android.bp
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright (C) 2020 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.
-
-aidl_interface {
- name: "android.hardware.memtrack",
- vendor_available: true,
- srcs: ["android/hardware/memtrack/*.aidl"],
- stability: "vintf",
- backend: {
- cpp: {
- enabled: false,
- },
- java: {
- enabled: false,
- },
- ndk: {
- vndk: {
- enabled: true,
- },
- },
- },
-}
diff --git a/memtrack/aidl/aidl_api/android.hardware.memtrack/current/android/hardware/memtrack/IMemtrack.aidl b/memtrack/aidl/aidl_api/android.hardware.memtrack/current/android/hardware/memtrack/IMemtrack.aidl
deleted file mode 100644
index 844a1bb..0000000
--- a/memtrack/aidl/aidl_api/android.hardware.memtrack/current/android/hardware/memtrack/IMemtrack.aidl
+++ /dev/null
@@ -1,23 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
-///////////////////////////////////////////////////////////////////////////////
-
-// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
-// edit this file. It looks like you are doing that because you have modified
-// an AIDL interface in a backward-incompatible way, e.g., deleting a function
-// from an interface or a field from a parcelable and it broke the build. That
-// breakage is intended.
-//
-// You must not make a backward incompatible changes to the AIDL files built
-// with the aidl_interface module type with versions property set. The module
-// type is used to build AIDL files in a way that they can be used across
-// independently updatable components of the system. If a device is shipped
-// with such a backward incompatible change, it has a high risk of breaking
-// later when a module using the interface is updated, e.g., Mainline modules.
-
-package android.hardware.memtrack;
-@VintfStability
-interface IMemtrack {
- android.hardware.memtrack.MemtrackRecord[] getMemory(in int pid, in android.hardware.memtrack.MemtrackType type);
- android.hardware.memtrack.DeviceInfo[] getGpuDeviceInfo();
-}
diff --git a/memtrack/aidl/aidl_api/android.hardware.memtrack/current/android/hardware/memtrack/MemtrackRecord.aidl b/memtrack/aidl/aidl_api/android.hardware.memtrack/current/android/hardware/memtrack/MemtrackRecord.aidl
deleted file mode 100644
index 09ecefc..0000000
--- a/memtrack/aidl/aidl_api/android.hardware.memtrack/current/android/hardware/memtrack/MemtrackRecord.aidl
+++ /dev/null
@@ -1,32 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
-///////////////////////////////////////////////////////////////////////////////
-
-// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
-// edit this file. It looks like you are doing that because you have modified
-// an AIDL interface in a backward-incompatible way, e.g., deleting a function
-// from an interface or a field from a parcelable and it broke the build. That
-// breakage is intended.
-//
-// You must not make a backward incompatible changes to the AIDL files built
-// with the aidl_interface module type with versions property set. The module
-// type is used to build AIDL files in a way that they can be used across
-// independently updatable components of the system. If a device is shipped
-// with such a backward incompatible change, it has a high risk of breaking
-// later when a module using the interface is updated, e.g., Mainline modules.
-
-package android.hardware.memtrack;
-@VintfStability
-parcelable MemtrackRecord {
- int flags;
- long sizeInBytes;
- const int FLAG_SMAPS_ACCOUNTED = 2;
- const int FLAG_SMAPS_UNACCOUNTED = 4;
- const int FLAG_SHARED = 8;
- const int FLAG_SHARED_PSS = 16;
- const int FLAG_PRIVATE = 32;
- const int FLAG_SYSTEM = 64;
- const int FLAG_DEDICATED = 128;
- const int FLAG_NONSECURE = 256;
- const int FLAG_SECURE = 512;
-}
diff --git a/memtrack/aidl/aidl_api/android.hardware.memtrack/current/android/hardware/memtrack/MemtrackType.aidl b/memtrack/aidl/aidl_api/android.hardware.memtrack/current/android/hardware/memtrack/MemtrackType.aidl
deleted file mode 100644
index 7f3f939..0000000
--- a/memtrack/aidl/aidl_api/android.hardware.memtrack/current/android/hardware/memtrack/MemtrackType.aidl
+++ /dev/null
@@ -1,27 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
-///////////////////////////////////////////////////////////////////////////////
-
-// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
-// edit this file. It looks like you are doing that because you have modified
-// an AIDL interface in a backward-incompatible way, e.g., deleting a function
-// from an interface or a field from a parcelable and it broke the build. That
-// breakage is intended.
-//
-// You must not make a backward incompatible changes to the AIDL files built
-// with the aidl_interface module type with versions property set. The module
-// type is used to build AIDL files in a way that they can be used across
-// independently updatable components of the system. If a device is shipped
-// with such a backward incompatible change, it has a high risk of breaking
-// later when a module using the interface is updated, e.g., Mainline modules.
-
-package android.hardware.memtrack;
-@Backing(type="int") @VintfStability
-enum MemtrackType {
- OTHER = 0,
- GL = 1,
- GRAPHICS = 2,
- MULTIMEDIA = 3,
- CAMERA = 4,
- NUM_TYPES = 5,
-}
diff --git a/memtrack/aidl/android/hardware/memtrack/DeviceInfo.aidl b/memtrack/aidl/android/hardware/memtrack/DeviceInfo.aidl
deleted file mode 100644
index aec11e9..0000000
--- a/memtrack/aidl/android/hardware/memtrack/DeviceInfo.aidl
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (C) 2020 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.memtrack;
-
-/*
- * A vector of DeviceInfo is returned by the function getGpuDeviceInfo().
- * Each entry consists of the device name and the device id.
- * See getGpuDeviceInfo() for further details.
- */
-@VintfStability
-parcelable DeviceInfo {
- int id;
- @utf8InCpp String name;
-}
-
diff --git a/memtrack/aidl/android/hardware/memtrack/IMemtrack.aidl b/memtrack/aidl/android/hardware/memtrack/IMemtrack.aidl
deleted file mode 100644
index 33c6956..0000000
--- a/memtrack/aidl/android/hardware/memtrack/IMemtrack.aidl
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (C) 2020 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.memtrack;
-
-import android.hardware.memtrack.DeviceInfo;
-import android.hardware.memtrack.MemtrackRecord;
-import android.hardware.memtrack.MemtrackType;
-
-/**
- * The Memory Tracker HAL is designed to return information about
- * device-specific memory usage.
- * The primary goal is to be able to track memory that is not
- * trackable in any other way, for example texture memory that is allocated by
- * a process, but not mapped in to that process's address space.
- * A secondary goal is to be able to categorize memory used by a process into
- * GL, graphics, etc. All memory sizes must be in real memory usage,
- * accounting for stride, bit depth, rounding up to page size, etc.
- *
- * Constructor for the interface should be used to perform memtrack management
- * setup actions and is called once before any calls to getMemory().
- */
-@VintfStability
-interface IMemtrack {
- /**
- * getMemory() populates MemtrackRecord vector with the sizes of memory
- * plus associated flags for that memory.
- *
- * A process collecting memory statistics will call getMemory for each
- * combination of pid and memory type. For each memory type that it
- * recognizes, the HAL must fill out an array of memtrack_record
- * structures breaking down the statistics of that memory type as much as
- * possible. For example,
- * getMemory(<pid>, GL) might return:
- * { { 4096, ACCOUNTED | PRIVATE | SYSTEM },
- * { 40960, UNACCOUNTED | PRIVATE | SYSTEM },
- * { 8192, ACCOUNTED | PRIVATE | DEDICATED },
- * { 8192, UNACCOUNTED | PRIVATE | DEDICATED } }
- * If the HAL cannot differentiate between SYSTEM and DEDICATED memory, it
- * could return:
- * { { 12288, ACCOUNTED | PRIVATE },
- * { 49152, UNACCOUNTED | PRIVATE } }
- *
- * Memory must not overlap between types. For example, a graphics buffer
- * that has been mapped into the GPU as a surface must show up when
- * GRAPHICS is requested and not when GL
- * is requested.
- *
- * @param pid process for which memory information is requested
- * @param type memory type that information is being requested about
- * @return vector of MemtrackRecord containing memory information
- */
- MemtrackRecord[] getMemory(in int pid, in MemtrackType type);
-
- /**
- * getGpuDeviceInfo() populates DeviceInfo with the ID and name
- * of each GPU device.
- *
- * For example, getGpuDeviceInfor, might return:
- * { { 0, <gpu-device-name> },
- * { 1, <gpu-device-name> } }
- *
- * This information is used to identify GPU devices for GPU specific
- * memory accounting (e.g. DMA buffer usage).
- *
- * @return vector of DeviceInfo populated for all GPU devices.
- */
- DeviceInfo[] getGpuDeviceInfo();
-}
diff --git a/memtrack/aidl/android/hardware/memtrack/MemtrackRecord.aidl b/memtrack/aidl/android/hardware/memtrack/MemtrackRecord.aidl
deleted file mode 100644
index 95254e9..0000000
--- a/memtrack/aidl/android/hardware/memtrack/MemtrackRecord.aidl
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2020 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.memtrack;
-
-/*
- * A vector of MemtrackRecord is returned by the function getMemory().
- * Each record consists of the size of the memory used by the process and
- * flags indicate all the MemtrackFlags that are valid for this record.
- * see getMemory() comments for further details.
- */
-@VintfStability
-parcelable MemtrackRecord {
- /* Memtrack Flags */
- const int FLAG_SMAPS_ACCOUNTED = 1 << 1;
- const int FLAG_SMAPS_UNACCOUNTED = 1 << 2;
- const int FLAG_SHARED = 1 << 3;
- const int FLAG_SHARED_PSS = 1 << 4;
- const int FLAG_PRIVATE = 1 << 5;
- const int FLAG_SYSTEM = 1 << 6;
- const int FLAG_DEDICATED = 1 << 7;
- const int FLAG_NONSECURE = 1 << 8;
- const int FLAG_SECURE = 1 << 9;
-
- /* Bitfield indicating all flags that are valid for this record */
- int flags;
-
- long sizeInBytes;
-}
-
diff --git a/memtrack/aidl/android/hardware/memtrack/MemtrackType.aidl b/memtrack/aidl/android/hardware/memtrack/MemtrackType.aidl
deleted file mode 100644
index 715c6bf..0000000
--- a/memtrack/aidl/android/hardware/memtrack/MemtrackType.aidl
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (C) 2020 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.memtrack;
-
-/**
- * Tags which define the usage of the memory buffers.
- */
-@VintfStability
-@Backing(type="int")
-enum MemtrackType {
- OTHER = 0,
- GL = 1,
- GRAPHICS = 2,
- MULTIMEDIA = 3,
- CAMERA = 4,
- NUM_TYPES,
-}
diff --git a/memtrack/aidl/default/Android.bp b/memtrack/aidl/default/Android.bp
deleted file mode 100644
index 52f88c8..0000000
--- a/memtrack/aidl/default/Android.bp
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright (C) 2020 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_binary {
- name: "android.hardware.memtrack-service.example",
- relative_install_path: "hw",
- init_rc: ["memtrack-default.rc"],
- vintf_fragments: ["memtrack-default.xml"],
- vendor: true,
- shared_libs: [
- "libbase",
- "libbinder_ndk",
- "android.hardware.memtrack-ndk_platform",
- ],
- srcs: [
- "main.cpp",
- "Memtrack.cpp",
- ],
-}
diff --git a/memtrack/aidl/default/Memtrack.cpp b/memtrack/aidl/default/Memtrack.cpp
deleted file mode 100644
index 7361719..0000000
--- a/memtrack/aidl/default/Memtrack.cpp
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2020 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.
- */
-
-#include "Memtrack.h"
-
-namespace aidl {
-namespace android {
-namespace hardware {
-namespace memtrack {
-
-ndk::ScopedAStatus Memtrack::getMemory(int pid, MemtrackType type,
- std::vector<MemtrackRecord>* _aidl_return) {
- if (pid < 0) {
- return ndk::ScopedAStatus(AStatus_fromExceptionCode(EX_ILLEGAL_ARGUMENT));
- }
- if (type < MemtrackType::OTHER || type >= MemtrackType::NUM_TYPES) {
- return ndk::ScopedAStatus(AStatus_fromExceptionCode(EX_UNSUPPORTED_OPERATION));
- }
- _aidl_return->clear();
- return ndk::ScopedAStatus::ok();
-}
-
-ndk::ScopedAStatus Memtrack::getGpuDeviceInfo(std::vector<DeviceInfo>* _aidl_return) {
- _aidl_return->clear();
- return ndk::ScopedAStatus::ok();
-}
-
-} // namespace memtrack
-} // namespace hardware
-} // namespace android
-} // namespace aidl
diff --git a/memtrack/aidl/default/Memtrack.h b/memtrack/aidl/default/Memtrack.h
deleted file mode 100644
index f2ef60e..0000000
--- a/memtrack/aidl/default/Memtrack.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (C) 2020 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.
- */
-
-#pragma once
-
-#include <aidl/android/hardware/memtrack/BnMemtrack.h>
-#include <aidl/android/hardware/memtrack/DeviceInfo.h>
-#include <aidl/android/hardware/memtrack/MemtrackRecord.h>
-#include <aidl/android/hardware/memtrack/MemtrackType.h>
-
-namespace aidl {
-namespace android {
-namespace hardware {
-namespace memtrack {
-
-class Memtrack : public BnMemtrack {
- ndk::ScopedAStatus getMemory(int pid, MemtrackType type,
- std::vector<MemtrackRecord>* _aidl_return) override;
-
- ndk::ScopedAStatus getGpuDeviceInfo(std::vector<DeviceInfo>* _aidl_return) override;
-};
-
-} // namespace memtrack
-} // namespace hardware
-} // namespace android
-} // namespace aidl
diff --git a/memtrack/aidl/default/main.cpp b/memtrack/aidl/default/main.cpp
deleted file mode 100644
index d063d2a..0000000
--- a/memtrack/aidl/default/main.cpp
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (C) 2020 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.
- */
-
-#include "Memtrack.h"
-
-#include <android-base/logging.h>
-#include <android/binder_manager.h>
-#include <android/binder_process.h>
-
-using aidl::android::hardware::memtrack::Memtrack;
-
-int main() {
- ABinderProcess_setThreadPoolMaxThreadCount(0);
- std::shared_ptr<Memtrack> memtrack = ndk::SharedRefBase::make<Memtrack>();
-
- const std::string instance = std::string() + Memtrack::descriptor + "/default";
- binder_status_t status =
- AServiceManager_addService(memtrack->asBinder().get(), instance.c_str());
- CHECK(status == STATUS_OK);
-
- ABinderProcess_joinThreadPool();
- return EXIT_FAILURE; // Unreachable
-}
diff --git a/memtrack/aidl/default/memtrack-default.rc b/memtrack/aidl/default/memtrack-default.rc
deleted file mode 100644
index 1725cd0..0000000
--- a/memtrack/aidl/default/memtrack-default.rc
+++ /dev/null
@@ -1,4 +0,0 @@
-service vendor.memtrack-default /vendor/bin/hw/android.hardware.memtrack-service.example
- class hal
- user nobody
- group system
diff --git a/memtrack/aidl/default/memtrack-default.xml b/memtrack/aidl/default/memtrack-default.xml
deleted file mode 100644
index 3e3e0f6..0000000
--- a/memtrack/aidl/default/memtrack-default.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-<manifest version="1.0" type="device">
- <hal format="aidl">
- <name>android.hardware.memtrack</name>
- <fqname>IMemtrack/default</fqname>
- </hal>
-</manifest>
-
diff --git a/memtrack/aidl/vts/Android.bp b/memtrack/aidl/vts/Android.bp
deleted file mode 100644
index ea36677..0000000
--- a/memtrack/aidl/vts/Android.bp
+++ /dev/null
@@ -1,17 +0,0 @@
-cc_test {
- name: "VtsHalMemtrackTargetTest",
- defaults: [
- "VtsHalTargetTestDefaults",
- "use_libaidlvintf_gtest_helper_static",
- ],
- srcs: ["VtsHalMemtrackTargetTest.cpp"],
- shared_libs: [
- "libbinder_ndk",
- ],
- static_libs: [
- "android.hardware.memtrack-unstable-ndk_platform",
- ],
- test_suites: [
- "vts-core",
- ],
-}
diff --git a/memtrack/aidl/vts/VtsHalMemtrackTargetTest.cpp b/memtrack/aidl/vts/VtsHalMemtrackTargetTest.cpp
deleted file mode 100644
index a3bd293..0000000
--- a/memtrack/aidl/vts/VtsHalMemtrackTargetTest.cpp
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright (C) 2020 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.
- */
-#include <aidl/Gtest.h>
-#include <aidl/Vintf.h>
-
-#include <aidl/android/hardware/memtrack/DeviceInfo.h>
-#include <aidl/android/hardware/memtrack/IMemtrack.h>
-#include <aidl/android/hardware/memtrack/MemtrackType.h>
-#include <android/binder_manager.h>
-#include <android/binder_process.h>
-
-using aidl::android::hardware::memtrack::DeviceInfo;
-using aidl::android::hardware::memtrack::IMemtrack;
-using aidl::android::hardware::memtrack::MemtrackRecord;
-using aidl::android::hardware::memtrack::MemtrackType;
-
-class MemtrackAidlTest : public testing::TestWithParam<std::string> {
- public:
- virtual void SetUp() override {
- const auto instance = std::string() + IMemtrack::descriptor + "/default";
- auto memtrackBinder = ndk::SpAIBinder(AServiceManager_getService(instance.c_str()));
- memtrack_ = IMemtrack::fromBinder(memtrackBinder);
- ASSERT_NE(memtrack_, nullptr);
- }
-
- std::shared_ptr<IMemtrack> memtrack_;
-};
-
-TEST_P(MemtrackAidlTest, GetMemoryInvalidPid) {
- int pid = -1;
- MemtrackType type = MemtrackType::OTHER;
- std::vector<MemtrackRecord> records;
-
- auto status = memtrack_->getMemory(pid, type, &records);
-
- EXPECT_EQ(status.getExceptionCode(), EX_ILLEGAL_ARGUMENT);
-}
-
-TEST_P(MemtrackAidlTest, GetMemoryInvalidType) {
- int pid = 1;
- MemtrackType type = MemtrackType::NUM_TYPES;
- std::vector<MemtrackRecord> records;
-
- auto status = memtrack_->getMemory(pid, type, &records);
-
- EXPECT_EQ(status.getExceptionCode(), EX_UNSUPPORTED_OPERATION);
-}
-
-TEST_P(MemtrackAidlTest, GetMemory) {
- int pid = 1;
- MemtrackType type = MemtrackType::OTHER;
- std::vector<MemtrackRecord> records;
-
- auto status = memtrack_->getMemory(pid, type, &records);
-
- EXPECT_TRUE(status.isOk());
-}
-
-TEST_P(MemtrackAidlTest, GetGpuDeviceInfo) {
- std::vector<DeviceInfo> device_info;
-
- auto status = memtrack_->getGpuDeviceInfo(&device_info);
-
- EXPECT_TRUE(status.isOk());
-}
-
-GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(MemtrackAidlTest);
-INSTANTIATE_TEST_SUITE_P(PerInstance, MemtrackAidlTest,
- testing::ValuesIn(android::getAidlHalInstanceNames(IMemtrack::descriptor)),
- android::PrintInstanceNameToString);
-
-int main(int argc, char** argv) {
- ::testing::InitGoogleTest(&argc, argv);
- ABinderProcess_setThreadPoolMaxThreadCount(1);
- ABinderProcess_startThreadPool();
- return RUN_ALL_TESTS();
-}
diff --git a/neuralnetworks/1.0/utils/include/nnapi/hal/1.0/Callbacks.h b/neuralnetworks/1.0/utils/include/nnapi/hal/1.0/Callbacks.h
index 65b75e5..2e00fce 100644
--- a/neuralnetworks/1.0/utils/include/nnapi/hal/1.0/Callbacks.h
+++ b/neuralnetworks/1.0/utils/include/nnapi/hal/1.0/Callbacks.h
@@ -27,6 +27,9 @@
#include <nnapi/hal/ProtectCallback.h>
#include <nnapi/hal/TransferValue.h>
+// See hardware/interfaces/neuralnetworks/utils/README.md for more information on HIDL interface
+// lifetimes across processes and for protecting asynchronous calls across HIDL.
+
namespace android::hardware::neuralnetworks::V1_0::utils {
class PreparedModelCallback final : public IPreparedModelCallback,
diff --git a/neuralnetworks/1.0/utils/include/nnapi/hal/1.0/Device.h b/neuralnetworks/1.0/utils/include/nnapi/hal/1.0/Device.h
index ee103ba..db3b2ad 100644
--- a/neuralnetworks/1.0/utils/include/nnapi/hal/1.0/Device.h
+++ b/neuralnetworks/1.0/utils/include/nnapi/hal/1.0/Device.h
@@ -32,8 +32,12 @@
#include <string>
#include <vector>
+// See hardware/interfaces/neuralnetworks/utils/README.md for more information on HIDL interface
+// lifetimes across processes and for protecting asynchronous calls across HIDL.
+
namespace android::hardware::neuralnetworks::V1_0::utils {
+// Class that adapts V1_0::IDevice to nn::IDevice.
class Device final : public nn::IDevice {
struct PrivateConstructorTag {};
diff --git a/neuralnetworks/1.0/utils/include/nnapi/hal/1.0/PreparedModel.h b/neuralnetworks/1.0/utils/include/nnapi/hal/1.0/PreparedModel.h
index 198cbc8..2de1828 100644
--- a/neuralnetworks/1.0/utils/include/nnapi/hal/1.0/PreparedModel.h
+++ b/neuralnetworks/1.0/utils/include/nnapi/hal/1.0/PreparedModel.h
@@ -29,8 +29,12 @@
#include <utility>
#include <vector>
+// See hardware/interfaces/neuralnetworks/utils/README.md for more information on HIDL interface
+// lifetimes across processes and for protecting asynchronous calls across HIDL.
+
namespace android::hardware::neuralnetworks::V1_0::utils {
+// Class that adapts V1_0::IPreparedModel to nn::IPreparedModel.
class PreparedModel final : public nn::IPreparedModel {
struct PrivateConstructorTag {};
diff --git a/neuralnetworks/1.0/utils/src/Callbacks.cpp b/neuralnetworks/1.0/utils/src/Callbacks.cpp
index b1259c3..a0bdb3c 100644
--- a/neuralnetworks/1.0/utils/src/Callbacks.cpp
+++ b/neuralnetworks/1.0/utils/src/Callbacks.cpp
@@ -32,6 +32,9 @@
#include <utility>
+// See hardware/interfaces/neuralnetworks/utils/README.md for more information on HIDL interface
+// lifetimes across processes and for protecting asynchronous calls across HIDL.
+
namespace android::hardware::neuralnetworks::V1_0::utils {
namespace {
diff --git a/neuralnetworks/1.0/utils/src/Device.cpp b/neuralnetworks/1.0/utils/src/Device.cpp
index 285c515..83e0015 100644
--- a/neuralnetworks/1.0/utils/src/Device.cpp
+++ b/neuralnetworks/1.0/utils/src/Device.cpp
@@ -38,6 +38,9 @@
#include <string>
#include <vector>
+// See hardware/interfaces/neuralnetworks/utils/README.md for more information on HIDL interface
+// lifetimes across processes and for protecting asynchronous calls across HIDL.
+
namespace android::hardware::neuralnetworks::V1_0::utils {
namespace {
diff --git a/neuralnetworks/1.0/utils/src/PreparedModel.cpp b/neuralnetworks/1.0/utils/src/PreparedModel.cpp
index add8275..c1dd1d9 100644
--- a/neuralnetworks/1.0/utils/src/PreparedModel.cpp
+++ b/neuralnetworks/1.0/utils/src/PreparedModel.cpp
@@ -34,6 +34,9 @@
#include <utility>
#include <vector>
+// See hardware/interfaces/neuralnetworks/utils/README.md for more information on HIDL interface
+// lifetimes across processes and for protecting asynchronous calls across HIDL.
+
namespace android::hardware::neuralnetworks::V1_0::utils {
nn::GeneralResult<std::shared_ptr<const PreparedModel>> PreparedModel::create(
diff --git a/neuralnetworks/1.1/utils/include/nnapi/hal/1.1/Device.h b/neuralnetworks/1.1/utils/include/nnapi/hal/1.1/Device.h
index c1e95fe1a..5e224b5 100644
--- a/neuralnetworks/1.1/utils/include/nnapi/hal/1.1/Device.h
+++ b/neuralnetworks/1.1/utils/include/nnapi/hal/1.1/Device.h
@@ -32,8 +32,12 @@
#include <string>
#include <vector>
+// See hardware/interfaces/neuralnetworks/utils/README.md for more information on HIDL interface
+// lifetimes across processes and for protecting asynchronous calls across HIDL.
+
namespace android::hardware::neuralnetworks::V1_1::utils {
+// Class that adapts V1_1::IDevice to nn::IDevice.
class Device final : public nn::IDevice {
struct PrivateConstructorTag {};
diff --git a/neuralnetworks/1.1/utils/src/Device.cpp b/neuralnetworks/1.1/utils/src/Device.cpp
index f73d3f8..b57c7f4 100644
--- a/neuralnetworks/1.1/utils/src/Device.cpp
+++ b/neuralnetworks/1.1/utils/src/Device.cpp
@@ -39,6 +39,9 @@
#include <string>
#include <vector>
+// See hardware/interfaces/neuralnetworks/utils/README.md for more information on HIDL interface
+// lifetimes across processes and for protecting asynchronous calls across HIDL.
+
namespace android::hardware::neuralnetworks::V1_1::utils {
namespace {
diff --git a/neuralnetworks/1.2/utils/include/nnapi/hal/1.2/Callbacks.h b/neuralnetworks/1.2/utils/include/nnapi/hal/1.2/Callbacks.h
index bc7d92a..1162bc3 100644
--- a/neuralnetworks/1.2/utils/include/nnapi/hal/1.2/Callbacks.h
+++ b/neuralnetworks/1.2/utils/include/nnapi/hal/1.2/Callbacks.h
@@ -31,6 +31,9 @@
#include <nnapi/hal/ProtectCallback.h>
#include <nnapi/hal/TransferValue.h>
+// See hardware/interfaces/neuralnetworks/utils/README.md for more information on HIDL interface
+// lifetimes across processes and for protecting asynchronous calls across HIDL.
+
namespace android::hardware::neuralnetworks::V1_2::utils {
class PreparedModelCallback final : public IPreparedModelCallback,
diff --git a/neuralnetworks/1.2/utils/include/nnapi/hal/1.2/Device.h b/neuralnetworks/1.2/utils/include/nnapi/hal/1.2/Device.h
index a68830d..79c3b04 100644
--- a/neuralnetworks/1.2/utils/include/nnapi/hal/1.2/Device.h
+++ b/neuralnetworks/1.2/utils/include/nnapi/hal/1.2/Device.h
@@ -32,6 +32,9 @@
#include <string>
#include <vector>
+// See hardware/interfaces/neuralnetworks/utils/README.md for more information on HIDL interface
+// lifetimes across processes and for protecting asynchronous calls across HIDL.
+
namespace android::hardware::neuralnetworks::V1_2::utils {
nn::GeneralResult<std::string> initVersionString(V1_2::IDevice* device);
@@ -40,6 +43,7 @@
nn::GeneralResult<std::pair<uint32_t, uint32_t>> initNumberOfCacheFilesNeeded(
V1_2::IDevice* device);
+// Class that adapts V1_2::IDevice to nn::IDevice.
class Device final : public nn::IDevice {
struct PrivateConstructorTag {};
diff --git a/neuralnetworks/1.2/utils/include/nnapi/hal/1.2/PreparedModel.h b/neuralnetworks/1.2/utils/include/nnapi/hal/1.2/PreparedModel.h
index 53bd4d1..8ed5ca7 100644
--- a/neuralnetworks/1.2/utils/include/nnapi/hal/1.2/PreparedModel.h
+++ b/neuralnetworks/1.2/utils/include/nnapi/hal/1.2/PreparedModel.h
@@ -30,8 +30,12 @@
#include <utility>
#include <vector>
+// See hardware/interfaces/neuralnetworks/utils/README.md for more information on HIDL interface
+// lifetimes across processes and for protecting asynchronous calls across HIDL.
+
namespace android::hardware::neuralnetworks::V1_2::utils {
+// Class that adapts V1_2::IPreparedModel to nn::IPreparedModel.
class PreparedModel final : public nn::IPreparedModel {
struct PrivateConstructorTag {};
diff --git a/neuralnetworks/1.2/utils/src/Callbacks.cpp b/neuralnetworks/1.2/utils/src/Callbacks.cpp
index 39f88c2..ab3e0ca 100644
--- a/neuralnetworks/1.2/utils/src/Callbacks.cpp
+++ b/neuralnetworks/1.2/utils/src/Callbacks.cpp
@@ -36,6 +36,9 @@
#include <utility>
+// See hardware/interfaces/neuralnetworks/utils/README.md for more information on HIDL interface
+// lifetimes across processes and for protecting asynchronous calls across HIDL.
+
namespace android::hardware::neuralnetworks::V1_2::utils {
namespace {
diff --git a/neuralnetworks/1.2/utils/src/Device.cpp b/neuralnetworks/1.2/utils/src/Device.cpp
index 0061065..6cca841 100644
--- a/neuralnetworks/1.2/utils/src/Device.cpp
+++ b/neuralnetworks/1.2/utils/src/Device.cpp
@@ -41,6 +41,9 @@
#include <string>
#include <vector>
+// See hardware/interfaces/neuralnetworks/utils/README.md for more information on HIDL interface
+// lifetimes across processes and for protecting asynchronous calls across HIDL.
+
namespace android::hardware::neuralnetworks::V1_2::utils {
namespace {
diff --git a/neuralnetworks/1.2/utils/src/PreparedModel.cpp b/neuralnetworks/1.2/utils/src/PreparedModel.cpp
index 32c2651..b422ced 100644
--- a/neuralnetworks/1.2/utils/src/PreparedModel.cpp
+++ b/neuralnetworks/1.2/utils/src/PreparedModel.cpp
@@ -37,6 +37,9 @@
#include <utility>
#include <vector>
+// See hardware/interfaces/neuralnetworks/utils/README.md for more information on HIDL interface
+// lifetimes across processes and for protecting asynchronous calls across HIDL.
+
namespace android::hardware::neuralnetworks::V1_2::utils {
namespace {
diff --git a/neuralnetworks/1.3/utils/include/nnapi/hal/1.3/Buffer.h b/neuralnetworks/1.3/utils/include/nnapi/hal/1.3/Buffer.h
index 637179d..fda79c8 100644
--- a/neuralnetworks/1.3/utils/include/nnapi/hal/1.3/Buffer.h
+++ b/neuralnetworks/1.3/utils/include/nnapi/hal/1.3/Buffer.h
@@ -24,8 +24,12 @@
#include <nnapi/Types.h>
#include <memory>
+// See hardware/interfaces/neuralnetworks/utils/README.md for more information on HIDL interface
+// lifetimes across processes.
+
namespace android::hardware::neuralnetworks::V1_3::utils {
+// Class that adapts V1_3::IBuffer to nn::IBuffer.
class Buffer final : public nn::IBuffer {
struct PrivateConstructorTag {};
diff --git a/neuralnetworks/1.3/utils/include/nnapi/hal/1.3/Callbacks.h b/neuralnetworks/1.3/utils/include/nnapi/hal/1.3/Callbacks.h
index d46b111..cb2a56a 100644
--- a/neuralnetworks/1.3/utils/include/nnapi/hal/1.3/Callbacks.h
+++ b/neuralnetworks/1.3/utils/include/nnapi/hal/1.3/Callbacks.h
@@ -34,6 +34,9 @@
#include <nnapi/hal/ProtectCallback.h>
#include <nnapi/hal/TransferValue.h>
+// See hardware/interfaces/neuralnetworks/utils/README.md for more information on HIDL interface
+// lifetimes across processes and for protecting asynchronous calls across HIDL.
+
namespace android::hardware::neuralnetworks::V1_3::utils {
class PreparedModelCallback final : public IPreparedModelCallback,
diff --git a/neuralnetworks/1.3/utils/include/nnapi/hal/1.3/Device.h b/neuralnetworks/1.3/utils/include/nnapi/hal/1.3/Device.h
index 0f5234b..84f606a 100644
--- a/neuralnetworks/1.3/utils/include/nnapi/hal/1.3/Device.h
+++ b/neuralnetworks/1.3/utils/include/nnapi/hal/1.3/Device.h
@@ -32,8 +32,12 @@
#include <string>
#include <vector>
+// See hardware/interfaces/neuralnetworks/utils/README.md for more information on HIDL interface
+// lifetimes across processes and for protecting asynchronous calls across HIDL.
+
namespace android::hardware::neuralnetworks::V1_3::utils {
+// Class that adapts V1_3::IDevice to nn::IDevice.
class Device final : public nn::IDevice {
struct PrivateConstructorTag {};
diff --git a/neuralnetworks/1.3/utils/include/nnapi/hal/1.3/PreparedModel.h b/neuralnetworks/1.3/utils/include/nnapi/hal/1.3/PreparedModel.h
index 09360ec..c4ba483 100644
--- a/neuralnetworks/1.3/utils/include/nnapi/hal/1.3/PreparedModel.h
+++ b/neuralnetworks/1.3/utils/include/nnapi/hal/1.3/PreparedModel.h
@@ -29,8 +29,12 @@
#include <utility>
#include <vector>
+// See hardware/interfaces/neuralnetworks/utils/README.md for more information on HIDL interface
+// lifetimes across processes and for protecting asynchronous calls across HIDL.
+
namespace android::hardware::neuralnetworks::V1_3::utils {
+// Class that adapts V1_3::IPreparedModel to nn::IPreparedModel.
class PreparedModel final : public nn::IPreparedModel {
struct PrivateConstructorTag {};
diff --git a/neuralnetworks/1.3/utils/src/Buffer.cpp b/neuralnetworks/1.3/utils/src/Buffer.cpp
index ffdeccd..4ef54a2 100644
--- a/neuralnetworks/1.3/utils/src/Buffer.cpp
+++ b/neuralnetworks/1.3/utils/src/Buffer.cpp
@@ -33,6 +33,9 @@
#include <memory>
#include <utility>
+// See hardware/interfaces/neuralnetworks/utils/README.md for more information on HIDL interface
+// lifetimes across processes.
+
namespace android::hardware::neuralnetworks::V1_3::utils {
nn::GeneralResult<std::shared_ptr<const Buffer>> Buffer::create(
diff --git a/neuralnetworks/1.3/utils/src/Callbacks.cpp b/neuralnetworks/1.3/utils/src/Callbacks.cpp
index e3c6074..17c20fb 100644
--- a/neuralnetworks/1.3/utils/src/Callbacks.cpp
+++ b/neuralnetworks/1.3/utils/src/Callbacks.cpp
@@ -39,6 +39,9 @@
#include <utility>
+// See hardware/interfaces/neuralnetworks/utils/README.md for more information on HIDL interface
+// lifetimes across processes and for protecting asynchronous calls across HIDL.
+
namespace android::hardware::neuralnetworks::V1_3::utils {
namespace {
diff --git a/neuralnetworks/1.3/utils/src/Device.cpp b/neuralnetworks/1.3/utils/src/Device.cpp
index 82837ba..6056498 100644
--- a/neuralnetworks/1.3/utils/src/Device.cpp
+++ b/neuralnetworks/1.3/utils/src/Device.cpp
@@ -47,6 +47,9 @@
#include <string>
#include <vector>
+// See hardware/interfaces/neuralnetworks/utils/README.md for more information on HIDL interface
+// lifetimes across processes and for protecting asynchronous calls across HIDL.
+
namespace android::hardware::neuralnetworks::V1_3::utils {
namespace {
diff --git a/neuralnetworks/1.3/utils/src/PreparedModel.cpp b/neuralnetworks/1.3/utils/src/PreparedModel.cpp
index 124a8db..0bae95d 100644
--- a/neuralnetworks/1.3/utils/src/PreparedModel.cpp
+++ b/neuralnetworks/1.3/utils/src/PreparedModel.cpp
@@ -39,6 +39,9 @@
#include <utility>
#include <vector>
+// See hardware/interfaces/neuralnetworks/utils/README.md for more information on HIDL interface
+// lifetimes across processes and for protecting asynchronous calls across HIDL.
+
namespace android::hardware::neuralnetworks::V1_3::utils {
namespace {
diff --git a/neuralnetworks/utils/README.md b/neuralnetworks/utils/README.md
index 0dee103..45ca0b4 100644
--- a/neuralnetworks/utils/README.md
+++ b/neuralnetworks/utils/README.md
@@ -1,11 +1,11 @@
# NNAPI Conversions
`convert` fails if either the source type or the destination type is invalid, and it yields a valid
-object if the conversion succeeds. For example, let's say that an enumeration in the current
-version has fewer possible values than the "same" canonical enumeration, such as `OperationType`.
-The new value of `HARD_SWISH` (introduced in Android R / NN HAL 1.3) does not map to any valid
-existing value in `OperationType`, but an older value of `ADD` (introduced in Android OC-MR1 / NN
-HAL 1.0) is valid. This can be seen in the following model conversions:
+object if the conversion succeeds. For example, let's say that an enumeration in the current version
+has fewer possible values than the "same" canonical enumeration, such as `OperationType`. The new
+value of `HARD_SWISH` (introduced in Android R / NN HAL 1.3) does not map to any valid existing
+value in `OperationType`, but an older value of `ADD` (introduced in Android OC-MR1 / NN HAL 1.0) is
+valid. This can be seen in the following model conversions:
```cpp
// Unsuccessful conversion
@@ -48,3 +48,50 @@
`unvalidatedConvert` functions operate on types that are either used in a HIDL method call directly
(i.e., not as a nested class) or used in a subsequent version of the NN HAL. Prefer using `convert`
over `unvalidatedConvert`.
+
+# HIDL Interface Lifetimes across Processes
+
+Some notes about HIDL interface objects and lifetimes across processes:
+
+All HIDL interface objects inherit from `IBase`, which itself inherits from `::android::RefBase`. As
+such, all HIDL interface objects are reference counted and must be owned through `::android::sp` (or
+referenced through `::android::wp`). Allocating `RefBase` objects on the stack will log errors and
+may result in crashes, and deleting a `RefBase` object through another means (e.g., "delete",
+"free", or RAII-cleanup through `std::unique_ptr` or some equivalent) will result in double-free
+and/or use-after-free undefined behavior.
+
+HIDL/Binder manages the reference count of HIDL interface objects automatically across processes. If
+a process that references (but did not create) the HIDL interface object dies, HIDL/Binder ensures
+any reference count it held is properly released. (Caveat: it might be possible that HIDL/Binder
+behave strangely with `::android::wp` references.)
+
+If the process which created the HIDL interface object dies, any call on this object from another
+process will result in a HIDL transport error with the code `DEAD_OBJECT`.
+
+# Protecting Asynchronous Calls across HIDL
+
+Some notes about asynchronous calls across HIDL:
+
+For synchronous calls across HIDL, if an error occurs after the function was called but before it
+returns, HIDL will return a transport error. For example, if the message cannot be delivered to the
+server process or if the server process dies before returning a result, HIDL will return from the
+function with the appropriate transport error in the `Return<>` object, which can be queried with
+`Return<>::isOk()`, `Return<>::isDeadObject()`, `Return<>::description()`, etc.
+
+However, HIDL offers no such error management in the case of asynchronous calls. By default, if the
+client launches an asynchronous task and the server fails to return a result through the callback,
+the client will be left waiting indefinitely for a result it will never receive.
+
+In the NNAPI, `IDevice::prepareModel*` and `IPreparedModel::execute*` (but not
+`IPreparedModel::executeSynchronously*`) are asynchronous calls across HIDL. Specifically, these
+asynchronous functions are called with a HIDL interface callback object (`IPrepareModelCallback` for
+`IDevice::prepareModel*` and `IExecutionCallback` for `IPreparedModel::execute*`) and are expected
+to quickly return, and the results are returned at a later time through these callback objects.
+
+To protect against the case when the server dies after the asynchronous task was called successfully
+but before the results could be returned, HIDL provides an object called a "`hidl_death_recipient`,"
+which can be used to detect when an interface object (and more generally, the server process) has
+died. nnapi/hal/ProtectCallback.h's `DeathHandler` uses `hidl_death_recipient`s to detect when the
+driver process has died, and `DeathHandler` will unblock any thread waiting on the results of an
+`IProtectedCallback` callback object that may otherwise not be signaled. In order for this to work,
+the `IProtectedCallback` object must have been registered via `DeathHandler::protectCallback()`.
diff --git a/neuralnetworks/utils/common/include/nnapi/hal/ProtectCallback.h b/neuralnetworks/utils/common/include/nnapi/hal/ProtectCallback.h
index 85bd613..c921885 100644
--- a/neuralnetworks/utils/common/include/nnapi/hal/ProtectCallback.h
+++ b/neuralnetworks/utils/common/include/nnapi/hal/ProtectCallback.h
@@ -28,6 +28,9 @@
#include <mutex>
#include <vector>
+// See hardware/interfaces/neuralnetworks/utils/README.md for more information on HIDL interface
+// lifetimes across processes and for protecting asynchronous calls across HIDL.
+
namespace android::hardware::neuralnetworks::utils {
class IProtectedCallback {
diff --git a/nfc/1.0/vts/functional/AndroidTest.xml b/nfc/1.0/vts/functional/AndroidTest.xml
index 364672b..76aca48 100644
--- a/nfc/1.0/vts/functional/AndroidTest.xml
+++ b/nfc/1.0/vts/functional/AndroidTest.xml
@@ -28,6 +28,6 @@
<test class="com.android.tradefed.testtype.GTest" >
<option name="native-test-device-path" value="/data/local/tmp" />
<option name="module-name" value="VtsHalNfcV1_0TargetTest" />
- <option name="native-test-timeout" value="180000"/>
+ <option name="native-test-timeout" value="600000"/>
</test>
</configuration>
diff --git a/wifi/1.4/vts/functional/wifi_rtt_controller_hidl_test.cpp b/wifi/1.4/vts/functional/wifi_rtt_controller_hidl_test.cpp
index 3977cdd..72cde3c 100644
--- a/wifi/1.4/vts/functional/wifi_rtt_controller_hidl_test.cpp
+++ b/wifi/1.4/vts/functional/wifi_rtt_controller_hidl_test.cpp
@@ -191,6 +191,8 @@
const auto& status =
HIDL_INVOKE(wifi_rtt_controller_, rangeRequest_1_4, cmdId, configs);
EXPECT_EQ(WifiStatusCode::SUCCESS, status.code);
+ // sleep for 2 seconds to wait for driver/firmware to complete RTT
+ sleep(2);
}
/*
* rangeRequest_1_4
@@ -242,6 +244,8 @@
const auto& status =
HIDL_INVOKE(wifi_rtt_controller_, rangeRequest_1_4, cmdId, configs);
EXPECT_EQ(WifiStatusCode::SUCCESS, status.code);
+ // sleep for 2 seconds to wait for driver/firmware to complete RTT
+ sleep(2);
}
/*
diff --git a/wifi/1.5/default/wifi_chip.cpp b/wifi/1.5/default/wifi_chip.cpp
index 44cd5cf..6dd400c 100644
--- a/wifi/1.5/default/wifi_chip.cpp
+++ b/wifi/1.5/default/wifi_chip.cpp
@@ -116,8 +116,8 @@
ifnames.push_back(buffer.data());
if (is_bridged) {
buffer.fill(0);
- if (property_get("ro.vendor.wifi.sap.concurrent.interface",
- buffer.data(), nullptr) == 0) {
+ if (property_get("ro.vendor.wifi.sap.concurrent.iface", buffer.data(),
+ nullptr) == 0) {
return ifnames;
}
ifnames.push_back(buffer.data());
@@ -1851,8 +1851,8 @@
} else {
int num_ifaces_need_to_allocate = 2 - instances.size();
for (int i = 0; i < num_ifaces_need_to_allocate; i++) {
- std::string instance_name =
- allocateApOrStaIfaceName(IfaceType::AP, startIdxOfApIface());
+ std::string instance_name = allocateApOrStaIfaceName(
+ IfaceType::AP, startIdxOfApIface() + i);
if (!instance_name.empty()) {
instances.push_back(instance_name);
}