Waive AID Range check for upgrading devices launched before P
We added a check in P that ensures all vendor provided AIDs only
appear in the carved out ranges for vendors to use. However,
upgrading devices may be using AIDs outside of this range and it is
very difficult to change these AIDs, so we waive this test for them.
Bug: 116830906
Test: test succeeds on upgrading devices
Change-Id: Iddcacb1dce77a150d5138e7b3115abf25bf60a6e
diff --git a/tests/grp_pwd_test.cpp b/tests/grp_pwd_test.cpp
index 24a8648..1c36dcf 100644
--- a/tests/grp_pwd_test.cpp
+++ b/tests/grp_pwd_test.cpp
@@ -33,6 +33,10 @@
#include <android-base/strings.h>
#include <private/android_filesystem_config.h>
+#if defined(__BIONIC__)
+#include <android-base/properties.h>
+#endif
+
// Generated android_ids array
#include "generated_android_ids.h"
@@ -217,6 +221,7 @@
check_get_passwd("u1_i0", 199000, TYPE_APP);
}
+#if defined(__BIONIC__)
template <typename T>
static void expect_ids(const T& ids) {
std::set<typename T::key_type> expected_ids;
@@ -243,6 +248,12 @@
expect_range(AID_SHARED_GID_START, AID_SHARED_GID_END);
expect_range(AID_ISOLATED_START, AID_ISOLATED_END);
+ // Upgrading devices launched before API level 28 may not comply with the below check.
+ // Due to the difficulty in changing uids after launch, it is waived for these devices.
+ if (android::base::GetIntProperty("ro.product.first_api_level", 0) < 28) {
+ return;
+ }
+
// Ensure that no other ids were returned.
auto return_differences = [&ids, &expected_ids] {
std::vector<typename T::key_type> missing_from_ids;
@@ -263,6 +274,7 @@
};
EXPECT_EQ(expected_ids, ids) << return_differences();
}
+#endif
TEST(pwd, getpwent_iterate) {
#if defined(__BIONIC__)