OSDN Git Service

am 37b44969: Add support for writing byte arrays to parcels
authorMarco Nelissen <marcone@google.com>
Thu, 20 Mar 2014 17:04:42 +0000 (10:04 -0700)
committerAndroid Git Automerger <android-git-automerger@android.com>
Thu, 20 Mar 2014 17:04:42 +0000 (10:04 -0700)
* commit '37b44969c0ca1d00e213da685dfbb2807f2bab30':
  Add support for writing byte arrays to parcels

cmds/dumpstate/dumpstate.c
include/gui/ISurfaceComposer.h
include/gui/SurfaceComposerClient.h
include/utils/Singleton.h
libs/binder/IPCThreadState.cpp
libs/binder/Parcel.cpp
libs/gui/SurfaceTextureClient.cpp
opengl/libagl/light.cpp
opengl/libs/EGL/egl_cache.cpp

index 3b28b22..ec529f3 100644 (file)
@@ -292,7 +292,7 @@ static void dumpstate() {
 }
 
 static void usage() {
-    fprintf(stderr, "usage: dumpstate [-b soundfile] [-e soundfile] [-o file [-d] [-p] [-z]] [-s]\n"
+    fprintf(stderr, "usage: dumpstate [-b soundfile] [-e soundfile] [-o file [-d] [-p] [-z]] [-s] [-q]\n"
             "  -o: write to file (instead of stdout)\n"
             "  -d: append date to filename (requires -o)\n"
             "  -z: gzip output (requires -o)\n"
@@ -300,12 +300,14 @@ static void usage() {
             "  -s: write output to control socket (for init)\n"
             "  -b: play sound file instead of vibrate, at beginning of job\n"
             "  -e: play sound file instead of vibrate, at end of job\n"
+            "  -q: disable vibrate\n"
                );
 }
 
 int main(int argc, char *argv[]) {
     int do_add_date = 0;
     int do_compress = 0;
+    int do_vibrate = 1;
     char* use_outfile = 0;
     char* begin_sound = 0;
     char* end_sound = 0;
@@ -328,7 +330,7 @@ int main(int argc, char *argv[]) {
     dump_traces_path = dump_traces();
 
     int c;
-    while ((c = getopt(argc, argv, "b:de:ho:svzp")) != -1) {
+    while ((c = getopt(argc, argv, "b:de:ho:svqzp")) != -1) {
         switch (c) {
             case 'b': begin_sound = optarg;  break;
             case 'd': do_add_date = 1;       break;
@@ -336,6 +338,7 @@ int main(int argc, char *argv[]) {
             case 'o': use_outfile = optarg;  break;
             case 's': use_socket = 1;        break;
             case 'v': break;  // compatibility no-op
+            case 'q': do_vibrate = 0;        break;
             case 'z': do_compress = 6;       break;
             case 'p': do_fb = 1;             break;
             case '?': printf("\n");
@@ -345,9 +348,12 @@ int main(int argc, char *argv[]) {
         }
     }
 
-    /* open the vibrator before dropping root */
-    FILE *vibrator = fopen("/sys/class/timed_output/vibrator/enable", "w");
-    if (vibrator) fcntl(fileno(vibrator), F_SETFD, FD_CLOEXEC);
+    FILE *vibrator = 0;
+    if (do_vibrate) {
+        /* open the vibrator before dropping root */
+        vibrator = fopen("/sys/class/timed_output/vibrator/enable", "w");
+        if (vibrator) fcntl(fileno(vibrator), F_SETFD, FD_CLOEXEC);
+    }
 
     /* read /proc/cmdline before dropping root */
     FILE *cmdline = fopen("/proc/cmdline", "r");
index 7320e4d..09e7771 100644 (file)
@@ -96,6 +96,10 @@ public:
         eElectronBeamAnimationOff = 0x10
     };
 
+    enum {
+        eDisplayIdMain = 0
+    };
+
     /* create connection with surface flinger, requires
      * ACCESS_SURFACE_FLINGER permission
      */
index 3bd10de..295bc02 100644 (file)
@@ -112,6 +112,14 @@ public:
     static ssize_t getDisplayHeight(DisplayID dpy);
     static ssize_t getDisplayOrientation(DisplayID dpy);
 
+    static inline sp<IBinder> getBuiltInDisplay(int32_t dpy) {
+        return NULL;
+    }
+
+    static inline status_t getDisplayInfo(const sp<IBinder>& dpy, DisplayInfo* info) {
+        return getDisplayInfo(0, info);
+    }
+
     status_t linkToComposerDeath(const sp<IBinder::DeathRecipient>& recipient,
             void* cookie = NULL, uint32_t flags = 0);
 
index a42ce21..c60680e 100644 (file)
@@ -65,9 +65,9 @@ private:
  */
 
 #define ANDROID_SINGLETON_STATIC_INSTANCE(TYPE)                 \
-    template class Singleton< TYPE >;                           \
     template<> Mutex Singleton< TYPE >::sLock(Mutex::PRIVATE);  \
-    template<> TYPE* Singleton< TYPE >::sInstance(0);
+    template<> TYPE* Singleton< TYPE >::sInstance(0);           \
+    template class Singleton< TYPE >;
 
 
 // ---------------------------------------------------------------------------
index 7a3a3b9..7e416b9 100644 (file)
@@ -758,7 +758,9 @@ finish:
 
 status_t IPCThreadState::talkWithDriver(bool doReceive)
 {
-    ALOG_ASSERT(mProcess->mDriverFD >= 0, "Binder driver is not opened");
+    if (mProcess->mDriverFD <= 0) {
+        return -EBADF;
+    }
     
     binder_write_read bwr;
     
@@ -814,6 +816,9 @@ status_t IPCThreadState::talkWithDriver(bool doReceive)
 #else
         err = INVALID_OPERATION;
 #endif
+        if (mProcess->mDriverFD <= 0) {
+            err = -EBADF;
+        }
         IF_LOG_COMMANDS() {
             alog << "Finished read/write, write size = " << mOut.dataSize() << endl;
         }
@@ -1106,7 +1111,9 @@ void IPCThreadState::threadDestructor(void *st)
        if (self) {
                self->flushCommands();
 #if defined(HAVE_ANDROID_OS)
-        ioctl(self->mProcess->mDriverFD, BINDER_THREAD_EXIT, 0);
+        if (self->mProcess->mDriverFD > 0) {
+            ioctl(self->mProcess->mDriverFD, BINDER_THREAD_EXIT, 0);
+        }
 #endif
                delete self;
        }
index 1162681..cb90b83 100644 (file)
@@ -1066,10 +1066,11 @@ int32_t Parcel::readExceptionCode() const
 {
   int32_t exception_code = readAligned<int32_t>();
   if (exception_code == EX_HAS_REPLY_HEADER) {
+    int32_t header_start = dataPosition();
     int32_t header_size = readAligned<int32_t>();
     // Skip over fat responses headers.  Not used (or propagated) in
     // native code
-    setDataPosition(dataPosition() + header_size);
+    setDataPosition(header_start + header_size);
     // And fat response headers are currently only used when there are no
     // exceptions, so return no error:
     return 0;
index 36a81a6..f60f902 100644 (file)
@@ -757,12 +757,16 @@ status_t SurfaceTextureClient::lock(
             ALOGW_IF(res, "failed locking buffer (handle = %p)",
                     backBuffer->handle);
 
-            mLockedBuffer = backBuffer;
-            outBuffer->width  = backBuffer->width;
-            outBuffer->height = backBuffer->height;
-            outBuffer->stride = backBuffer->stride;
-            outBuffer->format = backBuffer->format;
-            outBuffer->bits   = vaddr;
+            if (res != 0) {
+                err = INVALID_OPERATION;
+            } else {
+                mLockedBuffer = backBuffer;
+                outBuffer->width  = backBuffer->width;
+                outBuffer->height = backBuffer->height;
+                outBuffer->stride = backBuffer->stride;
+                outBuffer->format = backBuffer->format;
+                outBuffer->bits   = vaddr;
+            }
         }
     }
     return err;
index ca715db..fafec3f 100644 (file)
@@ -381,7 +381,14 @@ void lightVertex(ogles_context_t* c, vertex_t* v)
             // compute vertex-to-light vector
             if (ggl_unlikely(l.position.w)) {
                 // lightPos/1.0 - vertex/vertex.w == lightPos*vertex.w - vertex
+#if !OBJECT_SPACE_LIGHTING
+                vec4_t o;
+                const transform_t& mv = c->transforms.modelview.transform;
+                mv.point4(&mv, &o, &v->obj);
+                vss3(d.v, l.objPosition.v, o.w, o.v);
+#else
                 vss3(d.v, l.objPosition.v, v->obj.w, v->obj.v);
+#endif
                 sqDist = dot3(d.v, d.v);
                 vscale3(d.v, d.v, gglSqrtRecipx(sqDist));
             } else {
index c79fb5f..ed2bef3 100644 (file)
@@ -241,19 +241,11 @@ void egl_cache_t::saveBlobCacheLocked() {
         }
 
         size_t fileSize = headerSize + cacheSize;
-        if (ftruncate(fd, fileSize) == -1) {
-            ALOGE("error setting cache file size: %s (%d)", strerror(errno),
-                    errno);
-            close(fd);
-            unlink(fname);
-            return;
-        }
 
-        uint8_t* buf = reinterpret_cast<uint8_t*>(mmap(NULL, fileSize,
-                PROT_WRITE, MAP_SHARED, fd, 0));
-        if (buf == MAP_FAILED) {
-            ALOGE("error mmaping cache file: %s (%d)", strerror(errno),
-                    errno);
+        uint8_t* buf = new uint8_t [fileSize];
+        if (!buf) {
+            ALOGE("error allocating buffer for cache contents: %s (%d)",
+                    strerror(errno), errno);
             close(fd);
             unlink(fname);
             return;
@@ -264,7 +256,7 @@ void egl_cache_t::saveBlobCacheLocked() {
         if (err != OK) {
             ALOGE("error writing cache contents: %s (%d)", strerror(-err),
                     -err);
-            munmap(buf, fileSize);
+            delete [] buf;
             close(fd);
             unlink(fname);
             return;
@@ -275,7 +267,16 @@ void egl_cache_t::saveBlobCacheLocked() {
         uint32_t* crc = reinterpret_cast<uint32_t*>(buf + 4);
         *crc = crc32c(buf + headerSize, cacheSize);
 
-        munmap(buf, fileSize);
+        if (write(fd, buf, fileSize) == -1) {
+            ALOGE("error writing cache file: %s (%d)", strerror(errno),
+                    errno);
+            delete [] buf;
+            close(fd);
+            unlink(fname);
+            return;
+        }
+
+        delete [] buf;
         fchmod(fd, S_IRUSR);
         close(fd);
     }