• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

system/corennnnn


Commit MetaInfo

Revisionefa8604a1d1b3acd156d6aefdf7840d9e6486dd0 (tree)
Time2016-07-16 10:21:21
AuthorTreeHugger Robot <treehugger-gerrit@goog...>
CommiterAndroid (Google) Code Review

Log Message

Merge "Add skip-secondary flag" into nyc-mr1-dev

Change Summary

Incremental Difference

--- a/fastboot/fastboot.cpp
+++ b/fastboot/fastboot.cpp
@@ -327,9 +327,6 @@ static void usage() {
327327 " been flashed to is set as active.\n"
328328 " Secondary images may be flashed to\n"
329329 " an inactive slot.\n"
330- " flash-primary Same as flashall, but do not flash\n"
331- " secondary images.\n"
332- " flash-secondary Only flashes the secondary images.\n"
333330 " flash <partition> [ <filename> ] Write a file to a flash partition.\n"
334331 " flashing lock Locks the device. Prevents flashing.\n"
335332 " flashing unlock Unlocks the device. Allows flashing\n"
@@ -404,6 +401,9 @@ static void usage() {
404401 " supported, this sets the current slot\n"
405402 " to be active. This will run after all\n"
406403 " non-reboot commands.\n"
404+ " --skip-secondary Will not flash secondary slots when\n"
405+ " performing a flashall or update. This\n"
406+ " will preserve data on other slots.\n"
407407 #if !defined(_WIN32)
408408 " --wipe-and-use-fbe On devices which support it,\n"
409409 " erase userdata and cache, and\n"
@@ -1064,7 +1064,7 @@ static void set_active(Transport* transport, const std::string& slot_override) {
10641064 }
10651065 }
10661066
1067-static void do_update(Transport* transport, const char* filename, const std::string& slot_override, bool erase_first) {
1067+static void do_update(Transport* transport, const char* filename, const std::string& slot_override, bool erase_first, bool skip_secondary) {
10681068 queue_info_dump();
10691069
10701070 fb_queue_query_save("product", cur_product, sizeof(cur_product));
@@ -1086,8 +1086,7 @@ static void do_update(Transport* transport, const char* filename, const std::str
10861086 setup_requirements(reinterpret_cast<char*>(data), sz);
10871087
10881088 std::string secondary;
1089- bool update_secondary = slot_override != "all";
1090- if (update_secondary) {
1089+ if (!skip_secondary) {
10911090 if (slot_override != "") {
10921091 secondary = get_other_slot(transport, slot_override);
10931092 } else {
@@ -1097,13 +1096,13 @@ static void do_update(Transport* transport, const char* filename, const std::str
10971096 if (supports_AB(transport)) {
10981097 fprintf(stderr, "Warning: Could not determine slot for secondary images. Ignoring.\n");
10991098 }
1100- update_secondary = false;
1099+ skip_secondary = true;
11011100 }
11021101 }
11031102 for (size_t i = 0; i < ARRAY_SIZE(images); ++i) {
11041103 const char* slot = slot_override.c_str();
11051104 if (images[i].is_secondary) {
1106- if (update_secondary) {
1105+ if (!skip_secondary) {
11071106 slot = secondary.c_str();
11081107 } else {
11091108 continue;
@@ -1137,7 +1136,11 @@ static void do_update(Transport* transport, const char* filename, const std::str
11371136 }
11381137
11391138 CloseArchive(zip);
1140- set_active(transport, slot_override);
1139+ if (slot_override == "all") {
1140+ set_active(transport, "a");
1141+ } else {
1142+ set_active(transport, slot_override);
1143+ }
11411144 }
11421145
11431146 static void do_send_signature(const std::string& fn) {
@@ -1153,24 +1156,23 @@ static void do_send_signature(const std::string& fn) {
11531156 fb_queue_command("signature", "installing signature");
11541157 }
11551158
1156-static void do_flashall(Transport* transport, const std::string& slot_override, int erase_first, bool flash_primary, bool flash_secondary) {
1159+static void do_flashall(Transport* transport, const std::string& slot_override, int erase_first, bool skip_secondary) {
11571160 std::string fname;
1158- if (flash_primary) {
1159- queue_info_dump();
1161+ queue_info_dump();
1162+
1163+ fb_queue_query_save("product", cur_product, sizeof(cur_product));
11601164
1161- fb_queue_query_save("product", cur_product, sizeof(cur_product));
1165+ fname = find_item("info", product);
1166+ if (fname == "") die("cannot find android-info.txt");
11621167
1163- fname = find_item("info", product);
1164- if (fname == "") die("cannot find android-info.txt");
1168+ int64_t sz;
1169+ void* data = load_file(fname.c_str(), &sz);
1170+ if (data == nullptr) die("could not load android-info.txt: %s", strerror(errno));
11651171
1166- int64_t sz;
1167- void* data = load_file(fname.c_str(), &sz);
1168- if (data == nullptr) die("could not load android-info.txt: %s", strerror(errno));
1172+ setup_requirements(reinterpret_cast<char*>(data), sz);
11691173
1170- setup_requirements(reinterpret_cast<char*>(data), sz);
1171- }
11721174 std::string secondary;
1173- if (flash_secondary) {
1175+ if (!skip_secondary) {
11741176 if (slot_override != "") {
11751177 secondary = get_other_slot(transport, slot_override);
11761178 } else {
@@ -1180,16 +1182,16 @@ static void do_flashall(Transport* transport, const std::string& slot_override,
11801182 if (supports_AB(transport)) {
11811183 fprintf(stderr, "Warning: Could not determine slot for secondary images. Ignoring.\n");
11821184 }
1183- flash_secondary = false;
1185+ skip_secondary = true;
11841186 }
11851187 }
11861188
11871189 for (size_t i = 0; i < ARRAY_SIZE(images); i++) {
11881190 const char* slot = NULL;
11891191 if (images[i].is_secondary) {
1190- if (flash_secondary) slot = secondary.c_str();
1192+ if (!skip_secondary) slot = secondary.c_str();
11911193 } else {
1192- if (flash_primary) slot = slot_override.c_str();
1194+ slot = slot_override.c_str();
11931195 }
11941196 if (!slot) continue;
11951197 fname = find_item_given_name(images[i].img_name, product);
@@ -1209,7 +1211,11 @@ static void do_flashall(Transport* transport, const std::string& slot_override,
12091211 do_for_partitions(transport, images[i].part_name, slot, flashall, false);
12101212 }
12111213
1212- if (flash_primary) set_active(transport, slot_override);
1214+ if (slot_override == "all") {
1215+ set_active(transport, "a");
1216+ } else {
1217+ set_active(transport, slot_override);
1218+ }
12131219 }
12141220
12151221 #define skip(n) do { argc -= (n); argv += (n); } while (0)
@@ -1388,6 +1394,7 @@ int main(int argc, char **argv)
13881394 bool wants_reboot = false;
13891395 bool wants_reboot_bootloader = false;
13901396 bool wants_set_active = false;
1397+ bool skip_secondary = false;
13911398 bool erase_first = true;
13921399 bool set_fbe_marker = false;
13931400 void *data;
@@ -1412,6 +1419,7 @@ int main(int argc, char **argv)
14121419 {"slot", required_argument, 0, 0},
14131420 {"set_active", optional_argument, 0, 'a'},
14141421 {"set-active", optional_argument, 0, 'a'},
1422+ {"skip-secondary", no_argument, 0, 0},
14151423 #if !defined(_WIN32)
14161424 {"wipe-and-use-fbe", no_argument, 0, 0},
14171425 #endif
@@ -1496,6 +1504,8 @@ int main(int argc, char **argv)
14961504 return 0;
14971505 } else if (strcmp("slot", longopts[longindex].name) == 0) {
14981506 slot_override = std::string(optarg);
1507+ } else if (strcmp("skip-secondary", longopts[longindex].name) == 0 ) {
1508+ skip_secondary = true;
14991509 #if !defined(_WIN32)
15001510 } else if (strcmp("wipe-and-use-fbe", longopts[longindex].name) == 0) {
15011511 wants_wipe = true;
@@ -1702,26 +1712,22 @@ int main(int argc, char **argv)
17021712 } else if(!strcmp(*argv, "flashall")) {
17031713 skip(1);
17041714 if (slot_override == "all") {
1705- fprintf(stderr, "Warning: slot set to 'all'. Secondary slots will not be flashed.");
1706- do_flashall(transport, slot_override, erase_first, true, false);
1715+ fprintf(stderr, "Warning: slot set to 'all'. Secondary slots will not be flashed.\n");
1716+ do_flashall(transport, slot_override, erase_first, true);
17071717 } else {
1708- do_flashall(transport, slot_override, erase_first, true, true);
1718+ do_flashall(transport, slot_override, erase_first, skip_secondary);
17091719 }
17101720 wants_reboot = true;
1711- } else if(!strcmp(*argv, "flash-primary")) {
1712- skip(1);
1713- do_flashall(transport, slot_override, erase_first, true, false);
1714- wants_reboot = true;
1715- } else if(!strcmp(*argv, "flash-secondary")) {
1716- skip(1);
1717- do_flashall(transport, slot_override, erase_first, false, true);
1718- wants_reboot = true;
17191721 } else if(!strcmp(*argv, "update")) {
1722+ bool slot_all = (slot_override == "all");
1723+ if (slot_all) {
1724+ fprintf(stderr, "Warning: slot set to 'all'. Secondary slots will not be flashed.\n");
1725+ }
17201726 if (argc > 1) {
1721- do_update(transport, argv[1], slot_override, erase_first);
1727+ do_update(transport, argv[1], slot_override, erase_first, skip_secondary || slot_all);
17221728 skip(2);
17231729 } else {
1724- do_update(transport, "update.zip", slot_override, erase_first);
1730+ do_update(transport, "update.zip", slot_override, erase_first, skip_secondary || slot_all);
17251731 skip(1);
17261732 }
17271733 wants_reboot = 1;