am 14e8b01a: Don\'t change the framebuffer target until we render a new one

* commit '14e8b01a761180250671f3d6494532d8bd04fa8e':
  Don't change the framebuffer target until we render a new one
diff --git a/cmds/installd/commands.c b/cmds/installd/commands.c
index 84ad204..e9d6b15 100644
--- a/cmds/installd/commands.c
+++ b/cmds/installd/commands.c
@@ -184,7 +184,7 @@
     return delete_dir_contents(pkgdir, 0, "lib");
 }
 
-int make_user_data(const char *pkgname, uid_t uid, userid_t userid)
+int make_user_data(const char *pkgname, uid_t uid, userid_t userid, const char* seinfo)
 {
     char pkgdir[PKG_PATH_MAX];
     char applibdir[PKG_PATH_MAX];
@@ -245,7 +245,7 @@
         return -1;
     }
 
-    if (selinux_android_setfilecon(pkgdir, pkgname, uid) < 0) {
+    if (selinux_android_setfilecon2(pkgdir, pkgname, seinfo, uid) < 0) {
         ALOGE("cannot setfilecon dir '%s': %s\n", pkgdir, strerror(errno));
         unlink(libsymlink);
         unlink(pkgdir);
diff --git a/cmds/installd/installd.c b/cmds/installd/installd.c
index 1904408..a2cbccc 100644
--- a/cmds/installd/installd.c
+++ b/cmds/installd/installd.c
@@ -103,7 +103,8 @@
 
 static int do_mk_user_data(char **arg, char reply[REPLY_MAX])
 {
-    return make_user_data(arg[0], atoi(arg[1]), atoi(arg[2])); /* pkgname, uid, userid */
+    return make_user_data(arg[0], atoi(arg[1]), atoi(arg[2]), arg[3]);
+                             /* pkgname, uid, userid, seinfo */
 }
 
 static int do_rm_user(char **arg, char reply[REPLY_MAX])
@@ -142,7 +143,7 @@
     { "rmuserdata",           2, do_rm_user_data },
     { "movefiles",            0, do_movefiles },
     { "linklib",              3, do_linklib },
-    { "mkuserdata",           3, do_mk_user_data },
+    { "mkuserdata",           4, do_mk_user_data },
     { "rmuser",               1, do_rm_user },
 };
 
diff --git a/cmds/installd/installd.h b/cmds/installd/installd.h
index 635b07c..9ca2f86 100644
--- a/cmds/installd/installd.h
+++ b/cmds/installd/installd.h
@@ -194,7 +194,7 @@
 int renamepkg(const char *oldpkgname, const char *newpkgname);
 int fix_uid(const char *pkgname, uid_t uid, gid_t gid);
 int delete_user_data(const char *pkgname, userid_t userid);
-int make_user_data(const char *pkgname, uid_t uid, userid_t userid);
+int make_user_data(const char *pkgname, uid_t uid, userid_t userid, const char* seinfo);
 int delete_user(userid_t userid);
 int delete_cache(const char *pkgname, userid_t userid);
 int move_dex(const char *src, const char *dst);
diff --git a/cmds/screenshot/Android.mk b/cmds/screenshot/Android.mk
index 0afb2c5..1ee7807 100644
--- a/cmds/screenshot/Android.mk
+++ b/cmds/screenshot/Android.mk
@@ -7,6 +7,6 @@
 
 LOCAL_SHARED_LIBRARIES := libcutils libz liblog
 LOCAL_STATIC_LIBRARIES := libpng
-LOCAL_C_INCLUDES += external/zlib
+LOCAL_C_INCLUDES += external/zlib external/libpng
 
 include $(BUILD_EXECUTABLE)
diff --git a/cmds/screenshot/screenshot.c b/cmds/screenshot/screenshot.c
index cca80c3..be1ecd4 100644
--- a/cmds/screenshot/screenshot.c
+++ b/cmds/screenshot/screenshot.c
@@ -8,7 +8,7 @@
 #include <linux/fb.h>
 
 #include <zlib.h>
-#include <libpng/png.h>
+#include <png.h>
 
 #include "private/android_filesystem_config.h"
 
diff --git a/libs/gui/IGraphicBufferProducer.cpp b/libs/gui/IGraphicBufferProducer.cpp
index fc86e60..0f461e5 100644
--- a/libs/gui/IGraphicBufferProducer.cpp
+++ b/libs/gui/IGraphicBufferProducer.cpp
@@ -60,7 +60,11 @@
         bool nonNull = reply.readInt32();
         if (nonNull) {
             *buf = new GraphicBuffer();
-            reply.read(**buf);
+            result = reply.read(**buf);
+            if(result != NO_ERROR) {
+                (*buf).clear();
+                return result;
+            }
         }
         result = reply.readInt32();
         return result;
diff --git a/libs/gui/tests/SurfaceTexture_test.cpp b/libs/gui/tests/SurfaceTexture_test.cpp
index 05b0b67..e4fba15 100644
--- a/libs/gui/tests/SurfaceTexture_test.cpp
+++ b/libs/gui/tests/SurfaceTexture_test.cpp
@@ -35,7 +35,6 @@
 #include <GLES2/gl2ext.h>
 
 #include <ui/FramebufferNativeWindow.h>
-#include <utils/UniquePtr.h>
 #include <android/native_window.h>
 
 namespace android {
diff --git a/libs/ui/GraphicBuffer.cpp b/libs/ui/GraphicBuffer.cpp
index 0ecd3d9..96a7188 100644
--- a/libs/ui/GraphicBuffer.cpp
+++ b/libs/ui/GraphicBuffer.cpp
@@ -282,6 +282,8 @@
     if (handle != 0) {
         status_t err = mBufferMapper.registerBuffer(handle);
         if (err != NO_ERROR) {
+            width = height = stride = format = usage = 0;
+            handle = NULL;
             ALOGE("unflatten: registerBuffer failed: %s (%d)",
                     strerror(-err), err);
             return err;
diff --git a/opengl/tools/glgen/src/JniCodeEmitter.java b/opengl/tools/glgen/src/JniCodeEmitter.java
index d5e2d34..b1bd1fd 100644
--- a/opengl/tools/glgen/src/JniCodeEmitter.java
+++ b/opengl/tools/glgen/src/JniCodeEmitter.java
@@ -1073,6 +1073,7 @@
                 String decl = type.getDeclaration();
                 needsExit = true;
                 out.println(indent + "if (!" + cname + ") {");
+                out.println(indent + indent + "_exception = 1;");
                 out.println(indent + indent +
                             "_exceptionType = \"java/lang/IllegalArgumentException\";");
                 out.println(indent + indent +