diff options
author | Colin Cross <ccross@android.com> | 2013-10-02 20:24:46 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2013-10-02 20:24:46 +0000 |
commit | 6da66ef49b7c35cc5050a4a6b9771801640fb99b (patch) | |
tree | 7d6b64b88a5717e5c2dc425f9917dddb31304fe2 | |
parent | f3217de32cff8f82a22de84f35d782307a4ed4da (diff) | |
parent | 85373f42803f86e3295afd5031a0e42e0b3bef33 (diff) | |
download | system_core-6da66ef49b7c35cc5050a4a6b9771801640fb99b.zip system_core-6da66ef49b7c35cc5050a4a6b9771801640fb99b.tar.gz system_core-6da66ef49b7c35cc5050a4a6b9771801640fb99b.tar.bz2 |
Merge "Handle screendumps for all framebuffer sizes"
-rw-r--r-- | adb/framebuffer_service.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/adb/framebuffer_service.c b/adb/framebuffer_service.c index 20c08d2..fa7fd98 100644 --- a/adb/framebuffer_service.c +++ b/adb/framebuffer_service.c @@ -55,13 +55,13 @@ struct fbinfo { void framebuffer_service(int fd, void *cookie) { struct fbinfo fbinfo; - unsigned int i; + unsigned int i, bsize; char buf[640]; int fd_screencap; int w, h, f; int fds[2]; - if (pipe(fds) < 0) goto done; + if (pipe(fds) < 0) goto pipefail; pid_t pid = fork(); if (pid < 0) goto done; @@ -164,17 +164,19 @@ void framebuffer_service(int fd, void *cookie) if(writex(fd, &fbinfo, sizeof(fbinfo))) goto done; /* write data */ - for(i = 0; i < fbinfo.size; i += sizeof(buf)) { - if(readx(fd_screencap, buf, sizeof(buf))) goto done; - if(writex(fd, buf, sizeof(buf))) goto done; + for(i = 0; i < fbinfo.size; i += bsize) { + bsize = sizeof(buf); + if (i + bsize > fbinfo.size) + bsize = fbinfo.size - i; + if(readx(fd_screencap, buf, bsize)) goto done; + if(writex(fd, buf, bsize)) goto done; } - if(readx(fd_screencap, buf, fbinfo.size % sizeof(buf))) goto done; - if(writex(fd, buf, fbinfo.size % sizeof(buf))) goto done; done: TEMP_FAILURE_RETRY(waitpid(pid, NULL, 0)); close(fds[0]); close(fds[1]); +pipefail: close(fd); } |