summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2021-03-13 02:06:44 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2021-03-13 02:06:44 +0000
commit3d7a8f198db82160b2c638d725005b3db5ffe99a (patch)
tree4eec8f627bccae6ce9251408f58520da90462776
parent277b2d0e52b97b6c9ba726ebb958cbd889433915 (diff)
parent07672253a416c0bcaf1e0d61455e7c9ca47a8915 (diff)
downloadvoip-3d7a8f198db82160b2c638d725005b3db5ffe99a.tar.gz
Snap for 7205268 from 07672253a416c0bcaf1e0d61455e7c9ca47a8915 to sc-release
Change-Id: Ie48c2ad84e3f94fd13a9ec0fbe5e25f9753652a1
-rw-r--r--src/java/android/net/rtp/AudioCodec.java3
-rw-r--r--src/java/android/net/rtp/AudioGroup.java15
-rw-r--r--src/java/android/net/rtp/AudioStream.java2
-rw-r--r--src/java/android/net/rtp/RtpStream.java2
-rw-r--r--src/java/android/net/sip/SipAudioCall.java2
-rw-r--r--src/java/android/net/sip/SipErrorCode.java2
-rw-r--r--src/java/android/net/sip/SipException.java2
-rw-r--r--src/java/android/net/sip/SipManager.java2
-rw-r--r--src/java/android/net/sip/SipProfile.java2
-rw-r--r--src/java/android/net/sip/SipRegistrationListener.java2
-rw-r--r--src/java/android/net/sip/SipSession.java2
-rw-r--r--src/jni/rtp/Android.bp1
-rw-r--r--src/jni/rtp/AudioGroup.cpp59
13 files changed, 81 insertions, 15 deletions
diff --git a/src/java/android/net/rtp/AudioCodec.java b/src/java/android/net/rtp/AudioCodec.java
index 85255c8..9cae573 100644
--- a/src/java/android/net/rtp/AudioCodec.java
+++ b/src/java/android/net/rtp/AudioCodec.java
@@ -33,6 +33,9 @@ import java.util.Arrays;
* </pre>
*
* @see AudioStream
+ *
+ * @deprecated {@link android.net.sip.SipManager} and associated classes are no longer
+ * supported and should not be used as the basis of future VOIP apps.
*/
public class AudioCodec {
/**
diff --git a/src/java/android/net/rtp/AudioGroup.java b/src/java/android/net/rtp/AudioGroup.java
index 9d96006..c186125 100644
--- a/src/java/android/net/rtp/AudioGroup.java
+++ b/src/java/android/net/rtp/AudioGroup.java
@@ -16,10 +16,12 @@
package android.net.rtp;
+import static android.media.permission.PermissionUtil.myIdentity;
+
import android.annotation.NonNull;
-import android.app.ActivityThread;
import android.content.Context;
import android.media.AudioManager;
+import android.media.permission.Identity;
import java.util.HashMap;
import java.util.Locale;
@@ -63,6 +65,9 @@ import java.util.Map;
* the AudioGroups is in use.</p>
*
* @see AudioStream
+ *
+ * @deprecated {@link android.net.sip.SipManager} and associated classes are no longer supported and
+ * should not be used as the basis of future VOIP apps.
*/
public class AudioGroup {
/**
@@ -114,7 +119,7 @@ public class AudioGroup {
/**
* Creates an empty AudioGroup.
- * @param context Context used to get package name
+ * @param context Context the group belongs to
*/
public AudioGroup(@NonNull Context context) {
mContext = context;
@@ -164,11 +169,11 @@ public class AudioGroup {
AudioCodec codec = stream.getCodec();
String codecSpec = String.format(Locale.US, "%d %s %s", codec.type,
codec.rtpmap, codec.fmtp);
+
long id = nativeAdd(stream.getMode(), stream.getSocket(),
stream.getRemoteAddress().getHostAddress(),
stream.getRemotePort(), codecSpec, stream.getDtmfType(),
- mContext != null ? mContext.getOpPackageName()
- : ActivityThread.currentOpPackageName());
+ myIdentity(mContext));
mStreams.put(stream, id);
} catch (NullPointerException e) {
throw new IllegalStateException(e);
@@ -177,7 +182,7 @@ public class AudioGroup {
}
private native long nativeAdd(int mode, int socket, String remoteAddress,
- int remotePort, String codecSpec, int dtmfType, String opPackageName);
+ int remotePort, String codecSpec, int dtmfType, Identity identity);
// Package-private method used by AudioStream.join().
synchronized void remove(AudioStream stream) {
diff --git a/src/java/android/net/rtp/AudioStream.java b/src/java/android/net/rtp/AudioStream.java
index 5cd1abc..e746e7d 100644
--- a/src/java/android/net/rtp/AudioStream.java
+++ b/src/java/android/net/rtp/AudioStream.java
@@ -41,6 +41,8 @@ import java.net.SocketException;
*
* @see RtpStream
* @see AudioGroup
+ * @deprecated {@link android.net.sip.SipManager} and associated classes are no longer supported and
+ * should not be used as the basis of future VOIP apps.
*/
public class AudioStream extends RtpStream {
private AudioCodec mCodec;
diff --git a/src/java/android/net/rtp/RtpStream.java b/src/java/android/net/rtp/RtpStream.java
index b9d75cd..ad37455 100644
--- a/src/java/android/net/rtp/RtpStream.java
+++ b/src/java/android/net/rtp/RtpStream.java
@@ -27,6 +27,8 @@ import java.net.SocketException;
*
* <p class="note">Using this class requires
* {@link android.Manifest.permission#INTERNET} permission.</p>
+ * @deprecated {@link android.net.sip.SipManager} and associated classes are no longer supported and
+ * should not be used as the basis of future VOIP apps.
*/
public class RtpStream {
/**
diff --git a/src/java/android/net/sip/SipAudioCall.java b/src/java/android/net/sip/SipAudioCall.java
index 363995c..4d70017 100644
--- a/src/java/android/net/sip/SipAudioCall.java
+++ b/src/java/android/net/sip/SipAudioCall.java
@@ -56,6 +56,8 @@ import java.net.UnknownHostException;
* <a href="{@docRoot}guide/topics/network/sip.html">Session Initiation Protocol</a>
* developer guide.</p>
* </div>
+ * @deprecated {@link android.net.sip.SipManager} and associated classes are no longer supported and
+ * should not be used as the basis of future VOIP apps.
*/
public class SipAudioCall {
private static final String LOG_TAG = SipAudioCall.class.getSimpleName();
diff --git a/src/java/android/net/sip/SipErrorCode.java b/src/java/android/net/sip/SipErrorCode.java
index 509728f..e3f54eb 100644
--- a/src/java/android/net/sip/SipErrorCode.java
+++ b/src/java/android/net/sip/SipErrorCode.java
@@ -22,6 +22,8 @@ package android.net.sip;
* {@link SipSession.Listener#onError onError()},
* {@link SipSession.Listener#onCallChangeFailed onCallChangeFailed()} and
* {@link SipSession.Listener#onRegistrationFailed onRegistrationFailed()}.
+ * @deprecated {@link android.net.sip.SipManager} and associated classes are no longer supported and
+ * should not be used as the basis of future VOIP apps.
*/
public class SipErrorCode {
/** Not an error. */
diff --git a/src/java/android/net/sip/SipException.java b/src/java/android/net/sip/SipException.java
index 0339395..b9cdb12 100644
--- a/src/java/android/net/sip/SipException.java
+++ b/src/java/android/net/sip/SipException.java
@@ -18,6 +18,8 @@ package android.net.sip;
/**
* Indicates a general SIP-related exception.
+ * @deprecated {@link android.net.sip.SipManager} and associated classes are no longer supported and
+ * should not be used as the basis of future VOIP apps.
*/
public class SipException extends Exception {
public SipException() {
diff --git a/src/java/android/net/sip/SipManager.java b/src/java/android/net/sip/SipManager.java
index 39f66de..b74b07d 100644
--- a/src/java/android/net/sip/SipManager.java
+++ b/src/java/android/net/sip/SipManager.java
@@ -63,6 +63,8 @@ import java.util.List;
* <a href="{@docRoot}guide/topics/network/sip.html">Session Initiation Protocol</a>
* developer guide.</p>
* </div>
+ * @deprecated {@link android.net.sip.SipManager} and associated classes are no longer supported and
+ * should not be used as the basis of future VOIP apps.
*/
public class SipManager {
/**
diff --git a/src/java/android/net/sip/SipProfile.java b/src/java/android/net/sip/SipProfile.java
index 14b0334..6f22e47 100644
--- a/src/java/android/net/sip/SipProfile.java
+++ b/src/java/android/net/sip/SipProfile.java
@@ -45,6 +45,8 @@ import javax.sip.address.URI;
* <a href="{@docRoot}guide/topics/network/sip.html">Session Initiation Protocol</a>
* developer guide.</p>
* </div>
+ * @deprecated {@link android.net.sip.SipManager} and associated classes are no longer supported and
+ * should not be used as the basis of future VOIP apps.
*/
public class SipProfile implements Parcelable, Serializable, Cloneable {
private static final long serialVersionUID = 1L;
diff --git a/src/java/android/net/sip/SipRegistrationListener.java b/src/java/android/net/sip/SipRegistrationListener.java
index 9968cc7..0175e8a 100644
--- a/src/java/android/net/sip/SipRegistrationListener.java
+++ b/src/java/android/net/sip/SipRegistrationListener.java
@@ -18,6 +18,8 @@ package android.net.sip;
/**
* Listener for SIP registration events.
+ * @deprecated {@link android.net.sip.SipManager} and associated classes are no longer supported and
+ * should not be used as the basis of future VOIP apps.
*/
public interface SipRegistrationListener {
/**
diff --git a/src/java/android/net/sip/SipSession.java b/src/java/android/net/sip/SipSession.java
index edbc66f..764871c 100644
--- a/src/java/android/net/sip/SipSession.java
+++ b/src/java/android/net/sip/SipSession.java
@@ -25,6 +25,8 @@ import android.telephony.Rlog;
* <p>You can get a {@link SipSession} from {@link SipManager} with {@link
* SipManager#createSipSession createSipSession()} (when initiating calls) or {@link
* SipManager#getSessionFor getSessionFor()} (when receiving calls).</p>
+ * @deprecated {@link android.net.sip.SipManager} and associated classes are no longer supported and
+ * should not be used as the basis of future VOIP apps.
*/
public final class SipSession {
private static final String TAG = "SipSession";
diff --git a/src/jni/rtp/Android.bp b/src/jni/rtp/Android.bp
index a1497f9..3469960 100644
--- a/src/jni/rtp/Android.bp
+++ b/src/jni/rtp/Android.bp
@@ -43,6 +43,7 @@ cc_library_shared {
"libnativehelper",
"libstagefright_amrnb_common",
"libutils",
+ "media_permission-aidl-cpp",
],
static_libs: [
"libgsm",
diff --git a/src/jni/rtp/AudioGroup.cpp b/src/jni/rtp/AudioGroup.cpp
index 5f9cae8..e57b7f7 100644
--- a/src/jni/rtp/AudioGroup.cpp
+++ b/src/jni/rtp/AudioGroup.cpp
@@ -57,8 +57,17 @@ namespace {
using namespace android;
+using media::permission::Identity;
+
int gRandom = -1;
+static struct {
+ jfieldID fieldUid; // Identity.uid
+ jfieldID fieldPid; // Identity.pid
+ jfieldID fieldPackageName; // Identity.packageName
+ jfieldID fieldAttributionTag; // Identity.attributionTag
+} javaIdentityFields;
+
// We use a circular array to implement jitter buffer. The simplest way is doing
// a modulo operation on the index while accessing the array. However modulo can
// be expensive on some platforms, such as ARM. Thus we round up the size of the
@@ -480,7 +489,7 @@ void AudioStream::decode(int tick)
class AudioGroup
{
public:
- explicit AudioGroup(const String16 &opPackageName);
+ explicit AudioGroup(const Identity &identity);
~AudioGroup();
bool set(int sampleRate, int sampleCount);
@@ -505,7 +514,7 @@ private:
int mEventQueue;
volatile int mDtmfEvent;
- String16 mOpPackageName;
+ Identity mIdentity;
int mMode;
int mSampleRate;
@@ -554,9 +563,9 @@ private:
sp<DeviceThread> mDeviceThread;
};
-AudioGroup::AudioGroup(const String16 &opPackageName)
+AudioGroup::AudioGroup(const Identity &identity)
{
- mOpPackageName = opPackageName;
+ mIdentity = identity;
mMode = ON_HOLD;
mChain = NULL;
mEventQueue = -1;
@@ -818,7 +827,7 @@ bool AudioGroup::DeviceThread::threadLoop()
// Initialize AudioTrack and AudioRecord.
sp<AudioTrack> track = new AudioTrack();
- sp<AudioRecord> record = new AudioRecord(mGroup->mOpPackageName);
+ sp<AudioRecord> record = new AudioRecord(mGroup->mIdentity);
// Set caller name so it can be logged in destructor.
// MediaMetricsConstants.h: AMEDIAMETRICS_PROP_CALLERNAME_VALUE_RTP
track->setCallerName("rtp");
@@ -851,7 +860,7 @@ bool AudioGroup::DeviceThread::threadLoop()
sp<AudioEffect> aec;
if (mode == ECHO_SUPPRESSION) {
if (mGroup->platformHasAec()) {
- aec = new AudioEffect(mGroup->mOpPackageName);
+ aec = new AudioEffect(mGroup->mIdentity);
aec->set(FX_IID_AEC,
NULL,
0,
@@ -953,7 +962,7 @@ static jfieldID gMode;
jlong add(JNIEnv *env, jobject thiz, jint mode,
jint socket, jstring jRemoteAddress, jint remotePort,
- jstring jCodecSpec, jint dtmfType, jstring opPackageNameStr)
+ jstring jCodecSpec, jint dtmfType, jobject jIdentity)
{
AudioCodec *codec = NULL;
AudioStream *stream = NULL;
@@ -981,7 +990,25 @@ jlong add(JNIEnv *env, jobject thiz, jint mode,
return 0;
}
- ScopedUtfChars opPackageName(env, opPackageNameStr);
+ Identity identity;
+ identity.uid = env->GetIntField(jIdentity, javaIdentityFields.fieldUid);
+ identity.pid = env->GetIntField(jIdentity, javaIdentityFields.fieldPid);
+ jstring packageNameStr = static_cast<jstring>(
+ env->GetObjectField(jIdentity, javaIdentityFields.fieldPackageName));
+ if (packageNameStr == NULL) {
+ identity.packageName = std::nullopt;
+ } else {
+ identity.packageName = std::optional<std::string>(
+ std::string(ScopedUtfChars(env, packageNameStr).c_str()));
+ }
+ jstring attributionTagStr = static_cast<jstring>(
+ env->GetObjectField(jIdentity, javaIdentityFields.fieldAttributionTag));
+ if (attributionTagStr == NULL) {
+ identity.attributionTag = std::nullopt;
+ } else {
+ identity.attributionTag = std::optional<std::string>(
+ std::string(ScopedUtfChars(env, attributionTagStr).c_str()));
+ }
// Create audio codec.
int codecType = -1;
@@ -1012,7 +1039,7 @@ jlong add(JNIEnv *env, jobject thiz, jint mode,
group = (AudioGroup *)env->GetLongField(thiz, gNative);
if (!group) {
int mode = env->GetIntField(thiz, gMode);
- group = new AudioGroup(String16(opPackageName.c_str()));
+ group = new AudioGroup(identity);
if (!group->set(8000, 256) || !group->setMode(mode)) {
jniThrowException(env, "java/lang/IllegalStateException",
"cannot initialize audio group");
@@ -1068,7 +1095,7 @@ void sendDtmf(JNIEnv *env, jobject thiz, jint event)
}
JNINativeMethod gMethods[] = {
- {"nativeAdd", "(IILjava/lang/String;ILjava/lang/String;ILjava/lang/String;)J", (void *)add},
+ {"nativeAdd", "(IILjava/lang/String;ILjava/lang/String;ILandroid/media/permission/Identity;)J", (void *)add},
{"nativeRemove", "(J)V", (void *)remove},
{"nativeSetMode", "(I)V", (void *)setMode},
{"nativeSendDtmf", "(I)V", (void *)sendDtmf},
@@ -1092,5 +1119,17 @@ int registerAudioGroup(JNIEnv *env)
ALOGE("JNI registration failed");
return -1;
}
+
+ // Get the Identity class and fields
+ jclass identityClass = env->FindClass("android/media/permission/Identity");
+ javaIdentityFields.fieldUid =
+ env->GetFieldID(identityClass, "uid", "I");
+ javaIdentityFields.fieldPid =
+ env->GetFieldID(identityClass, "pid", "I");
+ javaIdentityFields.fieldPackageName =
+ env->GetFieldID(identityClass, "packageName", "Ljava/lang/String;");
+ javaIdentityFields.fieldAttributionTag =
+ env->GetFieldID(identityClass, "attributionTag", "Ljava/lang/String;");
+
return 0;
}