summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBilal Alsharifi <bilal.alsharifi@gmail.com>2019-10-10 15:10:02 -0400
committerBilal Alsharifi <bilal.alsharifi@gmail.com>2019-10-10 15:10:02 -0400
commite3ec31fd2d0cb4d8f29f890f7f4265bf20858fa7 (patch)
treee53a4020b24114fb2eccd2bf0785e92af6b8188f
parent74badf40598c8fa44b725421d637aec7dac391a2 (diff)
parentcc4e47233bc0bf0f775dcde03cc310b72bc2ccda (diff)
downloadsdl_android-e3ec31fd2d0cb4d8f29f890f7f4265bf20858fa7.tar.gz
Merge branch 'develop' into feature/SDL-0243-DisplayCap
# Conflicts: # base/src/main/java/com/smartdevicelink/proxy/interfaces/ISdl.java # javaSE/src/main/java/com/smartdevicelink/managers/lifecycle/LifecycleManager.java
-rw-r--r--android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/ScreenManagerTests.java2
-rw-r--r--android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicManagerTests.java8
-rw-r--r--android/sdl_android/src/androidTest/java/com/smartdevicelink/test/Test.java2
-rw-r--r--android/sdl_android/src/androidTest/java/com/smartdevicelink/test/Validator.java4
-rw-r--r--android/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/SystemCapabilityManagerTests.java2
-rw-r--r--android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/PermissionItemTest.java7
-rw-r--r--android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/ResultTests.java4
-rw-r--r--android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnPermissionsChangeTests.java6
-rw-r--r--android/sdl_android/src/main/java/com/smartdevicelink/SdlConnection/SdlSession.java8
-rw-r--r--android/sdl_android/src/main/java/com/smartdevicelink/SdlConnection/SdlSession2.java7
-rw-r--r--android/sdl_android/src/main/java/com/smartdevicelink/managers/SdlManager.java33
-rw-r--r--android/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyBase.java148
-rw-r--r--android/sdl_android/src/main/java/com/smartdevicelink/transport/SdlRouterService.java4
-rw-r--r--base/src/main/java/com/smartdevicelink/managers/ServiceEncryptionListener.java10
-rw-r--r--base/src/main/java/com/smartdevicelink/managers/lifecycle/BaseEncryptionLifecycleManager.java182
-rw-r--r--base/src/main/java/com/smartdevicelink/managers/permission/BasePermissionManager.java31
-rw-r--r--base/src/main/java/com/smartdevicelink/managers/screen/BaseScreenManager.java10
-rw-r--r--base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java16
-rw-r--r--base/src/main/java/com/smartdevicelink/proxy/interfaces/ISdl.java5
-rw-r--r--base/src/main/java/com/smartdevicelink/proxy/rpc/DiagnosticMessageResponse.java78
-rw-r--r--base/src/main/java/com/smartdevicelink/proxy/rpc/GetDTCsResponse.java77
-rw-r--r--base/src/main/java/com/smartdevicelink/proxy/rpc/GetInteriorVehicleDataResponse.java16
-rw-r--r--base/src/main/java/com/smartdevicelink/proxy/rpc/GetSystemCapabilityResponse.java15
-rw-r--r--base/src/main/java/com/smartdevicelink/proxy/rpc/OnPermissionsChange.java79
-rw-r--r--base/src/main/java/com/smartdevicelink/proxy/rpc/PermissionItem.java79
-rw-r--r--base/src/main/java/com/smartdevicelink/proxy/rpc/SetInteriorVehicleDataResponse.java15
-rw-r--r--base/src/main/java/com/smartdevicelink/proxy/rpc/enums/Result.java66
l---------baseAndroid/src/main/java/com/smartdevicelink/managers/ServiceEncryptionListener.java1
-rw-r--r--javaSE/src/main/java/com/smartdevicelink/managers/SdlManager.java35
-rw-r--r--javaSE/src/main/java/com/smartdevicelink/managers/lifecycle/EncryptionLifecycleManager.java45
-rw-r--r--javaSE/src/main/java/com/smartdevicelink/managers/lifecycle/LifecycleManager.java102
31 files changed, 886 insertions, 211 deletions
diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/ScreenManagerTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/ScreenManagerTests.java
index a72ee75e0..4ab1fe7f7 100644
--- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/ScreenManagerTests.java
+++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/ScreenManagerTests.java
@@ -69,7 +69,7 @@ public class ScreenManagerTests extends AndroidTestCase2 {
screenManager.setTextField2("Wednesday");
screenManager.setTextField3("My");
screenManager.setTextField4("Dudes");
- screenManager.setTemplateTitle("title");
+ screenManager.setTitle("title");
assertEquals(screenManager.getTextField1(), "It is");
assertEquals(screenManager.getTextField2(), "Wednesday");
assertEquals(screenManager.getTextField3(), "My");
diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicManagerTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicManagerTests.java
index c80110cd1..3597c33f5 100644
--- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicManagerTests.java
+++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/screen/TextAndGraphicManagerTests.java
@@ -96,7 +96,7 @@ public class TextAndGraphicManagerTests extends AndroidTestCase2 {
assertNull(textAndGraphicManager.getTextField2());
assertNull(textAndGraphicManager.getTextField3());
assertNull(textAndGraphicManager.getTextField4());
- assertNull(textAndGraphicManager.getTemplateTitle());
+ assertNull(textAndGraphicManager.getTitle());
assertNull(textAndGraphicManager.getMediaTrackTextField());
assertNull(textAndGraphicManager.getPrimaryGraphic());
assertNull(textAndGraphicManager.getSecondaryGraphic());
@@ -488,8 +488,8 @@ public class TextAndGraphicManagerTests extends AndroidTestCase2 {
public void testTemplateTitle() {
String title = "template title";
- textAndGraphicManager.setTemplateTitle(title);
- assertEquals(textAndGraphicManager.getTemplateTitle(), title);
+ textAndGraphicManager.setTitle(title);
+ assertEquals(textAndGraphicManager.getTitle(), title);
}
public void testAlignment() {
@@ -542,7 +542,7 @@ public class TextAndGraphicManagerTests extends AndroidTestCase2 {
assertNull(textAndGraphicManager.getTextField2Type());
assertNull(textAndGraphicManager.getTextField3Type());
assertNull(textAndGraphicManager.getTextField4Type());
- assertNull(textAndGraphicManager.getTemplateTitle());
+ assertNull(textAndGraphicManager.getTitle());
assertNotNull(textAndGraphicManager.getBlankArtwork());
assertNull(textAndGraphicManager.currentScreenData);
assertNull(textAndGraphicManager.inProgressUpdate);
diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/Test.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/Test.java
index 793b2b035..0f87878e2 100644
--- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/Test.java
+++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/Test.java
@@ -861,6 +861,7 @@ public class Test {
GENERAL_PERMISSIONITEM.setRpcName(GENERAL_STRING);
GENERAL_PERMISSIONITEM.setHMIPermissions(GENERAL_HMIPERMISSIONS);
GENERAL_PERMISSIONITEM.setParameterPermissions(GENERAL_PARAMETERPERMISSIONS);
+ GENERAL_PERMISSIONITEM.setRequireEncryption(GENERAL_BOOLEAN);
GENERAL_PERMISSIONITEM_LIST.add(GENERAL_PERMISSIONITEM);
GENERAL_SYSTEMCAPABILITY.setSystemCapabilityType(GENERAL_SYSTEMCAPABILITYTYPE);
@@ -1148,6 +1149,7 @@ public class Test {
JSON_PERMISSIONITEM.put(PermissionItem.KEY_HMI_PERMISSIONS, JSON_HMIPERMISSIONS);
JSON_PERMISSIONITEM.put(PermissionItem.KEY_PARAMETER_PERMISSIONS, JSON_PARAMETERPERMISSIONS);
JSON_PERMISSIONITEM.put(PermissionItem.KEY_RPC_NAME, GENERAL_STRING);
+ JSON_PERMISSIONITEM.put(PermissionItem.KEY_REQUIRE_ENCRYPTION, GENERAL_BOOLEAN);
JSON_PERMISSIONITEMS.put(JSON_PERMISSIONITEM);
JSON_IMAGE.put(Image.KEY_IMAGE_TYPE, GENERAL_IMAGETYPE);
diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/Validator.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/Validator.java
index 31b3eb21c..09c0631b9 100644
--- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/Validator.java
+++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/Validator.java
@@ -2349,6 +2349,10 @@ public class Validator{
return false;
}
+ if(item1.getRequireEncryption() != item2.getRequireEncryption()) {
+ return false;
+ }
+
return true;
}
diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/SystemCapabilityManagerTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/SystemCapabilityManagerTests.java
index 372e1db02..0d1fa04bf 100644
--- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/SystemCapabilityManagerTests.java
+++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/SystemCapabilityManagerTests.java
@@ -594,6 +594,8 @@ public class SystemCapabilityManagerTests extends AndroidTestCase2 {
@Override
public void startAudioService(boolean encrypted){}
+ @Override
+ public void startRPCEncryption() {}
}
diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/PermissionItemTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/PermissionItemTest.java
index 5fc144fea..491803317 100644
--- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/PermissionItemTest.java
+++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/PermissionItemTest.java
@@ -29,6 +29,7 @@ public class PermissionItemTest extends TestCase {
msg.setRpcName(Test.GENERAL_STRING);
msg.setHMIPermissions(Test.GENERAL_HMIPERMISSIONS);
msg.setParameterPermissions(Test.GENERAL_PARAMETERPERMISSIONS);
+ msg.setRequireEncryption(Test.GENERAL_BOOLEAN);
}
/**
@@ -39,11 +40,13 @@ public class PermissionItemTest extends TestCase {
String rpcName = msg.getRpcName();
HMIPermissions hmiPermissions = msg.getHMIPermissions();
ParameterPermissions parameterPermissions = msg.getParameterPermissions();
+ boolean isEncryptionRequired = msg.getRequireEncryption();
// Valid Tests
assertEquals(Test.MATCH, Test.GENERAL_STRING, rpcName);
assertTrue(Test.TRUE, Validator.validateHmiPermissions(Test.GENERAL_HMIPERMISSIONS, hmiPermissions));
assertTrue(Test.TRUE, Validator.validateParameterPermissions(Test.GENERAL_PARAMETERPERMISSIONS, parameterPermissions));
+ assertEquals(Test.MATCH, Test.GENERAL_BOOLEAN, isEncryptionRequired);
// Invalid/Null Tests
PermissionItem msg = new PermissionItem();
@@ -52,6 +55,7 @@ public class PermissionItemTest extends TestCase {
assertNull(Test.NULL, msg.getRpcName());
assertNull(Test.NULL, msg.getHMIPermissions());
assertNull(Test.NULL, msg.getParameterPermissions());
+ assertNull(Test.NULL, msg.getRequireEncryption());
}
public void testJson() {
@@ -61,6 +65,7 @@ public class PermissionItemTest extends TestCase {
reference.put(PermissionItem.KEY_RPC_NAME, Test.GENERAL_STRING);
reference.put(PermissionItem.KEY_HMI_PERMISSIONS, Test.JSON_HMIPERMISSIONS);
reference.put(PermissionItem.KEY_PARAMETER_PERMISSIONS, Test.JSON_PARAMETERPERMISSIONS);
+ reference.put(PermissionItem.KEY_REQUIRE_ENCRYPTION, Test.GENERAL_BOOLEAN);
JSONObject underTest = msg.serializeJSON();
assertEquals(Test.MATCH, reference.length(), underTest.length());
@@ -73,6 +78,8 @@ public class PermissionItemTest extends TestCase {
assertTrue(Test.TRUE, Validator.validateStringList(JsonUtils.readStringListFromJsonObject(reference, key), JsonUtils.readStringListFromJsonObject(underTest, key)));
} else if (key.equals(PermissionItem.KEY_PARAMETER_PERMISSIONS)) {
assertTrue(Test.TRUE, Validator.validateStringList(JsonUtils.readStringListFromJsonObject(reference, key), JsonUtils.readStringListFromJsonObject(underTest, key)));
+ } else if (key.equals(PermissionItem.KEY_REQUIRE_ENCRYPTION)) {
+ assertEquals(Test.MATCH, JsonUtils.readBooleanFromJsonObject(reference, key), JsonUtils.readBooleanFromJsonObject(underTest, key));
} else {
assertEquals(Test.MATCH, JsonUtils.readObjectFromJsonObject(reference, key), JsonUtils.readObjectFromJsonObject(underTest, key));
}
diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/ResultTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/ResultTests.java
index 992f4e54e..f3b374b4c 100644
--- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/ResultTests.java
+++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/ResultTests.java
@@ -88,6 +88,8 @@ public class ResultTests extends TestCase {
Result enumReadOnly = Result.valueForString(example);
example = "CORRUPTED_DATA";
Result enumCorruptData = Result.valueForString(example);
+ example = "ENCRYPTION_NEEDED";
+ Result enumEncryptionRequired = Result.valueForString(example);
assertNotNull("SUCCESS returned null", enumSuccess);
assertNotNull("INVALID_DATA returned null", enumInvalidData);
@@ -124,6 +126,7 @@ public class ResultTests extends TestCase {
assertNotNull("DATA_NOT_AVAILABLE returned null", enumDataNotAvailable);
assertNotNull("READ_ONLY returned null", enumReadOnly);
assertNotNull("CORRUPTED_DATA", enumCorruptData);
+ assertNotNull("ENCRYPTION_NEEDED", enumEncryptionRequired);
}
/**
@@ -196,6 +199,7 @@ public class ResultTests extends TestCase {
enumTestList.add(Result.DATA_NOT_AVAILABLE);
enumTestList.add(Result.READ_ONLY);
enumTestList.add(Result.CORRUPTED_DATA);
+ enumTestList.add(Result.ENCRYPTION_NEEDED);
assertTrue("Enum value list does not match enum class list",
enumValueList.containsAll(enumTestList) && enumTestList.containsAll(enumValueList));
diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnPermissionsChangeTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnPermissionsChangeTests.java
index e390fc599..5064753c6 100644
--- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnPermissionsChangeTests.java
+++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnPermissionsChangeTests.java
@@ -24,6 +24,7 @@ public class OnPermissionsChangeTests extends BaseRpcTests{
OnPermissionsChange msg = new OnPermissionsChange();
msg.setPermissionItem(Test.GENERAL_PERMISSIONITEM_LIST);
+ msg.setRequireEncryption(Test.GENERAL_BOOLEAN);
return msg;
}
@@ -44,6 +45,7 @@ public class OnPermissionsChangeTests extends BaseRpcTests{
try{
result.put(OnPermissionsChange.KEY_PERMISSION_ITEM, Test.JSON_PERMISSIONITEMS);
+ result.put(OnPermissionsChange.KEY_REQUIRE_ENCRYPTION, Test.GENERAL_BOOLEAN);
}catch(JSONException e){
fail(Test.JSON_FAIL);
}
@@ -57,17 +59,19 @@ public class OnPermissionsChangeTests extends BaseRpcTests{
public void testRpcValues () {
// Test Values
List<PermissionItem> data = ( (OnPermissionsChange) msg ).getPermissionItem();
-
+ boolean isRequired = ((OnPermissionsChange)msg).getRequireEncryption();
// Valid Tests
assertEquals(Test.MATCH, Test.GENERAL_PERMISSIONITEM_LIST.size(), data.size());
for(int i=0; i<data.size(); i++){
assertTrue(Test.TRUE, Validator.validatePermissionItem(Test.GENERAL_PERMISSIONITEM_LIST.get(i), data.get(i)));
}
+ assertEquals(Test.MATCH, Test.GENERAL_BOOLEAN, isRequired);
// Invalid/Null Tests
OnPermissionsChange msg = new OnPermissionsChange();
assertNotNull(Test.NOT_NULL, msg);
testNullBase(msg);
+ assertNull(Test.NULL, msg.getRequireEncryption());
assertNull(Test.NULL, msg.getPermissionItem());
}
diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/SdlConnection/SdlSession.java b/android/sdl_android/src/main/java/com/smartdevicelink/SdlConnection/SdlSession.java
index 58fa8d576..33f9d885e 100644
--- a/android/sdl_android/src/main/java/com/smartdevicelink/SdlConnection/SdlSession.java
+++ b/android/sdl_android/src/main/java/com/smartdevicelink/SdlConnection/SdlSession.java
@@ -107,6 +107,7 @@ public class SdlSession implements ISdlConnectionListener, IHeartbeatMonitorList
StreamPacketizer mAudioPacketizer = null;
SdlEncoder mSdlEncoder = null;
VirtualDisplayEncoder virtualDisplayEncoder = null;
+ boolean sdlSecurityInitializing = false;
public static SdlSession createSession(byte wiproVersion, ISdlConnectionListener listener, BaseTransportConfig btConfig) {
@@ -450,9 +451,12 @@ public class SdlSession implements ISdlConnectionListener, IHeartbeatMonitorList
if (!serviceList.contains(serviceType))
serviceList.add(serviceType);
- sdlSecurity.initialize();
+ if (!sdlSecurityInitializing) {
+ sdlSecurityInitializing = true;
+ sdlSecurity.initialize();
+ return;
+ }
}
- return;
}
_sdlConnection.startService(serviceType, sessionID, isEncrypted);
}
diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/SdlConnection/SdlSession2.java b/android/sdl_android/src/main/java/com/smartdevicelink/SdlConnection/SdlSession2.java
index b9b9a5e40..14258cbfe 100644
--- a/android/sdl_android/src/main/java/com/smartdevicelink/SdlConnection/SdlSession2.java
+++ b/android/sdl_android/src/main/java/com/smartdevicelink/SdlConnection/SdlSession2.java
@@ -154,9 +154,12 @@ public class SdlSession2 extends SdlSession implements ISdlProtocol{
if (!serviceList.contains(serviceType))
serviceList.add(serviceType);
- sdlSecurity.initialize();
+ if (!sdlSecurityInitializing) {
+ sdlSecurityInitializing = true;
+ sdlSecurity.initialize();
+ return;
+ }
}
- return;
}
sdlProtocol.startService(serviceType, sessionID, isEncrypted);
}
diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/managers/SdlManager.java b/android/sdl_android/src/main/java/com/smartdevicelink/managers/SdlManager.java
index a12b5d154..d36106c13 100644
--- a/android/sdl_android/src/main/java/com/smartdevicelink/managers/SdlManager.java
+++ b/android/sdl_android/src/main/java/com/smartdevicelink/managers/SdlManager.java
@@ -120,6 +120,7 @@ public class SdlManager extends BaseSdlManager{
private SdlManagerListener managerListener;
private List<Class<? extends SdlSecurityBase>> sdlSecList;
private LockScreenConfig lockScreenConfig;
+ private ServiceEncryptionListener serviceEncryptionListener;
// Managers
private PermissionManager permissionManager;
@@ -131,7 +132,7 @@ public class SdlManager extends BaseSdlManager{
// Initialize proxyBridge with anonymous lifecycleListener
- private final ProxyBridge proxyBridge= new ProxyBridge(new ProxyBridge.LifecycleListener() {
+ private final ProxyBridge proxyBridge = new ProxyBridge(new ProxyBridge.LifecycleListener() {
@Override
public void onProxyConnected() {
DebugTool.logInfo("Proxy is connected. Now initializing.");
@@ -680,7 +681,7 @@ public class SdlManager extends BaseSdlManager{
proxy.setMinimumProtocolVersion(minimumProtocolVersion);
proxy.setMinimumRPCVersion(minimumRPCVersion);
if (sdlSecList != null && !sdlSecList.isEmpty()) {
- proxy.setSdlSecurityClassList(sdlSecList);
+ proxy.setSdlSecurity(sdlSecList, serviceEncryptionListener);
}
//Setup the notification queue
initNotificationQueue();
@@ -900,6 +901,13 @@ public class SdlManager extends BaseSdlManager{
}
}
+ @Override
+ public void startRPCEncryption() {
+ if (proxy != null) {
+ proxy.startProtectedRPCService();
+ }
+ }
+
};
@@ -1097,12 +1105,24 @@ public class SdlManager extends BaseSdlManager{
* Sets the Security library
* @param secList The list of security class(es)
*/
+ @Deprecated
public Builder setSdlSecurity(List<Class<? extends SdlSecurityBase>> secList) {
sdlManager.sdlSecList = secList;
return this;
}
/**
+ * Sets the security libraries and a callback to notify caller when there is update to encryption service
+ * @param secList The list of security class(es)
+ * @param listener The callback object
+ */
+ public Builder setSdlSecurity(@NonNull List<Class<? extends SdlSecurityBase>> secList, ServiceEncryptionListener listener) {
+ sdlManager.sdlSecList = secList;
+ sdlManager.serviceEncryptionListener = listener;
+ return this;
+ }
+
+ /**
* Set the SdlManager Listener
* @param listener the listener
*/
@@ -1173,4 +1193,13 @@ public class SdlManager extends BaseSdlManager{
return sdlManager;
}
}
+
+ /**
+ * Start a secured RPC service
+ */
+ public void startRPCEncryption() {
+ if (proxy != null) {
+ proxy.startProtectedRPCService();
+ }
+ }
}
diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyBase.java b/android/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyBase.java
index ec6c751b8..30ebb6cb5 100644
--- a/android/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyBase.java
+++ b/android/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyBase.java
@@ -61,6 +61,7 @@ import com.smartdevicelink.encoder.VirtualDisplayEncoder;
import com.smartdevicelink.exception.SdlException;
import com.smartdevicelink.exception.SdlExceptionCause;
import com.smartdevicelink.haptic.HapticInterfaceManager;
+import com.smartdevicelink.managers.ServiceEncryptionListener;
import com.smartdevicelink.managers.lifecycle.RpcConverter;
import com.smartdevicelink.marshal.JsonRPCMarshaller;
import com.smartdevicelink.protocol.ProtocolMessage;
@@ -149,8 +150,10 @@ import java.net.ProtocolException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.HashSet;
import java.util.Hashtable;
import java.util.List;
+import java.util.Set;
import java.util.Vector;
import java.util.concurrent.Callable;
import java.util.concurrent.CopyOnWriteArrayList;
@@ -307,6 +310,9 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
private Version minimumProtocolVersion;
private Version minimumRPCVersion;
+ private Set<String> encryptionRequiredRPCs = new HashSet<>();
+ private boolean rpcSecuredServiceStarted;
+ private ServiceEncryptionListener serviceEncryptionListener;
// Interface broker
private SdlInterfaceBroker _interfaceBroker = null;
@@ -504,6 +510,11 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
AudioStreamingParams params) {
return SdlProxyBase.this.startAudioStream(isEncrypted, codec, params);
}
+
+ @Override
+ public void startRPCEncryption() {
+ SdlProxyBase.this.startProtectedRPCService();
+ }
};
private void notifyPutFileStreamError(Exception e, String info)
@@ -1022,8 +1033,14 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
_outgoingProxyMessageDispatcher = null;
}
throw e;
- }
-
+ }
+
+ addOnRPCNotificationListener(FunctionID.ON_PERMISSIONS_CHANGE, onPermissionsChangeListener);
+ this._internalInterface.addServiceListener(SessionType.RPC, securedServiceListener);
+ this._internalInterface.addServiceListener(SessionType.NAV, securedServiceListener);
+ this._internalInterface.addServiceListener(SessionType.PCM, securedServiceListener);
+
+
// Trace that ctor has fired
SdlTrace.logProxyEvent("SdlProxy Created, instanceID=" + this.toString(), SDL_LIB_TRACE_KEY);
}
@@ -1791,6 +1808,9 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
}
_proxyDisposed = true;
+ rpcSecuredServiceStarted = false;
+ encryptionRequiredRPCs.clear();
+ serviceEncryptionListener = null;
SdlTrace.logProxyEvent("Application called dispose() method.", SDL_LIB_TRACE_KEY);
@@ -2105,7 +2125,89 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
_proxyListener.onError("Proxy callback dispatcher is down. Proxy instance is invalid.", e);
}
/************* END Functions used by the Message Dispatching Queues ****************/
-
+
+
+ private OnRPCNotificationListener onPermissionsChangeListener = new OnRPCNotificationListener() {
+ @Override
+ public void onNotified(RPCNotification notification) {
+ List<PermissionItem> permissionItems = ((OnPermissionsChange) notification).getPermissionItem();
+ Boolean requireEncryptionAppLevel = ((OnPermissionsChange) notification).getRequireEncryption();
+ encryptionRequiredRPCs.clear();
+ if (requireEncryptionAppLevel == null || requireEncryptionAppLevel) {
+ if (permissionItems != null && !permissionItems.isEmpty()) {
+ for (PermissionItem permissionItem : permissionItems) {
+ if (permissionItem != null && Boolean.TRUE.equals(permissionItem.getRequireEncryption())) {
+ String rpcName = permissionItem.getRpcName();
+ if (rpcName != null) {
+ encryptionRequiredRPCs.add(rpcName);
+ }
+ }
+ }
+ }
+ checkStatusAndInitSecuredService();
+ }
+ }
+ };
+
+ private ISdlServiceListener securedServiceListener = new ISdlServiceListener() {
+ @Override
+ public void onServiceStarted(SdlSession session, SessionType type, boolean isEncrypted) {
+ if(SessionType.RPC.equals(type)){
+ rpcSecuredServiceStarted = isEncrypted;
+ }
+ if (serviceEncryptionListener != null) {
+ serviceEncryptionListener.onEncryptionServiceUpdated(type, isEncrypted, null);
+ }
+ DebugTool.logInfo("onServiceStarted, session Type: " + type.getName() + ", isEncrypted: " + isEncrypted);
+ }
+
+ @Override
+ public void onServiceEnded(SdlSession session, SessionType type) {
+ if (SessionType.RPC.equals(type)) {
+ rpcSecuredServiceStarted = false;
+ }
+ if (serviceEncryptionListener != null) {
+ serviceEncryptionListener.onEncryptionServiceUpdated(type, false, null);
+ }
+ DebugTool.logInfo("onServiceEnded, session Type: " + type.getName());
+ }
+
+ @Override
+ public void onServiceError(SdlSession session, SessionType type, String reason) {
+ if (SessionType.RPC.equals(type)) {
+ rpcSecuredServiceStarted = false;
+ }
+ if (serviceEncryptionListener != null) {
+ serviceEncryptionListener.onEncryptionServiceUpdated(type, false, "onServiceError: " + reason);
+ }
+ DebugTool.logError("onServiceError, session Type: " + type.getName() + ", reason: " + reason);
+ }
+ };
+
+ /**
+ * Checks if an RPC requires encryption
+ *
+ * @param rpcName the rpc name (FunctionID) to check
+ * @return true if the given RPC requires encryption; false, otherwise
+ */
+ public boolean getRPCRequiresEncryption(@NonNull FunctionID rpcName) {
+ return encryptionRequiredRPCs.contains(rpcName.toString());
+ }
+
+ /**
+ * Gets the encryption requirement
+ * @return true if encryption is required; false otherwise
+ */
+ public boolean getRequiresEncryption() {
+ return !encryptionRequiredRPCs.isEmpty();
+ }
+
+ private void checkStatusAndInitSecuredService() {
+ if ((_hmiLevel != null && _hmiLevel != HMILevel.HMI_NONE) && getRequiresEncryption() && !rpcSecuredServiceStarted) {
+ startProtectedRPCService();
+ }
+ }
+
// Private sendRPCMessagePrivate method. All RPCMessages are funneled through this method after error checking.
protected void sendRPCMessagePrivate(RPCMessage message) throws SdlException {
try {
@@ -2149,8 +2251,24 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
pm.setMessageType(MessageType.RPC);
pm.setSessionType(SessionType.RPC);
pm.setFunctionID(FunctionID.getFunctionId(message.getFunctionName()));
- pm.setPayloadProtected(message.isPayloadProtected());
-
+ if (rpcSecuredServiceStarted && getRPCRequiresEncryption(message.getFunctionID())) {
+ pm.setPayloadProtected(true);
+ } else {
+ pm.setPayloadProtected(message.isPayloadProtected());
+ }
+ if (pm.getPayloadProtected() && (!rpcSecuredServiceStarted || !rpcProtectedStartResponse)){
+ String errorInfo = "Trying to send an encrypted message and there is no secured service";
+ if (message.getMessageType().equals((RPCMessage.KEY_REQUEST))) {
+ RPCRequest request = (RPCRequest) message;
+ OnRPCResponseListener listener = ((RPCRequest) message).getOnRPCResponseListener();
+ if (listener != null) {
+ listener.onError(request.getCorrelationID(), Result.ABORTED, errorInfo);
+ }
+ }
+ DebugTool.logWarning(errorInfo);
+ return;
+ }
+
if (sdlSession != null) {
pm.setSessionID(sdlSession.getSessionId());
}
@@ -3856,6 +3974,9 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
if (msg.getHmiLevel() == HMILevel.HMI_FULL) firstTimeFull = false;
_hmiLevel = msg.getHmiLevel();
+ if (_hmiLevel != HMILevel.HMI_NONE) {
+ checkStatusAndInitSecuredService();
+ }
_audioStreamingState = msg.getAudioStreamingState();
msg.format(rpcSpecVersion, true);
@@ -7949,11 +8070,22 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
return sdlSession.getCurrentTransportType();
}
-
+
+ @Deprecated
public void setSdlSecurityClassList(List<Class<? extends SdlSecurityBase>> list) {
_secList = list;
- }
-
+ }
+
+ /**
+ * Sets the security libraries and a callback to notify caller when there is update to encryption service
+ * @param secList The list of security class(es)
+ * @param listener The callback object
+ */
+ public void setSdlSecurity(@NonNull List<Class<? extends SdlSecurityBase>> secList, ServiceEncryptionListener listener) {
+ _secList = secList;
+ serviceEncryptionListener = listener;
+ }
+
private void setSdlSecurity(SdlSecurityBase sec) {
if (sdlSession != null)
{
diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/transport/SdlRouterService.java b/android/sdl_android/src/main/java/com/smartdevicelink/transport/SdlRouterService.java
index 5273acd0e..3abd61094 100644
--- a/android/sdl_android/src/main/java/com/smartdevicelink/transport/SdlRouterService.java
+++ b/android/sdl_android/src/main/java/com/smartdevicelink/transport/SdlRouterService.java
@@ -1173,9 +1173,7 @@ public class SdlRouterService extends Service{
disconnectFilter.addAction(BluetoothDevice.ACTION_CLASS_CHANGED);
disconnectFilter.addAction(BluetoothDevice.ACTION_ACL_DISCONNECTED);
disconnectFilter.addAction(BluetoothDevice.ACTION_ACL_DISCONNECT_REQUESTED);
- if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB){
- disconnectFilter.addAction(BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED);
- }
+ disconnectFilter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED);
registerReceiver(mListenForDisconnect,disconnectFilter );
IntentFilter filter = new IntentFilter();
diff --git a/base/src/main/java/com/smartdevicelink/managers/ServiceEncryptionListener.java b/base/src/main/java/com/smartdevicelink/managers/ServiceEncryptionListener.java
new file mode 100644
index 000000000..fedefdec2
--- /dev/null
+++ b/base/src/main/java/com/smartdevicelink/managers/ServiceEncryptionListener.java
@@ -0,0 +1,10 @@
+package com.smartdevicelink.managers;
+
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+
+import com.smartdevicelink.protocol.enums.SessionType;
+
+public interface ServiceEncryptionListener {
+ void onEncryptionServiceUpdated(@NonNull SessionType serviceType, boolean isServiceEncrypted, @Nullable String error);
+} \ No newline at end of file
diff --git a/base/src/main/java/com/smartdevicelink/managers/lifecycle/BaseEncryptionLifecycleManager.java b/base/src/main/java/com/smartdevicelink/managers/lifecycle/BaseEncryptionLifecycleManager.java
new file mode 100644
index 000000000..808f4b0cd
--- /dev/null
+++ b/base/src/main/java/com/smartdevicelink/managers/lifecycle/BaseEncryptionLifecycleManager.java
@@ -0,0 +1,182 @@
+/*
+ * Copyright (c) 2019 Livio, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the Livio Inc. nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package com.smartdevicelink.managers.lifecycle;
+
+import android.support.annotation.NonNull;
+import com.smartdevicelink.SdlConnection.SdlSession;
+import com.smartdevicelink.managers.ServiceEncryptionListener;
+import com.smartdevicelink.protocol.enums.FunctionID;
+import com.smartdevicelink.protocol.enums.SessionType;
+import com.smartdevicelink.proxy.RPCNotification;
+import com.smartdevicelink.proxy.interfaces.ISdl;
+import com.smartdevicelink.proxy.interfaces.ISdlServiceListener;
+import com.smartdevicelink.proxy.rpc.OnHMIStatus;
+import com.smartdevicelink.proxy.rpc.OnPermissionsChange;
+import com.smartdevicelink.proxy.rpc.PermissionItem;
+import com.smartdevicelink.proxy.rpc.enums.HMILevel;
+import com.smartdevicelink.proxy.rpc.listeners.OnRPCNotificationListener;
+import com.smartdevicelink.util.DebugTool;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+abstract class BaseEncryptionLifecycleManager {
+ private ISdl internalInterface;
+ private ServiceEncryptionListener serviceEncryptionListener;
+ private HMILevel currentHMILevel;
+ private Set<String> encryptionRequiredRPCs = new HashSet<>();
+ private boolean rpcSecuredServiceStarted;
+
+ BaseEncryptionLifecycleManager(@NonNull ISdl isdl, ServiceEncryptionListener listener) {
+ internalInterface = isdl;
+ serviceEncryptionListener = listener;
+ rpcSecuredServiceStarted = false;
+
+ OnRPCNotificationListener onHMIStatusListener = new OnRPCNotificationListener() {
+ @Override
+ public void onNotified(RPCNotification notification) {
+ OnHMIStatus onHMIStatus = (OnHMIStatus) notification;
+ currentHMILevel = onHMIStatus.getHmiLevel();
+ checkStatusAndInitSecuredService();
+ }
+ };
+
+ OnRPCNotificationListener onPermissionsChangeListener = new OnRPCNotificationListener() {
+ @Override
+ public void onNotified(RPCNotification notification) {
+ List<PermissionItem> permissionItems = ((OnPermissionsChange) notification).getPermissionItem();
+ Boolean requireEncryptionAppLevel = ((OnPermissionsChange) notification).getRequireEncryption();
+ encryptionRequiredRPCs.clear();
+ if (requireEncryptionAppLevel == null || requireEncryptionAppLevel) {
+ if (permissionItems != null && !permissionItems.isEmpty()) {
+ for (PermissionItem permissionItem : permissionItems) {
+ if (permissionItem != null && Boolean.TRUE.equals(permissionItem.getRequireEncryption())) {
+ String rpcName = permissionItem.getRpcName();
+ if (rpcName != null) {
+ encryptionRequiredRPCs.add(rpcName);
+ }
+ }
+ }
+ }
+ checkStatusAndInitSecuredService();
+ }
+ }
+ };
+
+ ISdlServiceListener securedServiceListener = new ISdlServiceListener() {
+ @Override
+ public void onServiceStarted(SdlSession session, SessionType type, boolean isEncrypted) {
+ if(SessionType.RPC.equals(type)){
+ rpcSecuredServiceStarted = isEncrypted;
+ }
+ if (serviceEncryptionListener != null) {
+ serviceEncryptionListener.onEncryptionServiceUpdated(type, isEncrypted, null);
+ }
+ DebugTool.logInfo("onServiceStarted, session Type: " + type.getName() + ", isEncrypted: " + isEncrypted);
+ }
+
+ @Override
+ public void onServiceEnded(SdlSession session, SessionType type) {
+ if (SessionType.RPC.equals(type)) {
+ rpcSecuredServiceStarted = false;
+ }
+ if (serviceEncryptionListener != null) {
+ serviceEncryptionListener.onEncryptionServiceUpdated(type, false, null);
+ }
+ DebugTool.logInfo("onServiceEnded, session Type: " + type.getName());
+ }
+
+ @Override
+ public void onServiceError(SdlSession session, SessionType type, String reason) {
+ if (SessionType.RPC.equals(type)) {
+ rpcSecuredServiceStarted = false;
+ }
+ if (serviceEncryptionListener != null) {
+ serviceEncryptionListener.onEncryptionServiceUpdated(type, false, "onServiceError: " + reason);
+ }
+ DebugTool.logError("onServiceError, session Type: " + type.getName() + ", reason: " + reason);
+ }
+ };
+
+ internalInterface.addOnRPCNotificationListener(FunctionID.ON_HMI_STATUS, onHMIStatusListener);
+ internalInterface.addOnRPCNotificationListener(FunctionID.ON_PERMISSIONS_CHANGE, onPermissionsChangeListener);
+ internalInterface.addServiceListener(SessionType.RPC, securedServiceListener);
+ }
+
+ /**
+ * Gets the app level encryption requirement
+ *
+ * @return true if encryption is required for app level; false otherwise
+ */
+ private boolean getRequiresEncryption() {
+ return !encryptionRequiredRPCs.isEmpty();
+ }
+
+ /**
+ * Checks if an RPC requires encryption
+ *
+ * @param rpcName the rpc name to check
+ * @return true if the given RPC requires encryption; false, otherwise
+ */
+ boolean getRPCRequiresEncryption(@NonNull FunctionID rpcName) {
+ return encryptionRequiredRPCs.contains(rpcName.toString());
+ }
+
+ /**
+ * Checks the current state and make the call back to initiate secured service flow
+ */
+ private void checkStatusAndInitSecuredService() {
+ if ((currentHMILevel != null && currentHMILevel != HMILevel.HMI_NONE) && getRequiresEncryption() && !isEncryptionReady() ) {
+ internalInterface.startRPCEncryption();
+ }
+ }
+
+ /**
+ * Check to see if a secured service is ready to use
+ *
+ * @return true if there is a secured service; false otherwise
+ */
+ boolean isEncryptionReady() {
+ return rpcSecuredServiceStarted;
+ }
+
+ /**
+ * Clean up everything after the manager is no longer needed
+ */
+ void dispose() {
+ rpcSecuredServiceStarted = false;
+ encryptionRequiredRPCs.clear();
+ serviceEncryptionListener = null;
+ }
+}
diff --git a/base/src/main/java/com/smartdevicelink/managers/permission/BasePermissionManager.java b/base/src/main/java/com/smartdevicelink/managers/permission/BasePermissionManager.java
index 23b0ab8f7..5e242e21e 100644
--- a/base/src/main/java/com/smartdevicelink/managers/permission/BasePermissionManager.java
+++ b/base/src/main/java/com/smartdevicelink/managers/permission/BasePermissionManager.java
@@ -50,8 +50,10 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import java.util.UUID;
/**
@@ -67,6 +69,7 @@ abstract class BasePermissionManager extends BaseSubManager{
private Map<FunctionID, PermissionItem> currentPermissionItems;
private OnRPCNotificationListener onHMIStatusListener, onPermissionsChangeListener;
private List<PermissionFilter> filters;
+ private Set<String> encryptionRequiredRPCs = new HashSet<>();
// Permission groups status constants
@IntDef({PERMISSION_GROUP_STATUS_ALLOWED, PERMISSION_GROUP_STATUS_DISALLOWED,
@@ -116,6 +119,8 @@ abstract class BasePermissionManager extends BaseSubManager{
public void onNotified(RPCNotification notification) {
List<PermissionItem> permissionItems = ((OnPermissionsChange)notification).getPermissionItem();
Map<FunctionID, PermissionItem> previousPermissionItems = currentPermissionItems;
+ Boolean requireEncryptionAppLevel = ((OnPermissionsChange) notification).getRequireEncryption();
+ encryptionRequiredRPCs.clear();
currentPermissionItems = new HashMap<>();
if (permissionItems != null && !permissionItems.isEmpty()) {
for (PermissionItem permissionItem : permissionItems) {
@@ -123,6 +128,14 @@ abstract class BasePermissionManager extends BaseSubManager{
if (functionID != null) {
currentPermissionItems.put(functionID, permissionItem);
}
+ if (Boolean.TRUE.equals(permissionItem.getRequireEncryption())) {
+ if (requireEncryptionAppLevel == null || requireEncryptionAppLevel) {
+ String rpcName = permissionItem.getRpcName();
+ if (rpcName != null) {
+ encryptionRequiredRPCs.add(rpcName);
+ }
+ }
+ }
}
}
notifyListeners(previousPermissionItems, currentHMILevel, currentPermissionItems, currentHMILevel);
@@ -138,6 +151,24 @@ abstract class BasePermissionManager extends BaseSubManager{
super.start(listener);
}
+ /**
+ * Checks if an RPC requires encryption
+ *
+ * @param rpcName the rpc name (FunctionID) to check
+ * @return true if the given RPC requires encryption; false, otherwise
+ */
+ public boolean getRPCRequiresEncryption(@NonNull FunctionID rpcName) {
+ return encryptionRequiredRPCs.contains(rpcName.toString());
+ }
+
+ /**
+ * Gets the encryption requirement
+ * @return true if encryption is required; false otherwise
+ */
+ public boolean getRequiresEncryption() {
+ return !encryptionRequiredRPCs.isEmpty();
+ }
+
private synchronized void checkState(){
if(this.getState() == SETTING_UP && currentHMILevel != null){
transitionToState(READY);
diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/BaseScreenManager.java b/base/src/main/java/com/smartdevicelink/managers/screen/BaseScreenManager.java
index a63333032..95f5d5732 100644
--- a/base/src/main/java/com/smartdevicelink/managers/screen/BaseScreenManager.java
+++ b/base/src/main/java/com/smartdevicelink/managers/screen/BaseScreenManager.java
@@ -346,18 +346,18 @@ abstract class BaseScreenManager extends BaseSubManager {
/**
* Sets the title of the new template that will be displayed.
* Sending an empty String "" will clear the field
- * @param templateTitle the title of the new template that will be displayed. Maxlength: 100.
+ * @param title the title of the new template that will be displayed. Maxlength: 100.
*/
- public void setTemplateTitle(String templateTitle){
- this.textAndGraphicManager.setTemplateTitle(templateTitle);
+ public void setTitle(String title){
+ this.textAndGraphicManager.setTitle(title);
}
/**
* Gets the title of the new template that will be displayed
- * @return templateTitle - String value that represents the title of the new template that will be displayed
+ * @return title - String value that represents the title of the new template that will be displayed
*/
public String getTemplateTitle(){
- return this.textAndGraphicManager.getTemplateTitle();
+ return this.textAndGraphicManager.getTitle();
}
/**
diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java b/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java
index 4faa2d71f..83190d078 100644
--- a/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java
+++ b/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java
@@ -94,7 +94,7 @@ abstract class BaseTextAndGraphicManager extends BaseSubManager {
private OnSystemCapabilityListener onDisplaysCapabilityListener;
private SdlArtwork primaryGraphic, secondaryGraphic;
private TextAlignment textAlignment;
- private String textField1, textField2, textField3, textField4, mediaTrackTextField, templateTitle;
+ private String textField1, textField2, textField3, textField4, mediaTrackTextField, title;
private MetadataType textField1Type, textField2Type, textField3Type, textField4Type;
//Constructors
@@ -132,7 +132,7 @@ abstract class BaseTextAndGraphicManager extends BaseSubManager {
textField4 = null;
textField4Type = null;
mediaTrackTextField = null;
- templateTitle = null;
+ title = null;
textAlignment = null;
primaryGraphic = null;
secondaryGraphic = null;
@@ -400,8 +400,8 @@ abstract class BaseTextAndGraphicManager extends BaseSubManager {
show.setMediaTrack(mediaTrackTextField);
}
- if (templateTitle != null){
- show.setTemplateTitle(templateTitle);
+ if (title != null){
+ show.setTemplateTitle(title);
}
List<String> nonNullFields = findValidMainTextFields();
@@ -923,8 +923,8 @@ abstract class BaseTextAndGraphicManager extends BaseSubManager {
return textField4Type;
}
- void setTemplateTitle(String templateTitle){
- this.templateTitle = templateTitle;
+ void setTitle(String title){
+ this.title = title;
if (!batchingUpdates){
sdlUpdate(null);
}else{
@@ -932,8 +932,8 @@ abstract class BaseTextAndGraphicManager extends BaseSubManager {
}
}
- String getTemplateTitle(){
- return templateTitle;
+ String getTitle(){
+ return title;
}
void setPrimaryGraphic(SdlArtwork primaryGraphic){
diff --git a/base/src/main/java/com/smartdevicelink/proxy/interfaces/ISdl.java b/base/src/main/java/com/smartdevicelink/proxy/interfaces/ISdl.java
index 4159bd8f8..244c34395 100644
--- a/base/src/main/java/com/smartdevicelink/proxy/interfaces/ISdl.java
+++ b/base/src/main/java/com/smartdevicelink/proxy/interfaces/ISdl.java
@@ -262,4 +262,9 @@ public interface ISdl {
* @return byte value representing WiPro version
*/
@NonNull Version getProtocolVersion();
+
+ /**
+ * Start encrypted RPC service
+ */
+ void startRPCEncryption();
}
diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/DiagnosticMessageResponse.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/DiagnosticMessageResponse.java
index bd8c5599c..53b7a32e0 100644
--- a/base/src/main/java/com/smartdevicelink/proxy/rpc/DiagnosticMessageResponse.java
+++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/DiagnosticMessageResponse.java
@@ -1,34 +1,34 @@
-/*
- * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following
- * disclaimer in the documentation and/or other materials provided with the
- * distribution.
- *
- * Neither the name of the SmartDeviceLink Consortium, Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
+/*
+ * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the SmartDeviceLink Consortium, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
package com.smartdevicelink.proxy.rpc;
import android.support.annotation.NonNull;
@@ -61,19 +61,33 @@ public class DiagnosticMessageResponse extends RPCResponse {
* Constructs a new DiagnosticMessageResponse object
* @param success whether the request is successfully processed
* @param resultCode whether the request is successfully processed
+ * @deprecated use {@link DiagnosticMessageResponse#DiagnosticMessageResponse(Boolean, Result)}
*/
+ @Deprecated
public DiagnosticMessageResponse(@NonNull Boolean success, @NonNull Result resultCode, @NonNull List<Integer> messageDataResult) {
this();
setSuccess(success);
setResultCode(resultCode);
setMessageDataResult(messageDataResult);
}
+
+ /**
+ * Constructs a new DiagnosticMessageResponse object
+ * @param success whether the request is successfully processed
+ * @param resultCode whether the request is successfully processed
+ */
+ public DiagnosticMessageResponse(@NonNull Boolean success, @NonNull Result resultCode) {
+ this();
+ setSuccess(success);
+ setResultCode(resultCode);
+ }
+
@SuppressWarnings("unchecked")
public List<Integer> getMessageDataResult() {
return (List<Integer>) getObject(Integer.class, KEY_MESSAGE_DATA_RESULT);
}
- public void setMessageDataResult(@NonNull List<Integer> messageDataResult) {
+ public void setMessageDataResult(List<Integer> messageDataResult) {
setParameters(KEY_MESSAGE_DATA_RESULT, messageDataResult);
}
diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/GetDTCsResponse.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/GetDTCsResponse.java
index be970cc39..a0de6de5c 100644
--- a/base/src/main/java/com/smartdevicelink/proxy/rpc/GetDTCsResponse.java
+++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/GetDTCsResponse.java
@@ -1,34 +1,34 @@
-/*
- * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following
- * disclaimer in the documentation and/or other materials provided with the
- * distribution.
- *
- * Neither the name of the SmartDeviceLink Consortium, Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
+/*
+ * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the SmartDeviceLink Consortium, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
package com.smartdevicelink.proxy.rpc;
import android.support.annotation.NonNull;
@@ -63,7 +63,9 @@ public class GetDTCsResponse extends RPCResponse{
* @param success whether the request is successfully processed
* @param resultCode whether the request is successfully processed
* @param ecuHeader representation of the ecu header that was returned from the GetDTC request
+ * @deprecated use {@link GetDTCsResponse#GetDTCsResponse(Boolean, Result)}
*/
+ @Deprecated
public GetDTCsResponse(@NonNull Boolean success, @NonNull Result resultCode, @NonNull Integer ecuHeader) {
this();
setSuccess(success);
@@ -71,6 +73,17 @@ public class GetDTCsResponse extends RPCResponse{
setEcuHeader(ecuHeader);
}
+ /**
+ * Constructs a new GetDTCsResponse object
+ * @param success whether the request is successfully processed
+ * @param resultCode whether the request is successfully processed
+ */
+ public GetDTCsResponse(@NonNull Boolean success, @NonNull Result resultCode) {
+ this();
+ setSuccess(success);
+ setResultCode(resultCode);
+ }
+
@SuppressWarnings("unchecked")
public List<String> getDtc(){
return (List<String>) getObject(String.class, KEY_DTC);
@@ -84,7 +97,7 @@ public class GetDTCsResponse extends RPCResponse{
return getInteger(KEY_ECU_HEADER);
}
- public void setEcuHeader(@NonNull Integer ecuHeader){
+ public void setEcuHeader(Integer ecuHeader){
setParameters(KEY_ECU_HEADER, ecuHeader);
}
diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/GetInteriorVehicleDataResponse.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/GetInteriorVehicleDataResponse.java
index 6c27b8b37..7a85ac129 100644
--- a/base/src/main/java/com/smartdevicelink/proxy/rpc/GetInteriorVehicleDataResponse.java
+++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/GetInteriorVehicleDataResponse.java
@@ -67,9 +67,10 @@ public class GetInteriorVehicleDataResponse extends RPCResponse {
* @param moduleData specific data for the module that was requested
* @param resultCode whether the request is successfully processed
* @param success whether the request is successfully processed
-
+ * @deprecated use {@link GetInteriorVehicleDataResponse#GetInteriorVehicleDataResponse(Result, Boolean)}
*/
- public GetInteriorVehicleDataResponse( @NonNull ModuleData moduleData, @NonNull Result resultCode, @NonNull Boolean success) {
+ @Deprecated
+ public GetInteriorVehicleDataResponse(@NonNull ModuleData moduleData, @NonNull Result resultCode, @NonNull Boolean success) {
this();
setModuleData(moduleData);
setResultCode(resultCode);
@@ -77,6 +78,17 @@ public class GetInteriorVehicleDataResponse extends RPCResponse {
}
/**
+ * Constructs a new GetInteriorVehicleDataResponse object
+ * @param resultCode whether the request is successfully processed
+ * @param success whether the request is successfully processed
+ */
+ public GetInteriorVehicleDataResponse(@NonNull Result resultCode, @NonNull Boolean success) {
+ this();
+ setResultCode(resultCode);
+ setSuccess(success);
+ }
+
+ /**
* Gets the moduleData
*
* @return ModuleData
diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/GetSystemCapabilityResponse.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/GetSystemCapabilityResponse.java
index 8029e77e2..f324de95f 100644
--- a/base/src/main/java/com/smartdevicelink/proxy/rpc/GetSystemCapabilityResponse.java
+++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/GetSystemCapabilityResponse.java
@@ -69,7 +69,9 @@ public class GetSystemCapabilityResponse extends RPCResponse {
* @param systemCapability SystemCapability object
* @param resultCode whether the request is successfully processed
* @param success whether the request is successfully processed
+ * @deprecated use {@link GetSystemCapabilityResponse#GetSystemCapabilityResponse(Result, Boolean)}
*/
+ @Deprecated
public GetSystemCapabilityResponse(@NonNull SystemCapability systemCapability, @NonNull Result resultCode, @NonNull Boolean success) {
this();
setSystemCapability(systemCapability);
@@ -78,6 +80,17 @@ public class GetSystemCapabilityResponse extends RPCResponse {
}
/**
+ * Constructs a new GetSystemCapabilityResponse object
+ * @param resultCode whether the request is successfully processed
+ * @param success whether the request is successfully processed
+ */
+ public GetSystemCapabilityResponse(@NonNull Result resultCode, @NonNull Boolean success) {
+ this();
+ setResultCode(resultCode);
+ setSuccess(success);
+ }
+
+ /**
* Get the SystemCapability object returned after a GetSystemCapability call
* @return SystemCapability object
*/
@@ -89,7 +102,7 @@ public class GetSystemCapabilityResponse extends RPCResponse {
* Set a SystemCapability object in the response
* @param value SystemCapability object
*/
- public void setSystemCapability(@NonNull SystemCapability value){
+ public void setSystemCapability(SystemCapability value){
setParameters(KEY_SYSTEM_CAPABILITY, value);
}
}
diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/OnPermissionsChange.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/OnPermissionsChange.java
index 4f5845e4a..7a9532e36 100644
--- a/base/src/main/java/com/smartdevicelink/proxy/rpc/OnPermissionsChange.java
+++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/OnPermissionsChange.java
@@ -1,34 +1,34 @@
-/*
- * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following
- * disclaimer in the documentation and/or other materials provided with the
- * distribution.
- *
- * Neither the name of the SmartDeviceLink Consortium, Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
+/*
+ * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the SmartDeviceLink Consortium, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
package com.smartdevicelink.proxy.rpc;
import android.support.annotation.NonNull;
@@ -82,6 +82,7 @@ import java.util.List;
*/
public class OnPermissionsChange extends RPCNotification {
public static final String KEY_PERMISSION_ITEM = "permissionItem";
+ public static final String KEY_REQUIRE_ENCRYPTION = "requireEncryption";
/**
*Constructs a newly allocated OnCommand object
*/
@@ -118,4 +119,20 @@ public class OnPermissionsChange extends RPCNotification {
public void setPermissionItem(@NonNull List<PermissionItem> permissionItem) {
setParameters(KEY_PERMISSION_ITEM, permissionItem);
}
+
+ /**
+ * Returns the encryption requirement for this permission change
+ * @return true if encryption is required, false otherwise
+ */
+ public Boolean getRequireEncryption() {
+ return getBoolean(KEY_REQUIRE_ENCRYPTION);
+ }
+
+ /**
+ * Sets the encryption requirement for this permission change
+ * @param isRequired the boolean requirement to be set
+ */
+ public void setRequireEncryption(Boolean isRequired) {
+ setParameters(KEY_REQUIRE_ENCRYPTION, isRequired);
+ }
}
diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/PermissionItem.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/PermissionItem.java
index 7b5801b96..63d9624f7 100644
--- a/base/src/main/java/com/smartdevicelink/proxy/rpc/PermissionItem.java
+++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/PermissionItem.java
@@ -1,34 +1,34 @@
-/*
- * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following
- * disclaimer in the documentation and/or other materials provided with the
- * distribution.
- *
- * Neither the name of the SmartDeviceLink Consortium, Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
+/*
+ * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the SmartDeviceLink Consortium, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
package com.smartdevicelink.proxy.rpc;
@@ -83,6 +83,7 @@ public class PermissionItem extends RPCStruct {
public static final String KEY_RPC_NAME = "rpcName";
public static final String KEY_HMI_PERMISSIONS = "hmiPermissions";
public static final String KEY_PARAMETER_PERMISSIONS = "parameterPermissions";
+ public static final String KEY_REQUIRE_ENCRYPTION = "requireEncryption";
/**
* Constructs a new PermissionItem object
*/
@@ -125,4 +126,20 @@ public class PermissionItem extends RPCStruct {
public void setParameterPermissions(@NonNull ParameterPermissions parameterPermissions) {
setValue(KEY_PARAMETER_PERMISSIONS, parameterPermissions);
}
+
+ /**
+ * Gets the encryption requirement for this item
+ * @return true is encryption is required, false otherwise
+ */
+ public Boolean getRequireEncryption() {
+ return (Boolean) getValue(KEY_REQUIRE_ENCRYPTION);
+ }
+
+ /**
+ * Sets the encryption requirement for this item
+ * @param isRequired the boolean requirement to be set
+ */
+ public void setRequireEncryption(Boolean isRequired) {
+ setValue(KEY_REQUIRE_ENCRYPTION, isRequired);
+ }
}
diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/SetInteriorVehicleDataResponse.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/SetInteriorVehicleDataResponse.java
index 072aac498..1e756ade9 100644
--- a/base/src/main/java/com/smartdevicelink/proxy/rpc/SetInteriorVehicleDataResponse.java
+++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/SetInteriorVehicleDataResponse.java
@@ -66,7 +66,9 @@ public class SetInteriorVehicleDataResponse extends RPCResponse {
* @param moduleData
* @param success whether the request is successfully processed
* @param resultCode whether the request is successfully processed
+ * @deprecated use {@link SetInteriorVehicleDataResponse#SetInteriorVehicleDataResponse(Result, Boolean)}
*/
+ @Deprecated
public SetInteriorVehicleDataResponse(@NonNull ModuleData moduleData, @NonNull Result resultCode, @NonNull Boolean success) {
this();
setModuleData(moduleData);
@@ -75,6 +77,17 @@ public class SetInteriorVehicleDataResponse extends RPCResponse {
}
/**
+ * Constructs a new SetInteriorVehicleDataResponse object
+ * @param success whether the request is successfully processed
+ * @param resultCode whether the request is successfully processed
+ */
+ public SetInteriorVehicleDataResponse(@NonNull Result resultCode, @NonNull Boolean success) {
+ this();
+ setResultCode(resultCode);
+ setSuccess(success);
+ }
+
+ /**
* Gets the moduleData
*
* @return ModuleData
@@ -88,7 +101,7 @@ public class SetInteriorVehicleDataResponse extends RPCResponse {
*
* @param moduleData
*/
- public void setModuleData(@NonNull ModuleData moduleData) {
+ public void setModuleData(ModuleData moduleData) {
setParameters(KEY_MODULE_DATA, moduleData);
}
}
diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/enums/Result.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/enums/Result.java
index 1df3bcba5..7bc9454aa 100644
--- a/base/src/main/java/com/smartdevicelink/proxy/rpc/enums/Result.java
+++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/enums/Result.java
@@ -1,34 +1,34 @@
-/*
- * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following
- * disclaimer in the documentation and/or other materials provided with the
- * distribution.
- *
- * Neither the name of the SmartDeviceLink Consortium, Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
+/*
+ * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the SmartDeviceLink Consortium, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
package com.smartdevicelink.proxy.rpc.enums;
/**
@@ -212,6 +212,10 @@ public enum Result {
* The data sent failed to pass CRC check in receiver end
*/
CORRUPTED_DATA,
+ /**
+ * The data sent needs to be encrypted
+ */
+ ENCRYPTION_NEEDED,
;
/**
diff --git a/baseAndroid/src/main/java/com/smartdevicelink/managers/ServiceEncryptionListener.java b/baseAndroid/src/main/java/com/smartdevicelink/managers/ServiceEncryptionListener.java
new file mode 120000
index 000000000..f35552f46
--- /dev/null
+++ b/baseAndroid/src/main/java/com/smartdevicelink/managers/ServiceEncryptionListener.java
@@ -0,0 +1 @@
+../../../../../../../base/src/main/java/com/smartdevicelink/managers/ServiceEncryptionListener.java \ No newline at end of file
diff --git a/javaSE/src/main/java/com/smartdevicelink/managers/SdlManager.java b/javaSE/src/main/java/com/smartdevicelink/managers/SdlManager.java
index 632c4ed85..29278b51e 100644
--- a/javaSE/src/main/java/com/smartdevicelink/managers/SdlManager.java
+++ b/javaSE/src/main/java/com/smartdevicelink/managers/SdlManager.java
@@ -34,6 +34,7 @@ package com.smartdevicelink.managers;
import android.support.annotation.NonNull;
import android.util.Log;
+
import com.smartdevicelink.managers.file.FileManager;
import com.smartdevicelink.managers.file.filetypes.SdlArtwork;
import com.smartdevicelink.managers.lifecycle.LifecycleConfigurationUpdate;
@@ -47,7 +48,12 @@ import com.smartdevicelink.proxy.RPCRequest;
import com.smartdevicelink.proxy.RPCResponse;
import com.smartdevicelink.proxy.SystemCapabilityManager;
import com.smartdevicelink.proxy.interfaces.ISdl;
-import com.smartdevicelink.proxy.rpc.*;
+import com.smartdevicelink.proxy.rpc.ChangeRegistration;
+import com.smartdevicelink.proxy.rpc.OnHMIStatus;
+import com.smartdevicelink.proxy.rpc.RegisterAppInterfaceResponse;
+import com.smartdevicelink.proxy.rpc.SetAppIcon;
+import com.smartdevicelink.proxy.rpc.TTSChunk;
+import com.smartdevicelink.proxy.rpc.TemplateColorScheme;
import com.smartdevicelink.proxy.rpc.enums.AppHMIType;
import com.smartdevicelink.proxy.rpc.enums.Language;
import com.smartdevicelink.proxy.rpc.enums.Result;
@@ -61,6 +67,7 @@ import com.smartdevicelink.transport.BaseTransportConfig;
import com.smartdevicelink.transport.enums.TransportType;
import com.smartdevicelink.util.DebugTool;
import com.smartdevicelink.util.Version;
+
import org.json.JSONException;
import java.util.ArrayList;
@@ -88,6 +95,7 @@ public class SdlManager extends BaseSdlManager{
private SdlArtwork appIcon;
private SdlManagerListener managerListener;
private List<Class<? extends SdlSecurityBase>> sdlSecList;
+ private ServiceEncryptionListener serviceEncryptionListener;
// Managers
@@ -194,7 +202,7 @@ public class SdlManager extends BaseSdlManager{
private void notifyDevListener(String info) {
if (managerListener != null) {
if (getState() == BaseSubManager.ERROR){
- managerListener.onError(this,info, null);
+ managerListener.onError(this, info, null);
} else {
managerListener.onStart(this);
}
@@ -316,7 +324,6 @@ public class SdlManager extends BaseSdlManager{
// MANAGER GETTERS
-
/**
* Gets the PermissionManager. <br>
* <strong>Note: PermissionManager should be used only after SdlManager.start() CompletionListener callback is completed successfully.</strong>
@@ -539,7 +546,7 @@ public class SdlManager extends BaseSdlManager{
_internalInterface = lifecycleManager.getInternalInterface(SdlManager.this);
if (sdlSecList != null && !sdlSecList.isEmpty()) {
- lifecycleManager.setSdlSecurityClassList(sdlSecList);
+ lifecycleManager.setSdlSecurity(sdlSecList, serviceEncryptionListener);
}
//Setup the notification queue
@@ -711,12 +718,24 @@ public class SdlManager extends BaseSdlManager{
* Sets the Security libraries
* @param secList The list of security class(es)
*/
+ @Deprecated
public Builder setSdlSecurity(List<Class<? extends SdlSecurityBase>> secList) {
sdlManager.sdlSecList = secList;
return this;
}
/**
+ * Sets the security libraries and a callback to notify caller when there is update to encryption service
+ * @param secList The list of security class(es)
+ * @param listener The callback object
+ */
+ public Builder setSdlSecurity(@NonNull List<Class<? extends SdlSecurityBase>> secList, ServiceEncryptionListener listener) {
+ sdlManager.sdlSecList = secList;
+ sdlManager.serviceEncryptionListener = listener;
+ return this;
+ }
+
+ /**
* Set the SdlManager Listener
* @param listener the listener
*/
@@ -774,4 +793,12 @@ public class SdlManager extends BaseSdlManager{
}
}
+ /**
+ * Start a secured RPC service
+ */
+ public void startRPCEncryption() {
+ if (lifecycleManager != null) {
+ lifecycleManager.startRPCEncryption();
+ }
+ }
}
diff --git a/javaSE/src/main/java/com/smartdevicelink/managers/lifecycle/EncryptionLifecycleManager.java b/javaSE/src/main/java/com/smartdevicelink/managers/lifecycle/EncryptionLifecycleManager.java
new file mode 100644
index 000000000..1d5915bf4
--- /dev/null
+++ b/javaSE/src/main/java/com/smartdevicelink/managers/lifecycle/EncryptionLifecycleManager.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2019 Livio, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the Livio Inc. nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package com.smartdevicelink.managers.lifecycle;
+
+import android.support.annotation.NonNull;
+
+import com.smartdevicelink.managers.ServiceEncryptionListener;
+import com.smartdevicelink.proxy.interfaces.ISdl;
+
+class EncryptionLifecycleManager extends BaseEncryptionLifecycleManager {
+
+ EncryptionLifecycleManager(@NonNull ISdl internalInterface, ServiceEncryptionListener listener) {
+ super(internalInterface, listener);
+ }
+}
diff --git a/javaSE/src/main/java/com/smartdevicelink/managers/lifecycle/LifecycleManager.java b/javaSE/src/main/java/com/smartdevicelink/managers/lifecycle/LifecycleManager.java
index f796a03f5..7b2d3ec32 100644
--- a/javaSE/src/main/java/com/smartdevicelink/managers/lifecycle/LifecycleManager.java
+++ b/javaSE/src/main/java/com/smartdevicelink/managers/lifecycle/LifecycleManager.java
@@ -32,22 +32,60 @@
package com.smartdevicelink.managers.lifecycle;
+import android.support.annotation.NonNull;
import android.support.annotation.RestrictTo;
import android.util.Log;
+
import com.smartdevicelink.SdlConnection.ISdlConnectionListener;
import com.smartdevicelink.SdlConnection.SdlSession;
import com.smartdevicelink.exception.SdlException;
import com.smartdevicelink.managers.SdlManager;
+import com.smartdevicelink.managers.ServiceEncryptionListener;
import com.smartdevicelink.marshal.JsonRPCMarshaller;
import com.smartdevicelink.protocol.ProtocolMessage;
import com.smartdevicelink.protocol.enums.FunctionID;
import com.smartdevicelink.protocol.enums.MessageType;
import com.smartdevicelink.protocol.enums.SessionType;
-import com.smartdevicelink.proxy.*;
-import com.smartdevicelink.proxy.interfaces.*;
-import com.smartdevicelink.proxy.rpc.*;
-import com.smartdevicelink.proxy.rpc.enums.*;
-import com.smartdevicelink.proxy.rpc.listeners.*;
+import com.smartdevicelink.proxy.RPCMessage;
+import com.smartdevicelink.proxy.RPCNotification;
+import com.smartdevicelink.proxy.RPCRequest;
+import com.smartdevicelink.proxy.RPCResponse;
+import com.smartdevicelink.proxy.SystemCapabilityManager;
+import com.smartdevicelink.proxy.interfaces.IAudioStreamListener;
+import com.smartdevicelink.proxy.interfaces.ISdl;
+import com.smartdevicelink.proxy.interfaces.ISdlServiceListener;
+import com.smartdevicelink.proxy.interfaces.IVideoStreamListener;
+import com.smartdevicelink.proxy.interfaces.OnSystemCapabilityListener;
+import com.smartdevicelink.proxy.rpc.OnAppInterfaceUnregistered;
+import com.smartdevicelink.proxy.rpc.OnButtonEvent;
+import com.smartdevicelink.proxy.rpc.OnButtonPress;
+import com.smartdevicelink.proxy.rpc.OnHMIStatus;
+import com.smartdevicelink.proxy.rpc.OnSystemRequest;
+import com.smartdevicelink.proxy.rpc.RegisterAppInterface;
+import com.smartdevicelink.proxy.rpc.RegisterAppInterfaceResponse;
+import com.smartdevicelink.proxy.rpc.SdlMsgVersion;
+import com.smartdevicelink.proxy.rpc.SubscribeButton;
+import com.smartdevicelink.proxy.rpc.SystemRequest;
+import com.smartdevicelink.proxy.rpc.TTSChunk;
+import com.smartdevicelink.proxy.rpc.TemplateColorScheme;
+import com.smartdevicelink.proxy.rpc.UnregisterAppInterface;
+import com.smartdevicelink.proxy.rpc.VehicleType;
+import com.smartdevicelink.proxy.rpc.enums.AppHMIType;
+import com.smartdevicelink.proxy.rpc.enums.AppInterfaceUnregisteredReason;
+import com.smartdevicelink.proxy.rpc.enums.ButtonName;
+import com.smartdevicelink.proxy.rpc.enums.FileType;
+import com.smartdevicelink.proxy.rpc.enums.HMILevel;
+import com.smartdevicelink.proxy.rpc.enums.Language;
+import com.smartdevicelink.proxy.rpc.enums.RequestType;
+import com.smartdevicelink.proxy.rpc.enums.Result;
+import com.smartdevicelink.proxy.rpc.enums.SdlDisconnectedReason;
+import com.smartdevicelink.proxy.rpc.enums.SystemCapabilityType;
+import com.smartdevicelink.proxy.rpc.listeners.OnMultipleRequestListener;
+import com.smartdevicelink.proxy.rpc.listeners.OnPutFileUpdateListener;
+import com.smartdevicelink.proxy.rpc.listeners.OnRPCListener;
+import com.smartdevicelink.proxy.rpc.listeners.OnRPCNotificationListener;
+import com.smartdevicelink.proxy.rpc.listeners.OnRPCRequestListener;
+import com.smartdevicelink.proxy.rpc.listeners.OnRPCResponseListener;
import com.smartdevicelink.security.SdlSecurityBase;
import com.smartdevicelink.streaming.audio.AudioStreamingCodec;
import com.smartdevicelink.streaming.audio.AudioStreamingParams;
@@ -64,7 +102,7 @@ import java.util.Vector;
import java.util.concurrent.CopyOnWriteArrayList;
/**
- * The lifecycle manager creates a centeral point for all SDL session logic to converge. It should only be used by
+ * The lifecycle manager creates a central point for all SDL session logic to converge. It should only be used by
* the library itself. Usage outside the library is not permitted and will not be protected for in the future.
*/
@RestrictTo(RestrictTo.Scope.LIBRARY)
@@ -100,6 +138,7 @@ public class LifecycleManager extends BaseLifecycleManager {
private final HashMap<Integer, CopyOnWriteArrayList<OnRPCRequestListener>> rpcRequestListeners;
protected final SystemCapabilityManager systemCapabilityManager;
+ private EncryptionLifecycleManager encryptionLifecycleManager;
protected RegisterAppInterfaceResponse raiResponse = null;
@@ -128,7 +167,6 @@ public class LifecycleManager extends BaseLifecycleManager {
this.session = new SdlSession(sdlConnectionListener, config);
this.systemCapabilityManager = new SystemCapabilityManager(internalInterface);
-
}
public void start(){
@@ -141,6 +179,15 @@ public class LifecycleManager extends BaseLifecycleManager {
}
+ /**
+ * Start a secured RPC service
+ */
+ public void startRPCEncryption() {
+ if (session != null) {
+ session.startService(SessionType.RPC, session.getSessionId(), true);
+ }
+ }
+
public void stop(){
session.close();
}
@@ -735,7 +782,7 @@ public class LifecycleManager extends BaseLifecycleManager {
message.format(rpcSpecVersion,true);
byte[] msgBytes = JsonRPCMarshaller.marshall(message, (byte)getProtocolVersion().getMajor());
- ProtocolMessage pm = new ProtocolMessage();
+ final ProtocolMessage pm = new ProtocolMessage();
pm.setData(msgBytes);
if (session != null){
pm.setSessionID(session.getSessionId());
@@ -744,7 +791,24 @@ public class LifecycleManager extends BaseLifecycleManager {
pm.setMessageType(MessageType.RPC);
pm.setSessionType(SessionType.RPC);
pm.setFunctionID(FunctionID.getFunctionId(message.getFunctionName()));
- pm.setPayloadProtected(message.isPayloadProtected());
+
+ if (encryptionLifecycleManager != null && encryptionLifecycleManager.isEncryptionReady() && encryptionLifecycleManager.getRPCRequiresEncryption(message.getFunctionID())) {
+ pm.setPayloadProtected(true);
+ } else {
+ pm.setPayloadProtected(message.isPayloadProtected());
+ }
+ if (pm.getPayloadProtected() && (encryptionLifecycleManager == null || !encryptionLifecycleManager.isEncryptionReady())){
+ String errorInfo = "Trying to send an encrypted message and there is no secured service";
+ if (message.getMessageType().equals((RPCMessage.KEY_REQUEST))) {
+ RPCRequest request = (RPCRequest) message;
+ OnRPCResponseListener listener = ((RPCRequest) message).getOnRPCResponseListener();
+ if (listener != null) {
+ listener.onError(request.getCorrelationID(), Result.ABORTED, errorInfo);
+ }
+ }
+ DebugTool.logWarning(errorInfo);
+ return;
+ }
if(RPCMessage.KEY_REQUEST.equals(message.getMessageType())){ // Request Specifics
pm.setRPCType((byte)0x00);
@@ -1113,7 +1177,11 @@ public class LifecycleManager extends BaseLifecycleManager {
public Version getProtocolVersion() {
return LifecycleManager.this.getProtocolVersion();
}
-
+
+ @Override
+ public void startRPCEncryption() {
+ LifecycleManager.this.startRPCEncryption();
+ }
};
/* *******************************************************************************************************
@@ -1345,12 +1413,26 @@ public class LifecycleManager extends BaseLifecycleManager {
if (session != null && session.getIsConnected()) {
session.close();
}
+ if (encryptionLifecycleManager != null){
+ encryptionLifecycleManager.dispose();
+ }
}
+ @Deprecated
public void setSdlSecurityClassList(List<Class<? extends SdlSecurityBase>> list) {
_secList = list;
}
+ /**
+ * Sets the security libraries and a callback to notify caller when there is update to encryption service
+ * @param secList The list of security class(es)
+ * @param listener The callback object
+ */
+ public void setSdlSecurity(@NonNull List<Class<? extends SdlSecurityBase>> secList, ServiceEncryptionListener listener) {
+ this._secList = secList;
+ this.encryptionLifecycleManager = new EncryptionLifecycleManager(internalInterface, listener);
+ }
+
private void processRaiResponse(RegisterAppInterfaceResponse rai) {
if (rai == null) return;