summaryrefslogtreecommitdiffstats
path: root/voip
diff options
context:
space:
mode:
authorHung-ying Tyan <tyanh@google.com>2010-08-27 18:08:19 +0800
committerHung-ying Tyan <tyanh@google.com>2010-09-02 08:10:13 +0800
commit3424c02e6b931a8bbd651ae75217bebd008b2605 (patch)
treef8113a62a05f612a54da4c277661542edbcb9773 /voip
parenta2511da9d65b11be7f59ed3f525f77e85aeb4bef (diff)
downloadframeworks_base-3424c02e6b931a8bbd651ae75217bebd008b2605.zip
frameworks_base-3424c02e6b931a8bbd651ae75217bebd008b2605.tar.gz
frameworks_base-3424c02e6b931a8bbd651ae75217bebd008b2605.tar.bz2
Add software features for SIP and VOIP
and block SipService creation and SIP API if the feature is not available. Change-Id: Icf780af1ac20dda4d8180cea3e5b20e21a8350bc
Diffstat (limited to 'voip')
-rw-r--r--voip/java/android/net/sip/SipManager.java33
1 files changed, 24 insertions, 9 deletions
diff --git a/voip/java/android/net/sip/SipManager.java b/voip/java/android/net/sip/SipManager.java
index 287a13a..40792b9 100644
--- a/voip/java/android/net/sip/SipManager.java
+++ b/voip/java/android/net/sip/SipManager.java
@@ -18,6 +18,7 @@ package android.net.sip;
import android.content.Context;
import android.content.Intent;
+import android.content.pm.PackageManager;
import android.os.IBinder;
import android.os.Looper;
import android.os.RemoteException;
@@ -69,22 +70,36 @@ public class SipManager {
private ISipService mSipService;
/**
- * Creates a manager instance and initializes the background SIP service.
- * Will be removed once the SIP service is integrated into framework.
+ * Gets a manager instance. Returns null if SIP API is not supported.
*
- * @param context context to start the SIP service
- * @return the manager instance
+ * @param context application context for checking if SIP API is supported
+ * @return the manager instance or null if SIP API is not supported
*/
- public static SipManager getInstance(final Context context) {
- final SipManager manager = new SipManager();
- manager.createSipService(context);
- return manager;
+ public static SipManager getInstance(Context context) {
+ return (isApiSupported(context) ? new SipManager() : null);
+ }
+
+ /**
+ * Returns true if the SIP API is supported by the system.
+ */
+ public static boolean isApiSupported(Context context) {
+ return context.getPackageManager().hasSystemFeature(
+ PackageManager.FEATURE_SIP);
+ }
+
+ /**
+ * Returns true if the system supports SIP-based VoIP.
+ */
+ public static boolean isVoipSupported(Context context) {
+ return context.getPackageManager().hasSystemFeature(
+ PackageManager.FEATURE_SIP_VOIP) && isApiSupported(context);
}
private SipManager() {
+ createSipService();
}
- private void createSipService(Context context) {
+ private void createSipService() {
if (mSipService != null) return;
IBinder b = ServiceManager.getService(Context.SIP_SERVICE);
mSipService = ISipService.Stub.asInterface(b);