diff options
author | Amit Mahajan <amitmahajan@google.com> | 2019-09-12 12:30:32 -0700 |
---|---|---|
committer | Amit Mahajan <amitmahajan@google.com> | 2019-11-01 21:11:06 +0000 |
commit | 569835cd826f881e25e83f06dc6d9d98f2a5489a (patch) | |
tree | d97a54e72949294cde1f4fb6482130ac4cb8b3e6 | |
parent | 8cb93893ecec6dc409ff23e61b09cc2ba1dc0249 (diff) | |
download | voip-569835cd826f881e25e83f06dc6d9d98f2a5489a.tar.gz |
Remove usage of ActivityThread.
Test: basic sanity
Bug: 140872785
Merged-in: Ie42532e4227af21390771641d9236f7838903f6c
Change-Id: Ie42532e4227af21390771641d9236f7838903f6c
(cherry picked from commit a84007e1573981069d1c45d404bc2e10955563ff)
-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(); |