AppRTCDemo: check for necessary permissions before starting the call.
Also update PeerConnection.RTCConfiguration values. R=wzh@webrtc.org Review URL: https://webrtc-codereview.appspot.com/56559004 Cr-Commit-Position: refs/heads/master@{#9325}
This commit is contained in:
@@ -37,6 +37,7 @@ import android.app.AlertDialog;
|
|||||||
import android.app.FragmentTransaction;
|
import android.app.FragmentTransaction;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.opengl.GLSurfaceView;
|
import android.opengl.GLSurfaceView;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
@@ -93,6 +94,14 @@ public class CallActivity extends Activity
|
|||||||
public static final String EXTRA_RUNTIME =
|
public static final String EXTRA_RUNTIME =
|
||||||
"org.appspot.apprtc.RUNTIME";
|
"org.appspot.apprtc.RUNTIME";
|
||||||
private static final String TAG = "CallRTCClient";
|
private static final String TAG = "CallRTCClient";
|
||||||
|
|
||||||
|
// List of mandatory application permissions.
|
||||||
|
private static final String[] MANDATORY_PERMISSIONS = {
|
||||||
|
"android.permission.MODIFY_AUDIO_SETTINGS",
|
||||||
|
"android.permission.RECORD_AUDIO",
|
||||||
|
"android.permission.INTERNET"
|
||||||
|
};
|
||||||
|
|
||||||
// Peer connection statistics callback period in ms.
|
// Peer connection statistics callback period in ms.
|
||||||
private static final int STAT_CALLBACK_PERIOD = 1000;
|
private static final int STAT_CALLBACK_PERIOD = 1000;
|
||||||
// Local preview screen position before call is connected.
|
// Local preview screen position before call is connected.
|
||||||
@@ -186,6 +195,16 @@ public class CallActivity extends Activity
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Check for mandatory permissions.
|
||||||
|
for (String permission : MANDATORY_PERMISSIONS) {
|
||||||
|
if (checkCallingOrSelfPermission(permission) != PackageManager.PERMISSION_GRANTED) {
|
||||||
|
logAndToast("Permission " + permission + " is not granted");
|
||||||
|
setResult(RESULT_CANCELED);
|
||||||
|
finish();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Get Intent parameters.
|
// Get Intent parameters.
|
||||||
final Intent intent = getIntent();
|
final Intent intent = getIntent();
|
||||||
Uri roomUri = intent.getData();
|
Uri roomUri = intent.getData();
|
||||||
|
|||||||
@@ -418,6 +418,8 @@ public class PeerConnectionClient {
|
|||||||
// TCP candidates are only useful when connecting to a server that supports
|
// TCP candidates are only useful when connecting to a server that supports
|
||||||
// ICE-TCP.
|
// ICE-TCP.
|
||||||
rtcConfig.tcpCandidatePolicy = PeerConnection.TcpCandidatePolicy.DISABLED;
|
rtcConfig.tcpCandidatePolicy = PeerConnection.TcpCandidatePolicy.DISABLED;
|
||||||
|
rtcConfig.bundlePolicy = PeerConnection.BundlePolicy.MAXBUNDLE;
|
||||||
|
rtcConfig.rtcpMuxPolicy = PeerConnection.RtcpMuxPolicy.REQUIRE;
|
||||||
|
|
||||||
peerConnection = factory.createPeerConnection(
|
peerConnection = factory.createPeerConnection(
|
||||||
rtcConfig, pcConstraints, pcObserver);
|
rtcConfig, pcConstraints, pcObserver);
|
||||||
|
|||||||
Reference in New Issue
Block a user