diff options
author | Amit Mahajan <amitmahajan@google.com> | 2019-11-01 23:58:34 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2019-11-01 23:58:34 +0000 |
commit | 956b72449b9b88a547f91209b138589c89f3a16a (patch) | |
tree | d97a54e72949294cde1f4fb6482130ac4cb8b3e6 | |
parent | 8cb93893ecec6dc409ff23e61b09cc2ba1dc0249 (diff) | |
parent | 569835cd826f881e25e83f06dc6d9d98f2a5489a (diff) | |
download | voip-956b72449b9b88a547f91209b138589c89f3a16a.tar.gz |
Merge "Remove usage of ActivityThread."
-rw-r--r-- | src/java/android/net/rtp/AudioGroup.java | 17 | ||||
-rw-r--r-- | src/java/android/net/sip/SipAudioCall.java | 2 |
2 files changed, 17 insertions, 2 deletions
diff --git a/src/java/android/net/rtp/AudioGroup.java b/src/java/android/net/rtp/AudioGroup.java index 15390d3..b9b70f4 100644 --- a/src/java/android/net/rtp/AudioGroup.java +++ b/src/java/android/net/rtp/AudioGroup.java @@ -16,7 +16,9 @@ package android.net.rtp; +import android.annotation.Nullable; import android.app.ActivityThread; +import android.content.Context; import android.media.AudioManager; import java.util.HashMap; @@ -96,14 +98,27 @@ public class AudioGroup { private int mMode = MODE_ON_HOLD; private long mNative; + private Context mContext; static { System.loadLibrary("rtp_jni"); } /** * Creates an empty AudioGroup. + * @deprecated Replaced by {@link #AudioGroup(Context)} */ + @Deprecated public AudioGroup() { + this(null); + } + + /** + * Creates an empty AudioGroup. + * @param context Context used to get package name. If context is null, app ops checks will + * fail and as a result {@link AudioStream#join(AudioGroup)} may fail. + */ + public AudioGroup(@Nullable Context context) { + mContext = context; mStreams = new HashMap<AudioStream, Long>(); } @@ -153,7 +168,7 @@ public class AudioGroup { long id = nativeAdd(stream.getMode(), stream.getSocket(), stream.getRemoteAddress().getHostAddress(), stream.getRemotePort(), codecSpec, stream.getDtmfType(), - ActivityThread.currentOpPackageName()); + mContext != null ? mContext.getOpPackageName() : null); mStreams.put(stream, id); } catch (NullPointerException e) { throw new IllegalStateException(e); diff --git a/src/java/android/net/sip/SipAudioCall.java b/src/java/android/net/sip/SipAudioCall.java index ea943e9..f1eb35b 100644 --- a/src/java/android/net/sip/SipAudioCall.java +++ b/src/java/android/net/sip/SipAudioCall.java @@ -1081,7 +1081,7 @@ public class SipAudioCall { // don't create an AudioGroup here; doing so will fail if // there's another AudioGroup out there that's active } else { - if (audioGroup == null) audioGroup = new AudioGroup(); + if (audioGroup == null) audioGroup = new AudioGroup(mContext); stream.join(audioGroup); } setAudioGroupMode(); |