Skip to content

Commit e6e61be

Browse files
author
Robert Henigan
authored
Merge pull request #1655 from smartdevicelink/bugfix/videostreaming_incorret_restart
Fix video streaming incorrect restart
2 parents e22b26c + 5868f06 commit e6e61be

2 files changed

Lines changed: 14 additions & 8 deletions

File tree

android/sdl_android/src/main/java/com/smartdevicelink/managers/video/VideoStreamManager.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ public class VideoStreamManager extends BaseVideoStreamManager {
117117
private String vehicleMake = null;
118118
private boolean isEncrypted = false;
119119
private boolean withPendingRestart = false;
120+
private boolean wasCapabilityListenerAdded = false;
120121
private AbstractPacketizer videoPacketizer;
121122

122123
// INTERNAL INTERFACES
@@ -188,7 +189,10 @@ public void onNotified(RPCNotification notification) {
188189
if (VideoStreamManager.this.parameters == null) {
189190
getVideoStreamingParams();
190191
}
191-
internalInterface.getSystemCapabilityManager().addOnSystemCapabilityListener(SystemCapabilityType.VIDEO_STREAMING, systemCapabilityListener);
192+
if (!wasCapabilityListenerAdded) {
193+
wasCapabilityListenerAdded = true;
194+
internalInterface.getSystemCapabilityManager().addOnSystemCapabilityListener(SystemCapabilityType.VIDEO_STREAMING, systemCapabilityListener);
195+
}
192196
}
193197
checkState();
194198
if (hasStarted && (isHMIStateVideoStreamCapable(prevOnHMIStatus)) && (!isHMIStateVideoStreamCapable(currentOnHMIStatus))) {

android/sdl_android/src/main/java/com/smartdevicelink/streaming/video/SdlRemoteDisplay.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -133,14 +133,16 @@ public void resizeView(final int newWidth, final int newHeight) {
133133
@Override
134134
public void run() {
135135
try {
136-
Constructor<? extends ViewGroup.LayoutParams> ctor =
137-
mainView.getLayoutParams().getClass().getDeclaredConstructor(int.class, int.class);
138-
mainView.setLayoutParams(ctor.newInstance(newWidth, newHeight));
139-
mainView.requestLayout();
140-
invalidate();
141-
onViewResized(newWidth, newHeight);
136+
if (mainView != null) {
137+
Constructor<? extends ViewGroup.LayoutParams> ctor =
138+
mainView.getLayoutParams().getClass().getDeclaredConstructor(int.class, int.class);
139+
mainView.setLayoutParams(ctor.newInstance(newWidth, newHeight));
140+
mainView.requestLayout();
141+
invalidate();
142+
onViewResized(newWidth, newHeight);
143+
}
142144
} catch (Exception e) {
143-
e.printStackTrace();
145+
DebugTool.logError(TAG, "Exception thrown during view resize", e);
144146
}
145147
}
146148
});

0 commit comments

Comments
 (0)