Loading audio/7.0/config/audio_policy_configuration.xsd +9 −5 Original line number Diff line number Diff line Loading @@ -310,13 +310,17 @@ </xs:restriction> </xs:simpleType> <xs:simpleType name="vendorExtension"> <!-- Vendor extension names must be prefixed by "VX_" to distinguish them from AOSP values. Vendor are encouraged to namespace their module names to avoid conflicts. Example for an hypothetical Google virtual reality device: <devicePort tagName="VR" type="VX_GOOGLE_VR" role="sink"> <!-- Vendor extension names must be prefixed by "VX_" to distinguish them from AOSP values. Vendors must namespace their names to avoid conflicts. The namespace part must only use capital latin characters and decimal digits and consist of at least 3 characters. The part of the extension name after the namespace may in addition include underscores. Example for a hypothetical Google virtual reality device: <devicePort tagName="VR" type="VX_GOOGLE_VR" role="sink" /> --> <xs:restriction base="xs:string"> <xs:pattern value="VX_[_a-zA-Z0-9]+"/> <xs:pattern value="VX_[A-Z0-9]{3,}_[_A-Z0-9]+"/> </xs:restriction> </xs:simpleType> <xs:simpleType name="extendableAudioDevice"> Loading audio/common/7.0/enums/include/android_audio_policy_configuration_V7_0-enums.h +5 −7 Original line number Diff line number Diff line Loading @@ -18,8 +18,8 @@ #define ANDROID_AUDIO_POLICY_CONFIGURATION_V7_0__ENUMS_H #include <sys/types.h> #include <algorithm> #include <cctype> #include <regex> #include <string> #include <android_audio_policy_configuration_V7_0_enums.h> Loading Loading @@ -219,11 +219,9 @@ static inline bool maybeVendorExtension(const std::string& s) { } static inline bool isVendorExtension(const std::string& s) { // Must match the "vendorExtension" rule from the XSD file. static const std::string vendorPrefix = "VX_"; return maybeVendorExtension(s) && std::all_of(s.begin() + vendorPrefix.size(), s.end(), [](unsigned char c) { return c == '_' || std::isalnum(c); }); // Must be the same as the "vendorExtension" rule from the XSD file. static const std::regex vendorExtension("VX_[A-Z0-9]{3,}_[_A-Z0-9]+"); return std::regex_match(s.begin(), s.end(), vendorExtension); } static inline bool isUnknownAudioChannelMask(const std::string& mask) { Loading audio/common/all-versions/default/tests/hidlutils_tests.cpp +6 −0 Original line number Diff line number Diff line Loading @@ -432,10 +432,16 @@ TEST(HidlUtils, ConvertDeviceType) { // The enums module is too small to have unit tests on its own. TEST(HidlUtils, VendorExtension) { EXPECT_TRUE(xsd::isVendorExtension("VX_GOOGLE_VR_42")); EXPECT_TRUE(xsd::isVendorExtension("VX_QCM_SPK")); EXPECT_FALSE(xsd::isVendorExtension("")); EXPECT_FALSE(xsd::isVendorExtension("random string")); EXPECT_FALSE(xsd::isVendorExtension("VX_")); EXPECT_FALSE(xsd::isVendorExtension("VX_X")); EXPECT_FALSE(xsd::isVendorExtension("VX_X_")); EXPECT_FALSE(xsd::isVendorExtension("VX_X_X")); EXPECT_FALSE(xsd::isVendorExtension("VX_XX_X")); EXPECT_FALSE(xsd::isVendorExtension("VX_GOOGLE_$$")); EXPECT_FALSE(xsd::isVendorExtension("VX_$CM_SPK")); } TEST(HidlUtils, ConvertInvalidDeviceAddress) { Loading Loading
audio/7.0/config/audio_policy_configuration.xsd +9 −5 Original line number Diff line number Diff line Loading @@ -310,13 +310,17 @@ </xs:restriction> </xs:simpleType> <xs:simpleType name="vendorExtension"> <!-- Vendor extension names must be prefixed by "VX_" to distinguish them from AOSP values. Vendor are encouraged to namespace their module names to avoid conflicts. Example for an hypothetical Google virtual reality device: <devicePort tagName="VR" type="VX_GOOGLE_VR" role="sink"> <!-- Vendor extension names must be prefixed by "VX_" to distinguish them from AOSP values. Vendors must namespace their names to avoid conflicts. The namespace part must only use capital latin characters and decimal digits and consist of at least 3 characters. The part of the extension name after the namespace may in addition include underscores. Example for a hypothetical Google virtual reality device: <devicePort tagName="VR" type="VX_GOOGLE_VR" role="sink" /> --> <xs:restriction base="xs:string"> <xs:pattern value="VX_[_a-zA-Z0-9]+"/> <xs:pattern value="VX_[A-Z0-9]{3,}_[_A-Z0-9]+"/> </xs:restriction> </xs:simpleType> <xs:simpleType name="extendableAudioDevice"> Loading
audio/common/7.0/enums/include/android_audio_policy_configuration_V7_0-enums.h +5 −7 Original line number Diff line number Diff line Loading @@ -18,8 +18,8 @@ #define ANDROID_AUDIO_POLICY_CONFIGURATION_V7_0__ENUMS_H #include <sys/types.h> #include <algorithm> #include <cctype> #include <regex> #include <string> #include <android_audio_policy_configuration_V7_0_enums.h> Loading Loading @@ -219,11 +219,9 @@ static inline bool maybeVendorExtension(const std::string& s) { } static inline bool isVendorExtension(const std::string& s) { // Must match the "vendorExtension" rule from the XSD file. static const std::string vendorPrefix = "VX_"; return maybeVendorExtension(s) && std::all_of(s.begin() + vendorPrefix.size(), s.end(), [](unsigned char c) { return c == '_' || std::isalnum(c); }); // Must be the same as the "vendorExtension" rule from the XSD file. static const std::regex vendorExtension("VX_[A-Z0-9]{3,}_[_A-Z0-9]+"); return std::regex_match(s.begin(), s.end(), vendorExtension); } static inline bool isUnknownAudioChannelMask(const std::string& mask) { Loading
audio/common/all-versions/default/tests/hidlutils_tests.cpp +6 −0 Original line number Diff line number Diff line Loading @@ -432,10 +432,16 @@ TEST(HidlUtils, ConvertDeviceType) { // The enums module is too small to have unit tests on its own. TEST(HidlUtils, VendorExtension) { EXPECT_TRUE(xsd::isVendorExtension("VX_GOOGLE_VR_42")); EXPECT_TRUE(xsd::isVendorExtension("VX_QCM_SPK")); EXPECT_FALSE(xsd::isVendorExtension("")); EXPECT_FALSE(xsd::isVendorExtension("random string")); EXPECT_FALSE(xsd::isVendorExtension("VX_")); EXPECT_FALSE(xsd::isVendorExtension("VX_X")); EXPECT_FALSE(xsd::isVendorExtension("VX_X_")); EXPECT_FALSE(xsd::isVendorExtension("VX_X_X")); EXPECT_FALSE(xsd::isVendorExtension("VX_XX_X")); EXPECT_FALSE(xsd::isVendorExtension("VX_GOOGLE_$$")); EXPECT_FALSE(xsd::isVendorExtension("VX_$CM_SPK")); } TEST(HidlUtils, ConvertInvalidDeviceAddress) { Loading