diff options
| -rw-r--r-- | core/res/res/values/config.xml | 2 | ||||
| -rw-r--r-- | services/java/com/android/server/sip/SipService.java | 11 | ||||
| -rw-r--r-- | voip/java/android/net/sip/SipManager.java | 8 |
3 files changed, 21 insertions, 0 deletions
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml index d565c68e5c57..720dc978b95e 100644 --- a/core/res/res/values/config.xml +++ b/core/res/res/values/config.xml @@ -342,4 +342,6 @@ <!-- 2 means give warning --> <integer name="config_datause_notification_type">2</integer> + <!-- Enables SIP on WIFI only --> + <bool name="config_sip_wifi_only">false</bool> </resources> diff --git a/services/java/com/android/server/sip/SipService.java b/services/java/com/android/server/sip/SipService.java index d7747fb59f7e..7e13d653d3bb 100644 --- a/services/java/com/android/server/sip/SipService.java +++ b/services/java/com/android/server/sip/SipService.java @@ -71,6 +71,7 @@ public final class SipService extends ISipService.Stub { private boolean mConnected; private WakeupTimer mTimer; private WifiManager.WifiLock mWifiLock; + private boolean mWifiOnly; // SipProfile URI --> group private Map<String, SipSessionGroupExt> mSipGroups = @@ -99,6 +100,7 @@ public final class SipService extends ISipService.Stub { new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION)); mTimer = new WakeupTimer(context); + mWifiOnly = SipManager.isSipWifiOnly(context); } public synchronized SipProfile[] getListOfProfiles() { @@ -774,6 +776,15 @@ public final class SipService extends ISipService.Stub { String type = netInfo.getTypeName(); NetworkInfo.State state = netInfo.getState(); + if (mWifiOnly && (netInfo.getType() != + ConnectivityManager.TYPE_WIFI)) { + if (DEBUG) { + Log.d(TAG, "Wifi only, other connectivity ignored: " + + type); + } + return; + } + NetworkInfo activeNetInfo = getActiveNetworkInfo(); if (DEBUG) { if (activeNetInfo != null) { diff --git a/voip/java/android/net/sip/SipManager.java b/voip/java/android/net/sip/SipManager.java index 36895cd66ae2..9ee6f34c407e 100644 --- a/voip/java/android/net/sip/SipManager.java +++ b/voip/java/android/net/sip/SipManager.java @@ -97,6 +97,14 @@ public class SipManager { */ } + /** + * Returns true if SIP is only available on WIFI. + */ + public static boolean isSipWifiOnly(Context context) { + return context.getResources().getBoolean( + com.android.internal.R.bool.config_sip_wifi_only); + } + private SipManager() { createSipService(); } |