Hide __system_property_add/update, deprecate find_nth
These functions are supposed to be used only by the
property service.
__system_property_find_nth is deprecated and no longer part
of NDK. Call to this function will result in abort for apps
targeting Android O.
Bug: http://b/34114501
Test: bionic-unit-tests --gtest_filter=prop*
Change-Id: I9846965bf248e2ddf45cd7b293618245bbd87145
diff --git a/libc/bionic/system_properties.cpp b/libc/bionic/system_properties.cpp
index 0f68431..06173a8 100644
--- a/libc/bionic/system_properties.cpp
+++ b/libc/bionic/system_properties.cpp
@@ -56,6 +56,7 @@
#include "private/bionic_futex.h"
#include "private/bionic_lock.h"
#include "private/bionic_macros.h"
+#include "private/bionic_sdk_version.h"
#include "private/libc_logging.h"
static const char property_service_socket[] = "/dev/socket/" PROP_SERVICE_NAME;
@@ -1265,6 +1266,11 @@
const prop_info *__system_property_find_nth(unsigned n)
{
+ if (bionic_get_application_target_sdk_version() >= __ANDROID_API_O__) {
+ __libc_fatal("__system_property_find_nth is not supported since Android O,"
+ " please use __system_property_foreach instead.");
+ }
+
find_nth_cookie cookie(n);
const int err = __system_property_foreach(find_nth_fn, &cookie);
diff --git a/libc/include/sys/system_properties.h b/libc/include/sys/system_properties.h
index d3e0d8d..faed9a0 100644
--- a/libc/include/sys/system_properties.h
+++ b/libc/include/sys/system_properties.h
@@ -81,7 +81,8 @@
** is inefficient and order of results may change from call
** to call.
*/
-const prop_info *__system_property_find_nth(unsigned n);
+const prop_info *__system_property_find_nth(unsigned n)
+ __REMOVED_IN(26);
/* Pass a prop_info for each system property to the provided
** callback. Use __system_property_read() to read the value
diff --git a/libc/libc.arm.map b/libc/libc.arm.map
index f9c5ede..3ff7ead 100644
--- a/libc/libc.arm.map
+++ b/libc/libc.arm.map
@@ -186,19 +186,16 @@
__sym_ntos;
__sym_ston;
__system_properties_init;
- __system_property_add; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
__system_property_area__; # var
__system_property_area_init; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
__system_property_area_serial; # introduced=23
__system_property_find;
- __system_property_find_nth;
__system_property_foreach; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
__system_property_get;
__system_property_read;
__system_property_serial; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
__system_property_set; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
__system_property_set_filename; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
- __system_property_update; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
__system_property_wait_any; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
__timer_create; # arm x86 mips
__timer_delete; # arm x86 mips
@@ -1535,8 +1532,15 @@
wcswcs; # arm x86 mips
} LIBC_O;
+LIBC_DEPRECATED {
+ global:
+ __system_property_find_nth;
+};
+
LIBC_PLATFORM {
global:
+ __system_property_add;
+ __system_property_update;
android_net_res_stats_get_info_for_net;
android_net_res_stats_aggregate;
android_net_res_stats_get_usable_servers;
diff --git a/libc/libc.arm64.map b/libc/libc.arm64.map
index 179d8bf..a696c41 100644
--- a/libc/libc.arm64.map
+++ b/libc/libc.arm64.map
@@ -131,19 +131,16 @@
__sym_ntos;
__sym_ston;
__system_properties_init;
- __system_property_add; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
__system_property_area__; # var
__system_property_area_init; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
__system_property_area_serial; # introduced=23
__system_property_find;
- __system_property_find_nth;
__system_property_foreach; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
__system_property_get;
__system_property_read;
__system_property_serial; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
__system_property_set; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
__system_property_set_filename; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
- __system_property_update; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
__system_property_wait_any; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
__umask_chk; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
__vsnprintf_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
@@ -1252,8 +1249,15 @@
gMallocLeakZygoteChild;
} LIBC_O;
+LIBC_DEPRECATED {
+ global:
+ __system_property_find_nth;
+};
+
LIBC_PLATFORM {
global:
+ __system_property_add;
+ __system_property_update;
android_net_res_stats_get_info_for_net;
android_net_res_stats_aggregate;
android_net_res_stats_get_usable_servers;
diff --git a/libc/libc.map.txt b/libc/libc.map.txt
index f122937..391c65c 100644
--- a/libc/libc.map.txt
+++ b/libc/libc.map.txt
@@ -187,19 +187,16 @@
__sym_ntos;
__sym_ston;
__system_properties_init;
- __system_property_add; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
__system_property_area__; # var
__system_property_area_init; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
__system_property_area_serial; # introduced=23
__system_property_find;
- __system_property_find_nth;
__system_property_foreach; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
__system_property_get;
__system_property_read;
__system_property_serial; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
__system_property_set; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
__system_property_set_filename; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
- __system_property_update; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
__system_property_wait_any; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
__timer_create; # arm x86 mips
__timer_delete; # arm x86 mips
@@ -1561,8 +1558,15 @@
wcswcs; # arm x86 mips
} LIBC_O;
+LIBC_DEPRECATED {
+ global:
+ __system_property_find_nth;
+};
+
LIBC_PLATFORM {
global:
+ __system_property_add;
+ __system_property_update;
android_net_res_stats_get_info_for_net;
android_net_res_stats_aggregate;
android_net_res_stats_get_usable_servers;
diff --git a/libc/libc.mips.map b/libc/libc.mips.map
index a969703..c89b4ad 100644
--- a/libc/libc.mips.map
+++ b/libc/libc.mips.map
@@ -183,19 +183,16 @@
__sym_ntos;
__sym_ston;
__system_properties_init;
- __system_property_add; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
__system_property_area__; # var
__system_property_area_init; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
__system_property_area_serial; # introduced=23
__system_property_find;
- __system_property_find_nth;
__system_property_foreach; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
__system_property_get;
__system_property_read;
__system_property_serial; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
__system_property_set; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
__system_property_set_filename; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
- __system_property_update; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
__system_property_wait_any; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
__timer_create; # arm x86 mips
__timer_delete; # arm x86 mips
@@ -1376,8 +1373,15 @@
wcswcs; # arm x86 mips
} LIBC_O;
+LIBC_DEPRECATED {
+ global:
+ __system_property_find_nth;
+};
+
LIBC_PLATFORM {
global:
+ __system_property_add;
+ __system_property_update;
android_net_res_stats_get_info_for_net;
android_net_res_stats_aggregate;
android_net_res_stats_get_usable_servers;
diff --git a/libc/libc.mips64.map b/libc/libc.mips64.map
index 179d8bf..a696c41 100644
--- a/libc/libc.mips64.map
+++ b/libc/libc.mips64.map
@@ -131,19 +131,16 @@
__sym_ntos;
__sym_ston;
__system_properties_init;
- __system_property_add; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
__system_property_area__; # var
__system_property_area_init; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
__system_property_area_serial; # introduced=23
__system_property_find;
- __system_property_find_nth;
__system_property_foreach; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
__system_property_get;
__system_property_read;
__system_property_serial; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
__system_property_set; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
__system_property_set_filename; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
- __system_property_update; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
__system_property_wait_any; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
__umask_chk; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
__vsnprintf_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
@@ -1252,8 +1249,15 @@
gMallocLeakZygoteChild;
} LIBC_O;
+LIBC_DEPRECATED {
+ global:
+ __system_property_find_nth;
+};
+
LIBC_PLATFORM {
global:
+ __system_property_add;
+ __system_property_update;
android_net_res_stats_get_info_for_net;
android_net_res_stats_aggregate;
android_net_res_stats_get_usable_servers;
diff --git a/libc/libc.x86.map b/libc/libc.x86.map
index dfa839e..51b222d 100644
--- a/libc/libc.x86.map
+++ b/libc/libc.x86.map
@@ -183,19 +183,16 @@
__sym_ntos;
__sym_ston;
__system_properties_init;
- __system_property_add; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
__system_property_area__; # var
__system_property_area_init; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
__system_property_area_serial; # introduced=23
__system_property_find;
- __system_property_find_nth;
__system_property_foreach; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
__system_property_get;
__system_property_read;
__system_property_serial; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
__system_property_set; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
__system_property_set_filename; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
- __system_property_update; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
__system_property_wait_any; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
__timer_create; # arm x86 mips
__timer_delete; # arm x86 mips
@@ -1375,8 +1372,15 @@
wcswcs; # arm x86 mips
} LIBC_O;
+LIBC_DEPRECATED {
+ global:
+ __system_property_find_nth;
+};
+
LIBC_PLATFORM {
global:
+ __system_property_add;
+ __system_property_update;
android_net_res_stats_get_info_for_net;
android_net_res_stats_aggregate;
android_net_res_stats_get_usable_servers;
diff --git a/libc/libc.x86_64.map b/libc/libc.x86_64.map
index 179d8bf..a696c41 100644
--- a/libc/libc.x86_64.map
+++ b/libc/libc.x86_64.map
@@ -131,19 +131,16 @@
__sym_ntos;
__sym_ston;
__system_properties_init;
- __system_property_add; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
__system_property_area__; # var
__system_property_area_init; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
__system_property_area_serial; # introduced=23
__system_property_find;
- __system_property_find_nth;
__system_property_foreach; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
__system_property_get;
__system_property_read;
__system_property_serial; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
__system_property_set; # introduced-arm=12 introduced-arm64=21 introduced-mips=12 introduced-mips64=21 introduced-x86=12 introduced-x86_64=21
__system_property_set_filename; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
- __system_property_update; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
__system_property_wait_any; # introduced-arm=19 introduced-arm64=21 introduced-mips=19 introduced-mips64=21 introduced-x86=19 introduced-x86_64=21
__umask_chk; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
__vsnprintf_chk; # introduced-arm=17 introduced-arm64=21 introduced-mips=17 introduced-mips64=21 introduced-x86=17 introduced-x86_64=21
@@ -1252,8 +1249,15 @@
gMallocLeakZygoteChild;
} LIBC_O;
+LIBC_DEPRECATED {
+ global:
+ __system_property_find_nth;
+};
+
LIBC_PLATFORM {
global:
+ __system_property_add;
+ __system_property_update;
android_net_res_stats_get_info_for_net;
android_net_res_stats_aggregate;
android_net_res_stats_get_usable_servers;
diff --git a/tests/system_properties_test.cpp b/tests/system_properties_test.cpp
index 09eac3f..70482f0 100644
--- a/tests/system_properties_test.cpp
+++ b/tests/system_properties_test.cpp
@@ -244,16 +244,10 @@
ASSERT_EQ(0, __system_property_add("other_property", 14, "value2", 6));
ASSERT_EQ(0, __system_property_add("property_other", 14, "value3", 6));
- ASSERT_NE((const prop_info *)NULL, __system_property_find_nth(0));
- ASSERT_NE((const prop_info *)NULL, __system_property_find_nth(1));
- ASSERT_NE((const prop_info *)NULL, __system_property_find_nth(2));
-
- ASSERT_EQ((const prop_info *)NULL, __system_property_find_nth(3));
- ASSERT_EQ((const prop_info *)NULL, __system_property_find_nth(4));
- ASSERT_EQ((const prop_info *)NULL, __system_property_find_nth(5));
- ASSERT_EQ((const prop_info *)NULL, __system_property_find_nth(100));
- ASSERT_EQ((const prop_info *)NULL, __system_property_find_nth(200));
- ASSERT_EQ((const prop_info *)NULL, __system_property_find_nth(247));
+ // This method is no longer supported and should result in abort
+ ASSERT_EXIT(__system_property_find_nth(0), testing::KilledBySignal(SIGABRT),
+ "__system_property_find_nth is not supported since Android O,"
+ " please use __system_property_foreach instead.");
#else // __BIONIC__
GTEST_LOG_(INFO) << "This test does nothing.\n";
#endif // __BIONIC__