Merge change I228d52db into eclair

* changes:
  Three changes.
diff --git a/core/java/android/widget/RemoteViews.java b/core/java/android/widget/RemoteViews.java
index 8ef65db..6771711 100644
--- a/core/java/android/widget/RemoteViews.java
+++ b/core/java/android/widget/RemoteViews.java
@@ -143,7 +143,7 @@
                                     Intent.FLAG_ACTIVITY_NEW_TASK,
                                     Intent.FLAG_ACTIVITY_NEW_TASK, 0);
                         } catch (IntentSender.SendIntentException e) {
-                            throw new ActionException(e.toString());
+                            android.util.Log.e(LOG_TAG, "Cannot send pending intent: ", e);
                         }
                     }
                 };
diff --git a/opengl/tests/gl2_basic/gl2_basic.cpp b/opengl/tests/gl2_basic/gl2_basic.cpp
index 9345de5..d1090e6 100644
--- a/opengl/tests/gl2_basic/gl2_basic.cpp
+++ b/opengl/tests/gl2_basic/gl2_basic.cpp
@@ -178,21 +178,90 @@
 #if 0
 
 void PrintEGLConfig(EGLDisplay dpy, EGLConfig config) {
-	int attrib[] = {EGL_RED_SIZE, EGL_GREEN_SIZE, EGL_BLUE_SIZE, EGL_ALPHA_SIZE,
-			EGL_DEPTH_SIZE, EGL_SURFACE_TYPE, EGL_RENDERABLE_TYPE
-	};
-	for(size_t i = 0; i < sizeof(attrib)/sizeof(attrib[0]); i++) {
+    int attrib[] = {EGL_RED_SIZE, EGL_GREEN_SIZE, EGL_BLUE_SIZE, EGL_ALPHA_SIZE,
+            EGL_DEPTH_SIZE, EGL_SURFACE_TYPE, EGL_RENDERABLE_TYPE
+    };
+    for(size_t i = 0; i < sizeof(attrib)/sizeof(attrib[0]); i++) {
         int value = 0;
         int a = attrib[i];
         if (eglGetConfigAttrib(dpy, config, a, &value)) {
             printf(" 0x%04x: %d", a, value);
         }
-	}
-	printf("\n");
+    }
+    printf("\n");
 }
 
 #endif
 
+int printEGLConfigurations(EGLDisplay dpy) {
+    EGLint numConfig = 0;
+    EGLint returnVal = eglGetConfigs(dpy, NULL, 0, &numConfig);
+    checkEglError("eglGetConfigs", returnVal);
+    if (!returnVal) {
+        return false;
+    }
+
+    printf("Number of EGL configuration: %d\n", numConfig);
+
+    EGLConfig* configs = (EGLConfig*) malloc(sizeof(EGLConfig) * numConfig);
+    if (! configs) {
+        printf("Could not allocate configs.\n");
+        return false;
+    }
+
+    returnVal = eglGetConfigs(dpy, NULL, 0, &numConfig);
+    checkEglError("eglGetConfigs", returnVal);
+    if (!returnVal) {
+        free(configs);
+        return false;
+    }
+
+#define X(VAL) {VAL, #VAL}
+    struct {EGLint attribute; const char* name;} names[] = {
+    X(EGL_BUFFER_SIZE),
+    X(EGL_RED_SIZE),
+    X(EGL_GREEN_SIZE),
+    X(EGL_BLUE_SIZE),
+    X(EGL_ALPHA_SIZE),
+    X(EGL_CONFIG_CAVEAT),
+    X(EGL_CONFIG_ID),
+    X(EGL_DEPTH_SIZE),
+    X(EGL_LEVEL),
+    X(EGL_MAX_PBUFFER_WIDTH),
+    X(EGL_MAX_PBUFFER_HEIGHT),
+    X(EGL_MAX_PBUFFER_PIXELS),
+    X(EGL_NATIVE_RENDERABLE),
+    X(EGL_NATIVE_VISUAL_ID),
+    X(EGL_NATIVE_VISUAL_TYPE),
+    X(EGL_PRESERVED_RESOURCES),
+    X(EGL_SAMPLE_BUFFERS),
+    X(EGL_SAMPLES),
+    // X(EGL_STENCIL_BITS),
+    X(EGL_SURFACE_TYPE),
+    X(EGL_TRANSPARENT_TYPE),
+    // X(EGL_TRANSPARENT_RED),
+    // X(EGL_TRANSPARENT_GREEN),
+    // X(EGL_TRANSPARENT_BLUE)
+    };
+#undef X
+
+    for(int i = 0; i < numConfig; i++) {
+        printf("Configuration %d\n", i);
+        EGLConfig config = configs[i];
+        for (int j = 0; j < sizeof(names) / sizeof(names[0]); j++) {
+            EGLint value = -1;
+            returnVal = eglGetConfigAttrib(dpy, config, names[j].attribute, &value); 
+            if (returnVal) {
+                printf(" %s: %d (0x%x)", names[j].name, value, value);
+            }
+        }
+        printf("\n");
+    }
+
+    free(configs);
+    return true;
+}
+
 int main(int argc, char** argv) {
     EGLBoolean returnValue;
     EGLConfig myConfig = {0};
@@ -226,11 +295,16 @@
         return 0;
     }
 
+    if (!printEGLConfigurations(dpy)) {
+        printf("printEGLConfigurations failed\n");
+        return 0;
+    }
+
     EGLNativeWindowType window = android_createDisplaySurface();

     returnValue = EGLUtils::selectConfigForNativeWindow(dpy, s_configAttribs, window, &myConfig);
     if (returnValue) {
-    	printf("EGLUtils::selectConfigForNativeWindow() returned %d", returnValue);
-    	return 0;
+        printf("EGLUtils::selectConfigForNativeWindow() returned %d", returnValue);
+        return 0;
     }
 
     surface = eglCreateWindowSurface(dpy, myConfig, window, NULL);
diff --git a/services/java/com/android/server/DockObserver.java b/services/java/com/android/server/DockObserver.java
index a70134d..aa9c243 100644
--- a/services/java/com/android/server/DockObserver.java
+++ b/services/java/com/android/server/DockObserver.java
@@ -17,6 +17,7 @@
 package com.android.server;
 
 import android.app.Activity;
+import android.app.KeyguardManager;
 import android.content.ActivityNotFoundException;
 import android.content.BroadcastReceiver;
 import android.content.Context;
@@ -27,6 +28,8 @@
 import android.os.UEventObserver;
 import android.util.Log;
 
+import com.android.internal.widget.LockPatternUtils;
+
 import java.io.FileReader;
 import java.io.FileNotFoundException;
 
@@ -46,7 +49,11 @@
     private final Context mContext;
 
     private PowerManagerService mPowerManager;
-    
+
+    private KeyguardManager.KeyguardLock mKeyguardLock;
+    private boolean mKeyguardDisabled;
+    private LockPatternUtils mLockPatternUtils;
+
     // The broadcast receiver which receives the result of the ordered broadcast sent when
     // the dock state changes. The original ordered broadcast is sent with an initial result
     // code of RESULT_OK. If any of the registered broadcast receivers changes this value, e.g.,
@@ -88,6 +95,7 @@
     public DockObserver(Context context, PowerManagerService pm) {
         mContext = context;
         mPowerManager = pm;
+        mLockPatternUtils = new LockPatternUtils(context.getContentResolver());
         init();  // set initial status
         startObserving(DOCK_UEVENT_MATCH);
     }
@@ -130,6 +138,10 @@
 
     void systemReady() {
         synchronized (this) {
+            KeyguardManager keyguardManager =
+                    (KeyguardManager)mContext.getSystemService(Context.KEYGUARD_SERVICE);
+            mKeyguardLock = keyguardManager.newKeyguardLock(TAG);
+
             // don't bother broadcasting undocked here
             if (mDockState != Intent.EXTRA_DOCK_STATE_UNDOCKED) {
                 update();
@@ -142,10 +154,25 @@
         mHandler.sendEmptyMessage(0);
     }
 
+    private final void updateKeyguardLocked() {
+        if (!mLockPatternUtils.isLockPatternEnabled()) {
+            if (!mKeyguardDisabled && mDockState != Intent.EXTRA_DOCK_STATE_UNDOCKED) {
+                Log.d(TAG, "calling mKeyguardLock.disableKeyguard");
+                mKeyguardLock.disableKeyguard();
+                mKeyguardDisabled = true;
+            } else if (mKeyguardDisabled && mDockState == Intent.EXTRA_DOCK_STATE_UNDOCKED) {
+                Log.d(TAG, "calling mKeyguardLock.reenableKeyguard");
+                mKeyguardLock.reenableKeyguard();
+                mKeyguardDisabled = false;
+            }
+        }
+    }
+
     private final Handler mHandler = new Handler() {
         @Override
         public void handleMessage(Message msg) {
             synchronized (this) {
+                updateKeyguardLocked();
                 Log.d(TAG, "Broadcasting dock state " + mDockState);
                 // Pack up the values and broadcast them to everyone
                 mPowerManager.userActivityWithForce(SystemClock.uptimeMillis(), false, true);
diff --git a/services/java/com/android/server/WindowManagerService.java b/services/java/com/android/server/WindowManagerService.java
index 30855b1..01a4122 100644
--- a/services/java/com/android/server/WindowManagerService.java
+++ b/services/java/com/android/server/WindowManagerService.java
@@ -3965,7 +3965,7 @@
     // -------------------------------------------------------------
 
     public void disableKeyguard(IBinder token, String tag) {
-        if (mContext.checkCallingPermission(android.Manifest.permission.DISABLE_KEYGUARD)
+        if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DISABLE_KEYGUARD)
             != PackageManager.PERMISSION_GRANTED) {
             throw new SecurityException("Requires DISABLE_KEYGUARD permission");
         }
@@ -3973,7 +3973,7 @@
     }
 
     public void reenableKeyguard(IBinder token) {
-        if (mContext.checkCallingPermission(android.Manifest.permission.DISABLE_KEYGUARD)
+        if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DISABLE_KEYGUARD)
             != PackageManager.PERMISSION_GRANTED) {
             throw new SecurityException("Requires DISABLE_KEYGUARD permission");
         }
@@ -3999,7 +3999,7 @@
      * @see android.app.KeyguardManager#exitKeyguardSecurely
      */
     public void exitKeyguardSecurely(final IOnKeyguardExitResult callback) {
-        if (mContext.checkCallingPermission(android.Manifest.permission.DISABLE_KEYGUARD)
+        if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DISABLE_KEYGUARD)
             != PackageManager.PERMISSION_GRANTED) {
             throw new SecurityException("Requires DISABLE_KEYGUARD permission");
         }