diff options
Diffstat (limited to 'core/java/android')
27 files changed, 748 insertions, 374 deletions
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java index ccd65de..c9351af 100644 --- a/core/java/android/app/Notification.java +++ b/core/java/android/app/Notification.java @@ -416,7 +416,7 @@ public class Notification implements Parcelable if (this.largeIcon != null) { that.largeIcon = Bitmap.createBitmap(this.largeIcon); } - that.iconLevel = that.iconLevel; + that.iconLevel = this.iconLevel; that.sound = this.sound; // android.net.Uri is immutable that.audioStreamType = this.audioStreamType; diff --git a/core/java/android/bluetooth/BluetoothDeviceProfileState.java b/core/java/android/bluetooth/BluetoothDeviceProfileState.java index 9855709..6f3a2e7 100644 --- a/core/java/android/bluetooth/BluetoothDeviceProfileState.java +++ b/core/java/android/bluetooth/BluetoothDeviceProfileState.java @@ -26,8 +26,8 @@ import android.server.BluetoothA2dpService; import android.server.BluetoothService; import android.util.Log; -import com.android.internal.util.HierarchicalState; -import com.android.internal.util.HierarchicalStateMachine; +import com.android.internal.util.State; +import com.android.internal.util.StateMachine; import java.util.Set; @@ -57,7 +57,7 @@ import java.util.Set; * Todo(): Write tests for this class, when the Android Mock support is completed. * @hide */ -public final class BluetoothDeviceProfileState extends HierarchicalStateMachine { +public final class BluetoothDeviceProfileState extends StateMachine { private static final String TAG = "BluetoothDeviceProfileState"; private static final boolean DBG = false; @@ -235,16 +235,16 @@ public final class BluetoothDeviceProfileState extends HierarchicalStateMachine } } - private class BondedDevice extends HierarchicalState { + private class BondedDevice extends State { @Override - protected void enter() { + public void enter() { Log.i(TAG, "Entering ACL Connected state with: " + getCurrentMessage().what); Message m = new Message(); m.copyFrom(getCurrentMessage()); sendMessageAtFrontOfQueue(m); } @Override - protected boolean processMessage(Message message) { + public boolean processMessage(Message message) { log("ACL Connected State -> Processing Message: " + message.what); switch(message.what) { case CONNECT_HFP_OUTGOING: @@ -353,12 +353,12 @@ public final class BluetoothDeviceProfileState extends HierarchicalStateMachine } } - private class OutgoingHandsfree extends HierarchicalState { + private class OutgoingHandsfree extends State { private boolean mStatus = false; private int mCommand; @Override - protected void enter() { + public void enter() { Log.i(TAG, "Entering OutgoingHandsfree state with: " + getCurrentMessage().what); mCommand = getCurrentMessage().what; if (mCommand != CONNECT_HFP_OUTGOING && @@ -374,7 +374,7 @@ public final class BluetoothDeviceProfileState extends HierarchicalStateMachine } @Override - protected boolean processMessage(Message message) { + public boolean processMessage(Message message) { log("OutgoingHandsfree State -> Processing Message: " + message.what); Message deferMsg = new Message(); int command = message.what; @@ -466,12 +466,12 @@ public final class BluetoothDeviceProfileState extends HierarchicalStateMachine } } - private class IncomingHandsfree extends HierarchicalState { + private class IncomingHandsfree extends State { private boolean mStatus = false; private int mCommand; @Override - protected void enter() { + public void enter() { Log.i(TAG, "Entering IncomingHandsfree state with: " + getCurrentMessage().what); mCommand = getCurrentMessage().what; if (mCommand != CONNECT_HFP_INCOMING && @@ -487,7 +487,7 @@ public final class BluetoothDeviceProfileState extends HierarchicalStateMachine } @Override - protected boolean processMessage(Message message) { + public boolean processMessage(Message message) { log("IncomingHandsfree State -> Processing Message: " + message.what); switch(message.what) { case CONNECT_HFP_OUTGOING: @@ -546,12 +546,12 @@ public final class BluetoothDeviceProfileState extends HierarchicalStateMachine } } - private class OutgoingA2dp extends HierarchicalState { + private class OutgoingA2dp extends State { private boolean mStatus = false; private int mCommand; @Override - protected void enter() { + public void enter() { Log.i(TAG, "Entering OutgoingA2dp state with: " + getCurrentMessage().what); mCommand = getCurrentMessage().what; if (mCommand != CONNECT_A2DP_OUTGOING && @@ -567,7 +567,7 @@ public final class BluetoothDeviceProfileState extends HierarchicalStateMachine } @Override - protected boolean processMessage(Message message) { + public boolean processMessage(Message message) { log("OutgoingA2dp State->Processing Message: " + message.what); Message deferMsg = new Message(); switch(message.what) { @@ -656,12 +656,12 @@ public final class BluetoothDeviceProfileState extends HierarchicalStateMachine } } - private class IncomingA2dp extends HierarchicalState { + private class IncomingA2dp extends State { private boolean mStatus = false; private int mCommand; @Override - protected void enter() { + public void enter() { Log.i(TAG, "Entering IncomingA2dp state with: " + getCurrentMessage().what); mCommand = getCurrentMessage().what; if (mCommand != CONNECT_A2DP_INCOMING && @@ -677,7 +677,7 @@ public final class BluetoothDeviceProfileState extends HierarchicalStateMachine } @Override - protected boolean processMessage(Message message) { + public boolean processMessage(Message message) { log("IncomingA2dp State->Processing Message: " + message.what); Message deferMsg = new Message(); switch(message.what) { @@ -735,12 +735,12 @@ public final class BluetoothDeviceProfileState extends HierarchicalStateMachine } - private class OutgoingHid extends HierarchicalState { + private class OutgoingHid extends State { private boolean mStatus = false; private int mCommand; @Override - protected void enter() { + public void enter() { log("Entering OutgoingHid state with: " + getCurrentMessage().what); mCommand = getCurrentMessage().what; if (mCommand != CONNECT_HID_OUTGOING && @@ -752,7 +752,7 @@ public final class BluetoothDeviceProfileState extends HierarchicalStateMachine } @Override - protected boolean processMessage(Message message) { + public boolean processMessage(Message message) { log("OutgoingHid State->Processing Message: " + message.what); Message deferMsg = new Message(); switch(message.what) { @@ -816,12 +816,12 @@ public final class BluetoothDeviceProfileState extends HierarchicalStateMachine } } - private class IncomingHid extends HierarchicalState { + private class IncomingHid extends State { private boolean mStatus = false; private int mCommand; @Override - protected void enter() { + public void enter() { log("Entering IncomingHid state with: " + getCurrentMessage().what); mCommand = getCurrentMessage().what; if (mCommand != CONNECT_HID_INCOMING && @@ -833,7 +833,7 @@ public final class BluetoothDeviceProfileState extends HierarchicalStateMachine } @Override - protected boolean processMessage(Message message) { + public boolean processMessage(Message message) { log("IncomingHid State->Processing Message: " + message.what); Message deferMsg = new Message(); switch(message.what) { diff --git a/core/java/android/bluetooth/BluetoothProfileState.java b/core/java/android/bluetooth/BluetoothProfileState.java index 18060a0..98afdb8 100644 --- a/core/java/android/bluetooth/BluetoothProfileState.java +++ b/core/java/android/bluetooth/BluetoothProfileState.java @@ -22,8 +22,8 @@ import android.content.IntentFilter; import android.os.Message; import android.util.Log; -import com.android.internal.util.HierarchicalState; -import com.android.internal.util.HierarchicalStateMachine; +import com.android.internal.util.State; +import com.android.internal.util.StateMachine; /** * This state machine is used to serialize the connections @@ -39,7 +39,7 @@ import com.android.internal.util.HierarchicalStateMachine; * @hide */ -public class BluetoothProfileState extends HierarchicalStateMachine { +public class BluetoothProfileState extends StateMachine { private static final boolean DBG = true; private static final String TAG = "BluetoothProfileState"; @@ -101,15 +101,15 @@ public class BluetoothProfileState extends HierarchicalStateMachine { context.registerReceiver(mBroadcastReceiver, filter); } - private class StableState extends HierarchicalState { + private class StableState extends State { @Override - protected void enter() { + public void enter() { log("Entering Stable State"); mPendingDevice = null; } @Override - protected boolean processMessage(Message msg) { + public boolean processMessage(Message msg) { if (msg.what != TRANSITION_TO_STABLE) { transitionTo(mPendingCommandState); } @@ -117,15 +117,15 @@ public class BluetoothProfileState extends HierarchicalStateMachine { } } - private class PendingCommandState extends HierarchicalState { + private class PendingCommandState extends State { @Override - protected void enter() { + public void enter() { log("Entering PendingCommandState State"); dispatchMessage(getCurrentMessage()); } @Override - protected boolean processMessage(Message msg) { + public boolean processMessage(Message msg) { if (msg.what == TRANSITION_TO_STABLE) { transitionTo(mStableState); } else { diff --git a/core/java/android/bluetooth/BluetoothTetheringDataTracker.java b/core/java/android/bluetooth/BluetoothTetheringDataTracker.java index c08f14f..a7b0037 100644 --- a/core/java/android/bluetooth/BluetoothTetheringDataTracker.java +++ b/core/java/android/bluetooth/BluetoothTetheringDataTracker.java @@ -300,4 +300,8 @@ public class BluetoothTetheringDataTracker implements NetworkStateTracker { msg = mCsHandler.obtainMessage(EVENT_STATE_CHANGED, mNetworkInfo); msg.sendToTarget(); } + + public void setDependencyMet(boolean met) { + // not supported on this network + } } diff --git a/core/java/android/net/ConnectivityManager.java b/core/java/android/net/ConnectivityManager.java index 491c73a..b541ec3 100644 --- a/core/java/android/net/ConnectivityManager.java +++ b/core/java/android/net/ConnectivityManager.java @@ -221,12 +221,32 @@ public class ConnectivityManager /** {@hide} */ public static final int TYPE_DUMMY = 8; + /** {@hide} */ public static final int TYPE_ETHERNET = 9; - /** {@hide} TODO: Need to adjust this for WiMAX. */ - public static final int MAX_RADIO_TYPE = TYPE_ETHERNET; - /** {@hide} TODO: Need to adjust this for WiMAX. */ - public static final int MAX_NETWORK_TYPE = TYPE_ETHERNET; + /** + * Over the air Adminstration. + * {@hide} + */ + public static final int TYPE_MOBILE_FOTA = 10; + + /** + * IP Multimedia Subsystem + * {@hide} + */ + public static final int TYPE_MOBILE_IMS = 11; + + /** + * Carrier Branded Services + * {@hide} + */ + public static final int TYPE_MOBILE_CBS = 12; + + /** {@hide} */ + public static final int MAX_RADIO_TYPE = TYPE_MOBILE_CBS; + + /** {@hide} */ + public static final int MAX_NETWORK_TYPE = TYPE_MOBILE_CBS; public static final int DEFAULT_NETWORK_PREFERENCE = TYPE_WIFI; @@ -670,4 +690,16 @@ public class ConnectivityManager return null; } } + + /** + * @param networkType The network who's dependence has changed + * @param met Boolean - true if network use is ok, false if not + * {@hide} + */ + public void setDataDependency(int networkType, boolean met) { + try { + mService.setDataDependency(networkType, met); + } catch (RemoteException e) { + } + } } diff --git a/core/java/android/net/DhcpInfoInternal.java b/core/java/android/net/DhcpInfoInternal.java index 7396669..860da0a 100644 --- a/core/java/android/net/DhcpInfoInternal.java +++ b/core/java/android/net/DhcpInfoInternal.java @@ -22,6 +22,8 @@ import android.util.Log; import java.net.InetAddress; import java.net.Inet4Address; import java.net.UnknownHostException; +import java.util.ArrayList; +import java.util.Collection; /** * A simple object for retrieving the results of a DHCP request. @@ -31,7 +33,6 @@ import java.net.UnknownHostException; public class DhcpInfoInternal { private final static String TAG = "DhcpInfoInternal"; public String ipAddress; - public String gateway; public int prefixLength; public String dns1; @@ -40,7 +41,14 @@ public class DhcpInfoInternal { public String serverAddress; public int leaseDuration; + private Collection<RouteInfo> routes; + public DhcpInfoInternal() { + routes = new ArrayList<RouteInfo>(); + } + + public void addRoute(RouteInfo routeInfo) { + routes.add(routeInfo); } private int convertToInt(String addr) { @@ -58,7 +66,12 @@ public class DhcpInfoInternal { public DhcpInfo makeDhcpInfo() { DhcpInfo info = new DhcpInfo(); info.ipAddress = convertToInt(ipAddress); - info.gateway = convertToInt(gateway); + for (RouteInfo route : routes) { + if (route.isDefaultRoute()) { + info.gateway = convertToInt(route.getGateway().getHostAddress()); + break; + } + } try { InetAddress inetAddress = NetworkUtils.numericToInetAddress(ipAddress); info.netmask = NetworkUtils.prefixLengthToNetmaskInt(prefixLength); @@ -81,8 +94,8 @@ public class DhcpInfoInternal { public LinkProperties makeLinkProperties() { LinkProperties p = new LinkProperties(); p.addLinkAddress(makeLinkAddress()); - if (TextUtils.isEmpty(gateway) == false) { - p.addGateway(NetworkUtils.numericToInetAddress(gateway)); + for (RouteInfo route : routes) { + p.addRoute(route); } if (TextUtils.isEmpty(dns1) == false) { p.addDns(NetworkUtils.numericToInetAddress(dns1)); @@ -98,8 +111,10 @@ public class DhcpInfoInternal { } public String toString() { + String routeString = ""; + for (RouteInfo route : routes) routeString += route.toString() + " | "; return "addr: " + ipAddress + "/" + prefixLength + - " gateway: " + gateway + + " routes: " + routeString + " dns: " + dns1 + "," + dns2 + " dhcpServer: " + serverAddress + " leaseDuration: " + leaseDuration; diff --git a/core/java/android/net/DhcpStateMachine.java b/core/java/android/net/DhcpStateMachine.java index f5cf14b..eaf087f 100644 --- a/core/java/android/net/DhcpStateMachine.java +++ b/core/java/android/net/DhcpStateMachine.java @@ -17,8 +17,8 @@ package android.net; import com.android.internal.util.Protocol; -import com.android.internal.util.HierarchicalState; -import com.android.internal.util.HierarchicalStateMachine; +import com.android.internal.util.State; +import com.android.internal.util.StateMachine; import android.app.AlarmManager; import android.app.PendingIntent; @@ -47,14 +47,14 @@ import android.util.Log; * * @hide */ -public class DhcpStateMachine extends HierarchicalStateMachine { +public class DhcpStateMachine extends StateMachine { private static final String TAG = "DhcpStateMachine"; private static final boolean DBG = false; /* A StateMachine that controls the DhcpStateMachine */ - private HierarchicalStateMachine mController; + private StateMachine mController; private Context mContext; private BroadcastReceiver mBroadcastReceiver; @@ -95,13 +95,13 @@ public class DhcpStateMachine extends HierarchicalStateMachine { public static final int DHCP_SUCCESS = 1; public static final int DHCP_FAILURE = 2; - private HierarchicalState mDefaultState = new DefaultState(); - private HierarchicalState mStoppedState = new StoppedState(); - private HierarchicalState mWaitBeforeStartState = new WaitBeforeStartState(); - private HierarchicalState mRunningState = new RunningState(); - private HierarchicalState mWaitBeforeRenewalState = new WaitBeforeRenewalState(); + private State mDefaultState = new DefaultState(); + private State mStoppedState = new StoppedState(); + private State mWaitBeforeStartState = new WaitBeforeStartState(); + private State mRunningState = new RunningState(); + private State mWaitBeforeRenewalState = new WaitBeforeRenewalState(); - private DhcpStateMachine(Context context, HierarchicalStateMachine controller, String intf) { + private DhcpStateMachine(Context context, StateMachine controller, String intf) { super(TAG); mContext = context; @@ -136,7 +136,7 @@ public class DhcpStateMachine extends HierarchicalStateMachine { setInitialState(mStoppedState); } - public static DhcpStateMachine makeDhcpStateMachine(Context context, HierarchicalStateMachine controller, + public static DhcpStateMachine makeDhcpStateMachine(Context context, StateMachine controller, String intf) { DhcpStateMachine dsm = new DhcpStateMachine(context, controller, intf); dsm.start(); @@ -156,7 +156,7 @@ public class DhcpStateMachine extends HierarchicalStateMachine { mRegisteredForPreDhcpNotification = true; } - class DefaultState extends HierarchicalState { + class DefaultState extends State { @Override public boolean processMessage(Message message) { if (DBG) Log.d(TAG, getName() + message.toString() + "\n"); @@ -164,7 +164,7 @@ public class DhcpStateMachine extends HierarchicalStateMachine { case CMD_RENEW_DHCP: Log.e(TAG, "Error! Failed to handle a DHCP renewal on " + mInterfaceName); break; - case HSM_QUIT_CMD: + case SM_QUIT_CMD: mContext.unregisterReceiver(mBroadcastReceiver); //let parent kill the state machine return NOT_HANDLED; @@ -177,7 +177,7 @@ public class DhcpStateMachine extends HierarchicalStateMachine { } - class StoppedState extends HierarchicalState { + class StoppedState extends State { @Override public void enter() { if (DBG) Log.d(TAG, getName() + "\n"); @@ -210,7 +210,7 @@ public class DhcpStateMachine extends HierarchicalStateMachine { } } - class WaitBeforeStartState extends HierarchicalState { + class WaitBeforeStartState extends State { @Override public void enter() { if (DBG) Log.d(TAG, getName() + "\n"); @@ -242,7 +242,7 @@ public class DhcpStateMachine extends HierarchicalStateMachine { } } - class RunningState extends HierarchicalState { + class RunningState extends State { @Override public void enter() { if (DBG) Log.d(TAG, getName() + "\n"); @@ -281,7 +281,7 @@ public class DhcpStateMachine extends HierarchicalStateMachine { } } - class WaitBeforeRenewalState extends HierarchicalState { + class WaitBeforeRenewalState extends State { @Override public void enter() { if (DBG) Log.d(TAG, getName() + "\n"); diff --git a/core/java/android/net/DummyDataStateTracker.java b/core/java/android/net/DummyDataStateTracker.java index d0c77cf..e39725a 100644 --- a/core/java/android/net/DummyDataStateTracker.java +++ b/core/java/android/net/DummyDataStateTracker.java @@ -191,6 +191,10 @@ public class DummyDataStateTracker implements NetworkStateTracker { return new LinkCapabilities(mLinkCapabilities); } + public void setDependencyMet(boolean met) { + // not supported on this network + } + static private void log(String s) { Slog.d(TAG, s); } diff --git a/core/java/android/net/EthernetDataTracker.java b/core/java/android/net/EthernetDataTracker.java index df5fdd0..55850c9 100644 --- a/core/java/android/net/EthernetDataTracker.java +++ b/core/java/android/net/EthernetDataTracker.java @@ -330,4 +330,8 @@ public class EthernetDataTracker implements NetworkStateTracker { public String getTcpBufferSizesPropName() { return "net.tcp.buffersize.wifi"; } + + public void setDependencyMet(boolean met) { + // not supported on this network + } } diff --git a/core/java/android/net/IConnectivityManager.aidl b/core/java/android/net/IConnectivityManager.aidl index 70ab4f1..8be492c 100644 --- a/core/java/android/net/IConnectivityManager.aidl +++ b/core/java/android/net/IConnectivityManager.aidl @@ -92,4 +92,6 @@ interface IConnectivityManager void setGlobalProxy(in ProxyProperties p); ProxyProperties getProxy(); + + void setDataDependency(int networkType, boolean met); } diff --git a/core/java/android/net/LinkAddress.java b/core/java/android/net/LinkAddress.java index 9c36b12..f6a114c 100644 --- a/core/java/android/net/LinkAddress.java +++ b/core/java/android/net/LinkAddress.java @@ -78,6 +78,14 @@ public class LinkAddress implements Parcelable { this.prefixLength == linkAddress.prefixLength; } + @Override + /* + * generate hashcode based on significant fields + */ + public int hashCode() { + return ((null == address) ? 0 : address.hashCode()) + prefixLength; + } + /** * Returns the InetAddress for this address. */ diff --git a/core/java/android/net/LinkProperties.java b/core/java/android/net/LinkProperties.java index b6e9751..19894a0 100644 --- a/core/java/android/net/LinkProperties.java +++ b/core/java/android/net/LinkProperties.java @@ -19,11 +19,9 @@ package android.net; import android.net.ProxyProperties; import android.os.Parcelable; import android.os.Parcel; -import android.util.Log; +import android.text.TextUtils; import java.net.InetAddress; -import java.net.NetworkInterface; -import java.net.SocketException; import java.net.UnknownHostException; import java.util.ArrayList; import java.util.Collection; @@ -56,7 +54,7 @@ public class LinkProperties implements Parcelable { String mIfaceName; private Collection<LinkAddress> mLinkAddresses; private Collection<InetAddress> mDnses; - private Collection<InetAddress> mGateways; + private Collection<RouteInfo> mRoutes; private ProxyProperties mHttpProxy; public LinkProperties() { @@ -69,8 +67,9 @@ public class LinkProperties implements Parcelable { mIfaceName = source.getInterfaceName(); mLinkAddresses = source.getLinkAddresses(); mDnses = source.getDnses(); - mGateways = source.getGateways(); - mHttpProxy = new ProxyProperties(source.getHttpProxy()); + mRoutes = source.getRoutes(); + mHttpProxy = (source.getHttpProxy() == null) ? + null : new ProxyProperties(source.getHttpProxy()); } } @@ -91,7 +90,7 @@ public class LinkProperties implements Parcelable { } public void addLinkAddress(LinkAddress address) { - mLinkAddresses.add(address); + if (address != null) mLinkAddresses.add(address); } public Collection<LinkAddress> getLinkAddresses() { @@ -99,18 +98,18 @@ public class LinkProperties implements Parcelable { } public void addDns(InetAddress dns) { - mDnses.add(dns); + if (dns != null) mDnses.add(dns); } public Collection<InetAddress> getDnses() { return Collections.unmodifiableCollection(mDnses); } - public void addGateway(InetAddress gateway) { - mGateways.add(gateway); + public void addRoute(RouteInfo route) { + if (route != null) mRoutes.add(route); } - public Collection<InetAddress> getGateways() { - return Collections.unmodifiableCollection(mGateways); + public Collection<RouteInfo> getRoutes() { + return Collections.unmodifiableCollection(mRoutes); } public void setHttpProxy(ProxyProperties proxy) { @@ -124,7 +123,7 @@ public class LinkProperties implements Parcelable { mIfaceName = null; mLinkAddresses = new ArrayList<LinkAddress>(); mDnses = new ArrayList<InetAddress>(); - mGateways = new ArrayList<InetAddress>(); + mRoutes = new ArrayList<RouteInfo>(); mHttpProxy = null; } @@ -141,19 +140,80 @@ public class LinkProperties implements Parcelable { String ifaceName = (mIfaceName == null ? "" : "InterfaceName: " + mIfaceName + " "); String linkAddresses = "LinkAddresses: ["; - for (LinkAddress addr : mLinkAddresses) linkAddresses += addr.toString(); + for (LinkAddress addr : mLinkAddresses) linkAddresses += addr.toString() + ","; linkAddresses += "] "; String dns = "DnsAddresses: ["; for (InetAddress addr : mDnses) dns += addr.getHostAddress() + ","; dns += "] "; - String gateways = "Gateways: ["; - for (InetAddress gw : mGateways) gateways += gw.getHostAddress() + ","; - gateways += "] "; + String routes = "Routes: ["; + for (RouteInfo route : mRoutes) routes += route.toString() + ","; + routes += "] "; String proxy = (mHttpProxy == null ? "" : "HttpProxy: " + mHttpProxy.toString() + " "); - return ifaceName + linkAddresses + gateways + dns + proxy; + return ifaceName + linkAddresses + routes + dns + proxy; + } + + + @Override + /** + * Compares this {@code LinkProperties} instance against the target + * LinkProperties in {@code obj}. Two LinkPropertieses are equal if + * all their fields are equal in values. + * + * For collection fields, such as mDnses, containsAll() is used to check + * if two collections contains the same elements, independent of order. + * There are two thoughts regarding containsAll() + * 1. Duplicated elements. eg, (A, B, B) and (A, A, B) are equal. + * 2. Worst case performance is O(n^2). + * + * @param obj the object to be tested for equality. + * @return {@code true} if both objects are equal, {@code false} otherwise. + */ + public boolean equals(Object obj) { + if (this == obj) return true; + + if (!(obj instanceof LinkProperties)) return false; + + boolean sameAddresses; + boolean sameDnses; + boolean sameRoutes; + + LinkProperties target = (LinkProperties) obj; + + Collection<InetAddress> targetAddresses = target.getAddresses(); + Collection<InetAddress> sourceAddresses = getAddresses(); + sameAddresses = (sourceAddresses.size() == targetAddresses.size()) ? + sourceAddresses.containsAll(targetAddresses) : false; + + Collection<InetAddress> targetDnses = target.getDnses(); + sameDnses = (mDnses.size() == targetDnses.size()) ? + mDnses.containsAll(targetDnses) : false; + + Collection<RouteInfo> targetRoutes = target.getRoutes(); + sameRoutes = (mRoutes.size() == targetRoutes.size()) ? + mRoutes.containsAll(targetRoutes) : false; + + return + sameAddresses && sameDnses && sameRoutes + && TextUtils.equals(getInterfaceName(), target.getInterfaceName()) + && (getHttpProxy() == null ? target.getHttpProxy() == null : + getHttpProxy().equals(target.getHttpProxy())); + } + + @Override + /** + * generate hashcode based on significant fields + * Equal objects must produce the same hash code, while unequal objects + * may have the same hash codes. + */ + public int hashCode() { + return ((null == mIfaceName) ? 0 : mIfaceName.hashCode() + + mLinkAddresses.size() * 31 + + mDnses.size() * 37 + + mRoutes.size() * 41 + + ((null == mHttpProxy) ? 0 : mHttpProxy.hashCode())); } /** @@ -172,9 +232,9 @@ public class LinkProperties implements Parcelable { dest.writeByteArray(d.getAddress()); } - dest.writeInt(mGateways.size()); - for(InetAddress gw : mGateways) { - dest.writeByteArray(gw.getAddress()); + dest.writeInt(mRoutes.size()); + for(RouteInfo route : mRoutes) { + dest.writeParcelable(route, flags); } if (mHttpProxy != null) { @@ -213,9 +273,7 @@ public class LinkProperties implements Parcelable { } addressCount = in.readInt(); for (int i=0; i<addressCount; i++) { - try { - netProp.addGateway(InetAddress.getByAddress(in.createByteArray())); - } catch (UnknownHostException e) { } + netProp.addRoute((RouteInfo)in.readParcelable(null)); } if (in.readByte() == 1) { netProp.setHttpProxy((ProxyProperties)in.readParcelable(null)); diff --git a/core/java/android/net/MobileDataStateTracker.java b/core/java/android/net/MobileDataStateTracker.java index e04964e..770f152 100644 --- a/core/java/android/net/MobileDataStateTracker.java +++ b/core/java/android/net/MobileDataStateTracker.java @@ -20,6 +20,7 @@ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; +import android.os.Bundle; import android.os.HandlerThread; import android.os.Looper; import android.os.Messenger; @@ -275,6 +276,21 @@ public class MobileDataStateTracker implements NetworkStateTracker { setDetailedState(DetailedState.CONNECTED, reason, apnName); break; } + } else { + // There was no state change. Check if LinkProperties has been updated. + if (TextUtils.equals(reason, Phone.REASON_LINK_PROPERTIES_CHANGED)) { + mLinkProperties = intent.getParcelableExtra(Phone.DATA_LINK_PROPERTIES_KEY); + if (mLinkProperties == null) { + log("No link property in LINK_PROPERTIES change event."); + mLinkProperties = new LinkProperties(); + } + // Just update reason field in this NetworkInfo + mNetworkInfo.setDetailedState(mNetworkInfo.getDetailedState(), reason, + mNetworkInfo.getExtraInfo()); + Message msg = mTarget.obtainMessage(EVENT_CONFIGURATION_CHANGED, + mNetworkInfo); + msg.sendToTarget(); + } } } else if (intent.getAction(). equals(TelephonyIntents.ACTION_DATA_CONNECTION_FAILED)) { @@ -437,7 +453,8 @@ public class MobileDataStateTracker implements NetworkStateTracker { retValue = true; break; case Phone.APN_REQUEST_STARTED: - // no need to do anything - we're already due some status update intents + // set IDLE here , avoid the following second FAILED not sent out + mNetworkInfo.setDetailedState(DetailedState.IDLE, null, null); retValue = true; break; case Phone.APN_REQUEST_FAILED: @@ -492,6 +509,25 @@ public class MobileDataStateTracker implements NetworkStateTracker { } } + /** + * carrier dependency is met/unmet + * @param met + */ + public void setDependencyMet(boolean met) { + Bundle bundle = Bundle.forPair(DataConnectionTracker.APN_TYPE_KEY, mApnType); + try { + log("setDependencyMet: E met=" + met); + Message msg = Message.obtain(); + msg.what = DataConnectionTracker.CMD_SET_DEPENDENCY_MET; + msg.arg1 = (met ? DataConnectionTracker.ENABLED : DataConnectionTracker.DISABLED); + msg.setData(bundle); + mDataConnectionTrackerAc.sendMessage(msg); + log("setDependencyMet: X met=" + met); + } catch (NullPointerException e) { + log("setDependencyMet: X mAc was null" + e); + } + } + @Override public String toString() { StringBuffer sb = new StringBuffer("Mobile data state: "); @@ -546,6 +582,12 @@ public class MobileDataStateTracker implements NetworkStateTracker { return Phone.APN_TYPE_DUN; case ConnectivityManager.TYPE_MOBILE_HIPRI: return Phone.APN_TYPE_HIPRI; + case ConnectivityManager.TYPE_MOBILE_FOTA: + return Phone.APN_TYPE_FOTA; + case ConnectivityManager.TYPE_MOBILE_IMS: + return Phone.APN_TYPE_IMS; + case ConnectivityManager.TYPE_MOBILE_CBS: + return Phone.APN_TYPE_CBS; default: sloge("Error mapping networkType " + netType + " to apnType."); return null; diff --git a/core/java/android/net/NetworkConfig.java b/core/java/android/net/NetworkConfig.java new file mode 100644 index 0000000..3cc0bc5 --- /dev/null +++ b/core/java/android/net/NetworkConfig.java @@ -0,0 +1,80 @@ +/* + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.net; + +import android.util.Log; + +/** + * Describes the buildtime configuration of a network. + * Holds settings read from resources. + * @hide + */ +public class NetworkConfig { + /** + * Human readable string + */ + public String name; + + /** + * Type from ConnectivityManager + */ + public int type; + + /** + * the radio number from radio attributes config + */ + public int radio; + + /** + * higher number == higher priority when turning off connections + */ + public int priority; + + /** + * indicates the boot time dependencyMet setting + */ + public boolean dependencyMet; + + /** + * indicates the default restoral timer in seconds + * if the network is used as a special network feature + * -1 indicates no restoration of default + */ + public int restoreTime; + + /** + * input string from config.xml resource. Uses the form: + * [Connection name],[ConnectivityManager connection type], + * [associated radio-type],[priority],[dependencyMet] + */ + public NetworkConfig(String init) { + String fragments[] = init.split(","); + name = fragments[0].trim().toLowerCase(); + type = Integer.parseInt(fragments[1]); + radio = Integer.parseInt(fragments[2]); + priority = Integer.parseInt(fragments[3]); + restoreTime = Integer.parseInt(fragments[4]); + dependencyMet = Boolean.parseBoolean(fragments[5]); + } + + /** + * Indicates if this network is supposed to be default-routable + */ + public boolean isDefault() { + return (type == radio); + } +} diff --git a/core/java/android/net/NetworkStateTracker.java b/core/java/android/net/NetworkStateTracker.java index eb97d77..f53063d 100644 --- a/core/java/android/net/NetworkStateTracker.java +++ b/core/java/android/net/NetworkStateTracker.java @@ -176,4 +176,9 @@ public interface NetworkStateTracker { * Indicate tear down requested from connectivity */ public void setTeardownRequested(boolean isRequested); + + /** + * An external dependency has been met/unmet + */ + public void setDependencyMet(boolean met); } diff --git a/core/java/android/net/NetworkUtils.java b/core/java/android/net/NetworkUtils.java index 823d10f..8a678d6 100644 --- a/core/java/android/net/NetworkUtils.java +++ b/core/java/android/net/NetworkUtils.java @@ -38,32 +38,6 @@ public class NetworkUtils { /** Bring the named network interface down. */ public native static int disableInterface(String interfaceName); - /** - * Add a route to the routing table. - * - * @param interfaceName the interface to route through. - * @param dst the network or host to route to. May be IPv4 or IPv6, e.g. - * "0.0.0.0" or "2001:4860::". - * @param prefixLength the prefix length of the route. - * @param gw the gateway to use, e.g., "192.168.251.1". If null, - * indicates a directly-connected route. - */ - public native static int addRoute(String interfaceName, String dst, - int prefixLength, String gw); - - /** Return the gateway address for the default route for the named interface. */ - public static InetAddress getDefaultRoute(String interfaceName) { - int addr = getDefaultRouteNative(interfaceName); - return intToInetAddress(addr); - } - private native static int getDefaultRouteNative(String interfaceName); - - /** Remove host routes that uses the named interface. */ - public native static int removeHostRoutes(String interfaceName); - - /** Remove the default route for the named interface. */ - public native static int removeDefaultRoute(String interfaceName); - /** Reset any sockets that are connected via the named interface. */ public native static int resetConnections(String interfaceName); @@ -160,6 +134,15 @@ public class NetworkUtils { } /** + * Convert a IPv4 netmask integer to a prefix length + * @param netmask as an integer in network byte order + * @return the network prefix length + */ + public static int netmaskIntToPrefixLength(int netmask) { + return Integer.bitCount(netmask); + } + + /** * Create an InetAddress from a string where the string must be a standard * representation of a V4 or V6 address. Avoids doing a DNS lookup on failure * but it will throw an IllegalArgumentException in that case. @@ -173,56 +156,69 @@ public class NetworkUtils { } /** - * Add a default route through the specified gateway. - * @param interfaceName interface on which the route should be added - * @param gw the IP address of the gateway to which the route is desired, - * @return {@code true} on success, {@code false} on failure + * Get InetAddress masked with prefixLength. Will never return null. + * @param IP address which will be masked with specified prefixLength + * @param prefixLength the prefixLength used to mask the IP */ - public static boolean addDefaultRoute(String interfaceName, InetAddress gw) { - String dstStr; - String gwStr = gw.getHostAddress(); - - if (gw instanceof Inet4Address) { - dstStr = "0.0.0.0"; - } else if (gw instanceof Inet6Address) { - dstStr = "::"; - } else { - Log.w(TAG, "addDefaultRoute failure: address is neither IPv4 nor IPv6" + - "(" + gwStr + ")"); - return false; + public static InetAddress getNetworkPart(InetAddress address, int prefixLength) { + if (address == null) { + throw new RuntimeException("getNetworkPart doesn't accept null address"); } - return addRoute(interfaceName, dstStr, 0, gwStr) == 0; + + byte[] array = address.getAddress(); + + if (prefixLength < 0 || prefixLength > array.length * 8) { + throw new RuntimeException("getNetworkPart - bad prefixLength"); + } + + int offset = prefixLength / 8; + int reminder = prefixLength % 8; + byte mask = (byte)(0xFF << (8 - reminder)); + + if (offset < array.length) array[offset] = (byte)(array[offset] & mask); + + offset++; + + for (; offset < array.length; offset++) { + array[offset] = 0; + } + + InetAddress netPart = null; + try { + netPart = InetAddress.getByAddress(array); + } catch (UnknownHostException e) { + throw new RuntimeException("getNetworkPart error - " + e.toString()); + } + return netPart; } /** - * Add a host route. - * @param interfaceName interface on which the route should be added - * @param dst the IP address of the host to which the route is desired, - * this should not be null. - * @param gw the IP address of the gateway to which the route is desired, - * if null, indicates a directly-connected route. - * @return {@code true} on success, {@code false} on failure + * Check if IP address type is consistent between two InetAddress. + * @return true if both are the same type. False otherwise. */ - public static boolean addHostRoute(String interfaceName, InetAddress dst, - InetAddress gw) { - if (dst == null) { - Log.w(TAG, "addHostRoute: dst should not be null"); - return false; - } + public static boolean addressTypeMatches(InetAddress left, InetAddress right) { + return (((left instanceof Inet4Address) && (right instanceof Inet4Address)) || + ((left instanceof Inet6Address) && (right instanceof Inet6Address))); + } - int prefixLength; - String dstStr = dst.getHostAddress(); - String gwStr = (gw != null) ? gw.getHostAddress() : null; - - if (dst instanceof Inet4Address) { - prefixLength = 32; - } else if (dst instanceof Inet6Address) { - prefixLength = 128; - } else { - Log.w(TAG, "addHostRoute failure: address is neither IPv4 nor IPv6" + - "(" + dst + ")"); - return false; + /** + * Convert a 32 char hex string into a Inet6Address. + * throws a runtime exception if the string isn't 32 chars, isn't hex or can't be + * made into an Inet6Address + * @param addrHexString a 32 character hex string representing an IPv6 addr + * @return addr an InetAddress representation for the string + */ + public static InetAddress hexToInet6Address(String addrHexString) + throws IllegalArgumentException { + try { + return numericToInetAddress(String.format("%s:%s:%s:%s:%s:%s:%s:%s", + addrHexString.substring(0,4), addrHexString.substring(4,8), + addrHexString.substring(8,12), addrHexString.substring(12,16), + addrHexString.substring(16,20), addrHexString.substring(20,24), + addrHexString.substring(24,28), addrHexString.substring(28,32))); + } catch (Exception e) { + Log.e("NetworkUtils", "error in hexToInet6Address(" + addrHexString + "): " + e); + throw new IllegalArgumentException(e); } - return addRoute(interfaceName, dstStr, prefixLength, gwStr) == 0; } } diff --git a/core/java/android/net/ProxyProperties.java b/core/java/android/net/ProxyProperties.java index cbe4445..44dbec1 100644 --- a/core/java/android/net/ProxyProperties.java +++ b/core/java/android/net/ProxyProperties.java @@ -163,6 +163,16 @@ public class ProxyProperties implements Parcelable { return 0; } + @Override + /* + * generate hashcode based on significant fields + */ + public int hashCode() { + return ((null == mHost) ? 0 : mHost.hashCode()) + + ((null == mExclusionList) ? 0 : mExclusionList.hashCode()) + + mPort; + } + /** * Implement the Parcelable interface. * @hide diff --git a/core/java/android/net/RouteInfo.aidl b/core/java/android/net/RouteInfo.aidl new file mode 100644 index 0000000..2296a57 --- /dev/null +++ b/core/java/android/net/RouteInfo.aidl @@ -0,0 +1,19 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.net; + +parcelable RouteInfo; diff --git a/core/java/android/net/RouteInfo.java b/core/java/android/net/RouteInfo.java new file mode 100644 index 0000000..8e5ddda --- /dev/null +++ b/core/java/android/net/RouteInfo.java @@ -0,0 +1,246 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.net; + +import android.os.Parcel; +import android.os.Parcelable; + +import java.net.UnknownHostException; +import java.net.InetAddress; +import java.net.Inet4Address; +import java.net.Inet6Address; + +import java.util.Collection; + +/** + * A simple container for route information. + * + * @hide + */ +public class RouteInfo implements Parcelable { + /** + * The IP destination address for this route. + */ + private final LinkAddress mDestination; + + /** + * The gateway address for this route. + */ + private final InetAddress mGateway; + + private final boolean mIsDefault; + + public RouteInfo(LinkAddress destination, InetAddress gateway) { + if (destination == null) { + if (gateway != null) { + if (gateway instanceof Inet4Address) { + destination = new LinkAddress(Inet4Address.ANY, 0); + } else { + destination = new LinkAddress(Inet6Address.ANY, 0); + } + } else { + // no destination, no gateway. invalid. + throw new RuntimeException("Invalid arguments passed in."); + } + } + if (gateway == null) { + if (destination.getAddress() instanceof Inet4Address) { + gateway = Inet4Address.ANY; + } else { + gateway = Inet6Address.ANY; + } + } + mDestination = new LinkAddress(NetworkUtils.getNetworkPart(destination.getAddress(), + destination.getNetworkPrefixLength()), destination.getNetworkPrefixLength()); + mGateway = gateway; + mIsDefault = isDefault(); + } + + public RouteInfo(InetAddress gateway) { + this(null, gateway); + } + + public static RouteInfo makeHostRoute(InetAddress host) { + return makeHostRoute(host, null); + } + + public static RouteInfo makeHostRoute(InetAddress host, InetAddress gateway) { + if (host == null) return null; + + if (host instanceof Inet4Address) { + return new RouteInfo(new LinkAddress(host, 32), gateway); + } else { + return new RouteInfo(new LinkAddress(host, 128), gateway); + } + } + + private boolean isDefault() { + boolean val = false; + if (mGateway != null) { + if (mGateway instanceof Inet4Address) { + val = (mDestination == null || mDestination.getNetworkPrefixLength() == 0); + } else { + val = (mDestination == null || mDestination.getNetworkPrefixLength() == 0); + } + } + return val; + } + + public LinkAddress getDestination() { + return mDestination; + } + + public InetAddress getGateway() { + return mGateway; + } + + public boolean isDefaultRoute() { + return mIsDefault; + } + + public String toString() { + String val = ""; + if (mDestination != null) val = mDestination.toString(); + if (mGateway != null) val += " -> " + mGateway.getHostAddress(); + return val; + } + + public int describeContents() { + return 0; + } + + public void writeToParcel(Parcel dest, int flags) { + if (mDestination == null) { + dest.writeByte((byte) 0); + } else { + dest.writeByte((byte) 1); + dest.writeByteArray(mDestination.getAddress().getAddress()); + dest.writeInt(mDestination.getNetworkPrefixLength()); + } + + if (mGateway == null) { + dest.writeByte((byte) 0); + } else { + dest.writeByte((byte) 1); + dest.writeByteArray(mGateway.getAddress()); + } + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + + if (!(obj instanceof RouteInfo)) return false; + + RouteInfo target = (RouteInfo) obj; + + boolean sameDestination = ( mDestination == null) ? + target.getDestination() == null + : mDestination.equals(target.getDestination()); + + boolean sameAddress = (mGateway == null) ? + target.getGateway() == null + : mGateway.equals(target.getGateway()); + + return sameDestination && sameAddress + && mIsDefault == target.mIsDefault; + } + + @Override + public int hashCode() { + return (mDestination == null ? 0 : mDestination.hashCode()) + + (mGateway == null ? 0 :mGateway.hashCode()) + + (mIsDefault ? 3 : 7); + } + + public static final Creator<RouteInfo> CREATOR = + new Creator<RouteInfo>() { + public RouteInfo createFromParcel(Parcel in) { + InetAddress destAddr = null; + int prefix = 0; + InetAddress gateway = null; + + if (in.readByte() == 1) { + byte[] addr = in.createByteArray(); + prefix = in.readInt(); + + try { + destAddr = InetAddress.getByAddress(addr); + } catch (UnknownHostException e) {} + } + + if (in.readByte() == 1) { + byte[] addr = in.createByteArray(); + + try { + gateway = InetAddress.getByAddress(addr); + } catch (UnknownHostException e) {} + } + + LinkAddress dest = null; + + if (destAddr != null) { + dest = new LinkAddress(destAddr, prefix); + } + + return new RouteInfo(dest, gateway); + } + + public RouteInfo[] newArray(int size) { + return new RouteInfo[size]; + } + }; + + private boolean matches(InetAddress destination) { + if (destination == null) return false; + + // if the destination is present and the route is default. + // return true + if (isDefault()) return true; + + // match the route destination and destination with prefix length + InetAddress dstNet = NetworkUtils.getNetworkPart(destination, + mDestination.getNetworkPrefixLength()); + + return mDestination.getAddress().equals(dstNet); + } + + /** + * Find the route from a Collection of routes that best matches a given address. + * May return null if no routes are applicable. + * @param routes a Collection of RouteInfos to chose from + * @param dest the InetAddress your trying to get to + * @return the RouteInfo from the Collection that best fits the given address + */ + public static RouteInfo selectBestRoute(Collection<RouteInfo> routes, InetAddress dest) { + if ((routes == null) || (dest == null)) return null; + + RouteInfo bestRoute = null; + // pick a longest prefix match under same address type + for (RouteInfo route : routes) { + if (NetworkUtils.addressTypeMatches(route.mDestination.getAddress(), dest)) { + if ((bestRoute != null) && + (bestRoute.mDestination.getNetworkPrefixLength() >= + route.mDestination.getNetworkPrefixLength())) { + continue; + } + if (route.matches(dest)) bestRoute = route; + } + } + return bestRoute; + } +} diff --git a/core/java/android/nfc/INfcAdapter.aidl b/core/java/android/nfc/INfcAdapter.aidl index d439a48..870127c 100644 --- a/core/java/android/nfc/INfcAdapter.aidl +++ b/core/java/android/nfc/INfcAdapter.aidl @@ -28,7 +28,7 @@ import android.nfc.ILlcpConnectionlessSocket; import android.nfc.INfcTag; import android.nfc.IP2pTarget; import android.nfc.IP2pInitiator; -import android.nfc.INfcSecureElement; +import android.nfc.INfcAdapterExtras; /** * @hide @@ -41,13 +41,12 @@ interface INfcAdapter INfcTag getNfcTagInterface(); IP2pTarget getP2pTargetInterface(); IP2pInitiator getP2pInitiatorInterface(); - INfcSecureElement getNfcSecureElementInterface(); + INfcAdapterExtras getNfcAdapterExtrasInterface(); // NfcAdapter-class related methods boolean isEnabled(); NdefMessage localGet(); void localSet(in NdefMessage message); - void openTagConnection(in Tag tag); void enableForegroundDispatch(in ComponentName activity, in PendingIntent intent, in IntentFilter[] filters, in TechListParcel techLists); void disableForegroundDispatch(in ComponentName activity); @@ -59,12 +58,8 @@ interface INfcAdapter int createLlcpConnectionlessSocket(int sap); int createLlcpServiceSocket(int sap, String sn, int miu, int rw, int linearBufferLength); int createLlcpSocket(int sap, int miu, int rw, int linearBufferLength); - int deselectSecureElement(); boolean disable(); boolean enable(); String getProperties(String param); - int[] getSecureElementList(); - int getSelectedSecureElement(); - int selectSecureElement(int seId); int setProperties(String param, String value); -}
\ No newline at end of file +} diff --git a/core/java/android/nfc/INfcSecureElement.aidl b/core/java/android/nfc/INfcAdapterExtras.aidl index aa98dd2..ab5c1a6 100755 --- a/core/java/android/nfc/INfcSecureElement.aidl +++ b/core/java/android/nfc/INfcAdapterExtras.aidl @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010 The Android Open Source Project + * Copyright (C) 2011 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,13 +16,15 @@ package android.nfc; +import android.os.Bundle; + /** * {@hide} */ -interface INfcSecureElement { - int openSecureElementConnection(); - int closeSecureElementConnection(int nativeHandle); - byte[] exchangeAPDU(int nativeHandle, in byte[] data); - int[] getSecureElementTechList(int nativeHandle); - byte[] getSecureElementUid(int nativeHandle); -}
\ No newline at end of file +interface INfcAdapterExtras { + Bundle open(IBinder b); + Bundle close(); + Bundle transceive(in byte[] data_in); + int getCardEmulationRoute(); + void setCardEmulationRoute(int route); +} diff --git a/core/java/android/nfc/NfcAdapter.java b/core/java/android/nfc/NfcAdapter.java index 8c56fda..4689804 100644 --- a/core/java/android/nfc/NfcAdapter.java +++ b/core/java/android/nfc/NfcAdapter.java @@ -157,31 +157,6 @@ public final class NfcAdapter { public static final String EXTRA_ID = "android.nfc.extra.ID"; /** - * Broadcast Action: a transaction with a secure element has been detected. - * <p> - * Always contains the extra field - * {@link android.nfc.NfcAdapter#EXTRA_AID} - * @hide - */ - @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) - public static final String ACTION_TRANSACTION_DETECTED = - "android.nfc.action.TRANSACTION_DETECTED"; - - /** - * Broadcast Action: an RF field ON has been detected. - * @hide - */ - public static final String ACTION_RF_FIELD_ON_DETECTED = - "android.nfc.action.RF_FIELD_ON_DETECTED"; - - /** - * Broadcast Action: an RF Field OFF has been detected. - * @hide - */ - public static final String ACTION_RF_FIELD_OFF_DETECTED = - "android.nfc.action.RF_FIELD_OFF_DETECTED"; - - /** * Broadcast Action: an adapter's state changed between enabled and disabled. * * The new value is stored in the extra EXTRA_NEW_BOOLEAN_STATE and just contains @@ -201,15 +176,6 @@ public final class NfcAdapter { public static final String EXTRA_NEW_BOOLEAN_STATE = "android.nfc.isEnabled"; /** - * Mandatory byte array extra field in - * {@link android.nfc.NfcAdapter#ACTION_TRANSACTION_DETECTED}. - * <p> - * Contains the AID of the applet involved in the transaction. - * @hide - */ - public static final String EXTRA_AID = "android.nfc.extra.AID"; - - /** * LLCP link status: The LLCP link is activated. * @hide */ @@ -691,39 +657,14 @@ public final class NfcAdapter { } /** - * Create an Nfc Secure Element Connection * @hide */ - public NfcSecureElement createNfcSecureElementConnection() { + public INfcAdapterExtras getNfcAdapterExtrasInterface() { try { - return new NfcSecureElement(sService.getNfcSecureElementInterface()); + return sService.getNfcAdapterExtrasInterface(); } catch (RemoteException e) { - Log.e(TAG, "createNfcSecureElementConnection failed", e); + attemptDeadServiceRecovery(e); return null; } } - - /** - * To change the Secure Element Card Emulation state (ON/OFF) - * @hide - */ - public void changeNfcSecureElementCardEmulationState(boolean state) - { - int seId = 11259375; - if(state){ - /* Enable card emulation */ - try { - sService.selectSecureElement(seId); - } catch (RemoteException e) { - Log.e(TAG, "Enable card emulation failed", e); - } - }else{ - /* Disable card emulation */ - try { - sService.deselectSecureElement(); - } catch (RemoteException e) { - Log.e(TAG, " card emulation failed", e); - } - } - } } diff --git a/core/java/android/nfc/NfcSecureElement.java b/core/java/android/nfc/NfcSecureElement.java deleted file mode 100755 index 3b5f39e..0000000 --- a/core/java/android/nfc/NfcSecureElement.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package android.nfc; - -import android.nfc.tech.TagTechnology; -import android.os.RemoteException; -import android.util.Log; - -import java.io.IOException; - -//import android.util.Log; - -/** - * This class provides the primary API for managing all aspects Secure Element. - * Get an instance of this class by calling - * Context.getSystemService(Context.NFC_SERVICE). - * @hide - */ -public final class NfcSecureElement { - - private static final String TAG = "NfcSecureElement"; - - private INfcSecureElement mService; - - - /** - * @hide - */ - public NfcSecureElement(INfcSecureElement mSecureElementService) { - mService = mSecureElementService; - } - - public int openSecureElementConnection(String seType) throws IOException { - if (seType.equals("SmartMX")) { - try { - int handle = mService.openSecureElementConnection(); - // Handle potential errors - if (handle != 0) { - return handle; - } else { - throw new IOException("SmartMX connection not allowed"); - } - } catch (RemoteException e) { - Log.e(TAG, "RemoteException in openSecureElementConnection(): ", e); - return 0; - } - - } else if (seType.equals("UICC")) { - return 0; - } else { - throw new IOException("Wrong Secure Element type"); - } - } - - - public byte [] exchangeAPDU(int handle,byte [] data) throws IOException { - - - // Perform exchange APDU - try { - byte[] response = mService.exchangeAPDU(handle, data); - // Handle potential errors - if (response == null) { - throw new IOException("Exchange APDU failed"); - } - return response; - } catch (RemoteException e) { - Log.e(TAG, "RemoteException in exchangeAPDU(): ", e); - return null; - } - } - - public void closeSecureElementConnection(int handle) throws IOException { - - try { - int status = mService.closeSecureElementConnection(handle); - // Handle potential errors - if (ErrorCodes.isError(status)) { - throw new IOException("Error during the conection close"); - }; - } catch (RemoteException e) { - Log.e(TAG, "RemoteException in closeSecureElement(): ", e); - } - } - - - /** - * Returns target type. constants. - * - * @return Secure Element technology type. The possible values are defined in - * {@link TagTechnology} - * - */ - public int[] getSecureElementTechList(int handle) throws IOException { - try { - return mService.getSecureElementTechList(handle); - } catch (RemoteException e) { - Log.e(TAG, "RemoteException in getType(): ", e); - return null; - } - } - - /** - * Returns Secure Element UID. - * - * @return Secure Element UID. - */ - public byte[] getSecureElementUid(int handle) throws IOException { - - byte[] uid = null; - try { - uid = mService.getSecureElementUid(handle); - // Handle potential errors - if (uid == null) { - throw new IOException("Get Secure Element UID failed"); - } - return uid; - } catch (RemoteException e) { - Log.e(TAG, "RemoteException in getType(): ", e); - return null; - } - } - -} diff --git a/core/java/android/os/INetworkManagementService.aidl b/core/java/android/os/INetworkManagementService.aidl index 212c5fb..5a245f8 100644 --- a/core/java/android/os/INetworkManagementService.aidl +++ b/core/java/android/os/INetworkManagementService.aidl @@ -19,6 +19,7 @@ package android.os; import android.net.InterfaceConfiguration; import android.net.INetworkManagementEventObserver; +import android.net.RouteInfo; import android.net.wifi.WifiConfiguration; /** @@ -57,6 +58,22 @@ interface INetworkManagementService void setInterfaceConfig(String iface, in InterfaceConfiguration cfg); /** + * Retrieves the network routes currently configured on the specified + * interface + */ + RouteInfo[] getRoutes(String iface); + + /** + * Add the specified route to the interface. + */ + void addRoute(String iface, in RouteInfo route); + + /** + * Remove the specified route from the interface. + */ + void removeRoute(String iface, in RouteInfo route); + + /** * Shuts down the service */ void shutdown(); diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index fbdc0ba..d69303e 100644 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -3695,6 +3695,29 @@ public final class Settings { "inet_condition_debounce_down_delay"; /** + * URL to open browser on to allow user to manage a prepay account + * @hide + */ + public static final String SETUP_PREPAID_DATA_SERVICE_URL = + "setup_prepaid_data_service_url"; + + /** + * URL to attempt a GET on to see if this is a prepay device + * @hide + */ + public static final String SETUP_PREPAID_DETECTION_TARGET_URL = + "setup_prepaid_detection_target_url"; + + /** + * Host to check for a redirect to after an attempt to GET + * SETUP_PREPAID_DETECTION_TARGET_URL. (If we redirected there, + * this is a prepaid device with zero balance.) + * @hide + */ + public static final String SETUP_PREPAID_DETECTION_REDIR_HOST = + "setup_prepaid_detection_redir_host"; + + /** * @hide */ public static final String[] SETTINGS_TO_BACKUP = { diff --git a/core/java/android/provider/Telephony.java b/core/java/android/provider/Telephony.java index 62f66b6..d2d2557 100644 --- a/core/java/android/provider/Telephony.java +++ b/core/java/android/provider/Telephony.java @@ -1723,6 +1723,14 @@ public final class Telephony { public static final String TYPE = "type"; + public static final String INACTIVE_TIMER = "inactivetimer"; + + // Only if enabled try Data Connection. + public static final String ENABLED = "enabled"; + + // Rules apply based on class. + public static final String CLASS = "class"; + /** * The protocol to be used to connect to this APN. * diff --git a/core/java/android/view/ViewRoot.java b/core/java/android/view/ViewRoot.java index 5ad0b6b..f8298ef 100644 --- a/core/java/android/view/ViewRoot.java +++ b/core/java/android/view/ViewRoot.java @@ -1173,10 +1173,11 @@ public final class ViewRoot extends Handler implements ViewParent, } } mSurfaceHolder.mSurfaceLock.lock(); - // Make surface invalid. - //mSurfaceHolder.mSurface.copyFrom(mSurface); - mSurfaceHolder.mSurface = new Surface(); - mSurfaceHolder.mSurfaceLock.unlock(); + try { + mSurfaceHolder.mSurface = new Surface(); + } finally { + mSurfaceHolder.mSurfaceLock.unlock(); + } } } |