Do not crash when receiving video call on device w/o camera

Upon accepting a video call on a device that can not establish a video track on
its own (for example by not having a camera), displaying the video enable/disable
button would fail. This commit defaults this button to disabled.
This commit is contained in:
Daniel Gultsch 2021-03-26 12:54:23 +01:00
parent 77f448692c
commit 1822a71c2a
4 changed files with 9 additions and 7 deletions

View File

@ -874,7 +874,12 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe
} }
private void enableVideo(View view) { private void enableVideo(View view) {
requireRtpConnection().setVideoEnabled(true); try {
requireRtpConnection().setVideoEnabled(true);
} catch (final IllegalStateException e) {
Toast.makeText(this, R.string.unable_to_enable_video, Toast.LENGTH_SHORT).show();
return;
}
updateInCallButtonConfigurationVideo(true, requireRtpConnection().isCameraSwitchable()); updateInCallButtonConfigurationVideo(true, requireRtpConnection().isCameraSwitchable());
} }

View File

@ -408,11 +408,7 @@ public abstract class XmppActivity extends ActionBarActivity {
metrics = getResources().getDisplayMetrics(); metrics = getResources().getDisplayMetrics();
ExceptionHelper.init(getApplicationContext()); ExceptionHelper.init(getApplicationContext());
new EmojiService(this).init(); new EmojiService(this).init();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { this.isCameraFeatureAvailable = getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_ANY);
this.isCameraFeatureAvailable = getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_ANY);
} else {
this.isCameraFeatureAvailable = getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA);
}
this.mTheme = findTheme(); this.mTheme = findTheme();
setTheme(this.mTheme); setTheme(this.mTheme);
} }

View File

@ -393,7 +393,7 @@ public class WebRTCWrapper {
boolean isVideoEnabled() { boolean isVideoEnabled() {
final VideoTrack videoTrack = this.localVideoTrack; final VideoTrack videoTrack = this.localVideoTrack;
if (videoTrack == null) { if (videoTrack == null) {
throw new IllegalStateException("Local video track does not exist"); return false;
} }
return videoTrack.enabled(); return videoTrack.enabled();
} }

View File

@ -961,4 +961,5 @@
<string name="server_does_not_support_easy_onboarding_invites">Server does not support generating invites</string> <string name="server_does_not_support_easy_onboarding_invites">Server does not support generating invites</string>
<string name="no_active_accounts_support_this">No active accounts support this feature</string> <string name="no_active_accounts_support_this">No active accounts support this feature</string>
<string name="backup_started_message">The backup has been started. Youll get a notification once it has been completed.</string> <string name="backup_started_message">The backup has been started. Youll get a notification once it has been completed.</string>
<string name="unable_to_enable_video">Unable to enable video.</string>
</resources> </resources>