diff options
23 files changed, 819 insertions, 735 deletions
diff --git a/api/current.txt b/api/current.txt index bcfb24a25727..2e64adb09081 100644 --- a/api/current.txt +++ b/api/current.txt @@ -132,7 +132,6 @@ package android { field public static final java.lang.String SET_WALLPAPER = "android.permission.SET_WALLPAPER"; field public static final java.lang.String SET_WALLPAPER_HINTS = "android.permission.SET_WALLPAPER_HINTS"; field public static final java.lang.String SIGNAL_PERSISTENT_PROCESSES = "android.permission.SIGNAL_PERSISTENT_PROCESSES"; - field public static final java.lang.String SIM_COMMUNICATION = "android.permission.SIM_COMMUNICATION"; field public static final java.lang.String STATUS_BAR = "android.permission.STATUS_BAR"; field public static final java.lang.String SUBSCRIBED_FEEDS_READ = "android.permission.SUBSCRIBED_FEEDS_READ"; field public static final java.lang.String SUBSCRIBED_FEEDS_WRITE = "android.permission.SUBSCRIBED_FEEDS_WRITE"; @@ -27762,12 +27761,8 @@ package android.telephony { method public java.lang.String getVoiceMailAlphaTag(); method public java.lang.String getVoiceMailNumber(); method public boolean hasIccCard(); - method public boolean iccCloseLogicalChannel(int); - method public int iccOpenLogicalChannel(java.lang.String); - method public java.lang.String iccTransmitApduLogicalChannel(int, int, int, int, int, int, java.lang.String); method public boolean isNetworkRoaming(); method public void listen(android.telephony.PhoneStateListener, int); - method public java.lang.String sendEnvelopeWithStatus(java.lang.String); field public static final java.lang.String ACTION_PHONE_STATE_CHANGED = "android.intent.action.PHONE_STATE"; field public static final java.lang.String ACTION_RESPOND_VIA_MESSAGE = "android.intent.action.RESPOND_VIA_MESSAGE"; field public static final int CALL_STATE_IDLE = 0; // 0x0 diff --git a/core/java/android/net/ConnectivityManager.java b/core/java/android/net/ConnectivityManager.java index 2f2aba328661..24844ba46c28 100644 --- a/core/java/android/net/ConnectivityManager.java +++ b/core/java/android/net/ConnectivityManager.java @@ -40,6 +40,7 @@ import android.util.ArrayMap; import android.util.Log; import com.android.internal.telephony.ITelephony; +import com.android.internal.telephony.PhoneConstants; import com.android.internal.util.Protocol; import java.net.InetAddress; @@ -807,11 +808,34 @@ public class ConnectivityManager { * @deprecated Deprecated in favor of the cleaner {@link #requestNetwork} api. */ public int startUsingNetworkFeature(int networkType, String feature) { - try { - return mService.startUsingNetworkFeature(networkType, feature, - new Binder()); - } catch (RemoteException e) { - return -1; + NetworkCapabilities netCap = networkCapabilitiesForFeature(networkType, feature); + if (netCap == null) { + Log.d(TAG, "Can't satisfy startUsingNetworkFeature for " + networkType + ", " + + feature); + return PhoneConstants.APN_REQUEST_FAILED; + } + + NetworkRequest request = null; + synchronized (sLegacyRequests) { + LegacyRequest l = sLegacyRequests.get(netCap); + if (l != null) { + Log.d(TAG, "renewing startUsingNetworkFeature request " + l.networkRequest); + renewRequestLocked(l); + if (l.currentNetwork != null) { + return PhoneConstants.APN_ALREADY_ACTIVE; + } else { + return PhoneConstants.APN_REQUEST_STARTED; + } + } + + request = requestNetworkForFeatureLocked(netCap); + } + if (request != null) { + Log.d(TAG, "starting startUsingNeworkFeature for request " + request); + return PhoneConstants.APN_REQUEST_STARTED; + } else { + Log.d(TAG, " request Failed"); + return PhoneConstants.APN_REQUEST_FAILED; } } @@ -831,11 +855,169 @@ public class ConnectivityManager { * @deprecated Deprecated in favor of the cleaner {@link #requestNetwork} api. */ public int stopUsingNetworkFeature(int networkType, String feature) { - try { - return mService.stopUsingNetworkFeature(networkType, feature); - } catch (RemoteException e) { + NetworkCapabilities netCap = networkCapabilitiesForFeature(networkType, feature); + if (netCap == null) { + Log.d(TAG, "Can't satisfy stopUsingNetworkFeature for " + networkType + ", " + + feature); return -1; } + + NetworkRequest request = removeRequestForFeature(netCap); + if (request != null) { + Log.d(TAG, "stopUsingNetworkFeature for " + networkType + ", " + feature); + releaseNetworkRequest(request); + } + return 1; + } + + private NetworkCapabilities networkCapabilitiesForFeature(int networkType, String feature) { + if (networkType == TYPE_MOBILE) { + int cap = -1; + if ("enableMMS".equals(feature)) { + cap = NetworkCapabilities.NET_CAPABILITY_MMS; + } else if ("enableSUPL".equals(feature)) { + cap = NetworkCapabilities.NET_CAPABILITY_SUPL; + } else if ("enableDUN".equals(feature) || "enableDUNAlways".equals(feature)) { + cap = NetworkCapabilities.NET_CAPABILITY_DUN; + } else if ("enableHIPRI".equals(feature)) { + cap = NetworkCapabilities.NET_CAPABILITY_INTERNET; + } else if ("enableFOTA".equals(feature)) { + cap = NetworkCapabilities.NET_CAPABILITY_FOTA; + } else if ("enableIMS".equals(feature)) { + cap = NetworkCapabilities.NET_CAPABILITY_IMS; + } else if ("enableCBS".equals(feature)) { + cap = NetworkCapabilities.NET_CAPABILITY_CBS; + } else { + return null; + } + NetworkCapabilities netCap = new NetworkCapabilities(); + netCap.addTransportType(NetworkCapabilities.TRANSPORT_CELLULAR); + netCap.addNetworkCapability(cap); + return netCap; + } else if (networkType == TYPE_WIFI) { + if ("p2p".equals(feature)) { + NetworkCapabilities netCap = new NetworkCapabilities(); + netCap.addTransportType(NetworkCapabilities.TRANSPORT_WIFI); + netCap.addNetworkCapability(NetworkCapabilities.NET_CAPABILITY_WIFI_P2P); + return netCap; + } + } + return null; + } + + private int networkTypeForNetworkCapabilities(NetworkCapabilities netCap) { + if (netCap == null) return TYPE_NONE; + if (netCap.hasCapability(NetworkCapabilities.NET_CAPABILITY_CBS)) { + return TYPE_MOBILE_CBS; + } + if (netCap.hasCapability(NetworkCapabilities.NET_CAPABILITY_IMS)) { + return TYPE_MOBILE_IMS; + } + if (netCap.hasCapability(NetworkCapabilities.NET_CAPABILITY_FOTA)) { + return TYPE_MOBILE_FOTA; + } + if (netCap.hasCapability(NetworkCapabilities.NET_CAPABILITY_DUN)) { + return TYPE_MOBILE_DUN; + } + if (netCap.hasCapability(NetworkCapabilities.NET_CAPABILITY_SUPL)) { + return TYPE_MOBILE_SUPL; + } + if (netCap.hasCapability(NetworkCapabilities.NET_CAPABILITY_MMS)) { + return TYPE_MOBILE_MMS; + } + if (netCap.hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)) { + return TYPE_MOBILE_HIPRI; + } + return TYPE_NONE; + } + + private static class LegacyRequest { + NetworkCapabilities networkCapabilities; + NetworkRequest networkRequest; + int expireSequenceNumber; + Network currentNetwork; + int delay = -1; + NetworkCallbackListener networkCallbackListener = new NetworkCallbackListener() { + @Override + public void onAvailable(NetworkRequest request, Network network) { + currentNetwork = network; + Log.d(TAG, "startUsingNetworkFeature got Network:" + network); + network.bindProcessForHostResolution(); + } + @Override + public void onLost(NetworkRequest request, Network network) { + if (network.equals(currentNetwork)) { + currentNetwork = null; + network.unbindProcessForHostResolution(); + } + Log.d(TAG, "startUsingNetworkFeature lost Network:" + network); + } + }; + } + + private HashMap<NetworkCapabilities, LegacyRequest> sLegacyRequests = + new HashMap<NetworkCapabilities, LegacyRequest>(); + + private NetworkRequest findRequestForFeature(NetworkCapabilities netCap) { + synchronized (sLegacyRequests) { + LegacyRequest l = sLegacyRequests.get(netCap); + if (l != null) return l.networkRequest; + } + return null; + } + + private void renewRequestLocked(LegacyRequest l) { + l.expireSequenceNumber++; + Log.d(TAG, "renewing request to seqNum " + l.expireSequenceNumber); + sendExpireMsgForFeature(l.networkCapabilities, l.expireSequenceNumber, l.delay); + } + + private void expireRequest(NetworkCapabilities netCap, int sequenceNum) { + int ourSeqNum = -1; + synchronized (sLegacyRequests) { + LegacyRequest l = sLegacyRequests.get(netCap); + if (l == null) return; + ourSeqNum = l.expireSequenceNumber; + if (l.expireSequenceNumber == sequenceNum) { + releaseNetworkRequest(l.networkRequest); + sLegacyRequests.remove(netCap); + } + } + Log.d(TAG, "expireRequest with " + ourSeqNum + ", " + sequenceNum); + } + + private NetworkRequest requestNetworkForFeatureLocked(NetworkCapabilities netCap) { + int delay = -1; + int type = networkTypeForNetworkCapabilities(netCap); + try { + delay = mService.getRestoreDefaultNetworkDelay(type); + } catch (RemoteException e) {} + LegacyRequest l = new LegacyRequest(); + l.networkCapabilities = netCap; + l.delay = delay; + l.expireSequenceNumber = 0; + l.networkRequest = sendRequestForNetwork(netCap, l.networkCallbackListener, 0, + REQUEST, true); + if (l.networkRequest == null) return null; + sLegacyRequests.put(netCap, l); + sendExpireMsgForFeature(netCap, l.expireSequenceNumber, delay); + return l.networkRequest; + } + + private void sendExpireMsgForFeature(NetworkCapabilities netCap, int seqNum, int delay) { + if (delay >= 0) { + Log.d(TAG, "sending expire msg with seqNum " + seqNum + " and delay " + delay); + Message msg = sCallbackHandler.obtainMessage(EXPIRE_LEGACY_REQUEST, seqNum, 0, netCap); + sCallbackHandler.sendMessageDelayed(msg, delay); + } + } + + private NetworkRequest removeRequestForFeature(NetworkCapabilities netCap) { + synchronized (sLegacyRequests) { + LegacyRequest l = sLegacyRequests.remove(netCap); + if (l == null) return null; + return l.networkRequest; + } } /** @@ -1782,8 +1964,10 @@ public class ConnectivityManager { public static final int CALLBACK_RELEASED = BASE + 8; /** @hide */ public static final int CALLBACK_EXIT = BASE + 9; + /** @hide obj = NetworkCapabilities, arg1 = seq number */ + private static final int EXPIRE_LEGACY_REQUEST = BASE + 10; - private static class CallbackHandler extends Handler { + private class CallbackHandler extends Handler { private final HashMap<NetworkRequest, NetworkCallbackListener>mCallbackMap; private final AtomicInteger mRefCount; private static final String TAG = "ConnectivityManager.CallbackHandler"; @@ -1903,6 +2087,10 @@ public class ConnectivityManager { getLooper().quit(); break; } + case EXPIRE_LEGACY_REQUEST: { + expireRequest((NetworkCapabilities)message.obj, message.arg1); + break; + } } } @@ -1954,8 +2142,9 @@ public class ConnectivityManager { private final static int LISTEN = 1; private final static int REQUEST = 2; - private NetworkRequest somethingForNetwork(NetworkCapabilities need, - NetworkCallbackListener networkCallbackListener, int timeoutSec, int action) { + private NetworkRequest sendRequestForNetwork(NetworkCapabilities need, + NetworkCallbackListener networkCallbackListener, int timeoutSec, int action, + boolean legacy) { NetworkRequest networkRequest = null; if (networkCallbackListener == null) { throw new IllegalArgumentException("null NetworkCallbackListener"); @@ -1968,7 +2157,7 @@ public class ConnectivityManager { new Binder()); } else { networkRequest = mService.requestNetwork(need, new Messenger(sCallbackHandler), - timeoutSec, new Binder()); + timeoutSec, new Binder(), legacy); } if (networkRequest != null) { synchronized(sNetworkCallbackListener) { @@ -1998,7 +2187,7 @@ public class ConnectivityManager { */ public NetworkRequest requestNetwork(NetworkCapabilities need, NetworkCallbackListener networkCallbackListener) { - return somethingForNetwork(need, networkCallbackListener, 0, REQUEST); + return sendRequestForNetwork(need, networkCallbackListener, 0, REQUEST, false); } /** @@ -2021,7 +2210,7 @@ public class ConnectivityManager { */ public NetworkRequest requestNetwork(NetworkCapabilities need, NetworkCallbackListener networkCallbackListener, int timeoutSec) { - return somethingForNetwork(need, networkCallbackListener, timeoutSec, REQUEST); + return sendRequestForNetwork(need, networkCallbackListener, timeoutSec, REQUEST, false); } /** @@ -2099,7 +2288,7 @@ public class ConnectivityManager { */ public NetworkRequest listenForNetwork(NetworkCapabilities need, NetworkCallbackListener networkCallbackListener) { - return somethingForNetwork(need, networkCallbackListener, 0, LISTEN); + return sendRequestForNetwork(need, networkCallbackListener, 0, LISTEN, false); } /** diff --git a/core/java/android/net/ConnectivityServiceProtocol.java b/core/java/android/net/ConnectivityServiceProtocol.java deleted file mode 100644 index 74096b407b0b..000000000000 --- a/core/java/android/net/ConnectivityServiceProtocol.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (C) 2014 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 static com.android.internal.util.Protocol.BASE_CONNECTIVITY_SERVICE; - -/** - * Describes the Internal protocols used to communicate with ConnectivityService. - * @hide - */ -public class ConnectivityServiceProtocol { - - private static final int BASE = BASE_CONNECTIVITY_SERVICE; - - private ConnectivityServiceProtocol() {} - - /** - * This is a contract between ConnectivityService and various bearers. - * A NetworkFactory is an abstract entity that creates NetworkAgent objects. - * The bearers register with ConnectivityService using - * ConnectivityManager.registerNetworkFactory, where they pass in a Messenger - * to be used to deliver the following Messages. - */ - public static class NetworkFactoryProtocol { - private NetworkFactoryProtocol() {} - /** - * Pass a network request to the bearer. If the bearer believes it can - * satisfy the request it should connect to the network and create a - * NetworkAgent. Once the NetworkAgent is fully functional it will - * register itself with ConnectivityService using registerNetworkAgent. - * If the bearer cannot immediately satisfy the request (no network, - * user disabled the radio, lower-scored network) it should remember - * any NetworkRequests it may be able to satisfy in the future. It may - * disregard any that it will never be able to service, for example - * those requiring a different bearer. - * msg.obj = NetworkRequest - * msg.arg1 = score - the score of the any network currently satisfying this - * request. If this bearer knows in advance it cannot - * exceed this score it should not try to connect, holding the request - * for the future. - * Note that subsequent events may give a different (lower - * or higher) score for this request, transmitted to each - * NetworkFactory through additional CMD_REQUEST_NETWORK msgs - * with the same NetworkRequest but an updated score. - * Also, network conditions may change for this bearer - * allowing for a better score in the future. - */ - public static final int CMD_REQUEST_NETWORK = BASE; - - /** - * Cancel a network request - * msg.obj = NetworkRequest - */ - public static final int CMD_CANCEL_REQUEST = BASE + 1; - } -} diff --git a/core/java/android/net/IConnectivityManager.aidl b/core/java/android/net/IConnectivityManager.aidl index baec36ad48d3..b67ae88c880c 100644 --- a/core/java/android/net/IConnectivityManager.aidl +++ b/core/java/android/net/IConnectivityManager.aidl @@ -158,7 +158,7 @@ interface IConnectivityManager in NetworkCapabilities nc, int score); NetworkRequest requestNetwork(in NetworkCapabilities networkCapabilities, - in Messenger messenger, int timeoutSec, in IBinder binder); + in Messenger messenger, int timeoutSec, in IBinder binder, boolean legacy); NetworkRequest pendingRequestForNetwork(in NetworkCapabilities networkCapabilities, in PendingIntent operation); @@ -170,4 +170,6 @@ interface IConnectivityManager in PendingIntent operation); void releaseNetworkRequest(in NetworkRequest networkRequest); + + int getRestoreDefaultNetworkDelay(int networkType); } diff --git a/core/java/android/net/NetworkAgent.java b/core/java/android/net/NetworkAgent.java index 1c18ba564009..7e8b1f1acafd 100644 --- a/core/java/android/net/NetworkAgent.java +++ b/core/java/android/net/NetworkAgent.java @@ -24,85 +24,39 @@ import android.os.Messenger; import android.os.Parcel; import android.os.Parcelable; import android.util.Log; -import android.util.SparseArray; import com.android.internal.util.AsyncChannel; import com.android.internal.util.Protocol; +import java.util.ArrayList; import java.util.concurrent.atomic.AtomicBoolean; /** - * A Utility class for handling NetworkRequests. - * - * Created by bearer-specific code to handle tracking requests, scores, - * network data and handle communicating with ConnectivityService. Two - * abstract methods: connect and disconnect are used to act on the - * underlying bearer code. Connect is called when we have a NetworkRequest - * and our score is better than the current handling network's score, while - * disconnect is used when ConnectivityService requests a disconnect. + * A Utility class for handling for communicating between bearer-specific + * code and ConnectivityService. * * A bearer may have more than one NetworkAgent if it can simultaneously * support separate networks (IMS / Internet / MMS Apns on cellular, or - * perhaps connections with different SSID or P2P for Wi-Fi). The bearer - * code should pass its NetworkAgents the NetworkRequests each NetworkAgent - * can handle, demultiplexing for different network types. The bearer code - * can also filter out requests it can never handle. + * perhaps connections with different SSID or P2P for Wi-Fi). * - * Each NetworkAgent needs to be given a score and NetworkCapabilities for - * their potential network. While disconnected, the NetworkAgent will check - * each time its score changes or a NetworkRequest changes to see if - * the NetworkAgent can provide a higher scored network for a NetworkRequest - * that the NetworkAgent's NetworkCapabilties can satisfy. This condition will - * trigger a connect request via connect(). After connection, connection data - * should be given to the NetworkAgent by the bearer, including LinkProperties - * NetworkCapabilties and NetworkInfo. After that the NetworkAgent will register - * with ConnectivityService and forward the data on. * @hide */ public abstract class NetworkAgent extends Handler { - private final SparseArray<NetworkRequestAndScore> mNetworkRequests = new SparseArray<>(); - private boolean mConnectionRequested = false; - - private AsyncChannel mAsyncChannel; + private volatile AsyncChannel mAsyncChannel; private final String LOG_TAG; private static final boolean DBG = true; private static final boolean VDBG = true; - // TODO - this class shouldn't cache data or it runs the risk of getting out of sync - // Make the API require each of these when any is updated so we have the data we need, - // without caching. - private LinkProperties mLinkProperties; - private NetworkInfo mNetworkInfo; - private NetworkCapabilities mNetworkCapabilities; - private int mNetworkScore; - private boolean mRegistered = false; private final Context mContext; - private AtomicBoolean mHasRequests = new AtomicBoolean(false); - - // TODO - add a name member for logging purposes. - - protected final Object mLockObj = new Object(); - + private final ArrayList<Message>mPreConnectedQueue = new ArrayList<Message>(); private static final int BASE = Protocol.BASE_NETWORK_AGENT; /** - * Sent by self to queue up a new/modified request. - * obj = NetworkRequestAndScore - */ - private static final int CMD_ADD_REQUEST = BASE + 1; - - /** - * Sent by self to queue up the removal of a request. - * obj = NetworkRequest - */ - private static final int CMD_REMOVE_REQUEST = BASE + 2; - - /** * Sent by ConnectivityService to the NetworkAgent to inform it of * suspected connectivity problems on its network. The NetworkAgent * should take steps to verify and correct connectivity. */ - public static final int CMD_SUSPECT_BAD = BASE + 3; + public static final int CMD_SUSPECT_BAD = BASE; /** * Sent by the NetworkAgent (note the EVENT vs CMD prefix) to @@ -110,84 +64,63 @@ public abstract class NetworkAgent extends Handler { * Sent when the NetworkInfo changes, mainly due to change of state. * obj = NetworkInfo */ - public static final int EVENT_NETWORK_INFO_CHANGED = BASE + 4; + public static final int EVENT_NETWORK_INFO_CHANGED = BASE + 1; /** * Sent by the NetworkAgent to ConnectivityService to pass the current * NetworkCapabilties. * obj = NetworkCapabilities */ - public static final int EVENT_NETWORK_CAPABILITIES_CHANGED = BASE + 5; + public static final int EVENT_NETWORK_CAPABILITIES_CHANGED = BASE + 2; /** * Sent by the NetworkAgent to ConnectivityService to pass the current * NetworkProperties. * obj = NetworkProperties */ - public static final int EVENT_NETWORK_PROPERTIES_CHANGED = BASE + 6; + public static final int EVENT_NETWORK_PROPERTIES_CHANGED = BASE + 3; /** * Sent by the NetworkAgent to ConnectivityService to pass the current * network score. - * arg1 = network score int + * obj = network score Integer */ - public static final int EVENT_NETWORK_SCORE_CHANGED = BASE + 7; + public static final int EVENT_NETWORK_SCORE_CHANGED = BASE + 4; - public NetworkAgent(Looper looper, Context context, String logTag) { + public NetworkAgent(Looper looper, Context context, String logTag, NetworkInfo ni, + NetworkCapabilities nc, LinkProperties lp, int score) { super(looper); LOG_TAG = logTag; mContext = context; - } - - /** - * When conditions are right, register with ConnectivityService. - * Connditions include having a well defined network and a request - * that justifies it. The NetworkAgent will remain registered until - * disconnected. - * TODO - this should have all data passed in rather than caching - */ - private void registerSelf() { - synchronized(mLockObj) { - if (!mRegistered && mConnectionRequested && - mNetworkInfo != null && mNetworkInfo.isConnected() && - mNetworkCapabilities != null && - mLinkProperties != null && - mNetworkScore != 0) { - if (DBG) log("Registering NetworkAgent"); - mRegistered = true; - ConnectivityManager cm = (ConnectivityManager)mContext.getSystemService( - Context.CONNECTIVITY_SERVICE); - cm.registerNetworkAgent(new Messenger(this), new NetworkInfo(mNetworkInfo), - new LinkProperties(mLinkProperties), - new NetworkCapabilities(mNetworkCapabilities), mNetworkScore); - } else if (DBG && !mRegistered) { - String err = "Not registering due to "; - if (mConnectionRequested == false) err += "no Connect requested "; - if (mNetworkInfo == null) err += "null NetworkInfo "; - if (mNetworkInfo != null && mNetworkInfo.isConnected() == false) { - err += "NetworkInfo disconnected "; - } - if (mLinkProperties == null) err += "null LinkProperties "; - if (mNetworkCapabilities == null) err += "null NetworkCapabilities "; - if (mNetworkScore == 0) err += "null NetworkScore"; - log(err); - } + if (ni == null || nc == null || lp == null) { + throw new IllegalArgumentException(); } + + if (DBG) log("Registering NetworkAgent"); + ConnectivityManager cm = (ConnectivityManager)mContext.getSystemService( + Context.CONNECTIVITY_SERVICE); + cm.registerNetworkAgent(new Messenger(this), new NetworkInfo(ni), + new LinkProperties(lp), new NetworkCapabilities(nc), score); } @Override public void handleMessage(Message msg) { switch (msg.what) { case AsyncChannel.CMD_CHANNEL_FULL_CONNECTION: { - synchronized (mLockObj) { - if (mAsyncChannel != null) { - log("Received new connection while already connected!"); - } else { - if (DBG) log("NetworkAgent fully connected"); - mAsyncChannel = new AsyncChannel(); - mAsyncChannel.connected(null, this, msg.replyTo); - mAsyncChannel.replyToMessage(msg, AsyncChannel.CMD_CHANNEL_FULLY_CONNECTED, - AsyncChannel.STATUS_SUCCESSFUL); + if (mAsyncChannel != null) { + log("Received new connection while already connected!"); + } else { + if (DBG) log("NetworkAgent fully connected"); + AsyncChannel ac = new AsyncChannel(); + ac.connected(null, this, msg.replyTo); + ac.replyToMessage(msg, AsyncChannel.CMD_CHANNEL_FULLY_CONNECTED, + AsyncChannel.STATUS_SUCCESSFUL); + synchronized (mPreConnectedQueue) { + mAsyncChannel = ac; + for (Message m : mPreConnectedQueue) { + ac.sendMessage(m); + } + mPreConnectedQueue.clear(); } } break; @@ -199,213 +132,69 @@ public abstract class NetworkAgent extends Handler { } case AsyncChannel.CMD_CHANNEL_DISCONNECTED: { if (DBG) log("NetworkAgent channel lost"); - disconnect(); - clear(); + // let the client know CS is done with us. + unwanted(); + synchronized (mPreConnectedQueue) { + mAsyncChannel = null; + } break; } case CMD_SUSPECT_BAD: { log("Unhandled Message " + msg); break; } - case CMD_ADD_REQUEST: { - handleAddRequest(msg); - break; - } - case CMD_REMOVE_REQUEST: { - handleRemoveRequest(msg); - break; - } - } - } - - private void clear() { - synchronized(mLockObj) { - mNetworkRequests.clear(); - mHasRequests.set(false); - mConnectionRequested = false; - mAsyncChannel = null; - mRegistered = false; - } - } - - private static class NetworkRequestAndScore { - NetworkRequest req; - int score; - - NetworkRequestAndScore(NetworkRequest networkRequest, int score) { - req = networkRequest; - this.score = score; } } - private void handleAddRequest(Message msg) { - NetworkRequestAndScore n = (NetworkRequestAndScore)msg.obj; - // replaces old request, updating score - mNetworkRequests.put(n.req.requestId, n); - mHasRequests.set(true); - evalScores(); - } - - private void handleRemoveRequest(Message msg) { - NetworkRequest networkRequest = (NetworkRequest)msg.obj; - - if (mNetworkRequests.get(networkRequest.requestId) != null) { - mNetworkRequests.remove(networkRequest.requestId); - if (mNetworkRequests.size() == 0) mHasRequests.set(false); - evalScores(); - } - } - - /** - * Called to go through our list of requests and see if we're - * good enough to try connecting, or if we have gotten worse and - * need to disconnect. - * - * Once we are registered, does nothing: we disconnect when requested via - * CMD_CHANNEL_DISCONNECTED, generated by either a loss of connection - * between modules (bearer or ConnectivityService dies) or more commonly - * when the NetworkInfo reports to ConnectivityService it is disconnected. - */ - private void evalScores() { - synchronized(mLockObj) { - if (mRegistered) { - if (VDBG) log("evalScores - already connected - size=" + mNetworkRequests.size()); - // already trying - return; - } - if (VDBG) log("evalScores!"); - for (int i=0; i < mNetworkRequests.size(); i++) { - int score = mNetworkRequests.valueAt(i).score; - if (VDBG) log(" checking request Min " + score + " vs my score " + mNetworkScore); - if (score < mNetworkScore) { - // have a request that has a lower scored network servicing it - // (or no network) than we could provide, so let's connect! - mConnectionRequested = true; - connect(); - return; - } - } - // Our score is not high enough to satisfy any current request. - // This can happen if our score goes down after a connection is - // requested but before we actually connect. In this case, disconnect - // rather than continue trying - there's no point connecting if we know - // we'll just be torn down as soon as we do. - if (mConnectionRequested) { - mConnectionRequested = false; - disconnect(); + private void queueOrSendMessage(int what, Object obj) { + synchronized (mPreConnectedQueue) { + if (mAsyncChannel != null) { + mAsyncChannel.sendMessage(what, obj); + } else { + Message msg = Message.obtain(); + msg.what = what; + msg.obj = obj; + mPreConnectedQueue.add(msg); } } } - public void addNetworkRequest(NetworkRequest networkRequest, int score) { - if (DBG) log("adding NetworkRequest " + networkRequest + " with score " + score); - sendMessage(obtainMessage(CMD_ADD_REQUEST, - new NetworkRequestAndScore(networkRequest, score))); - } - - public void removeNetworkRequest(NetworkRequest networkRequest) { - if (DBG) log("removing NetworkRequest " + networkRequest); - sendMessage(obtainMessage(CMD_REMOVE_REQUEST, networkRequest)); - } - /** * Called by the bearer code when it has new LinkProperties data. - * If we're a registered NetworkAgent, this new data will get forwarded on, - * otherwise we store a copy in anticipation of registering. This call - * may also prompt registration if it causes the NetworkAgent to meet - * the conditions (fully configured, connected, satisfys a request and - * has sufficient score). */ public void sendLinkProperties(LinkProperties linkProperties) { - linkProperties = new LinkProperties(linkProperties); - synchronized(mLockObj) { - mLinkProperties = linkProperties; - if (mAsyncChannel != null) { - mAsyncChannel.sendMessage(EVENT_NETWORK_PROPERTIES_CHANGED, linkProperties); - } else { - registerSelf(); - } - } + queueOrSendMessage(EVENT_NETWORK_PROPERTIES_CHANGED, new LinkProperties(linkProperties)); } /** * Called by the bearer code when it has new NetworkInfo data. - * If we're a registered NetworkAgent, this new data will get forwarded on, - * otherwise we store a copy in anticipation of registering. This call - * may also prompt registration if it causes the NetworkAgent to meet - * the conditions (fully configured, connected, satisfys a request and - * has sufficient score). */ public void sendNetworkInfo(NetworkInfo networkInfo) { - networkInfo = new NetworkInfo(networkInfo); - synchronized(mLockObj) { - mNetworkInfo = networkInfo; - if (mAsyncChannel != null) { - mAsyncChannel.sendMessage(EVENT_NETWORK_INFO_CHANGED, networkInfo); - } else { - registerSelf(); - } - } + queueOrSendMessage(EVENT_NETWORK_INFO_CHANGED, new NetworkInfo(networkInfo)); } /** * Called by the bearer code when it has new NetworkCapabilities data. - * If we're a registered NetworkAgent, this new data will get forwarded on, - * otherwise we store a copy in anticipation of registering. This call - * may also prompt registration if it causes the NetworkAgent to meet - * the conditions (fully configured, connected, satisfys a request and - * has sufficient score). - * Note that if these capabilities make the network non-useful, - * ConnectivityServce will tear this network down. */ public void sendNetworkCapabilities(NetworkCapabilities networkCapabilities) { - networkCapabilities = new NetworkCapabilities(networkCapabilities); - synchronized(mLockObj) { - mNetworkCapabilities = networkCapabilities; - if (mAsyncChannel != null) { - mAsyncChannel.sendMessage(EVENT_NETWORK_CAPABILITIES_CHANGED, networkCapabilities); - } else { - registerSelf(); - } - } - } - - public NetworkCapabilities getNetworkCapabilities() { - synchronized(mLockObj) { - return new NetworkCapabilities(mNetworkCapabilities); - } + queueOrSendMessage(EVENT_NETWORK_CAPABILITIES_CHANGED, + new NetworkCapabilities(networkCapabilities)); } /** * Called by the bearer code when it has a new score for this network. - * If we're a registered NetworkAgent, this new data will get forwarded on, - * otherwise we store a copy. */ - public synchronized void sendNetworkScore(int score) { - synchronized(mLockObj) { - mNetworkScore = score; - evalScores(); - if (mAsyncChannel != null) { - mAsyncChannel.sendMessage(EVENT_NETWORK_SCORE_CHANGED, mNetworkScore); - } else { - registerSelf(); - } - } - } - - public boolean hasRequests() { - return mHasRequests.get(); + public void sendNetworkScore(int score) { + queueOrSendMessage(EVENT_NETWORK_SCORE_CHANGED, new Integer(score)); } - public boolean isConnectionRequested() { - synchronized(mLockObj) { - return mConnectionRequested; - } - } - - - abstract protected void connect(); - abstract protected void disconnect(); + /** + * Called when ConnectivityService has indicated they no longer want this network. + * The parent factory should (previously) have received indication of the change + * as well, either canceling NetworkRequests or altering their score such that this + * network won't be immediately requested again. + */ + abstract protected void unwanted(); protected void log(String s) { Log.d(LOG_TAG, "NetworkAgent: " + s); diff --git a/core/java/android/net/NetworkFactory.java b/core/java/android/net/NetworkFactory.java new file mode 100644 index 000000000000..a20e8e76eaf1 --- /dev/null +++ b/core/java/android/net/NetworkFactory.java @@ -0,0 +1,275 @@ +/* + * Copyright (C) 2014 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.content.Context; +import android.os.Handler; +import android.os.Looper; +import android.os.Message; +import android.os.Messenger; +import android.os.Parcel; +import android.os.Parcelable; +import android.util.Log; +import android.util.SparseArray; + +import com.android.internal.util.AsyncChannel; +import com.android.internal.util.Protocol; + +/** + * A NetworkFactory is an entity that creates NetworkAgent objects. + * The bearers register with ConnectivityService using {@link #register} and + * their factory will start receiving scored NetworkRequests. NetworkRequests + * can be filtered 3 ways: by NetworkCapabilities, by score and more complexly by + * overridden function. All of these can be dynamic - changing NetworkCapabilities + * or score forces re-evaluation of all current requests. + * + * If any requests pass the filter some overrideable functions will be called. + * If the bearer only cares about very simple start/stopNetwork callbacks, those + * functions can be overridden. If the bearer needs more interaction, it can + * override addNetworkRequest and removeNetworkRequest which will give it each + * request that passes their current filters. + * @hide + **/ +public class NetworkFactory extends Handler { + private static final boolean DBG = true; + + private static final int BASE = Protocol.BASE_NETWORK_FACTORY; + /** + * Pass a network request to the bearer. If the bearer believes it can + * satisfy the request it should connect to the network and create a + * NetworkAgent. Once the NetworkAgent is fully functional it will + * register itself with ConnectivityService using registerNetworkAgent. + * If the bearer cannot immediately satisfy the request (no network, + * user disabled the radio, lower-scored network) it should remember + * any NetworkRequests it may be able to satisfy in the future. It may + * disregard any that it will never be able to service, for example + * those requiring a different bearer. + * msg.obj = NetworkRequest + * msg.arg1 = score - the score of the any network currently satisfying this + * request. If this bearer knows in advance it cannot + * exceed this score it should not try to connect, holding the request + * for the future. + * Note that subsequent events may give a different (lower + * or higher) score for this request, transmitted to each + * NetworkFactory through additional CMD_REQUEST_NETWORK msgs + * with the same NetworkRequest but an updated score. + * Also, network conditions may change for this bearer + * allowing for a better score in the future. + */ + public static final int CMD_REQUEST_NETWORK = BASE; + + /** + * Cancel a network request + * msg.obj = NetworkRequest + */ + public static final int CMD_CANCEL_REQUEST = BASE + 1; + + /** + * Internally used to set our best-guess score. + * msg.arg1 = new score + */ + private static final int CMD_SET_SCORE = BASE + 2; + + /** + * Internally used to set our current filter for coarse bandwidth changes with + * technology changes. + * msg.obj = new filter + */ + private static final int CMD_SET_FILTER = BASE + 3; + + private final Context mContext; + private final String LOG_TAG; + + private final SparseArray<NetworkRequestInfo> mNetworkRequests = + new SparseArray<NetworkRequestInfo>(); + + private int mScore; + private NetworkCapabilities mCapabilityFilter; + + private int mRefCount = 0; + private Messenger mMessenger = null; + + public NetworkFactory(Looper looper, Context context, String logTag, + NetworkCapabilities filter) { + super(looper); + LOG_TAG = logTag; + mContext = context; + mCapabilityFilter = filter; + } + + public void register() { + if (DBG) log("Registering NetworkFactory"); + if (mMessenger == null) { + mMessenger = new Messenger(this); + ConnectivityManager.from(mContext).registerNetworkFactory(mMessenger, LOG_TAG); + } + } + + public void unregister() { + if (DBG) log("Unregistering NetworkFactory"); + if (mMessenger != null) { + ConnectivityManager.from(mContext).unregisterNetworkFactory(mMessenger); + mMessenger = null; + } + } + + @Override + public void handleMessage(Message msg) { + switch (msg.what) { + case CMD_REQUEST_NETWORK: { + handleAddRequest((NetworkRequest)msg.obj, msg.arg1); + break; + } + case CMD_CANCEL_REQUEST: { + handleRemoveRequest((NetworkRequest) msg.obj); + break; + } + case CMD_SET_SCORE: { + handleSetScore(msg.arg1); + break; + } + case CMD_SET_FILTER: { + handleSetFilter((NetworkCapabilities) msg.obj); + break; + } + } + } + + private class NetworkRequestInfo { + public final NetworkRequest request; + public int score; + public boolean requested; // do we have a request outstanding, limited by score + + public NetworkRequestInfo(NetworkRequest request, int score) { + this.request = request; + this.score = score; + this.requested = false; + } + } + + private void handleAddRequest(NetworkRequest request, int score) { + NetworkRequestInfo n = mNetworkRequests.get(request.requestId); + if (n == null) { + n = new NetworkRequestInfo(request, score); + mNetworkRequests.put(n.request.requestId, n); + } else { + n.score = score; + } + if (DBG) log("got request " + request + " with score " + score); + if (DBG) log(" my score=" + mScore + ", my filter=" + mCapabilityFilter); + + evalRequest(n); + } + + private void handleRemoveRequest(NetworkRequest request) { + NetworkRequestInfo n = mNetworkRequests.get(request.requestId); + if (n != null && n.requested) { + mNetworkRequests.remove(request.requestId); + releaseNetworkFor(n.request); + } + } + + private void handleSetScore(int score) { + mScore = score; + evalRequests(); + } + + private void handleSetFilter(NetworkCapabilities netCap) { + mCapabilityFilter = netCap; + evalRequests(); + } + + /** + * Overridable function to provide complex filtering. + * Called for every request every time a new NetworkRequest is seen + * and whenever the filterScore or filterNetworkCapabilities change. + * + * acceptRequest can be overriden to provide complex filter behavior + * for the incoming requests + * + * For output, this class will call {@link #needNetworkFor} and + * {@link #releaseNetworkFor} for every request that passes the filters. + * If you don't need to see every request, you can leave the base + * implementations of those two functions and instead override + * {@link #startNetwork} and {@link #stopNetwork}. + * + * If you want to see every score fluctuation on every request, set + * your score filter to a very high number and watch {@link #needNetworkFor}. + * + * @return {@code true} to accept the request. + */ + public boolean acceptRequest(NetworkRequest request, int score) { + return true; + } + + private void evalRequest(NetworkRequestInfo n) { + if (n.requested == false && n.score < mScore && + n.request.networkCapabilities.satisfiedByNetworkCapabilities( + mCapabilityFilter) && acceptRequest(n.request, n.score)) { + needNetworkFor(n.request, n.score); + n.requested = true; + } else if (n.requested == true && + (n.score > mScore || n.request.networkCapabilities.satisfiedByNetworkCapabilities( + mCapabilityFilter) == false || acceptRequest(n.request, n.score) == false)) { + releaseNetworkFor(n.request); + n.requested = false; + } + } + + private void evalRequests() { + for (int i = 0; i < mNetworkRequests.size(); i++) { + NetworkRequestInfo n = mNetworkRequests.valueAt(i); + + evalRequest(n); + } + } + + // override to do simple mode (request independent) + protected void startNetwork() { } + protected void stopNetwork() { } + + // override to do fancier stuff + protected void needNetworkFor(NetworkRequest networkRequest, int score) { + if (++mRefCount == 1) startNetwork(); + } + + protected void releaseNetworkFor(NetworkRequest networkRequest) { + if (--mRefCount == 0) stopNetwork(); + } + + + public void addNetworkRequest(NetworkRequest networkRequest, int score) { + sendMessage(obtainMessage(CMD_REQUEST_NETWORK, + new NetworkRequestInfo(networkRequest, score))); + } + + public void removeNetworkRequest(NetworkRequest networkRequest) { + sendMessage(obtainMessage(CMD_CANCEL_REQUEST, networkRequest)); + } + + public void setScoreFilter(int score) { + sendMessage(obtainMessage(CMD_SET_SCORE, score, 0)); + } + + public void setCapabilityFilter(NetworkCapabilities netCap) { + sendMessage(obtainMessage(CMD_SET_FILTER, new NetworkCapabilities(netCap))); + } + + protected void log(String s) { + Log.d(LOG_TAG, s); + } +} diff --git a/core/java/android/net/NetworkInfo.java b/core/java/android/net/NetworkInfo.java index 9e656eecbe4c..ccc56e23af75 100644 --- a/core/java/android/net/NetworkInfo.java +++ b/core/java/android/net/NetworkInfo.java @@ -198,7 +198,10 @@ public class NetworkInfo implements Parcelable { } } - void setSubtype(int subtype, String subtypeName) { + /** + * @hide + */ + public void setSubtype(int subtype, String subtypeName) { synchronized (this) { mSubtype = subtype; mSubtypeName = subtypeName; diff --git a/core/java/com/android/internal/util/Protocol.java b/core/java/com/android/internal/util/Protocol.java index 81e67d86d626..af966b194e56 100644 --- a/core/java/com/android/internal/util/Protocol.java +++ b/core/java/com/android/internal/util/Protocol.java @@ -57,9 +57,9 @@ public class Protocol { public static final int BASE_DNS_PINGER = 0x00050000; public static final int BASE_NSD_MANAGER = 0x00060000; public static final int BASE_NETWORK_STATE_TRACKER = 0x00070000; - public static final int BASE_CONNECTIVITY_SERVICE = 0x00080000; + public static final int BASE_CONNECTIVITY_MANAGER = 0x00080000; public static final int BASE_NETWORK_AGENT = 0x00081000; public static final int BASE_NETWORK_MONITOR = 0x00082000; - public static final int BASE_CONNECTIVITY_MANAGER = 0x00083000; + public static final int BASE_NETWORK_FACTORY = 0x00083000; //TODO: define all used protocols } diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml index 6d0b325bc2e3..55f52da4f9f2 100644 --- a/core/res/AndroidManifest.xml +++ b/core/res/AndroidManifest.xml @@ -1006,14 +1006,6 @@ android:permissionGroup="android.permission-group.SYSTEM_TOOLS" android:protectionLevel="signature" /> - <!-- Allows an application to communicate with a SIM card using logical - channels. --> - <permission android:name="android.permission.SIM_COMMUNICATION" - android:permissionGroup="android.permission-group.SYSTEM_TOOLS" - android:label="@string/permlab_sim_communication" - android:description="@string/permdesc_sim_communication" - android:protectionLevel="dangerous" /> - <!-- Allows TvInputService to access underlying TV input hardware such as built-in tuners and HDMI-in's. @hide This should only be used by OEM's TvInputService's. diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml index f6732d3d84ea..8af45db43124 100644 --- a/core/res/res/values/config.xml +++ b/core/res/res/values/config.xml @@ -858,6 +858,14 @@ <!-- Boolean indicating if current platform supports BLE peripheral mode --> <bool name="config_bluetooth_le_peripheral_mode_supported">false</bool> + <!-- Max number of scan filters supported by blutooth controller. 0 if the + device does not support hardware scan filters--> + <integer translatable="false" name="config_bluetooth_max_scan_filters">0</integer> + + <!-- Max number of advertisers supported by bluetooth controller. 0 if the + device does not support multiple advertisement--> + <integer translatable="false" name="config_bluetooth_max_advertisers">0</integer> + <!-- The default data-use polling period. --> <integer name="config_datause_polling_period_sec">600</integer> diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml index 7234911bf655..5d6987cea5cf 100644 --- a/core/res/res/values/strings.xml +++ b/core/res/res/values/strings.xml @@ -1583,11 +1583,6 @@ without your confirmation.</string> <!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. --> - <string name="permlab_sim_communication">sim communication</string> - <!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. --> - <string name="permdesc_sim_communication">Allows the app to send commands to the SIM. This is very dangerous.</string> - - <!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. --> <string name="permlab_camera">take pictures and videos</string> <!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. --> <string name="permdesc_camera">Allows the app to take pictures and videos diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index 8b1ca31eccfc..9e6588f1cd28 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -287,6 +287,8 @@ <java-symbol type="bool" name="config_disableUsbPermissionDialogs"/> <java-symbol type="bool" name="config_windowIsRound" /> + <java-symbol type="integer" name="config_bluetooth_max_advertisers" /> + <java-symbol type="integer" name="config_bluetooth_max_scan_filters" /> <java-symbol type="integer" name="config_cursorWindowSize" /> <java-symbol type="integer" name="config_extraFreeKbytesAdjust" /> <java-symbol type="integer" name="config_extraFreeKbytesAbsolute" /> diff --git a/media/java/android/media/tv/ITvInputClient.aidl b/media/java/android/media/tv/ITvInputClient.aidl index dc79a737403a..011da35082fe 100644 --- a/media/java/android/media/tv/ITvInputClient.aidl +++ b/media/java/android/media/tv/ITvInputClient.aidl @@ -31,5 +31,7 @@ oneway interface ITvInputClient { void onAvailabilityChanged(in String inputId, boolean isAvailable); void onSessionReleased(int seq); void onSessionEvent(in String name, in Bundle args, int seq); - void onVideoSizeChanged(int width, int height, int seq); + void onVideoStreamChanged(int width, int height, boolean interlaced, int seq); + void onAudioStreamChanged(int channelCount, int seq); + void onClosedCaptionStreamChanged(boolean hasClosedCaption, int seq); } diff --git a/media/java/android/media/tv/ITvInputSessionCallback.aidl b/media/java/android/media/tv/ITvInputSessionCallback.aidl index 71f2d07b4ad9..00f2922ad38a 100644 --- a/media/java/android/media/tv/ITvInputSessionCallback.aidl +++ b/media/java/android/media/tv/ITvInputSessionCallback.aidl @@ -27,5 +27,7 @@ import android.os.Bundle; oneway interface ITvInputSessionCallback { void onSessionCreated(ITvInputSession session); void onSessionEvent(in String name, in Bundle args); - void onVideoSizeChanged(int width, int height); + void onVideoStreamChanged(int width, int height, boolean interlaced); + void onAudioStreamChanged(int channelCount); + void onClosedCaptionStreamChanged(boolean hasClosedCaption); } diff --git a/media/java/android/media/tv/TvInputManager.java b/media/java/android/media/tv/TvInputManager.java index 1335a1bccf29..698a861fc721 100644 --- a/media/java/android/media/tv/TvInputManager.java +++ b/media/java/android/media/tv/TvInputManager.java @@ -88,15 +88,39 @@ public final class TvInputManager { } /** - * This is called at the beginning of the playback of a channel and later when the size of - * the video has been changed. + * This is called at the beginning of the playback of a channel and later when the format of + * the video stream has been changed. * * @param session A {@link TvInputManager.Session} associated with this callback - * @param width the width of the video - * @param height the height of the video + * @param width The width of the video. + * @param height The height of the video. + * @param interlaced whether the video is interlaced mode or planer mode. * @hide */ - public void onVideoSizeChanged(Session session, int width, int height) { + public void onVideoStreamChanged(Session session, int width, int height, + boolean interlaced) { + } + + /** + * This is called at the beginning of the playback of a channel and later when the format of + * the audio stream has been changed. + * + * @param session A {@link TvInputManager.Session} associated with this callback + * @param channelCount The number of channels in the audio stream. + * @hide + */ + public void onAudioStreamChanged(Session session, int channelCount) { + } + + /** + * This is called at the beginning of the playback of a channel and later when the closed + * caption stream has been changed. + * + * @param session A {@link TvInputManager.Session} associated with this callback + * @param hasClosedCaption Whether the stream has closed caption or not. + * @hide + */ + public void onClosedCaptionStreamChanged(Session session, boolean hasClosedCaption) { } /** @@ -141,11 +165,30 @@ public final class TvInputManager { }); } - public void postVideoSizeChanged(final int width, final int height) { + public void postVideoStreamChanged(final int width, final int height, + final boolean interlaced) { + mHandler.post(new Runnable() { + @Override + public void run() { + mSessionCallback.onVideoStreamChanged(mSession, width, height, interlaced); + } + }); + } + + public void postAudioStreamChanged(final int channelCount) { + mHandler.post(new Runnable() { + @Override + public void run() { + mSessionCallback.onAudioStreamChanged(mSession, channelCount); + } + }); + } + + public void postClosedCaptionStreamChanged(final boolean hasClosedCaption) { mHandler.post(new Runnable() { @Override public void run() { - mSessionCallback.onVideoSizeChanged(mSession, width, height); + mSessionCallback.onClosedCaptionStreamChanged(mSession, hasClosedCaption); } }); } @@ -238,14 +281,38 @@ public final class TvInputManager { } @Override - public void onVideoSizeChanged(int width, int height, int seq) { + public void onVideoStreamChanged(int width, int height, boolean interlaced, int seq) { + synchronized (mSessionCallbackRecordMap) { + SessionCallbackRecord record = mSessionCallbackRecordMap.get(seq); + if (record == null) { + Log.e(TAG, "Callback not found for seq " + seq); + return; + } + record.postVideoStreamChanged(width, height, interlaced); + } + } + + @Override + public void onAudioStreamChanged(int channelCount, int seq) { + synchronized (mSessionCallbackRecordMap) { + SessionCallbackRecord record = mSessionCallbackRecordMap.get(seq); + if (record == null) { + Log.e(TAG, "Callback not found for seq " + seq); + return; + } + record.postAudioStreamChanged(channelCount); + } + } + + @Override + public void onClosedCaptionStreamChanged(boolean hasClosedCaption, int seq) { synchronized (mSessionCallbackRecordMap) { SessionCallbackRecord record = mSessionCallbackRecordMap.get(seq); if (record == null) { Log.e(TAG, "Callback not found for seq " + seq); return; } - record.postVideoSizeChanged(width, height); + record.postClosedCaptionStreamChanged(hasClosedCaption); } } diff --git a/media/java/android/media/tv/TvInputService.java b/media/java/android/media/tv/TvInputService.java index 321301944873..8ba0e2078a78 100644 --- a/media/java/android/media/tv/TvInputService.java +++ b/media/java/android/media/tv/TvInputService.java @@ -223,20 +223,22 @@ public abstract class TvInputService extends Service { } /** - * Sends the change on the size of the video. This is expected to be called at the - * beginning of the playback and later when the size has been changed. + * Sends the change on the format of the video stream. This is expected to be called at the + * beginning of the playback and later when the format has been changed. * * @param width The width of the video. * @param height The height of the video. + * @param interlaced Whether the video is interlaced mode or planer mode. * @hide */ - public void dispatchVideoSizeChanged(final int width, final int height) { + public void dispatchVideoStreamChanged(final int width, final int height, + final boolean interlaced) { mHandler.post(new Runnable() { @Override public void run() { try { if (DEBUG) Log.d(TAG, "dispatchVideoSizeChanged"); - mSessionCallback.onVideoSizeChanged(width, height); + mSessionCallback.onVideoStreamChanged(width, height, interlaced); } catch (RemoteException e) { Log.w(TAG, "error in dispatchVideoSizeChanged"); } @@ -245,6 +247,48 @@ public abstract class TvInputService extends Service { } /** + * Sends the change on the format of the audio stream. This is expected to be called at the + * beginning of the playback and later when the format has been changed. + * + * @param channelNumber The number of channels in the audio stream. + * @hide + */ + public void dispatchAudioStreamChanged(final int channelNumber) { + mHandler.post(new Runnable() { + @Override + public void run() { + try { + if (DEBUG) Log.d(TAG, "dispatchAudioStreamChanged"); + mSessionCallback.onAudioStreamChanged(channelNumber); + } catch (RemoteException e) { + Log.w(TAG, "error in dispatchAudioStreamChanged"); + } + } + }); + } + + /** + * Sends the change on the closed caption stream. This is expected to be called at the + * beginning of the playback and later when the stream has been changed. + * + * @param hasClosedCaption Whether the stream has closed caption or not. + * @hide + */ + public void dispatchClosedCaptionStreamChanged(final boolean hasClosedCaption) { + mHandler.post(new Runnable() { + @Override + public void run() { + try { + if (DEBUG) Log.d(TAG, "dispatchClosedCaptionStreamChanged"); + mSessionCallback.onClosedCaptionStreamChanged(hasClosedCaption); + } catch (RemoteException e) { + Log.w(TAG, "error in dispatchClosedCaptionStreamChanged"); + } + } + }); + } + + /** * Called when the session is released. */ public abstract void onRelease(); diff --git a/media/java/android/media/tv/TvView.java b/media/java/android/media/tv/TvView.java index 126d73988de9..d8b362d41328 100644 --- a/media/java/android/media/tv/TvView.java +++ b/media/java/android/media/tv/TvView.java @@ -382,12 +382,33 @@ public class TvView extends SurfaceView { } @Override - public void onVideoSizeChanged(Session session, int width, int height) { + public void onVideoStreamChanged(Session session, int width, int height, + boolean interlaced) { if (DEBUG) { Log.d(TAG, "onVideoSizeChanged(" + width + ", " + height + ")"); } if (mExternalCallback != null) { - mExternalCallback.onVideoSizeChanged(session, width, height); + mExternalCallback.onVideoStreamChanged(session, width, height, interlaced); + } + } + + @Override + public void onAudioStreamChanged(Session session, int channelCount) { + if (DEBUG) { + Log.d(TAG, "onAudioStreamChanged(" + channelCount + ")"); + } + if (mExternalCallback != null) { + mExternalCallback.onAudioStreamChanged(session, channelCount); + } + } + + @Override + public void onClosedCaptionStreamChanged(Session session, boolean hasClosedCaption) { + if (DEBUG) { + Log.d(TAG, "onClosedCaptionStreamChanged(" + hasClosedCaption + ")"); + } + if (mExternalCallback != null) { + mExternalCallback.onClosedCaptionStreamChanged(session, hasClosedCaption); } } diff --git a/services/core/java/com/android/server/ConnectivityService.java b/services/core/java/com/android/server/ConnectivityService.java index d7a19add8f73..22ecd33c4e5a 100644 --- a/services/core/java/com/android/server/ConnectivityService.java +++ b/services/core/java/com/android/server/ConnectivityService.java @@ -38,7 +38,6 @@ import static android.net.ConnectivityManager.TYPE_WIMAX; import static android.net.ConnectivityManager.TYPE_PROXY; import static android.net.ConnectivityManager.getNetworkTypeName; import static android.net.ConnectivityManager.isNetworkTypeValid; -import static android.net.ConnectivityServiceProtocol.NetworkFactoryProtocol; import static android.net.NetworkPolicyManager.RULE_ALLOW_ALL; import static android.net.NetworkPolicyManager.RULE_REJECT_METERED; @@ -80,6 +79,7 @@ import android.net.NetworkCapabilities; import android.net.NetworkConfig; import android.net.NetworkInfo; import android.net.NetworkInfo.DetailedState; +import android.net.NetworkFactory; import android.net.NetworkQuotaInfo; import android.net.NetworkRequest; import android.net.NetworkState; @@ -2843,7 +2843,8 @@ public class ConnectivityService extends IConnectivityManager.Stub { } } - private int getRestoreDefaultNetworkDelay(int networkType) { + @Override + public int getRestoreDefaultNetworkDelay(int networkType) { String restoreDefaultNetworkDelayStr = SystemProperties.get( NETWORK_RESTORE_DELAY_PROP_NAME); if(restoreDefaultNetworkDelayStr != null && @@ -2994,6 +2995,16 @@ public class ConnectivityService extends IConnectivityManager.Stub { updateNetworkInfo(nai, info); break; } + case NetworkAgent.EVENT_NETWORK_SCORE_CHANGED: { + NetworkAgentInfo nai = mNetworkAgentInfos.get(msg.replyTo); + if (nai == null) { + loge("EVENT_NETWORK_SCORE_CHANGED from unknown NetworkAgent"); + break; + } + Integer score = (Integer) msg.obj; + updateNetworkScore(nai, score); + break; + } case NetworkMonitor.EVENT_NETWORK_VALIDATED: { NetworkAgentInfo nai = (NetworkAgentInfo)msg.obj; handleConnectionValidated(nai); @@ -3098,7 +3109,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { for (NetworkRequestInfo nri : mNetworkRequests.values()) { if (nri.isRequest == false) continue; NetworkAgentInfo nai = mNetworkForRequestId.get(nri.request.requestId); - ac.sendMessage(NetworkFactoryProtocol.CMD_REQUEST_NETWORK, + ac.sendMessage(android.net.NetworkFactory.CMD_REQUEST_NETWORK, (nai != null ? nai.currentScore : 0), 0, nri.request); } } else { @@ -3137,6 +3148,14 @@ public class ConnectivityService extends IConnectivityManager.Stub { } catch (Exception e) { loge("Exception removing network: " + e); } + // TODO - if we move the logic to the network agent (have them disconnect + // because they lost all their requests or because their score isn't good) + // then they would disconnect organically, report their new state and then + // disconnect the channel. + if (nai.networkInfo.isConnected()) { + nai.networkInfo.setDetailedState(NetworkInfo.DetailedState.DISCONNECTED, + null, null); + } notifyNetworkCallbacks(nai, ConnectivityManager.CALLBACK_LOST); nai.networkMonitor.sendMessage(NetworkMonitor.CMD_NETWORK_DISCONNECTED); mNetworkAgentInfos.remove(msg.replyTo); @@ -3203,7 +3222,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { } if (bestNetwork != null) { if (VDBG) log("using " + bestNetwork.name()); - bestNetwork.networkRequests.put(nri.request.requestId, nri.request); + bestNetwork.addRequest(nri.request); notifyNetworkCallback(bestNetwork, nri); score = bestNetwork.currentScore; } @@ -3211,7 +3230,8 @@ public class ConnectivityService extends IConnectivityManager.Stub { if (msg.what == EVENT_REGISTER_NETWORK_REQUEST) { if (DBG) log("sending new NetworkRequest to factories"); for (NetworkFactoryInfo nfi : mNetworkFactoryInfos.values()) { - nfi.asyncChannel.sendMessage(NetworkFactoryProtocol.CMD_REQUEST_NETWORK, score, 0, nri.request); + nfi.asyncChannel.sendMessage(android.net.NetworkFactory.CMD_REQUEST_NETWORK, score, + 0, nri.request); } } } @@ -3233,7 +3253,8 @@ public class ConnectivityService extends IConnectivityManager.Stub { if (nri.isRequest) { for (NetworkFactoryInfo nfi : mNetworkFactoryInfos.values()) { - nfi.asyncChannel.sendMessage(NetworkFactoryProtocol.CMD_CANCEL_REQUEST, nri.request); + nfi.asyncChannel.sendMessage(android.net.NetworkFactory.CMD_CANCEL_REQUEST, + nri.request); } if (affectedNetwork != null) { @@ -5279,7 +5300,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { @Override public NetworkRequest requestNetwork(NetworkCapabilities networkCapabilities, - Messenger messenger, int timeoutSec, IBinder binder) { + Messenger messenger, int timeoutSec, IBinder binder, boolean legacy) { if (networkCapabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_NOT_RESTRICTED) == false) { enforceConnectivityInternalPermission(); @@ -5291,7 +5312,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { throw new IllegalArgumentException("Bad timeout specified"); } NetworkRequest networkRequest = new NetworkRequest(new NetworkCapabilities( - networkCapabilities), false, nextNetworkRequestId()); + networkCapabilities), legacy, nextNetworkRequestId()); if (DBG) log("requestNetwork for " + networkRequest); NetworkRequestInfo nri = new NetworkRequestInfo(messenger, networkRequest, binder, NetworkRequestInfo.REQUEST); @@ -5392,7 +5413,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { NetworkAgentInfo nai = new NetworkAgentInfo(messenger, new AsyncChannel(), nextNetId(), new NetworkInfo(networkInfo), new LinkProperties(linkProperties), new NetworkCapabilities(networkCapabilities), currentScore, mContext, mTrackerHandler); - + if (VDBG) log("registerNetworkAgent " + nai); mHandler.sendMessage(mHandler.obtainMessage(EVENT_REGISTER_NETWORK_AGENT, nai)); } @@ -5439,7 +5460,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { mClat.stopClat(); } // If the link requires clat to be running, then start the daemon now. - if (newLp != null && na.networkInfo.isConnected()) { + if (na.networkInfo.isConnected()) { mClat.startClat(na); } else { mClat.stopClat(); @@ -5555,7 +5576,8 @@ public class ConnectivityService extends IConnectivityManager.Stub { private void sendUpdatedScoreToFactories(NetworkRequest networkRequest, int score) { if (VDBG) log("sending new Min Network Score(" + score + "): " + networkRequest.toString()); for (NetworkFactoryInfo nfi : mNetworkFactoryInfos.values()) { - nfi.asyncChannel.sendMessage(NetworkFactoryProtocol.CMD_REQUEST_NETWORK, score, 0, networkRequest); + nfi.asyncChannel.sendMessage(android.net.NetworkFactory.CMD_REQUEST_NETWORK, score, 0, + networkRequest); } } @@ -5658,7 +5680,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { if (VDBG) log(" accepting network in place of null"); } mNetworkForRequestId.put(nri.request.requestId, newNetwork); - newNetwork.networkRequests.put(nri.request.requestId, nri.request); + newNetwork.addRequest(nri.request); keep = true; // TODO - this could get expensive if we have alot of requests for this // network. Think about if there is a way to reduce this. Push @@ -5792,6 +5814,11 @@ public class ConnectivityService extends IConnectivityManager.Stub { } } + private void updateNetworkScore(NetworkAgentInfo nai, Integer scoreInteger) { + int score = scoreInteger.intValue(); + // TODO + } + // notify only this one new request of the current state protected void notifyNetworkCallback(NetworkAgentInfo nai, NetworkRequestInfo nri) { int notifyType = ConnectivityManager.CALLBACK_AVAILABLE; @@ -5810,15 +5837,13 @@ public class ConnectivityService extends IConnectivityManager.Stub { protected void notifyNetworkCallbacks(NetworkAgentInfo networkAgent, int notifyType) { if (VDBG) log("notifyType " + notifyType + " for " + networkAgent.name()); - boolean needsBroadcasts = false; for (int i = 0; i < networkAgent.networkRequests.size(); i++) { NetworkRequest nr = networkAgent.networkRequests.valueAt(i); NetworkRequestInfo nri = mNetworkRequests.get(nr); if (VDBG) log(" sending notification for " + nr); - if (nr.needsBroadcasts) needsBroadcasts = true; callCallbackForRequest(nri, networkAgent, notifyType); } - if (needsBroadcasts) { + if (networkAgent.needsBroadcasts) { if (notifyType == ConnectivityManager.CALLBACK_AVAILABLE) { sendConnectedBroadcastDelayed(networkAgent.networkInfo, getConnectivityChangeDelay()); diff --git a/services/core/java/com/android/server/connectivity/NetworkAgentInfo.java b/services/core/java/com/android/server/connectivity/NetworkAgentInfo.java index 8102591ea932..e9f968377f9f 100644 --- a/services/core/java/com/android/server/connectivity/NetworkAgentInfo.java +++ b/services/core/java/com/android/server/connectivity/NetworkAgentInfo.java @@ -45,6 +45,17 @@ public class NetworkAgentInfo { public int currentScore; public final NetworkMonitor networkMonitor; + /** + * Indicates we need to send CONNECTIVITY_ACTION broadcasts for this network. + * For example the built-in default network request and any requsts coming from + * the deprecated startUsingNetworkFeature API will have this set. Networks + * responding to the new requestNetwork API will rely on point to point callbacks. + * + * Gets set if any legacy requests get affiliated with this network and + * stays set for life so we send disconnected bcasts to match the connected, + * even if the legacy request has moved on. + */ + public boolean needsBroadcasts = false; // The list of NetworkRequests being satisfied by this Network. public final SparseArray<NetworkRequest> networkRequests = new SparseArray<NetworkRequest>(); @@ -66,6 +77,12 @@ public class NetworkAgentInfo { networkMonitor = new NetworkMonitor(context, handler, this); } + public void addRequest(NetworkRequest networkRequest) { + if (networkRequest.needsBroadcasts) needsBroadcasts = true; + + networkRequests.put(networkRequest.requestId, networkRequest); + } + public String toString() { return "NetworkAgentInfo{ ni{" + networkInfo + "} network{" + network + "} lp{" + diff --git a/services/core/java/com/android/server/tv/TvInputManagerService.java b/services/core/java/com/android/server/tv/TvInputManagerService.java index 5eb3305a11c1..1c277a8dd961 100644 --- a/services/core/java/com/android/server/tv/TvInputManagerService.java +++ b/services/core/java/com/android/server/tv/TvInputManagerService.java @@ -372,18 +372,54 @@ public final class TvInputManagerService extends SystemService { } @Override - public void onVideoSizeChanged(int width, int height) throws RemoteException { + public void onVideoStreamChanged(int width, int height, boolean interlaced) { synchronized (mLock) { if (DEBUG) { - Slog.d(TAG, "onVideoSizeChanged(" + width + ", " + height + ")"); + Slog.d(TAG, "onVideoStreamChanged(" + width + ", " + height + ")"); } if (sessionState.mSession == null || sessionState.mClient == null) { return; } try { - sessionState.mClient.onVideoSizeChanged(width, height, sessionState.mSeq); + sessionState.mClient.onVideoStreamChanged(width, height, interlaced, + sessionState.mSeq); } catch (RemoteException e) { - Slog.e(TAG, "error in onSessionEvent"); + Slog.e(TAG, "error in onVideoStreamChanged"); + } + } + } + + @Override + public void onAudioStreamChanged(int channelCount) { + synchronized (mLock) { + if (DEBUG) { + Slog.d(TAG, "onAudioStreamChanged(" + channelCount + ")"); + } + if (sessionState.mSession == null || sessionState.mClient == null) { + return; + } + try { + sessionState.mClient.onAudioStreamChanged(channelCount, sessionState.mSeq); + } catch (RemoteException e) { + Slog.e(TAG, "error in onAudioStreamChanged"); + } + } + } + + @Override + public void onClosedCaptionStreamChanged(boolean hasClosedCaption) { + synchronized (mLock) { + if (DEBUG) { + Slog.d(TAG, "onClosedCaptionStreamChanged(" + hasClosedCaption + ")"); + } + if (sessionState.mSession == null || sessionState.mClient == null) { + return; + } + try { + sessionState.mClient.onClosedCaptionStreamChanged(hasClosedCaption, + sessionState.mSeq); + } catch (RemoteException e) { + Slog.e(TAG, "error in onClosedCaptionStreamChanged"); } } } diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index 525441d72a0f..68bf6281fe18 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -1743,216 +1743,6 @@ public class TelephonyManager { } /** - * Opens a logical channel to the ICC card. - * - * Input parameters equivalent to TS 27.007 AT+CCHO command. - * - * <p>Requires Permission: - * {@link android.Manifest.permission#SIM_COMMUNICATION SIM_COMMUNICATION} - * - * @param AID Application id. See ETSI 102.221 and 101.220. - * @return The logical channel id which is negative on error. - */ - public int iccOpenLogicalChannel(String AID) { - try { - return getITelephony().iccOpenLogicalChannel(AID); - } catch (RemoteException ex) { - } catch (NullPointerException ex) { - } - return -1; - } - - /** - * Closes a previously opened logical channel to the ICC card. - * - * Input parameters equivalent to TS 27.007 AT+CCHC command. - * - * <p>Requires Permission: - * {@link android.Manifest.permission#SIM_COMMUNICATION SIM_COMMUNICATION} - * - * @param channel is the channel id to be closed as retruned by a successful - * iccOpenLogicalChannel. - * @return true if the channel was closed successfully. - */ - public boolean iccCloseLogicalChannel(int channel) { - try { - return getITelephony().iccCloseLogicalChannel(channel); - } catch (RemoteException ex) { - } catch (NullPointerException ex) { - } - return false; - } - - /** - * Transmit an APDU to the ICC card over a logical channel. - * - * Input parameters equivalent to TS 27.007 AT+CGLA command. - * - * <p>Requires Permission: - * {@link android.Manifest.permission#SIM_COMMUNICATION SIM_COMMUNICATION} - * - * @param channel is the channel id to be closed as returned by a successful - * iccOpenLogicalChannel. - * @param cla Class of the APDU command. - * @param instruction Instruction of the APDU command. - * @param p1 P1 value of the APDU command. - * @param p2 P2 value of the APDU command. - * @param p3 P3 value of the APDU command. If p3 is negative a 4 byte APDU - * is sent to the SIM. - * @param data Data to be sent with the APDU. - * @return The APDU response from the ICC card with the status appended at - * the end. If an error occurs, an empty string is returned. - */ - public String iccTransmitApduLogicalChannel(int channel, int cla, - int instruction, int p1, int p2, int p3, String data) { - try { - return getITelephony().iccTransmitApduLogicalChannel(channel, cla, - instruction, p1, p2, p3, data); - } catch (RemoteException ex) { - } catch (NullPointerException ex) { - } - return ""; - } - - /** - * Send ENVELOPE to the SIM and return the response. - * - * <p>Requires Permission: - * {@link android.Manifest.permission#SIM_COMMUNICATION SIM_COMMUNICATION} - * - * @param content String containing SAT/USAT response in hexadecimal - * format starting with command tag. See TS 102 223 for - * details. - * @return The APDU response from the ICC card, with the last 4 bytes - * being the status word. If the command fails, returns an empty - * string. - */ - public String sendEnvelopeWithStatus(String content) { - try { - return getITelephony().sendEnvelopeWithStatus(content); - } catch (RemoteException ex) { - } catch (NullPointerException ex) { - } - return ""; - } - - /** - * Read one of the NV items defined in {@link com.android.internal.telephony.RadioNVItems}. - * Used for device configuration by some CDMA operators. - * - * @param itemID the ID of the item to read. - * @return the NV item as a String, or null on any failure. - * @hide - */ - public String nvReadItem(int itemID) { - try { - return getITelephony().nvReadItem(itemID); - } catch (RemoteException ex) { - Rlog.e(TAG, "nvReadItem RemoteException", ex); - } catch (NullPointerException ex) { - Rlog.e(TAG, "nvReadItem NPE", ex); - } - return ""; - } - - - /** - * Write one of the NV items defined in {@link com.android.internal.telephony.RadioNVItems}. - * Used for device configuration by some CDMA operators. - * - * @param itemID the ID of the item to read. - * @param itemValue the value to write, as a String. - * @return true on success; false on any failure. - * @hide - */ - public boolean nvWriteItem(int itemID, String itemValue) { - try { - return getITelephony().nvWriteItem(itemID, itemValue); - } catch (RemoteException ex) { - Rlog.e(TAG, "nvWriteItem RemoteException", ex); - } catch (NullPointerException ex) { - Rlog.e(TAG, "nvWriteItem NPE", ex); - } - return false; - } - - /** - * Update the CDMA Preferred Roaming List (PRL) in the radio NV storage. - * Used for device configuration by some CDMA operators. - * - * @param preferredRoamingList byte array containing the new PRL. - * @return true on success; false on any failure. - * @hide - */ - public boolean nvWriteCdmaPrl(byte[] preferredRoamingList) { - try { - return getITelephony().nvWriteCdmaPrl(preferredRoamingList); - } catch (RemoteException ex) { - Rlog.e(TAG, "nvWriteCdmaPrl RemoteException", ex); - } catch (NullPointerException ex) { - Rlog.e(TAG, "nvWriteCdmaPrl NPE", ex); - } - return false; - } - - /** - * Perform the specified type of NV config reset. The radio will be taken offline - * and the device must be rebooted after the operation. Used for device - * configuration by some CDMA operators. - * - * @param resetType reset type: 1: reload NV reset, 2: erase NV reset, 3: factory NV reset - * @return true on success; false on any failure. - * @hide - */ - public boolean nvResetConfig(int resetType) { - try { - return getITelephony().nvResetConfig(resetType); - } catch (RemoteException ex) { - Rlog.e(TAG, "nvResetConfig RemoteException", ex); - } catch (NullPointerException ex) { - Rlog.e(TAG, "nvResetConfig NPE", ex); - } - return false; - } - - /** - * Get the preferred network type. - * Used for device configuration by some CDMA operators. - * - * @return the preferred network type, defined in RILConstants.java. - * @hide - */ - public int getPreferredNetworkType() { - try { - return getITelephony().getPreferredNetworkType(); - } catch (RemoteException ex) { - Rlog.e(TAG, "getPreferredNetworkType RemoteException", ex); - } catch (NullPointerException ex) { - Rlog.e(TAG, "getPreferredNetworkType NPE", ex); - } - return -1; - } - - /** - * Set the preferred network type. - * Used for device configuration by some CDMA operators. - * - * @param networkType the preferred network type, defined in RILConstants.java. - * @return true on success; false on any failure. - * @hide - */ - public boolean setPreferredNetworkType(int networkType) { - try { - return getITelephony().setPreferredNetworkType(networkType); - } catch (RemoteException ex) { - Rlog.e(TAG, "setPreferredNetworkType RemoteException", ex); - } catch (NullPointerException ex) { - Rlog.e(TAG, "setPreferredNetworkType NPE", ex); - } - return false; - } - - /** * Expose the rest of ITelephony to @PrivateApi */ diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl index acaa8deb8a63..f9462f260a85 100644 --- a/telephony/java/com/android/internal/telephony/ITelephony.aidl +++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl @@ -308,114 +308,6 @@ interface ITelephony { void setCellInfoListRate(int rateInMillis); /** - * Opens a logical channel to the ICC card. - * - * Input parameters equivalent to TS 27.007 AT+CCHO command. - * - * @param AID Application id. See ETSI 102.221 and 101.220. - * @return The logical channel id which is set to -1 on error. - */ - int iccOpenLogicalChannel(String AID); - - /** - * Closes a previously opened logical channel to the ICC card. - * - * Input parameters equivalent to TS 27.007 AT+CCHC command. - * - * @param channel is the channel id to be closed as retruned by a - * successful iccOpenLogicalChannel. - * @return true if the channel was closed successfully. - */ - boolean iccCloseLogicalChannel(int channel); - - /** - * Transmit an APDU to the ICC card over a logical channel. - * - * Input parameters equivalent to TS 27.007 AT+CGLA command. - * - * @param channel is the channel id to be closed as retruned by a - * successful iccOpenLogicalChannel. - * @param cla Class of the APDU command. - * @param instruction Instruction of the APDU command. - * @param p1 P1 value of the APDU command. - * @param p2 P2 value of the APDU command. - * @param p3 P3 value of the APDU command. If p3 is negative a 4 byte APDU - * is sent to the SIM. - * @param data Data to be sent with the APDU. - * @return The APDU response from the ICC card with the status appended at - * the end. If an error occurs, an empty string is returned. - */ - String iccTransmitApduLogicalChannel(int channel, int cla, int instruction, - int p1, int p2, int p3, String data); - - /** - * Send ENVELOPE to the SIM and returns the response. - * - * @param contents String containing SAT/USAT response in hexadecimal - * format starting with command tag. See TS 102 223 for - * details. - * @return The APDU response from the ICC card, with the last 4 bytes - * being the status word. If the command fails, returns an empty - * string. - */ - String sendEnvelopeWithStatus(String content); - - /** - * Read one of the NV items defined in {@link RadioNVItems} / {@code ril_nv_items.h}. - * Used for device configuration by some CDMA operators. - * - * @param itemID the ID of the item to read. - * @return the NV item as a String, or null on any failure. - */ - String nvReadItem(int itemID); - - /** - * Write one of the NV items defined in {@link RadioNVItems} / {@code ril_nv_items.h}. - * Used for device configuration by some CDMA operators. - * - * @param itemID the ID of the item to read. - * @param itemValue the value to write, as a String. - * @return true on success; false on any failure. - */ - boolean nvWriteItem(int itemID, String itemValue); - - /** - * Update the CDMA Preferred Roaming List (PRL) in the radio NV storage. - * Used for device configuration by some CDMA operators. - * - * @param preferredRoamingList byte array containing the new PRL. - * @return true on success; false on any failure. - */ - boolean nvWriteCdmaPrl(in byte[] preferredRoamingList); - - /** - * Perform the specified type of NV config reset. The radio will be taken offline - * and the device must be rebooted after the operation. Used for device - * configuration by some CDMA operators. - * - * @param resetType the type of reset to perform (1 == factory reset; 2 == NV-only reset). - * @return true on success; false on any failure. - */ - boolean nvResetConfig(int resetType); - - /* - * Get the preferred network type. - * Used for device configuration by some CDMA operators. - * - * @return the preferred network type, defined in RILConstants.java. - */ - int getPreferredNetworkType(); - - /** - * Set the preferred network type. - * Used for device configuration by some CDMA operators. - * - * @param networkType the preferred network type, defined in RILConstants.java. - * @return true on success; false on any failure. - */ - boolean setPreferredNetworkType(int networkType); - - /** * User enable/disable Mobile Data. * * @param enable true to turn on, else false @@ -429,3 +321,4 @@ interface ITelephony { */ boolean getDataEnabled(); } + diff --git a/wifi/java/android/net/wifi/WifiConfiguration.java b/wifi/java/android/net/wifi/WifiConfiguration.java index 0faaebae182f..5dfc3184193c 100644 --- a/wifi/java/android/net/wifi/WifiConfiguration.java +++ b/wifi/java/android/net/wifi/WifiConfiguration.java @@ -495,6 +495,12 @@ public class WifiConfiguration implements Parcelable { public boolean didSelfAdd; /** + * peer WifiConfiguration this WifiConfiguration was added for + * @hide + */ + public String peerWifiConfiguration; + + /** * @hide * Indicate that a WifiConfiguration is temporary and should not be saved * nor considered by AutoJoin. @@ -980,6 +986,7 @@ public class WifiConfiguration implements Parcelable { lastConnectUid = source.lastConnectUid; lastUpdateUid = source.lastUpdateUid; creatorUid = source.creatorUid; + peerWifiConfiguration = source.peerWifiConfiguration; } } |