Remove unnecessary runtime API-level checks.

APIs below level 16 are not supported by WebRTC.

BUG=webrtc:7549
TBR=henrika@webrtc.org

Review-Url: https://codereview.webrtc.org/2848323003
Cr-Commit-Position: refs/heads/master@{#17980}
This commit is contained in:
sakal
2017-05-02 08:33:52 -07:00
committed by Commit bot
parent 80e230239e
commit bee4ff8d82
5 changed files with 8 additions and 42 deletions

View File

@ -10,8 +10,6 @@
package org.appspot.apprtc;
import org.appspot.apprtc.util.AppRTCUtils;
import android.content.Context;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
@ -19,7 +17,7 @@ import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.os.Build;
import android.util.Log;
import org.appspot.apprtc.util.AppRTCUtils;
import org.webrtc.ThreadUtils;
/**
@ -149,10 +147,7 @@ public class AppRTCProximitySensor implements SensorEventListener {
info.append(", power: ").append(proximitySensor.getPower());
info.append(", resolution: ").append(proximitySensor.getResolution());
info.append(", max range: ").append(proximitySensor.getMaximumRange());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
// Added in API level 9.
info.append(", min delay: ").append(proximitySensor.getMinDelay());
}
info.append(", min delay: ").append(proximitySensor.getMinDelay());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) {
// Added in API level 20.
info.append(", type: ").append(proximitySensor.getStringType());

View File

@ -10,8 +10,6 @@
package org.webrtc.voiceengine;
import org.webrtc.Logging;
import android.annotation.TargetApi;
import android.media.audiofx.AcousticEchoCanceler;
import android.media.audiofx.AudioEffect;
@ -19,9 +17,9 @@ import android.media.audiofx.AudioEffect.Descriptor;
import android.media.audiofx.AutomaticGainControl;
import android.media.audiofx.NoiseSuppressor;
import android.os.Build;
import java.util.List;
import java.util.UUID;
import org.webrtc.Logging;
// This class wraps control of three different platform effects. Supported
// effects are: AcousticEchoCanceler (AEC) and NoiseSuppressor (NS).
@ -63,7 +61,7 @@ class WebRtcAudioEffects {
// Note: we're using isAcousticEchoCancelerEffectAvailable() instead of
// AcousticEchoCanceler.isAvailable() to avoid the expensive getEffects()
// OS API call.
return WebRtcAudioUtils.runningOnJellyBeanOrHigher() && isAcousticEchoCancelerEffectAvailable();
return isAcousticEchoCancelerEffectAvailable();
}
// Checks if the device implements Noise Suppression (NS).
@ -72,7 +70,7 @@ class WebRtcAudioEffects {
// Note: we're using isNoiseSuppressorEffectAvailable() instead of
// NoiseSuppressor.isAvailable() to avoid the expensive getEffects()
// OS API call.
return WebRtcAudioUtils.runningOnJellyBeanOrHigher() && isNoiseSuppressorEffectAvailable();
return isNoiseSuppressorEffectAvailable();
}
// Returns true if the device is blacklisted for HW AEC usage.
@ -153,11 +151,6 @@ class WebRtcAudioEffects {
}
static WebRtcAudioEffects create() {
// Return null if VoIP effects (AEC, AGC and NS) are not supported.
if (!WebRtcAudioUtils.runningOnJellyBeanOrHigher()) {
Logging.w(TAG, "API level 16 or higher is required!");
return null;
}
return new WebRtcAudioEffects();
}

View File

@ -229,8 +229,7 @@ public class WebRtcAudioManager {
// Returns true if low-latency audio output is supported.
private boolean isLowLatencyOutputSupported() {
return isOpenSLESSupported()
&& context.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.
@ -341,12 +340,6 @@ public class WebRtcAudioManager {
/ bytesPerFrame;
}
// Returns true if OpenSL ES audio is supported.
private static boolean isOpenSLESSupported() {
// Check for API level 9 or higher, to confirm use of OpenSL ES.
return WebRtcAudioUtils.runningOnGingerBreadOrHigher();
}
// Helper method which throws an exception when an assertion has failed.
private static void assertTrue(boolean condition) {
if (!condition) {

View File

@ -10,16 +10,14 @@
package org.webrtc.voiceengine;
import org.webrtc.Logging;
import android.content.Context;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Process;
import java.lang.Thread;
import java.util.Arrays;
import java.util.List;
import org.webrtc.Logging;
public final class WebRtcAudioUtils {
private static final String TAG = "WebRtcAudioUtils";
@ -129,16 +127,6 @@ public final class WebRtcAudioUtils {
return Arrays.asList(WebRtcAudioUtils.BLACKLISTED_NS_MODELS);
}
public static boolean runningOnGingerBreadOrHigher() {
// November 2010: Android 2.3, API Level 9.
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD;
}
public static boolean runningOnJellyBeanOrHigher() {
// June 2012: Android 4.1. API Level 16.
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN;
}
public static boolean runningOnJellyBeanMR1OrHigher() {
// November 2012: Android 4.2. API Level 17.
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1;

View File

@ -17,7 +17,6 @@ import android.os.Build;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.SystemClock;
import java.nio.ByteBuffer;
import java.nio.FloatBuffer;
import java.util.concurrent.Callable;
@ -259,9 +258,7 @@ public class SurfaceTextureHelper {
final float[] transformMatrix = new float[16];
surfaceTexture.getTransformMatrix(transformMatrix);
final long timestampNs = (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH)
? surfaceTexture.getTimestamp()
: TimeUnit.MILLISECONDS.toNanos(SystemClock.elapsedRealtime());
final long timestampNs = surfaceTexture.getTimestamp();
listener.onTextureFrameAvailable(oesTextureId, transformMatrix, timestampNs);
}