Sync Android AppRTCDemo with internal repo.

- Fixed some Lint warnings.
- Switch to OPUS by default.
- Add check to WebSocket connection that public methods are called
on correct thread.

R=jiayl@webrtc.org, wzh@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/36669004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@8032 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
glaznev@webrtc.org
2015-01-09 19:34:06 +00:00
parent 9657265f39
commit 80452d70cb
8 changed files with 96 additions and 64 deletions

View File

@@ -29,8 +29,10 @@ package org.appspot.apprtc.util;
import android.os.Build;
import android.util.Log;
import java.lang.Thread;
/**
* AppRTCUtils provides helper functions for managing thread safety.
*/
public final class AppRTCUtils {
private AppRTCUtils() {

View File

@@ -45,9 +45,12 @@ public class AsyncHttpURLConnection {
private final String message;
private final AsyncHttpEvents events;
/**
* Http requests callbacks.
*/
public interface AsyncHttpEvents {
public void OnHttpError(String errorMessage);
public void OnHttpComplete(String response);
public void onHttpError(String errorMessage);
public void onHttpComplete(String response);
}
public AsyncHttpURLConnection(String method, String url, String message,
@@ -99,18 +102,18 @@ public class AsyncHttpURLConnection {
// Get response.
int responseCode = connection.getResponseCode();
if (responseCode != 200) {
events.OnHttpError("Non-200 response to " + method + " to URL: "
events.onHttpError("Non-200 response to " + method + " to URL: "
+ url + " : " + connection.getHeaderField(null));
return;
}
InputStream responseStream = connection.getInputStream();
String response = drainStream(responseStream);
responseStream.close();
events.OnHttpComplete(response);
events.onHttpComplete(response);
} catch (SocketTimeoutException e) {
events.OnHttpError("HTTP " + method + " to " + url + " timeout");
events.onHttpError("HTTP " + method + " to " + url + " timeout");
} catch (IOException e) {
events.OnHttpError("HTTP " + method + " to " + url + " error: "
events.onHttpError("HTTP " + method + " to " + url + " error: "
+ e.getMessage());
}
}

View File

@@ -82,7 +82,7 @@ public class LooperExecutor extends Thread implements Executor {
return;
}
running = false;
handler.post( new Runnable() {
handler.post(new Runnable() {
@Override
public void run() {
Looper.myLooper().quitSafely();
@@ -91,6 +91,11 @@ public class LooperExecutor extends Thread implements Executor {
});
}
// Checks if current thread is a looper thread.
public boolean checkOnLooperThread() {
return (Thread.currentThread().getId() == threadId);
}
@Override
public synchronized void execute(final Runnable runnable) {
if (!running) {