Merge "SslCertificate should provide Date interface"
diff --git a/calendar/Android.mk b/calendar/Android.mk
index fd20dfa..7f9ee0a 100644
--- a/calendar/Android.mk
+++ b/calendar/Android.mk
@@ -10,7 +10,6 @@
 	../core/java/android/pim/ICalendar.java \
 	../core/java/android/pim/RecurrenceSet.java \
 	../core/java/android/pim/ContactsAsyncHelper.java \
-	../core/java/android/pim/DateException.java
 
 include $(BUILD_STATIC_JAVA_LIBRARY)
 
diff --git a/common/java/com/android/common/ui/PointerLocationView.java b/common/java/com/android/common/ui/PointerLocationView.java
deleted file mode 100644
index 7bdb0bc..0000000
--- a/common/java/com/android/common/ui/PointerLocationView.java
+++ /dev/null
@@ -1,337 +0,0 @@
-package com.android.common.ui;
-
-import android.content.Context;
-import android.graphics.Canvas;
-import android.graphics.Paint;
-import android.graphics.Paint.FontMetricsInt;
-import android.util.Log;
-import android.view.MotionEvent;
-import android.view.VelocityTracker;
-import android.view.View;
-import android.view.ViewConfiguration;
-
-import java.util.ArrayList;
-
-public class PointerLocationView extends View {
-    public static class PointerState {
-        private final ArrayList<Float> mXs = new ArrayList<Float>();
-        private final ArrayList<Float> mYs = new ArrayList<Float>();
-        private boolean mCurDown;
-        private int mCurX;
-        private int mCurY;
-        private float mCurPressure;
-        private float mCurSize;
-        private int mCurWidth;
-        private VelocityTracker mVelocity;
-    }
-
-    private final ViewConfiguration mVC;
-    private final Paint mTextPaint;
-    private final Paint mTextBackgroundPaint;
-    private final Paint mTextLevelPaint;
-    private final Paint mPaint;
-    private final Paint mTargetPaint;
-    private final Paint mPathPaint;
-    private final FontMetricsInt mTextMetrics = new FontMetricsInt();
-    private int mHeaderBottom;
-    private boolean mCurDown;
-    private int mCurNumPointers;
-    private int mMaxNumPointers;
-    private final ArrayList<PointerState> mPointers
-             = new ArrayList<PointerState>();
-    
-    private boolean mPrintCoords = true;
-    
-    public PointerLocationView(Context c) {
-        super(c);
-        mVC = ViewConfiguration.get(c);
-        mTextPaint = new Paint();
-        mTextPaint.setAntiAlias(true);
-        mTextPaint.setTextSize(10
-                * getResources().getDisplayMetrics().density);
-        mTextPaint.setARGB(255, 0, 0, 0);
-        mTextBackgroundPaint = new Paint();
-        mTextBackgroundPaint.setAntiAlias(false);
-        mTextBackgroundPaint.setARGB(128, 255, 255, 255);
-        mTextLevelPaint = new Paint();
-        mTextLevelPaint.setAntiAlias(false);
-        mTextLevelPaint.setARGB(192, 255, 0, 0);
-        mPaint = new Paint();
-        mPaint.setAntiAlias(true);
-        mPaint.setARGB(255, 255, 255, 255);
-        mPaint.setStyle(Paint.Style.STROKE);
-        mPaint.setStrokeWidth(2);
-        mTargetPaint = new Paint();
-        mTargetPaint.setAntiAlias(false);
-        mTargetPaint.setARGB(255, 0, 0, 192);
-        mPathPaint = new Paint();
-        mPathPaint.setAntiAlias(false);
-        mPathPaint.setARGB(255, 0, 96, 255);
-        mPaint.setStyle(Paint.Style.STROKE);
-        mPaint.setStrokeWidth(1);
-        
-        PointerState ps = new PointerState();
-        ps.mVelocity = VelocityTracker.obtain();
-        mPointers.add(ps);
-    }
-
-    public void setPrintCoords(boolean state) {
-        mPrintCoords = state;
-    }
-    
-    @Override
-    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
-        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
-        mTextPaint.getFontMetricsInt(mTextMetrics);
-        mHeaderBottom = -mTextMetrics.ascent+mTextMetrics.descent+2;
-        if (false) {
-            Log.i("foo", "Metrics: ascent=" + mTextMetrics.ascent
-                    + " descent=" + mTextMetrics.descent
-                    + " leading=" + mTextMetrics.leading
-                    + " top=" + mTextMetrics.top
-                    + " bottom=" + mTextMetrics.bottom);
-        }
-    }
-
-    @Override
-    protected void onDraw(Canvas canvas) {
-        synchronized (mPointers) {
-            final int w = getWidth();
-            final int itemW = w/7;
-            final int base = -mTextMetrics.ascent+1;
-            final int bottom = mHeaderBottom;
-            
-            final int NP = mPointers.size();
-            
-            if (NP > 0) {
-                final PointerState ps = mPointers.get(0);
-                canvas.drawRect(0, 0, itemW-1, bottom,mTextBackgroundPaint);
-                canvas.drawText("P: " + mCurNumPointers + " / " + mMaxNumPointers,
-                        1, base, mTextPaint);
-                
-                final int N = ps.mXs.size();
-                if ((mCurDown && ps.mCurDown) || N == 0) {
-                    canvas.drawRect(itemW, 0, (itemW * 2) - 1, bottom, mTextBackgroundPaint);
-                    canvas.drawText("X: " + ps.mCurX, 1 + itemW, base, mTextPaint);
-                    canvas.drawRect(itemW * 2, 0, (itemW * 3) - 1, bottom, mTextBackgroundPaint);
-                    canvas.drawText("Y: " + ps.mCurY, 1 + itemW * 2, base, mTextPaint);
-                } else {
-                    float dx = ps.mXs.get(N-1) - ps.mXs.get(0);
-                    float dy = ps.mYs.get(N-1) - ps.mYs.get(0);
-                    canvas.drawRect(itemW, 0, (itemW * 2) - 1, bottom,
-                            Math.abs(dx) < mVC.getScaledTouchSlop()
-                            ? mTextBackgroundPaint : mTextLevelPaint);
-                    canvas.drawText("dX: " + String.format("%.1f", dx), 1 + itemW, base, mTextPaint);
-                    canvas.drawRect(itemW * 2, 0, (itemW * 3) - 1, bottom,
-                            Math.abs(dy) < mVC.getScaledTouchSlop()
-                            ? mTextBackgroundPaint : mTextLevelPaint);
-                    canvas.drawText("dY: " + String.format("%.1f", dy), 1 + itemW * 2, base, mTextPaint);
-                }
-                
-                canvas.drawRect(itemW * 3, 0, (itemW * 4) - 1, bottom, mTextBackgroundPaint);
-                int velocity = ps.mVelocity == null ? 0 : (int) (ps.mVelocity.getXVelocity() * 1000);
-                canvas.drawText("Xv: " + velocity, 1 + itemW * 3, base, mTextPaint);
-                
-                canvas.drawRect(itemW * 4, 0, (itemW * 5) - 1, bottom, mTextBackgroundPaint);
-                velocity = ps.mVelocity == null ? 0 : (int) (ps.mVelocity.getYVelocity() * 1000);
-                canvas.drawText("Yv: " + velocity, 1 + itemW * 4, base, mTextPaint);
-                
-                canvas.drawRect(itemW * 5, 0, (itemW * 6) - 1, bottom, mTextBackgroundPaint);
-                canvas.drawRect(itemW * 5, 0, (itemW * 5) + (ps.mCurPressure * itemW) - 1,
-                        bottom, mTextLevelPaint);
-                canvas.drawText("Prs: " + String.format("%.2f", ps.mCurPressure), 1 + itemW * 5,
-                        base, mTextPaint);
-                
-                canvas.drawRect(itemW * 6, 0, w, bottom, mTextBackgroundPaint);
-                canvas.drawRect(itemW * 6, 0, (itemW * 6) + (ps.mCurSize * itemW) - 1,
-                        bottom, mTextLevelPaint);
-                canvas.drawText("Size: " + String.format("%.2f", ps.mCurSize), 1 + itemW * 6,
-                        base, mTextPaint);
-            }
-            
-            for (int p=0; p<NP; p++) {
-                final PointerState ps = mPointers.get(p);
-                
-                if (mCurDown && ps.mCurDown) {
-                    canvas.drawLine(0, (int)ps.mCurY, getWidth(), (int)ps.mCurY, mTargetPaint);
-                    canvas.drawLine((int)ps.mCurX, 0, (int)ps.mCurX, getHeight(), mTargetPaint);
-                    int pressureLevel = (int)(ps.mCurPressure*255);
-                    mPaint.setARGB(255, pressureLevel, 128, 255-pressureLevel);
-                    canvas.drawPoint(ps.mCurX, ps.mCurY, mPaint);
-                    canvas.drawCircle(ps.mCurX, ps.mCurY, ps.mCurWidth, mPaint);
-                }
-            }
-            
-            for (int p=0; p<NP; p++) {
-                final PointerState ps = mPointers.get(p);
-                
-                final int N = ps.mXs.size();
-                float lastX=0, lastY=0;
-                boolean haveLast = false;
-                boolean drawn = false;
-                mPaint.setARGB(255, 128, 255, 255);
-                for (int i=0; i<N; i++) {
-                    float x = ps.mXs.get(i);
-                    float y = ps.mYs.get(i);
-                    if (Float.isNaN(x)) {
-                        haveLast = false;
-                        continue;
-                    }
-                    if (haveLast) {
-                        canvas.drawLine(lastX, lastY, x, y, mPathPaint);
-                        canvas.drawPoint(lastX, lastY, mPaint);
-                        drawn = true;
-                    }
-                    lastX = x;
-                    lastY = y;
-                    haveLast = true;
-                }
-                
-                if (drawn) {
-                    if (ps.mVelocity != null) {
-                        mPaint.setARGB(255, 255, 64, 128);
-                        float xVel = ps.mVelocity.getXVelocity() * (1000/60);
-                        float yVel = ps.mVelocity.getYVelocity() * (1000/60);
-                        canvas.drawLine(lastX, lastY, lastX+xVel, lastY+yVel, mPaint);
-                    } else {
-                        canvas.drawPoint(lastX, lastY, mPaint);
-                    }
-                }
-            }
-        }
-    }
-
-    public void addTouchEvent(MotionEvent event) {
-        synchronized (mPointers) {
-            int action = event.getAction();
-            
-            //Log.i("Pointer", "Motion: action=0x" + Integer.toHexString(action)
-            //        + " pointers=" + event.getPointerCount());
-            
-            int NP = mPointers.size();
-            
-            //mRect.set(0, 0, getWidth(), mHeaderBottom+1);
-            //invalidate(mRect);
-            //if (mCurDown) {
-            //    mRect.set(mCurX-mCurWidth-3, mCurY-mCurWidth-3,
-            //            mCurX+mCurWidth+3, mCurY+mCurWidth+3);
-            //} else {
-            //    mRect.setEmpty();
-            //}
-            if (action == MotionEvent.ACTION_DOWN) {
-                for (int p=0; p<NP; p++) {
-                    final PointerState ps = mPointers.get(p);
-                    ps.mXs.clear();
-                    ps.mYs.clear();
-                    ps.mVelocity = VelocityTracker.obtain();
-                    ps.mCurDown = false;
-                }
-                mPointers.get(0).mCurDown = true;
-                mMaxNumPointers = 0;
-                if (mPrintCoords) {
-                    Log.i("Pointer", "Pointer 1: DOWN");
-                }
-            }
-            
-            if ((action&MotionEvent.ACTION_MASK) == MotionEvent.ACTION_POINTER_DOWN) {
-                final int index = (action&MotionEvent.ACTION_POINTER_INDEX_MASK)
-                        >> MotionEvent.ACTION_POINTER_INDEX_SHIFT;
-                final int id = event.getPointerId(index);
-                while (NP <= id) {
-                    PointerState ps = new PointerState();
-                    ps.mVelocity = VelocityTracker.obtain();
-                    mPointers.add(ps);
-                    NP++;
-                }
-                final PointerState ps = mPointers.get(id);
-                ps.mVelocity = VelocityTracker.obtain();
-                ps.mCurDown = true;
-                if (mPrintCoords) {
-                    Log.i("Pointer", "Pointer " + (id+1) + ": DOWN");
-                }
-            }
-            
-            final int NI = event.getPointerCount();
-            
-            mCurDown = action != MotionEvent.ACTION_UP
-                    && action != MotionEvent.ACTION_CANCEL;
-            mCurNumPointers = mCurDown ? NI : 0;
-            if (mMaxNumPointers < mCurNumPointers) {
-                mMaxNumPointers = mCurNumPointers;
-            }
-            
-            for (int i=0; i<NI; i++) {
-                final int id = event.getPointerId(i);
-                final PointerState ps = mPointers.get(id);
-                ps.mVelocity.addMovement(event);
-                ps.mVelocity.computeCurrentVelocity(1);
-                final int N = event.getHistorySize();
-                for (int j=0; j<N; j++) {
-                    if (mPrintCoords) {
-                        Log.i("Pointer", "Pointer " + (id+1) + ": ("
-                                + event.getHistoricalX(i, j)
-                                + ", " + event.getHistoricalY(i, j) + ")"
-                                + " Prs=" + event.getHistoricalPressure(i, j)
-                                + " Size=" + event.getHistoricalSize(i, j));
-                    }
-                    ps.mXs.add(event.getHistoricalX(i, j));
-                    ps.mYs.add(event.getHistoricalY(i, j));
-                }
-                if (mPrintCoords) {
-                    Log.i("Pointer", "Pointer " + (id+1) + ": ("
-                            + event.getX(i) + ", " + event.getY(i) + ")"
-                            + " Prs=" + event.getPressure(i)
-                            + " Size=" + event.getSize(i));
-                }
-                ps.mXs.add(event.getX(i));
-                ps.mYs.add(event.getY(i));
-                ps.mCurX = (int)event.getX(i);
-                ps.mCurY = (int)event.getY(i);
-                //Log.i("Pointer", "Pointer #" + p + ": (" + ps.mCurX
-                //        + "," + ps.mCurY + ")");
-                ps.mCurPressure = event.getPressure(i);
-                ps.mCurSize = event.getSize(i);
-                ps.mCurWidth = (int)(ps.mCurSize*(getWidth()/3));
-            }
-            
-            if ((action&MotionEvent.ACTION_MASK) == MotionEvent.ACTION_POINTER_UP) {
-                final int index = (action&MotionEvent.ACTION_POINTER_INDEX_MASK)
-                        >> MotionEvent.ACTION_POINTER_INDEX_SHIFT;
-                final int id = event.getPointerId(index);
-                final PointerState ps = mPointers.get(id);
-                ps.mXs.add(Float.NaN);
-                ps.mYs.add(Float.NaN);
-                ps.mCurDown = false;
-                if (mPrintCoords) {
-                    Log.i("Pointer", "Pointer " + (id+1) + ": UP");
-                }
-            }
-            
-            if (action == MotionEvent.ACTION_UP) {
-                for (int i=0; i<NI; i++) {
-                    final int id = event.getPointerId(i);
-                    final PointerState ps = mPointers.get(id);
-                    if (ps.mCurDown) {
-                        ps.mCurDown = false;
-                        if (mPrintCoords) {
-                            Log.i("Pointer", "Pointer " + (id+1) + ": UP");
-                        }
-                    }
-                }
-            }
-            
-            //if (mCurDown) {
-            //    mRect.union(mCurX-mCurWidth-3, mCurY-mCurWidth-3,
-            //            mCurX+mCurWidth+3, mCurY+mCurWidth+3);
-            //}
-            //invalidate(mRect);
-            postInvalidate();
-        }
-    }
-    
-    @Override
-    public boolean onTouchEvent(MotionEvent event) {
-        addTouchEvent(event);
-        return true;
-    }
-}
diff --git a/common/tests/Android.mk b/common/tests/Android.mk
index 0f2c3e4..7425552 100644
--- a/common/tests/Android.mk
+++ b/common/tests/Android.mk
@@ -23,4 +23,6 @@
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 LOCAL_STATIC_JAVA_LIBRARIES := android-common
 
+LOCAL_PROGUARD_ENABLED := disabled
+
 include $(BUILD_PACKAGE)
diff --git a/include/surfaceflinger/ISurfaceFlingerClient.h b/include/surfaceflinger/ISurfaceFlingerClient.h
index 1fba162..d257645 100644
--- a/include/surfaceflinger/ISurfaceFlingerClient.h
+++ b/include/surfaceflinger/ISurfaceFlingerClient.h
@@ -61,6 +61,7 @@
 
     virtual sp<ISurface> createSurface( surface_data_t* data,
                                         int pid, 
+                                        const String8& name,
                                         DisplayID display,
                                         uint32_t w,
                                         uint32_t h,
diff --git a/include/surfaceflinger/SurfaceComposerClient.h b/include/surfaceflinger/SurfaceComposerClient.h
index 49e83c0..9d0f0cb 100644
--- a/include/surfaceflinger/SurfaceComposerClient.h
+++ b/include/surfaceflinger/SurfaceComposerClient.h
@@ -65,6 +65,7 @@
     //! Create a surface
     sp<SurfaceControl> createSurface(
             int pid,            // pid of the process the surface is for
+            const String8& name,// name of the surface
             DisplayID display,  // Display to create this surface on
             uint32_t w,         // width in pixel
             uint32_t h,         // height in pixel
@@ -72,6 +73,16 @@
             uint32_t flags = 0  // usage flags
     );
 
+    sp<SurfaceControl> createSurface(
+            int pid,            // pid of the process the surface is for
+            DisplayID display,  // Display to create this surface on
+            uint32_t w,         // width in pixel
+            uint32_t h,         // height in pixel
+            PixelFormat format, // pixel-format desired
+            uint32_t flags = 0  // usage flags
+    );
+
+
     // ------------------------------------------------------------------------
     // Composer parameters
     // All composer parameters must be changed within a transaction
diff --git a/include/utils/ResourceTypes.h b/include/utils/ResourceTypes.h
index cd657e8..cbcef4e 100644
--- a/include/utils/ResourceTypes.h
+++ b/include/utils/ResourceTypes.h
@@ -944,8 +944,9 @@
     enum {
         // uiMode bits for the mode type.
         MASK_UI_MODE_TYPE = 0x0f,
-        UI_MODE_TYPE_NORMAL = 0x00,
-        UI_MODE_TYPE_CAR = 0x01,
+        UI_MODE_TYPE_ANY = 0x00,
+        UI_MODE_TYPE_NORMAL = 0x01,
+        UI_MODE_TYPE_CAR = 0x02,
 
         // uiMode bits for the night switch.
         MASK_UI_MODE_NIGHT = 0x30,
@@ -1086,7 +1087,7 @@
             }
         }
 
-        if (screenConfig || o.screenConfig) {
+        if (screenLayout || o.screenLayout) {
             if (((screenLayout^o.screenLayout) & MASK_SCREENSIZE) != 0) {
                 if (!(screenLayout & MASK_SCREENSIZE)) return false;
                 if (!(o.screenLayout & MASK_SCREENSIZE)) return true;
@@ -1102,7 +1103,7 @@
             if (!o.orientation) return true;
         }
 
-        if (screenConfig || o.screenConfig) {
+        if (uiMode || o.uiMode) {
             if (((uiMode^o.uiMode) & MASK_UI_MODE_TYPE) != 0) {
                 if (!(uiMode & MASK_UI_MODE_TYPE)) return false;
                 if (!(o.uiMode & MASK_UI_MODE_TYPE)) return true;
@@ -1203,7 +1204,7 @@
                 }
             }
 
-            if (screenConfig || o.screenConfig) {
+            if (screenLayout || o.screenLayout) {
                 if (((screenLayout^o.screenLayout) & MASK_SCREENSIZE) != 0
                         && (requested->screenLayout & MASK_SCREENSIZE)) {
                     return (screenLayout & MASK_SCREENSIZE);
@@ -1218,7 +1219,7 @@
                 return (orientation);
             }
 
-            if (screenConfig || o.screenConfig) {
+            if (uiMode || o.uiMode) {
                 if (((uiMode^o.uiMode) & MASK_UI_MODE_TYPE) != 0
                         && (requested->uiMode & MASK_UI_MODE_TYPE)) {
                     return (uiMode & MASK_UI_MODE_TYPE);
diff --git a/libs/audioflinger/AudioDumpInterface.cpp b/libs/audioflinger/AudioDumpInterface.cpp
index 30e2bc9..a018b4c 100644
--- a/libs/audioflinger/AudioDumpInterface.cpp
+++ b/libs/audioflinger/AudioDumpInterface.cpp
@@ -509,6 +509,12 @@
     return param.toString();
 }
 
+unsigned int AudioStreamInDump::getInputFramesLost() const
+{
+    if (mFinalStream != 0 ) return mFinalStream->getInputFramesLost();
+    return 0;
+}
+
 status_t AudioStreamInDump::dump(int fd, const Vector<String16>& args)
 {
     if (mFinalStream != 0 ) return mFinalStream->dump(fd, args);
diff --git a/libs/audioflinger/AudioDumpInterface.h b/libs/audioflinger/AudioDumpInterface.h
index 5b9a6b1..4c62b3e 100644
--- a/libs/audioflinger/AudioDumpInterface.h
+++ b/libs/audioflinger/AudioDumpInterface.h
@@ -94,6 +94,7 @@
     virtual status_t    standby();
     virtual status_t    setParameters(const String8& keyValuePairs);
     virtual String8     getParameters(const String8& keys);
+    virtual unsigned int  getInputFramesLost() const;
     virtual status_t    dump(int fd, const Vector<String16>& args);
     void                Close(void);
     AudioStreamIn*     finalStream() { return mFinalStream; }
diff --git a/libs/audioflinger/AudioFlinger.cpp b/libs/audioflinger/AudioFlinger.cpp
index 9d52882..2269352 100644
--- a/libs/audioflinger/AudioFlinger.cpp
+++ b/libs/audioflinger/AudioFlinger.cpp
@@ -618,6 +618,21 @@
     return mAudioHardware->getInputBufferSize(sampleRate, format, channelCount);
 }
 
+unsigned int AudioFlinger::getInputFramesLost(int ioHandle)
+{
+    if (ioHandle == 0) {
+        return 0;
+    }
+
+    Mutex::Autolock _l(mLock);
+
+    RecordThread *recordThread = checkRecordThread_l(ioHandle);
+    if (recordThread != NULL) {
+        return recordThread->getInputFramesLost();
+    }
+    return 0;
+}
+
 status_t AudioFlinger::setVoiceVolume(float value)
 {
     // check calling permissions
@@ -3575,6 +3590,11 @@
     mRsmpInIndex = mFrameCount;
 }
 
+unsigned int AudioFlinger::RecordThread::getInputFramesLost()
+{
+    return mInput->getInputFramesLost();
+}
+
 // ----------------------------------------------------------------------------
 
 int AudioFlinger::openOutput(uint32_t *pDevices,
diff --git a/libs/audioflinger/AudioFlinger.h b/libs/audioflinger/AudioFlinger.h
index 44da9ed..739ec33 100644
--- a/libs/audioflinger/AudioFlinger.h
+++ b/libs/audioflinger/AudioFlinger.h
@@ -108,6 +108,7 @@
     virtual     void        registerClient(const sp<IAudioFlingerClient>& client);
 
     virtual     size_t      getInputBufferSize(uint32_t sampleRate, int format, int channelCount);
+    virtual     unsigned int  getInputFramesLost(int ioHandle);
 
     virtual int openOutput(uint32_t *pDevices,
                                     uint32_t *pSamplingRate,
@@ -745,6 +746,7 @@
         virtual String8     getParameters(const String8& keys);
         virtual void        audioConfigChanged(int event, int param = 0);
                 void        readInputParameters();
+        virtual unsigned int  getInputFramesLost();
 
     private:
                 RecordThread();
diff --git a/libs/audioflinger/AudioHardwareGeneric.h b/libs/audioflinger/AudioHardwareGeneric.h
index 95c7ea3..aa4e78d 100644
--- a/libs/audioflinger/AudioHardwareGeneric.h
+++ b/libs/audioflinger/AudioHardwareGeneric.h
@@ -88,6 +88,7 @@
     virtual status_t    standby() { return NO_ERROR; }
     virtual status_t    setParameters(const String8& keyValuePairs);
     virtual String8     getParameters(const String8& keys);
+    virtual unsigned int  getInputFramesLost() const { return 0; }
 
 private:
     AudioHardwareGeneric *mAudioHardware;
diff --git a/libs/audioflinger/AudioHardwareStub.h b/libs/audioflinger/AudioHardwareStub.h
index 769ae3f..06a29de 100644
--- a/libs/audioflinger/AudioHardwareStub.h
+++ b/libs/audioflinger/AudioHardwareStub.h
@@ -57,6 +57,7 @@
     virtual status_t    standby() { return NO_ERROR; }
     virtual status_t    setParameters(const String8& keyValuePairs) { return NO_ERROR;}
     virtual String8     getParameters(const String8& keys);
+    virtual unsigned int  getInputFramesLost() const { return 0; }
 };
 
 class AudioHardwareStub : public  AudioHardwareBase
diff --git a/libs/surfaceflinger/LayerBase.cpp b/libs/surfaceflinger/LayerBase.cpp
index a3d293f..b0109ca 100644
--- a/libs/surfaceflinger/LayerBase.cpp
+++ b/libs/surfaceflinger/LayerBase.cpp
@@ -728,6 +728,14 @@
     delete lcblk;
 }
 
+void LayerBaseClient::setName(const String8& name) {
+    mName = name;
+}
+
+String8 LayerBaseClient::getName() const {
+    return mName;
+}
+
 int32_t LayerBaseClient::serverIndex() const 
 {
     sp<Client> client(this->client.promote());
diff --git a/libs/surfaceflinger/LayerBase.h b/libs/surfaceflinger/LayerBase.h
index 6aacd82..7ac8bc5 100644
--- a/libs/surfaceflinger/LayerBase.h
+++ b/libs/surfaceflinger/LayerBase.h
@@ -320,6 +320,8 @@
             const sp<Client>& client, int32_t i);
     virtual ~LayerBaseClient();
     virtual void onFirstRef();
+    void setName(const String8& name);
+    String8 getName() const;
 
     const wp<Client>    client;
 
@@ -333,6 +335,7 @@
     
     virtual void onRemoved();
 
+
     class Surface : public BnSurface 
     {
     public:
@@ -371,6 +374,7 @@
     mutable     Mutex           mLock;
     mutable     wp<Surface>     mClientSurface;
     // only read
+                String8         mName;
     const       uint32_t        mIdentity;
     static      int32_t         sIdentity;
 };
diff --git a/libs/surfaceflinger/SurfaceFlinger.cpp b/libs/surfaceflinger/SurfaceFlinger.cpp
index 4555b3c..2598440 100644
--- a/libs/surfaceflinger/SurfaceFlinger.cpp
+++ b/libs/surfaceflinger/SurfaceFlinger.cpp
@@ -625,12 +625,13 @@
 
             mVisibleRegionsDirty = true;
             mDirtyRegion.set(hw.bounds());
-            mFreezeDisplayTime = 0;
         }
 
         if (mCurrentState.freezeDisplay != mDrawingState.freezeDisplay) {
             // freezing or unfreezing the display -> trigger animation if needed
             mFreezeDisplay = mCurrentState.freezeDisplay;
+            if (mFreezeDisplay)
+                 mFreezeDisplayTime = 0;
         }
 
         if (currentLayers.size() > mDrawingState.layersSortedByZ.size()) {
@@ -1186,7 +1187,7 @@
 }
 
 sp<ISurface> SurfaceFlinger::createSurface(ClientID clientId, int pid,
-        ISurfaceFlingerClient::surface_data_t* params,
+        const String8& name, ISurfaceFlingerClient::surface_data_t* params,
         DisplayID d, uint32_t w, uint32_t h, PixelFormat format,
         uint32_t flags)
 {
@@ -1232,6 +1233,7 @@
     }
 
     if (layer != 0) {
+        layer->setName(name);
         setTransactionFlags(eTransactionNeeded);
         surfaceHandle = layer->getSurface();
         if (surfaceHandle != 0) { 
@@ -1506,8 +1508,10 @@
             if (lbc != 0) {
                 sp<Client> client(lbc->client.promote());
                 snprintf(buffer, SIZE,
-                        "      "
-                        "id=0x%08x, client=0x%08x, identity=%u\n",
+                        "      name=%s\n", lbc->getName().string());
+                result.append(buffer);
+                snprintf(buffer, SIZE,
+                        "      id=0x%08x, client=0x%08x, identity=%u\n",
                         lbc->clientIndex(), client.get() ? client->cid : 0,
                         lbc->getIdentity());
 
@@ -1760,10 +1764,12 @@
 
 sp<ISurface> BClient::createSurface(
         ISurfaceFlingerClient::surface_data_t* params, int pid,
+        const String8& name,
         DisplayID display, uint32_t w, uint32_t h, PixelFormat format,
         uint32_t flags)
 {
-    return mFlinger->createSurface(mId, pid, params, display, w, h, format, flags);
+    return mFlinger->createSurface(mId, pid, name, params, display, w, h,
+            format, flags);
 }
 
 status_t BClient::destroySurface(SurfaceID sid)
diff --git a/libs/surfaceflinger/SurfaceFlinger.h b/libs/surfaceflinger/SurfaceFlinger.h
index 4520c0e..d75dc15 100644
--- a/libs/surfaceflinger/SurfaceFlinger.h
+++ b/libs/surfaceflinger/SurfaceFlinger.h
@@ -189,7 +189,7 @@
     friend class LayerBlur;
     friend class LayerDim;
 
-    sp<ISurface> createSurface(ClientID client, int pid, 
+    sp<ISurface> createSurface(ClientID client, int pid, const String8& name,
             ISurfaceFlingerClient::surface_data_t* params,
             DisplayID display, uint32_t w, uint32_t h, PixelFormat format,
             uint32_t flags);
@@ -401,7 +401,7 @@
     virtual sp<IMemoryHeap> getControlBlock() const;
 
     virtual sp<ISurface> createSurface(
-            surface_data_t* params, int pid,
+            surface_data_t* params, int pid, const String8& name,
             DisplayID display, uint32_t w, uint32_t h,PixelFormat format,
             uint32_t flags);
 
diff --git a/libs/surfaceflinger_client/ISurfaceFlingerClient.cpp b/libs/surfaceflinger_client/ISurfaceFlingerClient.cpp
index e636c52..def96d7 100644
--- a/libs/surfaceflinger_client/ISurfaceFlingerClient.cpp
+++ b/libs/surfaceflinger_client/ISurfaceFlingerClient.cpp
@@ -74,6 +74,7 @@
 
     virtual sp<ISurface> createSurface( surface_data_t* params,
                                         int pid,
+                                        const String8& name,
                                         DisplayID display,
                                         uint32_t w,
                                         uint32_t h,
@@ -83,6 +84,7 @@
         Parcel data, reply;
         data.writeInterfaceToken(ISurfaceFlingerClient::getInterfaceDescriptor());
         data.writeInt32(pid);
+        data.writeString8(name);
         data.writeInt32(display);
         data.writeInt32(w);
         data.writeInt32(h);
@@ -154,12 +156,14 @@
             CHECK_INTERFACE(ISurfaceFlingerClient, data, reply);
             surface_data_t params;
             int32_t pid = data.readInt32();
+            String8 name = data.readString8();
             DisplayID display = data.readInt32();
             uint32_t w = data.readInt32();
             uint32_t h = data.readInt32();
             PixelFormat format = data.readInt32();
             uint32_t flags = data.readInt32();
-            sp<ISurface> s = createSurface(&params, pid, display, w, h, format, flags);
+            sp<ISurface> s = createSurface(&params, pid, name, display, w, h,
+                    format, flags);
             params.writeToParcel(reply);
             reply->writeStrongBinder(s->asBinder());
             return NO_ERROR;
diff --git a/libs/surfaceflinger_client/SurfaceComposerClient.cpp b/libs/surfaceflinger_client/SurfaceComposerClient.cpp
index 0b5e504..3117495 100644
--- a/libs/surfaceflinger_client/SurfaceComposerClient.cpp
+++ b/libs/surfaceflinger_client/SurfaceComposerClient.cpp
@@ -319,10 +319,30 @@
         PixelFormat format,
         uint32_t flags)
 {
+    String8 name;
+    const size_t SIZE = 128;
+    char buffer[SIZE];
+    snprintf(buffer, SIZE, "<pid_%d>", getpid());
+    name.append(buffer);
+
+    return SurfaceComposerClient::createSurface(pid, name, display,
+            w, h, format, flags);
+
+}
+
+sp<SurfaceControl> SurfaceComposerClient::createSurface(
+        int pid,
+        const String8& name,
+        DisplayID display,
+        uint32_t w,
+        uint32_t h,
+        PixelFormat format,
+        uint32_t flags)
+{
     sp<SurfaceControl> result;
     if (mStatus == NO_ERROR) {
         ISurfaceFlingerClient::surface_data_t data;
-        sp<ISurface> surface = mClient->createSurface(&data, pid,
+        sp<ISurface> surface = mClient->createSurface(&data, pid, name,
                 display, w, h, format, flags);
         if (surface != 0) {
             if (uint32_t(data.token) < NUM_LAYERS_MAX) {
diff --git a/libs/utils/ResourceTypes.cpp b/libs/utils/ResourceTypes.cpp
index 5f89788..6da11b5 100644
--- a/libs/utils/ResourceTypes.cpp
+++ b/libs/utils/ResourceTypes.cpp
@@ -4149,22 +4149,165 @@
                     } else {
                         sprintf(density, "%d", (int)dval);
                     }
-                    printf("      config %d lang=%c%c cnt=%c%c orien=%d touch=%d density=%s key=%d infl=%d nav=%d w=%d h=%d sz=%d lng=%d\n",
-                           (int)configIndex,
-                           type->config.language[0] ? type->config.language[0] : '-',
-                           type->config.language[1] ? type->config.language[1] : '-',
-                           type->config.country[0] ? type->config.country[0] : '-',
-                           type->config.country[1] ? type->config.country[1] : '-',
-                           type->config.orientation,
-                           type->config.touchscreen,
-                           density,
-                           type->config.keyboard,
-                           type->config.inputFlags,
-                           type->config.navigation,
-                           dtohs(type->config.screenWidth),
-                           dtohs(type->config.screenHeight),
-                           type->config.screenLayout&ResTable_config::MASK_SCREENSIZE,
-                           type->config.screenLayout&ResTable_config::MASK_SCREENLONG);
+                    printf("      config %d", (int)configIndex);
+                    if (type->config.mcc != 0) {
+                        printf(" mcc=%d", dtohs(type->config.mcc));
+                    }
+                    if (type->config.mnc != 0) {
+                        printf(" mnc=%d", dtohs(type->config.mnc));
+                    }
+                    if (type->config.locale != 0) {
+                        printf(" lang=%c%c cnt=%c%c",
+                               type->config.language[0] ? type->config.language[0] : '-',
+                               type->config.language[1] ? type->config.language[1] : '-',
+                               type->config.country[0] ? type->config.country[0] : '-',
+                               type->config.country[1] ? type->config.country[1] : '-');
+                    }
+                    if (type->config.screenLayout != 0) {
+                        printf(" sz=%d",
+                                type->config.screenLayout&ResTable_config::MASK_SCREENSIZE);
+                        switch (type->config.screenLayout&ResTable_config::MASK_SCREENSIZE) {
+                            case ResTable_config::SCREENSIZE_SMALL:
+                                printf(" (small)");
+                                break;
+                            case ResTable_config::SCREENSIZE_NORMAL:
+                                printf(" (normal)");
+                                break;
+                            case ResTable_config::SCREENSIZE_LARGE:
+                                printf(" (large)");
+                                break;
+                        }
+                        printf(" lng=%d",
+                                type->config.screenLayout&ResTable_config::MASK_SCREENLONG);
+                        switch (type->config.screenLayout&ResTable_config::MASK_SCREENLONG) {
+                            case ResTable_config::SCREENLONG_NO:
+                                printf(" (notlong)");
+                                break;
+                            case ResTable_config::SCREENLONG_YES:
+                                printf(" (long)");
+                                break;
+                        }
+                    }
+                    if (type->config.orientation != 0) {
+                        printf(" orient=%d", type->config.orientation);
+                        switch (type->config.orientation) {
+                            case ResTable_config::ORIENTATION_PORT:
+                                printf(" (port)");
+                                break;
+                            case ResTable_config::ORIENTATION_LAND:
+                                printf(" (land)");
+                                break;
+                            case ResTable_config::ORIENTATION_SQUARE:
+                                printf(" (square)");
+                                break;
+                        }
+                    }
+                    if (type->config.uiMode != 0) {
+                        printf(" type=%d",
+                                type->config.uiMode&ResTable_config::MASK_UI_MODE_TYPE);
+                        switch (type->config.uiMode&ResTable_config::MASK_UI_MODE_TYPE) {
+                            case ResTable_config::UI_MODE_TYPE_NORMAL:
+                                printf(" (normal)");
+                                break;
+                            case ResTable_config::UI_MODE_TYPE_CAR:
+                                printf(" (car)");
+                                break;
+                        }
+                        printf(" night=%d",
+                                type->config.uiMode&ResTable_config::MASK_UI_MODE_NIGHT);
+                        switch (type->config.uiMode&ResTable_config::MASK_UI_MODE_NIGHT) {
+                            case ResTable_config::UI_MODE_NIGHT_NO:
+                                printf(" (no)");
+                                break;
+                            case ResTable_config::UI_MODE_NIGHT_YES:
+                                printf(" (yes)");
+                                break;
+                        }
+                    }
+                    if (dval != 0) {
+                        printf(" density=%s", density);
+                    }
+                    if (type->config.touchscreen != 0) {
+                        printf(" touch=%d", type->config.touchscreen);
+                        switch (type->config.touchscreen) {
+                            case ResTable_config::TOUCHSCREEN_NOTOUCH:
+                                printf(" (notouch)");
+                                break;
+                            case ResTable_config::TOUCHSCREEN_STYLUS:
+                                printf(" (stylus)");
+                                break;
+                            case ResTable_config::TOUCHSCREEN_FINGER:
+                                printf(" (finger)");
+                                break;
+                        }
+                    }
+                    if (type->config.inputFlags != 0) {
+                        printf(" keyhid=%d", type->config.inputFlags&ResTable_config::MASK_KEYSHIDDEN);
+                        switch (type->config.inputFlags&ResTable_config::MASK_KEYSHIDDEN) {
+                            case ResTable_config::KEYSHIDDEN_NO:
+                                printf(" (no)");
+                                break;
+                            case ResTable_config::KEYSHIDDEN_YES:
+                                printf(" (yes)");
+                                break;
+                            case ResTable_config::KEYSHIDDEN_SOFT:
+                                printf(" (soft)");
+                                break;
+                        }
+                        printf(" navhid=%d", type->config.inputFlags&ResTable_config::MASK_NAVHIDDEN);
+                        switch (type->config.inputFlags&ResTable_config::MASK_NAVHIDDEN) {
+                            case ResTable_config::NAVHIDDEN_NO:
+                                printf(" (no)");
+                                break;
+                            case ResTable_config::NAVHIDDEN_YES:
+                                printf(" (yes)");
+                                break;
+                        }
+                    }
+                    if (type->config.keyboard != 0) {
+                        printf(" kbd=%d", type->config.keyboard);
+                        switch (type->config.keyboard) {
+                            case ResTable_config::KEYBOARD_NOKEYS:
+                                printf(" (nokeys)");
+                                break;
+                            case ResTable_config::KEYBOARD_QWERTY:
+                                printf(" (qwerty)");
+                                break;
+                            case ResTable_config::KEYBOARD_12KEY:
+                                printf(" (12key)");
+                                break;
+                        }
+                    }
+                    if (type->config.navigation != 0) {
+                        printf(" nav=%d", type->config.navigation);
+                        switch (type->config.navigation) {
+                            case ResTable_config::NAVIGATION_NONAV:
+                                printf(" (nonav)");
+                                break;
+                            case ResTable_config::NAVIGATION_DPAD:
+                                printf(" (dpad)");
+                                break;
+                            case ResTable_config::NAVIGATION_TRACKBALL:
+                                printf(" (trackball)");
+                                break;
+                            case ResTable_config::NAVIGATION_WHEEL:
+                                printf(" (wheel)");
+                                break;
+                        }
+                    }
+                    if (type->config.screenWidth != 0) {
+                        printf(" w=%d", dtohs(type->config.screenWidth));
+                    }
+                    if (type->config.screenHeight != 0) {
+                        printf(" h=%d", dtohs(type->config.screenHeight));
+                    }
+                    if (type->config.sdkVersion != 0) {
+                        printf(" sdk=%d", dtohs(type->config.sdkVersion));
+                    }
+                    if (type->config.minorVersion != 0) {
+                        printf(" mver=%d", dtohs(type->config.minorVersion));
+                    }
+                    printf("\n");
                     size_t entryCount = dtohl(type->entryCount);
                     uint32_t entriesStart = dtohl(type->entriesStart);
                     if ((entriesStart&0x3) != 0) {