Merge "DO NOT MERGE - Fixing ringtones that were put in as notifications" into gingerbread
diff --git a/core/java/android/nfc/ErrorCodes.java b/core/java/android/nfc/ErrorCodes.java
index 5b76d84..69329df 100644
--- a/core/java/android/nfc/ErrorCodes.java
+++ b/core/java/android/nfc/ErrorCodes.java
@@ -33,6 +33,34 @@
         }
     }
 
+    public static String asString(int code) {
+        switch (code) {
+            case SUCCESS: return "SUCCESS";
+            case ERROR_IO: return "IO";
+            case ERROR_CANCELLED: return "CANCELLED";
+            case ERROR_TIMEOUT: return "TIMEOUT";
+            case ERROR_BUSY: return "BUSY";
+            case ERROR_CONNECT: return "CONNECT/DISCONNECT";
+//            case ERROR_DISCONNECT: return "DISCONNECT";
+            case ERROR_READ: return "READ";
+            case ERROR_WRITE: return "WRITE";
+            case ERROR_INVALID_PARAM: return "INVALID_PARAM";
+            case ERROR_INSUFFICIENT_RESOURCES: return "INSUFFICIENT_RESOURCES";
+            case ERROR_SOCKET_CREATION: return "SOCKET_CREATION";
+            case ERROR_SOCKET_NOT_CONNECTED: return "SOCKET_NOT_CONNECTED";
+            case ERROR_BUFFER_TO_SMALL: return "BUFFER_TO_SMALL";
+            case ERROR_SAP_USED: return "SAP_USED";
+            case ERROR_SERVICE_NAME_USED: return "SERVICE_NAME_USED";
+            case ERROR_SOCKET_OPTIONS: return "SOCKET_OPTIONS";
+            case ERROR_NFC_ON: return "NFC_ON";
+            case ERROR_NOT_INITIALIZED: return "NOT_INITIALIZED";
+            case ERROR_SE_ALREADY_SELECTED: return "SE_ALREADY_SELECTED";
+            case ERROR_SE_CONNECTED: return "SE_CONNECTED";
+            case ERROR_NO_SE_CONNECTED: return "NO_SE_CONNECTED";
+            default: return "UNKNOWN ERROR";
+        }
+    }
+
     public static final int SUCCESS = 0;
 
     public static final int ERROR_IO = -1;
diff --git a/libs/surfaceflinger_client/Surface.cpp b/libs/surfaceflinger_client/Surface.cpp
index d44aab9..854a3c6 100644
--- a/libs/surfaceflinger_client/Surface.cpp
+++ b/libs/surfaceflinger_client/Surface.cpp
@@ -866,7 +866,18 @@
         return BAD_VALUE;
 
     Mutex::Autolock _l(mSurfaceLock);
+    if (mConnected == NATIVE_WINDOW_API_EGL) {
+        return INVALID_OPERATION;
+    }
+
     mBufferInfo.set(w, h, format);
+    if (format != 0) {
+        // we update the format of the surface as reported by query().
+        // this is to allow applications to change the format of a surface's
+        // buffer, and have it reflected in EGL; which is needed for
+        // EGLConfig validation.
+        mFormat = format;
+    }
     return NO_ERROR;
 }
 
diff --git a/native/android/native_window.cpp b/native/android/native_window.cpp
index bada078..7f92eec 100644
--- a/native/android/native_window.cpp
+++ b/native/android/native_window.cpp
@@ -58,8 +58,8 @@
 }
 
 int32_t ANativeWindow_setBuffersGeometry(ANativeWindow* window, int32_t width,
-        int32_t height) {
-    native_window_set_buffers_geometry(window, width, height, 0);
+        int32_t height, int32_t format) {
+    native_window_set_buffers_geometry(window, width, height, format);
     return 0;
 }
 
diff --git a/native/include/android/native_window.h b/native/include/android/native_window.h
index ad03d0e..f3d7550 100644
--- a/native/include/android/native_window.h
+++ b/native/include/android/native_window.h
@@ -96,7 +96,7 @@
  * For all of these parameters, if 0 is supplied then the window's base
  * value will come back in force.
  */
-int32_t ANativeWindow_setBuffersGeometry(ANativeWindow* window, int32_t width, int32_t height);
+int32_t ANativeWindow_setBuffersGeometry(ANativeWindow* window, int32_t width, int32_t height, int32_t format);
 
 /**
  * Lock the window's next drawing surface for writing.
diff --git a/opengl/libagl/egl.cpp b/opengl/libagl/egl.cpp
index ba33e17..662a1fa 100644
--- a/opengl/libagl/egl.cpp
+++ b/opengl/libagl/egl.cpp
@@ -833,6 +833,9 @@
     static bool mask(GLint reqValue, GLint confValue) {
         return (confValue & reqValue) == reqValue;
     }
+    static bool ignore(GLint reqValue, GLint confValue) {
+        return true;
+    }
 };
 
 // ----------------------------------------------------------------------------
@@ -1060,11 +1063,11 @@
         { EGL_CONFIG_CAVEAT,              config_management_t::exact   },
         { EGL_CONFIG_ID,                  config_management_t::exact   },
         { EGL_LEVEL,                      config_management_t::exact   },
-        { EGL_MAX_PBUFFER_HEIGHT,         config_management_t::exact   },
-        { EGL_MAX_PBUFFER_PIXELS,         config_management_t::exact   },
-        { EGL_MAX_PBUFFER_WIDTH,          config_management_t::exact   },
+        { EGL_MAX_PBUFFER_HEIGHT,         config_management_t::ignore   },
+        { EGL_MAX_PBUFFER_PIXELS,         config_management_t::ignore   },
+        { EGL_MAX_PBUFFER_WIDTH,          config_management_t::ignore   },
         { EGL_NATIVE_RENDERABLE,          config_management_t::exact   },
-        { EGL_NATIVE_VISUAL_ID,           config_management_t::exact   },
+        { EGL_NATIVE_VISUAL_ID,           config_management_t::ignore   },
         { EGL_NATIVE_VISUAL_TYPE,         config_management_t::exact   },
         { EGL_SAMPLES,                    config_management_t::exact   },
         { EGL_SAMPLE_BUFFERS,             config_management_t::exact   },
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeContentResolver.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeContentResolver.java
index d89dba9..20ccc0b 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeContentResolver.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeContentResolver.java
@@ -16,12 +16,27 @@
 
 package com.android.layoutlib.bridge;
 
+import android.content.ContentProviderOperation;
+import android.content.ContentProviderResult;
 import android.content.ContentResolver;
+import android.content.ContentValues;
 import android.content.Context;
 import android.content.IContentProvider;
+import android.content.OperationApplicationException;
+import android.content.res.AssetFileDescriptor;
 import android.database.ContentObserver;
+import android.database.Cursor;
+import android.database.CursorWindow;
+import android.database.IBulkCursor;
+import android.database.IContentObserver;
 import android.net.Uri;
 import android.os.Bundle;
+import android.os.IBinder;
+import android.os.ParcelFileDescriptor;
+import android.os.RemoteException;
+
+import java.io.FileNotFoundException;
+import java.util.ArrayList;
 
 /**
  * A mock content resolver for the LayoutLib Bridge.
@@ -32,20 +47,98 @@
  */
 public class BridgeContentResolver extends ContentResolver {
 
+    private BridgeContentProvider mProvider = null;
+
+    public static final class BridgeContentProvider implements IContentProvider {
+
+        public ContentProviderResult[] applyBatch(ArrayList<ContentProviderOperation> arg0)
+                throws RemoteException, OperationApplicationException {
+            // TODO Auto-generated method stub
+            return null;
+        }
+
+        public int bulkInsert(Uri arg0, ContentValues[] arg1) throws RemoteException {
+            // TODO Auto-generated method stub
+            return 0;
+        }
+
+        public IBulkCursor bulkQuery(Uri arg0, String[] arg1, String arg2, String[] arg3,
+                String arg4, IContentObserver arg5, CursorWindow arg6) throws RemoteException {
+            // TODO Auto-generated method stub
+            return null;
+        }
+
+        public Bundle call(String arg0, String arg1, Bundle arg2) throws RemoteException {
+            // TODO Auto-generated method stub
+            return null;
+        }
+
+        public int delete(Uri arg0, String arg1, String[] arg2) throws RemoteException {
+            // TODO Auto-generated method stub
+            return 0;
+        }
+
+        public String getType(Uri arg0) throws RemoteException {
+            // TODO Auto-generated method stub
+            return null;
+        }
+
+        public Uri insert(Uri arg0, ContentValues arg1) throws RemoteException {
+            // TODO Auto-generated method stub
+            return null;
+        }
+
+        public AssetFileDescriptor openAssetFile(Uri arg0, String arg1) throws RemoteException,
+                FileNotFoundException {
+            // TODO Auto-generated method stub
+            return null;
+        }
+
+        public ParcelFileDescriptor openFile(Uri arg0, String arg1) throws RemoteException,
+                FileNotFoundException {
+            // TODO Auto-generated method stub
+            return null;
+        }
+
+        public Cursor query(Uri arg0, String[] arg1, String arg2, String[] arg3, String arg4)
+                throws RemoteException {
+            // TODO Auto-generated method stub
+            return null;
+        }
+
+        public int update(Uri arg0, ContentValues arg1, String arg2, String[] arg3)
+                throws RemoteException {
+            // TODO Auto-generated method stub
+            return 0;
+        }
+
+        public IBinder asBinder() {
+            // TODO Auto-generated method stub
+            return null;
+        }
+
+    }
+
     public BridgeContentResolver(Context context) {
         super(context);
     }
 
     @Override
     public IContentProvider acquireProvider(Context c, String name) {
-        // ignore
-        return null;
+        if (mProvider == null) {
+            mProvider = new BridgeContentProvider();
+        }
+
+        return mProvider;
     }
 
     @Override
     public IContentProvider acquireExistingProvider(Context c, String name) {
-        // ignore
-        return null;
+        if (mProvider == null) {
+            mProvider = new BridgeContentProvider();
+        }
+
+        return mProvider;
     }
 
     @Override
@@ -53,7 +146,7 @@
         // ignore
         return false;
     }
-    
+
     /**
      * Stub for the layoutlib bridge content resolver.
      */
@@ -62,7 +155,7 @@
             ContentObserver observer) {
         // pass
     }
-    
+
     /**
      * Stub for the layoutlib bridge content resolver.
      */
@@ -70,7 +163,7 @@
     public void unregisterContentObserver(ContentObserver observer) {
         // pass
     }
-    
+
     /**
      * Stub for the layoutlib bridge content resolver.
      */
@@ -78,7 +171,7 @@
     public void notifyChange(Uri uri, ContentObserver observer, boolean syncToNetwork) {
         // pass
     }
-    
+
     /**
      * Stub for the layoutlib bridge content resolver.
      */
@@ -86,7 +179,7 @@
     public void startSync(Uri uri, Bundle extras) {
         // pass
     }
-    
+
     /**
      * Stub for the layoutlib bridge content resolver.
      */
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeContext.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeContext.java
index d5a90e6..1436494 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeContext.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeContext.java
@@ -997,8 +997,7 @@
 
     @Override
     public ApplicationInfo getApplicationInfo() {
-        // TODO Auto-generated method stub
-        return null;
+        return new ApplicationInfo();
     }
 
     @Override
diff --git a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/Main.java b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/Main.java
index 303f097..b30e9e5 100644
--- a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/Main.java
+++ b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/Main.java
@@ -67,6 +67,7 @@
                         "com.android.internal.R**",
                         "android.pim.*", // for datepicker
                         "android.os.*",  // for android.os.Handler
+                        "android.database.ContentObserver", // for Digital clock
                         });
             aa.analyze();
             agen.generate();