Merge "Added null check"
diff --git a/cmds/flatland/GLHelper.cpp b/cmds/flatland/GLHelper.cpp
index 05d082b..4b5aba9 100644
--- a/cmds/flatland/GLHelper.cpp
+++ b/cmds/flatland/GLHelper.cpp
@@ -201,14 +201,16 @@
 
 bool GLHelper::createNamedSurfaceTexture(GLuint name, uint32_t w, uint32_t h,
         sp<GLConsumer>* glConsumer, EGLSurface* surface) {
-    sp<BufferQueue> bq = new BufferQueue(mGraphicBufferAlloc);
-    sp<GLConsumer> glc = new GLConsumer(bq, name,
+    sp<IGraphicBufferProducer> producer;
+    sp<IGraphicBufferConsumer> consumer;
+    BufferQueue::createBufferQueue(&producer, &consumer, mGraphicBufferAlloc);
+    sp<GLConsumer> glc = new GLConsumer(consumer, name,
             GL_TEXTURE_EXTERNAL_OES, false);
     glc->setDefaultBufferSize(w, h);
     glc->setDefaultMaxBufferCount(3);
     glc->setConsumerUsageBits(GRALLOC_USAGE_HW_COMPOSER);
 
-    sp<ANativeWindow> anw = new Surface(bq);
+    sp<ANativeWindow> anw = new Surface(producer);
     EGLSurface s = eglCreateWindowSurface(mDisplay, mConfig, anw.get(), NULL);
     if (s == EGL_NO_SURFACE) {
         fprintf(stderr, "eglCreateWindowSurface error: %#x\n", eglGetError());
diff --git a/data/etc/android.software.accessibility.xml b/data/etc/android.software.accessibility.xml
deleted file mode 100644
index 709b3f0..0000000
--- a/data/etc/android.software.accessibility.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2014 The Android Open Source Project
-
-     Licensed under the Apache License, Version 2.0 (the "License");
-     you may not use this file except in compliance with the License.
-     You may obtain a copy of the License at
-
-          http://www.apache.org/licenses/LICENSE-2.0
-
-     Unless required by applicable law or agreed to in writing, software
-     distributed under the License is distributed on an "AS IS" BASIS,
-     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-     See the License for the specific language governing permissions and
-     limitations under the License.
--->
-
-<permissions>
-    <feature name="android.software.accessibility" />
-</permissions>
diff --git a/data/etc/handheld_core_hardware.xml b/data/etc/handheld_core_hardware.xml
index 3ff8969..4d81fb6 100644
--- a/data/etc/handheld_core_hardware.xml
+++ b/data/etc/handheld_core_hardware.xml
@@ -35,7 +35,6 @@
     <feature name="android.hardware.screen.landscape" />
 
     <!-- basic system services -->
-    <feature name="android.software.accessibility" />
     <feature name="android.software.app_widgets" />
     <feature name="android.software.backup" />
     <feature name="android.software.home_screen" />
diff --git a/data/etc/tablet_core_hardware.xml b/data/etc/tablet_core_hardware.xml
index 11c5d93..2a74b0f 100644
--- a/data/etc/tablet_core_hardware.xml
+++ b/data/etc/tablet_core_hardware.xml
@@ -36,7 +36,6 @@
     <feature name="android.hardware.screen.landscape" />
 
     <!-- basic system services -->
-    <feature name="android.software.accessibility" />
     <feature name="android.software.app_widgets" />
     <feature name="android.software.backup" />
     <feature name="android.software.home_screen" />
diff --git a/data/etc/wearable_core_hardware.xml b/data/etc/wearable_core_hardware.xml
index c34b25c..215665f 100644
--- a/data/etc/wearable_core_hardware.xml
+++ b/data/etc/wearable_core_hardware.xml
@@ -33,10 +33,12 @@
     <feature name="android.hardware.screen.landscape" />
 
     <!-- basic system services -->
-    <feature name="android.software.accessibility" />
     <feature name="android.software.home_screen" />
     <feature name="android.software.input_methods" />
 
+    <!-- Feature to specify if the device supports adding device admins. -->
+    <feature name="android.software.device_admin" />
+
     <!-- devices with GPS must include android.hardware.location.gps.xml -->
     <!-- devices with an autofocus camera and/or flash must include either
          android.hardware.camera.autofocus.xml or
diff --git a/include/gui/ISurfaceComposerClient.h b/include/gui/ISurfaceComposerClient.h
index 8caa765..cb9816f 100644
--- a/include/gui/ISurfaceComposerClient.h
+++ b/include/gui/ISurfaceComposerClient.h
@@ -49,7 +49,6 @@
 
         eFXSurfaceNormal    = 0x00000000,
         eFXSurfaceDim       = 0x00020000,
-        eFXSurfaceVideoPlane= 0x00040000,
         eFXSurfaceMask      = 0x000F0000,
     };
 
diff --git a/libs/binder/Parcel.cpp b/libs/binder/Parcel.cpp
index 3f38713..4298522 100644
--- a/libs/binder/Parcel.cpp
+++ b/libs/binder/Parcel.cpp
@@ -943,7 +943,8 @@
 
 status_t Parcel::read(void* outData, size_t len) const
 {
-    if ((mDataPos+PAD_SIZE(len)) >= mDataPos && (mDataPos+PAD_SIZE(len)) <= mDataSize) {
+    if ((mDataPos+PAD_SIZE(len)) >= mDataPos && (mDataPos+PAD_SIZE(len)) <= mDataSize
+            && len <= PAD_SIZE(len)) {
         memcpy(outData, mData+mDataPos, len);
         mDataPos += PAD_SIZE(len);
         ALOGV("read Setting data pos of %p to %d\n", this, mDataPos);
@@ -954,7 +955,8 @@
 
 const void* Parcel::readInplace(size_t len) const
 {
-    if ((mDataPos+PAD_SIZE(len)) >= mDataPos && (mDataPos+PAD_SIZE(len)) <= mDataSize) {
+    if ((mDataPos+PAD_SIZE(len)) >= mDataPos && (mDataPos+PAD_SIZE(len)) <= mDataSize
+            && len <= PAD_SIZE(len)) {
         const void* data = mData+mDataPos;
         mDataPos += PAD_SIZE(len);
         ALOGV("readInplace Setting data pos of %p to %d\n", this, mDataPos);
diff --git a/services/surfaceflinger/Android.mk b/services/surfaceflinger/Android.mk
index 28de90a..49a017f 100644
--- a/services/surfaceflinger/Android.mk
+++ b/services/surfaceflinger/Android.mk
@@ -10,7 +10,6 @@
     FrameTracker.cpp \
     Layer.cpp \
     LayerDim.cpp \
-    LayerVideoPlane.cpp \
     MessageQueue.cpp \
     SurfaceFlinger.cpp \
     SurfaceFlingerConsumer.cpp \
diff --git a/services/surfaceflinger/LayerVideoPlane.cpp b/services/surfaceflinger/LayerVideoPlane.cpp
deleted file mode 100644
index 995c43a..0000000
--- a/services/surfaceflinger/LayerVideoPlane.cpp
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <stdlib.h>
-#include <stdint.h>
-#include <sys/types.h>
-
-#include <utils/Errors.h>
-#include <utils/Log.h>
-
-#include <ui/GraphicBuffer.h>
-
-#include "LayerVideoPlane.h"
-#include "SurfaceFlinger.h"
-#include "DisplayDevice.h"
-#include "RenderEngine/RenderEngine.h"
-
-#define DEBUG_BLUE_SURFACE 1
-
-namespace android {
-// ---------------------------------------------------------------------------
-
-LayerVideoPlane::LayerVideoPlane(SurfaceFlinger* flinger, const sp<Client>& client,
-        const String8& name, uint32_t w, uint32_t h, uint32_t flags)
-    : Layer(flinger, client, name, w, h, flags) {
-}
-
-LayerVideoPlane::~LayerVideoPlane() {
-}
-
-void LayerVideoPlane::onDraw(const sp<const DisplayDevice>& hw,
-        const Region& /* clip */, bool useIdentityTransform) const
-{
-#if DEBUG_BLUE_SURFACE
-    Mesh mesh(Mesh::TRIANGLE_FAN, 4, 2);
-    computeGeometry(hw, mesh, useIdentityTransform);
-    RenderEngine& engine(mFlinger->getRenderEngine());
-    engine.setupFillWithColor(0.0f, 0.0f, 1.0f, 1.0f);
-    engine.drawMesh(mesh);
-#else
-    // TODO
-#endif
-}
-
-bool LayerVideoPlane::isVisible() const {
-    const Layer::State& s(getDrawingState());
-    return !(s.flags & layer_state_t::eLayerHidden);
-}
-
-
-// ---------------------------------------------------------------------------
-
-}; // namespace android
diff --git a/services/surfaceflinger/LayerVideoPlane.h b/services/surfaceflinger/LayerVideoPlane.h
deleted file mode 100644
index a07c689..0000000
--- a/services/surfaceflinger/LayerVideoPlane.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_LAYER_VIDEO_PLANE_H
-#define ANDROID_LAYER_VIDEO_PLANE_H
-
-#include <stdint.h>
-#include <sys/types.h>
-
-#include "Layer.h"
-
-// ---------------------------------------------------------------------------
-
-namespace android {
-
-class LayerVideoPlane : public Layer
-{
-public:
-            LayerVideoPlane(SurfaceFlinger* flinger, const sp<Client>& client,
-                    const String8& name, uint32_t w, uint32_t h, uint32_t flags);
-    virtual ~LayerVideoPlane();
-
-    virtual const char* getTypeId() const { return "LayerVideoPlane"; }
-    virtual void onDraw(const sp<const DisplayDevice>& hw, const Region& clip,
-            bool useIdentityTransform) const;
-    virtual bool isFixedSize() const      { return true; }
-    virtual bool isVisible() const;
-};
-
-// ---------------------------------------------------------------------------
-
-}; // namespace android
-
-#endif // ANDROID_LAYER_VIDEO_PLANE_H
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 31d3f6f..e05417f 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -65,7 +65,6 @@
 #include "EventThread.h"
 #include "Layer.h"
 #include "LayerDim.h"
-#include "LayerVideoPlane.h"
 #include "SurfaceFlinger.h"
 
 #include "DisplayHardware/FramebufferSurface.h"
@@ -1939,11 +1938,6 @@
                     name, w, h, flags,
                     handle, gbp, &layer);
             break;
-        case ISurfaceComposerClient::eFXSurfaceVideoPlane:
-            result = createVideoPlaneLayer(client,
-                    name, w, h, flags,
-                    handle, gbp, &layer);
-            break;
         default:
             result = BAD_VALUE;
             break;
@@ -2001,16 +1995,6 @@
     return NO_ERROR;
 }
 
-status_t SurfaceFlinger::createVideoPlaneLayer(const sp<Client>& client,
-        const String8& name, uint32_t w, uint32_t h, uint32_t flags,
-        sp<IBinder>* handle, sp<IGraphicBufferProducer>* gbp, sp<Layer>* outLayer)
-{
-    *outLayer = new LayerVideoPlane(this, client, name, w, h, flags);
-    *handle = (*outLayer)->getHandle();
-    *gbp = (*outLayer)->getBufferQueue();
-    return NO_ERROR;
-}
-
 status_t SurfaceFlinger::onLayerRemoved(const sp<Client>& client, const sp<IBinder>& handle)
 {
     // called by the window manager when it wants to remove a Layer
diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h
index c473d93..9230467 100644
--- a/services/surfaceflinger/SurfaceFlinger.h
+++ b/services/surfaceflinger/SurfaceFlinger.h
@@ -280,10 +280,6 @@
             uint32_t w, uint32_t h, uint32_t flags, sp<IBinder>* outHandle,
             sp<IGraphicBufferProducer>* outGbp, sp<Layer>* outLayer);
 
-    status_t createVideoPlaneLayer(const sp<Client>& client, const String8& name,
-            uint32_t w, uint32_t h, uint32_t flags, sp<IBinder>* outHandle,
-            sp<IGraphicBufferProducer>* outGbp, sp<Layer>* outLayer);
-
     // called in response to the window-manager calling
     // ISurfaceComposerClient::destroySurface()
     status_t onLayerRemoved(const sp<Client>& client, const sp<IBinder>& handle);