Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(37)

Unified Diff: webrtc/modules/audio_device/android/java/src/org/webrtc/voiceengine/WebRtcAudioManager.java

Issue 2894593002: Revert of Removes usage of native base::android::GetApplicationContext() (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 76ec4c5ede1d1bae2fc50b3ef540a92bb9777eb7..24b8ab834051885c3ed6912f40e700f92e14b412 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,7 +20,6 @@
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.
@@ -136,6 +135,7 @@
}
private final long nativeAudioManager;
+ private final Context context;
private final AudioManager audioManager;
private boolean initialized = false;
@@ -156,11 +156,11 @@
private final VolumeLogger volumeLogger;
- WebRtcAudioManager(long nativeAudioManager) {
+ WebRtcAudioManager(Context context, long nativeAudioManager) {
Logging.d(TAG, "ctor" + WebRtcAudioUtils.getThreadInfo());
+ this.context = context;
this.nativeAudioManager = nativeAudioManager;
- audioManager =
- (AudioManager) ContextUtils.getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
+ audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
if (DEBUG) {
WebRtcAudioUtils.logDeviceInfo(TAG);
}
@@ -224,14 +224,12 @@
// Gets the current earpiece state.
private boolean hasEarpiece() {
- return ContextUtils.getApplicationContext().getPackageManager().hasSystemFeature(
- PackageManager.FEATURE_TELEPHONY);
+ return context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEPHONY);
}
// Returns true if low-latency audio output is supported.
private boolean isLowLatencyOutputSupported() {
- return ContextUtils.getApplicationContext().getPackageManager().hasSystemFeature(
- PackageManager.FEATURE_AUDIO_LOW_LATENCY);
+ return context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_AUDIO_LOW_LATENCY);
}
// Returns true if low-latency audio input is supported.
@@ -250,8 +248,7 @@
@TargetApi(23)
private boolean isProAudioSupported() {
return WebRtcAudioUtils.runningOnMarshmallowOrHigher()
- && ContextUtils.getApplicationContext().getPackageManager().hasSystemFeature(
- PackageManager.FEATURE_AUDIO_PRO);
+ && context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_AUDIO_PRO);
}
// Returns the native output sample rate for this device's output stream.

Powered by Google App Engine
This is Rietveld 408576698