Un-deprecated __system_property_find_nth.

Netflix was using this, and looking the header file, although
__system_property_find_nth has been available since the beginning of time,
__system_property_foreach only appeared in 16. So anyone who wants to run
on pre-JellyBean devices would want to use __system_property_find_nth.

It's pretty much a one-liner in terms of __system_property_foreach anyway,
so it doesn't cost us anything to keep it.

Also restore slightly better tests than we originally removed.

Bug: http://b/36566667
Test: ran tests

(cherry picked from commit 438e01940b90a2b6061a9b9809e08466e1e9faac)

Change-Id: I639f2142ad4ba049b990b13ccccd255be4b4f479
diff --git a/tests/system_properties_test.cpp b/tests/system_properties_test.cpp
index 23d0cad..7415b3c 100644
--- a/tests/system_properties_test.cpp
+++ b/tests/system_properties_test.cpp
@@ -253,10 +253,21 @@
     ASSERT_EQ(0, __system_property_add("other_property", 14, "value2", 6));
     ASSERT_EQ(0, __system_property_add("property_other", 14, "value3", 6));
 
-    // 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.");
+    char name[PROP_NAME_MAX];
+    char value[PROP_VALUE_MAX];
+    EXPECT_EQ(6, __system_property_read(__system_property_find_nth(0), name, value));
+    EXPECT_STREQ("property", name);
+    EXPECT_STREQ("value1", value);
+    EXPECT_EQ(6, __system_property_read(__system_property_find_nth(1), name, value));
+    EXPECT_STREQ("other_property", name);
+    EXPECT_STREQ("value2", value);
+    EXPECT_EQ(6, __system_property_read(__system_property_find_nth(2), name, value));
+    EXPECT_STREQ("property_other", name);
+    EXPECT_STREQ("value3", value);
+
+    for (unsigned i = 3; i < 1024; ++i) {
+      ASSERT_TRUE(__system_property_find_nth(i) == nullptr);
+    }
 #else // __BIONIC__
     GTEST_LOG_(INFO) << "This test does nothing.\n";
 #endif // __BIONIC__