Merge "Set mIsMinInfoReady and mCurrentOtasp before notifcations." into honeycomb
diff --git a/core/java/com/android/internal/widget/PointerLocationView.java b/core/java/com/android/internal/widget/PointerLocationView.java
index 12cf853..0b765fd 100644
--- a/core/java/com/android/internal/widget/PointerLocationView.java
+++ b/core/java/com/android/internal/widget/PointerLocationView.java
@@ -300,6 +300,17 @@
                     mPaint.setARGB(255, pressureLevel, 128, 255 - pressureLevel);
                     drawOval(canvas, ps.mCoords.x, ps.mCoords.y, ps.mCoords.toolMajor,
                             ps.mCoords.toolMinor, ps.mCoords.orientation, mPaint);
+
+                    // Draw the orientation arrow.
+                    mPaint.setARGB(255, pressureLevel, 255, 0);
+                    float orientationVectorX = (float) (Math.sin(-ps.mCoords.orientation)
+                            * ps.mCoords.toolMajor * 0.7);
+                    float orientationVectorY = (float) (Math.cos(-ps.mCoords.orientation)
+                            * ps.mCoords.toolMajor * 0.7);
+                    canvas.drawLine(
+                            ps.mCoords.x - orientationVectorX, ps.mCoords.y - orientationVectorY,
+                            ps.mCoords.x + orientationVectorX, ps.mCoords.y + orientationVectorY,
+                            mPaint);
                 }
             }
         }
diff --git a/core/res/res/drawable-hdpi/stat_notify_chat.png b/core/res/res/drawable-hdpi/stat_notify_chat.png
index 95b2700..71ea8de 100644
--- a/core/res/res/drawable-hdpi/stat_notify_chat.png
+++ b/core/res/res/drawable-hdpi/stat_notify_chat.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/stat_notify_email_generic.png b/core/res/res/drawable-hdpi/stat_notify_email_generic.png
index f222872..bc5fcab 100644
--- a/core/res/res/drawable-hdpi/stat_notify_email_generic.png
+++ b/core/res/res/drawable-hdpi/stat_notify_email_generic.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/stat_notify_gmail.png b/core/res/res/drawable-hdpi/stat_notify_gmail.png
index 2d5686d..ea8beae 100644
--- a/core/res/res/drawable-hdpi/stat_notify_gmail.png
+++ b/core/res/res/drawable-hdpi/stat_notify_gmail.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/stat_notify_chat.png b/core/res/res/drawable-mdpi/stat_notify_chat.png
index f199fce..306d9c5 100644
--- a/core/res/res/drawable-mdpi/stat_notify_chat.png
+++ b/core/res/res/drawable-mdpi/stat_notify_chat.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/stat_notify_email_generic.png b/core/res/res/drawable-mdpi/stat_notify_email_generic.png
index 536e8ec..1620ad53 100644
--- a/core/res/res/drawable-mdpi/stat_notify_email_generic.png
+++ b/core/res/res/drawable-mdpi/stat_notify_email_generic.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/stat_notify_gmail.png b/core/res/res/drawable-mdpi/stat_notify_gmail.png
index 89fe3cd..4860c34 100644
--- a/core/res/res/drawable-mdpi/stat_notify_gmail.png
+++ b/core/res/res/drawable-mdpi/stat_notify_gmail.png
Binary files differ
diff --git a/core/res/res/drawable-xlarge-hdpi/stat_notify_chat.png b/core/res/res/drawable-xlarge-hdpi/stat_notify_chat.png
new file mode 100644
index 0000000..e936fac
--- /dev/null
+++ b/core/res/res/drawable-xlarge-hdpi/stat_notify_chat.png
Binary files differ
diff --git a/core/res/res/drawable-xlarge-hdpi/stat_notify_disk_full.png b/core/res/res/drawable-xlarge-hdpi/stat_notify_disk_full.png
new file mode 100644
index 0000000..eb626df
--- /dev/null
+++ b/core/res/res/drawable-xlarge-hdpi/stat_notify_disk_full.png
Binary files differ
diff --git a/core/res/res/drawable-xlarge-hdpi/stat_notify_email_generic.png b/core/res/res/drawable-xlarge-hdpi/stat_notify_email_generic.png
new file mode 100644
index 0000000..d6bc7d3
--- /dev/null
+++ b/core/res/res/drawable-xlarge-hdpi/stat_notify_email_generic.png
Binary files differ
diff --git a/core/res/res/drawable-xlarge-hdpi/stat_notify_error.png b/core/res/res/drawable-xlarge-hdpi/stat_notify_error.png
new file mode 100644
index 0000000..8c8f25d
--- /dev/null
+++ b/core/res/res/drawable-xlarge-hdpi/stat_notify_error.png
Binary files differ
diff --git a/core/res/res/drawable-xlarge-hdpi/stat_notify_gmail.png b/core/res/res/drawable-xlarge-hdpi/stat_notify_gmail.png
new file mode 100644
index 0000000..661cc2f
--- /dev/null
+++ b/core/res/res/drawable-xlarge-hdpi/stat_notify_gmail.png
Binary files differ
diff --git a/core/res/res/drawable-xlarge-mdpi/stat_notify_chat.png b/core/res/res/drawable-xlarge-mdpi/stat_notify_chat.png
new file mode 100644
index 0000000..b2d7186
--- /dev/null
+++ b/core/res/res/drawable-xlarge-mdpi/stat_notify_chat.png
Binary files differ
diff --git a/core/res/res/drawable-xlarge-mdpi/stat_notify_disk_full.png b/core/res/res/drawable-xlarge-mdpi/stat_notify_disk_full.png
new file mode 100644
index 0000000..36ab1ff
--- /dev/null
+++ b/core/res/res/drawable-xlarge-mdpi/stat_notify_disk_full.png
Binary files differ
diff --git a/core/res/res/drawable-xlarge-mdpi/stat_notify_email_generic.png b/core/res/res/drawable-xlarge-mdpi/stat_notify_email_generic.png
new file mode 100644
index 0000000..a14b3c7
--- /dev/null
+++ b/core/res/res/drawable-xlarge-mdpi/stat_notify_email_generic.png
Binary files differ
diff --git a/core/res/res/drawable-xlarge-mdpi/stat_notify_error.png b/core/res/res/drawable-xlarge-mdpi/stat_notify_error.png
new file mode 100644
index 0000000..81a66c1
--- /dev/null
+++ b/core/res/res/drawable-xlarge-mdpi/stat_notify_error.png
Binary files differ
diff --git a/core/res/res/drawable-xlarge-mdpi/stat_notify_gmail.png b/core/res/res/drawable-xlarge-mdpi/stat_notify_gmail.png
new file mode 100644
index 0000000..a286ac6
--- /dev/null
+++ b/core/res/res/drawable-xlarge-mdpi/stat_notify_gmail.png
Binary files differ
diff --git a/core/res/res/layout/volume_adjust.xml b/core/res/res/layout/volume_adjust.xml
index c44ed0b..18da85f 100644
--- a/core/res/res/layout/volume_adjust.xml
+++ b/core/res/res/layout/volume_adjust.xml
@@ -14,24 +14,32 @@
      limitations under the License.
 -->
 
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
-    android:background="@android:drawable/toast_frame"
-    android:orientation="vertical"
-    android:gravity="center_horizontal">
+    android:background="@android:drawable/dialog_full_holo_dark"
+    android:gravity="left">
+
+    <LinearLayout
+        android:layout_width="416dip"
+        android:layout_height="wrap_content"
+        android:paddingLeft="16dip"
+        android:paddingTop="16dip"
+        android:paddingRight="16dip"
+        android:paddingBottom="8dip"
+        android:orientation="vertical">
 
     <LinearLayout
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
-        android:layout_marginTop="14dip"
-        android:gravity="center_vertical">
+        android:layout_marginBottom="8dip"
+        android:gravity="left">
     
         <ImageView
             android:id="@+id/other_stream_icon"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
-            android:layout_marginRight="6dip" />
+            android:layout_marginRight="16dip" />
 
         <TextView
             android:layout_width="wrap_content"
@@ -56,13 +64,9 @@
     <ProgressBar
         style="?android:attr/progressBarStyleHorizontal"
         android:id="@+id/level"
-        android:layout_width="200dip"
-        android:layout_height="wrap_content"
-        android:layout_marginTop="14dip"
-        android:layout_marginBottom="14dip"
-        android:layout_marginLeft="25dip"
-        android:layout_marginRight="25dip" />
-
-</LinearLayout>
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content" />
+    </LinearLayout>
+</FrameLayout>
 
 
diff --git a/include/surfaceflinger/Surface.h b/include/surfaceflinger/Surface.h
index 2df8ca3..5532052 100644
--- a/include/surfaceflinger/Surface.h
+++ b/include/surfaceflinger/Surface.h
@@ -233,7 +233,7 @@
      *  private stuff...
      */
     void init();
-    status_t validate() const;
+    status_t validate(bool inCancelBuffer = false) const;
     sp<ISurface> getISurface() const;
 
     inline const GraphicBufferMapper& getBufferMapper() const { return mBufferMapper; }
diff --git a/libs/hwui/DisplayListRenderer.cpp b/libs/hwui/DisplayListRenderer.cpp
index 747543f..e3593da 100644
--- a/libs/hwui/DisplayListRenderer.cpp
+++ b/libs/hwui/DisplayListRenderer.cpp
@@ -129,7 +129,7 @@
     mBitmapResources.clear();
 
     for (size_t i = 0; i < mShaders.size(); i++) {
-        delete mShaders.itemAt(i);
+        caches.resourceCache.decrementRefcount(mShaders.itemAt(i));
     }
     mShaders.clear();
 
@@ -181,7 +181,9 @@
 
     const Vector<SkiaShader*> &shaders = recorder.getShaders();
     for (size_t i = 0; i < shaders.size(); i++) {
-        mShaders.add(shaders.itemAt(i));
+        SkiaShader* shader = shaders.itemAt(i);
+        mShaders.add(shader);
+        caches.resourceCache.incrementRefcount(shader);
     }
 
     const Vector<SkPaint*> &paints = recorder.getPaints();
@@ -405,10 +407,14 @@
     }
     mBitmapResources.clear();
 
-    mPaints.clear();
-    mPaintMap.clear();
+    for (size_t i = 0; i < mShaders.size(); i++) {
+       caches.resourceCache.decrementRefcount(mShaders.itemAt(i));
+    }
     mShaders.clear();
     mShaderMap.clear();
+
+    mPaints.clear();
+    mPaintMap.clear();
     mMatrices.clear();
 }
 
diff --git a/libs/hwui/DisplayListRenderer.h b/libs/hwui/DisplayListRenderer.h
index f183473..7152334 100644
--- a/libs/hwui/DisplayListRenderer.h
+++ b/libs/hwui/DisplayListRenderer.h
@@ -417,6 +417,7 @@
             shaderCopy = shader->copy();
             mShaderMap.add(shader, shaderCopy);
             mShaders.add(shaderCopy);
+            Caches::getInstance().resourceCache.incrementRefcount(shaderCopy);
         }
 
         addInt((int) shaderCopy);
diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp
index f005573..b933232 100644
--- a/libs/hwui/OpenGLRenderer.cpp
+++ b/libs/hwui/OpenGLRenderer.cpp
@@ -697,13 +697,7 @@
     if ((mSnapshot->flags & Snapshot::kFlagFboTarget) && mSnapshot->region) {
         Rect bounds(left, top, right, bottom);
         transform.mapRect(bounds);
-        if (bounds.intersect(*mSnapshot->clipRect)) {
-            bounds.snapToPixelBoundaries();
-            android::Rect dirty(bounds.left, bounds.top, bounds.right, bounds.bottom);
-            if (!dirty.isEmpty()) {
-                mSnapshot->region->orSelf(dirty);
-            }
-        }
+        dirtyLayerUnchecked(bounds, mSnapshot->region);
     }
 #endif
 }
@@ -713,12 +707,18 @@
 #if RENDER_LAYERS_AS_REGIONS
     if ((mSnapshot->flags & Snapshot::kFlagFboTarget) && mSnapshot->region) {
         Rect bounds(left, top, right, bottom);
-        if (bounds.intersect(*mSnapshot->clipRect)) {
-            bounds.snapToPixelBoundaries();
-            android::Rect dirty(bounds.left, bounds.top, bounds.right, bounds.bottom);
-            if (!dirty.isEmpty()) {
-                mSnapshot->region->orSelf(dirty);
-            }
+        dirtyLayerUnchecked(bounds, mSnapshot->region);
+    }
+#endif
+}
+
+void OpenGLRenderer::dirtyLayerUnchecked(Rect& bounds, Region* region) {
+#if RENDER_LAYERS_AS_REGIONS
+    if (bounds.intersect(*mSnapshot->clipRect)) {
+        bounds.snapToPixelBoundaries();
+        android::Rect dirty(bounds.left, bounds.top, bounds.right, bounds.bottom);
+        if (!dirty.isEmpty()) {
+            region->orSelf(dirty);
         }
     }
 #endif
diff --git a/libs/hwui/OpenGLRenderer.h b/libs/hwui/OpenGLRenderer.h
index 8cec8f1..56be134 100644
--- a/libs/hwui/OpenGLRenderer.h
+++ b/libs/hwui/OpenGLRenderer.h
@@ -145,6 +145,8 @@
     virtual void dirtyLayer(const float left, const float top,
             const float right, const float bottom);
 
+    void dirtyLayerUnchecked(Rect& bounds, Region* region);
+
 private:
     /**
      * Saves the current state of the renderer as a new snapshot.
diff --git a/libs/hwui/ResourceCache.cpp b/libs/hwui/ResourceCache.cpp
index 00de39b..70d117a 100644
--- a/libs/hwui/ResourceCache.cpp
+++ b/libs/hwui/ResourceCache.cpp
@@ -67,12 +67,12 @@
 
 void ResourceCache::incrementRefcount(SkiaShader* shaderResource) {
     shaderResource->getSkShader()->safeRef();
-    incrementRefcount((void*)shaderResource, kShader);
+    incrementRefcount((void*) shaderResource, kShader);
 }
 
 void ResourceCache::incrementRefcount(SkiaColorFilter* filterResource) {
     filterResource->getSkColorFilter()->safeRef();
-    incrementRefcount((void*)filterResource, kColorFilter);
+    incrementRefcount((void*) filterResource, kColorFilter);
 }
 
 void ResourceCache::decrementRefcount(void* resource) {
@@ -91,17 +91,17 @@
 void ResourceCache::decrementRefcount(SkBitmap* bitmapResource) {
     bitmapResource->pixelRef()->safeUnref();
     bitmapResource->getColorTable()->safeUnref();
-    decrementRefcount((void*)bitmapResource);
+    decrementRefcount((void*) bitmapResource);
 }
 
 void ResourceCache::decrementRefcount(SkiaShader* shaderResource) {
     shaderResource->getSkShader()->safeUnref();
-    decrementRefcount((void*)shaderResource);
+    decrementRefcount((void*) shaderResource);
 }
 
 void ResourceCache::decrementRefcount(SkiaColorFilter* filterResource) {
     filterResource->getSkColorFilter()->safeUnref();
-    decrementRefcount((void*)filterResource);
+    decrementRefcount((void*) filterResource);
 }
 
 void ResourceCache::recycle(SkBitmap* resource) {
diff --git a/libs/hwui/SkiaShader.cpp b/libs/hwui/SkiaShader.cpp
index a1783df..8878c709 100644
--- a/libs/hwui/SkiaShader.cpp
+++ b/libs/hwui/SkiaShader.cpp
@@ -205,9 +205,12 @@
 SkiaShader* SkiaLinearGradientShader::copy() {
     SkiaLinearGradientShader* copy = new SkiaLinearGradientShader();
     copy->copyFrom(*this);
-    copy->mBounds = mBounds;
-    copy->mColors = mColors;
-    copy->mPositions = mPositions;
+    copy->mBounds = new float[4];
+    memcpy(copy->mBounds, mBounds, sizeof(float) * 4);
+    copy->mColors = new uint32_t[mCount];
+    memcpy(copy->mColors, mColors, sizeof(uint32_t) * mCount);
+    copy->mPositions = new float[mCount];
+    memcpy(copy->mPositions, mPositions, sizeof(float) * mCount);
     copy->mCount = mCount;
     return copy;
 }
@@ -270,8 +273,10 @@
 SkiaShader* SkiaCircularGradientShader::copy() {
     SkiaCircularGradientShader* copy = new SkiaCircularGradientShader();
     copy->copyFrom(*this);
-    copy->mColors = mColors;
-    copy->mPositions = mPositions;
+    copy->mColors = new uint32_t[mCount];
+    memcpy(copy->mColors, mColors, sizeof(uint32_t) * mCount);
+    copy->mPositions = new float[mCount];
+    memcpy(copy->mPositions, mPositions, sizeof(float) * mCount);
     copy->mCount = mCount;
     return copy;
 }
@@ -317,8 +322,10 @@
 SkiaShader* SkiaSweepGradientShader::copy() {
     SkiaSweepGradientShader* copy = new SkiaSweepGradientShader();
     copy->copyFrom(*this);
-    copy->mColors = mColors;
-    copy->mPositions = mPositions;
+    copy->mColors = new uint32_t[mCount];
+    memcpy(copy->mColors, mColors, sizeof(uint32_t) * mCount);
+    copy->mPositions = new float[mCount];
+    memcpy(copy->mPositions, mPositions, sizeof(float) * mCount);
     copy->mCount = mCount;
     return copy;
 }
@@ -362,15 +369,24 @@
 SkiaComposeShader::SkiaComposeShader(SkiaShader* first, SkiaShader* second,
         SkXfermode::Mode mode, SkShader* key):
         SkiaShader(kCompose, key, SkShader::kClamp_TileMode, SkShader::kClamp_TileMode,
-        NULL, first->blend() || second->blend()), mFirst(first), mSecond(second), mMode(mode) {
+        NULL, first->blend() || second->blend()),
+        mFirst(first), mSecond(second), mMode(mode), mCleanup(false) {
+}
+
+SkiaComposeShader::~SkiaComposeShader() {
+    if (mCleanup) {
+        delete mFirst;
+        delete mSecond;
+    }
 }
 
 SkiaShader* SkiaComposeShader::copy() {
     SkiaComposeShader* copy = new SkiaComposeShader();
     copy->copyFrom(*this);
-    copy->mFirst = mFirst;
-    copy->mSecond = mSecond;
+    copy->mFirst = mFirst->copy();
+    copy->mSecond = mSecond->copy();
     copy->mMode = mMode;
+    copy->cleanup();
     return copy;
 }
 
diff --git a/libs/hwui/SkiaShader.h b/libs/hwui/SkiaShader.h
index 1ebde38..89dd131 100644
--- a/libs/hwui/SkiaShader.h
+++ b/libs/hwui/SkiaShader.h
@@ -234,6 +234,7 @@
  */
 struct SkiaComposeShader: public SkiaShader {
     SkiaComposeShader(SkiaShader* first, SkiaShader* second, SkXfermode::Mode mode, SkShader* key);
+    ~SkiaComposeShader();
     SkiaShader* copy();
 
     void set(TextureCache* textureCache, GradientCache* gradientCache);
@@ -243,12 +244,18 @@
             GLuint* textureUnit);
 
 private:
-    SkiaComposeShader() {
+    SkiaComposeShader(): mCleanup(false) {
+    }
+
+    void cleanup() {
+        mCleanup = true;
     }
 
     SkiaShader* mFirst;
     SkiaShader* mSecond;
     SkXfermode::Mode mMode;
+
+    bool mCleanup;
 }; // struct SkiaComposeShader
 
 }; // namespace uirenderer
diff --git a/libs/surfaceflinger_client/Surface.cpp b/libs/surfaceflinger_client/Surface.cpp
index aa0c2e8..e21bab7 100644
--- a/libs/surfaceflinger_client/Surface.cpp
+++ b/libs/surfaceflinger_client/Surface.cpp
@@ -466,7 +466,7 @@
     return mInitCheck == NO_ERROR;
 }
 
-status_t Surface::validate() const
+status_t Surface::validate(bool inCancelBuffer) const
 {
     // check that we initialized ourself properly
     if (mInitCheck != NO_ERROR) {
@@ -476,15 +476,6 @@
 
     // verify the identity of this surface
     uint32_t identity = mSharedBufferClient->getIdentity();
-
-    // this is a bit of a (temporary) special case, identity==0 means that
-    // no operation are allowed from the client (eg: dequeue/queue), this
-    // is used with PUSH_BUFFER surfaces for instance
-    if (identity == 0) {
-        LOGE("[Surface] invalid operation (identity=%u)", mIdentity);
-        return INVALID_OPERATION;
-    }
-
     if (mIdentity != identity) {
         LOGE("[Surface] using an invalid surface, "
                 "identity=%u should be %d",
@@ -492,17 +483,19 @@
         CallStack stack;
         stack.update();
         stack.dump("Surface");
-        return NO_INIT;
+        return BAD_INDEX;
     }
 
     // check the surface didn't become invalid
     status_t err = mSharedBufferClient->getStatus();
     if (err != NO_ERROR) {
-        LOGE("surface (identity=%u) is invalid, err=%d (%s)",
-                mIdentity, err, strerror(-err));
-        CallStack stack;
-        stack.update();
-        stack.dump("Surface");
+        if (!inCancelBuffer) {
+            LOGE("surface (identity=%u) is invalid, err=%d (%s)",
+                    mIdentity, err, strerror(-err));
+            CallStack stack;
+            stack.update();
+            stack.dump("Surface");
+        }
         return err;
     }
 
@@ -633,12 +626,12 @@
 
 int Surface::cancelBuffer(android_native_buffer_t* buffer)
 {
-    status_t err = validate();
+    status_t err = validate(true);
     switch (err) {
     case NO_ERROR:
         // no error, common case
         break;
-    case INVALID_OPERATION:
+    case BAD_INDEX:
         // legitimate errors here
         return err;
     default:
diff --git a/media/libstagefright/NuCachedSource2.cpp b/media/libstagefright/NuCachedSource2.cpp
index cdf4270..9017921 100644
--- a/media/libstagefright/NuCachedSource2.cpp
+++ b/media/libstagefright/NuCachedSource2.cpp
@@ -319,7 +319,7 @@
 
 void NuCachedSource2::restartPrefetcherIfNecessary_l(
         bool ignoreLowWaterThreshold) {
-    static const size_t kGrayArea = 256 * 1024;
+    static const size_t kGrayArea = 1024 * 1024;
 
     if (mFetching || mFinalStatus != OK) {
         return;
@@ -414,7 +414,7 @@
 
     if (offset < mCacheOffset
             || offset >= (off64_t)(mCacheOffset + mCache->totalSize())) {
-        static const off64_t kPadding = 32768;
+        static const off64_t kPadding = 256 * 1024;
 
         // In the presence of multiple decoded streams, once of them will
         // trigger this seek request, the other one will request data "nearby"
diff --git a/packages/SystemUI/res/drawable-hdpi/ic_sysbar_ime_default.png b/packages/SystemUI/res/drawable-hdpi/ic_sysbar_ime_default.png
index 499244b..056e7e7 100644
--- a/packages/SystemUI/res/drawable-hdpi/ic_sysbar_ime_default.png
+++ b/packages/SystemUI/res/drawable-hdpi/ic_sysbar_ime_default.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_0.png b/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_0.png
index b16e436..20ea735 100644
--- a/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_0.png
+++ b/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_0.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_1.png b/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_1.png
index 1b6ed74..a5e9c7c 100644
--- a/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_1.png
+++ b/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_1.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_1_fully.png b/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_1_fully.png
index 43e35d3..0287d5a 100644
--- a/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_1_fully.png
+++ b/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_1_fully.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_2.png b/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_2.png
index 498adbb..4dfbcb2 100644
--- a/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_2.png
+++ b/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_2.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_2_fully.png b/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_2_fully.png
index b7e42a0..b9d4cb0 100644
--- a/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_2_fully.png
+++ b/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_2_fully.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_3.png b/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_3.png
index 959fc5c..4c8ec0e 100644
--- a/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_3.png
+++ b/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_3.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_3_fully.png b/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_3_fully.png
index f905979..7e30894 100644
--- a/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_3_fully.png
+++ b/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_3_fully.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_4.png b/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_4.png
index 6e8e73c..72635a5 100644
--- a/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_4.png
+++ b/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_4.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_4_fully.png b/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_4_fully.png
index b5799c8..6f56886 100644
--- a/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_4_fully.png
+++ b/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_4_fully.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_flightmode.png b/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_flightmode.png
index 7682bba..118a6b4 100644
--- a/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_flightmode.png
+++ b/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_flightmode.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/stat_sys_wifi_signal_0.png b/packages/SystemUI/res/drawable-hdpi/stat_sys_wifi_signal_0.png
index 98e874a..ecd880f 100644
--- a/packages/SystemUI/res/drawable-hdpi/stat_sys_wifi_signal_0.png
+++ b/packages/SystemUI/res/drawable-hdpi/stat_sys_wifi_signal_0.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/stat_sys_wifi_signal_1.png b/packages/SystemUI/res/drawable-hdpi/stat_sys_wifi_signal_1.png
index 1626895..7251b14 100644
--- a/packages/SystemUI/res/drawable-hdpi/stat_sys_wifi_signal_1.png
+++ b/packages/SystemUI/res/drawable-hdpi/stat_sys_wifi_signal_1.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/stat_sys_wifi_signal_1_fully.png b/packages/SystemUI/res/drawable-hdpi/stat_sys_wifi_signal_1_fully.png
index 3c2e2b9..01135c8 100644
--- a/packages/SystemUI/res/drawable-hdpi/stat_sys_wifi_signal_1_fully.png
+++ b/packages/SystemUI/res/drawable-hdpi/stat_sys_wifi_signal_1_fully.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/stat_sys_wifi_signal_2.png b/packages/SystemUI/res/drawable-hdpi/stat_sys_wifi_signal_2.png
index 77e6ee4..794d9edd 100644
--- a/packages/SystemUI/res/drawable-hdpi/stat_sys_wifi_signal_2.png
+++ b/packages/SystemUI/res/drawable-hdpi/stat_sys_wifi_signal_2.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/stat_sys_wifi_signal_2_fully.png b/packages/SystemUI/res/drawable-hdpi/stat_sys_wifi_signal_2_fully.png
index 00d86bf..851ca41 100755
--- a/packages/SystemUI/res/drawable-hdpi/stat_sys_wifi_signal_2_fully.png
+++ b/packages/SystemUI/res/drawable-hdpi/stat_sys_wifi_signal_2_fully.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/stat_sys_wifi_signal_3.png b/packages/SystemUI/res/drawable-hdpi/stat_sys_wifi_signal_3.png
index c2574e1..f16783c 100644
--- a/packages/SystemUI/res/drawable-hdpi/stat_sys_wifi_signal_3.png
+++ b/packages/SystemUI/res/drawable-hdpi/stat_sys_wifi_signal_3.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/stat_sys_wifi_signal_3_fully.png b/packages/SystemUI/res/drawable-hdpi/stat_sys_wifi_signal_3_fully.png
index 70c030b..d217d09 100755
--- a/packages/SystemUI/res/drawable-hdpi/stat_sys_wifi_signal_3_fully.png
+++ b/packages/SystemUI/res/drawable-hdpi/stat_sys_wifi_signal_3_fully.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/stat_sys_wifi_signal_4.png b/packages/SystemUI/res/drawable-hdpi/stat_sys_wifi_signal_4.png
index 55caecf..b577ebe 100644
--- a/packages/SystemUI/res/drawable-hdpi/stat_sys_wifi_signal_4.png
+++ b/packages/SystemUI/res/drawable-hdpi/stat_sys_wifi_signal_4.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/stat_sys_wifi_signal_4_fully.png b/packages/SystemUI/res/drawable-hdpi/stat_sys_wifi_signal_4_fully.png
index b5326d2..6cf4829 100755
--- a/packages/SystemUI/res/drawable-hdpi/stat_sys_wifi_signal_4_fully.png
+++ b/packages/SystemUI/res/drawable-hdpi/stat_sys_wifi_signal_4_fully.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_back_default.png b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_back_default.png
index 25fffd6..4bcd2be 100644
--- a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_back_default.png
+++ b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_back_default.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_back_ime_default.png b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_back_ime_default.png
index b6e4ebc..dadb0cd 100644
--- a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_back_ime_default.png
+++ b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_back_ime_default.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_back_ime_pressed.png b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_back_ime_pressed.png
index 189a089..51d7cc2 100644
--- a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_back_ime_pressed.png
+++ b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_back_ime_pressed.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_back_pressed.png b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_back_pressed.png
index ebade92..83a8b26 100644
--- a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_back_pressed.png
+++ b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_back_pressed.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_home_default.png b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_home_default.png
index 6ef71c7..cfeba3e 100644
--- a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_home_default.png
+++ b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_home_default.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_home_pressed.png b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_home_pressed.png
index f6b0a17..b090b95 100644
--- a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_home_pressed.png
+++ b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_home_pressed.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_ime_default.png b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_ime_default.png
index 259db7a..e1d53bd 100644
--- a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_ime_default.png
+++ b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_ime_default.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_recent_default.png b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_recent_default.png
index 246c6fe..1d97e05 100644
--- a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_recent_default.png
+++ b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_recent_default.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_recent_pressed.png b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_recent_pressed.png
index 34515c7..c9724fc 100644
--- a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_recent_pressed.png
+++ b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_recent_pressed.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_0.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_0.png
index 9216030..39025f0 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_0.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_0.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_1.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_1.png
index e529f6f..a1f7057 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_1.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_1.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_1_fully.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_1_fully.png
index e529f6f..7cc9f02 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_1_fully.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_1_fully.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_1x.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_1x.png
index 02c27ee..25ca124 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_1x.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_1x.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_2.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_2.png
index 57558ad..122a473 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_2.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_2.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_2_fully.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_2_fully.png
index 57558ad..4b126dc 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_2_fully.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_2_fully.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_3.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_3.png
index e4425b2..828c0e2 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_3.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_3.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_3_fully.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_3_fully.png
index e4425b2..f52d8f9 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_3_fully.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_3_fully.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_3g.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_3g.png
index 84ac927..2725ed2 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_3g.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_3g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_4.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_4.png
index 09de6b0..61501c1 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_4.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_4.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_4_fully.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_4_fully.png
index 09de6b0..1171ffc 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_4_fully.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_4_fully.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_edge.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_edge.png
index 13cae40..83cb820 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_edge.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_edge.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_flightmode.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_flightmode.png
index 1534da3..98c3b10 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_flightmode.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_flightmode.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_gprs.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_gprs.png
index d0a4fd0..9c3c44c 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_gprs.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_gprs.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_hsdpa.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_hsdpa.png
index 05976bd..08b975a 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_hsdpa.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_hsdpa.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_roam.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_roam.png
index 2cc3cd6..ae9dc40 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_roam.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_roam.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_wifi_signal_0.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_wifi_signal_0.png
index 1c59b2a..94c41a7 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_wifi_signal_0.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_wifi_signal_0.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_wifi_signal_1.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_wifi_signal_1.png
index 32e9165..ac32aa6 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_wifi_signal_1.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_wifi_signal_1.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_wifi_signal_1_fully.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_wifi_signal_1_fully.png
index 32e9165..9845c46 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_wifi_signal_1_fully.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_wifi_signal_1_fully.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_wifi_signal_2.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_wifi_signal_2.png
index ea71298..34494e3 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_wifi_signal_2.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_wifi_signal_2.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_wifi_signal_2_fully.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_wifi_signal_2_fully.png
index ea71298..77f4a7b 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_wifi_signal_2_fully.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_wifi_signal_2_fully.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_wifi_signal_3.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_wifi_signal_3.png
index 869a497..a635c3c 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_wifi_signal_3.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_wifi_signal_3.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_wifi_signal_3_fully.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_wifi_signal_3_fully.png
index 869a497..c3e9240 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_wifi_signal_3_fully.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_wifi_signal_3_fully.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_wifi_signal_4.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_wifi_signal_4.png
index 1711c82..68ffdc9 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_wifi_signal_4.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_wifi_signal_4.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_wifi_signal_4_fully.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_wifi_signal_4_fully.png
index 1711c82..93a3dc0 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_wifi_signal_4_fully.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_wifi_signal_4_fully.png
Binary files differ
diff --git a/services/input/InputReader.cpp b/services/input/InputReader.cpp
index f6a8859..6b66791 100644
--- a/services/input/InputReader.cpp
+++ b/services/input/InputReader.cpp
@@ -80,6 +80,10 @@
     return sqrtf(x * x + y * y);
 }
 
+inline static int32_t signExtendNybble(int32_t value) {
+    return value >= 8 ? value - 16 : value;
+}
+
 static inline const char* toString(bool value) {
     return value ? "true" : "false";
 }
@@ -1917,6 +1921,8 @@
             out.orientationCalibration = Calibration::ORIENTATION_CALIBRATION_NONE;
         } else if (orientationCalibrationString == "interpolated") {
             out.orientationCalibration = Calibration::ORIENTATION_CALIBRATION_INTERPOLATED;
+        } else if (orientationCalibrationString == "vector") {
+            out.orientationCalibration = Calibration::ORIENTATION_CALIBRATION_VECTOR;
         } else if (orientationCalibrationString != "default") {
             LOGW("Invalid value for touch.orientation.calibration: '%s'",
                     orientationCalibrationString.string());
@@ -2152,6 +2158,9 @@
     case Calibration::ORIENTATION_CALIBRATION_INTERPOLATED:
         dump.append(INDENT4 "touch.orientation.calibration: interpolated\n");
         break;
+    case Calibration::ORIENTATION_CALIBRATION_VECTOR:
+        dump.append(INDENT4 "touch.orientation.calibration: vector\n");
+        break;
     default:
         assert(false);
     }
@@ -2567,6 +2576,19 @@
             case Calibration::ORIENTATION_CALIBRATION_INTERPOLATED:
                 orientation = in.orientation * mLocked.orientationScale;
                 break;
+            case Calibration::ORIENTATION_CALIBRATION_VECTOR: {
+                int32_t c1 = signExtendNybble((in.orientation & 0xf0) >> 4);
+                int32_t c2 = signExtendNybble(in.orientation & 0x0f);
+                if (c1 != 0 || c2 != 0) {
+                    orientation = atan2f(c1, c2) * 0.5f;
+                    float minorAxisScale = (16.0f - pythag(c1, c2)) / 16.0f;
+                    toolMinor *= minorAxisScale;
+                    touchMinor *= minorAxisScale;
+                } else {
+                    orientation = 0;
+                }
+                break;
+            }
             default:
                 orientation = 0;
             }
@@ -2586,7 +2608,6 @@
             case DISPLAY_ORIENTATION_180: {
                 x = mLocked.surfaceWidth - x;
                 y = mLocked.surfaceHeight - y;
-                orientation = - orientation;
                 break;
             }
             case DISPLAY_ORIENTATION_270: {
diff --git a/services/input/InputReader.h b/services/input/InputReader.h
index 8c849c4..8b2d40a 100644
--- a/services/input/InputReader.h
+++ b/services/input/InputReader.h
@@ -680,6 +680,7 @@
             ORIENTATION_CALIBRATION_DEFAULT,
             ORIENTATION_CALIBRATION_NONE,
             ORIENTATION_CALIBRATION_INTERPOLATED,
+            ORIENTATION_CALIBRATION_VECTOR,
         };
 
         OrientationCalibration orientationCalibration;
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 77695d7..154b822 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -1109,8 +1109,12 @@
 
 status_t SurfaceFlinger::purgatorizeLayer_l(const sp<LayerBase>& layerBase)
 {
-    // remove the layer from the main list (through a transaction).
+    // First add the layer to the purgatory list, which makes sure it won't
+    // go away, then remove it from the main list (through a transaction).
     ssize_t err = removeLayer_l(layerBase);
+    if (err >= 0) {
+        mLayerPurgatory.add(layerBase);
+    }
 
     layerBase->onRemoved();
 
@@ -1359,6 +1363,19 @@
              * to use the purgatory.
              */
             status_t err = flinger->removeLayer_l(l);
+            if (err == NAME_NOT_FOUND) {
+                // The surface wasn't in the current list, which means it was
+                // removed already, which means it is in the purgatory,
+                // and need to be removed from there.
+                // This needs to happen from the main thread since its dtor
+                // must run from there (b/c of OpenGL ES). Additionally, we
+                // can't really acquire our internal lock from
+                // destroySurface() -- see postMessage() below.
+                ssize_t idx = flinger->mLayerPurgatory.remove(l);
+                LOGE_IF(idx < 0,
+                        "layer=%p is not in the purgatory list", l.get());
+            }
+
             LOGE_IF(err<0 && err != NAME_NOT_FOUND,
                     "error removing layer=%p (%s)", l.get(), strerror(-err));
             return true;
diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h
index 2591123..eabdc64 100644
--- a/services/surfaceflinger/SurfaceFlinger.h
+++ b/services/surfaceflinger/SurfaceFlinger.h
@@ -375,6 +375,7 @@
     volatile    int32_t                 mTransactionFlags;
     volatile    int32_t                 mTransactionCount;
                 Condition               mTransactionCV;
+                SortedVector< sp<LayerBase> > mLayerPurgatory;
                 bool                    mResizeTransationPending;
 
                 // protected by mStateLock (but we could use another lock)