Snap for 8426163 from b3af60eab5ae65f1303e6dbc914f76da77907cb1 to mainline-tzdata2-release

Change-Id: I28062749893f459375aaad18c050ecb7b8001b82
diff --git a/Android.bp b/Android.bp
index 5295c5e..7f2d193 100644
--- a/Android.bp
+++ b/Android.bp
@@ -12,10 +12,6 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-package {
-    default_applicable_licenses: ["Android-Apache-2.0"],
-}
-
 filegroup {
     name: "opt-net-voip-srcs",
     srcs: [
diff --git a/src/java/android/net/rtp/AudioCodec.java b/src/java/android/net/rtp/AudioCodec.java
index 9cae573..85255c8 100644
--- a/src/java/android/net/rtp/AudioCodec.java
+++ b/src/java/android/net/rtp/AudioCodec.java
@@ -33,9 +33,6 @@
  * </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 3a85bbc..9d96006 100644
--- a/src/java/android/net/rtp/AudioGroup.java
+++ b/src/java/android/net/rtp/AudioGroup.java
@@ -17,10 +17,9 @@
 package android.net.rtp;
 
 import android.annotation.NonNull;
-import android.content.AttributionSource;
+import android.app.ActivityThread;
 import android.content.Context;
 import android.media.AudioManager;
-import android.os.Parcel;
 
 import java.util.HashMap;
 import java.util.Locale;
@@ -64,9 +63,6 @@
  * 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 {
     /**
@@ -118,7 +114,7 @@
 
     /**
      * Creates an empty AudioGroup.
-     * @param context Context the group belongs to
+     * @param context Context used to get package name
      */
     public AudioGroup(@NonNull Context context) {
         mContext = context;
@@ -168,15 +164,11 @@
                 AudioCodec codec = stream.getCodec();
                 String codecSpec = String.format(Locale.US, "%d %s %s", codec.type,
                         codec.rtpmap, codec.fmtp);
-
-                final long id;
-                try (AttributionSource.ScopedParcelState attributionSourceState = mContext
-                        .getAttributionSource().asScopedParcelState()) {
-                    id = nativeAdd(stream.getMode(), stream.getSocket(),
-                            stream.getRemoteAddress().getHostAddress(),
-                            stream.getRemotePort(), codecSpec, stream.getDtmfType(),
-                            attributionSourceState.getParcel());
-                }
+                long id = nativeAdd(stream.getMode(), stream.getSocket(),
+                        stream.getRemoteAddress().getHostAddress(),
+                        stream.getRemotePort(), codecSpec, stream.getDtmfType(),
+                        mContext != null ? mContext.getOpPackageName()
+                                : ActivityThread.currentOpPackageName());
                 mStreams.put(stream, id);
             } catch (NullPointerException e) {
                 throw new IllegalStateException(e);
@@ -184,8 +176,8 @@
         }
     }
 
-    private native long nativeAdd(int mode, int socket, String remoteAddress, int remotePort,
-            String codecSpec, int dtmfType, Parcel attributionSource);
+    private native long nativeAdd(int mode, int socket, String remoteAddress,
+            int remotePort, String codecSpec, int dtmfType, String opPackageName);
 
     // 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 e746e7d..5cd1abc 100644
--- a/src/java/android/net/rtp/AudioStream.java
+++ b/src/java/android/net/rtp/AudioStream.java
@@ -41,8 +41,6 @@
  *
  * @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 ad37455..b9d75cd 100644
--- a/src/java/android/net/rtp/RtpStream.java
+++ b/src/java/android/net/rtp/RtpStream.java
@@ -27,8 +27,6 @@
  *
  * <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 4d70017..363995c 100644
--- a/src/java/android/net/sip/SipAudioCall.java
+++ b/src/java/android/net/sip/SipAudioCall.java
@@ -56,8 +56,6 @@
  * <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 e3f54eb..509728f 100644
--- a/src/java/android/net/sip/SipErrorCode.java
+++ b/src/java/android/net/sip/SipErrorCode.java
@@ -22,8 +22,6 @@
  * {@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 b9cdb12..0339395 100644
--- a/src/java/android/net/sip/SipException.java
+++ b/src/java/android/net/sip/SipException.java
@@ -18,8 +18,6 @@
 
 /**
  * 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 b74b07d..39f66de 100644
--- a/src/java/android/net/sip/SipManager.java
+++ b/src/java/android/net/sip/SipManager.java
@@ -63,8 +63,6 @@
  * <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 6f22e47..14b0334 100644
--- a/src/java/android/net/sip/SipProfile.java
+++ b/src/java/android/net/sip/SipProfile.java
@@ -45,8 +45,6 @@
  * <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 0175e8a..9968cc7 100644
--- a/src/java/android/net/sip/SipRegistrationListener.java
+++ b/src/java/android/net/sip/SipRegistrationListener.java
@@ -18,8 +18,6 @@
 
 /**
  * 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 764871c..edbc66f 100644
--- a/src/java/android/net/sip/SipSession.java
+++ b/src/java/android/net/sip/SipSession.java
@@ -25,8 +25,6 @@
  * <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 325d6b9..b6c8588 100644
--- a/src/jni/rtp/Android.bp
+++ b/src/jni/rtp/Android.bp
@@ -12,10 +12,6 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-package {
-    default_applicable_licenses: ["Android-Apache-2.0"],
-}
-
 cc_library_shared {
     name: "librtp_jni",
     srcs: [
@@ -36,11 +32,8 @@
     ],
 
     shared_libs: [
-        "framework-permission-aidl-cpp",
-        "libandroid_runtime",
         "libaudioclient",
         "libaudiofoundation",
-        "libbinder",
         "libcutils",
         "liblog",
         "libnativehelper",
@@ -49,10 +42,13 @@
     ],
     static_libs: [
         "libgsm",
-        "framework-permission-aidl-cpp",
         "libstagefright_amrnbdec",
         "libstagefright_amrnbenc",
     ],
+    include_dirs: [
+        "frameworks/av/media/libstagefright/codecs/amrnb/enc/src",
+        "frameworks/av/media/libstagefright/codecs/amrnb/dec/src",
+    ],
     cflags: [
         "-fvisibility=hidden",
         "-Wall",
diff --git a/src/jni/rtp/AudioGroup.cpp b/src/jni/rtp/AudioGroup.cpp
index e92e799..51b723d 100644
--- a/src/jni/rtp/AudioGroup.cpp
+++ b/src/jni/rtp/AudioGroup.cpp
@@ -44,8 +44,6 @@
 #include <system/audio.h>
 
 #include <nativehelper/ScopedUtfChars.h>
-#include <android/content/AttributionSourceState.h>
-#include <android_os_Parcel.h>
 
 #include "jni.h"
 #include <nativehelper/JNIHelp.h>
@@ -59,8 +57,6 @@
 
 using namespace android;
 
-using android::content::AttributionSourceState;
-
 int gRandom = -1;
 
 // We use a circular array to implement jitter buffer. The simplest way is doing
@@ -484,7 +480,7 @@
 class AudioGroup
 {
 public:
-    explicit AudioGroup(const AttributionSourceState &attributionSource);
+    explicit AudioGroup(const String16 &opPackageName);
     ~AudioGroup();
     bool set(int sampleRate, int sampleCount);
 
@@ -509,7 +505,7 @@
     int mEventQueue;
     volatile int mDtmfEvent;
 
-    const AttributionSourceState mAttributionSource;
+    String16 mOpPackageName;
 
     int mMode;
     int mSampleRate;
@@ -558,9 +554,9 @@
     sp<DeviceThread> mDeviceThread;
 };
 
-AudioGroup::AudioGroup(const AttributionSourceState &attributionSource)
-        : mAttributionSource(attributionSource)
+AudioGroup::AudioGroup(const String16 &opPackageName)
 {
+    mOpPackageName = opPackageName;
     mMode = ON_HOLD;
     mChain = NULL;
     mEventQueue = -1;
@@ -822,7 +818,7 @@
 
     // Initialize AudioTrack and AudioRecord.
     sp<AudioTrack> track = new AudioTrack();
-    sp<AudioRecord> record = new AudioRecord(mGroup->mAttributionSource);
+    sp<AudioRecord> record = new AudioRecord(mGroup->mOpPackageName);
     // Set caller name so it can be logged in destructor.
     // MediaMetricsConstants.h: AMEDIAMETRICS_PROP_CALLERNAME_VALUE_RTP
     track->setCallerName("rtp");
@@ -855,14 +851,14 @@
     sp<AudioEffect> aec;
     if (mode == ECHO_SUPPRESSION) {
         if (mGroup->platformHasAec()) {
-            aec = new AudioEffect(mGroup->mAttributionSource);
-            aec->set(FX_IID_AEC,
-                     NULL,
-                     0,
-                     0,
-                     0,
-                     record->getSessionId(),
-                     AUDIO_IO_HANDLE_NONE); // record sessionId is sufficient.
+            aec = new AudioEffect(FX_IID_AEC,
+                                    mGroup->mOpPackageName,
+                                    NULL,
+                                    0,
+                                    0,
+                                    0,
+                                    record->getSessionId(),
+                                    AUDIO_IO_HANDLE_NONE); // record sessionId is sufficient.
             status_t status = aec->initCheck();
             if (status == NO_ERROR || status == ALREADY_EXISTS) {
                 aec->setEnabled(true);
@@ -957,7 +953,7 @@
 
 jlong add(JNIEnv *env, jobject thiz, jint mode,
     jint socket, jstring jRemoteAddress, jint remotePort,
-    jstring jCodecSpec, jint dtmfType, jobject jAttributionSource)
+    jstring jCodecSpec, jint dtmfType, jstring opPackageNameStr)
 {
     AudioCodec *codec = NULL;
     AudioStream *stream = NULL;
@@ -985,9 +981,7 @@
         return 0;
     }
 
-    Parcel* parcel = parcelForJavaObject(env, jAttributionSource);
-    AttributionSourceState attributionSource;
-    attributionSource.readFromParcel(parcel);
+    ScopedUtfChars opPackageName(env, opPackageNameStr);
 
     // Create audio codec.
     int codecType = -1;
@@ -1018,7 +1012,7 @@
     group = (AudioGroup *)env->GetLongField(thiz, gNative);
     if (!group) {
         int mode = env->GetIntField(thiz, gMode);
-        group = new AudioGroup(attributionSource);
+        group = new AudioGroup(String16(opPackageName.c_str()));
         if (!group->set(8000, 256) || !group->setMode(mode)) {
             jniThrowException(env, "java/lang/IllegalStateException",
                 "cannot initialize audio group");
@@ -1074,7 +1068,7 @@
 }
 
 JNINativeMethod gMethods[] = {
-    {"nativeAdd", "(IILjava/lang/String;ILjava/lang/String;ILandroid/os/Parcel;)J", (void *)add},
+    {"nativeAdd", "(IILjava/lang/String;ILjava/lang/String;ILjava/lang/String;)J", (void *)add},
     {"nativeRemove", "(J)V", (void *)remove},
     {"nativeSetMode", "(I)V", (void *)setMode},
     {"nativeSendDtmf", "(I)V", (void *)sendDtmf},
@@ -1084,7 +1078,7 @@
 
 int registerAudioGroup(JNIEnv *env)
 {
-    gRandom = open("/dev/urandom", O_RDONLY | O_CLOEXEC);
+    gRandom = open("/dev/urandom", O_RDONLY);
     if (gRandom == -1) {
         ALOGE("urandom: %s", strerror(errno));
         return -1;
@@ -1098,6 +1092,5 @@
         ALOGE("JNI registration failed");
         return -1;
     }
-
     return 0;
 }
diff --git a/src/jni/rtp/GsmCodec.cpp b/src/jni/rtp/GsmCodec.cpp
index ff1acec..4a04bfa 100644
--- a/src/jni/rtp/GsmCodec.cpp
+++ b/src/jni/rtp/GsmCodec.cpp
@@ -16,7 +16,9 @@
 
 #include "AudioCodec.h"
 
+extern "C" {
 #include "gsm.h"
+}
 
 namespace {