Chromium Code Reviews| 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..896a58a73b029f0bbedc07ca6736e6cfe1a2a1fe 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 |
| @@ -22,6 +22,8 @@ import java.util.Timer; |
| import java.util.TimerTask; |
| import org.webrtc.Logging; |
| +import org.chromium.base.ContextUtils; |
| + |
| // WebRtcAudioManager handles tasks that uses android.media.AudioManager. |
| // At construction, storeAudioParameters() is called and it retrieves |
| // fundamental audio parameters like native sample rate and number of channels. |
| @@ -135,7 +137,6 @@ public class WebRtcAudioManager { |
| } |
| private final long nativeAudioManager; |
| - private final Context context; |
| private final AudioManager audioManager; |
| private boolean initialized = false; |
| @@ -156,11 +157,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( |
|
sakal
2017/05/18 07:12:54
Instead of using Chromium ContextUtils, I think we
|
| + Context.AUDIO_SERVICE); |
| if (DEBUG) { |
| WebRtcAudioUtils.logDeviceInfo(TAG); |
| } |
| @@ -224,12 +225,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 +251,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. |