Lookup private resources in run-time

This fixes the following cases for us:

android.net.cts.ConnectivityManagerTest#testGetAllNetworkInfo
android.net.cts.ConnectivityManagerTest#testGetNetworkInfo
android.net.cts.ConnectivityManagerTest#testIsNetworkSupported
android.net.cts.ConnectivityManagerTest#testRequestRouteToHost
android.net.cts.ConnectivityManagerTest#testSetNetworkPreference

We need to use the prebuilt binary but that has dependency to
private resource identities that differs in our environment. With
this change the resources are looked up in run-time to avoid the
build time dependency.

Change-Id: I6579338b591ca7a0da3f03f796136269c7789780
(cherry picked from commit b29370db34)
This commit is contained in:
Johan Redestig
2013-10-30 14:14:58 +01:00
parent c893f50f6f
commit 5e671fabe6

View File

@@ -66,8 +66,10 @@ public class ConnectivityManagerTest extends AndroidTestCase {
mWifiManager = (WifiManager) getContext().getSystemService(Context.WIFI_SERVICE);
mPackageManager = getContext().getPackageManager();
String[] naStrings = getContext().getResources().getStringArray(
com.android.internal.R.array.networkAttributes);
// Get com.android.internal.R.array.networkAttributes
int resId = getContext().getResources().getIdentifier("networkAttributes", "array", "android");
String[] naStrings = getContext().getResources().getStringArray(resId);
for (String naString : naStrings) {
try {
NetworkConfig n = new NetworkConfig(naString);
@@ -75,8 +77,9 @@ public class ConnectivityManagerTest extends AndroidTestCase {
} catch (Exception e) {}
}
int[] protectedNetworks = getContext().getResources().getIntArray(
com.android.internal.R.array.config_protectedNetworks);
// Get com.android.internal.R.array.config_protectedNetworks
resId = getContext().getResources().getIdentifier("config_protectedNetworks", "array", "android");
int[] protectedNetworks = getContext().getResources().getIntArray(resId);
for (int p : protectedNetworks) {
mProtectedNetworks.add(p);
}