Index: webrtc/modules/audio_device/android/java/src/org/webrtc/voiceengine/WebRtcAudioManager.java |
diff --git a/webrtc/modules/audio_device/android/java/src/org/webrtc/voiceengine/WebRtcAudioManager.java b/webrtc/modules/audio_device/android/java/src/org/webrtc/voiceengine/WebRtcAudioManager.java |
index 24b8ab834051885c3ed6912f40e700f92e14b412..76ec4c5ede1d1bae2fc50b3ef540a92bb9777eb7 100644 |
--- a/webrtc/modules/audio_device/android/java/src/org/webrtc/voiceengine/WebRtcAudioManager.java |
+++ b/webrtc/modules/audio_device/android/java/src/org/webrtc/voiceengine/WebRtcAudioManager.java |
@@ -20,6 +20,7 @@ import android.media.AudioTrack; |
import android.os.Build; |
import java.util.Timer; |
import java.util.TimerTask; |
+import org.webrtc.ContextUtils; |
import org.webrtc.Logging; |
// WebRtcAudioManager handles tasks that uses android.media.AudioManager. |
@@ -135,7 +136,6 @@ public class WebRtcAudioManager { |
} |
private final long nativeAudioManager; |
- private final Context context; |
private final AudioManager audioManager; |
private boolean initialized = false; |
@@ -156,11 +156,11 @@ public class WebRtcAudioManager { |
private final VolumeLogger volumeLogger; |
- WebRtcAudioManager(Context context, long nativeAudioManager) { |
+ WebRtcAudioManager(long nativeAudioManager) { |
Logging.d(TAG, "ctor" + WebRtcAudioUtils.getThreadInfo()); |
- this.context = context; |
this.nativeAudioManager = nativeAudioManager; |
- audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); |
+ audioManager = |
+ (AudioManager) ContextUtils.getApplicationContext().getSystemService(Context.AUDIO_SERVICE); |
if (DEBUG) { |
WebRtcAudioUtils.logDeviceInfo(TAG); |
} |
@@ -224,12 +224,14 @@ public class WebRtcAudioManager { |
// Gets the current earpiece state. |
private boolean hasEarpiece() { |
- return context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEPHONY); |
+ return ContextUtils.getApplicationContext().getPackageManager().hasSystemFeature( |
+ PackageManager.FEATURE_TELEPHONY); |
} |
// Returns true if low-latency audio output is supported. |
private boolean isLowLatencyOutputSupported() { |
- return context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_AUDIO_LOW_LATENCY); |
+ return ContextUtils.getApplicationContext().getPackageManager().hasSystemFeature( |
+ PackageManager.FEATURE_AUDIO_LOW_LATENCY); |
} |
// Returns true if low-latency audio input is supported. |
@@ -248,7 +250,8 @@ public class WebRtcAudioManager { |
@TargetApi(23) |
private boolean isProAudioSupported() { |
return WebRtcAudioUtils.runningOnMarshmallowOrHigher() |
- && context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_AUDIO_PRO); |
+ && ContextUtils.getApplicationContext().getPackageManager().hasSystemFeature( |
+ PackageManager.FEATURE_AUDIO_PRO); |
} |
// Returns the native output sample rate for this device's output stream. |