diff options
Diffstat (limited to 'sdl_android/src/main/java/com')
29 files changed, 643 insertions, 80 deletions
diff --git a/sdl_android/src/main/java/com/smartdevicelink/SdlConnection/ISdlConnectionListener.java b/sdl_android/src/main/java/com/smartdevicelink/SdlConnection/ISdlConnectionListener.java index 8c9032d7b..627c6eca9 100644 --- a/sdl_android/src/main/java/com/smartdevicelink/SdlConnection/ISdlConnectionListener.java +++ b/sdl_android/src/main/java/com/smartdevicelink/SdlConnection/ISdlConnectionListener.java @@ -35,4 +35,6 @@ public interface ISdlConnectionListener { public void onHeartbeatTimedOut(byte sessionID);
public void onProtocolServiceDataACK(SessionType sessionType, int dataSize, byte sessionID);
+
+ void onAuthTokenReceived(String authToken, byte sessionID);
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/SdlConnection/SdlConnection.java b/sdl_android/src/main/java/com/smartdevicelink/SdlConnection/SdlConnection.java index 1d7055045..f67ac66af 100644 --- a/sdl_android/src/main/java/com/smartdevicelink/SdlConnection/SdlConnection.java +++ b/sdl_android/src/main/java/com/smartdevicelink/SdlConnection/SdlConnection.java @@ -37,7 +37,7 @@ public class SdlConnection implements IProtocolListener, ITransportListener { SdlTransport _transport = null;
AbstractProtocol _protocol = null;
ISdlConnectionListener _connectionListener = null;
-
+
// Thread safety locks
@@ -341,7 +341,13 @@ public class SdlConnection implements IProtocolListener, ITransportListener { }
}
return null;
- }
+ }
+
+ public void onAuthTokenReceived(String authToken, byte sessionID) {
+ if(this._connectionListener != null){
+ this._connectionListener.onAuthTokenReceived(authToken,sessionID);
+ }
+ }
private class InternalMsgDispatcher implements ISdlConnectionListener {
@@ -473,6 +479,14 @@ public class SdlConnection implements IProtocolListener, ITransportListener { session.onProtocolServiceDataACK(serviceType, dataSize, sessionID);
}
}
+
+ @Override
+ public void onAuthTokenReceived(String authToken, byte sessionID) {
+ SdlSession session = findSessionById(sessionID);
+ if (session != null) {
+ session.onAuthTokenReceived(authToken,sessionID);
+ }
+ }
}
public int getRegisterCount() {
diff --git a/sdl_android/src/main/java/com/smartdevicelink/SdlConnection/SdlSession.java b/sdl_android/src/main/java/com/smartdevicelink/SdlConnection/SdlSession.java index f509f412c..44df5f64c 100644 --- a/sdl_android/src/main/java/com/smartdevicelink/SdlConnection/SdlSession.java +++ b/sdl_android/src/main/java/com/smartdevicelink/SdlConnection/SdlSession.java @@ -658,6 +658,11 @@ public class SdlSession implements ISdlConnectionListener, IHeartbeatMonitorList }
@Override
+ public void onAuthTokenReceived(String authToken, byte sessionId) {
+ this.sessionListener.onAuthTokenReceived(authToken, sessionId);
+ }
+
+ @Override
public void onSecurityInitialized() {
if (_sdlConnection != null && sdlSecurity != null)
diff --git a/sdl_android/src/main/java/com/smartdevicelink/SdlConnection/SdlSession2.java b/sdl_android/src/main/java/com/smartdevicelink/SdlConnection/SdlSession2.java index 501fc31c8..913c8d5ee 100644 --- a/sdl_android/src/main/java/com/smartdevicelink/SdlConnection/SdlSession2.java +++ b/sdl_android/src/main/java/com/smartdevicelink/SdlConnection/SdlSession2.java @@ -233,6 +233,8 @@ public class SdlSession2 extends SdlSession implements ISdlProtocol{ public void onResetOutgoingHeartbeat(SessionType sessionType, byte sessionID) {/* Not supported */} @Override public void onResetIncomingHeartbeat(SessionType sessionType, byte sessionID) {/* Not supported */} + @Override + public void onAuthTokenReceived(String authToken, byte sessionID){/* Do nothing */ } /* *********************************************************************************************************************************************************************** * ***************************************************************** Security Listener ********************************************************************************* @@ -270,6 +272,11 @@ public class SdlSession2 extends SdlSession implements ISdlProtocol{ } + @Override + public void onAuthTokenReceived(String authToken) { + sessionListener.onAuthTokenReceived(authToken,sessionId); + } + /** * Check to see if a transport is available to start/use the supplied service. * @param sessionType the session that should be checked for transport availability diff --git a/sdl_android/src/main/java/com/smartdevicelink/managers/ProxyBridge.java b/sdl_android/src/main/java/com/smartdevicelink/managers/ProxyBridge.java index b8d97f39c..29b7c1387 100644 --- a/sdl_android/src/main/java/com/smartdevicelink/managers/ProxyBridge.java +++ b/sdl_android/src/main/java/com/smartdevicelink/managers/ProxyBridge.java @@ -22,6 +22,7 @@ import com.smartdevicelink.proxy.rpc.DiagnosticMessageResponse; import com.smartdevicelink.proxy.rpc.DialNumberResponse; import com.smartdevicelink.proxy.rpc.EndAudioPassThruResponse; import com.smartdevicelink.proxy.rpc.GenericResponse; +import com.smartdevicelink.proxy.rpc.GetCloudAppPropertiesResponse; import com.smartdevicelink.proxy.rpc.GetDTCsResponse; import com.smartdevicelink.proxy.rpc.GetInteriorVehicleDataResponse; import com.smartdevicelink.proxy.rpc.GetSystemCapabilityResponse; @@ -58,6 +59,7 @@ import com.smartdevicelink.proxy.rpc.ScrollableMessageResponse; import com.smartdevicelink.proxy.rpc.SendHapticDataResponse; import com.smartdevicelink.proxy.rpc.SendLocationResponse; import com.smartdevicelink.proxy.rpc.SetAppIconResponse; +import com.smartdevicelink.proxy.rpc.SetCloudAppPropertiesResponse; import com.smartdevicelink.proxy.rpc.SetDisplayLayoutResponse; import com.smartdevicelink.proxy.rpc.SetGlobalPropertiesResponse; import com.smartdevicelink.proxy.rpc.SetInteriorVehicleDataResponse; @@ -557,4 +559,14 @@ public class ProxyBridge implements IProxyListener{ public void onOnRCStatus(OnRCStatus notification) { onRPCReceived(notification); } + + @Override + public void onSetCloudAppProperties(SetCloudAppPropertiesResponse response) { + onRPCReceived(response); + } + + @Override + public void onGetCloudAppProperties(GetCloudAppPropertiesResponse response) { + onRPCReceived(response); + } } diff --git a/sdl_android/src/main/java/com/smartdevicelink/managers/SdlManager.java b/sdl_android/src/main/java/com/smartdevicelink/managers/SdlManager.java index b1c281903..0a97c518b 100644 --- a/sdl_android/src/main/java/com/smartdevicelink/managers/SdlManager.java +++ b/sdl_android/src/main/java/com/smartdevicelink/managers/SdlManager.java @@ -391,6 +391,15 @@ public class SdlManager{ return null; } + /** + * Retrieves the auth token, if any, that was attached to the StartServiceACK for the RPC + * service from the module. For example, this should be used to login to a user account. + * @return the string representation of the auth token + */ + public String getAuthToken(){ + return this.proxy.getAuthToken(); + } + // PROTECTED GETTERS protected String getAppName() { return appName; } diff --git a/sdl_android/src/main/java/com/smartdevicelink/protocol/ISdlProtocol.java b/sdl_android/src/main/java/com/smartdevicelink/protocol/ISdlProtocol.java index beb78a90a..32a21ec2a 100644 --- a/sdl_android/src/main/java/com/smartdevicelink/protocol/ISdlProtocol.java +++ b/sdl_android/src/main/java/com/smartdevicelink/protocol/ISdlProtocol.java @@ -53,4 +53,6 @@ public interface ISdlProtocol extends IProtocolListener { void setAcceptedVideoParams(VideoStreamingParameters acceptedVideoParams); void stopStream(SessionType serviceType); + + void onAuthTokenReceived(String authToken); } diff --git a/sdl_android/src/main/java/com/smartdevicelink/protocol/SdlProtocol.java b/sdl_android/src/main/java/com/smartdevicelink/protocol/SdlProtocol.java index 7f223d1ce..955a72fc8 100644 --- a/sdl_android/src/main/java/com/smartdevicelink/protocol/SdlProtocol.java +++ b/sdl_android/src/main/java/com/smartdevicelink/protocol/SdlProtocol.java @@ -978,6 +978,13 @@ public class SdlProtocol { Log.w(TAG, "Received a start service ack for RPC service while already active on a different transport."); return; } + + if(protocolVersion.isNewerThan(new Version(5,2,0)) >= 0){ + String authToken = (String)packet.getTag(ControlFrameTags.RPC.StartServiceACK.AUTH_TOKEN); + if(authToken != null){ + iSdlProtocol.onAuthTokenReceived(authToken); + } + } }else { //Version is either not included or lower than 5.1.0 diff --git a/sdl_android/src/main/java/com/smartdevicelink/protocol/WiProProtocol.java b/sdl_android/src/main/java/com/smartdevicelink/protocol/WiProProtocol.java index 0d99d63a5..bc7c04b08 100644 --- a/sdl_android/src/main/java/com/smartdevicelink/protocol/WiProProtocol.java +++ b/sdl_android/src/main/java/com/smartdevicelink/protocol/WiProProtocol.java @@ -503,6 +503,16 @@ public class WiProProtocol extends AbstractProtocol { }
}
handleProtocolSessionStarted(serviceType,(byte) packet.getSessionId(), getMajorVersionByte(), "", hashID, packet.isEncrypted());
+
+ if(serviceType.equals(SessionType.RPC)
+ && protocolVersion.isNewerThan(new Version(5,2,0)) >= 0){
+ // This has to be done after the session has been established because
+ // SdlConnection is just setup that way
+ String authToken = (String)packet.getTag(ControlFrameTags.RPC.StartServiceACK.AUTH_TOKEN);
+ if(authToken != null){
+ sdlconn.onAuthTokenReceived(authToken, (byte)packet.getSessionId());
+ }
+ }
} else if (frameInfo == FrameDataControlFrameType.StartSessionNACK.getValue()) {
List<String> rejectedParams = null;
if(packet.version >= 5){
diff --git a/sdl_android/src/main/java/com/smartdevicelink/protocol/enums/ControlFrameTags.java b/sdl_android/src/main/java/com/smartdevicelink/protocol/enums/ControlFrameTags.java index bc926f714..0dd46ecfd 100644 --- a/sdl_android/src/main/java/com/smartdevicelink/protocol/enums/ControlFrameTags.java +++ b/sdl_android/src/main/java/com/smartdevicelink/protocol/enums/ControlFrameTags.java @@ -35,6 +35,9 @@ public class ControlFrameTags { /** HU allowed transports for audio and video services (1 == Primary, 2 == Secondary) */ public static final String AUDIO_SERVICE_TRANSPORTS = "audioServiceTransports"; public static final String VIDEO_SERVICE_TRANSPORTS = "videoServiceTransports"; + /** Auth token to be used for log in into services **/ + public static final String AUTH_TOKEN = "authToken"; + } public static class StartServiceNAK extends NAKBase{} public static class EndService { diff --git a/sdl_android/src/main/java/com/smartdevicelink/protocol/enums/FunctionID.java b/sdl_android/src/main/java/com/smartdevicelink/protocol/enums/FunctionID.java index 4f1ad71b5..c5cacaed9 100644 --- a/sdl_android/src/main/java/com/smartdevicelink/protocol/enums/FunctionID.java +++ b/sdl_android/src/main/java/com/smartdevicelink/protocol/enums/FunctionID.java @@ -63,6 +63,8 @@ public enum FunctionID{ UNSUBSCRIBE_WAY_POINTS(47, "UnsubscribeWayPoints"),
GET_SYSTEM_CAPABILITY(48, "GetSystemCapability"),
SEND_HAPTIC_DATA(49, "SendHapticData"),
+ SET_CLOUD_APP_PROPERTIES(50, "SetCloudAppProperties"),
+ GET_CLOUD_APP_PROPERTIES(51, "GetCloudAppProperties"),
// NOTIFICATIONS
ON_HMI_STATUS(32768, "OnHMIStatus"),
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyBase.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyBase.java index 485d6fec4..986310d5f 100644 --- a/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyBase.java +++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyBase.java @@ -94,6 +94,7 @@ import com.smartdevicelink.transport.USBTransportConfig; import com.smartdevicelink.transport.enums.TransportType;
import com.smartdevicelink.util.CorrelationIdGenerator;
import com.smartdevicelink.util.DebugTool;
+import com.smartdevicelink.util.HttpUtils;
import com.smartdevicelink.util.Version;
import org.json.JSONArray;
@@ -256,6 +257,8 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase> protected VideoStreamingManager manager; //Will move to SdlSession once the class becomes public
+ protected String authToken;
+
private Version minimumProtocolVersion;
private Version minimumRPCVersion;
@@ -679,6 +682,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase> }
}
+
public void onProtocolServiceDataACK(SessionType sessionType, final int dataSize,
byte sessionID) {
if (_callbackToUIThread) {
@@ -693,6 +697,11 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase> _proxyListener.onServiceDataACK(dataSize);
}
}
+
+ @Override
+ public void onAuthTokenReceived(String authToken, byte sessionID) {
+ SdlProxyBase.this.authToken = authToken;
+ }
}
/**
@@ -1177,51 +1186,54 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase> sendBroadcastIntent(sendIntent);
}
}
-
-
+
+
private void sendOnSystemRequestToUrl(OnSystemRequest msg)
- {
+ {
Intent sendIntent = createBroadcastIntent();
Intent sendIntent2 = createBroadcastIntent();
HttpURLConnection urlConnection = null;
boolean bLegacy = false;
-
+
String sURLString;
- if (!getPoliciesURL().equals(""))
+ if (!getPoliciesURL().equals("")) {
sURLString = sPoliciesURL;
- else
+ } else {
sURLString = msg.getUrl();
+ }
Integer iTimeout = msg.getTimeout();
if (iTimeout == null)
iTimeout = 2000;
-
- Headers myHeader = msg.getHeader();
-
+
+ Headers myHeader = msg.getHeader();
+
+ RequestType requestType = msg.getRequestType();
updateBroadcastIntent(sendIntent, "FUNCTION_NAME", "sendOnSystemRequestToUrl");
- updateBroadcastIntent(sendIntent, "COMMENT5", "\r\nCloud URL: " + sURLString);
-
- try
+ updateBroadcastIntent(sendIntent, "COMMENT5", "\r\nCloud URL: " + sURLString);
+
+ try
{
- if (myHeader == null)
+ if (myHeader == null) {
updateBroadcastIntent(sendIntent, "COMMENT7", "\r\nHTTPRequest Header is null");
-
- String sBodyString = msg.getBody();
-
+ }
+
+ String sBodyString = msg.getBody();
+
JSONObject jsonObjectToSendToServer;
String valid_json = "";
int length;
if (sBodyString == null)
- {
- if(RequestType.HTTP.equals(msg.getRequestType())){
+ {
+ if(requestType == RequestType.HTTP ){
length = msg.getBulkData().length;
Intent sendIntent3 = createBroadcastIntent();
updateBroadcastIntent(sendIntent3, "FUNCTION_NAME", "replace");
- updateBroadcastIntent(sendIntent3, "COMMENT1", "Valid Json length before replace: " + length);
+ updateBroadcastIntent(sendIntent3, "COMMENT1", "Valid Json length before replace: " + length);
sendBroadcastIntent(sendIntent3);
-
+
}else{
List<String> legacyData = msg.getLegacyData();
JSONArray jsonArrayOfSdlPPackets = new JSONArray(legacyData);
@@ -1234,17 +1246,17 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase> }
}
else
- {
+ {
Intent sendIntent3 = createBroadcastIntent();
updateBroadcastIntent(sendIntent3, "FUNCTION_NAME", "replace");
- updateBroadcastIntent(sendIntent3, "COMMENT1", "Valid Json length before replace: " + sBodyString.getBytes("UTF-8").length);
+ updateBroadcastIntent(sendIntent3, "COMMENT1", "Valid Json length before replace: " + sBodyString.getBytes("UTF-8").length);
sendBroadcastIntent(sendIntent3);
valid_json = sBodyString.replace("\\", "");
length = valid_json.getBytes("UTF-8").length;
}
-
+
urlConnection = getURLConnection(myHeader, sURLString, iTimeout, length);
-
+
if (urlConnection == null)
{
Log.i(TAG, "urlConnection is null, check RPC input parameters");
@@ -1253,44 +1265,44 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase> }
DataOutputStream wr = new DataOutputStream(urlConnection.getOutputStream());
- if(RequestType.HTTP.equals(msg.getRequestType())){
+ if(requestType == RequestType.HTTP){
wr.write(msg.getBulkData());
}else{
wr.writeBytes(valid_json);
}
-
+
wr.flush();
wr.close();
-
-
+
+
long BeforeTime = System.currentTimeMillis();
long AfterTime = System.currentTimeMillis();
final long roundtriptime = AfterTime - BeforeTime;
-
+
updateBroadcastIntent(sendIntent, "COMMENT4", " Round trip time: " + roundtriptime);
- updateBroadcastIntent(sendIntent, "COMMENT1", "Received response from cloud, response code=" + urlConnection.getResponseCode() + " ");
-
+ updateBroadcastIntent(sendIntent, "COMMENT1", "Received response from cloud, response code=" + urlConnection.getResponseCode() + " ");
+
int iResponseCode = urlConnection.getResponseCode();
-
+
if (iResponseCode != HttpURLConnection.HTTP_OK)
{
Log.i(TAG, "Response code not HTTP_OK, returning from sendOnSystemRequestToUrl.");
updateBroadcastIntent(sendIntent, "COMMENT2", "Response code not HTTP_OK, aborting request. ");
return;
}
-
+
InputStream is = urlConnection.getInputStream();
BufferedReader rd = new BufferedReader(new InputStreamReader(is));
String line;
- StringBuilder response = new StringBuilder();
- while((line = rd.readLine()) != null)
+ StringBuilder response = new StringBuilder();
+ while((line = rd.readLine()) != null)
{
response.append(line);
response.append('\r');
}
rd.close();
//We've read the body
- if(RequestType.HTTP.equals(msg.getRequestType())){
+ if(requestType == RequestType.HTTP){
// Create the SystemRequest RPC to send to module.
PutFile putFile = new PutFile();
putFile.setFileType(FileType.JSON);
@@ -1299,39 +1311,39 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase> putFile.setFileData(response.toString().getBytes("UTF-8"));
putFile.setCRC(response.toString().getBytes());
updateBroadcastIntent(sendIntent, "DATA", "Data from cloud response: " + response.toString());
-
+
sendRPCRequestPrivate(putFile);
Log.i("sendSystemRequestToUrl", "sent to sdl");
updateBroadcastIntent(sendIntent2, "RPC_NAME", FunctionID.PUT_FILE.toString());
updateBroadcastIntent(sendIntent2, "TYPE", RPCMessage.KEY_REQUEST);
updateBroadcastIntent(sendIntent2, "CORRID", putFile.getCorrelationID());
-
+
}else{
- Vector<String> cloudDataReceived = new Vector<String>();
+ Vector<String> cloudDataReceived = new Vector<String>();
final String dataKey = "data";
// Convert the response to JSON
- JSONObject jsonResponse = new JSONObject(response.toString());
+ JSONObject jsonResponse = new JSONObject(response.toString());
if(jsonResponse.has(dataKey)){
- if (jsonResponse.get(dataKey) instanceof JSONArray)
+ if (jsonResponse.get(dataKey) instanceof JSONArray)
{
JSONArray jsonArray = jsonResponse.getJSONArray(dataKey);
- for (int i=0; i<jsonArray.length(); i++)
+ for (int i=0; i<jsonArray.length(); i++)
{
- if (jsonArray.get(i) instanceof String)
+ if (jsonArray.get(i) instanceof String)
{
cloudDataReceived.add(jsonArray.getString(i));
//Log.i("sendSystemRequestToUrl", "jsonArray.getString(i): " + jsonArray.getString(i));
}
}
- }
- else if (jsonResponse.get(dataKey) instanceof String)
+ }
+ else if (jsonResponse.get(dataKey) instanceof String)
{
cloudDataReceived.add(jsonResponse.getString(dataKey));
//Log.i("sendSystemRequestToUrl", "jsonResponse.getString(data): " + jsonResponse.getString("data"));
- }
+ }
}
- else
+ else
{
DebugTool.logError("sendSystemRequestToUrl: Data in JSON Object neither an array nor a string.");
//Log.i("sendSystemRequestToUrl", "sendSystemRequestToUrl: Data in JSON Object neither an array nor a string.");
@@ -1366,7 +1378,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase> }
if (getIsConnected())
- {
+ {
sendRPCRequestPrivate(mySystemRequest);
Log.i("sendSystemRequestToUrl", "sent to sdl");
@@ -1376,43 +1388,43 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase> }
}
}
- catch (SdlException e)
+ catch (SdlException e)
{
DebugTool.logError("sendSystemRequestToUrl: Could not get data from JSONObject received.", e);
updateBroadcastIntent(sendIntent, "COMMENT3", " SdlException encountered sendOnSystemRequestToUrl: "+ e);
//Log.i("pt", "sendSystemRequestToUrl: Could not get data from JSONObject received."+ e);
- }
- catch (JSONException e)
+ }
+ catch (JSONException e)
{
DebugTool.logError("sendSystemRequestToUrl: JSONException: ", e);
updateBroadcastIntent(sendIntent, "COMMENT3", " JSONException encountered sendOnSystemRequestToUrl: "+ e);
//Log.i("pt", "sendSystemRequestToUrl: JSONException: "+ e);
- }
- catch (UnsupportedEncodingException e)
+ }
+ catch (UnsupportedEncodingException e)
{
DebugTool.logError("sendSystemRequestToUrl: Could not encode string.", e);
updateBroadcastIntent(sendIntent, "COMMENT3", " UnsupportedEncodingException encountered sendOnSystemRequestToUrl: "+ e);
//Log.i("pt", "sendSystemRequestToUrl: Could not encode string."+ e);
- }
- catch (ProtocolException e)
+ }
+ catch (ProtocolException e)
{
DebugTool.logError("sendSystemRequestToUrl: Could not set request method to post.", e);
updateBroadcastIntent(sendIntent, "COMMENT3", " ProtocolException encountered sendOnSystemRequestToUrl: "+ e);
//Log.i("pt", "sendSystemRequestToUrl: Could not set request method to post."+ e);
- }
- catch (MalformedURLException e)
+ }
+ catch (MalformedURLException e)
{
DebugTool.logError("sendSystemRequestToUrl: URL Exception when sending SystemRequest to an external server.", e);
updateBroadcastIntent(sendIntent, "COMMENT3", " MalformedURLException encountered sendOnSystemRequestToUrl: "+ e);
//Log.i("pt", "sendSystemRequestToUrl: URL Exception when sending SystemRequest to an external server."+ e);
- }
- catch (IOException e)
+ }
+ catch (IOException e)
{
DebugTool.logError("sendSystemRequestToUrl: IOException: ", e);
updateBroadcastIntent(sendIntent, "COMMENT3", " IOException while sending to cloud: IOException: "+ e);
//Log.i("pt", "sendSystemRequestToUrl: IOException: "+ e);
- }
- catch (Exception e)
+ }
+ catch (Exception e)
{
DebugTool.logError("sendSystemRequestToUrl: Unexpected Exception: ", e);
updateBroadcastIntent(sendIntent, "COMMENT3", " Exception encountered sendOnSystemRequestToUrl: "+ e);
@@ -1428,9 +1440,9 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase> else
iFileCount = 0;
- if(urlConnection != null)
+ if(urlConnection != null)
{
- urlConnection.disconnect();
+ urlConnection.disconnect();
}
}
}
@@ -3366,8 +3378,39 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase> _proxyListener.onSendHapticDataResponse( msg);
onRPCResponseReceived(msg);
}
- }
- else {
+ } else if (functionName.equals(FunctionID.SET_CLOUD_APP_PROPERTIES.toString())) {
+ final SetCloudAppPropertiesResponse msg = new SetCloudAppPropertiesResponse(hash);
+ msg.format(rpcSpecVersion, true);
+ if (_callbackToUIThread) {
+ // Run in UI thread
+ _mainUIHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ _proxyListener.onSetCloudAppProperties(msg);
+ onRPCResponseReceived(msg);
+ }
+ });
+ } else {
+ _proxyListener.onSetCloudAppProperties(msg);
+ onRPCResponseReceived(msg);
+ }
+ } else if (functionName.equals(FunctionID.GET_CLOUD_APP_PROPERTIES.toString())) {
+ final GetCloudAppPropertiesResponse msg = new GetCloudAppPropertiesResponse(hash);
+ msg.format(rpcSpecVersion, true);
+ if (_callbackToUIThread) {
+ // Run in UI thread
+ _mainUIHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ _proxyListener.onGetCloudAppProperties(msg);
+ onRPCResponseReceived(msg);
+ }
+ });
+ } else {
+ _proxyListener.onGetCloudAppProperties(msg);
+ onRPCResponseReceived(msg);
+ }
+ } else {
if (_sdlMsgVersion != null) {
DebugTool.logError("Unrecognized response Message: " + functionName +
" SDL Message Version = " + _sdlMsgVersion);
@@ -3637,9 +3680,10 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase> final OnSystemRequest msg = new OnSystemRequest(hash);
msg.format(rpcSpecVersion,true);
- if ((msg.getUrl() != null) &&
- (((msg.getRequestType() == RequestType.PROPRIETARY) && (msg.getFileType() == FileType.JSON))
- || ((msg.getRequestType() == RequestType.HTTP) && (msg.getFileType() == FileType.BINARY)))){
+ RequestType requestType = msg.getRequestType();
+ if(msg.getUrl() != null) {
+ if (((requestType == RequestType.PROPRIETARY) && (msg.getFileType() == FileType.JSON))
+ || ((requestType == RequestType.HTTP) && (msg.getFileType() == FileType.BINARY))) {
Thread handleOffboardTransmissionThread = new Thread() {
@Override
public void run() {
@@ -3648,15 +3692,34 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase> };
handleOffboardTransmissionThread.start();
+ } else if (requestType == RequestType.LOCK_SCREEN_ICON_URL) {
+ //Cache this for when the lockscreen is displayed
+ lockScreenIconRequest = msg;
+ } else if (requestType == RequestType.ICON_URL) {
+ //Download the icon file and send SystemRequest RPC
+ Thread handleOffBoardTransmissionThread = new Thread() {
+ @Override
+ public void run() {
+ byte[] file = HttpUtils.downloadFile(msg.getUrl());
+ if (file != null) {
+ SystemRequest systemRequest = new SystemRequest();
+ systemRequest.setFileName(msg.getUrl());
+ systemRequest.setBulkData(file);
+ systemRequest.setRequestType(RequestType.ICON_URL);
+ try {
+ sendRPCRequestPrivate(systemRequest);
+ } catch (SdlException e) {
+ e.printStackTrace();
+ }
+ } else {
+ DebugTool.logError("File was null at: " + msg.getUrl());
+ }
+ }
+ };
+ handleOffBoardTransmissionThread.start();
}
-
-
- if(msg.getRequestType() == RequestType.LOCK_SCREEN_ICON_URL &&
- msg.getUrl() != null){
- lockScreenIconRequest = msg;
- }
-
- msg.format(rpcSpecVersion, true);
+ }
+
if (_callbackToUIThread) {
// Run in UI thread
_mainUIHandler.post(new Runnable() {
@@ -7448,6 +7511,14 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase> return this.raiResponse;
}
+ /**
+ * Retrieves the auth token, if any, that was attached to the StartServiceACK for the RPC
+ * service from the module. For example, this should be used to login to a user account.
+ * @return the string representation of the auth token
+ */
+ public String getAuthToken(){
+ return this.authToken;
+ }
/**
* VideoStreamingManager houses all the elements needed to create a scoped, streaming manager for video projection. It is only a private, instance
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/interfaces/IProxyListenerBase.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/interfaces/IProxyListenerBase.java index b7486785f..bc989352d 100644 --- a/sdl_android/src/main/java/com/smartdevicelink/proxy/interfaces/IProxyListenerBase.java +++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/interfaces/IProxyListenerBase.java @@ -17,6 +17,7 @@ import com.smartdevicelink.proxy.rpc.DiagnosticMessageResponse; import com.smartdevicelink.proxy.rpc.DialNumberResponse;
import com.smartdevicelink.proxy.rpc.EndAudioPassThruResponse;
import com.smartdevicelink.proxy.rpc.GenericResponse;
+import com.smartdevicelink.proxy.rpc.GetCloudAppPropertiesResponse;
import com.smartdevicelink.proxy.rpc.GetDTCsResponse;
import com.smartdevicelink.proxy.rpc.GetInteriorVehicleDataResponse;
import com.smartdevicelink.proxy.rpc.GetSystemCapabilityResponse;
@@ -51,6 +52,7 @@ import com.smartdevicelink.proxy.rpc.ScrollableMessageResponse; import com.smartdevicelink.proxy.rpc.SendHapticDataResponse;
import com.smartdevicelink.proxy.rpc.SendLocationResponse;
import com.smartdevicelink.proxy.rpc.SetAppIconResponse;
+import com.smartdevicelink.proxy.rpc.SetCloudAppPropertiesResponse;
import com.smartdevicelink.proxy.rpc.SetDisplayLayoutResponse;
import com.smartdevicelink.proxy.rpc.SetGlobalPropertiesResponse;
import com.smartdevicelink.proxy.rpc.SetInteriorVehicleDataResponse;
@@ -356,4 +358,8 @@ public interface IProxyListenerBase { public void onSendHapticDataResponse(SendHapticDataResponse response);
public void onOnRCStatus(OnRCStatus notification);
+
+ public void onSetCloudAppProperties(SetCloudAppPropertiesResponse response);
+
+ public void onGetCloudAppProperties(GetCloudAppPropertiesResponse response);
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/CloudAppProperties.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/CloudAppProperties.java new file mode 100644 index 000000000..6538496ee --- /dev/null +++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/CloudAppProperties.java @@ -0,0 +1,104 @@ +package com.smartdevicelink.proxy.rpc; + +import android.support.annotation.NonNull; + +import com.smartdevicelink.proxy.RPCStruct; +import com.smartdevicelink.proxy.rpc.enums.HybridAppPreference; + +import java.util.Hashtable; + +/** + * Properties that relate to a a cloud app entry. + */ +public class CloudAppProperties extends RPCStruct { + public static final String KEY_APP_NAME = "appName"; + public static final String KEY_APP_ID = "appID"; + public static final String KEY_ENABLED = "enabled"; + public static final String KEY_AUTH_TOKEN = "authToken"; + public static final String KEY_CLOUD_TRANSPORT_TYPE = "cloudTransportType"; + public static final String KEY_HYBRID_APP_PREFERENCE = "hybridAppPreference"; + public static final String KEY_ENDPOINT = "endpoint"; + + + public CloudAppProperties(){} + + public CloudAppProperties(Hashtable<String, Object> hash) { + super(hash); + } + + public CloudAppProperties(@NonNull String appName, @NonNull String appID){ + this(); + setValue(KEY_APP_NAME, appName); + setValue(KEY_APP_ID, appID); + } + + public void setAppName(String appName){ + setValue(KEY_APP_NAME, appName); + } + + public String getAppName(){ + return getString(KEY_APP_NAME); + } + + public void setAppID(String appID){ + setValue(KEY_APP_ID, appID); + } + + public String getAppID(){ + return getString(KEY_APP_ID); + } + + /** + * If true, this cloud app entry will designate it should appear in the HMI + * @param enabled if the app should be + */ + public void setEnabled(boolean enabled){ + setValue(KEY_ENABLED, enabled); + } + + /** + * @return if this cloud app entry will designate it should appear in the HMI + */ + public Boolean isEnabled(){ + return getBoolean(KEY_ENABLED); + } + + public void setAuthToken(String token){ + setValue(KEY_AUTH_TOKEN, token); + } + + public String getAuthToken(){ + return getString(KEY_AUTH_TOKEN); + } + + public void setCloudTransportType(String transportType){ + setValue(KEY_CLOUD_TRANSPORT_TYPE, transportType); + } + + public String getCloudTransportType(){ + return getString(KEY_CLOUD_TRANSPORT_TYPE); + } + + public void setHybridAppPreference(HybridAppPreference hybridAppPreference){ + setValue(KEY_HYBRID_APP_PREFERENCE, hybridAppPreference); + } + + public HybridAppPreference getHybridAppPreference(){ + return (HybridAppPreference)getObject(HybridAppPreference.class, KEY_HYBRID_APP_PREFERENCE); + } + + /** + * @param token - max length ="65535" + */ + public void setEndpoint(String token){ + setValue(KEY_ENDPOINT, token); + } + + /** + * @return token - max length ="65535" + */ + public String getEndpoint(){ + return getString(KEY_ENDPOINT); + } + +} diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/GetCloudAppProperties.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/GetCloudAppProperties.java new file mode 100644 index 000000000..032ae7dad --- /dev/null +++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/GetCloudAppProperties.java @@ -0,0 +1,35 @@ +package com.smartdevicelink.proxy.rpc; + +import android.support.annotation.NonNull; + +import com.smartdevicelink.protocol.enums.FunctionID; +import com.smartdevicelink.proxy.RPCRequest; + +import java.util.Hashtable; + +public class GetCloudAppProperties extends RPCRequest { + + public static final String KEY_APP_ID = "appID"; + + public GetCloudAppProperties() { + super(FunctionID.GET_CLOUD_APP_PROPERTIES.toString()); + } + + public GetCloudAppProperties(Hashtable<String, Object> hash) { + super(hash); + } + + public GetCloudAppProperties(@NonNull String appID){ + this(); + setParameters(KEY_APP_ID, appID); + } + + public void setAppId(String appId){ + setParameters(KEY_APP_ID, appId); + } + + public String getAppId(){ + return getString((KEY_APP_ID)); + } + +} diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/GetCloudAppPropertiesResponse.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/GetCloudAppPropertiesResponse.java new file mode 100644 index 000000000..7577dd396 --- /dev/null +++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/GetCloudAppPropertiesResponse.java @@ -0,0 +1,28 @@ +package com.smartdevicelink.proxy.rpc; + +import android.support.annotation.NonNull; + +import com.smartdevicelink.protocol.enums.FunctionID; +import com.smartdevicelink.proxy.RPCResponse; + +import java.util.Hashtable; + +public class GetCloudAppPropertiesResponse extends RPCResponse { + + public static final String KEY_PROPERTIES = "properties"; + + public GetCloudAppPropertiesResponse() { + super(FunctionID.GET_CLOUD_APP_PROPERTIES.toString()); + } + public GetCloudAppPropertiesResponse(Hashtable<String, Object> hash) { + super(hash); + } + + public void setCloudAppProperties(@NonNull CloudAppProperties cloudAppProperties){ + setParameters(KEY_PROPERTIES, cloudAppProperties); + } + + public CloudAppProperties getCloudAppProperties(){ + return (CloudAppProperties) getObject(CloudAppProperties.class, KEY_PROPERTIES); + } +} diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/GetVehicleData.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/GetVehicleData.java index e751f4a3f..b847b37bc 100644 --- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/GetVehicleData.java +++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/GetVehicleData.java @@ -194,7 +194,15 @@ import java.util.Hashtable; * <td>Subscribable</td>
* <td>SmartDeviceLink 5.0</td>
* </tr>
- * </table>
+ * <tr>
+ * <td>cloudAppVehicleID</td>
+ * <td>Boolean</td>
+ * <td>ID for the vehicle when connecting to cloud applications</td>
+ * <td>N</td>
+ * <td>Subscribable</td>
+ * <td>SmartDeviceLink 5.1 </td>
+ * </tr>
+ * </table>
*
*
* <p><b>Response</b></p>
@@ -247,6 +255,7 @@ public class GetVehicleData extends RPCRequest { public static final String KEY_FUEL_RANGE = "fuelRange";
public static final String KEY_TURN_SIGNAL = "turnSignal";
public static final String KEY_ELECTRONIC_PARK_BRAKE_STATUS = "electronicParkBrakeStatus";
+ public static final String KEY_CLOUD_APP_VEHICLE_ID = "cloudAppVehicleID";
/**
* Constructs a new GetVehicleData object
@@ -484,4 +493,20 @@ public class GetVehicleData extends RPCRequest { public Boolean getElectronicParkBrakeStatus(){
return getBoolean(KEY_ELECTRONIC_PARK_BRAKE_STATUS);
}
+
+ /**
+ * Sets a boolean value. If true, gets the cloudAppVehicleID data
+ * @param cloudAppVehicleID a boolean value
+ */
+ public void setCloudAppVehicleID(boolean cloudAppVehicleID){
+ setParameters(KEY_CLOUD_APP_VEHICLE_ID, cloudAppVehicleID);
+ }
+
+ /**
+ * Gets a boolean value. If true, means the cloudAppVehicleDataID data has been set to retrieve.
+ * @return a Boolean value.
+ */
+ public Boolean getCloudAppVehicleID(){
+ return getBoolean(KEY_CLOUD_APP_VEHICLE_ID);
+ }
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/GetVehicleDataResponse.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/GetVehicleDataResponse.java index 91eefc13c..fc26a2c9a 100644 --- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/GetVehicleDataResponse.java +++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/GetVehicleDataResponse.java @@ -52,6 +52,7 @@ public class GetVehicleDataResponse extends RPCResponse { public static final String KEY_FUEL_RANGE = "fuelRange";
public static final String KEY_TURN_SIGNAL = "turnSignal";
public static final String KEY_ELECTRONIC_PARK_BRAKE_STATUS = "electronicParkBrakeStatus";
+ public static final String KEY_CLOUD_APP_VEHICLE_ID = "cloudAppVehicleID";
/**
* Constructs a new GetVehicleDataResponse object
@@ -313,4 +314,20 @@ public class GetVehicleDataResponse extends RPCResponse { public ElectronicParkBrakeStatus getElectronicParkBrakeStatus(){
return (ElectronicParkBrakeStatus) getObject(ElectronicParkBrakeStatus.class, KEY_ELECTRONIC_PARK_BRAKE_STATUS);
}
+
+ /**
+ * Sets a string value for the cloud app vehicle ID
+ * @param cloudAppVehicleID a string value
+ */
+ public void setCloudAppVehicleID(String cloudAppVehicleID){
+ setParameters(KEY_CLOUD_APP_VEHICLE_ID, cloudAppVehicleID);
+ }
+
+ /**
+ * Gets a String value of the returned cloud app vehicle ID
+ * @return a String value.
+ */
+ public String getCloudAppVehicleID(){
+ return getString(KEY_CLOUD_APP_VEHICLE_ID);
+ }
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnVehicleData.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnVehicleData.java index 526f8dbb7..7b97f9286 100644 --- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnVehicleData.java +++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnVehicleData.java @@ -245,6 +245,14 @@ import java.util.List; * <td> minvalue: -2000; maxvalue:2000</td>
* <td>SmartDeviceLink 2.0</td>
* </tr>
+ * <tr>
+ * <td>cloudAppVehicleID</td>
+ * <td>String</td>
+ * <td>ID for the vehicle when connecting to cloud applications</td>
+ * <td>N</td>
+ * <td></td>
+ * <td>SmartDeviceLink 5.1 </td>
+ * </tr>
* </table>
*
* @since SmartDeviceLink 1.0
@@ -284,6 +292,8 @@ public class OnVehicleData extends RPCNotification { public static final String KEY_FUEL_RANGE = "fuelRange";
public static final String KEY_TURN_SIGNAL = "turnSignal";
public static final String KEY_ELECTRONIC_PARK_BRAKE_STATUS = "electronicParkBrakeStatus";
+ public static final String KEY_CLOUD_APP_VEHICLE_ID = "cloudAppVehicleID";
+
public OnVehicleData() {
super(FunctionID.ON_VEHICLE_DATA.toString());
@@ -525,4 +535,20 @@ public class OnVehicleData extends RPCNotification { public ElectronicParkBrakeStatus getElectronicParkBrakeStatus(){
return (ElectronicParkBrakeStatus) getObject(ElectronicParkBrakeStatus.class, KEY_ELECTRONIC_PARK_BRAKE_STATUS);
}
+
+ /**
+ * Sets a string value for the cloud app vehicle ID
+ * @param cloudAppVehicleID a string value
+ */
+ public void setCloudAppVehicleID(String cloudAppVehicleID){
+ setParameters(KEY_CLOUD_APP_VEHICLE_ID, cloudAppVehicleID);
+ }
+
+ /**
+ * Gets a String value of the returned cloud app vehicle ID
+ * @return a String value.
+ */
+ public String getCloudAppVehicleID(){
+ return getString(KEY_CLOUD_APP_VEHICLE_ID);
+ }
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SetCloudAppProperties.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SetCloudAppProperties.java new file mode 100644 index 000000000..5f6160361 --- /dev/null +++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SetCloudAppProperties.java @@ -0,0 +1,36 @@ +package com.smartdevicelink.proxy.rpc; + +import android.support.annotation.NonNull; + +import com.smartdevicelink.protocol.enums.FunctionID; +import com.smartdevicelink.proxy.RPCRequest; + +import java.util.Hashtable; + +public class SetCloudAppProperties extends RPCRequest { + + public static final String KEY_PROPERTIES = "properties"; + + public SetCloudAppProperties(){ + super(FunctionID.SET_CLOUD_APP_PROPERTIES.toString()); + } + + public SetCloudAppProperties(Hashtable<String, Object> hash) { + super(hash); + } + + public SetCloudAppProperties(@NonNull CloudAppProperties cloudAppProperties){ + this(); + setParameters(KEY_PROPERTIES, cloudAppProperties); + } + + public void setProperties(@NonNull CloudAppProperties cloudAppProperties){ + setParameters(KEY_PROPERTIES, cloudAppProperties); + } + + public CloudAppProperties getProperties(){ + return (CloudAppProperties) getObject(CloudAppProperties.class, KEY_PROPERTIES); + } + + +} diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SetCloudAppPropertiesResponse.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SetCloudAppPropertiesResponse.java new file mode 100644 index 000000000..ea3e79d00 --- /dev/null +++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SetCloudAppPropertiesResponse.java @@ -0,0 +1,18 @@ +package com.smartdevicelink.proxy.rpc; + +import com.smartdevicelink.protocol.enums.FunctionID; +import com.smartdevicelink.proxy.RPCResponse; + +import java.util.Hashtable; + +public class SetCloudAppPropertiesResponse extends RPCResponse { + + public SetCloudAppPropertiesResponse(){ + super(FunctionID.SET_CLOUD_APP_PROPERTIES.toString()); + } + public SetCloudAppPropertiesResponse(Hashtable<String, Object> hash) { + super(hash); + } + + +} diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SubscribeVehicleData.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SubscribeVehicleData.java index 420d907b1..700f1dcb9 100644 --- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SubscribeVehicleData.java +++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SubscribeVehicleData.java @@ -234,7 +234,15 @@ import java.util.Hashtable; * <td>Subscribable</td>
* <td>SmartDeviceLink 5.0 </td>
* </tr>
- * </table>
+ * <tr>
+ * <td>cloudAppVehicleID</td>
+ * <td>Boolean</td>
+ * <td>ID for the vehicle when connecting to cloud applications</td>
+ * <td>N</td>
+ * <td>Subscribable</td>
+ * <td>SmartDeviceLink 5.1 </td>
+ * </tr>
+ * </table>
*
* <p> <b>Response</b></p>
*<p><b>Non-default Result Codes:</b></p>
@@ -282,6 +290,7 @@ public class SubscribeVehicleData extends RPCRequest { public static final String KEY_FUEL_RANGE = "fuelRange";
public static final String KEY_TURN_SIGNAL = "turnSignal";
public static final String KEY_ELECTRONIC_PARK_BRAKE_STATUS = "electronicParkBrakeStatus";
+ public static final String KEY_CLOUD_APP_VEHICLE_ID = "cloudAppVehicleID";
/**
* Constructs a new SubscribeVehicleData object
@@ -808,4 +817,20 @@ public class SubscribeVehicleData extends RPCRequest { public Boolean getElectronicParkBrakeStatus(){
return getBoolean(KEY_ELECTRONIC_PARK_BRAKE_STATUS);
}
+
+ /**
+ * Sets a boolean value. If true, subscribes cloudAppVehicleID data
+ * @param cloudAppVehicleID a boolean value
+ */
+ public void setCloudAppVehicleID(boolean cloudAppVehicleID){
+ setParameters(KEY_CLOUD_APP_VEHICLE_ID, cloudAppVehicleID);
+ }
+
+ /**
+ * Gets a boolean value. If true, means the cloudAppVehicleDataID data has been subscribed.
+ * @return a Boolean value.
+ */
+ public Boolean getCloudAppVehicleID(){
+ return getBoolean(KEY_CLOUD_APP_VEHICLE_ID);
+ }
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SubscribeVehicleDataResponse.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SubscribeVehicleDataResponse.java index 47d32936d..cc27233a8 100644 --- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SubscribeVehicleDataResponse.java +++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SubscribeVehicleDataResponse.java @@ -42,6 +42,7 @@ public class SubscribeVehicleDataResponse extends RPCResponse { public static final String KEY_FUEL_RANGE = "fuelRange";
public static final String KEY_TURN_SIGNAL = "turnSignal";
public static final String KEY_ELECTRONIC_PARK_BRAKE_STATUS = "electronicParkBrakeStatus";
+ public static final String KEY_CLOUD_APP_VEHICLE_ID = "cloudAppVehicleID";
/**
* Constructs a new SubscribeVehicleDataResponse object
@@ -466,4 +467,20 @@ public class SubscribeVehicleDataResponse extends RPCResponse { public VehicleDataResult getElectronicParkBrakeStatus(){
return (VehicleDataResult) getObject(VehicleDataResult.class, KEY_ELECTRONIC_PARK_BRAKE_STATUS);
}
+
+ /**
+ * Sets cloudAppVehicleID
+ * @param cloudAppVehicleID a boolean value
+ */
+ public void setCloudAppVehicleID(VehicleDataResult cloudAppVehicleID){
+ setParameters(KEY_CLOUD_APP_VEHICLE_ID, cloudAppVehicleID);
+ }
+
+ /**
+ * Gets a boolean value. If true, means the cloudAppVehicleDataID data has been subscribed.
+ * @return a Boolean value.
+ */
+ public VehicleDataResult getCloudAppVehicleID(){
+ return (VehicleDataResult) getObject(VehicleDataResult.class, KEY_CLOUD_APP_VEHICLE_ID);
+ }
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/UnsubscribeVehicleData.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/UnsubscribeVehicleData.java index ca2439b9e..e682fa518 100644 --- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/UnsubscribeVehicleData.java +++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/UnsubscribeVehicleData.java @@ -275,6 +275,7 @@ public class UnsubscribeVehicleData extends RPCRequest { public static final String KEY_FUEL_RANGE = "fuelRange";
public static final String KEY_TURN_SIGNAL = "turnSignal";
public static final String KEY_ELECTRONIC_PARK_BRAKE_STATUS = "electronicParkBrakeStatus";
+ public static final String KEY_CLOUD_APP_VEHICLE_ID = "cloudAppVehicleID";
/**
* Constructs a new UnsubscribeVehicleData object
@@ -802,4 +803,20 @@ public class UnsubscribeVehicleData extends RPCRequest { public Boolean getElectronicParkBrakeStatus() {
return getBoolean(KEY_ELECTRONIC_PARK_BRAKE_STATUS);
}
+
+ /**
+ * Sets cloudAppVehicleID
+ * @param cloudAppVehicleID a boolean value
+ */
+ public void setCloudAppVehicleID(VehicleDataResult cloudAppVehicleID){
+ setParameters(KEY_CLOUD_APP_VEHICLE_ID, cloudAppVehicleID);
+ }
+
+ /**
+ * Gets a boolean value. If true, means the cloudAppVehicleDataID data should be unsubscribed.
+ * @return a Boolean value.
+ */
+ public VehicleDataResult getCloudAppVehicleID(){
+ return (VehicleDataResult) getObject(VehicleDataResult.class, KEY_CLOUD_APP_VEHICLE_ID);
+ }
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/UnsubscribeVehicleDataResponse.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/UnsubscribeVehicleDataResponse.java index e3b8b44b0..c2ba69cfa 100644 --- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/UnsubscribeVehicleDataResponse.java +++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/UnsubscribeVehicleDataResponse.java @@ -42,6 +42,7 @@ public class UnsubscribeVehicleDataResponse extends RPCResponse { public static final String KEY_FUEL_RANGE = "fuelRange";
public static final String KEY_TURN_SIGNAL = "turnSignal";
public static final String KEY_ELECTRONIC_PARK_BRAKE_STATUS = "electronicParkBrakeStatus";
+ public static final String KEY_CLOUD_APP_VEHICLE_ID = "cloudAppVehicleID";
/**
* Constructs a new UnsubscribeVehicleDataResponse object
@@ -468,4 +469,20 @@ public class UnsubscribeVehicleDataResponse extends RPCResponse { public VehicleDataResult getElectronicParkBrakeStatus(){
return (VehicleDataResult) getObject(VehicleDataResult.class, KEY_ELECTRONIC_PARK_BRAKE_STATUS);
}
+
+ /**
+ * Sets cloudAppVehicleID
+ * @param cloudAppVehicleID a boolean value
+ */
+ public void setCloudAppVehicleID(VehicleDataResult cloudAppVehicleID){
+ setParameters(KEY_CLOUD_APP_VEHICLE_ID, cloudAppVehicleID);
+ }
+
+ /**
+ * Gets a boolean value. If true, means the cloudAppVehicleDataID data has been unsubscribed.
+ * @return a Boolean value.
+ */
+ public VehicleDataResult getCloudAppVehicleID(){
+ return (VehicleDataResult) getObject(VehicleDataResult.class, KEY_CLOUD_APP_VEHICLE_ID);
+ }
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/enums/HybridAppPreference.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/enums/HybridAppPreference.java new file mode 100644 index 000000000..16732e9c3 --- /dev/null +++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/enums/HybridAppPreference.java @@ -0,0 +1,16 @@ +package com.smartdevicelink.proxy.rpc.enums; + +public enum HybridAppPreference { + + MOBILE, + CLOUD, + BOTH; + + public static HybridAppPreference valueForString(String value){ + try{ + return valueOf(value); + }catch(Exception e){ + return null; + } + } +} diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/enums/RequestType.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/enums/RequestType.java index 75707802e..e6fbab6df 100644 --- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/enums/RequestType.java +++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/enums/RequestType.java @@ -72,6 +72,10 @@ public enum RequestType { * @since SmartDeviceLink 5.0
*/
OEM_SPECIFIC,
+ /**
+ * @since SmartDeviceLink 5.1
+ */
+ ICON_URL,
;
/**
* Convert String to RequestType
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/enums/VehicleDataType.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/enums/VehicleDataType.java index 01525ef4a..8694d67c1 100644 --- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/enums/VehicleDataType.java +++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/enums/VehicleDataType.java @@ -125,6 +125,11 @@ public enum VehicleDataType { * Notifies ELECTRONICPARKBRAKESTATUSData may be subscribed
*/
VEHICLEDATA_ELECTRONICPARKBRAKESTATUS,
+
+ /**
+ * Notifies VEHICLEDATA_CLOUDAPPVEHICLEID may be subscribed
+ */
+ VEHICLEDATA_CLOUDAPPVEHICLEID,
;
/**
diff --git a/sdl_android/src/main/java/com/smartdevicelink/util/HttpUtils.java b/sdl_android/src/main/java/com/smartdevicelink/util/HttpUtils.java index d0752e008..77b1a8004 100644 --- a/sdl_android/src/main/java/com/smartdevicelink/util/HttpUtils.java +++ b/sdl_android/src/main/java/com/smartdevicelink/util/HttpUtils.java @@ -1,12 +1,15 @@ package com.smartdevicelink.util; import java.io.BufferedInputStream; +import java.io.ByteArrayOutputStream; import java.io.IOException; +import java.io.InputStream; import java.net.URL; import java.net.URLConnection; import android.graphics.Bitmap; import android.graphics.BitmapFactory; +import android.support.annotation.NonNull; public class HttpUtils{ @@ -19,4 +22,24 @@ public class HttpUtils{ return result; } + public static byte[] downloadFile(@NonNull String urlStr){ + try { + URL url = new URL(urlStr); + URLConnection connection = url.openConnection(); + InputStream inputStream = connection.getInputStream(); + ByteArrayOutputStream buffer = new ByteArrayOutputStream(); + + int nRead; + byte[] data = new byte[4096]; + + while ((nRead = inputStream.read(data, 0, data.length)) != -1) { + buffer.write(data, 0, nRead); + } + return buffer.toByteArray(); + }catch (Exception e){ + DebugTool.logError("Unable to download file - " + urlStr, e); + return null; + } + } + } |