Annotate rest of WebRTC with @Nullable.
Bug: webrtc:8881 Change-Id: Ic199efa73a0b3b9437df1e8fe5a1814a70380993 Reviewed-on: https://webrtc-review.googlesource.com/64884 Reviewed-by: Paulina Hensman <phensman@webrtc.org> Reviewed-by: Henrik Andreassson <henrika@webrtc.org> Commit-Queue: Sami Kalliomäki <sakal@webrtc.org> Cr-Commit-Position: refs/heads/master@{#22639}
This commit is contained in:
parent
903dc861e7
commit
dc52651911
@ -13,16 +13,17 @@ package org.webrtc.examples.androidnativeapi;
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.widget.Button;
|
||||
import javax.annotation.Nullable;
|
||||
import org.webrtc.ContextUtils;
|
||||
import org.webrtc.EglBase;
|
||||
import org.webrtc.GlRectDrawer;
|
||||
import org.webrtc.SurfaceViewRenderer;
|
||||
|
||||
public class MainActivity extends Activity {
|
||||
private CallClient callClient;
|
||||
private EglBase eglBase;
|
||||
private SurfaceViewRenderer localRenderer;
|
||||
private SurfaceViewRenderer remoteRenderer;
|
||||
private @Nullable CallClient callClient;
|
||||
private @Nullable EglBase eglBase;
|
||||
private @Nullable SurfaceViewRenderer localRenderer;
|
||||
private @Nullable SurfaceViewRenderer remoteRenderer;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstance) {
|
||||
|
||||
@ -12,6 +12,7 @@ package org.webrtc;
|
||||
|
||||
import android.content.Context;
|
||||
import java.util.List;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class UnityUtility {
|
||||
private static final String VIDEO_CAPTURER_THREAD_NAME = "VideoCapturerThread";
|
||||
@ -26,7 +27,7 @@ public class UnityUtility {
|
||||
return Camera2Enumerator.isSupported(ContextUtils.getApplicationContext());
|
||||
}
|
||||
|
||||
private static VideoCapturer createCameraCapturer(CameraEnumerator enumerator) {
|
||||
private static @Nullable VideoCapturer createCameraCapturer(CameraEnumerator enumerator) {
|
||||
final String[] deviceNames = enumerator.getDeviceNames();
|
||||
|
||||
for (String deviceName : deviceNames) {
|
||||
|
||||
@ -19,6 +19,7 @@ import android.media.audiofx.NoiseSuppressor;
|
||||
import android.os.Build;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import javax.annotation.Nullable;
|
||||
import org.webrtc.Logging;
|
||||
|
||||
// This class wraps control of three different platform effects. Supported
|
||||
@ -40,12 +41,12 @@ public class WebRtcAudioEffects {
|
||||
// Contains the available effect descriptors returned from the
|
||||
// AudioEffect.getEffects() call. This result is cached to avoid doing the
|
||||
// slow OS call multiple times.
|
||||
private static Descriptor[] cachedEffects = null;
|
||||
private static @Nullable Descriptor[] cachedEffects = null;
|
||||
|
||||
// Contains the audio effect objects. Created in enable() and destroyed
|
||||
// in release().
|
||||
private AcousticEchoCanceler aec = null;
|
||||
private NoiseSuppressor ns = null;
|
||||
private @Nullable AcousticEchoCanceler aec = null;
|
||||
private @Nullable NoiseSuppressor ns = null;
|
||||
|
||||
// Affects the final state given to the setEnabled() method on each effect.
|
||||
// The default state is set to "disabled" but each effect can also be enabled
|
||||
@ -291,7 +292,7 @@ public class WebRtcAudioEffects {
|
||||
|
||||
// Returns the cached copy of the audio effects array, if available, or
|
||||
// queries the operating system for the list of effects.
|
||||
private static Descriptor[] getAvailableEffects() {
|
||||
private static @Nullable Descriptor[] getAvailableEffects() {
|
||||
if (cachedEffects != null) {
|
||||
return cachedEffects;
|
||||
}
|
||||
|
||||
@ -20,6 +20,7 @@ import android.media.AudioTrack;
|
||||
import android.os.Build;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import javax.annotation.Nullable;
|
||||
import org.webrtc.ContextUtils;
|
||||
import org.webrtc.Logging;
|
||||
|
||||
@ -102,7 +103,7 @@ public class WebRtcAudioManager {
|
||||
private static final int TIMER_PERIOD_IN_SECONDS = 30;
|
||||
|
||||
private final AudioManager audioManager;
|
||||
private Timer timer;
|
||||
private @Nullable Timer timer;
|
||||
|
||||
public VolumeLogger(AudioManager audioManager) {
|
||||
this.audioManager = audioManager;
|
||||
|
||||
@ -19,6 +19,7 @@ import java.lang.System;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import javax.annotation.Nullable;
|
||||
import org.webrtc.Logging;
|
||||
import org.webrtc.ThreadUtils;
|
||||
|
||||
@ -51,12 +52,12 @@ public class WebRtcAudioRecord {
|
||||
|
||||
private final long nativeAudioRecord;
|
||||
|
||||
private WebRtcAudioEffects effects = null;
|
||||
private @Nullable WebRtcAudioEffects effects = null;
|
||||
|
||||
private ByteBuffer byteBuffer;
|
||||
|
||||
private AudioRecord audioRecord = null;
|
||||
private AudioRecordThread audioThread = null;
|
||||
private @Nullable AudioRecord audioRecord = null;
|
||||
private @Nullable AudioRecordThread audioThread = null;
|
||||
|
||||
private static volatile boolean microphoneMute = false;
|
||||
private byte[] emptyBytes;
|
||||
@ -73,7 +74,7 @@ public class WebRtcAudioRecord {
|
||||
void onWebRtcAudioRecordError(String errorMessage);
|
||||
}
|
||||
|
||||
private static WebRtcAudioRecordErrorCallback errorCallback = null;
|
||||
private static @Nullable WebRtcAudioRecordErrorCallback errorCallback = null;
|
||||
|
||||
public static void setErrorCallback(WebRtcAudioRecordErrorCallback errorCallback) {
|
||||
Logging.d(TAG, "Set error callback");
|
||||
@ -123,7 +124,7 @@ public class WebRtcAudioRecord {
|
||||
void onWebRtcAudioRecordSamplesReady(AudioSamples samples);
|
||||
}
|
||||
|
||||
private static WebRtcAudioRecordSamplesReadyCallback audioSamplesReadyCallback = null;
|
||||
private static @Nullable WebRtcAudioRecordSamplesReadyCallback audioSamplesReadyCallback = null;
|
||||
|
||||
public static void setOnAudioSamplesReady(WebRtcAudioRecordSamplesReadyCallback callback) {
|
||||
audioSamplesReadyCallback = callback;
|
||||
|
||||
@ -20,6 +20,7 @@ import android.media.AudioTrack;
|
||||
import android.os.Process;
|
||||
import java.lang.Thread;
|
||||
import java.nio.ByteBuffer;
|
||||
import javax.annotation.Nullable;
|
||||
import org.webrtc.ContextUtils;
|
||||
import org.webrtc.Logging;
|
||||
import org.webrtc.ThreadUtils;
|
||||
@ -79,8 +80,8 @@ public class WebRtcAudioTrack {
|
||||
|
||||
private ByteBuffer byteBuffer;
|
||||
|
||||
private AudioTrack audioTrack = null;
|
||||
private AudioTrackThread audioThread = null;
|
||||
private @Nullable AudioTrack audioTrack = null;
|
||||
private @Nullable AudioTrackThread audioThread = null;
|
||||
|
||||
// Samples to be played are replaced by zeros if |speakerMute| is set to true.
|
||||
// Can be used to ensure that the speaker is fully muted.
|
||||
@ -107,8 +108,8 @@ public class WebRtcAudioTrack {
|
||||
void onWebRtcAudioTrackError(String errorMessage);
|
||||
}
|
||||
|
||||
private static WebRtcAudioTrackErrorCallback errorCallbackOld = null;
|
||||
private static ErrorCallback errorCallback = null;
|
||||
private static @Nullable WebRtcAudioTrackErrorCallback errorCallbackOld = null;
|
||||
private static @Nullable ErrorCallback errorCallback = null;
|
||||
|
||||
@Deprecated
|
||||
public static void setErrorCallback(WebRtcAudioTrackErrorCallback errorCallback) {
|
||||
|
||||
@ -1383,18 +1383,5 @@ if (is_android) {
|
||||
"java/src/org/webrtc/Size.java",
|
||||
"java/src/org/webrtc/ThreadUtils.java",
|
||||
]
|
||||
|
||||
# TODO(crbug.com/824679): Find out why this fails in Chromium
|
||||
if (!build_with_chromium) {
|
||||
javac_args = [
|
||||
"-Xep:ParameterNotNullable:ERROR",
|
||||
"-Xep:FieldMissingNullable:ERROR",
|
||||
"-Xep:ReturnMissingNullable:ERROR",
|
||||
]
|
||||
}
|
||||
|
||||
deps = [
|
||||
"//third_party/jsr-305:jsr_305_javalib",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@ -845,16 +845,9 @@ rtc_android_library("libjingle_peerconnection_java") {
|
||||
]
|
||||
}
|
||||
|
||||
javac_args = [
|
||||
"-Xep:ParameterNotNullable:ERROR",
|
||||
"-Xep:FieldMissingNullable:ERROR",
|
||||
"-Xep:ReturnMissingNullable:ERROR",
|
||||
]
|
||||
|
||||
deps = [
|
||||
"../../modules/audio_device:audio_device_java",
|
||||
"../../rtc_base:base_java",
|
||||
"//third_party/jsr-305:jsr_305_javalib",
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
@ -27,6 +27,7 @@ import android.support.test.filters.MediumTest;
|
||||
import android.support.test.filters.SmallTest;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import javax.annotation.Nullable;
|
||||
import org.chromium.base.test.BaseJUnit4ClassRunner;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
@ -46,7 +47,7 @@ public class Camera2CapturerTest {
|
||||
final LooperThread looperThread;
|
||||
final CountDownLatch openDoneSignal;
|
||||
final Object cameraDeviceLock;
|
||||
CameraDevice cameraDevice; // Guarded by cameraDeviceLock
|
||||
@Nullable CameraDevice cameraDevice; // Guarded by cameraDeviceLock
|
||||
boolean openSucceeded; // Guarded by cameraDeviceLock
|
||||
|
||||
private class LooperThread extends Thread {
|
||||
|
||||
@ -25,6 +25,7 @@ import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import javax.annotation.Nullable;
|
||||
import org.chromium.base.test.BaseJUnit4ClassRunner;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.webrtc.CameraEnumerationAndroid.CaptureFormat;
|
||||
@ -103,7 +104,7 @@ class CameraVideoCapturerTestFixtures {
|
||||
|
||||
static private class FakeCapturerObserver implements CameraVideoCapturer.CapturerObserver {
|
||||
private int framesCaptured = 0;
|
||||
private VideoFrame videoFrame;
|
||||
private @Nullable VideoFrame videoFrame;
|
||||
final private Object frameLock = new Object();
|
||||
final private Object capturerStartLock = new Object();
|
||||
private Boolean capturerStartResult;
|
||||
@ -290,7 +291,7 @@ class CameraVideoCapturerTestFixtures {
|
||||
return cameraEnumerator.createCapturer(name, eventsHandler);
|
||||
}
|
||||
|
||||
public String getNameOfFrontFacingDevice() {
|
||||
public @Nullable String getNameOfFrontFacingDevice() {
|
||||
for (String deviceName : cameraEnumerator.getDeviceNames()) {
|
||||
if (cameraEnumerator.isFrontFacing(deviceName)) {
|
||||
return deviceName;
|
||||
@ -300,7 +301,7 @@ class CameraVideoCapturerTestFixtures {
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getNameOfBackFacingDevice() {
|
||||
public @Nullable String getNameOfBackFacingDevice() {
|
||||
for (String deviceName : cameraEnumerator.getDeviceNames()) {
|
||||
if (cameraEnumerator.isBackFacing(deviceName)) {
|
||||
return deviceName;
|
||||
|
||||
@ -18,6 +18,7 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import javax.annotation.Nullable;
|
||||
import org.chromium.base.test.BaseJUnit4ClassRunner;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@ -51,7 +52,7 @@ public class DefaultVideoEncoderFactoryTest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public VideoEncoder createEncoder(VideoCodecInfo info) {
|
||||
public @Nullable VideoEncoder createEncoder(VideoCodecInfo info) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@ -21,6 +21,7 @@ import java.util.List;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import javax.annotation.Nullable;
|
||||
import org.chromium.base.test.params.BaseJUnit4RunnerDelegate;
|
||||
import org.chromium.base.test.params.ParameterAnnotations.ClassParameter;
|
||||
import org.chromium.base.test.params.ParameterAnnotations.UseRunnerDelegate;
|
||||
@ -118,7 +119,7 @@ public final class HardwareVideoDecoderTest {
|
||||
return new HardwareVideoDecoderFactory(eglContext);
|
||||
}
|
||||
|
||||
private VideoDecoder createDecoder() {
|
||||
private @Nullable VideoDecoder createDecoder() {
|
||||
VideoDecoderFactory factory =
|
||||
createDecoderFactory(useEglContext ? eglBase.getEglBaseContext() : null);
|
||||
return factory.createDecoder(codecType);
|
||||
|
||||
@ -26,6 +26,7 @@ import java.util.List;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import javax.annotation.Nullable;
|
||||
import org.chromium.base.test.params.BaseJUnit4RunnerDelegate;
|
||||
import org.chromium.base.test.params.ParameterAnnotations.ClassParameter;
|
||||
import org.chromium.base.test.params.ParameterAnnotations.UseRunnerDelegate;
|
||||
@ -291,7 +292,7 @@ public class HardwareVideoEncoderTest {
|
||||
eglContext, ENABLE_INTEL_VP8_ENCODER, ENABLE_H264_HIGH_PROFILE);
|
||||
}
|
||||
|
||||
private VideoEncoder createEncoder() {
|
||||
private @Nullable VideoEncoder createEncoder() {
|
||||
VideoEncoderFactory factory =
|
||||
createEncoderFactory(useEglContext ? eglBase.getEglBaseContext() : null);
|
||||
VideoCodecInfo[] supportedCodecs = factory.getSupportedCodecs();
|
||||
|
||||
@ -35,6 +35,7 @@ import android.support.test.annotation.UiThreadTest;
|
||||
import android.support.test.filters.MediumTest;
|
||||
import android.support.test.filters.SmallTest;
|
||||
import android.support.test.rule.UiThreadTestRule;
|
||||
import javax.annotation.Nullable;
|
||||
import org.chromium.base.test.BaseJUnit4ClassRunner;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
@ -147,7 +148,7 @@ public class NetworkMonitorTest {
|
||||
}
|
||||
|
||||
private static final Object lock = new Object();
|
||||
private static Handler uiThreadHandler = null;
|
||||
private static @Nullable Handler uiThreadHandler = null;
|
||||
|
||||
private NetworkMonitorAutoDetect receiver;
|
||||
private MockConnectivityManagerDelegate connectivityDelegate;
|
||||
@ -155,10 +156,11 @@ public class NetworkMonitorTest {
|
||||
|
||||
private static Handler getUiThreadHandler() {
|
||||
synchronized (lock) {
|
||||
if (uiThreadHandler == null) {
|
||||
uiThreadHandler = new Handler(Looper.getMainLooper());
|
||||
Handler handler = uiThreadHandler;
|
||||
if (handler != null) {
|
||||
return handler;
|
||||
}
|
||||
return uiThreadHandler;
|
||||
return uiThreadHandler = new Handler(Looper.getMainLooper());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -34,6 +34,7 @@ import java.util.Queue;
|
||||
import java.util.TreeSet;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import javax.annotation.Nullable;
|
||||
import org.chromium.base.test.BaseJUnit4ClassRunner;
|
||||
import org.chromium.base.test.util.DisabledTest;
|
||||
import org.junit.Before;
|
||||
@ -48,7 +49,7 @@ import org.webrtc.PeerConnection.SignalingState;
|
||||
@RunWith(BaseJUnit4ClassRunner.class)
|
||||
public class PeerConnectionTest {
|
||||
private static final int TIMEOUT_SECONDS = 20;
|
||||
private TreeSet<String> threadsBeforeTest = null;
|
||||
private @Nullable TreeSet<String> threadsBeforeTest = null;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@ -530,8 +531,8 @@ public class PeerConnectionTest {
|
||||
|
||||
private static class SdpObserverLatch implements SdpObserver {
|
||||
private boolean success = false;
|
||||
private SessionDescription sdp = null;
|
||||
private String error = null;
|
||||
private @Nullable SessionDescription sdp = null;
|
||||
private @Nullable String error = null;
|
||||
private CountDownLatch latch = new CountDownLatch(1);
|
||||
|
||||
public SdpObserverLatch() {}
|
||||
@ -572,11 +573,11 @@ public class PeerConnectionTest {
|
||||
return success;
|
||||
}
|
||||
|
||||
public SessionDescription getSdp() {
|
||||
public @Nullable SessionDescription getSdp() {
|
||||
return sdp;
|
||||
}
|
||||
|
||||
public String getError() {
|
||||
public @Nullable String getError() {
|
||||
return error;
|
||||
}
|
||||
}
|
||||
|
||||
@ -21,6 +21,7 @@ import android.support.test.filters.MediumTest;
|
||||
import android.support.test.filters.SmallTest;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import javax.annotation.Nullable;
|
||||
import org.chromium.base.test.BaseJUnit4ClassRunner;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@ -37,7 +38,7 @@ public class SurfaceTextureHelperTest {
|
||||
public float[] transformMatrix;
|
||||
private boolean hasNewFrame = false;
|
||||
// Thread where frames are expected to be received on.
|
||||
private final Thread expectedThread;
|
||||
private final @Nullable Thread expectedThread;
|
||||
|
||||
MockTextureListener() {
|
||||
this.expectedThread = null;
|
||||
|
||||
42
webrtc.gni
42
webrtc.gni
@ -501,11 +501,25 @@ if (is_android) {
|
||||
# Treat warnings as errors.
|
||||
javac_args += [ "-Werror" ]
|
||||
|
||||
# TODO(crbug.com/824679): Find out why this fails in Chromium
|
||||
if (!build_with_chromium) {
|
||||
javac_args += [
|
||||
"-Xep:ParameterNotNullable:ERROR",
|
||||
"-Xep:FieldMissingNullable:ERROR",
|
||||
"-Xep:ReturnMissingNullable:ERROR",
|
||||
]
|
||||
}
|
||||
|
||||
# Add any arguments defined by the invoker.
|
||||
if (defined(invoker.javac_args)) {
|
||||
javac_args += invoker.javac_args
|
||||
}
|
||||
|
||||
if (!defined(deps)) {
|
||||
deps = []
|
||||
}
|
||||
deps += [ "//third_party/jsr-305:jsr_305_javalib" ]
|
||||
|
||||
no_build_hooks = true
|
||||
}
|
||||
}
|
||||
@ -524,6 +538,20 @@ if (is_android) {
|
||||
# Treat warnings as errors.
|
||||
javac_args = [ "-Werror" ]
|
||||
|
||||
# TODO(crbug.com/824679): Find out why this fails in Chromium
|
||||
if (!build_with_chromium) {
|
||||
javac_args += [
|
||||
"-Xep:ParameterNotNullable:ERROR",
|
||||
"-Xep:FieldMissingNullable:ERROR",
|
||||
"-Xep:ReturnMissingNullable:ERROR",
|
||||
]
|
||||
}
|
||||
|
||||
if (!defined(deps)) {
|
||||
deps = []
|
||||
}
|
||||
deps += [ "//third_party/jsr-305:jsr_305_javalib" ]
|
||||
|
||||
no_build_hooks = true
|
||||
}
|
||||
}
|
||||
@ -542,6 +570,20 @@ if (is_android) {
|
||||
# Treat warnings as errors.
|
||||
javac_args = [ "-Werror" ]
|
||||
|
||||
# TODO(crbug.com/824679): Find out why this fails in Chromium
|
||||
if (!build_with_chromium) {
|
||||
javac_args += [
|
||||
"-Xep:ParameterNotNullable:ERROR",
|
||||
"-Xep:FieldMissingNullable:ERROR",
|
||||
"-Xep:ReturnMissingNullable:ERROR",
|
||||
]
|
||||
}
|
||||
|
||||
if (!defined(deps)) {
|
||||
deps = []
|
||||
}
|
||||
deps += [ "//third_party/jsr-305:jsr_305_javalib" ]
|
||||
|
||||
no_build_hooks = true
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user