diff options
author | BrettyWhite <geekman3454@protonmail.com> | 2019-06-10 13:37:37 -0400 |
---|---|---|
committer | BrettyWhite <geekman3454@protonmail.com> | 2019-06-10 13:37:37 -0400 |
commit | 975f87e7a3a2c3fe77aa4b6c17c34650a8f27d9f (patch) | |
tree | 5a84ba1f5a733538cea3e03c519df3b23eb15464 | |
parent | ed04e3b4a155014d1fd79f52710568bd9d0a5595 (diff) | |
download | sdl_android-975f87e7a3a2c3fe77aa4b6c17c34650a8f27d9f.tar.gz |
fixed NPE and deletion issue
4 files changed, 23 insertions, 5 deletions
diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/BaseChoiceSetManager.java b/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/BaseChoiceSetManager.java index d96a8b4f1..5cd089abd 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/BaseChoiceSetManager.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/BaseChoiceSetManager.java @@ -156,7 +156,7 @@ abstract class BaseChoiceSetManager extends BaseSubManager { public void onCheckChoiceVROperationComplete(boolean vrOptional) { isVROptional = vrOptional; transitionToState(READY); - Log.i("CHOICE", "VOICE IS OPTIONAL: "+ vrOptional + " READY TO GO"); + DebugTool.logInfo("VR is optional: "+ isVROptional); } @Override @@ -225,7 +225,10 @@ abstract class BaseChoiceSetManager extends BaseSubManager { final HashSet<ChoiceCell> cellsToBeDeleted = choicesToBeDeletedWithArray(choices); HashSet<ChoiceCell> cellsToBeRemovedFromPending = choicesToBeRemovedFromPendingWithArray(choices); // If choices are deleted that are already uploaded or pending and are used by a pending presentation, cancel it and send an error - HashSet<ChoiceCell> pendingPresentationChoices = new HashSet<>(pendingPresentationSet.getChoices()); + HashSet<ChoiceCell> pendingPresentationChoices = new HashSet<>(); + if (pendingPresentationSet != null && pendingPresentationSet.getChoices() != null) { + pendingPresentationChoices.addAll(pendingPresentationSet.getChoices()); + } if (pendingPresentOperation != null && !pendingPresentOperation.isCancelled() && !pendingPresentOperation.isDone() && (cellsToBeDeleted.retainAll(pendingPresentationChoices) || cellsToBeRemovedFromPending.retainAll(pendingPresentationChoices))){ pendingPresentOperation.cancel(true); @@ -241,7 +244,10 @@ abstract class BaseChoiceSetManager extends BaseSubManager { } // Find Choices to delete - if (cellsToBeDeleted.size() == 0){ return; } + if (cellsToBeDeleted.size() == 0){ + DebugTool.logInfo("Cells to be deleted size == 0"); + return; + } findIdsOnChoices(cellsToBeDeleted); DeleteChoicesOperation deleteChoicesOperation = new DeleteChoicesOperation(internalInterface, cellsToBeDeleted, new CompletionListener() { @@ -254,8 +260,7 @@ abstract class BaseChoiceSetManager extends BaseSubManager { preloadedChoices.removeAll(cellsToBeDeleted); } }); - Future something = executor.submit(deleteChoicesOperation); - something.cancel(true); + executor.submit(deleteChoicesOperation); } public void presentChoiceSet(final ChoiceSet choiceSet, final InteractionMode mode, final KeyboardListener keyboardListener){ diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/operations/DeleteChoicesOperation.java b/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/operations/DeleteChoicesOperation.java index faf0b909d..482c3de4f 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/operations/DeleteChoicesOperation.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/operations/DeleteChoicesOperation.java @@ -39,6 +39,7 @@ import com.smartdevicelink.proxy.interfaces.ISdl; import com.smartdevicelink.proxy.rpc.DeleteInteractionChoiceSet; import com.smartdevicelink.proxy.rpc.enums.Result; import com.smartdevicelink.proxy.rpc.listeners.OnMultipleRequestListener; +import com.smartdevicelink.util.DebugTool; import java.lang.ref.WeakReference; import java.util.ArrayList; @@ -79,6 +80,7 @@ public class DeleteChoicesOperation implements Runnable { if (completionListener != null){ completionListener.onComplete(true); } + DebugTool.logInfo("Successfully deleted choices"); } @Override @@ -86,6 +88,7 @@ public class DeleteChoicesOperation implements Runnable { if (completionListener != null){ completionListener.onComplete(false); } + DebugTool.logError("Failed to delete choice: "+ info+ " | Corr ID: "+ correlationId); } @Override diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/operations/PresentChoiceSetOperation.java b/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/operations/PresentChoiceSetOperation.java index 31234372e..590e1b553 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/operations/PresentChoiceSetOperation.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/operations/PresentChoiceSetOperation.java @@ -248,6 +248,11 @@ public class PresentChoiceSetOperation implements Runnable { @Override public void onNotified(RPCNotification notification) { + if (Thread.interrupted()){ + finishOperation(); + return; + } + if (keyboardListener == null){ DebugTool.logError("Received Keyboard Input But Listener is null"); return; diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/operations/PresentKeyboardOperation.java b/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/operations/PresentKeyboardOperation.java index 2c7d74f6d..617767472 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/operations/PresentKeyboardOperation.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/operations/PresentKeyboardOperation.java @@ -192,6 +192,11 @@ public class PresentKeyboardOperation implements Runnable { @Override public void onNotified(RPCNotification notification) { + if (Thread.interrupted()){ + finishOperation(); + return; + } + if (keyboardListener == null){ DebugTool.logError("Received Keyboard Input But Listener is null"); return; |