Lines Matching refs:transport
61 #include "transport.h"
233 // Opens a new Transport connected to a device. If |serial| is non-null it will be used to identify
239 // The returned Transport is a singleton, so multiple calls to this function will return the same
240 // object, and the caller should not attempt to delete the returned Transport.
241 static Transport* open_device() {
242 static Transport* transport = nullptr;
245 if (transport != nullptr) {
246 return transport;
279 transport = tcp::Connect(host, port, &error).release();
281 transport = udp::Connect(host, port, &error).release();
284 if (transport == nullptr && announce) {
288 transport = usb_open(match_fastboot);
291 if (transport != nullptr) {
292 return transport;
726 static int64_t get_target_sparse_limit(Transport* transport) {
728 if (!fb_getvar(transport, "max-download-size", &max_download_size) ||
748 static int64_t get_sparse_limit(Transport* transport, int64_t size) {
757 target_sparse_limit = get_target_sparse_limit(transport);
776 static bool needs_erase(Transport* transport, const char* partition) {
778 if (!fb_getvar(transport, std::string("partition-type:") + partition, &partition_type)) {
784 static int load_buf_fd(Transport* transport, int fd, struct fastboot_buffer* buf) {
791 int64_t limit = get_sparse_limit(transport, sz);
810 static int load_buf(Transport* transport, const char *fname, struct fastboot_buffer *buf)
819 return load_buf_fd(transport, fd, buf);
851 static std::vector<std::string> get_suffixes(Transport* transport) {
854 if (!fb_getvar(transport, "slot-suffixes", &suffix_list)) {
860 static std::string verify_slot(Transport* transport, const char *slot, bool allow_all) {
865 std::vector<std::string> suffixes = get_suffixes(transport);
874 std::vector<std::string> suffixes = get_suffixes(transport);
878 if (!fb_getvar(transport, "current-slot", ¤t_slot)) {
902 static std::string verify_slot(Transport* transport, const char *slot) {
903 return verify_slot(transport, slot, true);
906 static void do_for_partition(Transport* transport, const char *part, const char *slot,
911 if (!fb_getvar(transport, std::string("has-slot:")+part, &has_slot)) {
917 if (!fb_getvar(transport, "current-slot", ¤t_slot)) {
938 static void do_for_partitions(Transport* transport, const char *part, const char *slot,
943 if (!fb_getvar(transport, std::string("has-slot:") + part, &has_slot)) {
947 transport);
949 do_for_partition(transport, part, suffix.c_str(), func, force_slot);
952 do_for_partition(transport, part, "", func, force_slot);
955 do_for_partition(transport, part, slot, func, force_slot);
959 static void do_flash(Transport* transport, const char* pname, const char* fname) {
962 if (load_buf(transport, fname, &buf)) {
976 static void do_update(Transport* transport, const char* filename, const char* slot_override, bool erase_first) {
1007 int rc = load_buf_fd(transport, fd, &buf);
1012 if (erase_first && needs_erase(transport, partition.c_str())) {
1021 do_for_partitions(transport, images[i].part_name, slot_override, update, false);
1043 static void do_flashall(Transport* transport, const char* slot_override, int erase_first) {
1060 if (load_buf(transport, fname, &buf)) {
1068 if (erase_first && needs_erase(transport, partition.c_str())) {
1073 do_for_partitions(transport, images[i].part_name, slot_override, flashall, false);
1158 static void fb_perform_format(Transport* transport,
1177 if (!fb_getvar(transport, std::string("partition-type:") + partition, &partition_type)) {
1189 if (!fb_getvar(transport, std::string("partition-size:") + partition, &partition_size)) {
1231 if (load_buf_fd(transport, fd, &buf)) {
1396 Transport* transport = open_device();
1397 if (transport == nullptr) {
1402 slot_override = verify_slot(transport, slot_override.c_str());
1404 next_active = verify_slot(transport, next_active.c_str(), false);
1411 next_active = verify_slot(transport, slot_override.c_str(), false);
1426 if (fb_getvar(transport, std::string("partition-type:") + argv[1], &partition_type) &&
1434 do_for_partitions(transport, argv[1], slot_override.c_str(), erase, true);
1464 if (erase_first && needs_erase(transport, partition.c_str())) {
1467 fb_perform_format(transport, partition.c_str(), 0,
1470 do_for_partitions(transport, argv[1], slot_override.c_str(), format, true);
1532 if (erase_first && needs_erase(transport, partition.c_str())) {
1535 do_flash(transport, partition.c_str(), fname);
1537 do_for_partitions(transport, pname, slot_override.c_str(), flash, true);
1557 do_for_partitions(transport, argv[1], slot_override.c_str(), flashraw, true);
1560 do_flashall(transport, slot_override.c_str(), erase_first);
1564 do_update(transport, argv[1], slot_override.c_str(), erase_first);
1567 do_update(transport, "update.zip", slot_override.c_str(), erase_first);
1573 std::string slot = verify_slot(transport, argv[1], false);
1609 fb_perform_format(transport, "userdata", 1, nullptr, nullptr, initial_userdata_dir);
1612 fb_perform_format(transport, "userdata", 1, nullptr, nullptr, "");
1616 if (fb_getvar(transport, "partition-type:cache", &cache_type) && !cache_type.empty()) {
1619 fb_perform_format(transport, "cache", 1, nullptr, nullptr, "");
1633 return fb_execute_queue(transport) ? EXIT_FAILURE : EXIT_SUCCESS;