Skip to content

Commit 53546c6

Browse files
authored
Merge pull request #1314 from smartdevicelink/bugfix/issue_1282
Bugfix/issue 1282
2 parents 9a1be39 + 9c5c4c1 commit 53546c6

9 files changed

Lines changed: 172 additions & 3 deletions

File tree

android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/video/VideoStreamManagerTests.java

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,11 @@
1919
import com.smartdevicelink.proxy.rpc.ImageResolution;
2020
import com.smartdevicelink.proxy.rpc.OnHMIStatus;
2121
import com.smartdevicelink.proxy.rpc.OnTouchEvent;
22+
import com.smartdevicelink.proxy.rpc.RegisterAppInterface;
23+
import com.smartdevicelink.proxy.rpc.RegisterAppInterfaceResponse;
2224
import com.smartdevicelink.proxy.rpc.TouchCoord;
2325
import com.smartdevicelink.proxy.rpc.TouchEvent;
26+
import com.smartdevicelink.proxy.rpc.VehicleType;
2427
import com.smartdevicelink.proxy.rpc.enums.HMILevel;
2528
import com.smartdevicelink.proxy.rpc.enums.SystemCapabilityType;
2629
import com.smartdevicelink.proxy.rpc.enums.TouchType;
@@ -99,6 +102,12 @@ public void testInitialization(){
99102
ISdl internalInterface = mock(ISdl.class);
100103
when(internalInterface.getProtocolVersion()).thenReturn(new Version(5,1,0));
101104

105+
RegisterAppInterfaceResponse mockRegisterAppInterfaceResponse = new RegisterAppInterfaceResponse();
106+
VehicleType mockVehicleType = new VehicleType();
107+
mockVehicleType.setMake("Ford");
108+
mockRegisterAppInterfaceResponse.setVehicleType(mockVehicleType);
109+
when(internalInterface.getRegisterAppInterfaceResponse()).thenReturn(mockRegisterAppInterfaceResponse);
110+
102111
Answer<Void> onAddServiceListener = new Answer<Void>() {
103112
@Override
104113
public Void answer(InvocationOnMock invocation) {
@@ -126,6 +135,13 @@ public void testHMILevelNotFull(){
126135
final ISdl internalInterface = mock(ISdl.class);
127136

128137
when(internalInterface.getProtocolVersion()).thenReturn((new Version(5,0,0)));
138+
139+
RegisterAppInterfaceResponse mockRegisterAppInterfaceResponse = new RegisterAppInterfaceResponse();
140+
VehicleType mockVehicleType = new VehicleType();
141+
mockVehicleType.setMake("Ford");
142+
mockRegisterAppInterfaceResponse.setVehicleType(mockVehicleType);
143+
when(internalInterface.getRegisterAppInterfaceResponse()).thenReturn(mockRegisterAppInterfaceResponse);
144+
129145
when(internalInterface.isCapabilitySupported(SystemCapabilityType.VIDEO_STREAMING)).thenReturn(true);
130146

131147
final VideoStreamManager videoStreamManager = new VideoStreamManager(internalInterface);
@@ -143,6 +159,12 @@ public void onComplete(boolean success) {
143159
public void testRemoteDisplayStream(){
144160
ISdl internalInterface = mock(ISdl.class);
145161

162+
RegisterAppInterfaceResponse mockRegisterAppInterfaceResponse = new RegisterAppInterfaceResponse();
163+
VehicleType mockVehicleType = new VehicleType();
164+
mockVehicleType.setMake("Ford");
165+
mockRegisterAppInterfaceResponse.setVehicleType(mockVehicleType);
166+
when(internalInterface.getRegisterAppInterfaceResponse()).thenReturn(mockRegisterAppInterfaceResponse);
167+
146168
final Set<Object> listenerSet = new HashSet<>();
147169

148170
when(internalInterface.getProtocolVersion()).thenReturn(new Version(5,0,0));
@@ -252,6 +274,13 @@ public void onComplete(boolean success) {
252274

253275
public void testConvertTouchEvent() {
254276
ISdl internalInterface = mock(ISdl.class);
277+
278+
RegisterAppInterfaceResponse mockRegisterAppInterfaceResponse = new RegisterAppInterfaceResponse();
279+
VehicleType mockVehicleType = new VehicleType();
280+
mockVehicleType.setMake("Ford");
281+
mockRegisterAppInterfaceResponse.setVehicleType(mockVehicleType);
282+
when(internalInterface.getRegisterAppInterfaceResponse()).thenReturn(mockRegisterAppInterfaceResponse);
283+
255284
VideoStreamManager videoStreamManager = new VideoStreamManager(internalInterface);
256285
List<MotionEvent> motionEventList;
257286
long e1TS = 1558124390L, e2TS = 1558125390L, e3TS = 1558126390L;
@@ -467,6 +496,12 @@ public void testConvertTouchEvent_Scale_1_5() {
467496
private void assertMotionEventWithScale(int width, int height, float scale) {
468497
ISdl internalInterface = mock(ISdl.class);
469498

499+
RegisterAppInterfaceResponse mockRegisterAppInterfaceResponse = new RegisterAppInterfaceResponse();
500+
VehicleType mockVehicleType = new VehicleType();
501+
mockVehicleType.setMake("Ford");
502+
mockRegisterAppInterfaceResponse.setVehicleType(mockVehicleType);
503+
when(internalInterface.getRegisterAppInterfaceResponse()).thenReturn(mockRegisterAppInterfaceResponse);
504+
470505
// Preferred Resolution capability
471506
ImageResolution resolution = new ImageResolution(width, height);
472507

android/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/SystemCapabilityManagerTests.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -950,6 +950,9 @@ public boolean removeOnRPCListener(FunctionID messageId, OnRPCListener listener)
950950
@Override
951951
public void getCapability(SystemCapabilityType systemCapabilityType, OnSystemCapabilityListener scListener) { }
952952

953+
@Override
954+
public RegisterAppInterfaceResponse getRegisterAppInterfaceResponse(){return null;}
955+
953956
@Override
954957
public SdlMsgVersion getSdlMsgVersion(){
955958
return null;

android/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/video/VideoStreamingParametersTest.java

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,66 @@ public void testUpdateScale_1_5_Resolution_1280_569() {
8181
assertEquals(380, height);
8282
}
8383

84+
public void testUpdateScale_1_0_Ford_Resolution_800_354() {
85+
preferredResolution = new ImageResolution(800, 354);
86+
87+
capability.setScale(1.0);
88+
capability.setPreferredResolution(preferredResolution);
89+
90+
params.update(capability, "Ford");
91+
92+
int width = params.getResolution().getResolutionWidth();
93+
int height = params.getResolution().getResolutionHeight();
94+
95+
assertEquals(800, width);
96+
assertEquals(354, height);
97+
}
98+
99+
public void testUpdateScale_1_3_Lincoln_Resolution_600_900() {
100+
preferredResolution = new ImageResolution(600, 900);
101+
102+
capability.setScale(1.0);
103+
capability.setPreferredResolution(preferredResolution);
104+
105+
params.update(capability, "Lincoln");
106+
107+
int width = params.getResolution().getResolutionWidth();
108+
int height = params.getResolution().getResolutionHeight();
109+
110+
assertEquals(450, width);
111+
assertEquals(676, height);
112+
}
113+
114+
public void testUpdateScale_1_3_Ford_Resolution_900_600() {
115+
preferredResolution = new ImageResolution(900, 600);
116+
117+
capability.setScale(1.0);
118+
capability.setPreferredResolution(preferredResolution);
119+
120+
params.update(capability, "Ford");
121+
122+
int width = params.getResolution().getResolutionWidth();
123+
int height = params.getResolution().getResolutionHeight();
124+
125+
assertEquals(676, width);
126+
assertEquals(450, height);
127+
}
128+
129+
public void testUpdateScale_1_0_Toyota_Resolution_900_600() {
130+
preferredResolution = new ImageResolution(900, 600);
131+
132+
capability.setScale(1.0);
133+
capability.setPreferredResolution(preferredResolution);
134+
135+
params.update(capability, "Toyota");
136+
137+
int width = params.getResolution().getResolutionWidth();
138+
int height = params.getResolution().getResolutionHeight();
139+
140+
assertEquals(900, width);
141+
assertEquals(600, height);
142+
}
143+
84144
public void testUpdateCapabilityFormat(){
85145
VideoStreamingCapability capability = new VideoStreamingCapability();
86146
capability.setMaxBitrate(10000);

android/sdl_android/src/main/java/com/smartdevicelink/managers/SdlManager.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -866,6 +866,11 @@ public void getCapability(SystemCapabilityType systemCapabilityType, OnSystemCap
866866
proxy.getCapability(systemCapabilityType, scListener);
867867
}
868868

869+
@Override
870+
public RegisterAppInterfaceResponse getRegisterAppInterfaceResponse() {
871+
return proxy.getRegisterAppInterfaceResponse();
872+
}
873+
869874
@Override
870875
public boolean isCapabilitySupported(SystemCapabilityType systemCapabilityType){
871876
return proxy.isCapabilitySupported(systemCapabilityType);

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
import com.smartdevicelink.proxy.rpc.OnTouchEvent;
6161
import com.smartdevicelink.proxy.rpc.TouchCoord;
6262
import com.smartdevicelink.proxy.rpc.TouchEvent;
63+
import com.smartdevicelink.proxy.rpc.VehicleType;
6364
import com.smartdevicelink.proxy.rpc.VideoStreamingCapability;
6465
import com.smartdevicelink.proxy.rpc.enums.HMILevel;
6566
import com.smartdevicelink.proxy.rpc.enums.PredefinedWindows;
@@ -95,6 +96,7 @@ public class VideoStreamManager extends BaseVideoStreamManager {
9596
private IVideoStreamListener streamListener;
9697
private boolean isTransportAvailable = false;
9798
private boolean hasStarted;
99+
private String vehicleMake = null;
98100

99101
// INTERNAL INTERFACES
100102

@@ -176,10 +178,12 @@ public void onNotified(RPCNotification notification) {
176178
};
177179

178180
// MANAGER APIs
179-
180181
public VideoStreamManager(ISdl internalInterface){
181182
super(internalInterface);
182183

184+
if(internalInterface.getRegisterAppInterfaceResponse().getVehicleType() != null) {
185+
vehicleMake = internalInterface.getRegisterAppInterfaceResponse().getVehicleType().getMake();
186+
}
183187
virtualDisplayEncoder = new VirtualDisplayEncoder();
184188
hmiLevel = HMILevel.HMI_NONE;
185189

@@ -218,7 +222,7 @@ private void getVideoStreamingParams(){
218222
@Override
219223
public void onCapabilityRetrieved(Object capability) {
220224
VideoStreamingParameters params = new VideoStreamingParameters();
221-
params.update((VideoStreamingCapability)capability); //Streaming parameters are ready time to stream
225+
params.update((VideoStreamingCapability)capability, vehicleMake); //Streaming parameters are ready time to stream
222226
VideoStreamManager.this.parameters = params;
223227

224228
checkState();
@@ -270,7 +274,7 @@ public void startRemoteDisplayStream(Context context, Class<? extends SdlRemoteD
270274
@Override
271275
public void onCapabilityRetrieved(Object capability) {
272276
VideoStreamingParameters params = new VideoStreamingParameters();
273-
params.update((VideoStreamingCapability)capability); //Streaming parameters are ready time to stream
277+
params.update((VideoStreamingCapability)capability, vehicleMake); //Streaming parameters are ready time to stream
274278
startStreaming(params, encrypted);
275279
}
276280

android/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyBase.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,11 @@ public Object getCapability(SystemCapabilityType systemCapabilityType){
444444
return SdlProxyBase.this.getCapability(systemCapabilityType);
445445
}
446446

447+
@Override
448+
public RegisterAppInterfaceResponse getRegisterAppInterfaceResponse() {
449+
return SdlProxyBase.this.getRegisterAppInterfaceResponse();
450+
}
451+
447452
@Override
448453
public void getCapability(SystemCapabilityType systemCapabilityType, OnSystemCapabilityListener scListener) {
449454
SdlProxyBase.this.getCapability(systemCapabilityType, scListener);

base/src/main/java/com/smartdevicelink/proxy/interfaces/ISdl.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import com.smartdevicelink.protocol.enums.SessionType;
77
import com.smartdevicelink.proxy.RPCMessage;
88
import com.smartdevicelink.proxy.RPCRequest;
9+
import com.smartdevicelink.proxy.rpc.RegisterAppInterfaceResponse;
910
import com.smartdevicelink.proxy.rpc.SdlMsgVersion;
1011
import com.smartdevicelink.proxy.rpc.enums.SystemCapabilityType;
1112
import com.smartdevicelink.proxy.rpc.listeners.OnMultipleRequestListener;
@@ -218,6 +219,12 @@ public interface ISdl {
218219
*/
219220
void getCapability(SystemCapabilityType systemCapabilityType, OnSystemCapabilityListener scListener);
220221

222+
/**
223+
* Get RegisterAppInterfaceResponse
224+
* @return the RegisterAppInterfaceResponse if available, null if not
225+
*/
226+
RegisterAppInterfaceResponse getRegisterAppInterfaceResponse();
227+
221228
/**
222229
* Check if capability is supported
223230
* @param systemCapabilityType a system capability type that should be checked for support

base/src/main/java/com/smartdevicelink/streaming/video/VideoStreamingParameters.java

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,54 @@ public void update(VideoStreamingParameters params){
131131
* Update the values contained in the capability that should have been returned through the SystemCapabilityManager.
132132
* This update will use the most preferred streaming format from the module.
133133
* @param capability the video streaming capability returned from the SystemCapabilityManager
134+
* @param vehicleMake the vehicle make from the RegisterAppInterfaceResponse
134135
* @see com.smartdevicelink.proxy.SystemCapabilityManager
135136
* @see VideoStreamingCapability
136137
*/
138+
public void update(VideoStreamingCapability capability, String vehicleMake){
139+
if(capability.getMaxBitrate()!=null){ this.bitrate = capability.getMaxBitrate() * 1000; } // NOTE: the unit of maxBitrate in getSystemCapability is kbps.
140+
double scale = DEFAULT_SCALE;
141+
if(capability.getScale() != null) { scale = capability.getScale(); }
142+
ImageResolution resolution = capability.getPreferredResolution();
143+
if(resolution!=null){
144+
145+
if (vehicleMake != null) {
146+
if ((vehicleMake.contains("Ford") || vehicleMake.contains("Lincoln")) && ((resolution.getResolutionHeight() != null && resolution.getResolutionHeight() > 800) || (resolution.getResolutionWidth() != null && resolution.getResolutionWidth() > 800))) {
147+
scale = 1.0 / 0.75;
148+
}
149+
}
150+
151+
if(resolution.getResolutionHeight()!=null && resolution.getResolutionHeight() > 0){ this.resolution.setResolutionHeight((int)(resolution.getResolutionHeight() / scale)); }
152+
if(resolution.getResolutionWidth()!=null && resolution.getResolutionWidth() > 0){ this.resolution.setResolutionWidth((int)(resolution.getResolutionWidth() / scale)); }
153+
}
154+
155+
// This should be the last call as it will return out once a suitable format is found
156+
final List<VideoStreamingFormat> formats = capability.getSupportedFormats();
157+
if(formats != null && formats.size()>0){
158+
for(VideoStreamingFormat format : formats){
159+
for(int i = 0; i < CURRENTLY_SUPPORTED_FORMATS.length; i ++){
160+
if(CURRENTLY_SUPPORTED_FORMATS[i].equals(format) ){
161+
this.format = format;
162+
return;
163+
}
164+
}
165+
}
166+
DebugTool.logWarning("The VideoStreamingFormat has not been updated because none of the provided formats are supported.");
167+
168+
//TODO In the future we should set format to null, but might be a breaking change
169+
// For now, format will remain whatever was set prior to this update
170+
}
171+
172+
}
173+
174+
/**
175+
* Update the values contained in the capability that should have been returned through the SystemCapabilityManager.
176+
* This update will use the most preferred streaming format from the module.
177+
* @param capability the video streaming capability returned from the SystemCapabilityManager
178+
* @see com.smartdevicelink.proxy.SystemCapabilityManager
179+
* @see VideoStreamingCapability
180+
*/
181+
@Deprecated
137182
public void update(VideoStreamingCapability capability){
138183
if(capability.getMaxBitrate()!=null){ this.bitrate = capability.getMaxBitrate() * 1000; } // NOTE: the unit of maxBitrate in getSystemCapability is kbps.
139184
double scale = DEFAULT_SCALE;

javaSE/src/main/java/com/smartdevicelink/managers/lifecycle/LifecycleManager.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,6 +1145,11 @@ public void getCapability(SystemCapabilityType systemCapabilityType, OnSystemCap
11451145

11461146
}
11471147

1148+
@Override
1149+
public RegisterAppInterfaceResponse getRegisterAppInterfaceResponse() {
1150+
return raiResponse;
1151+
}
1152+
11481153
@Override
11491154
public boolean isCapabilitySupported(SystemCapabilityType systemCapabilityType) {
11501155
return LifecycleManager.this.systemCapabilityManager.isCapabilitySupported(systemCapabilityType);

0 commit comments

Comments
 (0)