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

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

Issue 2903253004: Reland of Removes usage of native base::android::GetApplicationContext() (Closed)
Patch Set: Deprecated comment. 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 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.

Powered by Google App Engine
This is Rietveld 408576698