Remove redundant initializers from WebRTC Java code.
Removes redundant field initializers such as null, 0 and false.
Bug: webrtc:9742
Change-Id: I1e54f6c6000885cf95f7af8e2701875a78445497
Reviewed-on: https://webrtc-review.googlesource.com/99481
Reviewed-by: Henrik Andreassson <henrika@webrtc.org>
Reviewed-by: Artem Titov <titovartem@webrtc.org>
Commit-Queue: Sami Kalliomäki <sakal@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24676}
diff --git a/sdk/android/api/org/webrtc/DataChannel.java b/sdk/android/api/org/webrtc/DataChannel.java
index 6b03409..53ea0d8 100644
--- a/sdk/android/api/org/webrtc/DataChannel.java
+++ b/sdk/android/api/org/webrtc/DataChannel.java
@@ -22,7 +22,7 @@
// Optional unsigned short in WebIDL, -1 means unspecified.
public int maxRetransmits = -1;
public String protocol = "";
- public boolean negotiated = false;
+ public boolean negotiated;
// Optional unsigned short in WebIDL, -1 means unspecified.
public int id = -1;
diff --git a/sdk/android/api/org/webrtc/MediaCodecVideoDecoder.java b/sdk/android/api/org/webrtc/MediaCodecVideoDecoder.java
index aa87cdb..ec65475 100644
--- a/sdk/android/api/org/webrtc/MediaCodecVideoDecoder.java
+++ b/sdk/android/api/org/webrtc/MediaCodecVideoDecoder.java
@@ -21,9 +21,9 @@
import android.view.Surface;
import java.nio.ByteBuffer;
import java.util.ArrayDeque;
-import java.util.HashMap;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Queue;
@@ -156,9 +156,9 @@
private static final int MAX_QUEUED_OUTPUTBUFFERS = 3;
// Active running decoder instance. Set in initDecode() (called from native code)
// and reset to null in release() call.
- @Nullable private static MediaCodecVideoDecoder runningInstance = null;
- @Nullable private static MediaCodecVideoDecoderErrorCallback errorCallback = null;
- private static int codecErrors = 0;
+ @Nullable private static MediaCodecVideoDecoder runningInstance;
+ @Nullable private static MediaCodecVideoDecoderErrorCallback errorCallback;
+ private static int codecErrors;
// List of disabled codec types - can be set from application.
private static Set<String> hwDecoderDisabledTypes = new HashSet<String>();
@Nullable private static EglBase eglBase;
@@ -228,7 +228,7 @@
// The below variables are only used when decoding to a Surface.
@Nullable private TextureListener textureListener;
private int droppedFrames;
- @Nullable private Surface surface = null;
+ @Nullable private Surface surface;
private final Queue<DecodedOutputBuffer> dequeuedSurfaceOutputBuffers =
new ArrayDeque<DecodedOutputBuffer>();
diff --git a/sdk/android/api/org/webrtc/MediaCodecVideoEncoder.java b/sdk/android/api/org/webrtc/MediaCodecVideoEncoder.java
index 5846e70..38054c6 100644
--- a/sdk/android/api/org/webrtc/MediaCodecVideoEncoder.java
+++ b/sdk/android/api/org/webrtc/MediaCodecVideoEncoder.java
@@ -23,8 +23,8 @@
import android.view.Surface;
import java.nio.ByteBuffer;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.Arrays;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -164,9 +164,9 @@
// Active running encoder instance. Set in initEncode() (called from native code)
// and reset to null in release() call.
- @Nullable private static MediaCodecVideoEncoder runningInstance = null;
- @Nullable private static MediaCodecVideoEncoderErrorCallback errorCallback = null;
- private static int codecErrors = 0;
+ @Nullable private static MediaCodecVideoEncoder runningInstance;
+ @Nullable private static MediaCodecVideoEncoderErrorCallback errorCallback;
+ private static int codecErrors;
// List of disabled codec types - can be set from application.
private static Set<String> hwEncoderDisabledTypes = new HashSet<String>();
@Nullable private static EglBase staticEglBase;
@@ -348,7 +348,7 @@
private long lastKeyFrameMs;
// SPS and PPS NALs (Config frame) for H.264.
- @Nullable private ByteBuffer configData = null;
+ @Nullable private ByteBuffer configData;
// MediaCodec error handler - invoked when critical error happens which may prevent
// further use of media codec API. Now it means that one of media codec instances
diff --git a/sdk/android/api/org/webrtc/NetworkMonitorAutoDetect.java b/sdk/android/api/org/webrtc/NetworkMonitorAutoDetect.java
index d8c8344..491e6fa 100644
--- a/sdk/android/api/org/webrtc/NetworkMonitorAutoDetect.java
+++ b/sdk/android/api/org/webrtc/NetworkMonitorAutoDetect.java
@@ -526,7 +526,7 @@
private final Observer observer;
// Network information about a WifiP2p (aka WiFi-Direct) network, or null if no such network is
// connected.
- @Nullable private NetworkInformation wifiP2pNetworkInfo = null;
+ @Nullable private NetworkInformation wifiP2pNetworkInfo;
WifiDirectManagerDelegate(Observer observer, Context context) {
this.context = context;
diff --git a/sdk/android/api/org/webrtc/PeerConnectionFactory.java b/sdk/android/api/org/webrtc/PeerConnectionFactory.java
index 8dd2429..672bd0e 100644
--- a/sdk/android/api/org/webrtc/PeerConnectionFactory.java
+++ b/sdk/android/api/org/webrtc/PeerConnectionFactory.java
@@ -29,7 +29,7 @@
private static final String VIDEO_CAPTURER_THREAD_NAME = "VideoCapturerThread";
private final long nativeFactory;
- private static volatile boolean internalTracerInitialized = false;
+ private static volatile boolean internalTracerInitialized;
@Nullable private static Thread networkThread;
@Nullable private static Thread workerThread;
@Nullable private static Thread signalingThread;
@@ -63,11 +63,11 @@
public static class Builder {
private final Context applicationContext;
private String fieldTrials = "";
- private boolean enableInternalTracer = false;
+ private boolean enableInternalTracer;
private NativeLibraryLoader nativeLibraryLoader = new NativeLibrary.DefaultLoader();
private String nativeLibraryName = "jingle_peerconnection_so";
- @Nullable private Loggable loggable = null;
- @Nullable private Severity loggableSeverity = null;
+ @Nullable private Loggable loggable;
+ @Nullable private Severity loggableSeverity;
Builder(Context applicationContext) {
this.applicationContext = applicationContext;
diff --git a/sdk/android/api/org/webrtc/ScreenCapturerAndroid.java b/sdk/android/api/org/webrtc/ScreenCapturerAndroid.java
index a13f871..2528460 100644
--- a/sdk/android/api/org/webrtc/ScreenCapturerAndroid.java
+++ b/sdk/android/api/org/webrtc/ScreenCapturerAndroid.java
@@ -47,9 +47,9 @@
@Nullable private VirtualDisplay virtualDisplay;
@Nullable private SurfaceTextureHelper surfaceTextureHelper;
@Nullable private CapturerObserver capturerObserver;
- private long numCapturedFrames = 0;
+ private long numCapturedFrames;
@Nullable private MediaProjection mediaProjection;
- private boolean isDisposed = false;
+ private boolean isDisposed;
@Nullable private MediaProjectionManager mediaProjectionManager;
/**
diff --git a/sdk/android/api/org/webrtc/SurfaceEglRenderer.java b/sdk/android/api/org/webrtc/SurfaceEglRenderer.java
index 350a4cb..dfda8cb 100644
--- a/sdk/android/api/org/webrtc/SurfaceEglRenderer.java
+++ b/sdk/android/api/org/webrtc/SurfaceEglRenderer.java
@@ -28,7 +28,7 @@
private RendererCommon.RendererEvents rendererEvents;
private final Object layoutLock = new Object();
- private boolean isRenderingPaused = false;
+ private boolean isRenderingPaused;
private boolean isFirstFrameRendered;
private int rotatedFrameWidth;
private int rotatedFrameHeight;
diff --git a/sdk/android/api/org/webrtc/SurfaceTextureHelper.java b/sdk/android/api/org/webrtc/SurfaceTextureHelper.java
index decdd05..bb67d1f9 100644
--- a/sdk/android/api/org/webrtc/SurfaceTextureHelper.java
+++ b/sdk/android/api/org/webrtc/SurfaceTextureHelper.java
@@ -71,9 +71,9 @@
// These variables are only accessed from the |handler| thread.
@Nullable private VideoSink listener;
// The possible states of this class.
- private boolean hasPendingTexture = false;
- private volatile boolean isTextureInUse = false;
- private boolean isQuitting = false;
+ private boolean hasPendingTexture;
+ private volatile boolean isTextureInUse;
+ private boolean isQuitting;
private int frameRotation;
private int textureWidth;
private int textureHeight;