private void processUndeployCmd(DataInputStream params, IOTACommandHelper helper) throws IOException { String suiteUri = params.readUTF(); FlashFile suiteFile = new FlashFile(suiteUri); if (suiteFile.exists()) { if (helper.isSuiteInUse(suiteUri)) { if (suiteUri.equals(Isolate.currentIsolate().getParentSuiteSourceURI())) { helper.makeObsolete(suiteUri); } else { helper.sendErrorDetails("Attempt to undeploy suite that is in use"); return; } } else { VM.unregisterSuite(suiteUri); suiteFile.delete(); } } else { helper.sendErrorDetails("Attempt to undeploy unknown suite: " + suiteUri); return; } helper.sendPrompt(); }
private void processFlashAppCmd(DataInputStream params, IOTACommandHelper helper) throws IOException { String fileNameOnTarget = params.readUTF(); FlashFile suiteFile = new FlashFile(fileNameOnTarget); String currentSuiteUri = Isolate.currentIsolate().getParentSuiteSourceURI(); boolean isReplacingCurrentAppSuite = fileNameOnTarget.equals(currentSuiteUri); boolean isRunningLibrary = currentSuiteUri.equals(ConfigPage.LIBRARY_URI); boolean isLibrarySuiteObsolete = new FlashFile("obsolete:" + ConfigPage.LIBRARY_URI).exists(); boolean isMasterAppSuiteObsolete = !isRunningLibrary && new FlashFile("obsolete:" + currentSuiteUri).exists(); /* * ircas irl ilso imaso action * 0 x 0 0 delete if exists and not in use, flash * 0 0 0 1 error return "Attempt to flash child suite while update to master is pending" * 0 1 0 1 cannot happen * 0 x 1 x error return "Attempt to flash application suite while update to library is pending" * 1 0 x 0 obsolete master app, then flash * 1 0 x 1 flash master app * 1 1 x x cannot happen * */ if (!isReplacingCurrentAppSuite) { if (isLibrarySuiteObsolete) { helper.sendErrorDetails( "Attempt to flash application suite while update to library is pending"); return; } if (isMasterAppSuiteObsolete) { helper.sendErrorDetails( "Attempt to flash child suite while update to master is pending"); // because if we // allowed this we'd need to perform a remap of the MMU, which would cause us to start // executing the // new bytecodes of the pending master app return; } if (suiteFile.exists()) { if (helper.isSuiteInUse(fileNameOnTarget)) { helper.sendErrorDetails("Attempt to replace child suite that is in use"); return; } VM.unregisterSuite(fileNameOnTarget); suiteFile.delete(); } } int virtualAddress; FlashFile currentFile = new FlashFile(fileNameOnTarget); if (currentFile.exists()) { virtualAddress = currentFile.getVirtualAddress(); } else { virtualAddress = FlashFile.getUnusedVirtualAddress(); } helper.sendPrompt(); Utils.log("[OTA] Flashing suite: " + fileNameOnTarget); helper.replaceSuiteFile(params, fileNameOnTarget, virtualAddress); if (!isReplacingCurrentAppSuite) { Utils.log("[OTA] remapping virtual addresses..."); suiteFile.map(); } helper.sendPrompt(); }