resolved conflicts for merge of 3e4975a5 to master
Change-Id: Icd382fc43c8a1975801ab42eb184b633520149c7
diff --git a/api/current.xml b/api/current.xml
index 3c4e5ff..4add887 100644
--- a/api/current.xml
+++ b/api/current.xml
@@ -55641,6 +55641,28 @@
visibility="public"
>
</field>
+<field name="FEATURE_SIP"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value=""android.software.sip""
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="FEATURE_SIP_VOIP"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value=""android.software.sip.voip""
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
<field name="FEATURE_TELEPHONY"
type="java.lang.String"
transient="false"
diff --git a/core/java/android/content/pm/PackageManager.java b/core/java/android/content/pm/PackageManager.java
index 52010a8..33a1db8 100644
--- a/core/java/android/content/pm/PackageManager.java
+++ b/core/java/android/content/pm/PackageManager.java
@@ -760,7 +760,21 @@
*/
@SdkConstant(SdkConstantType.FEATURE)
public static final String FEATURE_TELEPHONY_GSM = "android.hardware.telephony.gsm";
-
+
+ /**
+ * Feature for {@link #getSystemAvailableFeatures} and
+ * {@link #hasSystemFeature}: The SIP API is enabled on the device.
+ */
+ @SdkConstant(SdkConstantType.FEATURE)
+ public static final String FEATURE_SIP = "android.software.sip";
+
+ /**
+ * Feature for {@link #getSystemAvailableFeatures} and
+ * {@link #hasSystemFeature}: The device supports SIP-based VOIP.
+ */
+ @SdkConstant(SdkConstantType.FEATURE)
+ public static final String FEATURE_SIP_VOIP = "android.software.sip.voip";
+
/**
* Feature for {@link #getSystemAvailableFeatures} and
* {@link #hasSystemFeature}: The device's display has a touch screen.
diff --git a/data/etc/android.software.sip.voip.xml b/data/etc/android.software.sip.voip.xml
new file mode 100644
index 0000000..edd06c1
--- /dev/null
+++ b/data/etc/android.software.sip.voip.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2009 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.
+-->
+
+<!-- This is the standard set of features for devices that support SIP-based VoIP. -->
+<permissions>
+ <feature name="android.software.sip" />
+ <feature name="android.software.sip.voip" />
+</permissions>
diff --git a/data/etc/android.software.sip.xml b/data/etc/android.software.sip.xml
new file mode 100644
index 0000000..d9fcaad
--- /dev/null
+++ b/data/etc/android.software.sip.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2009 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.
+-->
+
+<!-- This is the standard set of features for devices that support the SIP API. -->
+<permissions>
+ <feature name="android.software.sip" />
+</permissions>
diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java
index d44ce97..dffc31c 100644
--- a/services/java/com/android/server/SystemServer.java
+++ b/services/java/com/android/server/SystemServer.java
@@ -431,8 +431,11 @@
}
try {
- Slog.i(TAG, "Sip Service");
- ServiceManager.addService("sip", new SipService(context));
+ SipService sipService = SipService.create(context);
+ if (sipService != null) {
+ Slog.i(TAG, "Sip Service");
+ ServiceManager.addService("sip", sipService);
+ }
} catch (Throwable e) {
Slog.e(TAG, "Failure starting SIP Service", e);
}
diff --git a/services/java/com/android/server/sip/SipService.java b/services/java/com/android/server/sip/SipService.java
index 3dcaff6..626b488 100644
--- a/services/java/com/android/server/sip/SipService.java
+++ b/services/java/com/android/server/sip/SipService.java
@@ -53,8 +53,6 @@
import java.util.TreeSet;
import javax.sip.SipException;
-/**
- */
public final class SipService extends ISipService.Stub {
private static final String TAG = "SipService";
private static final int EXPIRY_TIME = 3600;
@@ -78,7 +76,16 @@
private ConnectivityReceiver mConnectivityReceiver;
- public SipService(Context context) {
+ /**
+ * Creates a {@code SipService} instance. Returns null if SIP API is not
+ * supported.
+ */
+ public static SipService create(Context context) {
+ return (SipManager.isApiSupported(context) ? new SipService(context)
+ : null);
+ }
+
+ private SipService(Context context) {
Log.v(TAG, " service started!");
mContext = context;
mConnectivityReceiver = new ConnectivityReceiver();
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 @@
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 @@
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);