• R/O
  • HTTP
  • SSH
  • HTTPS

提交

標籤
無標籤

Frequently used words (click to add to your profile)

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

system/corennnnn


Commit MetaInfo

修訂f7c38b4c03d75c9cb27610acab96f4e7f4169de8 (tree)
時間2016-07-29 04:13:57
作者Felipe Leme <felipeal@goog...>
CommiterFelipe Leme

Log Message

Removed extra 'pulling file' message.

Taking a zip bugreport has 2 phases: generating the bugreport and
pulling the file.

Initially adb was printing 2 messages, but since the latter is almost
instantaneously, it could be confusing to have 2 lines...

Fixes: 30451250
Change-Id: I1c6cc6163492c1fb6064667dfdb7aaf6ed4c4c6f

Change Summary

差異

--- a/adb/bugreport.cpp
+++ b/adb/bugreport.cpp
@@ -30,7 +30,12 @@ static constexpr char BUGZ_PROGRESS_SEPARATOR[] = "/";
3030 class BugreportStandardStreamsCallback : public StandardStreamsCallbackInterface {
3131 public:
3232 BugreportStandardStreamsCallback(const std::string& dest_file, bool show_progress, Bugreport* br)
33- : br_(br), dest_file_(dest_file), show_progress_(show_progress), status_(-1), line_() {
33+ : br_(br),
34+ dest_file_(dest_file),
35+ line_message_(android::base::StringPrintf("generating %s", dest_file_.c_str())),
36+ show_progress_(show_progress),
37+ status_(-1),
38+ line_() {
3439 }
3540
3641 void OnStdout(const char* buffer, int length) {
@@ -62,12 +67,12 @@ class BugreportStandardStreamsCallback : public StandardStreamsCallbackInterface
6267 if (android::base::StartsWith(line, BUGZ_OK_PREFIX)) {
6368 if (show_progress_) {
6469 // Make sure pull message doesn't conflict with generation message.
65- br_->UpdateProgress(dest_file_, 100, 100, true);
70+ br_->UpdateProgress(line_message_, 100, 100);
6671 }
6772
6873 const char* zip_file = &line[strlen(BUGZ_OK_PREFIX)];
6974 std::vector<const char*> srcs{zip_file};
70- status_ = br_->DoSyncPull(srcs, dest_file_.c_str(), true, dest_file_.c_str()) ? 0 : 1;
75+ status_ = br_->DoSyncPull(srcs, dest_file_.c_str(), true, line_message_.c_str()) ? 0 : 1;
7176 if (status_ != 0) {
7277 fprintf(stderr, "Could not copy file '%s' to '%s'\n", zip_file, dest_file_.c_str());
7378 }
@@ -96,6 +101,7 @@ class BugreportStandardStreamsCallback : public StandardStreamsCallbackInterface
96101
97102 Bugreport* br_;
98103 const std::string dest_file_;
104+ const std::string line_message_;
99105 bool show_progress_;
100106 int status_;
101107
@@ -156,15 +162,11 @@ int Bugreport::DoIt(TransportType transport_type, const char* serial, int argc,
156162 return SendShellCommand(transport_type, serial, bugz_command, false, &bugz_callback);
157163 }
158164
159-void Bugreport::UpdateProgress(const std::string& file_name, int progress, int total,
160- bool keep_info_line) {
165+void Bugreport::UpdateProgress(const std::string& message, int progress, int total) {
161166 int progress_percentage = (progress * 100 / total);
162- line_printer_.Print(android::base::StringPrintf("[%3d%%] generating %s", progress_percentage,
163- file_name.c_str()),
164- LinePrinter::INFO);
165- if (keep_info_line) {
166- line_printer_.KeepInfoLine();
167- }
167+ line_printer_.Print(
168+ android::base::StringPrintf("[%3d%%] %s", progress_percentage, message.c_str()),
169+ LinePrinter::INFO);
168170 }
169171
170172 int Bugreport::SendShellCommand(TransportType transport_type, const char* serial,
--- a/adb/bugreport.h
+++ b/adb/bugreport.h
@@ -43,8 +43,7 @@ class Bugreport {
4343 const char* name);
4444
4545 private:
46- virtual void UpdateProgress(const std::string& file_name, int progress, int total,
47- bool keep_info_line = false);
46+ virtual void UpdateProgress(const std::string& file_name, int progress, int total);
4847 LinePrinter line_printer_;
4948 DISALLOW_COPY_AND_ASSIGN(Bugreport);
5049 };
--- a/adb/bugreport_test.cpp
+++ b/adb/bugreport_test.cpp
@@ -117,7 +117,7 @@ class BugreportMock : public Bugreport {
117117 bool disable_shell_protocol, StandardStreamsCallbackInterface* callback));
118118 MOCK_METHOD4(DoSyncPull, bool(const std::vector<const char*>& srcs, const char* dst,
119119 bool copy_attrs, const char* name));
120- MOCK_METHOD4(UpdateProgress, void(const std::string&, int, int, bool));
120+ MOCK_METHOD3(UpdateProgress, void(const std::string&, int, int));
121121 };
122122
123123 class BugreportTest : public ::testing::Test {
@@ -129,8 +129,8 @@ class BugreportTest : public ::testing::Test {
129129 WithArg<4>(ReturnCallbackDone(0))));
130130 }
131131
132- void ExpectProgress(int progress, int total, bool keep_info_line = false) {
133- EXPECT_CALL(br_, UpdateProgress(StrEq("file.zip"), progress, total, keep_info_line));
132+ void ExpectProgress(int progress, int total) {
133+ EXPECT_CALL(br_, UpdateProgress(HasSubstr("file.zip"), progress, total));
134134 }
135135
136136 BugreportMock br_;
@@ -159,7 +159,7 @@ TEST_F(BugreportTest, OkLegacy) {
159159 .WillOnce(DoAll(WithArg<4>(WriteOnStdout("OK:/device/bugreport.zip")),
160160 WithArg<4>(ReturnCallbackDone())));
161161 EXPECT_CALL(br_, DoSyncPull(ElementsAre(StrEq("/device/bugreport.zip")), StrEq("file.zip"),
162- true, StrEq("file.zip")))
162+ true, HasSubstr("file.zip")))
163163 .WillOnce(Return(true));
164164
165165 const char* args[1024] = {"bugreport", "file.zip"};
@@ -175,7 +175,7 @@ TEST_F(BugreportTest, OkLegacySplitBuffer) {
175175 WithArg<4>(WriteOnStdout("/bugreport.zip")),
176176 WithArg<4>(ReturnCallbackDone())));
177177 EXPECT_CALL(br_, DoSyncPull(ElementsAre(StrEq("/device/bugreport.zip")), StrEq("file.zip"),
178- true, StrEq("file.zip")))
178+ true, HasSubstr("file.zip")))
179179 .WillOnce(Return(true));
180180
181181 const char* args[1024] = {"bugreport", "file.zip"};
@@ -189,7 +189,7 @@ TEST_F(BugreportTest, Ok) {
189189 ExpectProgress(10, 100);
190190 ExpectProgress(50, 100);
191191 ExpectProgress(99, 100);
192- ExpectProgress(100, 100, true);
192+ ExpectProgress(100, 100);
193193 // clang-format off
194194 EXPECT_CALL(br_, SendShellCommand(kTransportLocal, "HannibalLecter", "bugreportz -p", false, _))
195195 .WillOnce(DoAll(
@@ -208,7 +208,7 @@ TEST_F(BugreportTest, Ok) {
208208 WithArg<4>(WriteOnStdout(".zip")),
209209 WithArg<4>(ReturnCallbackDone())));
210210 EXPECT_CALL(br_, DoSyncPull(ElementsAre(StrEq("/device/bugreport.zip")), StrEq("file.zip"),
211- true, StrEq("file.zip")))
211+ true, HasSubstr("file.zip")))
212212 .WillOnce(Return(true));
213213
214214 const char* args[1024] = {"bugreport", "file.zip"};
@@ -218,12 +218,12 @@ TEST_F(BugreportTest, Ok) {
218218 // Tests 'adb bugreport file' when it succeeds
219219 TEST_F(BugreportTest, OkNoExtension) {
220220 SetBugreportzVersion("1.1");
221- ExpectProgress(100, 100, true);
221+ ExpectProgress(100, 100);
222222 EXPECT_CALL(br_, SendShellCommand(kTransportLocal, "HannibalLecter", "bugreportz -p", false, _))
223223 .WillOnce(DoAll(WithArg<4>(WriteOnStdout("OK:/device/bugreport.zip\n")),
224224 WithArg<4>(ReturnCallbackDone())));
225225 EXPECT_CALL(br_, DoSyncPull(ElementsAre(StrEq("/device/bugreport.zip")), StrEq("file.zip"),
226- true, StrEq("file.zip")))
226+ true, HasSubstr("file.zip")))
227227 .WillOnce(Return(true));
228228
229229 const char* args[1024] = {"bugreport", "file"};
@@ -294,12 +294,12 @@ TEST_F(BugreportTest, BugreportzFailed) {
294294 // Tests 'adb bugreport file.zip' when the bugreport could not be pulled
295295 TEST_F(BugreportTest, PullFails) {
296296 SetBugreportzVersion("1.1");
297- ExpectProgress(100, 100, true);
297+ ExpectProgress(100, 100);
298298 EXPECT_CALL(br_, SendShellCommand(kTransportLocal, "HannibalLecter", "bugreportz -p", false, _))
299299 .WillOnce(DoAll(WithArg<4>(WriteOnStdout("OK:/device/bugreport.zip")),
300300 WithArg<4>(ReturnCallbackDone())));
301301 EXPECT_CALL(br_, DoSyncPull(ElementsAre(StrEq("/device/bugreport.zip")), StrEq("file.zip"),
302- true, StrEq("file.zip")))
302+ true, HasSubstr("file.zip")))
303303 .WillOnce(Return(false));
304304
305305 const char* args[1024] = {"bugreport", "file.zip"};