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:
parent
770cc380eb
commit
9e3cb336d4
@ -37,6 +37,7 @@ import android.app.AlertDialog;
|
||||
import android.app.FragmentTransaction;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.net.Uri;
|
||||
import android.opengl.GLSurfaceView;
|
||||
import android.os.Bundle;
|
||||
@ -93,6 +94,14 @@ public class CallActivity extends Activity
|
||||
public static final String EXTRA_RUNTIME =
|
||||
"org.appspot.apprtc.RUNTIME";
|
||||
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.
|
||||
private static final int STAT_CALLBACK_PERIOD = 1000;
|
||||
// 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.
|
||||
final Intent intent = getIntent();
|
||||
Uri roomUri = intent.getData();
|
||||
|
@ -418,6 +418,8 @@ public class PeerConnectionClient {
|
||||
// TCP candidates are only useful when connecting to a server that supports
|
||||
// ICE-TCP.
|
||||
rtcConfig.tcpCandidatePolicy = PeerConnection.TcpCandidatePolicy.DISABLED;
|
||||
rtcConfig.bundlePolicy = PeerConnection.BundlePolicy.MAXBUNDLE;
|
||||
rtcConfig.rtcpMuxPolicy = PeerConnection.RtcpMuxPolicy.REQUIRE;
|
||||
|
||||
peerConnection = factory.createPeerConnection(
|
||||
rtcConfig, pcConstraints, pcObserver);
|
||||
|
Loading…
Reference in New Issue
Block a user