|
|
|
@ -1103,33 +1103,34 @@ protocol CallServiceObserver: class {
|
|
|
|
|
func setHasLocalVideo(hasLocalVideo: Bool) {
|
|
|
|
|
AssertIsOnMainThread()
|
|
|
|
|
|
|
|
|
|
let authStatus = AVCaptureDevice.authorizationStatus(forMediaType:AVMediaTypeVideo)
|
|
|
|
|
switch authStatus {
|
|
|
|
|
case .notDetermined:
|
|
|
|
|
Logger.debug("\(TAG) authStatus: AVAuthorizationStatusNotDetermined")
|
|
|
|
|
break
|
|
|
|
|
case .restricted:
|
|
|
|
|
Logger.debug("\(TAG) authStatus: AVAuthorizationStatusRestricted")
|
|
|
|
|
break
|
|
|
|
|
case .denied:
|
|
|
|
|
Logger.debug("\(TAG) authStatus: AVAuthorizationStatusDenied")
|
|
|
|
|
break
|
|
|
|
|
case .authorized:
|
|
|
|
|
Logger.debug("\(TAG) authStatus: AVAuthorizationStatusAuthorized")
|
|
|
|
|
break
|
|
|
|
|
guard let frontmostViewController = UIApplication.shared.frontmostViewController else {
|
|
|
|
|
owsFail("\(TAG) could not identify frontmostViewController in \(#function)")
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
frontmostViewController.ows_ask(forCameraPermissions: { [weak self] in
|
|
|
|
|
// Success callback; camera permissions are granted.
|
|
|
|
|
|
|
|
|
|
guard let strongSelf = self else {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
strongSelf.setHasLocalVideoWithCameraPermissions(hasLocalVideo: hasLocalVideo)
|
|
|
|
|
|
|
|
|
|
}, failureCallback: {
|
|
|
|
|
// Failed callback; camera permissions are _NOT_ granted.
|
|
|
|
|
|
|
|
|
|
// We don't need to worry about the user granting or remoting this permission
|
|
|
|
|
// during a call while the app is in the background, because changing this
|
|
|
|
|
// permission kills the app.
|
|
|
|
|
if authStatus != .authorized {
|
|
|
|
|
|
|
|
|
|
OWSAlerts.showAlert(withTitle: NSLocalizedString("MISSING_CAMERA_PERMISSION_TITLE", comment: "Alert title when camera is not authorized"),
|
|
|
|
|
message: NSLocalizedString("MISSING_CAMERA_PERMISSION_MESSAGE", comment: "Alert body when camera is not authorized"))
|
|
|
|
|
|
|
|
|
|
return
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private func setHasLocalVideoWithCameraPermissions(hasLocalVideo: Bool) {
|
|
|
|
|
AssertIsOnMainThread()
|
|
|
|
|
|
|
|
|
|
guard let call = self.call else {
|
|
|
|
|
// This should never happen; return to a known good state.
|
|
|
|
|
owsFail("\(TAG) call was unexpectedly nil in \(#function)")
|
|
|
|
@ -1434,7 +1435,7 @@ protocol CallServiceObserver: class {
|
|
|
|
|
AssertIsOnMainThread()
|
|
|
|
|
|
|
|
|
|
if case CallError.assertionError(description: let description) = error {
|
|
|
|
|
owsFail(description)
|
|
|
|
|
Logger.error(description)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if let failedCall = failedCall {
|
|
|
|
|