summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoey Grover <joeygrover@gmail.com>2018-10-24 15:42:26 -0400
committerGitHub <noreply@github.com>2018-10-24 15:42:26 -0400
commit93981e813c2ad540a3651949f48ca875f718ec2a (patch)
tree6c512a137c5dff61c423f33cd20f6a9e780ff9a2
parentdfa5ccd9dfac1d1d4f6a296a7ec16a498379e25c (diff)
parent8e4d44708ed6ffe4cc982630903bb4e06428226b (diff)
downloadsdl_android-93981e813c2ad540a3651949f48ca875f718ec2a.tar.gz
Merge pull request #911 from smartdevicelink/hotfix/remove_sdlexception_throw4.7.1
Remove incorrect SdlException throw in SdlManager
-rwxr-xr-xhello_sdl_android/src/main/java/com/sdl/hellosdlandroid/SdlService.java23
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/managers/SdlManagerTests.java20
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/managers/SdlManager.java36
3 files changed, 38 insertions, 41 deletions
diff --git a/hello_sdl_android/src/main/java/com/sdl/hellosdlandroid/SdlService.java b/hello_sdl_android/src/main/java/com/sdl/hellosdlandroid/SdlService.java
index 2847a3fd6..ea98cbf7f 100755
--- a/hello_sdl_android/src/main/java/com/sdl/hellosdlandroid/SdlService.java
+++ b/hello_sdl_android/src/main/java/com/sdl/hellosdlandroid/SdlService.java
@@ -13,14 +13,12 @@ import android.os.Build;
import android.os.IBinder;
import android.util.Log;
-import com.smartdevicelink.exception.SdlException;
import com.smartdevicelink.managers.CompletionListener;
import com.smartdevicelink.managers.SdlManager;
import com.smartdevicelink.managers.SdlManagerListener;
import com.smartdevicelink.managers.file.filetypes.SdlArtwork;
import com.smartdevicelink.protocol.enums.FunctionID;
import com.smartdevicelink.proxy.RPCNotification;
-import com.smartdevicelink.proxy.RPCRequest;
import com.smartdevicelink.proxy.TTSChunkFactory;
import com.smartdevicelink.proxy.rpc.AddCommand;
import com.smartdevicelink.proxy.rpc.MenuParams;
@@ -31,11 +29,9 @@ import com.smartdevicelink.proxy.rpc.enums.AppHMIType;
import com.smartdevicelink.proxy.rpc.enums.FileType;
import com.smartdevicelink.proxy.rpc.enums.HMILevel;
import com.smartdevicelink.proxy.rpc.listeners.OnRPCNotificationListener;
-import com.smartdevicelink.transport.BTTransportConfig;
import com.smartdevicelink.transport.BaseTransportConfig;
import com.smartdevicelink.transport.MultiplexTransportConfig;
import com.smartdevicelink.transport.TCPTransportConfig;
-import com.smartdevicelink.transport.USBTransportConfig;
import java.util.Collections;
import java.util.Vector;
@@ -217,14 +213,14 @@ public class SdlService extends Service {
command.setCmdID(TEST_COMMAND_ID);
command.setMenuParams(params);
command.setVrCommands(Collections.singletonList(TEST_COMMAND_NAME));
- sendRpcRequest(command);
+ sdlManager.sendRPC(command);
}
/**
* Will speak a sample welcome message
*/
private void performWelcomeSpeak(){
- sendRpcRequest(new Speak(TTSChunkFactory.createSimpleTTSChunks(WELCOME_SPEAK)));
+ sdlManager.sendRPC(new Speak(TTSChunkFactory.createSimpleTTSChunks(WELCOME_SPEAK)));
}
/**
@@ -256,19 +252,8 @@ public class SdlService extends Service {
sdlManager.getScreenManager().setTextField2("");
sdlManager.getScreenManager().commit(null);
- sendRpcRequest(new Speak(TTSChunkFactory.createSimpleTTSChunks(TEST_COMMAND_NAME)));
+ sdlManager.sendRPC(new Speak(TTSChunkFactory.createSimpleTTSChunks(TEST_COMMAND_NAME)));
}
- /**
- * Sends an RPC Request to the connected head unit. Automatically adds a correlation id.
- * @param request the rpc request that is to be sent to the module
- */
- private void sendRpcRequest(RPCRequest request){
- try {
- sdlManager.sendRPC(request);
- } catch (SdlException e) {
- e.printStackTrace();
- }
- }
-} \ No newline at end of file
+}
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/managers/SdlManagerTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/managers/SdlManagerTests.java
index 61626251b..e22e397d2 100644
--- a/sdl_android/src/androidTest/java/com/smartdevicelink/managers/SdlManagerTests.java
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/managers/SdlManagerTests.java
@@ -315,11 +315,8 @@ public class SdlManagerTests extends AndroidTestCase2 {
listenerCalledCounter++;
}
});
- try {
- sdlManager.sendRPC(request);
- } catch (SdlException e) {
- e.printStackTrace();
- }
+
+ sdlManager.sendRPC(request);
// Make sure the listener is called exactly once
assertEquals("Listener was not called or called more/less frequently than expected", listenerCalledCounter, 1);
@@ -375,16 +372,13 @@ public class SdlManagerTests extends AndroidTestCase2 {
@Override
public void onResponse(int correlationId, RPCResponse response) {}
};
- try {
- if (sequentialSend) {
- sdlManager.sendSequentialRPCs(rpcsList, onMultipleRequestListener);
- } else {
- sdlManager.sendRPCs(rpcsList, onMultipleRequestListener);
- }
- } catch (SdlException e) {
- e.printStackTrace();
+ if (sequentialSend) {
+ sdlManager.sendSequentialRPCs(rpcsList, onMultipleRequestListener);
+ } else {
+ sdlManager.sendRPCs(rpcsList, onMultipleRequestListener);
}
+
// Make sure the listener is called exactly once
assertEquals("Listener was not called or called more/less frequently than expected", listenerCalledCounter, 1);
}
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 2717123b5..0c98cab7e 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/managers/SdlManager.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/managers/SdlManager.java
@@ -601,12 +601,15 @@ public class SdlManager{
* Send RPC Message <br>
* <strong>Note: Only takes type of RPCRequest for now, notifications and responses will be thrown out</strong>
* @param message RPCMessage
- * @throws SdlException
*/
- public void sendRPC(RPCMessage message) throws SdlException {
+ public void sendRPC(RPCMessage message) {
if (message instanceof RPCRequest){
- proxy.sendRPCRequest((RPCRequest)message);
+ try{
+ proxy.sendRPCRequest((RPCRequest)message);
+ }catch (SdlException exception){
+ handleSdlException(exception);
+ }
}
}
@@ -620,9 +623,8 @@ public class SdlManager{
*
* @param rpcs is the list of RPCMessages being sent
* @param listener listener for updates and completions
- * @throws SdlException if an unrecoverable error is encountered
*/
- public void sendSequentialRPCs(final List<? extends RPCMessage> rpcs, final OnMultipleRequestListener listener) throws SdlException {
+ public void sendSequentialRPCs(final List<? extends RPCMessage> rpcs, final OnMultipleRequestListener listener){
List<RPCRequest> rpcRequestList = new ArrayList<>();
for (int i = 0; i < rpcs.size(); i++) {
@@ -632,7 +634,11 @@ public class SdlManager{
}
if (rpcRequestList.size() > 0) {
- proxy.sendSequentialRequests(rpcRequestList, listener);
+ try{
+ proxy.sendSequentialRequests(rpcRequestList, listener);
+ }catch (SdlException exception){
+ handleSdlException(exception);
+ }
}
}
@@ -646,9 +652,8 @@ public class SdlManager{
*
* @param rpcs is the list of RPCMessages being sent
* @param listener listener for updates and completions
- * @throws SdlException if an unrecoverable error is encountered
*/
- public void sendRPCs(List<? extends RPCMessage> rpcs, final OnMultipleRequestListener listener) throws SdlException {
+ public void sendRPCs(List<? extends RPCMessage> rpcs, final OnMultipleRequestListener listener) {
List<RPCRequest> rpcRequestList = new ArrayList<>();
for (int i = 0; i < rpcs.size(); i++) {
@@ -658,7 +663,20 @@ public class SdlManager{
}
if (rpcRequestList.size() > 0) {
- proxy.sendRequests(rpcRequestList, listener);
+ try{
+ proxy.sendRequests(rpcRequestList, listener);
+ }catch (SdlException exception){
+ handleSdlException(exception);
+ }
+ }
+ }
+
+ private void handleSdlException(SdlException exception){
+ if(exception != null){
+ DebugTool.logError("Caught SdlException: " + exception.getSdlExceptionCause());
+ // In the future this should handle logic to dispose the manager if it is an unrecoverable error
+ }else{
+ DebugTool.logError("Caught SdlException" );
}
}