diff options
Diffstat (limited to 'core')
18 files changed, 308 insertions, 153 deletions
diff --git a/core/java/android/app/ActivityManager.java b/core/java/android/app/ActivityManager.java index bb9e19f..a25e311 100644 --- a/core/java/android/app/ActivityManager.java +++ b/core/java/android/app/ActivityManager.java @@ -16,6 +16,7 @@ package android.app; +import android.R; import com.android.internal.app.IUsageStats; import com.android.internal.os.PkgUsageStats; import com.android.internal.util.MemInfoReader; @@ -369,9 +370,9 @@ public class ActivityManager { // Really brain dead right now -- just take this from the configured // vm heap size, and assume it is in megabytes and thus ends with "m". String vmHeapSize = SystemProperties.get("dalvik.vm.heapsize", "16m"); - return Integer.parseInt(vmHeapSize.substring(0, vmHeapSize.length()-1)); + return Integer.parseInt(vmHeapSize.substring(0, vmHeapSize.length() - 1)); } - + /** * Used by persistent processes to determine if they are running on a * higher-end device so should be okay using hardware drawing acceleration diff --git a/core/java/android/app/AppOpsManager.java b/core/java/android/app/AppOpsManager.java index c9776f1..4fcb18a 100644 --- a/core/java/android/app/AppOpsManager.java +++ b/core/java/android/app/AppOpsManager.java @@ -422,6 +422,14 @@ public class AppOpsManager { } } + /** @hide */ + public void resetAllModes() { + try { + mService.resetAllModes(); + } catch (RemoteException e) { + } + } + public void startWatchingMode(int op, String packageName, final Callback callback) { synchronized (mModeWatchers) { IAppOpsCallback cb = mModeWatchers.get(callback); diff --git a/core/java/android/bluetooth/BluetoothTetheringDataTracker.java b/core/java/android/bluetooth/BluetoothTetheringDataTracker.java index 81c0a6a..0aedecb 100644 --- a/core/java/android/bluetooth/BluetoothTetheringDataTracker.java +++ b/core/java/android/bluetooth/BluetoothTetheringDataTracker.java @@ -152,6 +152,11 @@ public class BluetoothTetheringDataTracker implements NetworkStateTracker { // not implemented } + @Override + public void captivePortalCheckCompleted(boolean isCaptivePortal) { + // not implemented + } + /** * Re-enable connectivity to a network after a {@link #teardown()}. */ diff --git a/core/java/android/net/BaseNetworkStateTracker.java b/core/java/android/net/BaseNetworkStateTracker.java index 1165281..e87f84c 100644 --- a/core/java/android/net/BaseNetworkStateTracker.java +++ b/core/java/android/net/BaseNetworkStateTracker.java @@ -102,6 +102,11 @@ public abstract class BaseNetworkStateTracker implements NetworkStateTracker { } @Override + public void captivePortalCheckCompleted(boolean isCaptivePortal) { + // not implemented + } + + @Override public boolean setRadio(boolean turnOn) { // Base tracker doesn't handle radios return true; diff --git a/core/java/android/net/CaptivePortalTracker.java b/core/java/android/net/CaptivePortalTracker.java index 21995c0..19c5f39 100644 --- a/core/java/android/net/CaptivePortalTracker.java +++ b/core/java/android/net/CaptivePortalTracker.java @@ -34,6 +34,7 @@ import android.os.Message; import android.os.RemoteException; import android.provider.Settings; import android.telephony.TelephonyManager; +import android.text.TextUtils; import com.android.internal.util.State; import com.android.internal.util.StateMachine; @@ -42,6 +43,7 @@ import java.io.IOException; import java.net.HttpURLConnection; import java.net.InetAddress; import java.net.Inet4Address; +import java.net.SocketTimeoutException; import java.net.URL; import java.net.UnknownHostException; @@ -52,17 +54,15 @@ import com.android.internal.R; * @hide */ public class CaptivePortalTracker extends StateMachine { - private static final boolean DBG = false; + private static final boolean DBG = true; private static final String TAG = "CaptivePortalTracker"; private static final String DEFAULT_SERVER = "clients3.google.com"; - private static final String NOTIFICATION_ID = "CaptivePortal.Notification"; private static final int SOCKET_TIMEOUT_MS = 10000; private String mServer; private String mUrl; - private boolean mNotificationShown = false; private boolean mIsCaptivePortalCheckEnabled = false; private IConnectivityManager mConnService; private TelephonyManager mTelephonyManager; @@ -159,12 +159,12 @@ public class CaptivePortalTracker extends StateMachine { private class DefaultState extends State { @Override public void enter() { - if (DBG) log(getName() + "\n"); + setNotificationOff(); } @Override public boolean processMessage(Message message) { - if (DBG) log(getName() + message.toString() + "\n"); + if (DBG) log(getName() + message.toString()); switch (message.what) { case CMD_DETECT_PORTAL: NetworkInfo info = (NetworkInfo) message.obj; @@ -186,23 +186,24 @@ public class CaptivePortalTracker extends StateMachine { private class NoActiveNetworkState extends State { @Override public void enter() { - if (DBG) log(getName() + "\n"); mNetworkInfo = null; - /* Clear any previous notification */ - setNotificationVisible(false); } @Override public boolean processMessage(Message message) { - if (DBG) log(getName() + message.toString() + "\n"); + if (DBG) log(getName() + message.toString()); InetAddress server; NetworkInfo info; switch (message.what) { case CMD_CONNECTIVITY_CHANGE: info = (NetworkInfo) message.obj; - if (info.isConnected() && isActiveNetwork(info)) { - mNetworkInfo = info; - transitionTo(mDelayedCaptiveCheckState); + if (info.getType() == ConnectivityManager.TYPE_WIFI) { + if (info.isConnected() && isActiveNetwork(info)) { + mNetworkInfo = info; + transitionTo(mDelayedCaptiveCheckState); + } + } else { + log(getName() + " not a wifi connectivity change, ignore"); } break; default: @@ -215,7 +216,7 @@ public class CaptivePortalTracker extends StateMachine { private class ActiveNetworkState extends State { @Override public void enter() { - if (DBG) log(getName() + "\n"); + setNotificationOff(); } @Override @@ -248,7 +249,6 @@ public class CaptivePortalTracker extends StateMachine { private class DelayedCaptiveCheckState extends State { @Override public void enter() { - if (DBG) log(getName() + "\n"); Message message = obtainMessage(CMD_DELAYED_CAPTIVE_CHECK, ++mDelayedCheckToken, 0); if (mDeviceProvisioned) { sendMessageDelayed(message, DELAYED_CHECK_INTERVAL_MS); @@ -259,7 +259,7 @@ public class CaptivePortalTracker extends StateMachine { @Override public boolean processMessage(Message message) { - if (DBG) log(getName() + message.toString() + "\n"); + if (DBG) log(getName() + message.toString()); switch (message.what) { case CMD_DELAYED_CAPTIVE_CHECK: if (message.arg1 == mDelayedCheckToken) { @@ -270,11 +270,17 @@ public class CaptivePortalTracker extends StateMachine { } else { if (DBG) log("Not captive network " + mNetworkInfo); } + notifyPortalCheckCompleted(mNetworkInfo, captive); if (mDeviceProvisioned) { if (captive) { // Setup Wizard will assist the user in connecting to a captive // portal, so make the notification visible unless during setup - setNotificationVisible(true); + try { + mConnService.setProvisioningNotificationVisible(true, + mNetworkInfo.getType(), mNetworkInfo.getExtraInfo(), mUrl); + } catch(RemoteException e) { + e.printStackTrace(); + } } } else { Intent intent = new Intent( @@ -300,12 +306,26 @@ public class CaptivePortalTracker extends StateMachine { return; } try { + if (DBG) log("notifyPortalCheckComplete: ni=" + info); mConnService.captivePortalCheckComplete(info); } catch(RemoteException e) { e.printStackTrace(); } } + private void notifyPortalCheckCompleted(NetworkInfo info, boolean isCaptivePortal) { + if (info == null) { + loge("notifyPortalCheckComplete on null"); + return; + } + try { + if (DBG) log("notifyPortalCheckCompleted: captive=" + isCaptivePortal + " ni=" + info); + mConnService.captivePortalCheckCompleted(info, isCaptivePortal); + } catch(RemoteException e) { + e.printStackTrace(); + } + } + private boolean isActiveNetwork(NetworkInfo info) { try { NetworkInfo active = mConnService.getActiveNetworkInfo(); @@ -318,6 +338,15 @@ public class CaptivePortalTracker extends StateMachine { return false; } + private void setNotificationOff() { + try { + mConnService.setProvisioningNotificationVisible(false, ConnectivityManager.TYPE_NONE, + null, null); + } catch (RemoteException e) { + log("setNotificationOff: " + e); + } + } + /** * Do a URL fetch on a known server to see if we get the data we expect */ @@ -360,58 +389,4 @@ public class CaptivePortalTracker extends StateMachine { } return null; } - - private void setNotificationVisible(boolean visible) { - // if it should be hidden and it is already hidden, then noop - if (!visible && !mNotificationShown) { - return; - } - - Resources r = Resources.getSystem(); - NotificationManager notificationManager = (NotificationManager) mContext - .getSystemService(Context.NOTIFICATION_SERVICE); - - if (visible) { - CharSequence title; - CharSequence details; - int icon; - switch (mNetworkInfo.getType()) { - case ConnectivityManager.TYPE_WIFI: - title = r.getString(R.string.wifi_available_sign_in, 0); - details = r.getString(R.string.network_available_sign_in_detailed, - mNetworkInfo.getExtraInfo()); - icon = R.drawable.stat_notify_wifi_in_range; - break; - case ConnectivityManager.TYPE_MOBILE: - title = r.getString(R.string.network_available_sign_in, 0); - // TODO: Change this to pull from NetworkInfo once a printable - // name has been added to it - details = mTelephonyManager.getNetworkOperatorName(); - icon = R.drawable.stat_notify_rssi_in_range; - break; - default: - title = r.getString(R.string.network_available_sign_in, 0); - details = r.getString(R.string.network_available_sign_in_detailed, - mNetworkInfo.getExtraInfo()); - icon = R.drawable.stat_notify_rssi_in_range; - break; - } - - Notification notification = new Notification(); - notification.when = 0; - notification.icon = icon; - notification.flags = Notification.FLAG_AUTO_CANCEL; - Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(mUrl)); - intent.setFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT | - Intent.FLAG_ACTIVITY_NEW_TASK); - notification.contentIntent = PendingIntent.getActivity(mContext, 0, intent, 0); - notification.tickerText = title; - notification.setLatestEventInfo(mContext, title, details, notification.contentIntent); - - notificationManager.notify(NOTIFICATION_ID, 1, notification); - } else { - notificationManager.cancel(NOTIFICATION_ID, 1); - } - mNotificationShown = visible; - } } diff --git a/core/java/android/net/ConnectivityManager.java b/core/java/android/net/ConnectivityManager.java index 697bde9..02a6494 100644 --- a/core/java/android/net/ConnectivityManager.java +++ b/core/java/android/net/ConnectivityManager.java @@ -583,6 +583,29 @@ public class ConnectivityManager { } /** + * Returns details about the Provisioning or currently active default data network. When + * connected, this network is the default route for outgoing connections. + * You should always check {@link NetworkInfo#isConnected()} before initiating + * network traffic. This may return {@code null} when there is no default + * network. + * + * @return a {@link NetworkInfo} object for the current default network + * or {@code null} if no network default network is currently active + * + * <p>This method requires the call to hold the permission + * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}. + * + * {@hide} + */ + public NetworkInfo getProvisioningOrActiveNetworkInfo() { + try { + return mService.getProvisioningOrActiveNetworkInfo(); + } catch (RemoteException e) { + return null; + } + } + + /** * Returns the IP information for the current default network. * * @return a {@link LinkProperties} object describing the IP info @@ -1283,84 +1306,59 @@ public class ConnectivityManager { } /** - * Supply the backend messenger for a network tracker + * Signal that the captive portal check on the indicated network + * is complete and whether its a captive portal or not. * - * @param type NetworkType to set - * @param messenger {@link Messenger} + * @param info the {@link NetworkInfo} object for the networkType + * in question. + * @param isCaptivePortal true/false. + * + * <p>This method requires the call to hold the permission + * {@link android.Manifest.permission#CONNECTIVITY_INTERNAL}. * {@hide} */ - public void supplyMessenger(int networkType, Messenger messenger) { + public void captivePortalCheckCompleted(NetworkInfo info, boolean isCaptivePortal) { try { - mService.supplyMessenger(networkType, messenger); + mService.captivePortalCheckCompleted(info, isCaptivePortal); } catch (RemoteException e) { } } /** - * The ResultReceiver resultCode for checkMobileProvisioning (CMP_RESULT_CODE) - */ - - /** - * No connection was possible to the network. - * {@hide} - */ - public static final int CMP_RESULT_CODE_NO_CONNECTION = 0; - - /** - * A connection was made to the internet, all is well. - * {@hide} - */ - public static final int CMP_RESULT_CODE_CONNECTABLE = 1; - - /** - * A connection was made but there was a redirection, we appear to be in walled garden. - * This is an indication of a warm sim on a mobile network. - * {@hide} - */ - public static final int CMP_RESULT_CODE_REDIRECTED = 2; - - /** - * A connection was made but no dns server was available to resolve a name to address. - * This is an indication of a warm sim on a mobile network. + * Supply the backend messenger for a network tracker * + * @param type NetworkType to set + * @param messenger {@link Messenger} * {@hide} */ - public static final int CMP_RESULT_CODE_NO_DNS = 3; - - /** - * A connection was made but could not open a TCP connection. - * This is an indication of a warm sim on a mobile network. - * {@hide} - */ - public static final int CMP_RESULT_CODE_NO_TCP_CONNECTION = 4; + public void supplyMessenger(int networkType, Messenger messenger) { + try { + mService.supplyMessenger(networkType, messenger); + } catch (RemoteException e) { + } + } /** - * Check mobile provisioning. The resultCode passed to - * onReceiveResult will be one of the CMP_RESULT_CODE_xxxx values above. - * This may take a minute or more to complete. + * Check mobile provisioning. * - * @param sendNotificaiton, when true a notification will be sent to user. * @param suggestedTimeOutMs, timeout in milliseconds - * @param resultReceiver needs to be supplied to receive the result * * @return time out that will be used, maybe less that suggestedTimeOutMs * -1 if an error. * * {@hide} */ - public int checkMobileProvisioning(boolean sendNotification, int suggestedTimeOutMs, - ResultReceiver resultReceiver) { + public int checkMobileProvisioning(int suggestedTimeOutMs) { int timeOutMs = -1; try { - timeOutMs = mService.checkMobileProvisioning(sendNotification, suggestedTimeOutMs, - resultReceiver); + timeOutMs = mService.checkMobileProvisioning(suggestedTimeOutMs); } catch (RemoteException e) { } return timeOutMs; } /** - * Get the carrier provisioning url. + * Get the mobile provisioning url. * {@hide} */ public String getMobileProvisioningUrl() { @@ -1370,4 +1368,32 @@ public class ConnectivityManager { } return null; } + + /** + * Get the mobile redirected provisioning url. + * {@hide} + */ + public String getMobileRedirectedProvisioningUrl() { + try { + return mService.getMobileRedirectedProvisioningUrl(); + } catch (RemoteException e) { + } + return null; + } + + /** + * Set sign in error notification to visible or in visible + * + * @param visible + * @param networkType + * + * {@hide} + */ + public void setProvisioningNotificationVisible(boolean visible, int networkType, + String extraInfo, String url) { + try { + mService.setProvisioningNotificationVisible(visible, networkType, extraInfo, url); + } catch (RemoteException e) { + } + } } diff --git a/core/java/android/net/DummyDataStateTracker.java b/core/java/android/net/DummyDataStateTracker.java index 15a81f3..ee738fd 100644 --- a/core/java/android/net/DummyDataStateTracker.java +++ b/core/java/android/net/DummyDataStateTracker.java @@ -120,10 +120,16 @@ public class DummyDataStateTracker implements NetworkStateTracker { return true; } + @Override public void captivePortalCheckComplete() { // not implemented } + @Override + public void captivePortalCheckCompleted(boolean isCaptivePortal) { + // not implemented + } + /** * Record the detailed state of a network, and if it is a * change from the previous state, send a notification to diff --git a/core/java/android/net/EthernetDataTracker.java b/core/java/android/net/EthernetDataTracker.java index 27d5a58..ac2b0d9 100644 --- a/core/java/android/net/EthernetDataTracker.java +++ b/core/java/android/net/EthernetDataTracker.java @@ -279,6 +279,11 @@ public class EthernetDataTracker implements NetworkStateTracker { // not implemented } + @Override + public void captivePortalCheckCompleted(boolean isCaptivePortal) { + // not implemented + } + /** * Turn the wireless radio off for a network. * @param turnOn {@code true} to turn the radio on, {@code false} diff --git a/core/java/android/net/IConnectivityManager.aidl b/core/java/android/net/IConnectivityManager.aidl index 4600c1a..a17b4f5 100644 --- a/core/java/android/net/IConnectivityManager.aidl +++ b/core/java/android/net/IConnectivityManager.aidl @@ -46,6 +46,8 @@ interface IConnectivityManager NetworkInfo getNetworkInfo(int networkType); NetworkInfo[] getAllNetworkInfo(); + NetworkInfo getProvisioningOrActiveNetworkInfo(); + boolean isNetworkSupported(int networkType); LinkProperties getActiveLinkProperties(); @@ -129,11 +131,17 @@ interface IConnectivityManager void captivePortalCheckComplete(in NetworkInfo info); + void captivePortalCheckCompleted(in NetworkInfo info, boolean isCaptivePortal); + void supplyMessenger(int networkType, in Messenger messenger); int findConnectionTypeForIface(in String iface); - int checkMobileProvisioning(boolean sendNotification, int suggestedTimeOutMs, in ResultReceiver resultReceiver); + int checkMobileProvisioning(int suggestedTimeOutMs); String getMobileProvisioningUrl(); + + String getMobileRedirectedProvisioningUrl(); + + void setProvisioningNotificationVisible(boolean visible, int networkType, in String extraInfo, in String url); } diff --git a/core/java/android/net/MobileDataStateTracker.java b/core/java/android/net/MobileDataStateTracker.java index 5a1daed..e09254b 100644 --- a/core/java/android/net/MobileDataStateTracker.java +++ b/core/java/android/net/MobileDataStateTracker.java @@ -40,6 +40,7 @@ import com.android.internal.util.AsyncChannel; import java.io.CharArrayWriter; import java.io.PrintWriter; +import java.util.concurrent.atomic.AtomicBoolean; /** * Track the state of mobile data connectivity. This is done by @@ -51,7 +52,7 @@ import java.io.PrintWriter; public class MobileDataStateTracker implements NetworkStateTracker { private static final String TAG = "MobileDataStateTracker"; - private static final boolean DBG = false; + private static final boolean DBG = true; private static final boolean VDBG = false; private PhoneConstants.DataState mMobileDataState; @@ -75,6 +76,8 @@ public class MobileDataStateTracker implements NetworkStateTracker { private Handler mHandler; private AsyncChannel mDataConnectionTrackerAc; + private AtomicBoolean mIsCaptivePortal = new AtomicBoolean(false); + /** * Create a new MobileDataStateTracker * @param netType the ConnectivityManager network type @@ -101,6 +104,7 @@ public class MobileDataStateTracker implements NetworkStateTracker { IntentFilter filter = new IntentFilter(); filter.addAction(TelephonyIntents.ACTION_ANY_DATA_CONNECTION_STATE_CHANGED); + filter.addAction(TelephonyIntents.ACTION_DATA_CONNECTION_CONNECTED_TO_PROVISIONING_APN); filter.addAction(TelephonyIntents.ACTION_DATA_CONNECTION_FAILED); mContext.registerReceiver(new MobileDataStateReceiver(), filter); @@ -168,20 +172,55 @@ public class MobileDataStateTracker implements NetworkStateTracker { public void releaseWakeLock() { } + private void updateLinkProperitesAndCapatilities(Intent intent) { + mLinkProperties = intent.getParcelableExtra( + PhoneConstants.DATA_LINK_PROPERTIES_KEY); + if (mLinkProperties == null) { + loge("CONNECTED event did not supply link properties."); + mLinkProperties = new LinkProperties(); + } + mLinkCapabilities = intent.getParcelableExtra( + PhoneConstants.DATA_LINK_CAPABILITIES_KEY); + if (mLinkCapabilities == null) { + loge("CONNECTED event did not supply link capabilities."); + mLinkCapabilities = new LinkCapabilities(); + } + } + private class MobileDataStateReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { + // Assume this isn't a provisioning network. + mNetworkInfo.setIsConnectedToProvisioningNetwork(false); if (intent.getAction().equals(TelephonyIntents. - ACTION_ANY_DATA_CONNECTION_STATE_CHANGED)) { + ACTION_DATA_CONNECTION_CONNECTED_TO_PROVISIONING_APN)) { + String apnName = intent.getStringExtra(PhoneConstants.DATA_APN_KEY); String apnType = intent.getStringExtra(PhoneConstants.DATA_APN_TYPE_KEY); - if (VDBG) { - log(String.format("Broadcast received: ACTION_ANY_DATA_CONNECTION_STATE_CHANGED" - + "mApnType=%s %s received apnType=%s", mApnType, - TextUtils.equals(apnType, mApnType) ? "==" : "!=", apnType)); + if (!TextUtils.equals(mApnType, apnType)) { + return; + } + if (DBG) { + log("Broadcast received: " + intent.getAction() + " apnType=" + apnType + + " apnName=" + apnName); } + + // Make us in the connecting state until we make a new TYPE_MOBILE_PROVISIONING + mMobileDataState = PhoneConstants.DataState.CONNECTING; + updateLinkProperitesAndCapatilities(intent); + mNetworkInfo.setIsConnectedToProvisioningNetwork(true); + + // Change state to SUSPENDED so setDetailedState + // sends EVENT_STATE_CHANGED to connectivityService + setDetailedState(DetailedState.SUSPENDED, "", apnName); + } else if (intent.getAction().equals(TelephonyIntents. + ACTION_ANY_DATA_CONNECTION_STATE_CHANGED)) { + String apnType = intent.getStringExtra(PhoneConstants.DATA_APN_TYPE_KEY); if (!TextUtils.equals(apnType, mApnType)) { return; } + if (DBG) { + log("Broadcast received: " + intent.getAction() + " apnType=" + apnType); + } int oldSubtype = mNetworkInfo.getSubtype(); int newSubType = TelephonyManager.getDefault().getNetworkType(); @@ -199,7 +238,7 @@ public class MobileDataStateTracker implements NetworkStateTracker { String apnName = intent.getStringExtra(PhoneConstants.DATA_APN_KEY); mNetworkInfo.setRoaming(intent.getBooleanExtra( PhoneConstants.DATA_NETWORK_ROAMING_KEY, false)); - if (VDBG) { + if (DBG) { log(mApnType + " setting isAvailable to " + intent.getBooleanExtra(PhoneConstants.NETWORK_UNAVAILABLE_KEY,false)); } @@ -233,18 +272,7 @@ public class MobileDataStateTracker implements NetworkStateTracker { setDetailedState(DetailedState.SUSPENDED, reason, apnName); break; case CONNECTED: - mLinkProperties = intent.getParcelableExtra( - PhoneConstants.DATA_LINK_PROPERTIES_KEY); - if (mLinkProperties == null) { - loge("CONNECTED event did not supply link properties."); - mLinkProperties = new LinkProperties(); - } - mLinkCapabilities = intent.getParcelableExtra( - PhoneConstants.DATA_LINK_CAPABILITIES_KEY); - if (mLinkCapabilities == null) { - loge("CONNECTED event did not supply link capabilities."); - mLinkCapabilities = new LinkCapabilities(); - } + updateLinkProperitesAndCapatilities(intent); setDetailedState(DetailedState.CONNECTED, reason, apnName); break; } @@ -269,18 +297,13 @@ public class MobileDataStateTracker implements NetworkStateTracker { equals(TelephonyIntents.ACTION_DATA_CONNECTION_FAILED)) { String apnType = intent.getStringExtra(PhoneConstants.DATA_APN_TYPE_KEY); if (!TextUtils.equals(apnType, mApnType)) { - if (DBG) { - log(String.format( - "Broadcast received: ACTION_ANY_DATA_CONNECTION_FAILED ignore, " + - "mApnType=%s != received apnType=%s", mApnType, apnType)); - } return; } String reason = intent.getStringExtra(PhoneConstants.FAILURE_REASON_KEY); String apnName = intent.getStringExtra(PhoneConstants.DATA_APN_KEY); if (DBG) { - log("Received " + intent.getAction() + - " broadcast" + reason == null ? "" : "(" + reason + ")"); + log("Broadcast received: " + intent.getAction() + + " reason=" + reason == null ? "null" : reason); } setDetailedState(DetailedState.FAILED, reason, apnName); } else { @@ -372,11 +395,27 @@ public class MobileDataStateTracker implements NetworkStateTracker { return (setEnableApn(mApnType, false) != PhoneConstants.APN_REQUEST_FAILED); } + /** + * @return true if this is ready to operate + */ + public boolean isReady() { + return mDataConnectionTrackerAc != null; + } + @Override public void captivePortalCheckComplete() { // not implemented } + @Override + public void captivePortalCheckCompleted(boolean isCaptivePortal) { + if (mIsCaptivePortal.getAndSet(isCaptivePortal) != isCaptivePortal) { + // Captive portal change enable/disable failing fast + setEnableFailFastMobileData( + isCaptivePortal ? DctConstants.ENABLED : DctConstants.DISABLED); + } + } + /** * Record the detailed state of a network, and if it is a * change from the previous state, send a notification to @@ -525,6 +564,40 @@ public class MobileDataStateTracker implements NetworkStateTracker { } } + /** + * Inform DCT mobile provisioning has started, it ends when provisioning completes. + */ + public void enableMobileProvisioning(String url) { + if (DBG) log("enableMobileProvisioning(url=" + url + ")"); + final AsyncChannel channel = mDataConnectionTrackerAc; + if (channel != null) { + Message msg = Message.obtain(); + msg.what = DctConstants.CMD_ENABLE_MOBILE_PROVISIONING; + msg.setData(Bundle.forPair(DctConstants.PROVISIONING_URL_KEY, url)); + channel.sendMessage(msg); + } + } + + /** + * Return if this network is the provisioning network. Valid only if connected. + * @param met + */ + public boolean isProvisioningNetwork() { + boolean retVal; + try { + Message msg = Message.obtain(); + msg.what = DctConstants.CMD_IS_PROVISIONING_APN; + msg.setData(Bundle.forPair(DctConstants.APN_TYPE_KEY, mApnType)); + Message result = mDataConnectionTrackerAc.sendMessageSynchronously(msg); + retVal = result.arg1 == DctConstants.ENABLED; + } catch (NullPointerException e) { + loge("isProvisioningNetwork: X " + e); + retVal = false; + } + if (DBG) log("isProvisioningNetwork: retVal=" + retVal); + return retVal; + } + @Override public void addStackedLink(LinkProperties link) { mLinkProperties.addStackedLink(link); diff --git a/core/java/android/net/NetworkInfo.java b/core/java/android/net/NetworkInfo.java index 689dae5..4d2a70d 100644 --- a/core/java/android/net/NetworkInfo.java +++ b/core/java/android/net/NetworkInfo.java @@ -83,7 +83,7 @@ public class NetworkInfo implements Parcelable { /** Link has poor connectivity. */ VERIFYING_POOR_LINK, /** Checking if network is a captive portal */ - CAPTIVE_PORTAL_CHECK, + CAPTIVE_PORTAL_CHECK } /** @@ -120,6 +120,8 @@ public class NetworkInfo implements Parcelable { private String mExtraInfo; private boolean mIsFailover; private boolean mIsRoaming; + private boolean mIsConnectedToProvisioningNetwork; + /** * Indicates whether network connectivity is possible: */ @@ -148,6 +150,7 @@ public class NetworkInfo implements Parcelable { mState = State.UNKNOWN; mIsAvailable = false; // until we're told otherwise, assume unavailable mIsRoaming = false; + mIsConnectedToProvisioningNetwork = false; } /** {@hide} */ @@ -164,6 +167,7 @@ public class NetworkInfo implements Parcelable { mIsFailover = source.mIsFailover; mIsRoaming = source.mIsRoaming; mIsAvailable = source.mIsAvailable; + mIsConnectedToProvisioningNetwork = source.mIsConnectedToProvisioningNetwork; } } @@ -322,6 +326,22 @@ public class NetworkInfo implements Parcelable { } } + /** {@hide} */ + @VisibleForTesting + public boolean isConnectedToProvisioningNetwork() { + synchronized (this) { + return mIsConnectedToProvisioningNetwork; + } + } + + /** {@hide} */ + @VisibleForTesting + public void setIsConnectedToProvisioningNetwork(boolean val) { + synchronized (this) { + mIsConnectedToProvisioningNetwork = val; + } + } + /** * Reports the current coarse-grained state of the network. * @return the coarse-grained state @@ -405,7 +425,9 @@ public class NetworkInfo implements Parcelable { append(", extra: ").append(mExtraInfo == null ? "(none)" : mExtraInfo). append(", roaming: ").append(mIsRoaming). append(", failover: ").append(mIsFailover). - append(", isAvailable: ").append(mIsAvailable); + append(", isAvailable: ").append(mIsAvailable). + append(", isConnectedToProvisioningNetwork: "). + append(mIsConnectedToProvisioningNetwork); return builder.toString(); } } @@ -433,6 +455,7 @@ public class NetworkInfo implements Parcelable { dest.writeInt(mIsFailover ? 1 : 0); dest.writeInt(mIsAvailable ? 1 : 0); dest.writeInt(mIsRoaming ? 1 : 0); + dest.writeInt(mIsConnectedToProvisioningNetwork ? 1 : 0); dest.writeString(mReason); dest.writeString(mExtraInfo); } @@ -455,6 +478,7 @@ public class NetworkInfo implements Parcelable { netInfo.mIsFailover = in.readInt() != 0; netInfo.mIsAvailable = in.readInt() != 0; netInfo.mIsRoaming = in.readInt() != 0; + netInfo.mIsConnectedToProvisioningNetwork = in.readInt() != 0; netInfo.mReason = in.readString(); netInfo.mExtraInfo = in.readString(); return netInfo; diff --git a/core/java/android/net/NetworkStateTracker.java b/core/java/android/net/NetworkStateTracker.java index cf77a1c..9ed7533 100644 --- a/core/java/android/net/NetworkStateTracker.java +++ b/core/java/android/net/NetworkStateTracker.java @@ -144,6 +144,11 @@ public interface NetworkStateTracker { public void captivePortalCheckComplete(); /** + * Captive portal check has completed + */ + public void captivePortalCheckCompleted(boolean isCaptive); + + /** * Turn the wireless radio off for a network. * @param turnOn {@code true} to turn the radio on, {@code false} */ diff --git a/core/java/android/net/SSLCertificateSocketFactory.java b/core/java/android/net/SSLCertificateSocketFactory.java index 2a2f7cf..0fe5cc4 100644 --- a/core/java/android/net/SSLCertificateSocketFactory.java +++ b/core/java/android/net/SSLCertificateSocketFactory.java @@ -81,9 +81,6 @@ public class SSLCertificateSocketFactory extends SSLSocketFactory { } }; - private static final HostnameVerifier HOSTNAME_VERIFIER = - HttpsURLConnection.getDefaultHostnameVerifier(); - private SSLSocketFactory mInsecureFactory = null; private SSLSocketFactory mSecureFactory = null; private TrustManager[] mTrustManagers = null; @@ -195,7 +192,7 @@ public class SSLCertificateSocketFactory extends SSLSocketFactory { if (session == null) { throw new SSLException("Cannot verify SSL socket without session"); } - if (!HOSTNAME_VERIFIER.verify(hostname, session)) { + if (!HttpsURLConnection.getDefaultHostnameVerifier().verify(hostname, session)) { throw new SSLPeerUnverifiedException("Cannot verify hostname: " + hostname); } } diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index 3c8187e..8b28e21 100644 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -4937,6 +4937,13 @@ public final class Settings { "data_stall_alarm_aggressive_delay_in_ms"; /** + * The number of milliseconds to allow the provisioning apn to remain active + * @hide + */ + public static final String PROVISIONING_APN_ALARM_DELAY_IN_MS = + "provisioning_apn_alarm_delay_in_ms"; + + /** * The interval in milliseconds at which to check gprs registration * after the first registration mismatch of gprs and voice service, * to detect possible data network registration problems. diff --git a/core/java/com/android/internal/app/IAppOpsService.aidl b/core/java/com/android/internal/app/IAppOpsService.aidl index a9da863..cfd9cc7 100644 --- a/core/java/com/android/internal/app/IAppOpsService.aidl +++ b/core/java/com/android/internal/app/IAppOpsService.aidl @@ -33,4 +33,5 @@ interface IAppOpsService { List<AppOpsManager.PackageOps> getPackagesForOps(in int[] ops); List<AppOpsManager.PackageOps> getOpsForPackage(int uid, String packageName, in int[] ops); void setMode(int code, int uid, String packageName, int mode); + void resetAllModes(); } diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml index 4bff536..c23012a 100644 --- a/core/res/AndroidManifest.xml +++ b/core/res/AndroidManifest.xml @@ -151,6 +151,7 @@ <protected-broadcast android:name="android.intent.action.DREAMING_STARTED" /> <protected-broadcast android:name="android.intent.action.DREAMING_STOPPED" /> <protected-broadcast android:name="android.intent.action.ANY_DATA_STATE" /> + <protected-broadcast android:name="android.intent.action.DATA_CONNECTION_CONNECTED_TO_PROVISIONING_APN" /> <protected-broadcast android:name="com.android.server.WifiManager.action.START_SCAN" /> <protected-broadcast android:name="com.android.server.WifiManager.action.DELAYED_DRIVER_STOP" /> @@ -181,6 +182,9 @@ <protected-broadcast android:name="android.intent.action.ACTION_IDLE_MAINTENANCE_START" /> <protected-broadcast android:name="android.intent.action.ACTION_IDLE_MAINTENANCE_END" /> + <protected-broadcast + android:name="com.android.server.connectivityservice.CONNECTED_TO_PROVISIONING_NETWORK_ACTION" /> + <!-- ====================================== --> <!-- Permissions for things that cost money --> <!-- ====================================== --> diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml index 4572f5b..707590b 100644 --- a/core/res/res/values/config.xml +++ b/core/res/res/values/config.xml @@ -772,6 +772,10 @@ <!-- IP address of the dns server to use if nobody else suggests one --> <string name="config_default_dns_server" translatable="false">8.8.8.8</string> + <!-- The default mobile provisioning apn. Empty by default, maybe overridden by + an mcc/mnc specific config.xml --> + <string name="mobile_provisioning_apn" translatable="false"></string> + <!-- The default mobile provisioning url. Empty by default, maybe overridden by an mcc/mnc specific config.xml --> <string name="mobile_provisioning_url" translatable="false"></string> diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index b885d56..a67c2af 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -703,6 +703,7 @@ <java-symbol type="string" name="preposition_for_time" /> <java-symbol type="string" name="progress_erasing" /> <java-symbol type="string" name="progress_unmounting" /> + <java-symbol type="string" name="mobile_provisioning_apn" /> <java-symbol type="string" name="mobile_provisioning_url" /> <java-symbol type="string" name="mobile_redirected_provisioning_url" /> <java-symbol type="string" name="reboot_safemode_confirm" /> |