Skip to content

Commit

Permalink
incoming voip call permission check
Browse files Browse the repository at this point in the history
  • Loading branch information
imndx committed Aug 8, 2019
1 parent 1a632d9 commit 6ccb56b
Showing 1 changed file with 18 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import android.view.WindowManager.LayoutParams;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentManager;
Expand Down Expand Up @@ -98,11 +99,12 @@ public void onCreate(Bundle savedInstanceState) {
ButterKnife.bind(this);

// Check for mandatory permissions.
for (String permission : MANDATORY_PERMISSIONS) {
if (checkCallingOrSelfPermission(permission) != PackageManager.PERMISSION_GRANTED) {
setResult(RESULT_CANCELED);
finish();
return;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
for (String permission : MANDATORY_PERMISSIONS) {
if (checkCallingOrSelfPermission(permission) != PackageManager.PERMISSION_GRANTED) {
requestPermissions(MANDATORY_PERMISSIONS, 100);
break;
}
}
}

Expand All @@ -122,6 +124,17 @@ public void onCreate(Bundle savedInstanceState) {
}
}

@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
for (int result : grantResults) {
if (result != PackageManager.PERMISSION_GRANTED) {
Toast.makeText(this, "需要录音和摄像头权限,才能进行语音通话", Toast.LENGTH_SHORT).show();
finish();
return;
}
}
}

private AVEngineKit.CallSessionCallback currentCallback;

private void initFromFloatView() {
Expand Down

0 comments on commit 6ccb56b

Please sign in to comment.