Commit graph

397 commits

Author SHA1 Message Date
Daniel Rosenberg
559cc01e3e resolve merge conflicts of 40eff95 to stage-aosp-master
Change-Id: I91935ba9603ffd41af2009adc13a024701619c52
2016-08-22 20:13:52 -07:00
Daniel Rosenberg
92b4476aa0 Add skip-secondary flag
The skip-secondary flag now replaces flash-primary. This flag will
skip over the secondary images for both flashall and update.

Change-Id: I9f380f3195006d325d6c45776bf79ecec17506ad
(cherry-picked from commit e180929866)
2016-08-19 16:52:26 -07:00
Daniel Rosenberg
8091947847 Switch fastboot to new A/B spec
Slots are now referred to as a and b instead
of _a and _b. For the moment, _a and _b will
still be supported. For old devices that
support A/B, they are assumed to have 2 slots.

Bug: 29643845
Change-Id: Ieab6bed7b4977d8386dcec0afa434371f54bd63f
(cherry-picked from commit 563fcf6f69)
2016-08-19 16:52:26 -07:00
Alex Light
bb9b8a5abf Add Fastboot support for flashing secondary images
Fastboot update and flashall will now flash secondary
images if provided, and if the --slot flag is not set
to 'all'. Also added flash-primary to preserve the
previous behavior, and flash-secondary to just flash
the secondary images.

Fixes from: I5bd2de1c1e0e6224a195b566f7dcbe383555a80a

Bug: 29278988
Change-Id: Ia870e4be55617c0eefa4e1381287f8cd14affe7e
(cherry-picked from commit 6c98509c34)
2016-08-19 16:52:26 -07:00
Daniel Rosenberg
ad3d3c184e Handle invalid suffix lists
Some devices will report an error string as a value
when unknown variables are queried. This can lead to
unexpected behavior, so we attempt to detect this case
by seeing if the suffix list doesn't make sense.

Change-Id: I939b1e01c40ddc05d881fd54423406db250cc8e5
(cherry-picked from commit 190d968414)
2016-08-19 15:31:01 -07:00
Daniel Rosenberg
1345409537 Call set_active after flashall and update
If the device has previously failed to boot, and the current slot is
marked as unbootable, we must call set_active to reenable the slot.

Bug: 29827625
Change-Id: I8b723dda80e246b48e5967aff4503c3d120bfb9b
(cherry-picked from commit 9c9a6c62e5)
2016-08-19 15:31:01 -07:00
Greg Kaiser
0c8a67bbfd Merge "fastboot: Don't leak file in error case"
am: 3a197b3799

Change-Id: Ieaab2ed5c1619f75fa4c334d61afaf858ad7d46c
2016-08-12 17:45:32 +00:00
Greg Kaiser
dc9b62ba74 fastboot: Don't leak file in error case
This is probably not very significant in this standalone tool,
but makes it easier for us to find leaks in our other system
code via static analysis.

(cherry-pick of 407a2195391685627e6be947491041ae3c8cbe61.)

Change-Id: I4e14cadc1e53bac0848e0e0c7f531f920e43cb0a
2016-08-12 08:57:22 -07:00
Chih-Hung Hsieh
4c4fa90462 Merge \"Fix clang-tidy performance warnings in syste/core.\"
am: 4efbce14b5

Change-Id: I84f6b0134fae6e9f40710f243f4825e3f31fa15f
2016-08-01 20:23:10 +00:00
Treehugger Robot
4efbce14b5 Merge "Fix clang-tidy performance warnings in syste/core." 2016-08-01 20:13:54 +00:00
Chih-Hung Hsieh
8f7b9e3d39 Fix clang-tidy performance warnings in syste/core.
* Use const reference type for parameters to avoid unnecessary copy.
* Suppress warning of not using faster overloaded string find function.

Bug: 30407689
Bug: 30411878
Change-Id: I6cfdbbd50cf5e8f3db6e5263076d3a17a9a791ee
Test: build with WITH_TIDY=1
Merged-In: Ie79dbe21899867bc62031f8618bb1322b8071525
2016-08-01 11:55:42 -07:00
Chih-Hung Hsieh
89cc78b77f Merge \"Fix google-explicit-constructor warnings in system/core.\"
am: 6dc68cb5f9

Change-Id: I5a010465364b6e14423b19e8c0f9cffa58ee3152
2016-07-29 17:01:17 +00:00
Chih-Hung Hsieh
034c475931 Fix google-explicit-constructor warnings in system/core.
* Declare explicit conversion constructors.
* Add NOLINT for implicit conversion constructors.
* Fix also some misaligned indendations.

Bug: 28341362
Change-Id: Idf911f35923b408d92285cc1a053f382ba08c63e
Test: build with clang-tidy
2016-07-26 11:26:01 -07:00
Elliott Hughes
7191a56e96 Merge \"Remove unnecessary ARRAY_SIZE macros.\"
am: c37d8ea22a

Change-Id: Id3443d7247e893ee549ae5b799a8f0bf42088d35
2016-06-29 00:16:44 +00:00
Elliott Hughes
749ae2d32f Remove unnecessary ARRAY_SIZE macros.
Use the canonical one instead.

Change-Id: Id80f19455f37fd2a29d9ec4191c1a0af80c5c0e7
2016-06-28 14:48:45 -07:00
Chih-Hung Hsieh
65828a0ec9 Merge \"Fix misc-macro-parentheses warnings in system/core.\"
am: 495541c5bb

Change-Id: I021b653779c5119398c31ee354372366ba029328
2016-06-22 22:39:07 +00:00
Chih-Hung Hsieh
cdb2ca5d9f Fix misc-macro-parentheses warnings in system/core.
Add parentheses around macro arguments used beside operators.
Bug: 28705665

Change-Id: I9226f319e283be640eddc31687f75b51a8ef0ac6
2016-06-22 14:33:13 -07:00
Elliott Hughes
7f80f04a2c Merge "Report errno more often in fastboot." am: 8c5384e50b
am: 272b2694cd

* commit '272b2694cd3556120a3e39b88a0702103e2ed58a':
  Report errno more often in fastboot.

Change-Id: Ie26d2c70e65b70c08017f848f21fb91d6f20e3a4
2016-05-11 21:50:07 +00:00
Elliott Hughes
53ec495b40 Report errno more often in fastboot.
Change-Id: I4b4b47c584a146b38876a379f26ceb20d071c643
2016-05-11 12:39:27 -07:00
Chih-hung Hsieh
fb44ca5178 Merge "Fix google-explicit-constructor warnings." am: 7bdd6a8b5a
am: 427d8d840f

* commit '427d8d840f6ec5ce5767b2ee521e4ac5b7ebd619':
  Fix google-explicit-constructor warnings.

Change-Id: I26dc45aca83f991aa7993f6d4233e0439dd44a22
2016-04-30 05:16:35 +00:00
Chih-hung Hsieh
7bdd6a8b5a Merge "Fix google-explicit-constructor warnings." 2016-04-30 05:10:05 +00:00
Chih-Hung Hsieh
1c563d96f0 Fix google-explicit-constructor warnings.
Bug: 28341362
Change-Id: I4504e98a8db31e0edcbe63c23f9af43eb13e9d86
2016-04-29 15:44:04 -07:00
Elliott Hughes
a73dfe0cf9 Merge "Use more std::string in fastboot." am: 17f3b1bad7
am: 05ec41963d

* commit '05ec41963d7e219a78ef9ffad6d1b1dcf5f4135c':
  Use more std::string in fastboot.

Change-Id: I819aefd792b1c3cd98403f0b25afa21717086e44
2016-04-29 17:58:07 +00:00
Elliott Hughes
2810d00dd9 Use more std::string in fastboot.
Change-Id: Ic8c77eac1e0088627ab650050d9c97c5749e5c39
2016-04-29 08:30:13 -07:00
Elliott Hughes
32fed55e81 Merge "GCC compiler warning fix for sprintf into snprintf" am: d2afbe4
am: 3b4af9a

* commit '3b4af9a44dd6ffa724dfb5f40479f817efc74227':
  GCC compiler warning fix for sprintf into snprintf

Change-Id: I76d8892909721d7218112f5d360eca91ae686e84
2016-04-25 21:20:15 +00:00
Raja M
79bf64dc66 GCC compiler warning fix for sprintf into snprintf
To fix GCC WARNINGS while building.
or
To support error free -D_FORTIFY_SOURCE=2 strict mode compilation.
2016-04-24 09:44:04 +05:30
Alex Deymo
1b245719f1 Merge "fastboot: Minor fix to help text."
am: 92a7043

* commit '92a70439d6767f577546ccf7baf215b113265ae0':
  fastboot: Minor fix to help text.
2016-03-25 04:49:37 +00:00
Alex Deymo
f62d0cd943 fastboot: Minor fix to help text.
Help text had some missing end of line markers.

Bug: None
TEST=make out/host/linux-x86/bin/fastboot; fastboot

Change-Id: Iaa9e4e0a2d70c7d427f5e99e72fe1c2e2c26ee92
2016-03-24 19:51:05 -07:00
Ying Wang
3905db7616 Merge "Also archive adb.exe/fastboot.exe when building win_sdk." am: f666ba41a7
am: aa88fa5837

* commit 'aa88fa58371930b9b7aef8d942f72d7b9a29c8a7':
  Also archive adb.exe/fastboot.exe when building win_sdk.
2016-03-01 19:50:46 +00:00
Ying Wang
71edfc8b9a Also archive adb.exe/fastboot.exe when building win_sdk.
On linux we archive both Linux and Windows binaries.

Bug: 27315911
Change-Id: I17d25cd1ea611a9c917f1e78b47f21a8959eea20
2016-02-29 19:27:06 -08:00
James Hawkins
22b6f7a559 resolve merge conflicts of 0f5d443d0c to nyc-dev-plus-aosp
Change-Id: I850bda0808ae17ade5bc0e667211a599d284d6e3
2016-02-19 11:10:30 -08:00
James Hawkins
588a2cad7f system/core: Cleanup direct calls to opendir by containing in a
std::unique_ptr.

Bug: 26643633
Change-Id: Ia3491fdbff086558da694ae949cf08e4c89d0307
2016-02-18 14:52:46 -08:00
David Pursell
7b3b490fe2 Merge "fastboot: fix TCP protocol version check."
am: bcaeb78f63

* commit 'bcaeb78f63efb1daa83b5ed43aca9775ac1014b3':
  fastboot: fix TCP protocol version check.
2016-02-17 18:25:22 +00:00
David Pursell
aad72a533f fastboot: fix TCP protocol version check.
Currently the TCP handshake fails if the device TCP protocol version
doesn't match the host exactly, but the protocol is supposed to allow
for forwards compatibility by accepting any protocol version >= itself.
That way the other side can potentially lower its protocol to match and
keep going.

This CL fixes the protocol version check and adds corresponding unit
tests.

Bug: http://b/27220700
Change-Id: Ib17f0a55eb910105a27609bc94bf76a30442e92e
2016-02-17 10:00:09 -08:00
David Pursell
22317f2b5a Merge "fastboot: add UDP protocol."
am: c7f43c6ae1

* commit 'c7f43c6ae16a475627e6b3da44dde1cad17ab45a':
  fastboot: add UDP protocol.
2016-02-10 20:03:48 +00:00
David Pursell
4601c978ca fastboot: add UDP protocol.
Implements a UDP protocol for fastboot, documented in
fastboot_protocol.txt.

This version of the protocol does not include multi-packet windowing,
which will likely be needed to achieve reasonable speeds over WiFi.
Since we don't have any WiFi use cases yet, we'd like to get this in
now and update the protocol later if it becomes necessary.

Usage:
  fastboot -s udp:<hostname>[:port] <command>

Bug: http://b/26154914
Change-Id: Ia5bbae6bcd6405671f594d7120b3994746d234d3
2016-02-10 10:21:30 -08:00
David Pursell
09bd9593f0 Merge "fastboot: add Socket timeout detection."
am: d4ac11a57d

* commit 'd4ac11a57d37c56360e59ba75aa2f6ee777e5ed8':
  fastboot: add Socket timeout detection.
2016-02-08 19:00:39 +00:00
David Pursell
c742a7f174 fastboot: add Socket timeout detection.
UDP fastboot will require re-transmission in the case of datagrams
getting lost. This CL adds Socket functionality to easily distinguish
between a normal timeout and a socket failure.

I also found some Windows docs that indicate sockets may become
invalid after a call to recv() times out. This has never occurred in
my testing, but to be safe this switches the timeout implementation
to use select() instead of SO_RCVTIMEO.

Bug: http://b/26154914
Change-Id: Id7b598f8aea5df1a3676d24702b489042d5f9e3a
2016-02-05 13:22:06 -08:00
Elliott Hughes
a8c7e98123 Merge "Fix the version number in the fastboot documentation." am: 80e88a1274
am: 0f242b2dbf

* commit '0f242b2dbfd076fb1a23e6d5f80e317e8afc0a50':
  Fix the version number in the fastboot documentation.
2016-02-03 23:20:23 +00:00
Elliott Hughes
d505cd8db2 Fix the version number in the fastboot documentation.
Bug: https://code.google.com/p/android/issues/detail?id=65414
Change-Id: Ia52101f7c8d59e79583fd9658e001648ff545c66
2016-02-03 14:30:01 -08:00
David Pursell
bafd9f7e63 Merge "fastboot: add TCP protocol." am: 80dc9d8584
am: 6e2adac0c7

* commit '6e2adac0c76b6485ad7eda85f731bfb3f132658a':
  fastboot: add TCP protocol.
2016-02-03 22:07:22 +00:00
David Pursell
2ec418a4c9 fastboot: add TCP protocol.
This CL implements a TCP protocol for use with fastboot. Protocol
description is given in fastboot_protocol.txt, some examples of
expected behavior can also be found in tcp_test.cpp.

Usage is:
  fastboot -s tcp:<hostname>[:port] <command>

Bug: http://b/26558551
Change-Id: If53a514a534489c617db32c4fea8819949121282
2016-02-03 13:57:45 -08:00
David Pursell
dfc0a5d840 Merge "fastboot: fix SocketMock send failures." am: e54ea1c12d
am: 91b4e68738

* commit '91b4e687388e9e90714412d09dd521593f03ef80':
  fastboot: fix SocketMock send failures.
2016-02-03 19:00:18 +00:00
David Pursell
2c094f7983 fastboot: fix SocketMock send failures.
Fixes SocketMock::ExpectSendFailure() to allow unit testing of errors
during send, and adds tests for ExpectSendFailure() and
AddReceiveFailure().

Also adds missing tests to make sure ReceiveAll() continues to read
until failure or all bytes have been read.

Bug: http://b/26157893
Change-Id: I67e7d6de8e8ec4a3b62a6b7d7217f7530862edf7
2016-02-03 10:43:01 -08:00
David Pursell
f722c253e6 Merge "libcutils/fastboot: improve multi-buffer write." am: f6f800ef3c
am: ef0e01c346

* commit 'ef0e01c346b2f60b1941bf3335906de5996785d8':
  libcutils/fastboot: improve multi-buffer write.
2016-02-03 18:13:02 +00:00
David Pursell
b34e4a06ee libcutils/fastboot: improve multi-buffer write.
Fixes libcutils multi-buffer write interface to be more friendly and
hooks into it from the fastboot Socket class.

Bug: http://b/26558551
Change-Id: Ibb3a8428fc379755602de52722c1260f9e345bc0
2016-02-03 10:01:38 -08:00
David Pursell
4659c63114 Merge "fastboot: socket testing improvements." am: f971b6a24b
am: fe12d889e4

* commit 'fe12d889e41b688a84b4727126fde66011ca0ae6':
  fastboot: socket testing improvements.
2016-02-02 19:44:03 +00:00
David Pursell
c3a466960f fastboot: socket testing improvements.
(This code was originally part of a huge fastboot CL but has been split
out to try to make the CLs a little more manageable).

More prep for fastboot TCP and UDP implementations. This CL adds a
SocketMock class that makes it easy to mock out network behavior so we
can unit test the TCP and UDP protocols.

Also uses the new libcutils socket_get_local_port() to avoid hardcoding
a server port in unit tests.

Bug: http://b/26157893.
Change-Id: I1ba10f31e98d7349313fc15f240383d63378a8db
2016-02-02 11:29:10 -08:00
David Pursell
f6012df68d Merge "fastboot: use cutils socket functions." am: bbedd9523f
am: f0bfaf9503

* commit 'f0bfaf95038241c3f8ed65099c7d532a6c112e86':
  fastboot: use cutils socket functions.
2016-01-22 18:46:54 +00:00
David Pursell
572bce2908 fastboot: use cutils socket functions.
Now that cutils has cross-platform socket functionality, we can
restructure fastboot to remove platform-dependent networking code.

This CL adds socket_set_receive_timeout() to libcutils and combines the
fastboot socket code into a single implementation. It also adds TCP
functionality to fastboot sockets, but nothing uses it yet except for
the unit tests. A future CL will add the TCP protocol which will use
this TCP socket implementation.

Bug: http://b/26558551

Change-Id: If613fb348f9332b31fa2c88d67fb1e839923768a
2016-01-21 09:53:11 -08:00
David Pursell
cb56fb4b15 Merge "libcutils: share Windows networking code." am: 1906de1e0f
am: 7a568dbdd6

* commit '7a568dbdd6c1a39a90c01ab89092cb67a9a86198':
  libcutils: share Windows networking code.
2016-01-21 17:03:45 +00:00
David Pursell
1906de1e0f Merge "libcutils: share Windows networking code." 2016-01-21 16:40:00 +00:00
Josh Gao
08550d5cc9 Merge "fastboot: show progress when sending sparse images." am: 6a27196516
am: 69c9274c3e

* commit '69c9274c3ea023a7d3505592fab99f87144a61dd':
  fastboot: show progress when sending sparse images.
2016-01-19 23:08:28 +00:00
Josh Gao
163b83d01c Merge "fastboot: add .clang-format." am: d8ecde09c7
am: 5210031f9c

* commit '5210031f9c9873bbeca5f63af1ec22620590d2c1':
  fastboot: add .clang-format.
2016-01-19 23:06:32 +00:00
Josh Gao
9da9ac5b2a fastboot: show progress when sending sparse images.
Bug: http://b/25443220
Change-Id: Ica0c88aea2a0661f39ff1415ebba464c037651da
2016-01-19 14:50:18 -08:00
Josh Gao
cb73db7cd8 fastboot: add .clang-format.
Change-Id: Iacad00adfa3948118543d680651814b3c8c42858
2016-01-19 14:49:45 -08:00
David Pursell
0eb8e1b706 libcutils: share Windows networking code.
This CL moves Windows networking code from fastboot to libcutils so
that it can be shared with other host programs such as adb.

Not all libcutils networking functions have been implemented for
Windows, just those necessary for fastboot. In the next CL I will do
the same for adb, adding any additional required functions.

Unit tests have also been added to test the functions using a loopback
connection.

Bug: http://b/26236380.
Change-Id: Ibc51a67030fe69a04c23512eefa9d19b055c7c12
2016-01-15 15:57:35 -08:00
Daniel Rosenberg
ba3e38f9e1 Merge "fastboot: Add "--slot other"" am: 6bb8f752ec
am: abf108f6b2

* commit 'abf108f6b2cbcc4aaf7cea9719aff8b569245d60':
  fastboot: Add "--slot other"
2016-01-06 20:56:13 +00:00
Daniel Rosenberg
ed60d0706e Merge "fastboot: correct set_active behavior" am: 275d091441
am: f88b8cbe15

* commit 'f88b8cbe157b4372d4f1277e85ed25315ecd6c30':
  fastboot: correct set_active behavior
2016-01-06 19:49:25 +00:00
Daniel Rosenberg
c1743ba0d4 fastboot: Add "--slot other"
This allows you to flash to a slot other than the current one
without needing to enter the name of the slots.

Change-Id: I6bf8c29817be0a29b1abb005f1e72056cee126df
2016-01-06 19:42:01 +00:00
Daniel Rosenberg
15174d9bc7 fastboot: correct set_active behavior
Removed automatic reboot attached to set_active,
and fixed documentation error.

Change-Id: Idbb1639dc80870c17a6622dc78a7d78c88e268ab
2016-01-05 19:35:54 -08:00
David Pursell
e19a7980b8 Merge "fastboot: implement UDP networking interface." am: b6dfab03b6
am: 9526f21b56

* commit '9526f21b563c13836c75c33495b52d0f6ebc44ce':
  fastboot: implement UDP networking interface.
2015-12-17 00:42:27 +00:00
David Pursell
815c7beae7 fastboot: implement UDP networking interface.
This CL creates a UdpSocket class that provides a simple unified
interface to send and receive UDP packets for all platforms. Nothing
uses this interface yet except for tests.

The eventual goal is to implement a UDP protocol for fastboot, but it
makes the code much simpler and more modular if we handle the low-level
networking here independently of our custom fastboot protocol.

Some of the Windows code is similar to adb. I'd like to create a
library to hold the common functionality, but it is going to be a
little delicate to separate out the features unique to adb (e.g. the
custom file descriptor system), and I don't want to risk breaking
something in adb before the holiday break, so I'm hoping to get this in
for now and merge them early next year.

Tests are included in this CL to exercise this functionality using a
loopback connection.

Bug: http://b/26154763.
Tests: `fastboot_test` loopback tests on Linux, Mac, and Windows 7.
Change-Id: I81d1b7ace8d864246b99f6c80b8e29f64b8aa375
2015-12-16 16:16:08 -08:00
Elliott Hughes
2e83684537 Merge "Share the new adb USB diagnostic code with fastboot." am: efd8c3289e
am: 40f80e25d3

* commit '40f80e25d3f399ece26d5f1ac145921ccb7f5f80':
  Share the new adb USB diagnostic code with fastboot.
2015-12-14 12:47:44 -08:00
Elliott Hughes
1b708d368f Share the new adb USB diagnostic code with fastboot.
Bug: http://b/26134129
Change-Id: Ieaf0651c7b3f8a028760982091ec63a21a5484ba
2015-12-14 10:50:21 -08:00
Elliott Hughes
f65569d497 Merge "Remove fastboot/genkey.sh." am: 796ea6a65d
am: 54a584d722

* commit '54a584d72233c107f58863c659a011f65d4074fb':
  Remove fastboot/genkey.sh.
2015-12-13 13:19:26 -08:00
Elliott Hughes
44b6aefeeb Remove fastboot/genkey.sh.
Some unknown cruft from the pre-cupcake era.

Change-Id: I8964892419cda9781d1506aa7006c51dc00ca33d
2015-12-11 17:57:53 -08:00
Daniel Rosenberg
589500fe2e resolve merge conflicts of b940309ec7 to master.
Change-Id: Icd6daa7385b8cd8c19f52dbc6805142e81b93dc9
2015-12-09 17:58:00 -08:00
Daniel Rosenberg
98a8257313 Merge "fastboot: Re-add set_active as a command." 2015-12-10 00:54:01 +00:00
Elliott Hughes
ef119a14b8 Merge "Track rename of base/ to android-base/." am: 912ed3d8ca am: e2a9563be1
am: 3608ee5e90

* commit '3608ee5e903689ea7c433587be664649689816e1':
  Track rename of base/ to android-base/.
2015-12-07 23:59:44 +00:00
Daniel Rosenberg
9b432054dc fastboot: Re-add set_active as a command.
It turns out that adding a -- allows suffixes
starting with - to work fine, and there are
edge cases where calling set_active twice in
a command is useful, so the command version
has been re-added.

Change-Id: I528c258bf23ade61db530eb27586c1a1721896bc
2015-12-07 13:42:48 -08:00
Elliott Hughes
4f71319df0 Track rename of base/ to android-base/.
Change-Id: Idf9444fece4aa89c93e15640de59a91f6e758ccf
2015-12-04 22:00:26 -08:00
Paul Crowley
8f7f56e25b Add --wipe-and-use-fbe option to fastboot for FBE userdata marker.
With this option, userdata is wiped and recreated with the
"convert_fbe" file in the root, which triggers conversion to FBE.

Bug: 25898323
Change-Id: I9347b7057b6278e7e6437504896b22c82dd01d89
2015-12-03 18:02:25 +00:00
David Pursell
0b15663830 fastboot: create Transport object (take 2).
(Second upload of this CL; original upload had the wrong version of
usb_windows.cpp that caused a compilation error. Fixed error and
re-tested.)

This CL creates a Transport object to provide a generic interface for
various transports. Specifically this is designed to be able to add UDP
support to fastboot in an upcoming CL without changing the main program
logic.

Also includes some minor code style fixes and replaces malloc/free
in the USB implementation files with smart pointers and std::string.

Bug: http://b/22029765
Change-Id: I1175bbce08690fbd15f51e68166be9b3e9973ea0
2015-11-16 09:31:07 -08:00
David Pursell
44c58471e4 Merge "Revert "fastboot: create Transport object."" 2015-11-14 00:18:43 +00:00
David Pursell
c0504e1873 Revert "fastboot: create Transport object."
This broke some stuff, will look into it Monday.

This reverts commit 6f233a7799.

Change-Id: I155bc85d21fda3b0ba1e5e17839059797fb15509
2015-11-14 00:15:57 +00:00
David Pursell
f131772a79 Merge "fastboot: create Transport object." 2015-11-13 22:49:08 +00:00
Daniel Rosenberg
996ecd8b7d Fix fastboot to not add '-' before suffix
Change-Id: I9351b385412151498f47ab46a2620f21b9ac38b8
2015-11-13 12:56:19 -08:00
David Pursell
6f233a7799 fastboot: create Transport object.
This CL creates a Transport object to provide a generic interface for
various transports. Specifically this is designed to be able to add UDP
support to fastboot in an upcoming CL without changing the main program
logic.

Also includes some minor code style fixes and replaces malloc/free
in the USB implementation files with smart pointers and std::string.

Bug: http://b/22029765
Change-Id: I68641af0da7d13db4647f5e20a18d04d67f0b327
2015-11-13 11:08:17 -08:00
Daniel Rosenberg
8336a96c9c Merge changes I8fb6b513,I6dd16245,I0c2753e2
* changes:
  Update fastboot help command with long options
  Changed set_active to be a flag
  Fix fastboot variable name
2015-11-12 23:22:00 +00:00
Elliott Hughes
a2db2618ec Cope with angler's whitespace-padded partition size reporting.
Before:

  $ fastboot -w
  wiping userdata...
  Couldn't parse partition size '0x        0x66257ee00'.
  wiping cache...
  Couldn't parse partition size '0x        0x6400000'.
  erasing 'userdata'...

Bug: http://b/25653580
Change-Id: I301b8410689c1e52681796c240a149d270360edf
2015-11-12 07:28:39 -08:00
Daniel Rosenberg
7aa38bc54c Update fastboot help command with long options
Change-Id: I8fb6b5139f81893b324202d4c68f29393213ee6f
2015-11-11 20:27:56 -08:00
Daniel Rosenberg
0d08856416 Changed set_active to be a flag
set_active must be able to accept flag like arguments

Change-Id: I6dd162453835d2d64fd8d877f2a7b98e8dd8a907
2015-11-11 20:27:50 -08:00
Daniel Rosenberg
a797479bd5 Fix fastboot variable name
Change-Id: I0c2753e2b79d715f227ee314c071ce68d91779b3
2015-11-11 20:27:43 -08:00
Elliott Hughes
c1fd492ac5 Revert "Revert "adb/base: fix adb push of Unicode filenames on Win32""
This reverts commit cc8cd59456.

With the dependency on libcutils (for gettid for non-bionic) removed,
this no longer breaks the build.

Change-Id: I645bd6876e2502ddc1535b69af1e645c0df9d178
2015-11-11 18:23:00 -08:00
Elliott Hughes
cc8cd59456 Revert "adb/base: fix adb push of Unicode filenames on Win32"
This reverts commit ac9514a452.

The new gettid dependency caused other breakage.

Change-Id: I74a75e40c30a45beb275f9dd38eb5c7beac15fbd
2015-11-11 18:01:12 +00:00
Spencer Low
ac9514a452 adb/base: fix adb push of Unicode filenames on Win32
ae5a6c06cd made adb push use
android::base::ReadFileToString() for small files, but that API did not
support UTF-8 filenames on Windows, until this fix which does the
following:

- Add android::base::{WideToUTF8,UTF8ToWide}() which are only available
  on Windows. The signatures are based on Chromium's APIs of the same
  name.

- Add the namespace android::base::utf8 which has versions of APIs that
  take UTF-8 strings. To use this, make sure your code is in a namespace
  and then do "using namespace android::base::utf8;". On Windows, this will
  make calls to open() call android::base::utf8::open(), and on other
  platforms, it will just call the regular ::open().

- Make ReadFileToString() and WriteStringToFile() use utf8::open() and
  utf8::unlink().

- Adapt unittests from Chromium.

- fastboot needs to link with libcutils because it links with libbase
  which depends on libcutils for gettid() for logging.

Change-Id: I1aeac40ff358331d7a1ff457ce894bfb17863904
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2015-11-10 15:48:54 -08:00
Daniel Rosenberg
f8e70a3a60 Merge "Fastboot changes to support A/B partitioning" 2015-11-06 03:43:49 +00:00
Daniel Rosenberg
b7bd4ae529 Fastboot changes to support A/B partitioning
Introduce support for -slot option for specifying slots,
and set_active, for changing the current slot.
Change-Id: Ib3b2a75491c0d0413534dd0c1d7bcb52555bba66
2015-11-05 18:07:46 -08:00
Elliott Hughes
4ca547be67 Merge "Fix fastboot to cope with hammerhead\'s implicit hex."
am: 2b7b3bd100

* commit '2b7b3bd100747fb7a02f1d8c7c2e8a5ee6cdc82f':
  Fix fastboot to cope with hammerhead's implicit hex.
2015-11-03 16:55:42 +00:00
Elliott Hughes
2030bac88b Fix fastboot to cope with hammerhead's implicit hex.
Before:

  wiping userdata...
  Couldn't parse partition size '3321fa800'.
  wiping cache...
  Couldn't parse partition size '2bc00000'.

Groan. So much variation between bootloaders. I wish we had a reference
bootloader like ChromeOS does.

I've also removed a harmless warning:

  couldn't parse max-download-size ''

Change-Id: Ia1099d2f87000ebb96622ad9171819a1326fa249
2015-11-03 08:20:30 -08:00
Elliott Hughes
d09dc85d63 Merge "Work around an angler bootloader bug."
am: 9eab787560

* commit '9eab7875602dec9910002f080df513077f56a2dd':
  Work around an angler bootloader bug.
2015-11-03 00:07:18 +00:00
Elliott Hughes
77c0e66bef Work around an angler bootloader bug.
It's probably not the only device whose bootloader is similarly broken.
NVIDIA did a sufficiently good job with Nexus 9 that it's almost a bad
idea for me to do most of my development there...

Change-Id: I71436cc5c33023be077ca77f6dad5dbe75b11b09
2015-11-02 15:51:12 -08:00
Elliott Hughes
a2a6b0bfa9 Merge "Clarify and fix the intent of the partition-type checking code."
am: d0f45aa24c

* commit 'd0f45aa24c09c0802784263fe2dccd38e226e23a':
  Clarify and fix the intent of the partition-type checking code.
2015-11-02 23:47:39 +00:00
Elliott Hughes
8ab9a32323 Clarify and fix the intent of the partition-type checking code.
Change-Id: I202dab4ee91208b632bc2086d1e5c387a4c29edd
2015-11-02 14:05:57 -08:00
Elliott Hughes
1de89478ac Merge "Fix ParseInt/ParseUint to handle explicit "0x" hex."
am: ddf5edacc2

* commit 'ddf5edacc24125730b537265f69a081b19606246':
  Fix ParseInt/ParseUint to handle explicit "0x" hex.
2015-11-02 18:30:59 +00:00
Elliott Hughes
3ab05869d8 Fix ParseInt/ParseUint to handle explicit "0x" hex.
Also improve fastboot error reporting around max-download-size.

Change-Id: Ic3aec9460de01e5264a2803a0a6be3706d73026b
2015-11-02 09:01:53 -08:00
Elliott Hughes
5e58724b33 Merge "fastboot shouldn\'t erase non-existent cache partitions."
am: 9ebdf72a54

* commit '9ebdf72a5465b75ab4ce359e11c1ff6c2f3e376a':
  fastboot shouldn't erase non-existent cache partitions.
2015-10-30 21:42:04 +00:00
Elliott Hughes
2fd45a9cea fastboot shouldn't erase non-existent cache partitions.
Check that the cache partition exists before trying to erase it.

Also clean up some of the C string handling and int booleans.

Bug: http://b/25375777
Change-Id: I1880e542b729f2026ab3a2943d4bee9d659b1eeb
2015-10-30 14:15:22 -07:00
Elliott Hughes
259ad4a8e7 Fix the fastboot build.
load_file takes an int64_t rather than a size_t to support large files on LP32.

Change-Id: I8d3032cab63c30c4158dbc521d3d520415cdf58f
2015-09-02 20:33:44 -07:00