Merge "CTS: Only listen to wifi events when toggling wifi" into nyc-dev
This commit is contained in:
@@ -28,7 +28,7 @@
|
||||
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="android.net.cts.appForApi23.getConnectivityActionCount" />
|
||||
<action android:name="android.net.cts.appForApi23.getWifiConnectivityActionCount" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
|
||||
@@ -21,18 +21,21 @@ import android.content.Intent;
|
||||
import android.net.ConnectivityManager;
|
||||
|
||||
public class ConnectivityReceiver extends BroadcastReceiver {
|
||||
public static String GET_CONNECTIVITY_ACTION_COUNT =
|
||||
"android.net.cts.appForApi23.getConnectivityActionCount";
|
||||
public static String GET_WIFI_CONNECTIVITY_ACTION_COUNT =
|
||||
"android.net.cts.appForApi23.getWifiConnectivityActionCount";
|
||||
|
||||
private static int sConnectivityActionCount = 0;
|
||||
private static int sWifiConnectivityActionCount = 0;
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (ConnectivityManager.CONNECTIVITY_ACTION.equals(intent.getAction())) {
|
||||
sConnectivityActionCount++;
|
||||
int networkType = intent.getIntExtra(ConnectivityManager.EXTRA_NETWORK_TYPE, 0);
|
||||
if (networkType == ConnectivityManager.TYPE_WIFI) {
|
||||
sWifiConnectivityActionCount++;
|
||||
}
|
||||
}
|
||||
if (GET_CONNECTIVITY_ACTION_COUNT.equals(intent.getAction())) {
|
||||
setResultCode(sConnectivityActionCount);
|
||||
if (GET_WIFI_CONNECTIVITY_ACTION_COUNT.equals(intent.getAction())) {
|
||||
setResultCode(sWifiConnectivityActionCount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,9 +77,9 @@ public class ConnectivityManagerTest extends AndroidTestCase {
|
||||
private static final String NETWORK_CALLBACK_ACTION =
|
||||
"ConnectivityManagerTest.NetworkCallbackAction";
|
||||
|
||||
// Intent string to get the number of CONNECTIVITY_ACTION callbacks the test app has seen
|
||||
public static final String GET_CONNECTIVITY_ACTION_COUNT =
|
||||
"android.net.cts.appForApi23.getConnectivityActionCount";
|
||||
// Intent string to get the number of wifi CONNECTIVITY_ACTION callbacks the test app has seen
|
||||
public static final String GET_WIFI_CONNECTIVITY_ACTION_COUNT =
|
||||
"android.net.cts.appForApi23.getWifiConnectivityActionCount";
|
||||
|
||||
// device could have only one interface: data, wifi.
|
||||
private static final int MIN_NUM_NETWORK_TYPES = 1;
|
||||
@@ -423,7 +423,7 @@ public class ConnectivityManagerTest extends AndroidTestCase {
|
||||
|
||||
toggleWifi();
|
||||
|
||||
Intent getConnectivityCount = new Intent(GET_CONNECTIVITY_ACTION_COUNT);
|
||||
Intent getConnectivityCount = new Intent(GET_WIFI_CONNECTIVITY_ACTION_COUNT);
|
||||
assertEquals(2, sendOrderedBroadcastAndReturnResultCode(
|
||||
getConnectivityCount, SEND_BROADCAST_TIMEOUT));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user