diff options
Diffstat (limited to 'core/java/android')
26 files changed, 911 insertions, 287 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 new file mode 100644 index 0000000..eaf087f --- /dev/null +++ b/core/java/android/net/DhcpStateMachine.java @@ -0,0 +1,353 @@ +/* + * 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 com.android.internal.util.Protocol; +import com.android.internal.util.State; +import com.android.internal.util.StateMachine; + +import android.app.AlarmManager; +import android.app.PendingIntent; +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.content.IntentFilter; +import android.net.DhcpInfoInternal; +import android.net.NetworkUtils; +import android.os.Message; +import android.os.PowerManager; +import android.os.SystemClock; +import android.util.Log; + +/** + * StateMachine that interacts with the native DHCP client and can talk to + * a controller that also needs to be a StateMachine + * + * The Dhcp state machine provides the following features: + * - Wakeup and renewal using the native DHCP client (which will not renew + * on its own when the device is in suspend state and this can lead to device + * holding IP address beyond expiry) + * - A notification right before DHCP request or renewal is started. This + * can be used for any additional setup before DHCP. For example, wifi sets + * BT-Wifi coex settings right before DHCP is initiated + * + * @hide + */ +public class DhcpStateMachine extends StateMachine { + + private static final String TAG = "DhcpStateMachine"; + private static final boolean DBG = false; + + + /* A StateMachine that controls the DhcpStateMachine */ + private StateMachine mController; + + private Context mContext; + private BroadcastReceiver mBroadcastReceiver; + private AlarmManager mAlarmManager; + private PendingIntent mDhcpRenewalIntent; + private PowerManager.WakeLock mDhcpRenewWakeLock; + private static final String WAKELOCK_TAG = "DHCP"; + + private static final int DHCP_RENEW = 0; + private static final String ACTION_DHCP_RENEW = "android.net.wifi.DHCP_RENEW"; + + private enum DhcpAction { + START, + RENEW + }; + + private String mInterfaceName; + private boolean mRegisteredForPreDhcpNotification = false; + + private static final int BASE = Protocol.BASE_DHCP; + + /* Commands from controller to start/stop DHCP */ + public static final int CMD_START_DHCP = BASE + 1; + public static final int CMD_STOP_DHCP = BASE + 2; + public static final int CMD_RENEW_DHCP = BASE + 3; + + /* Notification from DHCP state machine prior to DHCP discovery/renewal */ + public static final int CMD_PRE_DHCP_ACTION = BASE + 4; + /* Notification from DHCP state machine post DHCP discovery/renewal. Indicates + * success/failure */ + public static final int CMD_POST_DHCP_ACTION = BASE + 5; + + /* Command from controller to indicate DHCP discovery/renewal can continue + * after pre DHCP action is complete */ + public static final int CMD_PRE_DHCP_ACTION_COMPLETE = BASE + 6; + + /* Message.arg1 arguments to CMD_POST_DHCP notification */ + public static final int DHCP_SUCCESS = 1; + public static final int DHCP_FAILURE = 2; + + 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, StateMachine controller, String intf) { + super(TAG); + + mContext = context; + mController = controller; + mInterfaceName = intf; + + mAlarmManager = (AlarmManager)mContext.getSystemService(Context.ALARM_SERVICE); + Intent dhcpRenewalIntent = new Intent(ACTION_DHCP_RENEW, null); + mDhcpRenewalIntent = PendingIntent.getBroadcast(mContext, DHCP_RENEW, dhcpRenewalIntent, 0); + + PowerManager powerManager = (PowerManager)mContext.getSystemService(Context.POWER_SERVICE); + mDhcpRenewWakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, WAKELOCK_TAG); + + mBroadcastReceiver = new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + //DHCP renew + if (DBG) Log.d(TAG, "Sending a DHCP renewal " + this); + //acquire a 40s wakelock to finish DHCP renewal + mDhcpRenewWakeLock.acquire(40000); + sendMessage(CMD_RENEW_DHCP); + } + }; + mContext.registerReceiver(mBroadcastReceiver, new IntentFilter(ACTION_DHCP_RENEW)); + + addState(mDefaultState); + addState(mStoppedState, mDefaultState); + addState(mWaitBeforeStartState, mDefaultState); + addState(mRunningState, mDefaultState); + addState(mWaitBeforeRenewalState, mDefaultState); + + setInitialState(mStoppedState); + } + + public static DhcpStateMachine makeDhcpStateMachine(Context context, StateMachine controller, + String intf) { + DhcpStateMachine dsm = new DhcpStateMachine(context, controller, intf); + dsm.start(); + return dsm; + } + + /** + * This sends a notification right before DHCP request/renewal so that the + * controller can do certain actions before DHCP packets are sent out. + * When the controller is ready, it sends a CMD_PRE_DHCP_ACTION_COMPLETE message + * to indicate DHCP can continue + * + * This is used by Wifi at this time for the purpose of doing BT-Wifi coex + * handling during Dhcp + */ + public void registerForPreDhcpNotification() { + mRegisteredForPreDhcpNotification = true; + } + + class DefaultState extends State { + @Override + public boolean processMessage(Message message) { + if (DBG) Log.d(TAG, getName() + message.toString() + "\n"); + switch (message.what) { + case CMD_RENEW_DHCP: + Log.e(TAG, "Error! Failed to handle a DHCP renewal on " + mInterfaceName); + break; + case SM_QUIT_CMD: + mContext.unregisterReceiver(mBroadcastReceiver); + //let parent kill the state machine + return NOT_HANDLED; + default: + Log.e(TAG, "Error! unhandled message " + message); + break; + } + return HANDLED; + } + } + + + class StoppedState extends State { + @Override + public void enter() { + if (DBG) Log.d(TAG, getName() + "\n"); + } + + @Override + public boolean processMessage(Message message) { + boolean retValue = HANDLED; + if (DBG) Log.d(TAG, getName() + message.toString() + "\n"); + switch (message.what) { + case CMD_START_DHCP: + if (mRegisteredForPreDhcpNotification) { + /* Notify controller before starting DHCP */ + mController.sendMessage(CMD_PRE_DHCP_ACTION); + transitionTo(mWaitBeforeStartState); + } else { + if (runDhcp(DhcpAction.START)) { + transitionTo(mRunningState); + } + } + break; + case CMD_STOP_DHCP: + //ignore + break; + default: + retValue = NOT_HANDLED; + break; + } + return retValue; + } + } + + class WaitBeforeStartState extends State { + @Override + public void enter() { + if (DBG) Log.d(TAG, getName() + "\n"); + } + + @Override + public boolean processMessage(Message message) { + boolean retValue = HANDLED; + if (DBG) Log.d(TAG, getName() + message.toString() + "\n"); + switch (message.what) { + case CMD_PRE_DHCP_ACTION_COMPLETE: + if (runDhcp(DhcpAction.START)) { + transitionTo(mRunningState); + } else { + transitionTo(mStoppedState); + } + break; + case CMD_STOP_DHCP: + transitionTo(mStoppedState); + break; + case CMD_START_DHCP: + //ignore + break; + default: + retValue = NOT_HANDLED; + break; + } + return retValue; + } + } + + class RunningState extends State { + @Override + public void enter() { + if (DBG) Log.d(TAG, getName() + "\n"); + } + + @Override + public boolean processMessage(Message message) { + boolean retValue = HANDLED; + if (DBG) Log.d(TAG, getName() + message.toString() + "\n"); + switch (message.what) { + case CMD_STOP_DHCP: + mAlarmManager.cancel(mDhcpRenewalIntent); + if (!NetworkUtils.stopDhcp(mInterfaceName)) { + Log.e(TAG, "Failed to stop Dhcp on " + mInterfaceName); + } + transitionTo(mStoppedState); + break; + case CMD_RENEW_DHCP: + if (mRegisteredForPreDhcpNotification) { + /* Notify controller before starting DHCP */ + mController.sendMessage(CMD_PRE_DHCP_ACTION); + transitionTo(mWaitBeforeRenewalState); + } else { + if (!runDhcp(DhcpAction.RENEW)) { + transitionTo(mStoppedState); + } + } + break; + case CMD_START_DHCP: + //ignore + break; + default: + retValue = NOT_HANDLED; + } + return retValue; + } + } + + class WaitBeforeRenewalState extends State { + @Override + public void enter() { + if (DBG) Log.d(TAG, getName() + "\n"); + } + + @Override + public boolean processMessage(Message message) { + boolean retValue = HANDLED; + if (DBG) Log.d(TAG, getName() + message.toString() + "\n"); + switch (message.what) { + case CMD_STOP_DHCP: + mAlarmManager.cancel(mDhcpRenewalIntent); + if (!NetworkUtils.stopDhcp(mInterfaceName)) { + Log.e(TAG, "Failed to stop Dhcp on " + mInterfaceName); + } + transitionTo(mStoppedState); + break; + case CMD_PRE_DHCP_ACTION_COMPLETE: + if (runDhcp(DhcpAction.RENEW)) { + transitionTo(mRunningState); + } else { + transitionTo(mStoppedState); + } + break; + case CMD_START_DHCP: + //ignore + break; + default: + retValue = NOT_HANDLED; + break; + } + return retValue; + } + } + + private boolean runDhcp(DhcpAction dhcpAction) { + boolean success = false; + DhcpInfoInternal dhcpInfoInternal = new DhcpInfoInternal(); + + if (dhcpAction == DhcpAction.START) { + Log.d(TAG, "DHCP request on " + mInterfaceName); + success = NetworkUtils.runDhcp(mInterfaceName, dhcpInfoInternal); + } else if (dhcpAction == DhcpAction.RENEW) { + Log.d(TAG, "DHCP renewal on " + mInterfaceName); + success = NetworkUtils.runDhcpRenew(mInterfaceName, dhcpInfoInternal); + } + + if (success) { + Log.d(TAG, "DHCP succeeded on " + mInterfaceName); + //Do it a bit earlier than half the lease duration time + //to beat the native DHCP client and avoid extra packets + //48% for one hour lease time = 29 minutes + mAlarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, + SystemClock.elapsedRealtime() + + dhcpInfoInternal.leaseDuration * 480, //in milliseconds + mDhcpRenewalIntent); + + mController.obtainMessage(CMD_POST_DHCP_ACTION, DHCP_SUCCESS, 0, dhcpInfoInternal) + .sendToTarget(); + } else { + Log.d(TAG, "DHCP failed on " + mInterfaceName + ": " + + NetworkUtils.getDhcpError()); + NetworkUtils.stopDhcp(mInterfaceName); + mController.obtainMessage(CMD_POST_DHCP_ACTION, DHCP_FAILURE, 0) + .sendToTarget(); + } + return success; + } +} 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..61acf2b 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,7 +67,7 @@ public class LinkProperties implements Parcelable { mIfaceName = source.getInterfaceName(); mLinkAddresses = source.getLinkAddresses(); mDnses = source.getDnses(); - mGateways = source.getGateways(); + mRoutes = source.getRoutes(); mHttpProxy = new ProxyProperties(source.getHttpProxy()); } } @@ -91,7 +89,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 +97,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 +122,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 +139,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 +231,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 +272,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..bb6ee0f 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; @@ -437,7 +438,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 +494,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 +567,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 b3f3988..823d10f 100644 --- a/core/java/android/net/NetworkUtils.java +++ b/core/java/android/net/NetworkUtils.java @@ -80,6 +80,16 @@ public class NetworkUtils { public native static boolean runDhcp(String interfaceName, DhcpInfoInternal ipInfo); /** + * Initiate renewal on the Dhcp client daemon. This call blocks until it obtains + * a result (either success or failure) from the daemon. + * @param interfaceName the name of the interface to configure + * @param ipInfo if the request succeeds, this object is filled in with + * the IP address information. + * @return {@code true} for success, {@code false} for failure + */ + public native static boolean runDhcpRenew(String interfaceName, DhcpInfoInternal ipInfo); + + /** * Shut down the DHCP client daemon. * @param interfaceName the name of the interface for which the daemon * should be stopped 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..5b10531 --- /dev/null +++ b/core/java/android/net/RouteInfo.java @@ -0,0 +1,162 @@ +/* + * 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; +/** + * 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) { + try { + if ((gateway != null) && (gateway instanceof Inet4Address)) { + destination = new LinkAddress(InetAddress.getByName("0.0.0.0"), 32); + } else { + destination = new LinkAddress(InetAddress.getByName("::0"), 128); + } + } catch (Exception e) {} + } + mDestination = destination; + mGateway = gateway; + mIsDefault = isDefault(); + } + + public RouteInfo(InetAddress gateway) { + LinkAddress destination = null; + try { + if ((gateway != null) && (gateway instanceof Inet4Address)) { + destination = new LinkAddress(InetAddress.getByName("0.0.0.0"), 32); + } else { + destination = new LinkAddress(InetAddress.getByName("::0"), 128); + } + } catch (Exception e) {} + mDestination = destination; + mGateway = gateway; + mIsDefault = isDefault(); + } + + private boolean isDefault() { + boolean val = false; + if (mGateway != null) { + if (mGateway instanceof Inet4Address) { + val = (mDestination == null || mDestination.getNetworkPrefixLength() == 32); + } else { + val = (mDestination == null || mDestination.getNetworkPrefixLength() == 128); + } + } + 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()); + } + } + + 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]; + } + }; +} 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/provider/Settings.java b/core/java/android/provider/Settings.java index 6deb5a0..b09b44e 100644 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -3688,6 +3688,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 a53c6d0..7d6e18f 100644 --- a/core/java/android/view/ViewRoot.java +++ b/core/java/android/view/ViewRoot.java @@ -1175,10 +1175,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(); + } } } |