mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-18 03:48:08 +00:00
Reload video devices after camera permission granted to ensure to be able to capture & send video right after
This commit is contained in:
parent
6fe6d516cb
commit
69c795fc29
6 changed files with 45 additions and 0 deletions
|
|
@ -638,6 +638,11 @@ public class LinphoneActivity extends LinphoneGenericActivity
|
|||
if (permissions[i].compareTo(Manifest.permission.READ_CONTACTS) == 0
|
||||
|| permissions[i].compareTo(Manifest.permission.WRITE_CONTACTS) == 0)
|
||||
readContactsI = i;
|
||||
|
||||
if (permissions[i].equals(Manifest.permission.CAMERA)
|
||||
&& grantResults[i] == PackageManager.PERMISSION_GRANTED) {
|
||||
LinphoneUtils.reloadVideoDevices();
|
||||
}
|
||||
}
|
||||
|
||||
if (readContactsI >= 0
|
||||
|
|
|
|||
|
|
@ -406,6 +406,10 @@ public class AssistantActivity extends ThemableActivity
|
|||
+ (grantResults[i] == PackageManager.PERMISSION_GRANTED
|
||||
? "granted"
|
||||
: "denied"));
|
||||
if (permissions[i].equals(Manifest.permission.CAMERA)
|
||||
&& grantResults[i] == PackageManager.PERMISSION_GRANTED) {
|
||||
LinphoneUtils.reloadVideoDevices();
|
||||
}
|
||||
}
|
||||
|
||||
switch (requestCode) {
|
||||
|
|
|
|||
|
|
@ -526,6 +526,7 @@ public class CallActivity extends LinphoneGenericActivity
|
|||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
LinphoneUtils.reloadVideoDevices();
|
||||
acceptCallUpdate(
|
||||
grantResults[0] == PackageManager.PERMISSION_GRANTED);
|
||||
}
|
||||
|
|
@ -536,6 +537,7 @@ public class CallActivity extends LinphoneGenericActivity
|
|||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
LinphoneUtils.reloadVideoDevices();
|
||||
disableVideo(grantResults[0] != PackageManager.PERMISSION_GRANTED);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -319,6 +319,10 @@ public class CallIncomingActivity extends LinphoneGenericActivity {
|
|||
+ (grantResults[i] == PackageManager.PERMISSION_GRANTED
|
||||
? "granted"
|
||||
: "denied"));
|
||||
if (permissions[i].equals(Manifest.permission.CAMERA)
|
||||
&& grantResults[i] == PackageManager.PERMISSION_GRANTED) {
|
||||
LinphoneUtils.reloadVideoDevices();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -298,6 +298,10 @@ public class CallOutgoingActivity extends LinphoneGenericActivity implements OnC
|
|||
+ (grantResults[i] == PackageManager.PERMISSION_GRANTED
|
||||
? "granted"
|
||||
: "denied"));
|
||||
if (permissions[i].equals(Manifest.permission.CAMERA)
|
||||
&& grantResults[i] == PackageManager.PERMISSION_GRANTED) {
|
||||
LinphoneUtils.reloadVideoDevices();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,6 +65,7 @@ import org.linphone.core.Factory;
|
|||
import org.linphone.core.LogCollectionState;
|
||||
import org.linphone.core.ProxyConfig;
|
||||
import org.linphone.core.tools.Log;
|
||||
import org.linphone.mediastream.video.capture.hwconf.AndroidCameraConfiguration;
|
||||
import org.linphone.settings.LinphonePreferences;
|
||||
|
||||
/** Helpers. */
|
||||
|
|
@ -272,6 +273,31 @@ public final class LinphoneUtils {
|
|||
return true;
|
||||
}
|
||||
|
||||
public static void reloadVideoDevices() {
|
||||
Core core = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||
if (core == null) return;
|
||||
|
||||
Log.i("[Utils] Reloading camera");
|
||||
core.reloadVideoDevices();
|
||||
|
||||
boolean useFrontCam = LinphonePreferences.instance().useFrontCam();
|
||||
int camId = 0;
|
||||
AndroidCameraConfiguration.AndroidCamera[] cameras =
|
||||
AndroidCameraConfiguration.retrieveCameras();
|
||||
for (AndroidCameraConfiguration.AndroidCamera androidCamera : cameras) {
|
||||
if (androidCamera.frontFacing == useFrontCam) {
|
||||
camId = androidCamera.id;
|
||||
break;
|
||||
}
|
||||
}
|
||||
String[] devices = core.getVideoDevicesList();
|
||||
if (camId >= devices.length) {
|
||||
camId = 0;
|
||||
}
|
||||
String newDevice = devices[camId];
|
||||
core.setVideoDevice(newDevice);
|
||||
}
|
||||
|
||||
public static String getDisplayableUsernameFromAddress(String sipAddress) {
|
||||
String username = sipAddress;
|
||||
Core lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue