Annotate AppRTCMobile with @Nulllable.

Bug: webrtc:8881
Change-Id: I32390b1e2586415757f0453b60d35b23160d2862
Reviewed-on: https://webrtc-review.googlesource.com/63641
Reviewed-by: Paulina Hensman <phensman@webrtc.org>
Commit-Queue: Sami Kalliomäki <sakal@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22580}
This commit is contained in:
Sami Kalliomäki
2018-03-22 13:42:50 +01:00
committed by Commit Bot
parent 6a4d411023
commit 06e363a6e6
13 changed files with 79 additions and 9 deletions

View File

@ -106,12 +106,19 @@ if (is_android) {
"androidapp/src/org/appspot/apprtc/util/AsyncHttpURLConnection.java",
]
javac_args = [
"-Xep:ParameterNotNullable:ERROR",
"-Xep:FieldMissingNullable:ERROR",
"-Xep:ReturnMissingNullable:ERROR",
]
deps = [
":AppRTCMobile_resources",
"../rtc_base:base_java",
"../sdk/android:libjingle_peerconnection_java",
"../sdk/android:libjingle_peerconnection_metrics_default_java",
"androidapp/third_party/autobanh:autobanh_java",
"//third_party/jsr-305:jsr_305_javalib",
]
}

View File

@ -24,6 +24,7 @@ import android.util.Log;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import javax.annotation.Nullable;
import org.appspot.apprtc.util.AppRTCUtils;
import org.webrtc.ThreadUtils;
@ -57,8 +58,10 @@ public class AppRTCAudioManager {
}
private final Context apprtcContext;
@Nullable
private AudioManager audioManager;
@Nullable
private AudioManagerEvents audioManagerEvents;
private AudioManagerState amState;
private int savedAudioMode = AudioManager.MODE_INVALID;
@ -90,6 +93,7 @@ public class AppRTCAudioManager {
// relative to the view screen of a device and can therefore be used to
// assist device switching (close to ear <=> use headset earpiece if
// available, far from ear <=> use speaker phone).
@Nullable
private AppRTCProximitySensor proximitySensor = null;
// Handles all tasks related to Bluetooth headset devices.
@ -103,6 +107,7 @@ public class AppRTCAudioManager {
private BroadcastReceiver wiredHeadsetReceiver;
// Callback method for changes in audio focus.
@Nullable
private AudioManager.OnAudioFocusChangeListener audioFocusChangeListener;
/**

View File

@ -24,6 +24,7 @@ import android.media.AudioManager;
import android.os.Handler;
import android.os.Looper;
import android.os.Process;
import javax.annotation.Nullable;
import android.util.Log;
import java.util.List;
import java.util.Set;
@ -64,14 +65,18 @@ public class AppRTCBluetoothManager {
private final Context apprtcContext;
private final AppRTCAudioManager apprtcAudioManager;
@Nullable
private final AudioManager audioManager;
private final Handler handler;
int scoConnectionAttempts;
private State bluetoothState;
private final BluetoothProfile.ServiceListener bluetoothServiceListener;
@Nullable
private BluetoothAdapter bluetoothAdapter;
@Nullable
private BluetoothHeadset bluetoothHeadset;
@Nullable
private BluetoothDevice bluetoothDevice;
private final BroadcastReceiver bluetoothHeadsetReceiver;
@ -390,6 +395,7 @@ public class AppRTCBluetoothManager {
/**
* Stubs for test mocks.
*/
@Nullable
protected AudioManager getAudioManager(Context context) {
return (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
}

View File

@ -16,6 +16,7 @@ import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.os.Build;
import javax.annotation.Nullable;
import android.util.Log;
import org.appspot.apprtc.util.AppRTCUtils;
import org.webrtc.ThreadUtils;
@ -39,6 +40,7 @@ public class AppRTCProximitySensor implements SensorEventListener {
private final Runnable onSensorStateListener;
private final SensorManager sensorManager;
@Nullable
private Sensor proximitySensor = null;
private boolean lastStateReportIsNear = false;

View File

@ -36,6 +36,7 @@ import java.lang.RuntimeException;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import javax.annotation.Nullable;
import org.appspot.apprtc.AppRTCAudioManager.AudioDevice;
import org.appspot.apprtc.AppRTCAudioManager.AudioManagerEvents;
import org.appspot.apprtc.AppRTCClient.RoomConnectionParameters;
@ -168,18 +169,26 @@ public class CallActivity extends Activity implements AppRTCClient.SignalingEven
private final ProxyRenderer remoteProxyRenderer = new ProxyRenderer();
private final ProxyVideoSink localProxyVideoSink = new ProxyVideoSink();
@Nullable
private PeerConnectionClient peerConnectionClient = null;
@Nullable
private AppRTCClient appRtcClient;
@Nullable
private SignalingParameters signalingParameters;
@Nullable
private AppRTCAudioManager audioManager = null;
@Nullable
private SurfaceViewRenderer pipRenderer;
@Nullable
private SurfaceViewRenderer fullscreenRenderer;
@Nullable
private VideoFileRenderer videoFileRenderer;
private final List<VideoRenderer.Callbacks> remoteRenderers = new ArrayList<>();
private Toast logToast;
private boolean commandLineRun;
private boolean activityRunning;
private RoomConnectionParameters roomConnectionParameters;
@Nullable
private PeerConnectionParameters peerConnectionParameters;
private boolean iceConnected;
private boolean isError;
@ -440,7 +449,7 @@ public class CallActivity extends Activity implements AppRTCClient.SignalingEven
return getIntent().getBooleanExtra(EXTRA_CAPTURETOTEXTURE_ENABLED, false);
}
private VideoCapturer createCameraCapturer(CameraEnumerator enumerator) {
private @Nullable VideoCapturer createCameraCapturer(CameraEnumerator enumerator) {
final String[] deviceNames = enumerator.getDeviceNames();
// First, try to find front facing camera
@ -473,7 +482,7 @@ public class CallActivity extends Activity implements AppRTCClient.SignalingEven
}
@TargetApi(21)
private VideoCapturer createScreenCapturer() {
private @Nullable VideoCapturer createScreenCapturer() {
if (mediaProjectionPermissionResultCode != Activity.RESULT_OK) {
reportError("User didn't give permission to capture the screen.");
return null;
@ -710,7 +719,7 @@ public class CallActivity extends Activity implements AppRTCClient.SignalingEven
});
}
private VideoCapturer createVideoCapturer() {
private @Nullable VideoCapturer createVideoCapturer() {
final VideoCapturer videoCapturer;
String videoFileAsCamera = getIntent().getStringExtra(EXTRA_VIDEO_FILE_AS_CAMERA);
if (videoFileAsCamera != null) {

View File

@ -31,6 +31,7 @@ import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import javax.annotation.Nullable;
/**
* Simple CPU monitor. The caller creates a CpuMonitor object which can then
@ -91,6 +92,7 @@ class CpuMonitor {
// CPU frequency in percentage from maximum.
private final MovingAverage frequencyScale;
@Nullable
private ScheduledExecutorService executor;
private long lastStatLogTimeMs;
private long[] cpuFreqMax;
@ -101,6 +103,7 @@ class CpuMonitor {
private String[] maxPath;
private String[] curPath;
private double[] curFreqScales;
@Nullable
private ProcStat lastProcStat;
private static class ProcStat {
@ -485,7 +488,7 @@ class CpuMonitor {
* of /proc/stat.
*/
@SuppressWarnings("StringSplitter")
private ProcStat readProcStat() {
private @Nullable ProcStat readProcStat() {
long userTime = 0;
long systemTime = 0;
long idleTime = 0;

View File

@ -10,6 +10,7 @@
package org.appspot.apprtc;
import javax.annotation.Nullable;
import android.util.Log;
import org.json.JSONArray;
@ -53,6 +54,7 @@ public class DirectRTCClient implements AppRTCClient, TCPChannelClient.TCPChanne
private final ExecutorService executor;
private final SignalingEvents events;
@Nullable
private TCPChannelClient tcpClient;
private RoomConnectionParameters connectionParameters;

View File

@ -34,6 +34,7 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.annotation.Nullable;
import org.appspot.apprtc.AppRTCClient.SignalingParameters;
import org.appspot.apprtc.RecordedAudioToFileController;
import org.webrtc.AudioSource;
@ -121,10 +122,15 @@ public class PeerConnectionClient {
private final EglBase rootEglBase;
private final Context appContext;
@Nullable
private PeerConnectionFactory factory;
@Nullable
private PeerConnection peerConnection;
@Nullable
PeerConnectionFactory.Options options = null;
@Nullable
private AudioSource audioSource;
@Nullable
private VideoSource videoSource;
private boolean videoCallEnabled;
private boolean preferIsac;
@ -132,7 +138,9 @@ public class PeerConnectionClient {
private boolean videoCapturerStopped;
private boolean isError;
private Timer statsTimer;
@Nullable
private VideoSink localRender;
@Nullable
private List<VideoRenderer.Callbacks> remoteRenders;
private SignalingParameters signalingParameters;
private int videoWidth;
@ -144,26 +152,38 @@ public class PeerConnectionClient {
// Queued remote ICE candidates are consumed only after both local and
// remote descriptions are set. Similarly local ICE candidates are sent to
// remote peer after both local and remote description are set.
@Nullable
private List<IceCandidate> queuedRemoteCandidates;
@Nullable
private PeerConnectionEvents events;
private boolean isInitiator;
@Nullable
private SessionDescription localSdp; // either offer or answer SDP
@Nullable
private MediaStream mediaStream;
@Nullable
private VideoCapturer videoCapturer;
// enableVideo is set to true if video should be rendered and sent.
private boolean renderVideo;
@Nullable
private VideoTrack localVideoTrack;
@Nullable
private VideoTrack remoteVideoTrack;
@Nullable
private RtpSender localVideoSender;
// enableAudio is set to true if audio should be sent.
private boolean enableAudio;
@Nullable
private AudioTrack localAudioTrack;
@Nullable
private DataChannel dataChannel;
private boolean dataChannelEnabled;
// Enable RtcEventLog.
@Nullable
private RtcEventLog rtcEventLog;
// Implements the WebRtcAudioRecordSamplesReadyCallback interface and writes
// recorded audio samples to an output file.
@Nullable
private RecordedAudioToFileController saveRecordedAudioToFile = null;
/**
@ -950,7 +970,7 @@ public class PeerConnectionClient {
});
}
public void setVideoMaxBitrate(final Integer maxBitrateKbps) {
public void setVideoMaxBitrate(@Nullable final Integer maxBitrateKbps) {
executor.execute(new Runnable() {
@Override
public void run() {
@ -994,6 +1014,7 @@ public class PeerConnectionClient {
});
}
@Nullable
private AudioTrack createAudioTrack() {
audioSource = factory.createAudioSource(audioConstraints);
localAudioTrack = factory.createAudioTrack(AUDIO_TRACK_ID, audioSource);
@ -1001,6 +1022,7 @@ public class PeerConnectionClient {
return localAudioTrack;
}
@Nullable
private VideoTrack createVideoTrack(VideoCapturer capturer) {
videoSource = factory.createVideoSource(capturer);
capturer.startCapture(videoWidth, videoHeight, videoFps);
@ -1024,7 +1046,7 @@ public class PeerConnectionClient {
}
// Returns the remote VideoTrack, assuming there is only one.
private VideoTrack getRemoteVideoTrack() {
private @Nullable VideoTrack getRemoteVideoTrack() {
for (RtpTransceiver transceiver : peerConnection.getTransceivers()) {
MediaStreamTrack track = transceiver.getReceiver().track();
if (track instanceof VideoTrack) {
@ -1125,7 +1147,8 @@ public class PeerConnectionClient {
return buffer.toString();
}
private static String movePayloadTypesToFront(List<String> preferredPayloadTypes, String mLine) {
private static @Nullable String movePayloadTypesToFront(
List<String> preferredPayloadTypes, String mLine) {
// The format of the media description line should be: m=<media> <port> <proto> <fmt> ...
final List<String> origLineParts = Arrays.asList(mLine.split(" "));
if (origLineParts.size() <= 3) {

View File

@ -12,6 +12,7 @@ package org.appspot.apprtc;
import android.media.AudioFormat;
import android.os.Environment;
import javax.annotation.Nullable;
import android.util.Log;
import java.io.File;
import java.io.FileOutputStream;
@ -33,6 +34,7 @@ public class RecordedAudioToFileController implements SamplesReadyCallback {
private final Object lock = new Object();
private final ExecutorService executor;
@Nullable
private OutputStream rawAudioFileOutputStream = null;
private long fileSizeInBytes = 0;

View File

@ -10,6 +10,7 @@
package org.appspot.apprtc;
import javax.annotation.Nullable;
import android.util.Log;
import java.io.BufferedReader;
import java.io.IOException;
@ -123,7 +124,9 @@ public class TCPChannelClient {
private abstract class TCPSocket extends Thread {
// Lock for editing out and rawSocket
protected final Object rawSocketLock;
@Nullable
private PrintWriter out;
@Nullable
private Socket rawSocket;
/**
@ -131,6 +134,7 @@ public class TCPChannelClient {
*
* @return Socket connection, null if connection failed.
*/
@Nullable
public abstract Socket connect();
/** Returns true if sockets is a server rawSocket. */
@ -263,6 +267,7 @@ public class TCPChannelClient {
private class TCPSocketServer extends TCPSocket {
// Server socket is also guarded by rawSocketLock.
@Nullable
private ServerSocket serverSocket;
final private InetAddress address;
@ -274,6 +279,7 @@ public class TCPChannelClient {
}
/** Opens a listening socket and waits for a connection. */
@Nullable
@Override
public Socket connect() {
Log.d(TAG, "Listening on [" + address.getHostAddress() + "]:" + Integer.toString(port));
@ -335,6 +341,7 @@ public class TCPChannelClient {
}
/** Connects to the peer. */
@Nullable
@Override
public Socket connect() {
Log.d(TAG, "Connecting to [" + address.getHostAddress() + "]:" + Integer.toString(port));

View File

@ -11,6 +11,7 @@
package org.appspot.apprtc;
import android.os.Handler;
import javax.annotation.Nullable;
import android.util.Log;
import de.tavendo.autobahn.WebSocket.WebSocketConnectionObserver;
import de.tavendo.autobahn.WebSocketConnection;
@ -39,7 +40,9 @@ public class WebSocketChannelClient {
private WebSocketConnection ws;
private String wsServerUrl;
private String postServerUrl;
@Nullable
private String roomID;
@Nullable
private String clientID;
private WebSocketConnectionState state;
// Do not remove this member variable. If this is removed, the observer gets garbage collected and

View File

@ -10,6 +10,7 @@
package org.appspot.apprtc;
import javax.annotation.Nullable;
import org.appspot.apprtc.RoomParametersFetcher.RoomParametersFetcherEvents;
import org.appspot.apprtc.WebSocketChannelClient.WebSocketChannelEvents;
import org.appspot.apprtc.WebSocketChannelClient.WebSocketConnectionState;
@ -380,7 +381,7 @@ public class WebSocketRTCClient implements AppRTCClient, WebSocketChannelEvents
// Send SDP or ICE candidate to a room server.
private void sendPostMessage(
final MessageType messageType, final String url, final String message) {
final MessageType messageType, final String url, @Nullable final String message) {
String logInfo = url;
if (message != null) {
logInfo += ". Message: " + message;