Android: Fix warnings

TBR=sakal@webrtc.org

Bug: webrtc:6597,webrtc:8534
Change-Id: I39f96d9e0e6d604051b1cc13368dd44fc82b30b0
Reviewed-on: https://webrtc-review.googlesource.com/23622
Reviewed-by: Magnus Jedvert <magjed@webrtc.org>
Commit-Queue: Magnus Jedvert <magjed@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#20719}
This commit is contained in:
Magnus Jedvert
2017-11-16 16:53:12 +01:00
committed by Commit Bot
parent df0822b102
commit 6062f372c7
19 changed files with 107 additions and 115 deletions

View File

@ -19,7 +19,7 @@ import org.webrtc.IceCandidate;
import org.webrtc.PeerConnection;
import org.webrtc.SessionDescription;
import java.util.LinkedList;
import java.util.ArrayList;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.regex.Matcher;
@ -233,7 +233,7 @@ public class DirectRTCClient implements AppRTCClient, TCPChannelClient.TCPChanne
SignalingParameters parameters = new SignalingParameters(
// Ice servers are not needed for direct connections.
new LinkedList<>(),
new ArrayList<>(),
isServer, // Server side acts as the initiator on direct connections.
null, // clientId
null, // wssUrl
@ -269,7 +269,7 @@ public class DirectRTCClient implements AppRTCClient, TCPChannelClient.TCPChanne
SignalingParameters parameters = new SignalingParameters(
// Ice servers are not needed for direct connections.
new LinkedList<>(),
new ArrayList<>(),
false, // This code will only be run on the client side. So, we are not the initiator.
null, // clientId
null, // wssUrl

View File

@ -22,7 +22,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.ArrayList;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;
@ -139,7 +139,7 @@ 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.
private LinkedList<IceCandidate> queuedRemoteCandidates;
private List<IceCandidate> queuedRemoteCandidates;
private PeerConnectionEvents events;
private boolean isInitiator;
private SessionDescription localSdp; // either offer or answer SDP
@ -603,7 +603,7 @@ public class PeerConnectionClient {
Log.d(TAG, "Create peer connection.");
Log.d(TAG, "PCConstraints: " + pcConstraints.toString());
queuedRemoteCandidates = new LinkedList<>();
queuedRemoteCandidates = new ArrayList<>();
if (videoCallEnabled) {
factory.setVideoHwAccelerationOptions(

View File

@ -15,8 +15,9 @@ import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.LinkedList;
import java.util.ArrayList;
import java.util.Scanner;
import java.util.List;
import org.appspot.apprtc.AppRTCClient.SignalingParameters;
import org.appspot.apprtc.util.AsyncHttpURLConnection;
import org.appspot.apprtc.util.AsyncHttpURLConnection.AsyncHttpEvents;
@ -82,7 +83,7 @@ public class RoomParametersFetcher {
private void roomHttpResponseParse(String response) {
Log.d(TAG, "Room response: " + response);
try {
LinkedList<IceCandidate> iceCandidates = null;
List<IceCandidate> iceCandidates = null;
SessionDescription offerSdp = null;
JSONObject roomJson = new JSONObject(response);
@ -99,7 +100,7 @@ public class RoomParametersFetcher {
String wssPostUrl = roomJson.getString("wss_post_url");
boolean initiator = (roomJson.getBoolean("is_initiator"));
if (!initiator) {
iceCandidates = new LinkedList<>();
iceCandidates = new ArrayList<>();
String messagesString = roomJson.getString("messages");
JSONArray messages = new JSONArray(messagesString);
for (int i = 0; i < messages.length(); ++i) {
@ -124,7 +125,7 @@ public class RoomParametersFetcher {
Log.d(TAG, "WSS url: " + wssUrl);
Log.d(TAG, "WSS POST url: " + wssPostUrl);
LinkedList<PeerConnection.IceServer> iceServers =
List<PeerConnection.IceServer> iceServers =
iceServersFromPCConfigJSON(roomJson.getString("pc_config"));
boolean isTurnPresent = false;
for (PeerConnection.IceServer server : iceServers) {
@ -138,7 +139,7 @@ public class RoomParametersFetcher {
}
// Request TURN servers.
if (!isTurnPresent && !roomJson.optString("ice_server_url").isEmpty()) {
LinkedList<PeerConnection.IceServer> turnServers =
List<PeerConnection.IceServer> turnServers =
requestTurnServers(roomJson.getString("ice_server_url"));
for (PeerConnection.IceServer turnServer : turnServers) {
Log.d(TAG, "TurnServer: " + turnServer);
@ -158,9 +159,9 @@ public class RoomParametersFetcher {
// Requests & returns a TURN ICE Server based on a request URL. Must be run
// off the main thread!
private LinkedList<PeerConnection.IceServer> requestTurnServers(String url)
private List<PeerConnection.IceServer> requestTurnServers(String url)
throws IOException, JSONException {
LinkedList<PeerConnection.IceServer> turnServers = new LinkedList<>();
List<PeerConnection.IceServer> turnServers = new ArrayList<>();
Log.d(TAG, "Request TURN from: " + url);
HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
connection.setDoOutput(true);
@ -198,11 +199,11 @@ public class RoomParametersFetcher {
// Return the list of ICE servers described by a WebRTCPeerConnection
// configuration string.
private LinkedList<PeerConnection.IceServer> iceServersFromPCConfigJSON(String pcConfig)
private List<PeerConnection.IceServer> iceServersFromPCConfigJSON(String pcConfig)
throws JSONException {
JSONObject json = new JSONObject(pcConfig);
JSONArray servers = json.getJSONArray("iceServers");
LinkedList<PeerConnection.IceServer> ret = new LinkedList<>();
List<PeerConnection.IceServer> ret = new ArrayList<>();
for (int i = 0; i < servers.length(); ++i) {
JSONObject server = servers.getJSONObject(i);
String url = server.getString("urls");
@ -218,7 +219,7 @@ public class RoomParametersFetcher {
// Return the contents of an InputStream as a String.
private static String drainStream(InputStream in) {
Scanner s = new Scanner(in).useDelimiter("\\A");
Scanner s = new Scanner(in, "UTF-8").useDelimiter("\\A");
return s.hasNext() ? s.next() : "";
}
}

View File

@ -17,7 +17,8 @@ import de.tavendo.autobahn.WebSocketConnection;
import de.tavendo.autobahn.WebSocketException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.LinkedList;
import java.util.ArrayList;
import java.util.List;
import org.appspot.apprtc.util.AsyncHttpURLConnection;
import org.appspot.apprtc.util.AsyncHttpURLConnection.AsyncHttpEvents;
import org.json.JSONException;
@ -48,7 +49,7 @@ public class WebSocketChannelClient {
private boolean closeEvent;
// WebSocket send queue. Messages are added to the queue when WebSocket
// client is not registered and are consumed in register() call.
private final LinkedList<String> wsSendQueue;
private final List<String> wsSendQueue = new ArrayList<>();
/**
* Possible WebSocket connection states.
@ -70,7 +71,6 @@ public class WebSocketChannelClient {
this.events = events;
roomID = null;
clientID = null;
wsSendQueue = new LinkedList<>();
state = WebSocketConnectionState.NEW;
}

View File

@ -108,7 +108,7 @@ public class AsyncHttpURLConnection {
// Return the contents of an InputStream as a String.
private static String drainStream(InputStream in) {
Scanner s = new Scanner(in).useDelimiter("\\A");
Scanner s = new Scanner(in, "UTF-8").useDelimiter("\\A");
return s.hasNext() ? s.next() : "";
}
}