Merge "Add the ability to file a NetworkRequest for TRANSPORT_WIFI." into nyc-dev

This commit is contained in:
Lorenzo Colitti
2016-02-18 06:00:23 +00:00
committed by Android (Google) Code Review
3 changed files with 27 additions and 0 deletions

View File

@@ -283,6 +283,19 @@
android:layout_height="wrap_content"
android:text="@string/release_cell" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button android:id="@+id/request_wifi"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/request_wifi" />
<Button android:id="@+id/release_wifi"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/release_wifi" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:paddingBottom="4dip"

View File

@@ -46,6 +46,8 @@
<string name="release_supl">Release SUPL</string>
<string name="request_cell">Request cell</string>
<string name="release_cell">Release cell</string>
<string name="request_wifi">Request Wi-Fi</string>
<string name="release_wifi">Release Wi-Fi</string>
<string name="report_all_bad">Report all bad</string>
<string name="default_request">Make http request</string>

View File

@@ -360,6 +360,10 @@ public class Connectivity extends Activity {
private final RequestableNetwork mBoundTestNetwork;
private boolean mRequestRunning;
private void addRequestableNetwork(RequestableNetwork network) {
mRequestableNetworks.add(network);
}
private void addRequestableNetwork(int capability, int requestButton, int releaseButton) {
mRequestableNetworks.add(new RequestableNetwork(capability, requestButton, releaseButton));
}
@@ -369,7 +373,15 @@ public class Connectivity extends Activity {
addRequestableNetwork(NET_CAPABILITY_MMS, R.id.request_mms, R.id.release_mms);
addRequestableNetwork(NET_CAPABILITY_SUPL, R.id.request_supl, R.id.release_supl);
addRequestableNetwork(NET_CAPABILITY_INTERNET, R.id.request_cell, R.id.release_cell);
// Make bound requests use cell data.
mBoundTestNetwork = mRequestableNetworks.get(mRequestableNetworks.size() - 1);
NetworkRequest wifiRequest = new NetworkRequest.Builder()
.addTransportType(NetworkCapabilities.TRANSPORT_WIFI)
.build();
addRequestableNetwork(new RequestableNetwork(wifiRequest,
R.id.request_wifi, R.id.release_wifi, R.id.wifi_progress));
}
final NetworkRequest mEmptyRequest = new NetworkRequest.Builder().clearCapabilities().build();