am 4b1bdc02: Merge "DO NOT MERGE Fixing Connectivity" into gingerbread

Merge commit '4b1bdc0209650436ebe0dad1020080cc891e97b6' into gingerbread-plus-aosp

* commit '4b1bdc0209650436ebe0dad1020080cc891e97b6':
  DO NOT MERGE Fixing Connectivity
This commit is contained in:
Robert Greenwalt
2010-08-20 12:04:07 -07:00
committed by Android Git Automerger
7 changed files with 34 additions and 6 deletions

View File

@ -240,6 +240,7 @@ public class MobileDataStateTracker extends NetworkStateTracker {
if (mInterfaceName == null) { if (mInterfaceName == null) {
Log.d(TAG, "CONNECTED event did not supply interface name."); Log.d(TAG, "CONNECTED event did not supply interface name.");
} }
mDefaultGatewayAddr = intent.getIntExtra(Phone.DATA_GATEWAY_KEY, 0);
setDetailedState(DetailedState.CONNECTED, reason, apnName); setDetailedState(DetailedState.CONNECTED, reason, apnName);
break; break;
} }

View File

@ -128,4 +128,19 @@ public class NetworkUtils {
| (addrBytes[0] & 0xff); | (addrBytes[0] & 0xff);
return addr; return addr;
} }
public static int v4StringToInt(String str) {
int result = 0;
String[] array = str.split("\\.");
if (array.length != 4) return 0;
try {
result = Integer.parseInt(array[3]);
result = (result << 8) + Integer.parseInt(array[2]);
result = (result << 8) + Integer.parseInt(array[1]);
result = (result << 8) + Integer.parseInt(array[0]);
} catch (NumberFormatException e) {
return 0;
}
return result;
}
} }

View File

@ -19,6 +19,7 @@ package com.android.server;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.net.NetworkUtils;
import android.os.Binder; import android.os.Binder;
import android.os.Bundle; import android.os.Bundle;
import android.os.IBinder; import android.os.IBinder;
@ -348,7 +349,8 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub {
} }
public void notifyDataConnection(int state, boolean isDataConnectivityPossible, public void notifyDataConnection(int state, boolean isDataConnectivityPossible,
String reason, String apn, String[] apnTypes, String interfaceName, int networkType) { String reason, String apn, String[] apnTypes, String interfaceName, int networkType,
String gateway) {
if (!checkNotifyPermission("notifyDataConnection()" )) { if (!checkNotifyPermission("notifyDataConnection()" )) {
return; return;
} }
@ -372,7 +374,7 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub {
} }
} }
broadcastDataConnectionStateChanged(state, isDataConnectivityPossible, reason, apn, broadcastDataConnectionStateChanged(state, isDataConnectivityPossible, reason, apn,
apnTypes, interfaceName); apnTypes, interfaceName, gateway);
} }
public void notifyDataConnectionFailed(String reason) { public void notifyDataConnectionFailed(String reason) {
@ -535,7 +537,7 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub {
private void broadcastDataConnectionStateChanged(int state, private void broadcastDataConnectionStateChanged(int state,
boolean isDataConnectivityPossible, boolean isDataConnectivityPossible,
String reason, String apn, String[] apnTypes, String interfaceName) { String reason, String apn, String[] apnTypes, String interfaceName, String gateway) {
// Note: not reporting to the battery stats service here, because the // Note: not reporting to the battery stats service here, because the
// status bar takes care of that after taking into account all of the // status bar takes care of that after taking into account all of the
// required info. // required info.
@ -558,6 +560,12 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub {
} }
intent.putExtra(Phone.DATA_APN_TYPES_KEY, types); intent.putExtra(Phone.DATA_APN_TYPES_KEY, types);
intent.putExtra(Phone.DATA_IFACE_NAME_KEY, interfaceName); intent.putExtra(Phone.DATA_IFACE_NAME_KEY, interfaceName);
int gatewayAddr = 0;
if (gateway != null) {
gatewayAddr = NetworkUtils.v4StringToInt(gateway);
}
intent.putExtra(Phone.DATA_GATEWAY_KEY, gatewayAddr);
mContext.sendStickyBroadcast(intent); mContext.sendStickyBroadcast(intent);
} }

View File

@ -102,7 +102,8 @@ public class DefaultPhoneNotifier implements PhoneNotifier {
sender.getActiveApnTypes(), sender.getActiveApnTypes(),
sender.getInterfaceName(null), sender.getInterfaceName(null),
((telephony!=null) ? telephony.getNetworkType() : ((telephony!=null) ? telephony.getNetworkType() :
TelephonyManager.NETWORK_TYPE_UNKNOWN)); TelephonyManager.NETWORK_TYPE_UNKNOWN),
sender.getGateway(null));
} catch (RemoteException ex) { } catch (RemoteException ex) {
// system process is dead // system process is dead
} }

View File

@ -32,7 +32,8 @@ interface ITelephonyRegistry {
void notifyCallForwardingChanged(boolean cfi); void notifyCallForwardingChanged(boolean cfi);
void notifyDataActivity(int state); void notifyDataActivity(int state);
void notifyDataConnection(int state, boolean isDataConnectivityPossible, void notifyDataConnection(int state, boolean isDataConnectivityPossible,
String reason, String apn, in String[] apnTypes, String interfaceName, int networkType); String reason, String apn, in String[] apnTypes, String interfaceName, int networkType,
String gateway);
void notifyDataConnectionFailed(String reason); void notifyDataConnectionFailed(String reason);
void notifyCellLocation(in Bundle cellLocation); void notifyCellLocation(in Bundle cellLocation);
} }

View File

@ -103,6 +103,7 @@ public interface Phone {
static final String DATA_APN_KEY = "apn"; static final String DATA_APN_KEY = "apn";
static final String DATA_IFACE_NAME_KEY = "iface"; static final String DATA_IFACE_NAME_KEY = "iface";
static final String DATA_GATEWAY_KEY = "gateway";
static final String NETWORK_UNAVAILABLE_KEY = "networkUnvailable"; static final String NETWORK_UNAVAILABLE_KEY = "networkUnvailable";
static final String PHONE_IN_ECM_STATE = "phoneinECMState"; static final String PHONE_IN_ECM_STATE = "phoneinECMState";

View File

@ -104,7 +104,8 @@ public class SipPhoneNotifier implements PhoneNotifier {
sender.getActiveApnTypes(), sender.getActiveApnTypes(),
sender.getInterfaceName(null), sender.getInterfaceName(null),
((telephony!=null) ? telephony.getNetworkType() : ((telephony!=null) ? telephony.getNetworkType() :
TelephonyManager.NETWORK_TYPE_UNKNOWN)); TelephonyManager.NETWORK_TYPE_UNKNOWN),
sender.getGateway(null));
} catch (RemoteException ex) { } catch (RemoteException ex) {
// system process is dead // system process is dead
} }