| 545 | } |
| 546 | |
| 547 | static bool installFromSdDynamic( |
| 548 | File &file, const String &path, uint32_t appSize, uint32_t appOffset, bool spiffs, uint32_t spiffsOffset, |
| 549 | uint32_t spiffsSize, uint32_t spiffsCopySize, std::vector<LauncherInstallFatPartition> &fatPartitions |
| 550 | ) { |
| 551 | String error; |
| 552 | LauncherPartitionTable table; |
| 553 | if (!launcherPartitionReadCurrent(table, &error)) { |
| 554 | displayRedStripe(error.length() ? error : "Partition read failed"); |
| 555 | launcherDelayMs(2000); |
| 556 | return false; |
| 557 | } |
| 558 | |
| 559 | if (appSize == 0 || appOffset + appSize > file.size()) { |
| 560 | displayRedStripe("Invalid app image"); |
| 561 | launcherDelayMs(2000); |
| 562 | return false; |
| 563 | } |
| 564 | |
| 565 | String appLabel = launcherPartitionNextAppLabel(table, installedAppNameFromPath(path)); |
| 566 | LauncherPartitionEntry appEntry; |
| 567 | LauncherPartitionEntry spiffsEntry; |
| 568 | bool hasSpiffsEntry = false; |
| 569 | |
| 570 | if (!launcherSelectInstallLayout( |
| 571 | table, |
| 572 | appSize, |
| 573 | appLabel, |
| 574 | spiffs, |
| 575 | spiffsSize, |
| 576 | fatPartitions, |
| 577 | appEntry, |
| 578 | spiffsEntry, |
| 579 | hasSpiffsEntry, |
| 580 | error |
| 581 | )) { |
| 582 | launcherConsolePrintf("SD install layout failed: %s\n", error.c_str()); |
| 583 | displayRedStripe(error.length() ? error : "No install space"); |
| 584 | launcherDelayMs(2000); |
| 585 | return false; |
| 586 | } |
| 587 | if (!launcherPartitionValidate(table, &error)) { |
| 588 | displayRedStripe(error.length() ? error : "Invalid table"); |
| 589 | launcherDelayMs(2000); |
| 590 | return false; |
| 591 | } |
| 592 | |
| 593 | pauseSdInstallInput(); |
| 594 | bool success = false; |
| 595 | displayRedStripe("Installing APP"); |
| 596 | prog_handler = 0; |
| 597 | if (!flashRawFromSd(file, appOffset, appSize, appEntry, true)) { |
| 598 | displayRedStripe(String("APP: ") + launcherUpdateLastErrorName()); |
| 599 | launcherDelayMs(2000); |
| 600 | goto DONE; |
| 601 | } |
| 602 | |
| 603 | if (hasSpiffsEntry && spiffsCopySize > 0) { |
| 604 | const uint32_t copySize = spiffsCopySize > spiffsEntry.size ? spiffsEntry.size : spiffsCopySize; |
no test coverage detected