summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorandroid-build-team Robot2018-04-19 02:21:09 -0500
committerandroid-build-team Robot2018-04-19 02:21:09 -0500
commitcb0ee29e765a3f5076b90019f1c22636979ea2f4 (patch)
tree8950def2175740193329ea8e92a3643519682e73
parentde4546f09411c520897c6d2b52df5a98d1b58cec (diff)
parent3c50fab04876f7fc3c6a02f42b718be27944c0fc (diff)
downloadplatform-hardware-interfaces-cb0ee29e765a3f5076b90019f1c22636979ea2f4.tar.gz
platform-hardware-interfaces-cb0ee29e765a3f5076b90019f1c22636979ea2f4.tar.xz
platform-hardware-interfaces-cb0ee29e765a3f5076b90019f1c22636979ea2f4.zip
Snap for 4731145 from 3c50fab04876f7fc3c6a02f42b718be27944c0fc to pi-release
Change-Id: I715d042786e189575e5ce9a0f7c231883589cf5f
-rw-r--r--audio/core/4.0/vts/functional/AudioPrimaryHidlHalTest.cpp78
-rw-r--r--audio/core/all-versions/default/include/core/all-versions/default/PrimaryDevice.impl.h12
-rw-r--r--automotive/vehicle/2.0/types.hal40
-rw-r--r--current.txt2
-rw-r--r--wifi/1.2/default/wifi_chip.cpp32
5 files changed, 121 insertions, 43 deletions
diff --git a/audio/core/4.0/vts/functional/AudioPrimaryHidlHalTest.cpp b/audio/core/4.0/vts/functional/AudioPrimaryHidlHalTest.cpp
index a568a3ce..9484ddd4 100644
--- a/audio/core/4.0/vts/functional/AudioPrimaryHidlHalTest.cpp
+++ b/audio/core/4.0/vts/functional/AudioPrimaryHidlHalTest.cpp
@@ -63,6 +63,7 @@ using ::android::hardware::audio::V4_0::AudioDrain;
63using ::android::hardware::audio::V4_0::DeviceAddress; 63using ::android::hardware::audio::V4_0::DeviceAddress;
64using ::android::hardware::audio::V4_0::IDevice; 64using ::android::hardware::audio::V4_0::IDevice;
65using ::android::hardware::audio::V4_0::IPrimaryDevice; 65using ::android::hardware::audio::V4_0::IPrimaryDevice;
66using Rotation = ::android::hardware::audio::V4_0::IPrimaryDevice::Rotation;
66using TtyMode = ::android::hardware::audio::V4_0::IPrimaryDevice::TtyMode; 67using TtyMode = ::android::hardware::audio::V4_0::IPrimaryDevice::TtyMode;
67using ::android::hardware::audio::V4_0::IDevicesFactory; 68using ::android::hardware::audio::V4_0::IDevicesFactory;
68using ::android::hardware::audio::V4_0::IStream; 69using ::android::hardware::audio::V4_0::IStream;
@@ -95,6 +96,11 @@ using ::android::hardware::audio::common::utils::mkBitfield;
95 96
96using namespace ::android::hardware::audio::common::test::utility; 97using namespace ::android::hardware::audio::common::test::utility;
97 98
99// Typical accepted results from interface methods
100static auto okOrNotSupported = {Result::OK, Result::NOT_SUPPORTED};
101static auto okOrNotSupportedOrInvalidArgs = {Result::OK, Result::NOT_SUPPORTED,
102 Result::INVALID_ARGUMENTS};
103
98class AudioHidlTestEnvironment : public ::Environment { 104class AudioHidlTestEnvironment : public ::Environment {
99 public: 105 public:
100 virtual void registerTestServices() override { registerTestService<IDevicesFactory>(); } 106 virtual void registerTestServices() override { registerTestService<IDevicesFactory>(); }
@@ -439,11 +445,7 @@ INSTANTIATE_TEST_CASE_P(
439TEST_F(AudioPrimaryHidlTest, setScreenState) { 445TEST_F(AudioPrimaryHidlTest, setScreenState) {
440 doc::test("Check that the hal can receive the screen state"); 446 doc::test("Check that the hal can receive the screen state");
441 for (bool turnedOn : {false, true, true, false, false}) { 447 for (bool turnedOn : {false, true, true, false, false}) {
442 auto ret = device->setScreenState(turnedOn); 448 ASSERT_RESULT(okOrNotSupported, device->setScreenState(turnedOn));
443 ASSERT_IS_OK(ret);
444 Result result = ret;
445 auto okOrNotSupported = {Result::OK, Result::NOT_SUPPORTED};
446 ASSERT_RESULT(okOrNotSupported, result);
447 } 449 }
448} 450}
449 451
@@ -783,7 +785,7 @@ TEST_IO_STREAM(SupportedFormat, "Check that the stream format is declared as sup
783 testCapabilityGetter("getSupportedFormat", stream.get(), &getSupportedFormats, 785 testCapabilityGetter("getSupportedFormat", stream.get(), &getSupportedFormats,
784 &IStream::getFormat, &IStream::setFormat)) 786 &IStream::getFormat, &IStream::setFormat))
785 787
786static void testGetDevice(IStream* stream, AudioDevice expectedDevice) { 788static void testGetDevices(IStream* stream, AudioDevice expectedDevice) {
787 hidl_vec<DeviceAddress> devices; 789 hidl_vec<DeviceAddress> devices;
788 Result res; 790 Result res;
789 ASSERT_OK(stream->getDevices(returnIn(res, devices))); 791 ASSERT_OK(stream->getDevices(returnIn(res, devices)));
@@ -798,11 +800,11 @@ static void testGetDevice(IStream* stream, AudioDevice expectedDevice) {
798 << "\n Actual: " << ::testing::PrintToString(device); 800 << "\n Actual: " << ::testing::PrintToString(device);
799} 801}
800 802
801TEST_IO_STREAM(GetDevice, "Check that the stream device == the one it was opened with", 803TEST_IO_STREAM(GetDevices, "Check that the stream device == the one it was opened with",
802 areAudioPatchesSupported() ? doc::partialTest("Audio patches are supported") 804 areAudioPatchesSupported() ? doc::partialTest("Audio patches are supported")
803 : testGetDevice(stream.get(), address.device)) 805 : testGetDevices(stream.get(), address.device))
804 806
805static void testSetDevice(IStream* stream, const DeviceAddress& address) { 807static void testSetDevices(IStream* stream, const DeviceAddress& address) {
806 DeviceAddress otherAddress = address; 808 DeviceAddress otherAddress = address;
807 otherAddress.device = (address.device & AudioDevice::BIT_IN) == 0 ? AudioDevice::OUT_SPEAKER 809 otherAddress.device = (address.device & AudioDevice::BIT_IN) == 0 ? AudioDevice::OUT_SPEAKER
808 : AudioDevice::IN_BUILTIN_MIC; 810 : AudioDevice::IN_BUILTIN_MIC;
@@ -811,9 +813,9 @@ static void testSetDevice(IStream* stream, const DeviceAddress& address) {
811 ASSERT_OK(stream->setDevices({address})); // Go back to the original value 813 ASSERT_OK(stream->setDevices({address})); // Go back to the original value
812} 814}
813 815
814TEST_IO_STREAM(SetDevice, "Check that the stream can be rerouted to SPEAKER or BUILTIN_MIC", 816TEST_IO_STREAM(SetDevices, "Check that the stream can be rerouted to SPEAKER or BUILTIN_MIC",
815 areAudioPatchesSupported() ? doc::partialTest("Audio patches are supported") 817 areAudioPatchesSupported() ? doc::partialTest("Audio patches are supported")
816 : testSetDevice(stream.get(), address)) 818 : testSetDevices(stream.get(), address))
817 819
818static void testGetAudioProperties(IStream* stream, AudioConfig expectedConfig) { 820static void testGetAudioProperties(IStream* stream, AudioConfig expectedConfig) {
819 uint32_t sampleRateHz; 821 uint32_t sampleRateHz;
@@ -833,10 +835,8 @@ TEST_IO_STREAM(GetAudioProperties,
833 "Check that the stream audio properties == the ones it was opened with", 835 "Check that the stream audio properties == the ones it was opened with",
834 testGetAudioProperties(stream.get(), audioConfig)) 836 testGetAudioProperties(stream.get(), audioConfig))
835 837
836static auto invalidArgsOrNotSupportedOrOK = {Result::INVALID_ARGUMENTS, Result::NOT_SUPPORTED,
837 Result::OK};
838TEST_IO_STREAM(SetHwAvSync, "Try to set hardware sync to an invalid value", 838TEST_IO_STREAM(SetHwAvSync, "Try to set hardware sync to an invalid value",
839 ASSERT_RESULT(invalidArgsOrNotSupportedOrOK, stream->setHwAvSync(666))) 839 ASSERT_RESULT(okOrNotSupportedOrInvalidArgs, stream->setHwAvSync(666)))
840 840
841static void checkGetHwAVSync(IDevice* device) { 841static void checkGetHwAVSync(IDevice* device) {
842 Result res; 842 Result res;
@@ -882,7 +882,7 @@ TEST_IO_STREAM(setNonExistingParameter, "Set the values of an non existing param
882 // error code when a key is not supported. 882 // error code when a key is not supported.
883 // To allow implementation to just wrapped the legacy one, consider OK as a 883 // To allow implementation to just wrapped the legacy one, consider OK as a
884 // valid result for setting a non existing parameter. 884 // valid result for setting a non existing parameter.
885 ASSERT_RESULT(invalidArgsOrNotSupportedOrOK, 885 ASSERT_RESULT(okOrNotSupportedOrInvalidArgs,
886 stream->setParameters({}, {{"non existing key", "0"}}))) 886 stream->setParameters({}, {{"non existing key", "0"}})))
887 887
888TEST_IO_STREAM(DebugDump, "Check that a stream can dump its state without error", 888TEST_IO_STREAM(DebugDump, "Check that a stream can dump its state without error",
@@ -1147,7 +1147,6 @@ static bool isAsyncModeSupported(IStreamOut* stream) {
1147 auto res = stream->setCallback(new MockOutCallbacks); 1147 auto res = stream->setCallback(new MockOutCallbacks);
1148 stream->clearCallback(); // try to restore the no callback state, ignore 1148 stream->clearCallback(); // try to restore the no callback state, ignore
1149 // any error 1149 // any error
1150 auto okOrNotSupported = {Result::OK, Result::NOT_SUPPORTED};
1151 EXPECT_RESULT(okOrNotSupported, res); 1150 EXPECT_RESULT(okOrNotSupported, res);
1152 return res.isOk() ? res == Result::OK : false; 1151 return res.isOk() ? res == Result::OK : false;
1153} 1152}
@@ -1257,6 +1256,11 @@ TEST_P(OutputStreamTest, GetPresentationPositionStop) {
1257 ASSERT_PRED2([](auto c, auto m) { return c - m < 1e+6; }, currentTime, mesureTime); 1256 ASSERT_PRED2([](auto c, auto m) { return c - m < 1e+6; }, currentTime, mesureTime);
1258} 1257}
1259 1258
1259TEST_P(OutputStreamTest, SelectPresentation) {
1260 doc::test("Verify that presentation selection does not crash");
1261 ASSERT_RESULT(okOrNotSupported, stream->selectPresentation(0, 0));
1262}
1263
1260////////////////////////////////////////////////////////////////////////////// 1264//////////////////////////////////////////////////////////////////////////////
1261/////////////////////////////// PrimaryDevice //////////////////////////////// 1265/////////////////////////////// PrimaryDevice ////////////////////////////////
1262////////////////////////////////////////////////////////////////////////////// 1266//////////////////////////////////////////////////////////////////////////////
@@ -1283,6 +1287,42 @@ TEST_F(AudioPrimaryHidlTest, setMode) {
1283 } 1287 }
1284} 1288}
1285 1289
1290TEST_F(AudioPrimaryHidlTest, setBtHfpSampleRate) {
1291 doc::test(
1292 "Make sure setBtHfpSampleRate either succeeds or "
1293 "indicates that it is not supported at all, or that the provided value is invalid");
1294 for (auto samplingRate : {8000, 16000, 22050, 24000}) {
1295 ASSERT_RESULT(okOrNotSupportedOrInvalidArgs, device->setBtHfpSampleRate(samplingRate));
1296 }
1297}
1298
1299TEST_F(AudioPrimaryHidlTest, setBtHfpVolume) {
1300 doc::test(
1301 "Make sure setBtHfpVolume is either not supported or "
1302 "only succeed if volume is in [0,1]");
1303 auto ret = device->setBtHfpVolume(0.0);
1304 if (ret == Result::NOT_SUPPORTED) {
1305 doc::partialTest("setBtHfpVolume is not supported");
1306 return;
1307 }
1308 testUnitaryGain([](float volume) { return device->setBtHfpVolume(volume); });
1309}
1310
1311TEST_F(AudioPrimaryHidlTest, setBtScoHeadsetDebugName) {
1312 doc::test(
1313 "Make sure setBtScoHeadsetDebugName either succeeds or "
1314 "indicates that it is not supported");
1315 ASSERT_RESULT(okOrNotSupported, device->setBtScoHeadsetDebugName("test"));
1316}
1317
1318TEST_F(AudioPrimaryHidlTest, updateRotation) {
1319 doc::test("Check that the hal can receive the current rotation");
1320 for (Rotation rotation : {Rotation::DEG_0, Rotation::DEG_90, Rotation::DEG_180,
1321 Rotation::DEG_270, Rotation::DEG_0}) {
1322 ASSERT_RESULT(okOrNotSupported, device->updateRotation(rotation));
1323 }
1324}
1325
1286TEST_F(BoolAccessorPrimaryHidlTest, BtScoNrecEnabled) { 1326TEST_F(BoolAccessorPrimaryHidlTest, BtScoNrecEnabled) {
1287 doc::test("Query and set the BT SCO NR&EC state"); 1327 doc::test("Query and set the BT SCO NR&EC state");
1288 testOptionalAccessors("BtScoNrecEnabled", {true, false, true}, 1328 testOptionalAccessors("BtScoNrecEnabled", {true, false, true},
@@ -1297,6 +1337,12 @@ TEST_F(BoolAccessorPrimaryHidlTest, setGetBtScoWidebandEnabled) {
1297 &IPrimaryDevice::getBtScoWidebandEnabled); 1337 &IPrimaryDevice::getBtScoWidebandEnabled);
1298} 1338}
1299 1339
1340TEST_F(BoolAccessorPrimaryHidlTest, setGetBtHfpEnabled) {
1341 doc::test("Query and set the BT HFP state");
1342 testOptionalAccessors("BtHfpEnabled", {true, false, true}, &IPrimaryDevice::setBtHfpEnabled,
1343 &IPrimaryDevice::getBtHfpEnabled);
1344}
1345
1300using TtyModeAccessorPrimaryHidlTest = AccessorPrimaryHidlTest<TtyMode>; 1346using TtyModeAccessorPrimaryHidlTest = AccessorPrimaryHidlTest<TtyMode>;
1301TEST_F(TtyModeAccessorPrimaryHidlTest, setGetTtyMode) { 1347TEST_F(TtyModeAccessorPrimaryHidlTest, setGetTtyMode) {
1302 doc::test("Query and set the TTY mode state"); 1348 doc::test("Query and set the TTY mode state");
diff --git a/audio/core/all-versions/default/include/core/all-versions/default/PrimaryDevice.impl.h b/audio/core/all-versions/default/include/core/all-versions/default/PrimaryDevice.impl.h
index f00cac4e..9b39d9c9 100644
--- a/audio/core/all-versions/default/include/core/all-versions/default/PrimaryDevice.impl.h
+++ b/audio/core/all-versions/default/include/core/all-versions/default/PrimaryDevice.impl.h
@@ -16,6 +16,10 @@
16 16
17#include <common/all-versions/IncludeGuard.h> 17#include <common/all-versions/IncludeGuard.h>
18 18
19#ifdef AUDIO_HAL_VERSION_4_0
20#include <cmath>
21#endif
22
19namespace android { 23namespace android {
20namespace hardware { 24namespace hardware {
21namespace audio { 25namespace audio {
@@ -244,7 +248,13 @@ Return<Result> PrimaryDevice::setBtHfpSampleRate(uint32_t sampleRateHz) {
244 return mDevice->setParam(AUDIO_PARAMETER_KEY_HFP_SET_SAMPLING_RATE, int(sampleRateHz)); 248 return mDevice->setParam(AUDIO_PARAMETER_KEY_HFP_SET_SAMPLING_RATE, int(sampleRateHz));
245} 249}
246Return<Result> PrimaryDevice::setBtHfpVolume(float volume) { 250Return<Result> PrimaryDevice::setBtHfpVolume(float volume) {
247 return mDevice->setParam(AUDIO_PARAMETER_KEY_HFP_VOLUME, volume); 251 if (!all_versions::implementation::isGainNormalized(volume)) {
252 ALOGW("Can not set BT HFP volume (%f) outside [0,1]", volume);
253 return Result::INVALID_ARGUMENTS;
254 }
255 // Map the normalized volume onto the range of [0, 15]
256 return mDevice->setParam(AUDIO_PARAMETER_KEY_HFP_VOLUME,
257 static_cast<int>(std::round(volume * 15)));
248} 258}
249Return<Result> PrimaryDevice::updateRotation(IPrimaryDevice::Rotation rotation) { 259Return<Result> PrimaryDevice::updateRotation(IPrimaryDevice::Rotation rotation) {
250 // legacy API expects the rotation in degree 260 // legacy API expects the rotation in degree
diff --git a/automotive/vehicle/2.0/types.hal b/automotive/vehicle/2.0/types.hal
index 15ba4940..12e2257a 100644
--- a/automotive/vehicle/2.0/types.hal
+++ b/automotive/vehicle/2.0/types.hal
@@ -654,7 +654,8 @@ enum VehicleProperty : int32_t {
654 * HVAC current temperature. 654 * HVAC current temperature.
655 * 655 *
656 * @change_mode VehiclePropertyChangeMode:ON_CHANGE 656 * @change_mode VehiclePropertyChangeMode:ON_CHANGE
657 * @access VehiclePropertyAccess:READ_WRITE 657 * @access VehiclePropertyAccess:READ
658 * @unit VehicleUnit:CELSIUS
658 */ 659 */
659 HVAC_TEMPERATURE_CURRENT = ( 660 HVAC_TEMPERATURE_CURRENT = (
660 0x0502 661 0x0502
@@ -667,6 +668,7 @@ enum VehicleProperty : int32_t {
667 * 668 *
668 * @change_mode VehiclePropertyChangeMode:ON_CHANGE 669 * @change_mode VehiclePropertyChangeMode:ON_CHANGE
669 * @access VehiclePropertyAccess:READ_WRITE 670 * @access VehiclePropertyAccess:READ_WRITE
671 * @unit VehicleUnit:CELSIUS
670 */ 672 */
671 HVAC_TEMPERATURE_SET = ( 673 HVAC_TEMPERATURE_SET = (
672 0x0503 674 0x0503
@@ -791,7 +793,7 @@ enum VehicleProperty : int32_t {
791 | VehicleArea:SEAT), 793 | VehicleArea:SEAT),
792 794
793 /** 795 /**
794 * Seat temperature 796 * Seat heating/cooling
795 * 797 *
796 * Negative values indicate cooling. 798 * Negative values indicate cooling.
797 * 0 indicates off. 799 * 0 indicates off.
@@ -847,9 +849,11 @@ enum VehicleProperty : int32_t {
847 /** 849 /**
848 * Temperature units for display 850 * Temperature units for display
849 * 851 *
850 * Indicates whether the temperature is in Celsius, Fahrenheit, or a 852 * Indicates whether the vehicle is displaying temperature to the user as
851 * different unit from VehicleUnit enum. This parameter MAY be used for 853 * Celsius or Fahrenheit.
852 * displaying any HVAC temperature in the system. 854 * This parameter MAY be used for displaying any HVAC temperature in the system.
855 * Values must be one of VehicleUnit::CELSIUS or VehicleUnit::FAHRENHEIT
856 * Note that internally, all temperatures are represented in floating point Celsius.
853 * 857 *
854 * @change_mode VehiclePropertyChangeMode:ON_CHANGE 858 * @change_mode VehiclePropertyChangeMode:ON_CHANGE
855 * @access VehiclePropertyAccess:READ_WRITE 859 * @access VehiclePropertyAccess:READ_WRITE
@@ -1629,8 +1633,8 @@ enum VehicleProperty : int32_t {
1629 /** 1633 /**
1630 * Window Position 1634 * Window Position
1631 * 1635 *
1632 * Max = window up / closed 1636 * Min = window up / closed
1633 * Min = window down / open 1637 * Max = window down / open
1634 * 1638 *
1635 * For a window that may open out of plane (i.e. vent mode of sunroof) this 1639 * For a window that may open out of plane (i.e. vent mode of sunroof) this
1636 * parameter will work with negative values as follows: 1640 * parameter will work with negative values as follows:
@@ -1652,25 +1656,25 @@ enum VehicleProperty : int32_t {
1652 /** 1656 /**
1653 * Window Move 1657 * Window Move
1654 * 1658 *
1655 * Max = window up / closed 1659 * Max = Open the window as fast as possible
1656 * Min = window down / open 1660 * Min = Close the window as fast as possible
1657 * Magnitude denotes relative speed. I.e. +2 is faster than +1 in raising 1661 * Magnitude denotes relative speed. I.e. +2 is faster than +1 in closing
1658 * the window. 1662 * the window.
1659 * 1663 *
1660 * For a window that may open out of plane (i.e. vent mode of sunroof) this 1664 * For a window that may open out of plane (i.e. vent mode of sunroof) this
1661 * parameter will work as follows: 1665 * parameter will work as follows:
1662 * 1666 *
1663 * If sunroof is open: 1667 * If sunroof is open:
1664 * Max = open the sunroof further, automatically stop when fully open. 1668 * Max = open the sunroof further, automatically stop when fully open.
1665 * Min = close the sunroof, automatically stop when sunroof is closed. 1669 * Min = close the sunroof, automatically stop when sunroof is closed.
1666 * 1670 *
1667 * If vent is open: 1671 * If vent is open:
1668 * Max = close the vent, automatically stop when vent is closed. 1672 * Max = close the vent, automatically stop when vent is closed.
1669 * Min = open the vent further, automatically stop when vent is fully open. 1673 * Min = open the vent further, automatically stop when vent is fully open.
1670 * 1674 *
1671 * If window is in the closed position: 1675 * If sunroof is in the closed position:
1672 * Max = open the sunroof, automatically stop when sunroof is fully open. 1676 * Max = open the sunroof, automatically stop when sunroof is fully open.
1673 * Min = open the vent, automatically stop when vent is fully open. 1677 * Min = open the vent, automatically stop when vent is fully open.
1674 * 1678 *
1675 * @change_mode VehiclePropertyChangeMode:ON_CHANGE 1679 * @change_mode VehiclePropertyChangeMode:ON_CHANGE
1676 * @access VehiclePropertyAccess:READ_WRITE 1680 * @access VehiclePropertyAccess:READ_WRITE
diff --git a/current.txt b/current.txt
index 7e4b1021..75b1a06e 100644
--- a/current.txt
+++ b/current.txt
@@ -299,7 +299,7 @@ f2904a4c108ad1b93eb2fa4e43b82bd01ce1ff26156316e49d1d9fc80dfecaad android.hardwar
2993b17c1fdfc389e0abe626c37054954b07201127d890c2bc05d47613ec1f4de4f android.hardware.automotive.evs@1.0::types 2993b17c1fdfc389e0abe626c37054954b07201127d890c2bc05d47613ec1f4de4f android.hardware.automotive.evs@1.0::types
300b3caf524c46a47d67e6453a34419e1881942d059e146cda740502670e9a752c3 android.hardware.automotive.vehicle@2.0::IVehicle 300b3caf524c46a47d67e6453a34419e1881942d059e146cda740502670e9a752c3 android.hardware.automotive.vehicle@2.0::IVehicle
3017ce8728b27600e840cacf0a832f6942819fe535f9d3797ae052d5eef5065921c android.hardware.automotive.vehicle@2.0::IVehicleCallback 3017ce8728b27600e840cacf0a832f6942819fe535f9d3797ae052d5eef5065921c android.hardware.automotive.vehicle@2.0::IVehicleCallback
302848fb32d5ca79dd527d966e67c0af5874b6d7b361246b491e315cf7dea7888ab android.hardware.automotive.vehicle@2.0::types 3022e1815967a3e3278a7f304ed7efc04fbc56d0bb65b3126248c3a0d515b93f63d android.hardware.automotive.vehicle@2.0::types
30332cc50cc2a7658ec613c0c2dd2accbf6a05113b749852879e818b8b7b438db19 android.hardware.bluetooth.a2dp@1.0::IBluetoothAudioHost 30332cc50cc2a7658ec613c0c2dd2accbf6a05113b749852879e818b8b7b438db19 android.hardware.bluetooth.a2dp@1.0::IBluetoothAudioHost
304ff4be64d7992f8bec97dff37f35450e79b3430c61f85f54322ce45bef229dc3b android.hardware.bluetooth.a2dp@1.0::IBluetoothAudioOffload 304ff4be64d7992f8bec97dff37f35450e79b3430c61f85f54322ce45bef229dc3b android.hardware.bluetooth.a2dp@1.0::IBluetoothAudioOffload
30527f22d2e873e6201f9620cf4d8e2facb25bd0dd30a2b911e441b4600d560fa62 android.hardware.bluetooth.a2dp@1.0::types 30527f22d2e873e6201f9620cf4d8e2facb25bd0dd30a2b911e441b4600d560fa62 android.hardware.bluetooth.a2dp@1.0::types
diff --git a/wifi/1.2/default/wifi_chip.cpp b/wifi/1.2/default/wifi_chip.cpp
index dcd0a3ce..ab96ef1b 100644
--- a/wifi/1.2/default/wifi_chip.cpp
+++ b/wifi/1.2/default/wifi_chip.cpp
@@ -48,6 +48,7 @@ constexpr ChipModeId kV2ChipModeId = 2;
48constexpr char kCpioMagic[] = "070701"; 48constexpr char kCpioMagic[] = "070701";
49constexpr size_t kMaxBufferSizeBytes = 1024 * 1024; 49constexpr size_t kMaxBufferSizeBytes = 1024 * 1024;
50constexpr uint32_t kMaxRingBufferFileAgeSeconds = 60 * 60; 50constexpr uint32_t kMaxRingBufferFileAgeSeconds = 60 * 60;
51constexpr uint32_t kMaxRingBufferFileNum = 20;
51constexpr char kTombstoneFolderPath[] = "/data/vendor/tombstones/wifi/"; 52constexpr char kTombstoneFolderPath[] = "/data/vendor/tombstones/wifi/";
52 53
53template <typename Iface> 54template <typename Iface>
@@ -104,7 +105,9 @@ std::string getP2pIfaceName() {
104 return buffer.data(); 105 return buffer.data();
105} 106}
106 107
107// delete files older than a predefined time in the wifi tombstone dir 108// delete files that meet either conditions:
109// 1. older than a predefined time in the wifi tombstone dir.
110// 2. Files in excess to a predefined amount, starting from the oldest ones
108bool removeOldFilesInternal() { 111bool removeOldFilesInternal() {
109 time_t now = time(0); 112 time_t now = time(0);
110 const time_t delete_files_before = now - kMaxRingBufferFileAgeSeconds; 113 const time_t delete_files_before = now - kMaxRingBufferFileAgeSeconds;
@@ -116,6 +119,7 @@ bool removeOldFilesInternal() {
116 unique_fd dir_auto_closer(dirfd(dir_dump)); 119 unique_fd dir_auto_closer(dirfd(dir_dump));
117 struct dirent* dp; 120 struct dirent* dp;
118 bool success = true; 121 bool success = true;
122 std::list<std::pair<const time_t, std::string>> valid_files;
119 while ((dp = readdir(dir_dump))) { 123 while ((dp = readdir(dir_dump))) {
120 if (dp->d_type != DT_REG) { 124 if (dp->d_type != DT_REG) {
121 continue; 125 continue;
@@ -129,12 +133,23 @@ bool removeOldFilesInternal() {
129 success = false; 133 success = false;
130 continue; 134 continue;
131 } 135 }
132 if (cur_file_stat.st_mtime >= delete_files_before) { 136 const time_t cur_file_time = cur_file_stat.st_mtime;
133 continue; 137 valid_files.push_back(
134 } 138 std::pair<const time_t, std::string>(cur_file_time, cur_file_path));
135 if (unlink(cur_file_path.c_str()) != 0) { 139 }
136 LOG(ERROR) << "Error deleting file " << strerror(errno); 140 valid_files.sort(); // sort the list of files by last modified time from
137 success = false; 141 // small to big.
142 uint32_t cur_file_count = valid_files.size();
143 for (auto cur_file : valid_files) {
144 if (cur_file_count > kMaxRingBufferFileNum ||
145 cur_file.first < delete_files_before) {
146 if (unlink(cur_file.second.c_str()) != 0) {
147 LOG(ERROR) << "Error deleting file " << strerror(errno);
148 success = false;
149 }
150 cur_file_count--;
151 } else {
152 break;
138 } 153 }
139 } 154 }
140 return success; 155 return success;
@@ -309,6 +324,9 @@ WifiChip::WifiChip(
309} 324}
310 325
311void WifiChip::invalidate() { 326void WifiChip::invalidate() {
327 if (!writeRingbufferFilesInternal()) {
328 LOG(ERROR) << "Error writing files to flash";
329 }
312 invalidateAndRemoveAllIfaces(); 330 invalidateAndRemoveAllIfaces();
313 legacy_hal_.reset(); 331 legacy_hal_.reset();
314 event_cb_handler_.invalidate(); 332 event_cb_handler_.invalidate();