Include network type that caused broadcast.

Network type can be obtained through EXTRA_NETWORK_INFO, but offer
it as first-class extra since the returned NetworkInfo is deprecated.

Bug: 6936247
Change-Id: Ief59577afd2bd930f0f4c5650b413feef86bfbc3
This commit is contained in:
Jeff Sharkey
2012-08-06 11:41:50 -07:00
parent a1ef1bec2a
commit 47905d1f1d
2 changed files with 13 additions and 0 deletions

View File

@@ -89,10 +89,20 @@ public class ConnectivityManager {
* should always obtain network information through
* {@link #getActiveNetworkInfo()} or
* {@link #getAllNetworkInfo()}.
* @see #EXTRA_NETWORK_TYPE
*/
@Deprecated
public static final String EXTRA_NETWORK_INFO = "networkInfo";
/**
* Network type which triggered a {@link #CONNECTIVITY_ACTION} broadcast.
* Can be used with {@link #getNetworkInfo(int)} to get {@link NetworkInfo}
* state based on the calling application.
*
* @see android.content.Intent#getIntExtra(String, int)
*/
public static final String EXTRA_NETWORK_TYPE = "networkType";
/**
* The lookup key for a boolean that indicates whether a connect event
* is for a network to which the connectivity manager was failing over

View File

@@ -1622,6 +1622,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
Intent intent = new Intent(ConnectivityManager.CONNECTIVITY_ACTION);
intent.putExtra(ConnectivityManager.EXTRA_NETWORK_INFO, info);
intent.putExtra(ConnectivityManager.EXTRA_NETWORK_TYPE, info.getType());
if (info.isFailover()) {
intent.putExtra(ConnectivityManager.EXTRA_IS_FAILOVER, true);
info.setFailover(false);
@@ -1748,6 +1749,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
private Intent makeGeneralIntent(NetworkInfo info, String bcastType) {
Intent intent = new Intent(bcastType);
intent.putExtra(ConnectivityManager.EXTRA_NETWORK_INFO, info);
intent.putExtra(ConnectivityManager.EXTRA_NETWORK_TYPE, info.getType());
if (info.isFailover()) {
intent.putExtra(ConnectivityManager.EXTRA_IS_FAILOVER, true);
info.setFailover(false);
@@ -1798,6 +1800,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
Intent intent = new Intent(ConnectivityManager.CONNECTIVITY_ACTION);
intent.putExtra(ConnectivityManager.EXTRA_NETWORK_INFO, info);
intent.putExtra(ConnectivityManager.EXTRA_NETWORK_TYPE, info.getType());
if (getActiveNetworkInfo() == null) {
intent.putExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY, true);
}