Merge "unhide functions used by reflected files for SDK." into honeycomb
diff --git a/core/java/android/widget/ExpandableListView.java b/core/java/android/widget/ExpandableListView.java
index 3d21048..472a335 100644
--- a/core/java/android/widget/ExpandableListView.java
+++ b/core/java/android/widget/ExpandableListView.java
@@ -22,7 +22,6 @@
 import android.content.res.TypedArray;
 import android.graphics.Canvas;
 import android.graphics.Rect;
-import android.graphics.drawable.ColorDrawable;
 import android.graphics.drawable.Drawable;
 import android.os.Parcel;
 import android.os.Parcelable;
@@ -212,6 +211,9 @@
                 .getDimensionPixelSize(com.android.internal.R.styleable.ExpandableListView_indicatorLeft, 0);
         mIndicatorRight = a
                 .getDimensionPixelSize(com.android.internal.R.styleable.ExpandableListView_indicatorRight, 0);
+        if (mIndicatorRight == 0) {
+            mIndicatorRight = mIndicatorLeft + mGroupIndicator.getIntrinsicWidth();
+        }
         mChildIndicatorLeft = a.getDimensionPixelSize(
                 com.android.internal.R.styleable.ExpandableListView_childIndicatorLeft, CHILD_INDICATOR_INHERIT);
         mChildIndicatorRight = a.getDimensionPixelSize(
diff --git a/core/res/res/layout-xlarge/keyguard_screen_glogin_unlock.xml b/core/res/res/layout-xlarge/keyguard_screen_glogin_unlock.xml
index 8a46546..4f5beff 100644
--- a/core/res/res/layout-xlarge/keyguard_screen_glogin_unlock.xml
+++ b/core/res/res/layout-xlarge/keyguard_screen_glogin_unlock.xml
@@ -27,12 +27,11 @@
         android:layout_height="0px"
         android:layout_weight="1"
         android:layout_above="@+id/emergencyCall">
-        <RelativeLayout 
+        <RelativeLayout
             android:layout_width="match_parent"
-            android:layout_height="match_parent"
-                >
-        
-            <TextView 
+            android:layout_height="match_parent">
+
+            <TextView
                 android:id="@+id/topHeader"
                 android:layout_width="match_parent"
                 android:layout_height="64dip"
@@ -43,7 +42,7 @@
                 android:drawableLeft="@drawable/ic_lock_idle_lock"
                 android:drawablePadding="5dip"
                 />
-        
+
             <!-- spacer below header -->
             <View
                 android:id="@+id/spacerTop"
@@ -51,7 +50,7 @@
                 android:layout_height="1dip"
                 android:layout_below="@id/topHeader"
                 android:background="@drawable/divider_horizontal_dark"/>
-        
+
             <TextView
                 android:id="@+id/instructions"
                 android:layout_width="match_parent"
@@ -62,7 +61,7 @@
                 android:textAppearance="?android:attr/textAppearanceSmall"
                 android:text="@android:string/lockscreen_glogin_instructions"
                 />
-        
+
             <EditText
                 android:id="@+id/login"
                 android:layout_width="match_parent"
@@ -74,7 +73,7 @@
                 android:hint="@android:string/lockscreen_glogin_username_hint"
                 android:inputType="textEmailAddress"
                 />
-        
+
             <EditText
                 android:id="@+id/password"
                 android:layout_width="match_parent"
@@ -88,11 +87,11 @@
                 android:nextFocusRight="@+id/ok"
                 android:nextFocusDown="@+id/ok"
                 />
-        
+
             <!-- ok below password, aligned to right of screen -->
             <Button
                 android:id="@+id/ok"
-                android:layout_width="85dip"
+                android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:layout_below="@id/password"
                 android:layout_marginTop="7dip"
@@ -100,10 +99,10 @@
                 android:layout_alignParentRight="true"
                 android:text="@android:string/lockscreen_glogin_submit_button"
                 />
-        
+
         </RelativeLayout>
     </ScrollView>
-    
+
     <!-- spacer above emergency call -->
     <View
         android:layout_width="match_parent"
@@ -121,6 +120,7 @@
         android:drawableLeft="@drawable/ic_emergency"
         android:drawablePadding="8dip"
         android:text="@android:string/lockscreen_emergency_call"
+        android:visibility="gone"
         />
 
 </LinearLayout>
diff --git a/core/res/res/values/themes.xml b/core/res/res/values/themes.xml
index f65b1f2..744d0d8 100644
--- a/core/res/res/values/themes.xml
+++ b/core/res/res/values/themes.xml
@@ -114,7 +114,7 @@
                 ?android:attr/expandableListPreferredItemPaddingLeft</item>
 
         <item name="expandableListPreferredItemIndicatorLeft">3dip</item>
-        <item name="expandableListPreferredItemIndicatorRight">33dip</item>
+        <item name="expandableListPreferredItemIndicatorRight">0dip</item>
         <item name="expandableListPreferredChildIndicatorLeft">
                 ?android:attr/expandableListPreferredItemIndicatorLeft</item>
         <item name="expandableListPreferredChildIndicatorRight">
@@ -816,7 +816,7 @@
                 ?android:attr/expandableListPreferredItemPaddingLeft</item>
 
         <item name="expandableListPreferredItemIndicatorLeft">3dip</item>
-        <item name="expandableListPreferredItemIndicatorRight">33dip</item>
+        <item name="expandableListPreferredItemIndicatorRight">0dip</item>
         <item name="expandableListPreferredChildIndicatorLeft">
                 ?android:attr/expandableListPreferredItemIndicatorLeft</item>
         <item name="expandableListPreferredChildIndicatorRight">
@@ -1075,7 +1075,7 @@
                 ?android:attr/expandableListPreferredItemPaddingLeft</item>
 
         <item name="expandableListPreferredItemIndicatorLeft">3dip</item>
-        <item name="expandableListPreferredItemIndicatorRight">33dip</item>
+        <item name="expandableListPreferredItemIndicatorRight">0dip</item>
         <item name="expandableListPreferredChildIndicatorLeft">
                 ?android:attr/expandableListPreferredItemIndicatorLeft</item>
         <item name="expandableListPreferredChildIndicatorRight">
diff --git a/libs/hwui/Debug.h b/libs/hwui/Debug.h
index bdd8e73..71ec760 100644
--- a/libs/hwui/Debug.h
+++ b/libs/hwui/Debug.h
@@ -37,6 +37,10 @@
 // Turn on to display vertex and tex coords data about 9patch objects
 // This flag requires DEBUG_PATCHES to be turned on
 #define DEBUG_PATCHES_VERTICES 0
+// Turn on to display vertex and tex coords data used by empty quads
+// in 9patch objects
+// This flag requires DEBUG_PATCHES to be turned on
+#define DEBUG_PATCHES_EMPTY_VERTICES 0
 
 // Turn on to display debug info about paths
 #define DEBUG_PATHS 0
diff --git a/libs/hwui/LayerRenderer.cpp b/libs/hwui/LayerRenderer.cpp
index cd2554e..e6bea78 100644
--- a/libs/hwui/LayerRenderer.cpp
+++ b/libs/hwui/LayerRenderer.cpp
@@ -29,10 +29,6 @@
 void LayerRenderer::prepare(bool opaque) {
     LAYER_RENDERER_LOGD("Rendering into layer, fbo = %d", mLayer->fbo);
 
-#if RENDER_LAYERS_AS_REGIONS
-    mLayer->region.clear();
-#endif
-
     glGetIntegerv(GL_FRAMEBUFFER_BINDING, (GLint*) &mPreviousFbo);
     glBindFramebuffer(GL_FRAMEBUFFER, mLayer->fbo);
 
@@ -78,6 +74,7 @@
             mLayer->meshIndices = NULL;
             mLayer->meshElementCount = 0;
         }
+        mLayer->region.clear();
         return;
     }
 
@@ -129,6 +126,8 @@
         indices[index + 4] = quad + 1;   // top-right
         indices[index + 5] = quad + 3;   // bottom-right
     }
+
+    mLayer->region.clear();
 #endif
 }
 
diff --git a/libs/hwui/Patch.cpp b/libs/hwui/Patch.cpp
index e5cb67b..77cbb80 100644
--- a/libs/hwui/Patch.cpp
+++ b/libs/hwui/Patch.cpp
@@ -212,7 +212,7 @@
         }
         float u2 = fmax(0.0f, stepX - 0.5f) / bitmapWidth;
 
-        generateQuad(vertex, x1, y1, x2, y2, u1, v1, u2, v2, quadCount);
+        bool valid = generateQuad(vertex, x1, y1, x2, y2, u1, v1, u2, v2, quadCount);
 
         x1 = x2;
         u1 = (stepX + 0.5f) / bitmapWidth;
@@ -223,17 +223,22 @@
     generateQuad(vertex, x1, y1, width, y2, u1, v1, 1.0f, v2, quadCount);
 }
 
-void Patch::generateQuad(TextureVertex*& vertex, float x1, float y1, float x2, float y2,
+bool Patch::generateQuad(TextureVertex*& vertex, float x1, float y1, float x2, float y2,
             float u1, float v1, float u2, float v2, uint32_t& quadCount) {
     const uint32_t oldQuadCount = quadCount;
-    const bool valid = x2 - x1 > 0.9999f && y2 - y1 > 0.9999f;
+    const bool valid = x2 >= x1 && y2 >= y1;
     if (valid) {
         quadCount++;
     }
 
     // Skip degenerate and transparent (empty) quads
     if (!valid || ((mColorKey >> oldQuadCount) & 0x1) == 1) {
-        return;
+#if DEBUG_PATCHES_EMPTY_VERTICES
+        PATCH_LOGD("    quad %d (empty)", oldQuadCount);
+        PATCH_LOGD("        left,  top    = %.2f, %.2f\t\tu1, v1 = %.2f, %.2f", x1, y1, u1, v1);
+        PATCH_LOGD("        right, bottom = %.2f, %.2f\t\tu2, v2 = %.2f, %.2f", x2, y2, u2, v2);
+#endif
+        return false;
     }
 
 #if RENDER_LAYERS_AS_REGIONS
@@ -262,6 +267,8 @@
     PATCH_LOGD("        left,  top    = %.2f, %.2f\t\tu1, v1 = %.2f, %.2f", x1, y1, u1, v1);
     PATCH_LOGD("        right, bottom = %.2f, %.2f\t\tu2, v2 = %.2f, %.2f", x2, y2, u2, v2);
 #endif
+
+    return true;
 }
 
 }; // namespace uirenderer
diff --git a/libs/hwui/Patch.h b/libs/hwui/Patch.h
index 0f0ffa2..45ce998 100644
--- a/libs/hwui/Patch.h
+++ b/libs/hwui/Patch.h
@@ -71,7 +71,7 @@
     void generateRow(TextureVertex*& vertex, float y1, float y2,
             float v1, float v2, float stretchX, float width, float bitmapWidth,
             uint32_t& quadCount);
-    void generateQuad(TextureVertex*& vertex,
+    bool generateQuad(TextureVertex*& vertex,
             float x1, float y1, float x2, float y2,
             float u1, float v1, float u2, float v2,
             uint32_t& quadCount);
diff --git a/libs/rs/java/ImageProcessing/src/com/android/rs/image/vertical_blur.rs b/libs/rs/java/ImageProcessing/src/com/android/rs/image/vertical_blur.rs
index aa4cf2d..4615e1f 100644
--- a/libs/rs/java/ImageProcessing/src/com/android/rs/image/vertical_blur.rs
+++ b/libs/rs/java/ImageProcessing/src/com/android/rs/image/vertical_blur.rs
@@ -56,7 +56,7 @@
 }
 
 //sliao
-uchar3 convert2uchar3(float3 xyz);
+extern uchar3 __attribute__((overloadable)) convert2uchar3(float3 xyz);
 
 void root(const void *v_in, void *v_out, const void *usrData, uint32_t x, uint32_t y) {
     uchar4 *output = (uchar4 *)v_out;
diff --git a/libs/rs/rsScriptC.cpp b/libs/rs/rsScriptC.cpp
index 0ecb18a..1ab2109 100644
--- a/libs/rs/rsScriptC.cpp
+++ b/libs/rs/rsScriptC.cpp
@@ -490,7 +490,8 @@
         if (bccLinkBC(s->mBccScript,
                       resName,
                       NULL /*rs_runtime_lib_bc*/,
-                      0 /*rs_runtime_lib_bc_size*/,
+                      1 /*rs_runtime_lib_bc_size*/
+                        /*"1" means skip buffer here, and let libbcc decide*/,
                       0) != 0) {
             LOGE("bcc: FAILS to link bitcode");
             // Handle Fatal Error
diff --git a/policy/src/com/android/internal/policy/impl/PasswordUnlockScreen.java b/policy/src/com/android/internal/policy/impl/PasswordUnlockScreen.java
index 9db86aa..b789288 100644
--- a/policy/src/com/android/internal/policy/impl/PasswordUnlockScreen.java
+++ b/policy/src/com/android/internal/policy/impl/PasswordUnlockScreen.java
@@ -109,22 +109,21 @@
         mLockPatternUtils.updateEmergencyCallButtonState(mEmergencyCallButton);
 
         mKeyboardHelper = new PasswordEntryKeyboardHelper(context, mKeyboardView, this, false);
+        // TODO: re-enable on phones with keyboards
+        boolean isPhysicalKbShowing = false;
+        //mCreationHardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_NO;
         if (mKeyboardViewAlpha == null || !mIsAlpha) {
             mKeyboardHelper.setKeyboardMode(mIsAlpha ?
                     PasswordEntryKeyboardHelper.KEYBOARD_MODE_ALPHA
                     : PasswordEntryKeyboardHelper.KEYBOARD_MODE_NUMERIC);
-            mKeyboardView.setVisibility(
-                    mCreationHardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_NO
-                    ? View.INVISIBLE : View.VISIBLE);
+            mKeyboardView.setVisibility(isPhysicalKbShowing ? View.INVISIBLE : View.VISIBLE);
         } else {
             mKeyboardHelperAlpha = new PasswordEntryKeyboardHelper(context, mKeyboardViewAlpha,
                     this, false);
             mKeyboardHelper.setKeyboardMode(PasswordEntryKeyboardHelper.KEYBOARD_MODE_NUMERIC);
             mKeyboardHelperAlpha.setKeyboardMode(PasswordEntryKeyboardHelper.KEYBOARD_MODE_ALPHA);
             mKeyboardView.setVisibility(View.GONE);
-            mKeyboardViewAlpha.setVisibility(
-                    mCreationHardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_NO
-                    ? View.INVISIBLE : View.VISIBLE);
+            mKeyboardViewAlpha.setVisibility(isPhysicalKbShowing ? View.INVISIBLE : View.VISIBLE);
             mPasswordEntry.setWidth(mKeyboardViewAlpha.getLayoutParams().width);
         }
 
diff --git a/tests/HwAccelerationTest/AndroidManifest.xml b/tests/HwAccelerationTest/AndroidManifest.xml
index e73afa0..7099ab5 100644
--- a/tests/HwAccelerationTest/AndroidManifest.xml
+++ b/tests/HwAccelerationTest/AndroidManifest.xml
@@ -25,6 +25,16 @@
         android:hardwareAccelerated="true">
 
         <activity
+                android:name="SimplePatchActivity"
+                android:label="_SimplePatch"
+                android:theme="@android:style/Theme.Translucent.NoTitleBar">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.LAUNCHER" />
+            </intent-filter>
+        </activity>
+
+        <activity
                 android:name="ViewLayersActivity"
                 android:label="_ViewLayers">
             <intent-filter>
diff --git a/tests/HwAccelerationTest/res/drawable-mdpi/expander_ic_maximized.9.png b/tests/HwAccelerationTest/res/drawable-mdpi/expander_ic_maximized.9.png
new file mode 100644
index 0000000..d5c3276
--- /dev/null
+++ b/tests/HwAccelerationTest/res/drawable-mdpi/expander_ic_maximized.9.png
Binary files differ
diff --git a/tests/HwAccelerationTest/res/drawable-mdpi/expander_ic_minimized.9.png b/tests/HwAccelerationTest/res/drawable-mdpi/expander_ic_minimized.9.png
new file mode 100644
index 0000000..4515b42
--- /dev/null
+++ b/tests/HwAccelerationTest/res/drawable-mdpi/expander_ic_minimized.9.png
Binary files differ
diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/SimplePatchActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/SimplePatchActivity.java
new file mode 100644
index 0000000..a9b4d1c
--- /dev/null
+++ b/tests/HwAccelerationTest/src/com/android/test/hwui/SimplePatchActivity.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.test.hwui;
+
+import android.app.Activity;
+import android.content.Context;
+import android.graphics.Canvas;
+import android.graphics.drawable.Drawable;
+import android.os.Bundle;
+import android.view.View;
+
+@SuppressWarnings({"UnusedDeclaration"})
+public class SimplePatchActivity extends Activity {
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        
+        setContentView(new PatchView(this));
+    }
+
+    private static class PatchView extends View {
+        private final Drawable mDrawable;
+
+        public PatchView(Context context) {
+            super(context);
+            setBackgroundColor(0xff000000);
+            mDrawable = context.getResources().getDrawable(R.drawable.expander_ic_minimized);
+        }
+
+        @Override
+        protected void onDraw(Canvas canvas) {
+            super.onDraw(canvas);
+            canvas.save();
+            canvas.translate(200, 200);
+            mDrawable.setBounds(3, 0, 33, 64);
+            mDrawable.draw(canvas);
+            mDrawable.setBounds(63, 0, 94, 64);
+            mDrawable.draw(canvas);
+            canvas.restore();
+        }
+    }
+}
diff --git a/wifi/java/android/net/wifi/WifiManager.java b/wifi/java/android/net/wifi/WifiManager.java
index 54887d7..d05918f 100644
--- a/wifi/java/android/net/wifi/WifiManager.java
+++ b/wifi/java/android/net/wifi/WifiManager.java
@@ -274,6 +274,25 @@
      * @see #ERROR_AUTHENTICATING
      */
     public static final String EXTRA_SUPPLICANT_ERROR = "supplicantError";
+
+    /**
+     * Broadcast intent action for reporting errors
+     * @hide
+     */
+    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
+    public static final String ERROR_ACTION = "android.net.wifi.ERROR";
+    /**
+     * The type of error being reported
+     * @hide
+     */
+    public static final String EXTRA_ERROR_CODE = "errorCode";
+
+    /**
+     * Valid error codes
+     * @hide
+     */
+    public static final int WPS_OVERLAP_ERROR = 1;
+
     /**
      * Broadcast intent action indicating that the configured networks changed.
      * This can be as a result of adding/updating/deleting a network
diff --git a/wifi/java/android/net/wifi/WifiMonitor.java b/wifi/java/android/net/wifi/WifiMonitor.java
index 934e509..090ad3b 100644
--- a/wifi/java/android/net/wifi/WifiMonitor.java
+++ b/wifi/java/android/net/wifi/WifiMonitor.java
@@ -53,6 +53,9 @@
     private static final String passwordKeyMayBeIncorrectEvent =
        "pre-shared key may be incorrect";
 
+    /* WPS events */
+    private static final String wpsOverlapEvent = "WPS-OVERLAP-DETECTED";
+
     /**
      * Names of events from wpa_supplicant (minus the prefix). In the
      * format descriptions, * &quot;<code>x</code>&quot;
@@ -174,6 +177,8 @@
                     if (eventStr.startsWith(wpaEventPrefix) &&
                             0 < eventStr.indexOf(passwordKeyMayBeIncorrectEvent)) {
                         handlePasswordKeyMayBeIncorrect();
+                    } else if (eventStr.startsWith(wpsOverlapEvent)) {
+                        mWifiStateMachine.notifyWpsOverlap();
                     }
                     continue;
                 }
diff --git a/wifi/java/android/net/wifi/WifiStateMachine.java b/wifi/java/android/net/wifi/WifiStateMachine.java
index d7d86f0..0548b4d 100644
--- a/wifi/java/android/net/wifi/WifiStateMachine.java
+++ b/wifi/java/android/net/wifi/WifiStateMachine.java
@@ -215,6 +215,9 @@
     static final int SUPPLICANT_STATE_CHANGE_EVENT        = 39;
     /* Password may be incorrect */
     static final int PASSWORD_MAY_BE_INCORRECT_EVENT      = 40;
+    /* WPS overlap detected */
+    static final int WPS_OVERLAP_EVENT                    = 41;
+
 
     /* Supplicant commands */
     /* Is supplicant alive ? */
@@ -1287,6 +1290,13 @@
         mContext.sendStickyBroadcast(intent);
     }
 
+    private void sendErrorBroadcast(int errorCode) {
+        Intent intent = new Intent(WifiManager.ERROR_ACTION);
+        intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
+        intent.putExtra(WifiManager.EXTRA_ERROR_CODE, errorCode);
+        mContext.sendBroadcast(intent);
+    }
+
     private void sendLinkConfigurationChangedBroadcast() {
         Intent intent = new Intent(WifiManager.LINK_CONFIGURATION_CHANGED_ACTION);
         intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
@@ -1382,6 +1392,14 @@
     }
 
     /**
+     * Send a notification that the supplicant has detected overlapped
+     * WPS sessions
+     */
+    void notifyWpsOverlap() {
+        sendMessage(WPS_OVERLAP_EVENT);
+    }
+
+    /**
      * Send the tracker a notification that a connection to the supplicant
      * daemon has been established.
      */
@@ -1499,6 +1517,7 @@
                 case SCAN_RESULTS_EVENT:
                 case SUPPLICANT_STATE_CHANGE_EVENT:
                 case PASSWORD_MAY_BE_INCORRECT_EVENT:
+                case WPS_OVERLAP_EVENT:
                 case CMD_BLACKLIST_NETWORK:
                 case CMD_CLEAR_BLACKLIST:
                 case CMD_SET_SCAN_MODE:
@@ -2042,6 +2061,7 @@
                 case NETWORK_CONNECTION_EVENT:
                 case NETWORK_DISCONNECTION_EVENT:
                 case PASSWORD_MAY_BE_INCORRECT_EVENT:
+                case WPS_OVERLAP_EVENT:
                 case CMD_SET_SCAN_TYPE:
                 case CMD_SET_HIGH_PERF_MODE:
                 case CMD_SET_COUNTRY_CODE:
@@ -2276,6 +2296,10 @@
                 case PASSWORD_MAY_BE_INCORRECT_EVENT:
                     mSupplicantStateTracker.sendMessage(PASSWORD_MAY_BE_INCORRECT_EVENT);
                     break;
+                case WPS_OVERLAP_EVENT:
+                    /* We just need to broadcast the error */
+                    sendErrorBroadcast(WifiManager.WPS_OVERLAP_ERROR);
+                    break;
                 case SUPPLICANT_STATE_CHANGE_EVENT:
                     stateChangeResult = (StateChangeResult) message.obj;
                     SupplicantState state = stateChangeResult.state;