am 3424c02e: Add software features for SIP and VOIP

Merge commit '3424c02e6b931a8bbd651ae75217bebd008b2605' into gingerbread-plus-aosp

* commit '3424c02e6b931a8bbd651ae75217bebd008b2605':
  Add software features for SIP and VOIP
This commit is contained in:
Hung-ying Tyan
2010-09-01 18:01:31 -07:00
committed by Android Git Automerger
7 changed files with 118 additions and 16 deletions

View File

@@ -49131,6 +49131,28 @@
visibility="public"
>
</field>
<field name="FEATURE_SIP"
type="java.lang.String"
transient="false"
volatile="false"
value="&quot;android.software.sip&quot;"
static="true"
final="true"
deprecated="not deprecated"
visibility="public"
>
</field>
<field name="FEATURE_SIP_VOIP"
type="java.lang.String"
transient="false"
volatile="false"
value="&quot;android.software.sip.voip&quot;"
static="true"
final="true"
deprecated="not deprecated"
visibility="public"
>
</field>
<field name="FEATURE_TELEPHONY"
type="java.lang.String"
transient="false"

View File

@@ -760,7 +760,21 @@ public abstract class PackageManager {
*/
@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.

View File

@@ -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>

View File

@@ -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>

View File

@@ -418,10 +418,13 @@ class ServerThread extends Thread {
}
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 DiskStats Service", e);
Slog.e(TAG, "Failure starting SIP Service", e);
}
}

View File

@@ -53,8 +53,6 @@ import java.util.TimerTask;
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 @@ public final class SipService extends ISipService.Stub {
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();

View File

@@ -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);