Merge "Fix issue 3412777 ANR on adding effects." into honeycomb
diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java
index f91ae9f..fa99eae 100644
--- a/core/java/android/webkit/WebView.java
+++ b/core/java/android/webkit/WebView.java
@@ -7144,6 +7144,16 @@
                     setContentScrollTo(msg.arg1, msg.arg2);
                     break;
                 case SCROLL_TO_MSG_ID:
+                    if (((Boolean) msg.obj).booleanValue()) {
+                        // This scroll is intended to bring the textfield into
+                        // view, but is only necessary if the IME is showing
+                        InputMethodManager imm = InputMethodManager.peekInstance();
+                        if (imm == null || !imm.isAcceptingText()
+                                || (!imm.isActive(WebView.this) && (!inEditingMode()
+                                || !imm.isActive(mWebTextView)))) {
+                            break;
+                        }
+                    }
                     if (setContentScrollTo(msg.arg1, msg.arg2)) {
                         // if we can't scroll to the exact position due to pin,
                         // send a message to WebCore to re-scroll when we get a
diff --git a/core/java/android/webkit/WebViewCore.java b/core/java/android/webkit/WebViewCore.java
index b949a41..5bdf408 100644
--- a/core/java/android/webkit/WebViewCore.java
+++ b/core/java/android/webkit/WebViewCore.java
@@ -2120,7 +2120,7 @@
     }
 
     // called by JNI
-    private void contentScrollTo(int x, int y) {
+    private void contentScrollTo(int x, int y, boolean onlyIfImeIsShowing) {
         if (!mBrowserFrame.firstLayoutDone()) {
             /*
              * WebKit restore state will be called before didFirstLayout(),
@@ -2133,7 +2133,8 @@
         }
         if (mWebView != null) {
             Message msg = Message.obtain(mWebView.mPrivateHandler,
-                    WebView.SCROLL_TO_MSG_ID, x, y);
+                    WebView.SCROLL_TO_MSG_ID, x, y,
+                    Boolean.valueOf(onlyIfImeIsShowing));
             if (mDrawIsScheduled) {
                 mEventHub.sendMessage(Message.obtain(null,
                         EventHub.MESSAGE_RELAY, msg));
diff --git a/core/res/res/layout-xlarge/keyguard_screen_password_landscape.xml b/core/res/res/layout-xlarge/keyguard_screen_password_landscape.xml
index 16bfc31..1783088 100644
--- a/core/res/res/layout-xlarge/keyguard_screen_password_landscape.xml
+++ b/core/res/res/layout-xlarge/keyguard_screen_password_landscape.xml
@@ -61,7 +61,6 @@
                 android:textSize="24sp"
                 android:textAppearance="?android:attr/textAppearanceMedium"
                 android:background="@drawable/lockscreen_password_field_dark"
-                android:hint="@string/keyguard_password_entry_touch_hint"
                 android:textColor="#ffffffff"
                 />
 
diff --git a/core/res/res/layout-xlarge/keyguard_screen_password_portrait.xml b/core/res/res/layout-xlarge/keyguard_screen_password_portrait.xml
index b87b51f..63241dd 100644
--- a/core/res/res/layout-xlarge/keyguard_screen_password_portrait.xml
+++ b/core/res/res/layout-xlarge/keyguard_screen_password_portrait.xml
@@ -57,7 +57,6 @@
             android:layout_marginBottom="5dip"
             android:textAppearance="?android:attr/textAppearanceMedium"
             android:background="@drawable/lockscreen_password_field_dark"
-            android:hint="@string/keyguard_password_entry_touch_hint"
             android:textColor="#ffffffff"
             />
 
diff --git a/docs/html/guide/developing/building/index.jd b/docs/html/guide/developing/building/index.jd
index b001ebc..25a6e23 100644
--- a/docs/html/guide/developing/building/index.jd
+++ b/docs/html/guide/developing/building/index.jd
@@ -37,7 +37,7 @@
   
   <p>The following diagram depicts the components involved in building and running an application:</p>
 
-  <img src="/images/build-simplified.png" />
+  <img src="{@docRoot}images/build-simplified.png" />
 
   <h2 id="detailed-build">A Detailed Look at the Build Process</h2>
 
@@ -49,7 +49,7 @@
   tools and processes are masked from you. The following diagram depicts the different tools and
   processes that are involved in a build:</p>
 
-  <p><img src="/images/build.png" /></p>
+  <p><img src="{@docRoot}images/build.png" /></p>
 
   <p>The general process for a typical build is outlined below:</p>
 
diff --git a/docs/html/guide/developing/debugging/debugging-tracing.jd b/docs/html/guide/developing/debugging/debugging-tracing.jd
index dcc889d..0401966 100644
--- a/docs/html/guide/developing/debugging/debugging-tracing.jd
+++ b/docs/html/guide/developing/debugging/debugging-tracing.jd
@@ -67,7 +67,7 @@
   selected method. The method in this case is <code>LoadListener.nativeFinished()</code> and it was selected in
   the profile view.</p>
 
-  <img src="/images/traceview_timeline.png"
+  <img src="{@docRoot}images/traceview_timeline.png"
        alt="Traceview timeline panel"
        width="893"
        height="284" />
@@ -87,7 +87,7 @@
   <code>LoadListener.nativeFinished();</code> looking at the timeline panel shows that one of those calls took
   an unusually long time.</p>
 
-  <img src="/images/traceview_profile.png"
+  <img src="{@docRoot}images/traceview_profile.png"
        alt="Traceview profile panel."
        width="892"
        height="630" />
diff --git a/docs/html/guide/developing/debugging/index.jd b/docs/html/guide/developing/debugging/index.jd
index f9202ce..1f1a4ca 100644
--- a/docs/html/guide/developing/debugging/index.jd
+++ b/docs/html/guide/developing/debugging/index.jd
@@ -62,7 +62,7 @@
 
   <p>Figure 1 shows how the various debugging tools work together in a typical
   debugging environment.</p>
-  <img src="/images/debugging.png"
+  <img src="{@docRoot}images/debugging.png"
         alt="Debugging workflow" />
   <p class="img-caption><strong>Figure 1. </strong> Debugging Workflow</p>
 
diff --git a/docs/html/guide/developing/devices/emulator.jd b/docs/html/guide/developing/devices/emulator.jd
index a3cd5c5..53c1407 100644
--- a/docs/html/guide/developing/devices/emulator.jd
+++ b/docs/html/guide/developing/devices/emulator.jd
@@ -33,7 +33,7 @@
 </div>
 </div>
 
-<img src="/images/emulator-wvga800l.png" alt="Image of the Android Emulator"
+<img src="{@docRoot}images/emulator-wvga800l.png" alt="Image of the Android Emulator"
 width="367" height="349" style="margin-left:2em;float:right;"/>
 <p>The Android SDK includes a virtual mobile device emulator
 that runs on your computer. The emulator lets you prototype, develop, and test
diff --git a/docs/html/guide/developing/projects/index.jd b/docs/html/guide/developing/projects/index.jd
index 45fd5a1..609a71a 100644
--- a/docs/html/guide/developing/projects/index.jd
+++ b/docs/html/guide/developing/projects/index.jd
@@ -471,7 +471,7 @@
 <code>MyLibrary/src</code>. Eclipse shows an error on one of them because they
 are duplicate links to a single class.</p> 
  
-<img src="/images/developing/lib-migration-0.png" alt=""> 
+<img src="{@docRoot}images/developing/lib-migration-0.png" alt=""> 
 <p class="img-caption"><strong>Figure 1.</strong> Library project migration error</p>
 <p>To fix the error, remove the linked folder that <em>does not</em> contain the
 <code>_src</code> suffix. </p> 
@@ -481,14 +481,14 @@
 <code>MyLibrary</code> folder) and choose <strong>Build Path</strong> &gt;
 <strong>Remove from Build Path</strong>, as shown in figure 2.</li> 
  
-<img src="/images/developing/lib-migration-1.png" style="height:600px"
+<img src="{@docRoot}images/developing/lib-migration-1.png" style="height:600px"
 alt=""> 
 <p class="img-caption"><strong>Figure 2.</strong> Remove from Build Path menu item</p>
  
 <li>Next, when asked about unlinking the folder from the project, select
 <strong>Yes</strong>, as shown in figure 3.</li> 
  
-<img src="/images/developing/lib-migration-2.png" alt=""> 
+<img src="{@docRoot}images/developing/lib-migration-2.png" alt=""> 
 
 <p class="img-caption"><strong>Figure 3.</strong> Unlink folder confirmation window</p>
 </ol> 
diff --git a/docs/html/guide/guide_toc.cs b/docs/html/guide/guide_toc.cs
index 270d153..cf0593c 100644
--- a/docs/html/guide/guide_toc.cs
+++ b/docs/html/guide/guide_toc.cs
@@ -466,34 +466,34 @@
           <li><a href="<?cs var:toroot ?>guide/developing/tools/logcat.html">logcat</a></li>
           <li><a href="<?cs var:toroot ?>guide/developing/tools/mksdcard.html">mksdcard</a></li>
 
-          <li><a href="/guide/developing/tools/monkey.html">Monkey</a></li>
+          <li><a href="<?cs var:toroot ?>guide/developing/tools/monkey.html">Monkey</a></li>
               <li class="toggle-list">
                  <div>
-                     <a href="/guide/developing/tools/monkeyrunner_concepts.html">
+                     <a href="<?cs var:toroot ?>guide/developing/tools/monkeyrunner_concepts.html">
                      <span class="en">monkeyrunner</span>
                   </a>
                   </div>
                   <ul>
                       <li>
-                          <a href="/guide/developing/tools/MonkeyDevice.html">
+                          <a href="<?cs var:toroot ?>guide/developing/tools/MonkeyDevice.html">
                                 <span class="en">MonkeyDevice</span>
                         </a>
                     </li>
                     <li>
-                        <a href="/guide/developing/tools/MonkeyImage.html">
+                        <a href="<?cs var:toroot ?>guide/developing/tools/MonkeyImage.html">
                             <span class="en">MonkeyImage</span>
                         </a>
                     </li>
                     <li>
-                        <a href="/guide/developing/tools/MonkeyRunner.html">
+                        <a href="<?cs var:toroot ?>guide/developing/tools/MonkeyRunner.html">
                             <span class="en">MonkeyRunner</span>
                         </a>
                     </li>
                   </ul>
               </li>
-              <li><a href="/guide/developing/tools/proguard.html">ProGuard</a></li>
-              <li><a href="/guide/developing/tools/adb.html#sqlite">sqlite3</a></li>
-              <li><a href="/guide/developing/tools/traceview.html">Traceview</a></li>
+              <li><a href="<?cs var:toroot ?>guide/developing/tools/proguard.html">ProGuard</a></li>
+              <li><a href="<?cs var:toroot ?>guide/developing/tools/adb.html#sqlite">sqlite3</a></li>
+              <li><a href="<?cs var:toroot ?>guide/developing/tools/traceview.html">Traceview</a></li>
           <li><a href="<?cs var:toroot ?>guide/developing/tools/zipalign.html">zipalign</a></li>
         </ul>
       </li>
diff --git a/services/java/com/android/server/WindowManagerService.java b/services/java/com/android/server/WindowManagerService.java
index 7a3ef14..e1c03d4 100644
--- a/services/java/com/android/server/WindowManagerService.java
+++ b/services/java/com/android/server/WindowManagerService.java
@@ -5101,6 +5101,9 @@
             }
             Binder.restoreCallingIdentity(ident);
 
+            // Constrain frame to the screen size.
+            frame.intersect(0, 0, dw, dh);
+            
             if (frame.isEmpty() || maxLayer == 0) {
                 return null;
             }
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java
index b0f0a43..821e39f 100644
--- a/telephony/java/android/telephony/TelephonyManager.java
+++ b/telephony/java/android/telephony/TelephonyManager.java
@@ -23,6 +23,7 @@
 import android.os.RemoteException;
 import android.os.ServiceManager;
 import android.os.SystemProperties;
+import android.util.Log;
 
 import com.android.internal.telephony.IPhoneSubInfo;
 import com.android.internal.telephony.ITelephony;
@@ -55,14 +56,21 @@
 public class TelephonyManager {
     private static final String TAG = "TelephonyManager";
 
-    private Context mContext;
-    private ITelephonyRegistry mRegistry;
+    private static Context sContext;
+    private static ITelephonyRegistry sRegistry;
 
     /** @hide */
     public TelephonyManager(Context context) {
-        mContext = context;
-        mRegistry = ITelephonyRegistry.Stub.asInterface(ServiceManager.getService(
+        if (sContext == null) {
+            sContext = context;
+
+            sRegistry = ITelephonyRegistry.Stub.asInterface(ServiceManager.getService(
                     "telephony.registry"));
+        } else {
+            Log.e(TAG, "Hidden constructor called more than once per process!");
+            Log.e(TAG, "Original: " + sContext.getPackageName() + ", new: " +
+                    context.getPackageName());
+        }
     }
 
     /** @hide */
@@ -71,7 +79,8 @@
 
     private static TelephonyManager sInstance = new TelephonyManager();
 
-    /** @hide */
+    /** @hide
+    /* @deprecated - use getSystemService as described above */
     public static TelephonyManager getDefault() {
         return sInstance;
     }
@@ -889,10 +898,10 @@
      *               LISTEN_ flags.
      */
     public void listen(PhoneStateListener listener, int events) {
-        String pkgForDebug = mContext != null ? mContext.getPackageName() : "<unknown>";
+        String pkgForDebug = sContext != null ? sContext.getPackageName() : "<unknown>";
         try {
             Boolean notifyNow = (getITelephony() != null);
-            mRegistry.listen(pkgForDebug, listener.callback, events, notifyNow);
+            sRegistry.listen(pkgForDebug, listener.callback, events, notifyNow);
         } catch (RemoteException ex) {
             // system process dead
         } catch (NullPointerException ex) {
@@ -967,7 +976,8 @@
      * @hide pending API review
      */
     public boolean isVoiceCapable() {
-        return mContext.getResources().getBoolean(
+        if (sContext == null) return true;
+        return sContext.getResources().getBoolean(
                 com.android.internal.R.bool.config_voice_capable);
     }
 
@@ -983,7 +993,8 @@
      * @hide pending API review
      */
     public boolean isSmsCapable() {
-        return mContext.getResources().getBoolean(
+        if (sContext == null) return true;
+        return sContext.getResources().getBoolean(
                 com.android.internal.R.bool.config_sms_capable);
     }
 }