Skip to content

Commit f119e40

Browse files
Merge branch 'develop' into feature/scm_align_part3
# Conflicts: # android/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/SystemCapabilityManagerTests.java # android/sdl_android/src/main/java/com/smartdevicelink/managers/SdlManager.java # android/sdl_android/src/main/java/com/smartdevicelink/managers/video/VideoStreamManager.java
2 parents 89f4f1d + 57989dd commit f119e40

18 files changed

Lines changed: 518 additions & 97 deletions

File tree

android/hello_sdl_android/src/main/java/com/sdl/hellosdlandroid/SdlReceiver.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,9 @@
77

88
import com.smartdevicelink.transport.SdlBroadcastReceiver;
99
import com.smartdevicelink.transport.SdlRouterService;
10-
import com.smartdevicelink.transport.TransportConstants;
1110

1211
public class SdlReceiver extends SdlBroadcastReceiver {
1312
private static final String TAG = "SdlBroadcastReciever";
14-
public static final String RECONNECT_LANG_CHANGE = "RECONNECT_LANG_CHANGE";
1513

1614
@Override
1715
public void onSdlEnabled(Context context, Intent intent) {
@@ -36,16 +34,5 @@ public Class<? extends SdlRouterService> defineLocalSdlRouterClass() {
3634
@Override
3735
public void onReceive(Context context, Intent intent) {
3836
super.onReceive(context, intent); // Required if overriding this method
39-
40-
if (intent != null) {
41-
String action = intent.getAction();
42-
if (action != null){
43-
if(action.equalsIgnoreCase(TransportConstants.START_ROUTER_SERVICE_ACTION)) {
44-
if (intent.getBooleanExtra(RECONNECT_LANG_CHANGE, false)) {
45-
onSdlEnabled(context, intent);
46-
}
47-
}
48-
}
49-
}
5037
}
5138
}

android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/file/SdlArtworkTests.java renamed to android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/file/filetypes/SdlArtworkTests.java

File renamed without changes.
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
/*
2+
* Copyright (c) 2019 Livio, Inc.
3+
* All rights reserved.
4+
*
5+
* Redistribution and use in source and binary forms, with or without
6+
* modification, are permitted provided that the following conditions are met:
7+
*
8+
* Redistributions of source code must retain the above copyright notice, this
9+
* list of conditions and the following disclaimer.
10+
*
11+
* Redistributions in binary form must reproduce the above copyright notice,
12+
* this list of conditions and the following
13+
* disclaimer in the documentation and/or other materials provided with the
14+
* distribution.
15+
*
16+
* Neither the name of the Livio Inc. nor the names of its contributors
17+
* may be used to endorse or promote products derived from this software
18+
* without specific prior written permission.
19+
*
20+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
24+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30+
* POSSIBILITY OF SUCH DAMAGE.
31+
*/
32+
33+
package com.smartdevicelink.managers.file.filetypes;
34+
35+
import com.smartdevicelink.AndroidTestCase2;
36+
import com.smartdevicelink.test.Test;
37+
38+
public class SdlFileTests extends AndroidTestCase2 {
39+
40+
public void testConstructorWithNoParams() {
41+
SdlFile sdlFile;
42+
43+
// Case 1 (Setting data)
44+
sdlFile = new SdlFile();
45+
sdlFile.setFileData(Test.GENERAL_BYTE_ARRAY);
46+
assertEquals(sdlFile.getFileData(), Test.GENERAL_BYTE_ARRAY);
47+
sdlFile.setName(null);
48+
assertEquals(sdlFile.getName(), "e9800998ecf8427e");
49+
sdlFile.setName(Test.GENERAL_STRING);
50+
assertEquals(sdlFile.getName(), Test.GENERAL_STRING);
51+
sdlFile.setType(Test.GENERAL_FILETYPE);
52+
assertEquals(sdlFile.getType(), Test.GENERAL_FILETYPE);
53+
sdlFile.setPersistent(Test.GENERAL_BOOLEAN);
54+
assertEquals(sdlFile.isPersistent(), Test.GENERAL_BOOLEAN);
55+
56+
// Case 2 (Setting resourceId)
57+
sdlFile = new SdlFile();
58+
sdlFile.setResourceId(Test.GENERAL_INTEGER);
59+
assertEquals((Integer) sdlFile.getResourceId(), Test.GENERAL_INTEGER);
60+
sdlFile.setName(null);
61+
assertEquals(sdlFile.getName(), "ec9ebc78777cf40d");
62+
sdlFile.setName(Test.GENERAL_STRING);
63+
assertEquals(sdlFile.getName(), Test.GENERAL_STRING);
64+
sdlFile.setType(Test.GENERAL_FILETYPE);
65+
assertEquals(sdlFile.getType(), Test.GENERAL_FILETYPE);
66+
sdlFile.setPersistent(Test.GENERAL_BOOLEAN);
67+
assertEquals(sdlFile.isPersistent(), Test.GENERAL_BOOLEAN);
68+
69+
// Case 3 (Setting URI)
70+
sdlFile = new SdlFile();
71+
sdlFile.setUri(Test.GENERAL_URI);
72+
assertEquals(sdlFile.getUri(), Test.GENERAL_URI);
73+
sdlFile.setName(null);
74+
assertEquals(sdlFile.getName(), "d3467db131372140");
75+
sdlFile.setName(Test.GENERAL_STRING);
76+
assertEquals(sdlFile.getName(), Test.GENERAL_STRING);
77+
sdlFile.setType(Test.GENERAL_FILETYPE);
78+
assertEquals(sdlFile.getType(), Test.GENERAL_FILETYPE);
79+
sdlFile.setPersistent(Test.GENERAL_BOOLEAN);
80+
assertEquals(sdlFile.isPersistent(), Test.GENERAL_BOOLEAN);
81+
}
82+
83+
public void testConstructorWithResourceId() {
84+
// Case1 (Set the name manually)
85+
SdlFile sdlFile1 = new SdlFile(Test.GENERAL_STRING, Test.GENERAL_FILETYPE, Test.GENERAL_INTEGER, Test.GENERAL_BOOLEAN);
86+
assertEquals(sdlFile1.getName(), Test.GENERAL_STRING);
87+
assertEquals(sdlFile1.getType(), Test.GENERAL_FILETYPE);
88+
assertEquals((Integer) sdlFile1.getResourceId(), Test.GENERAL_INTEGER);
89+
assertEquals(sdlFile1.isPersistent(), Test.GENERAL_BOOLEAN);
90+
91+
// Case2 (Let the library generate a name)
92+
SdlFile sdlFile2 = new SdlFile(null, Test.GENERAL_FILETYPE, Test.GENERAL_INTEGER, Test.GENERAL_BOOLEAN);
93+
SdlFile sdlFile3 = new SdlFile(null, Test.GENERAL_FILETYPE, Test.GENERAL_INTEGER, Test.GENERAL_BOOLEAN);
94+
assertEquals(sdlFile2.getName(), sdlFile3.getName());
95+
assertEquals(sdlFile2.getName(), "ec9ebc78777cf40d");
96+
assertEquals(sdlFile2.getType(), Test.GENERAL_FILETYPE);
97+
assertEquals((Integer) sdlFile2.getResourceId(), Test.GENERAL_INTEGER);
98+
assertEquals(sdlFile2.isPersistent(), Test.GENERAL_BOOLEAN);
99+
}
100+
101+
public void testConstructorWithData() {
102+
// Case1 (Set the name manually)
103+
SdlFile sdlFile1 = new SdlFile(Test.GENERAL_STRING, Test.GENERAL_FILETYPE, Test.GENERAL_BYTE_ARRAY, Test.GENERAL_BOOLEAN);
104+
assertEquals(sdlFile1.getName(), Test.GENERAL_STRING);
105+
assertEquals(sdlFile1.getType(), Test.GENERAL_FILETYPE);
106+
assertEquals(sdlFile1.getFileData(), Test.GENERAL_BYTE_ARRAY);
107+
assertEquals(sdlFile1.isPersistent(), Test.GENERAL_BOOLEAN);
108+
109+
// Case2 (Let the library generate a name)
110+
SdlFile sdlFile2 = new SdlFile(null, Test.GENERAL_FILETYPE, Test.GENERAL_BYTE_ARRAY, Test.GENERAL_BOOLEAN);
111+
SdlFile sdlFile3 = new SdlFile(null, Test.GENERAL_FILETYPE, Test.GENERAL_BYTE_ARRAY, Test.GENERAL_BOOLEAN);
112+
assertEquals(sdlFile2.getName(), sdlFile3.getName());
113+
assertEquals(sdlFile2.getName(), "e9800998ecf8427e");
114+
assertEquals(sdlFile2.getType(), Test.GENERAL_FILETYPE);
115+
assertEquals(sdlFile2.getFileData(), Test.GENERAL_BYTE_ARRAY);
116+
assertEquals(sdlFile2.isPersistent(), Test.GENERAL_BOOLEAN);
117+
}
118+
119+
public void testConstructorWithUri() {
120+
// Case1 (Set the name manually)
121+
SdlFile sdlFile1 = new SdlFile(Test.GENERAL_STRING, Test.GENERAL_FILETYPE, Test.GENERAL_URI, Test.GENERAL_BOOLEAN);
122+
assertEquals(sdlFile1.getName(), Test.GENERAL_STRING);
123+
assertEquals(sdlFile1.getType(), Test.GENERAL_FILETYPE);
124+
assertEquals(sdlFile1.getUri(), Test.GENERAL_URI);
125+
assertEquals(sdlFile1.isPersistent(), Test.GENERAL_BOOLEAN);
126+
127+
// Case2 (Let the library generate a name)
128+
SdlFile sdlFile2 = new SdlFile(null, Test.GENERAL_FILETYPE, Test.GENERAL_URI, Test.GENERAL_BOOLEAN);
129+
SdlFile sdlFile3 = new SdlFile(null, Test.GENERAL_FILETYPE, Test.GENERAL_URI, Test.GENERAL_BOOLEAN);
130+
assertEquals(sdlFile2.getName(), sdlFile3.getName());
131+
assertEquals(sdlFile2.getName(), "d3467db131372140");
132+
assertEquals(sdlFile2.getType(), Test.GENERAL_FILETYPE);
133+
assertEquals(sdlFile2.getUri(), Test.GENERAL_URI);
134+
assertEquals(sdlFile2.isPersistent(), Test.GENERAL_BOOLEAN);
135+
}
136+
}

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/Test.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.smartdevicelink.test;
22

33
import android.graphics.Color;
4+
import android.net.Uri;
45
import android.util.Log;
56

67
import com.smartdevicelink.R;
@@ -264,6 +265,7 @@ public class Test {
264265
public static final ImageField GENERAL_IMAGEFIELD = new ImageField();
265266
public static final DeviceInfo GENERAL_DEVICEINFO = new DeviceInfo();
266267
public static final AppInfo GENERAL_APPINFO = new AppInfo();
268+
public static final Uri GENERAL_URI = Uri.parse("http://www.google.com");;
267269
public static final LayoutMode GENERAL_LAYOUTMODE = LayoutMode.LIST_ONLY;
268270
public static final MenuParams GENERAL_MENUPARAMS = new MenuParams();
269271
public static final SoftButton GENERAL_SOFTBUTTON = new SoftButton();

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -995,15 +995,21 @@ public boolean removeOnRPCListener(FunctionID messageId, OnRPCListener listener)
995995
public Object getCapability(SystemCapabilityType systemCapabilityType){return null;}
996996

997997
@Override
998-
public void getCapability(SystemCapabilityType systemCapabilityType, OnSystemCapabilityListener scListener) { }
998+
public void getCapability(SystemCapabilityType systemCapabilityType, OnSystemCapabilityListener scListener) {
999+
}
1000+
1001+
@Override
1002+
public RegisterAppInterfaceResponse getRegisterAppInterfaceResponse() {
1003+
return null;
1004+
}
9991005

10001006
@Override
10011007
public Object getCapability(SystemCapabilityType systemCapabilityType, OnSystemCapabilityListener scListener, boolean forceUpdate) {
10021008
return null;
10031009
}
10041010

10051011
@Override
1006-
public SdlMsgVersion getSdlMsgVersion(){
1012+
public SdlMsgVersion getSdlMsgVersion() {
10071013
return null;
10081014
}
10091015

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 Object getCapability(SystemCapabilityType systemCapabilityType, OnSystemCapabilityListener scListener, boolean forceUpdate) {
871876
if (proxy != null && proxy.getSystemCapabilityManager() != null) {

0 commit comments

Comments
 (0)