Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public void tearDown() throws Exception {
assertNull(csm.currentSystemContext);
assertNull(csm.defaultMainWindowCapability);

assertEquals(csm.transactionQueue.getTasksAsList().size(), 0);
assertNull(csm.transactionQueue);

assertFalse(csm.isVROptional);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,11 @@ public void onDecoderError(Exception e) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
decoder = new AudioDecoder(audioSource, context.get(), sdlSampleRate, sdlSampleType, decoderListener);
} else {
if (getTransactionQueue() == null) {
DebugTool.logError(TAG, "Queue is null, cannot push audio source");
finish(completionListener, false);
return;
}
// this BaseAudioDecoder subclass uses methods deprecated with api 21
decoder = new AudioDecoderCompat(getTransactionQueue(), audioSource, context.get(), sdlSampleRate, sdlSampleType, decoderListener);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,13 @@ public void onComplete(boolean success, int bytesAvailable, Collection<String> f
}

private void listRemoteFilesWithCompletionListener(final FileManagerCompletionListener completionListener) {
if (transactionQueue == null) {
DebugTool.logError(TAG, "Queue is null, cannot retrieve uploaded files");
if (completionListener != null) {
completionListener.onComplete(false, bytesAvailable, null, "Queue is null, cannot upload files");
}
return;
}
ListFilesOperation operation = new ListFilesOperation(internalInterface, new FileManagerCompletionListener() {
@Override
public void onComplete(boolean success, int bytesAvailable, Collection<String> fileNames, String errorMessage) {
Expand Down Expand Up @@ -196,6 +203,13 @@ public void onComplete(boolean success, int bytesAvailable, Collection<String> f
}

private void deleteRemoteFileWithNamePrivate(@NonNull final String fileName, final FileManagerCompletionListener listener) {
if (transactionQueue == null) {
DebugTool.logError(TAG, "Queue is null, cannot delete files");
if (listener != null) {
listener.onComplete(false, bytesAvailable, null, "Queue is null, cannot delete files");
}
return;
}
DeleteFileOperation operation = new DeleteFileOperation(internalInterface, fileName, mutableRemoteFileNames, new FileManagerCompletionListener() {
@Override
public void onComplete(boolean success, int bytesAvailable, Collection<String> fileNames, String errorMessage) {
Expand Down Expand Up @@ -406,6 +420,14 @@ private void uploadFilePrivate(@NonNull final SdlFile file, final FileManagerCom
}

private void sdl_uploadFilePrivate(@NonNull final SdlFile file, final FileManagerCompletionListener listener) {

if (transactionQueue == null) {
DebugTool.logError(TAG, "Queue is null, cannot upload files");
if (listener != null) {
listener.onComplete(false, bytesAvailable, null, "Queue is null, cannot upload files");
}
return;
}
final SdlFile fileClone = file.clone();

SdlFileWrapper fileWrapper = new SdlFileWrapper(fileClone, new FileManagerCompletionListener() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,17 @@ public void dispose() {
public void presentAlert(AlertView alert, AlertCompletionListener listener) {
if (getState() == ERROR) {
DebugTool.logWarning(TAG, "Alert Manager In Error State");
if (listener != null) {
listener.onComplete(false, null);
}
return;
}

if (transactionQueue == null) {
DebugTool.logError(TAG, "Queue is null, Cannot present Alert.");
if (listener != null) {
listener.onComplete(false, null);
}
return;
}

Expand All @@ -149,6 +160,9 @@ public void presentAlert(AlertView alert, AlertCompletionListener listener) {
if (alert.getSoftButtons() != null) {
if (!BaseScreenManager.checkAndAssignButtonIds(alert.getSoftButtons(), BaseScreenManager.ManagerLocation.ALERT_MANAGER)) {
DebugTool.logError(TAG, "Attempted to set soft button objects for Alert, but multiple buttons had the same id.");
if (listener != null) {
listener.onComplete(false, null);
}
return;
}
softButtonObjects.addAll(alert.getSoftButtons());
Expand Down Expand Up @@ -216,10 +230,14 @@ protected SoftButtonObject getSoftButtonObjectById(int buttonId) {
private void updateTransactionQueueSuspended() {
if (!isAlertRPCAllowed || currentWindowCapability == null) {
DebugTool.logInfo(TAG, String.format("Suspending the transaction queue. Current permission status is false: %b, window capabilities are null: %b", isAlertRPCAllowed, currentWindowCapability == null));
transactionQueue.pause();
if (transactionQueue != null) {
transactionQueue.pause();
}
} else {
DebugTool.logInfo(TAG, "Starting the transaction queue");
transactionQueue.resume();
if (transactionQueue != null) {
transactionQueue.resume();
}
}
}

Expand Down Expand Up @@ -332,6 +350,11 @@ public void onNotified(RPCNotification notification) {

// Updates pending task with new DisplayCapabilities
void updatePendingOperationsWithNewWindowCapability() {
if (transactionQueue == null) {
DebugTool.logError(TAG, "Queue is null, cannot update any Alert operations with new " +
"WindowCapability");
return;
}
for (Task task : transactionQueue.getTasksAsList()) {
if (!(task instanceof PresentAlertOperation)) {
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,10 @@ public void onCapabilityRetrieved(Object capability) {

// Auto-send an updated Show if we have new capabilities
if (softButtonObjects != null && !softButtonObjects.isEmpty() && softButtonCapabilities != null && !softButtonCapabilitiesEquals(oldSoftButtonCapabilities, softButtonCapabilities)) {
if (transactionQueue == null) {
DebugTool.logError(TAG, "Queue is null, cannot update SoftButtons");
return;
}
SoftButtonReplaceOperation operation = new SoftButtonReplaceOperation(internalInterface, fileManager, softButtonCapabilities, softButtonObjects, getCurrentMainField1(), isDynamicGraphicSupported);
transactionQueue.add(operation, false);
}
Expand Down Expand Up @@ -261,10 +265,14 @@ private Queue newTransactionQueue() {
private void updateTransactionQueueSuspended() {
if (softButtonCapabilities == null || HMILevel.HMI_NONE.equals(currentHMILevel)) {
DebugTool.logInfo(TAG, String.format("Suspending the transaction queue. Current HMI level is NONE: %b, soft button capabilities are null: %b", HMILevel.HMI_NONE.equals(currentHMILevel), softButtonCapabilities == null));
transactionQueue.pause();
if (transactionQueue != null) {
transactionQueue.pause();
}
} else {
DebugTool.logInfo(TAG, "Starting the transaction queue");
transactionQueue.resume();
if (transactionQueue != null) {
transactionQueue.resume();
}
}
}

Expand Down Expand Up @@ -323,6 +331,10 @@ protected void setSoftButtonObjects(@NonNull List<SoftButtonObject> list) {
batchQueue.clear();
batchQueue.add(operation);
} else {
if (transactionQueue == null) {
DebugTool.logError(TAG, "Queue is null, cannot add SoftButtons");
return;
}
transactionQueue.clear();
transactionQueue.add(operation, false);
}
Expand Down Expand Up @@ -357,6 +369,10 @@ private void transitionSoftButton() {
}
batchQueue.add(operation);
} else {
if (transactionQueue == null) {
DebugTool.logError(TAG, "Queue is null, cannot transition SoftButton state");
return;
}
transactionQueue.add(operation, false);
}
}
Expand Down Expand Up @@ -397,6 +413,10 @@ protected SoftButtonObject getSoftButtonObjectById(int buttonId) {
* @param batchUpdates Set true if the manager should batch updates together, or false if it should send them as soon as they happen
*/
protected void setBatchUpdates(boolean batchUpdates) {
if (transactionQueue == null) {
DebugTool.logError(TAG, "Queue is null, cannot update SoftButtons");
return;
}
this.batchUpdates = batchUpdates;

if (!this.batchUpdates) {
Expand Down Expand Up @@ -425,6 +445,11 @@ protected String getCurrentMainField1() {
* @param currentMainField1 the String that will be set to TextField1 on the current template
*/
protected void setCurrentMainField1(String currentMainField1) {
if (transactionQueue == null) {
DebugTool.logError(TAG, "Queue is null, cannot update MainField1 for SoftButton " +
"operations");
return;
}
this.currentMainField1 = currentMainField1;

for (Task task : transactionQueue.getTasksAsList()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,14 @@ private Queue newTransactionQueue() {
private void updateTransactionQueueSuspended() {
if (defaultMainWindowCapability == null || HMILevel.HMI_NONE.equals(currentHMILevel)) {
DebugTool.logInfo(TAG, String.format("Suspending the transaction queue. Current HMI level is NONE: %b, window capabilities are null: %b", HMILevel.HMI_NONE.equals(currentHMILevel), defaultMainWindowCapability == null));
transactionQueue.pause();
if (transactionQueue != null) {
transactionQueue.pause();
}
} else {
DebugTool.logInfo(TAG, "Starting the transaction queue");
transactionQueue.resume();
if (transactionQueue != null) {
transactionQueue.resume();
}
}
}

Expand All @@ -181,6 +185,13 @@ protected void update(CompletionListener listener) {
}

private synchronized void sdlUpdate(final CompletionListener listener) {
if (transactionQueue == null) {
DebugTool.logError(TAG, "Queue is null, cannot perform a text/graphic update");
if (listener != null) {
listener.onComplete(false);
}
return;
}

CurrentScreenDataUpdatedListener currentScreenDataUpdateListener = new CurrentScreenDataUpdatedListener() {
@Override
Expand Down Expand Up @@ -225,6 +236,10 @@ void resetFieldsToCurrentScreenData() {

//Updates pending task with current screen data
void updatePendingOperationsWithNewScreenData() {
if (transactionQueue == null) {
DebugTool.logError(TAG, "Queue is null");
return;
}
for (Task task : transactionQueue.getTasksAsList()) {
if (!(task instanceof TextAndGraphicUpdateOperation)) {
continue;
Expand All @@ -237,6 +252,10 @@ void updatePendingOperationsWithNewScreenData() {
}

void updatePendingOperationsWithFailedScreenState(TextAndGraphicState errorState) {
if (transactionQueue == null) {
DebugTool.logError(TAG, "Queue is null");
return;
}
for (Task task : transactionQueue.getTasksAsList()) {
if (!(task instanceof TextAndGraphicUpdateOperation)) {
continue;
Expand Down
Loading