Android standalone: remove some usages of deprecated APIs and prevent further regressions.

Also:
- Fixed WebRTCDemo UI to say "SwitchToBack" at startup since default camera is front
- Rebuild WebRTCDemo APK when resources/layout/strings change

R=henrike@webrtc.org

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

git-svn-id: http://webrtc.googlecode.com/svn/trunk@4916 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
fischman@webrtc.org 2013-10-03 18:57:48 +00:00
parent 4e65e07e41
commit 6c82e04cee
8 changed files with 25 additions and 26 deletions

View File

@ -12,3 +12,5 @@
# Project target.
target=android-17
java.compilerargs=-Xlint:all -Werror

View File

@ -301,7 +301,7 @@ public class AppRTCClient {
JSONArray mandatoryKeys = mandatoryJSON.names();
if (mandatoryKeys != null) {
for (int i = 0; i < mandatoryKeys.length(); ++i) {
String key = (String) mandatoryKeys.getString(i);
String key = mandatoryKeys.getString(i);
String value = mandatoryJSON.getString(key);
constraints.mandatory.add(
new MediaConstraints.KeyValuePair(key, value));

View File

@ -36,6 +36,7 @@ import android.media.AudioManager;
import android.os.Bundle;
import android.os.PowerManager;
import android.util.Log;
import android.view.WindowManager;
import android.webkit.JavascriptInterface;
import android.widget.EditText;
import android.widget.Toast;
@ -96,10 +97,8 @@ public class AppRTCDemoActivity extends Activity
Thread.setDefaultUncaughtExceptionHandler(
new UnhandledExceptionHandler(this));
PowerManager powerManager = (PowerManager) getSystemService(POWER_SERVICE);
wakeLock = powerManager.newWakeLock(
PowerManager.SCREEN_BRIGHT_WAKE_LOCK, "AppRTCDemo");
wakeLock.acquire();
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
Point displaySize = new Point();
getWindowManager().getDefaultDisplay().getSize(displaySize);
@ -111,9 +110,13 @@ public class AppRTCDemoActivity extends Activity
AudioManager audioManager =
((AudioManager) getSystemService(AUDIO_SERVICE));
audioManager.setMode(audioManager.isWiredHeadsetOn() ?
// TODO(fischman): figure out how to do this Right(tm) and remove the
// suppression.
@SuppressWarnings("deprecation")
boolean isWiredHeadsetOn = audioManager.isWiredHeadsetOn();
audioManager.setMode(isWiredHeadsetOn ?
AudioManager.MODE_IN_CALL : AudioManager.MODE_IN_COMMUNICATION);
audioManager.setSpeakerphoneOn(!audioManager.isWiredHeadsetOn());
audioManager.setSpeakerphoneOn(!isWiredHeadsetOn);
sdpMediaConstraints = new MediaConstraints();
sdpMediaConstraints.mandatory.add(new MediaConstraints.KeyValuePair(

View File

@ -47,7 +47,6 @@ public class ViERenderer {
public static SurfaceView CreateLocalRenderer(Context context) {
SurfaceView localRender = new SurfaceView(context);
g_localRenderer = localRender.getHolder();
g_localRenderer.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
return localRender;
}

View File

@ -50,6 +50,7 @@
'<(PRODUCT_DIR)/lib.java/video_render_module_java.jar',
'<(PRODUCT_DIR)/libwebrtc-video-demo-jni.so',
'<!@(find <(android_webrtc_demo_root)/src -name "*.java")',
'<!@(find <(android_webrtc_demo_root)/res -type f)',
],
'outputs': ['<(PRODUCT_DIR)/WebRTCDemo-debug.apk'],
'action': ['bash', '-ec',

View File

@ -895,6 +895,10 @@ Notice for all the files in this folder.
verbose="${verbose}"
classpathref="project.javac.classpath"
fork="${need.javac.fork}">
<!-- TODO(henrike): uncomment once WebRTCDemo stops using -->
<!-- (deprecated) TabActivity -->
<!-- <compilerarg value="-Xlint:all"/> -->
<!-- <compilerarg value="-Werror"/> -->
<src path="${source.absolute.dir}" />
<src path="${gen.absolute.dir}" />
<src path="${webrtc.modules.dir}/video_capture/android/java" />

View File

@ -20,7 +20,7 @@
<Button android:id="@+id/btSwitchCamera"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/frontCamera"
android:text="@string/backCamera"
android:layout_gravity="bottom"/>
<Button android:id="@+id/btStartStopCall"
android:layout_width="fill_parent"

View File

@ -31,8 +31,6 @@ import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.PowerManager;
import android.os.PowerManager.WakeLock;
import android.util.Log;
import android.view.Display;
import android.view.Gravity;
@ -67,10 +65,9 @@ import java.net.NetworkInterface;
import java.net.SocketException;
import java.util.Enumeration;
/** {@} */
public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
View.OnClickListener,
OnItemSelectedListener {
View.OnClickListener,
OnItemSelectedListener {
private ViEAndroidJavaAPI vieAndroidAPI = null;
// remote renderer
@ -187,8 +184,6 @@ public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
private String webrtcName = "/webrtc";
private String webrtcDebugDir = null;
private WakeLock wakeLock;
private boolean usingFrontCamera = true;
// The orientations (in degrees) of each of the cameras CCW-relative to the
// device, indexed by CameraInfo.CAMERA_FACING_{BACK,FRONT}, and -1
@ -264,17 +259,12 @@ public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
populateCameraOrientations();
PowerManager pm = (PowerManager) this.getSystemService(
Context.POWER_SERVICE);
wakeLock = pm.newWakeLock(
PowerManager.SCREEN_DIM_WAKE_LOCK, TAG);
setContentView(R.layout.tabhost);
IntentFilter receiverFilter = new IntentFilter(Intent.ACTION_HEADSET_PLUG);
@ -502,7 +492,9 @@ public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
AlertDialog alertDialog = new AlertDialog.Builder(this).create();
alertDialog.setTitle("WebRTC Error");
alertDialog.setMessage("Can not init video engine.");
alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
alertDialog.setButton(
DialogInterface.BUTTON_POSITIVE,
"OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
return;
} });
@ -848,12 +840,10 @@ public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
if (viERunning || voERunning) {
stopAll();
startMain();
wakeLock.release(); // release the wake lock
btStartStopCall.setText(R.string.startCall);
} else if (enableVoice || enableVideo){
++numCalls;
startCall();
wakeLock.acquire(); // screen stay on during the call
btStartStopCall.setText(R.string.stopCall);
}
if (AUTO_CALL_RESTART_DELAY_MS > 0) {