diff options
50 files changed, 473 insertions, 171 deletions
diff --git a/api/current.xml b/api/current.xml index 64e5626c1c94..2ebf2ed5edce 100644 --- a/api/current.xml +++ b/api/current.xml @@ -11809,6 +11809,28 @@ visibility="public" > </field> +<field name="dialog_holo_dark_frame" + type="int" + transient="false" + volatile="false" + value="17301682" + static="true" + final="true" + deprecated="not deprecated" + visibility="public" +> +</field> +<field name="dialog_holo_light_frame" + type="int" + transient="false" + volatile="false" + value="17301683" + static="true" + final="true" + deprecated="not deprecated" + visibility="public" +> +</field> <field name="divider_horizontal_bright" type="int" transient="false" @@ -26585,6 +26607,39 @@ <parameter name="viewSpacingBottom" type="int"> </parameter> </method> +<field name="THEME_HOLO_DARK" + type="int" + transient="false" + volatile="false" + value="2" + static="true" + final="true" + deprecated="not deprecated" + visibility="public" +> +</field> +<field name="THEME_HOLO_LIGHT" + type="int" + transient="false" + volatile="false" + value="3" + static="true" + final="true" + deprecated="not deprecated" + visibility="public" +> +</field> +<field name="THEME_TRADITIONAL" + type="int" + transient="false" + volatile="false" + value="1" + static="true" + final="true" + deprecated="not deprecated" + visibility="public" +> +</field> </class> <class name="AlertDialog.Builder" extends="java.lang.Object" diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java index 055984f9fa32..3c45080531ea 100644 --- a/core/java/android/app/Activity.java +++ b/core/java/android/app/Activity.java @@ -4268,7 +4268,7 @@ public class Activity extends ContextThemeWrapper mWindow = PolicyManager.makeNewWindow(this); mWindow.setCallback(this); - mWindow.getLayoutInflater().setFactory2(this); + mWindow.getLayoutInflater().setPrivateFactory(this); if (info.softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED) { mWindow.setSoftInputMode(info.softInputMode); } diff --git a/core/java/android/app/AlertDialog.java b/core/java/android/app/AlertDialog.java index 428f4e3d4b3f..e83d1047ee80 100644 --- a/core/java/android/app/AlertDialog.java +++ b/core/java/android/app/AlertDialog.java @@ -58,29 +58,69 @@ import android.widget.ListView; public class AlertDialog extends Dialog implements DialogInterface { private AlertController mAlert; + /** + * Special theme constant for {@link #AlertDialog(Context, int)}: use + * the traditional (pre-Holo) alert dialog theme. + */ + public static final int THEME_TRADITIONAL = 1; + + /** + * Special theme constant for {@link #AlertDialog(Context, int)}: use + * the holographic alert theme with a dark background. + */ + public static final int THEME_HOLO_DARK = 2; + + /** + * Special theme constant for {@link #AlertDialog(Context, int)}: use + * the holographic alert theme with a light background. + */ + public static final int THEME_HOLO_LIGHT = 3; + protected AlertDialog(Context context) { - this(context, getDefaultDialogTheme(context)); + this(context, resolveDialogTheme(context, 0), true); } + /** + * Construct an AlertDialog that uses an explicit theme. The actual style + * that an AlertDialog uses is a private implementation, however you can + * here supply either the name of an attribute in the theme from which + * to get the dialog's style (such as {@link android.R.attr#alertDialogTheme} + * or one of the constants {@link #THEME_TRADITIONAL}, + * {@link #THEME_HOLO_DARK}, or {@link #THEME_HOLO_LIGHT}. + */ protected AlertDialog(Context context, int theme) { - super(context, theme == 0 ? getDefaultDialogTheme(context) : theme); + this(context, theme, true); + } + + AlertDialog(Context context, int theme, boolean createContextWrapper) { + super(context, resolveDialogTheme(context, theme), createContextWrapper); mWindow.alwaysReadCloseOnTouchAttr(); - mAlert = new AlertController(context, this, getWindow()); + mAlert = new AlertController(getContext(), this, getWindow()); } protected AlertDialog(Context context, boolean cancelable, OnCancelListener cancelListener) { - super(context, getDefaultDialogTheme(context)); + super(context, resolveDialogTheme(context, 0)); mWindow.alwaysReadCloseOnTouchAttr(); setCancelable(cancelable); setOnCancelListener(cancelListener); mAlert = new AlertController(context, this, getWindow()); } - private static int getDefaultDialogTheme(Context context) { - TypedValue outValue = new TypedValue(); - context.getTheme().resolveAttribute(com.android.internal.R.attr.alertDialogTheme, - outValue, true); - return outValue.resourceId; + static int resolveDialogTheme(Context context, int resid) { + if (resid == THEME_TRADITIONAL) { + return com.android.internal.R.style.Theme_Dialog_Alert; + } else if (resid == THEME_HOLO_DARK) { + return com.android.internal.R.style.Theme_Holo_Dialog_Alert; + } else if (resid == THEME_HOLO_LIGHT) { + return com.android.internal.R.style.Theme_Holo_Light_Dialog_Alert; + } else if (resid >= 0x01000000) { // start of real resource IDs. + return resid; + } else { + TypedValue outValue = new TypedValue(); + context.getTheme().resolveAttribute(com.android.internal.R.attr.alertDialogTheme, + outValue, true); + return outValue.resourceId; + } } /** @@ -294,15 +334,23 @@ public class AlertDialog extends Dialog implements DialogInterface { * Constructor using a context for this builder and the {@link AlertDialog} it creates. */ public Builder(Context context) { - this(context, getDefaultDialogTheme(context)); + this(context, resolveDialogTheme(context, 0)); } /** * Constructor using a context and theme for this builder and - * the {@link AlertDialog} it creates. + * the {@link AlertDialog} it creates. The actual theme + * that an AlertDialog uses is a private implementation, however you can + * here supply either the name of an attribute in the theme from which + * to get the dialog's style (such as {@link android.R.attr#alertDialogTheme} + * or one of the constants + * {@link AlertDialog#THEME_TRADITIONAL AlertDialog.THEME_TRADITIONAL}, + * {@link AlertDialog#THEME_HOLO_DARK AlertDialog.THEME_HOLO_DARK}, or + * {@link AlertDialog#THEME_HOLO_LIGHT AlertDialog.THEME_HOLO_LIGHT}. */ public Builder(Context context, int theme) { - P = new AlertController.AlertParams(new ContextThemeWrapper(context, theme)); + P = new AlertController.AlertParams(new ContextThemeWrapper( + context, resolveDialogTheme(context, theme))); mTheme = theme; } @@ -840,7 +888,7 @@ public class AlertDialog extends Dialog implements DialogInterface { * to do and want this to be created and displayed. */ public AlertDialog create() { - final AlertDialog dialog = new AlertDialog(P.mContext, mTheme); + final AlertDialog dialog = new AlertDialog(P.mContext, mTheme, false); P.apply(dialog.mAlert); dialog.setCancelable(P.mCancelable); dialog.setOnCancelListener(P.mOnCancelListener); diff --git a/core/java/android/app/Dialog.java b/core/java/android/app/Dialog.java index f4fa567e28fd..23d4065622ac 100644 --- a/core/java/android/app/Dialog.java +++ b/core/java/android/app/Dialog.java @@ -119,7 +119,7 @@ public class Dialog implements DialogInterface, Window.Callback, * present its UI. */ public Dialog(Context context) { - this(context, 0); + this(context, 0, true); } /** @@ -135,6 +135,10 @@ public class Dialog implements DialogInterface, Window.Callback, * <var>context</var>. If 0, the default dialog theme will be used. */ public Dialog(Context context, int theme) { + this(context, theme, true); + } + + Dialog(Context context, int theme, boolean createContextWrapper) { if (theme == 0) { TypedValue outValue = new TypedValue(); context.getTheme().resolveAttribute(com.android.internal.R.attr.dialogTheme, @@ -142,7 +146,7 @@ public class Dialog implements DialogInterface, Window.Callback, theme = outValue.resourceId; } - mContext = new ContextThemeWrapper(context, theme); + mContext = createContextWrapper ? new ContextThemeWrapper(context, theme) : context; mWindowManager = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE); Window w = PolicyManager.makeNewWindow(mContext); mWindow = w; @@ -152,7 +156,7 @@ public class Dialog implements DialogInterface, Window.Callback, mUiThread = Thread.currentThread(); mListenersHandler = new ListenersHandler(this); } - + /** * @deprecated * @hide diff --git a/core/java/android/view/LayoutInflater.java b/core/java/android/view/LayoutInflater.java index d24af52303d8..a17ed9d1ad0d 100644 --- a/core/java/android/view/LayoutInflater.java +++ b/core/java/android/view/LayoutInflater.java @@ -68,6 +68,7 @@ public abstract class LayoutInflater { private boolean mFactorySet; private Factory mFactory; private Factory2 mFactory2; + private Factory2 mPrivateFactory; private Filter mFilter; private final Object[] mConstructorArgs = new Object[2]; @@ -193,6 +194,7 @@ public abstract class LayoutInflater { mContext = newContext; mFactory = original.mFactory; mFactory2 = original.mFactory2; + mPrivateFactory = original.mPrivateFactory; mFilter = original.mFilter; } @@ -300,6 +302,13 @@ public abstract class LayoutInflater { } /** + * @hide for use by framework + */ + public void setPrivateFactory(Factory2 factory) { + mPrivateFactory = factory; + } + + /** * @return The {@link Filter} currently used by this LayoutInflater to restrict the set of Views * that are allowed to be inflated. */ @@ -651,6 +660,10 @@ public abstract class LayoutInflater { else if (mFactory != null) view = mFactory.onCreateView(name, mContext, attrs); else view = null; + if (view == null && mPrivateFactory != null) { + view = mPrivateFactory.onCreateView(parent, name, mContext, attrs); + } + if (view == null) { if (-1 == name.indexOf('.')) { view = onCreateView(parent, name, attrs); diff --git a/core/java/android/view/ViewRoot.java b/core/java/android/view/ViewRoot.java index b21af410b306..b1d509acfe79 100644 --- a/core/java/android/view/ViewRoot.java +++ b/core/java/android/view/ViewRoot.java @@ -1551,11 +1551,13 @@ public final class ViewRoot extends Handler implements ViewParent, Log.e(TAG, "OutOfResourcesException locking surface", e); // TODO: we should ask the window manager to do something! // for now we just do nothing + mLayoutRequested = true; // ask wm for a new surface next time. return; } catch (IllegalArgumentException e) { Log.e(TAG, "IllegalArgumentException locking surface", e); // TODO: we should ask the window manager to do something! // for now we just do nothing + mLayoutRequested = true; // ask wm for a new surface next time. return; } diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java index 63632996bc99..790a04023330 100644 --- a/core/java/android/webkit/WebView.java +++ b/core/java/android/webkit/WebView.java @@ -350,6 +350,7 @@ public class WebView extends AbsoluteLayout private ZoomManager mZoomManager; private Rect mGLRectViewport = new Rect(); + private boolean mGLViewportEmpty = false; /** * Transportation object for returning WebView across thread boundaries. @@ -3734,6 +3735,10 @@ public class WebView extends AbsoluteLayout return; } + if (canvas.isHardwareAccelerated()) { + mZoomManager.setHardwareAccelerated(); + } + int saveCount = canvas.save(); if (mInOverScrollMode && !getSettings() .getUseWebViewBackgroundForOverscrollBackground()) { @@ -4071,7 +4076,8 @@ public class WebView extends AbsoluteLayout } if (canvas.isHardwareAccelerated()) { - int functor = nativeGetDrawGLFunction(mGLRectViewport, getScale(), extras); + int functor = nativeGetDrawGLFunction(mGLViewportEmpty ? null : mGLRectViewport, + getScale(), extras); ((HardwareCanvas) canvas).callDrawGLFunction(functor); } else { DrawFilter df = null; @@ -5155,16 +5161,21 @@ public class WebView extends AbsoluteLayout void setGLRectViewport() { // Use the getGlobalVisibleRect() to get the intersection among the parents - getGlobalVisibleRect(mGLRectViewport); - - // Then need to invert the Y axis, just for GL - View rootView = getRootView(); - int rootViewHeight = rootView.getHeight(); - int savedWebViewBottom = mGLRectViewport.bottom; - mGLRectViewport.bottom = rootViewHeight - mGLRectViewport.top - getVisibleTitleHeight(); - mGLRectViewport.top = rootViewHeight - savedWebViewBottom; - - nativeUpdateDrawGLFunction(mGLRectViewport); + // visible == false means we're clipped - send a null rect down to indicate that + // we should not draw + boolean visible = getGlobalVisibleRect(mGLRectViewport); + if (visible) { + // Then need to invert the Y axis, just for GL + View rootView = getRootView(); + int rootViewHeight = rootView.getHeight(); + int savedWebViewBottom = mGLRectViewport.bottom; + mGLRectViewport.bottom = rootViewHeight - mGLRectViewport.top - getVisibleTitleHeight(); + mGLRectViewport.top = rootViewHeight - savedWebViewBottom; + mGLViewportEmpty = false; + } else { + mGLViewportEmpty = true; + } + nativeUpdateDrawGLFunction(mGLViewportEmpty ? null : mGLRectViewport); } /** @@ -6824,7 +6835,7 @@ public class WebView extends AbsoluteLayout previouslyFocusedRect); } else { result = super.requestFocus(direction, previouslyFocusedRect); - if (mWebViewCore.getSettings().getNeedInitialFocus()) { + if (mWebViewCore.getSettings().getNeedInitialFocus() && !isInTouchMode()) { // For cases such as GMail, where we gain focus from a direction, // we want to move to the first available link. // FIXME: If there are no visible links, we may not want to diff --git a/core/java/android/webkit/ZoomManager.java b/core/java/android/webkit/ZoomManager.java index b47fe86ec6ce..efbcd5811db8 100644 --- a/core/java/android/webkit/ZoomManager.java +++ b/core/java/android/webkit/ZoomManager.java @@ -183,6 +183,9 @@ class ZoomManager { private ScaleGestureDetector mScaleDetector; private boolean mPinchToZoomAnimating = false; + private boolean mHardwareAccelerated = false; + private boolean mInHWAcceleratedZoom = false; + public ZoomManager(WebView webView, CallbackProxy callbackProxy) { mWebView = webView; mCallbackProxy = callbackProxy; @@ -384,6 +387,10 @@ class ZoomManager { scale = getReadingLevelScale(); } + if (mHardwareAccelerated) { + mInHWAcceleratedZoom = true; + } + setZoomScale(scale, reflowText); if (oldScale != mActualScale) { @@ -447,8 +454,18 @@ class ZoomManager { - titleHeight, mWebView.getViewHeight(), Math.round(mWebView.getContentHeight() * zoomScale)) + titleHeight) + mWebView.getScrollY(); - canvas.translate(tx, ty); - canvas.scale(zoomScale, zoomScale); + if (mHardwareAccelerated) { + mWebView.updateScrollCoordinates(mWebView.getScrollX() - tx, mWebView.getScrollY() - ty); + setZoomScale(zoomScale, false); + + if (mZoomScale == 0) { + // We've reached the end of the zoom animation. + mInHWAcceleratedZoom = false; + } + } else { + canvas.translate(tx, ty); + canvas.scale(zoomScale, zoomScale); + } } public boolean isZoomAnimating() { @@ -493,12 +510,14 @@ class ZoomManager { mActualScale = scale; mInvActualScale = 1 / scale; - if (!mWebView.drawHistory()) { + if (!mWebView.drawHistory() && !mInHWAcceleratedZoom) { // If history Picture is drawn, don't update scroll. They will // be updated when we get out of that mode. // update our scroll so we don't appear to jump // i.e. keep the center of the doc in the center of the view + // If this is part of a zoom on a HW accelerated canvas, we + // have already updated the scroll so don't do it again. int oldX = mWebView.getScrollX(); int oldY = mWebView.getScrollY(); float ratio = scale * oldInvScale; @@ -1020,4 +1039,8 @@ class ZoomManager { return null; } } + + public void setHardwareAccelerated() { + mHardwareAccelerated = true; + } } diff --git a/core/res/res/drawable-hdpi/stat_notify_chat.png b/core/res/res/drawable-hdpi/stat_notify_chat.png Binary files differindex b2e65c627380..9c713c8f2738 100644 --- a/core/res/res/drawable-hdpi/stat_notify_chat.png +++ b/core/res/res/drawable-hdpi/stat_notify_chat.png diff --git a/core/res/res/drawable-mdpi/stat_notify_chat.png b/core/res/res/drawable-mdpi/stat_notify_chat.png Binary files differindex f98b032bcc4b..91b429008ef6 100644 --- a/core/res/res/drawable-mdpi/stat_notify_chat.png +++ b/core/res/res/drawable-mdpi/stat_notify_chat.png diff --git a/core/res/res/drawable-xlarge-hdpi/stat_notify_chat.png b/core/res/res/drawable-xlarge-hdpi/stat_notify_chat.png Binary files differindex e936faceda63..8cc5535c21e1 100644 --- a/core/res/res/drawable-xlarge-hdpi/stat_notify_chat.png +++ b/core/res/res/drawable-xlarge-hdpi/stat_notify_chat.png diff --git a/core/res/res/drawable-xlarge-hdpi/stat_notify_disk_full.png b/core/res/res/drawable-xlarge-hdpi/stat_notify_disk_full.png Binary files differindex eb626df39878..4441ba20b86a 100644 --- a/core/res/res/drawable-xlarge-hdpi/stat_notify_disk_full.png +++ b/core/res/res/drawable-xlarge-hdpi/stat_notify_disk_full.png diff --git a/core/res/res/drawable-xlarge-hdpi/stat_notify_email_generic.png b/core/res/res/drawable-xlarge-hdpi/stat_notify_email_generic.png Binary files differindex d6bc7d30cddb..73891a387641 100644 --- a/core/res/res/drawable-xlarge-hdpi/stat_notify_email_generic.png +++ b/core/res/res/drawable-xlarge-hdpi/stat_notify_email_generic.png diff --git a/core/res/res/drawable-xlarge-hdpi/stat_notify_error.png b/core/res/res/drawable-xlarge-hdpi/stat_notify_error.png Binary files differindex 8c8f25dbc171..db68eeae3357 100644 --- a/core/res/res/drawable-xlarge-hdpi/stat_notify_error.png +++ b/core/res/res/drawable-xlarge-hdpi/stat_notify_error.png diff --git a/core/res/res/drawable-xlarge-hdpi/stat_notify_gmail.png b/core/res/res/drawable-xlarge-hdpi/stat_notify_gmail.png Binary files differindex 661cc2ff47b8..7af6921a84f1 100644 --- a/core/res/res/drawable-xlarge-hdpi/stat_notify_gmail.png +++ b/core/res/res/drawable-xlarge-hdpi/stat_notify_gmail.png diff --git a/core/res/res/drawable-xlarge-mdpi/stat_notify_chat.png b/core/res/res/drawable-xlarge-mdpi/stat_notify_chat.png Binary files differindex b2d71862c8cc..22adc672d9d2 100644 --- a/core/res/res/drawable-xlarge-mdpi/stat_notify_chat.png +++ b/core/res/res/drawable-xlarge-mdpi/stat_notify_chat.png diff --git a/core/res/res/drawable-xlarge-mdpi/stat_notify_disk_full.png b/core/res/res/drawable-xlarge-mdpi/stat_notify_disk_full.png Binary files differindex 36ab1ff76f47..c434d12449bf 100644 --- a/core/res/res/drawable-xlarge-mdpi/stat_notify_disk_full.png +++ b/core/res/res/drawable-xlarge-mdpi/stat_notify_disk_full.png diff --git a/core/res/res/drawable-xlarge-mdpi/stat_notify_email_generic.png b/core/res/res/drawable-xlarge-mdpi/stat_notify_email_generic.png Binary files differindex a14b3c7d0e7c..daf3b84fb413 100644 --- a/core/res/res/drawable-xlarge-mdpi/stat_notify_email_generic.png +++ b/core/res/res/drawable-xlarge-mdpi/stat_notify_email_generic.png diff --git a/core/res/res/drawable-xlarge-mdpi/stat_notify_error.png b/core/res/res/drawable-xlarge-mdpi/stat_notify_error.png Binary files differindex 81a66c112876..7b097b157d10 100644 --- a/core/res/res/drawable-xlarge-mdpi/stat_notify_error.png +++ b/core/res/res/drawable-xlarge-mdpi/stat_notify_error.png diff --git a/core/res/res/drawable-xlarge-mdpi/stat_notify_gmail.png b/core/res/res/drawable-xlarge-mdpi/stat_notify_gmail.png Binary files differindex a286ac611169..8daef7cbbe08 100644 --- a/core/res/res/drawable-xlarge-mdpi/stat_notify_gmail.png +++ b/core/res/res/drawable-xlarge-mdpi/stat_notify_gmail.png diff --git a/core/res/res/layout-xlarge/status_bar_latest_event_content_large_icon.xml b/core/res/res/layout-xlarge/status_bar_latest_event_content_large_icon.xml index e9b106d8654b..fcbdf6d16a48 100644 --- a/core/res/res/layout-xlarge/status_bar_latest_event_content_large_icon.xml +++ b/core/res/res/layout-xlarge/status_bar_latest_event_content_large_icon.xml @@ -30,27 +30,21 @@ android:fadingEdge="horizontal" /> </LinearLayout> - <RelativeLayout + <TextView android:id="@+id/info" + android:textAppearance="@style/TextAppearance.StatusBar.EventContent.Info" android:layout_width="wrap_content" android:layout_height="match_parent" - > - <TextView android:id="@+id/info" - android:textAppearance="@style/TextAppearance.StatusBar.EventContent.Info" - android:layout_width="wrap_content" - android:layout_height="match_parent" - android:singleLine="true" - android:gravity="center_vertical" - android:layout_alignParentLeft="true" - android:paddingLeft="8dp" - /> - <ImageView android:id="@+id/icon" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_alignParentBottom="true" - android:layout_alignRight="@id/info" - android:layout_marginBottom="8dip" - android:scaleType="center" - /> - </RelativeLayout> + android:singleLine="true" + android:gravity="center_vertical" + android:paddingLeft="4dp" + android:paddingRight="4dp" + /> + <ImageView android:id="@+id/icon" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="bottom" + android:layout_marginBottom="13dip" + android:scaleType="center" + /> </LinearLayout> diff --git a/core/res/res/layout-xlarge/status_bar_latest_event_ticker_large_icon.xml b/core/res/res/layout-xlarge/status_bar_latest_event_ticker_large_icon.xml index b382c554d2d9..ff0f7d44e637 100644 --- a/core/res/res/layout-xlarge/status_bar_latest_event_ticker_large_icon.xml +++ b/core/res/res/layout-xlarge/status_bar_latest_event_ticker_large_icon.xml @@ -37,11 +37,13 @@ android:layout_marginTop="-10dp" /> <ImageView android:id="@+id/icon" - android:layout_width="48dp" - android:layout_height="32dp" - android:layout_gravity="top" - android:layout_marginTop="6dp" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="bottom" + android:layout_marginBottom="13dip" android:scaleType="center" + android:layout_marginRight="4dip" + android:layout_marginLeft="16dip" /> </LinearLayout> diff --git a/core/res/res/values/colors.xml b/core/res/res/values/colors.xml index ff9ef59fe215..9c59cb6eca9c 100644 --- a/core/res/res/values/colors.xml +++ b/core/res/res/values/colors.xml @@ -72,6 +72,9 @@ <drawable name="editbox_dropdown_dark_frame">@drawable/editbox_dropdown_background_dark</drawable> <drawable name="editbox_dropdown_light_frame">@drawable/editbox_dropdown_background</drawable> + <drawable name="dialog_holo_dark_frame">@drawable/dialog_full_holo_dark</drawable> + <drawable name="dialog_holo_light_frame">@drawable/dialog_full_holo_light</drawable> + <drawable name="input_method_fullscreen_background">#fff9f9f9</drawable> <!-- For date picker widget --> diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml index ae269dfbd390..957707d49a68 100644 --- a/core/res/res/values/public.xml +++ b/core/res/res/values/public.xml @@ -1496,6 +1496,9 @@ a ListView). --> <public type="layout" name="simple_list_item_activated_2" /> + <public type="drawable" name="dialog_holo_dark_frame" /> + <public type="drawable" name="dialog_holo_light_frame" /> + <public type="style" name="Theme.WithActionBar" /> <public type="style" name="Theme.NoTitleBar.OverlayActionModes" /> diff --git a/graphics/java/android/graphics/Paint.java b/graphics/java/android/graphics/Paint.java index b739d838ca9d..d8a7f9d57c7a 100644 --- a/graphics/java/android/graphics/Paint.java +++ b/graphics/java/android/graphics/Paint.java @@ -1690,7 +1690,7 @@ public class Paint { int contextLen = contextEnd - contextStart; char[] buf = TemporaryBuffer.obtain(contextLen); TextUtils.getChars(text, contextStart, contextEnd, buf, 0); - int result = getTextRunCursor(buf, 0, contextLen, flags, offset, cursorOpt); + int result = getTextRunCursor(buf, 0, contextLen, flags, offset - contextStart, cursorOpt); TemporaryBuffer.recycle(buf); return result; } diff --git a/graphics/java/android/graphics/SurfaceTexture.java b/graphics/java/android/graphics/SurfaceTexture.java index 64c209a38801..4c659d4dc98c 100644 --- a/graphics/java/android/graphics/SurfaceTexture.java +++ b/graphics/java/android/graphics/SurfaceTexture.java @@ -24,9 +24,9 @@ import android.os.Message; /** * Captures frames from an image stream as an OpenGL ES texture. * - * <p>The image stream may come from either video playback or camera preview. A SurfaceTexture may - * be used in place of a SurfaceHolder when specifying the output destination of a MediaPlayer or - * Camera object. This will cause all the frames from that image stream to be sent to the + * <p>The image stream may come from either camera preview. A SurfaceTexture may be used in place + * of a SurfaceHolder when specifying the output destination of a {@link android.hardware.Camera} + * object. Doing so will cause all the frames from the image stream to be sent to the * SurfaceTexture object rather than to the device's display. When {@link #updateTexImage} is * called, the contents of the texture object specified when the SurfaceTexture was created is * updated to contain the most recent image from the image stream. This may cause some frames of @@ -34,6 +34,11 @@ import android.os.Message; * * <p>The texture object uses the GL_TEXTURE_EXTERNAL_OES texture target, which is defined by the * OES_EGL_image_external OpenGL ES extension. This limits how the texture may be used. + * + * <p>SurfaceTexture objects may be created on any thread. {@link #updateTexImage} may only be + * called on the thread with the OpenGL ES context that contains the texture object. The + * frame-available callback is called on an arbitrary thread, so unless special care is taken {@link + * #updateTexImage} should not be called directly from the callback. */ public class SurfaceTexture { diff --git a/libs/hwui/OpenGLDebugRenderer.cpp b/libs/hwui/OpenGLDebugRenderer.cpp index 58d6c26940c7..05870bb2e07e 100644 --- a/libs/hwui/OpenGLDebugRenderer.cpp +++ b/libs/hwui/OpenGLDebugRenderer.cpp @@ -23,10 +23,11 @@ namespace android { namespace uirenderer { -void OpenGLDebugRenderer::prepare(bool opaque) { +void OpenGLDebugRenderer::prepareDirty(float left, float top, + float right, float bottom, bool opaque) { mPrimitivesCount = 0; LOGD("========= Frame start ========="); - OpenGLRenderer::prepare(opaque); + OpenGLRenderer::prepareDirty(left, top, right, bottom, opaque); } void OpenGLDebugRenderer::finish() { @@ -105,6 +106,33 @@ void OpenGLDebugRenderer::drawRect(float left, float top, float right, float bot OpenGLRenderer::drawRect(left, top, right, bottom, paint); } +void OpenGLDebugRenderer::drawRoundRect(float left, float top, float right, float bottom, + float rx, float ry, SkPaint* paint) { + mPrimitivesCount++; + StopWatch w("drawRoundRect"); + OpenGLRenderer::drawRoundRect(left, top, right, bottom, rx, ry, paint); +} + +void OpenGLDebugRenderer::drawCircle(float x, float y, float radius, SkPaint* paint) { + mPrimitivesCount++; + StopWatch w("drawCircle"); + OpenGLRenderer::drawCircle(x, y, radius, paint); +} + +void OpenGLDebugRenderer::drawOval(float left, float top, float right, float bottom, + SkPaint* paint) { + mPrimitivesCount++; + StopWatch w("drawOval"); + OpenGLRenderer::drawOval(left, top, right, bottom, paint); +} + +void OpenGLDebugRenderer::drawArc(float left, float top, float right, float bottom, + float startAngle, float sweepAngle, bool useCenter, SkPaint* paint) { + mPrimitivesCount++; + StopWatch w("drawArc"); + OpenGLRenderer::drawArc(left, top, right, bottom, startAngle, sweepAngle, useCenter, paint); +} + void OpenGLDebugRenderer::drawPath(SkPath* path, SkPaint* paint) { mPrimitivesCount++; StopWatch w("drawPath"); diff --git a/libs/hwui/OpenGLDebugRenderer.h b/libs/hwui/OpenGLDebugRenderer.h index 76e6a2e90b0f..1a18a6727f9f 100644 --- a/libs/hwui/OpenGLDebugRenderer.h +++ b/libs/hwui/OpenGLDebugRenderer.h @@ -34,7 +34,7 @@ public: ~OpenGLDebugRenderer() { } - void prepare(bool opaque); + void prepareDirty(float left, float top, float right, float bottom, bool opaque); void finish(); int saveLayer(float left, float top, float right, float bottom, @@ -52,6 +52,12 @@ public: float left, float top, float right, float bottom, SkPaint* paint); void drawColor(int color, SkXfermode::Mode mode); void drawRect(float left, float top, float right, float bottom, SkPaint* paint); + void drawRoundRect(float left, float top, float right, float bottom, + float rx, float ry, SkPaint* paint); + void drawCircle(float x, float y, float radius, SkPaint* paint); + void drawOval(float left, float top, float right, float bottom, SkPaint* paint); + void drawArc(float left, float top, float right, float bottom, + float startAngle, float sweepAngle, bool useCenter, SkPaint* paint); void drawPath(SkPath* path, SkPaint* paint); void drawLines(float* points, int count, SkPaint* paint); void drawText(const char* text, int bytesCount, int count, float x, float y, diff --git a/libs/rs/rsLocklessFifo.cpp b/libs/rs/rsLocklessFifo.cpp index 3f8854330acf..70b72783863e 100644 --- a/libs/rs/rsLocklessFifo.cpp +++ b/libs/rs/rsLocklessFifo.cpp @@ -100,7 +100,9 @@ void LocklessCommandFifo::commit(uint32_t command, uint32_t sizeInBytes) { //dumpState("commit 1"); reinterpret_cast<uint16_t *>(mPut)[0] = command; reinterpret_cast<uint16_t *>(mPut)[1] = sizeInBytes; - mPut += ((sizeInBytes + 3) & ~3) + 4; + + int32_t s = ((sizeInBytes + 3) & ~3) + 4; + android_atomic_add(s, (int32_t *)&mPut); //dumpState("commit 2"); mSignalToWorker.set(); } diff --git a/libs/utils/ResourceTypes.cpp b/libs/utils/ResourceTypes.cpp index bbf50934df92..73ff2302d917 100644 --- a/libs/utils/ResourceTypes.cpp +++ b/libs/utils/ResourceTypes.cpp @@ -3703,9 +3703,9 @@ void ResTable::getConfigurations(Vector<ResTable_config>* configs) const void ResTable::getLocales(Vector<String8>* locales) const { Vector<ResTable_config> configs; - LOGD("calling getConfigurations"); + LOGV("calling getConfigurations"); getConfigurations(&configs); - LOGD("called getConfigurations size=%d", (int)configs.size()); + LOGV("called getConfigurations size=%d", (int)configs.size()); const size_t I = configs.size(); for (size_t i=0; i<I; i++) { char locale[6]; diff --git a/media/libstagefright/AwesomePlayer.cpp b/media/libstagefright/AwesomePlayer.cpp index 11ac56ce296e..89b3dab46d73 100644 --- a/media/libstagefright/AwesomePlayer.cpp +++ b/media/libstagefright/AwesomePlayer.cpp @@ -378,14 +378,11 @@ status_t AwesomePlayer::setDataSource_l(const sp<MediaExtractor> &extractor) { } void AwesomePlayer::reset() { - LOGI("reset"); - Mutex::Autolock autoLock(mLock); reset_l(); } void AwesomePlayer::reset_l() { - LOGI("reset_l"); mDisplayWidth = 0; mDisplayHeight = 0; @@ -411,10 +408,6 @@ void AwesomePlayer::reset_l() { } } - if (mFlags & PREPARING) { - LOGI("waiting until preparation is completes."); - } - while (mFlags & PREPARING) { mPreparedCondition.wait(mLock); } @@ -438,8 +431,6 @@ void AwesomePlayer::reset_l() { } mAudioSource.clear(); - LOGI("audio source cleared"); - mTimeSource = NULL; delete mAudioPlayer; @@ -480,8 +471,6 @@ void AwesomePlayer::reset_l() { IPCThreadState::self()->flushCommands(); } - LOGI("video source cleared"); - mDurationUs = -1; mFlags = 0; mExtractorFlags = 0; @@ -498,8 +487,6 @@ void AwesomePlayer::reset_l() { mFileSource.clear(); mBitrate = -1; - - LOGI("reset_l completed"); } void AwesomePlayer::notifyListener_l(int msg, int ext1, int ext2) { diff --git a/media/libstagefright/rtsp/ASessionDescription.cpp b/media/libstagefright/rtsp/ASessionDescription.cpp index 77917b3a793d..3e710dc4a7b3 100644 --- a/media/libstagefright/rtsp/ASessionDescription.cpp +++ b/media/libstagefright/rtsp/ASessionDescription.cpp @@ -254,26 +254,12 @@ bool ASessionDescription::getDurationUs(int64_t *durationUs) const { return false; } - if (value == "npt=now-" || value == "npt=0-") { - return false; - } - if (strncmp(value.c_str(), "npt=", 4)) { return false; } - const char *s = value.c_str() + 4; - char *end; - double from = strtod(s, &end); - - if (end == s || *end != '-') { - return false; - } - - s = end + 1; - double to = strtod(s, &end); - - if (end == s || *end != '\0' || to < from) { + float from, to; + if (!parseNTPRange(value.c_str() + 4, &from, &to)) { return false; } @@ -307,5 +293,39 @@ void ASessionDescription::ParseFormatDesc( } } +// static +bool ASessionDescription::parseNTPRange( + const char *s, float *npt1, float *npt2) { + if (s[0] == '-') { + return false; // no start time available. + } + + if (!strncmp("now", s, 3)) { + return false; // no absolute start time available + } + + char *end; + *npt1 = strtof(s, &end); + + if (end == s || *end != '-') { + // Failed to parse float or trailing "dash". + return false; + } + + s = end + 1; // skip the dash. + + if (!strncmp("now", s, 3)) { + return false; // no absolute end time available + } + + *npt2 = strtof(s, &end); + + if (end == s || *end != '\0') { + return false; + } + + return *npt2 > *npt1; +} + } // namespace android diff --git a/media/libstagefright/rtsp/ASessionDescription.h b/media/libstagefright/rtsp/ASessionDescription.h index a3fa79ed5a00..b4629834b68d 100644 --- a/media/libstagefright/rtsp/ASessionDescription.h +++ b/media/libstagefright/rtsp/ASessionDescription.h @@ -55,6 +55,14 @@ struct ASessionDescription : public RefBase { bool findAttribute(size_t index, const char *key, AString *value) const; + // parses strings of the form + // npt := npt-time "-" npt-time? | "-" npt-time + // npt-time := "now" | [0-9]+("." [0-9]*)? + // + // Returns true iff both "npt1" and "npt2" times were available, + // i.e. we have a fixed duration, otherwise this is live streaming. + static bool parseNTPRange(const char *s, float *npt1, float *npt2); + protected: virtual ~ASessionDescription(); diff --git a/media/libstagefright/rtsp/MyHandler.h b/media/libstagefright/rtsp/MyHandler.h index 9bb8c46453b0..306a9c1c260b 100644 --- a/media/libstagefright/rtsp/MyHandler.h +++ b/media/libstagefright/rtsp/MyHandler.h @@ -938,13 +938,11 @@ struct MyHandler : public AHandler { AString val; CHECK(GetAttribute(range.c_str(), "npt", &val)); - float npt1, npt2; - if (val == "now-" || val == "0-") { + float npt1, npt2; + if (!ASessionDescription::parseNTPRange(val.c_str(), &npt1, &npt2)) { // This is a live stream and therefore not seekable. return; - } else { - CHECK_EQ(sscanf(val.c_str(), "%f-%f", &npt1, &npt2), 2); } i = response->mHeaders.indexOfKey("rtp-info"); diff --git a/packages/SystemUI/res/layout-xlarge/status_bar_notification_row.xml b/packages/SystemUI/res/layout-xlarge/status_bar_notification_row.xml index 0f3f5f0afb10..8e456b2d701f 100644 --- a/packages/SystemUI/res/layout-xlarge/status_bar_notification_row.xml +++ b/packages/SystemUI/res/layout-xlarge/status_bar_notification_row.xml @@ -27,7 +27,7 @@ <com.android.systemui.statusbar.LatestItemView android:id="@+id/content" android:layout_width="match_parent" - android:layout_height="64sp" + android:layout_height="64dp" android:layout_alignParentTop="true" android:layout_toRightOf="@id/large_icon" android:layout_toLeftOf="@id/veto" diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java index fd044187c4a6..6c8a20d57329 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java @@ -98,8 +98,6 @@ public class TabletStatusBar extends StatusBar implements // Fitts' Law assistance for LatinIME; TODO: replace with a more general approach private static final boolean FAKE_SPACE_BAR = true; - public static final int LIGHTS_ON_DELAY = 5000; - // The height of the bar, as definied by the build. It may be taller if we're plugged // into hdmi. int mNaturalBarHeight = -1; @@ -392,6 +390,12 @@ public class TabletStatusBar extends StatusBar implements new View.OnTouchListener() { public boolean onTouch(View v, MotionEvent ev) { if (ev.getAction() == MotionEvent.ACTION_DOWN) { + // even though setting the systemUI visibility below will turn these views + // on, we need them to come up faster so that they can catch this motion + // event + mShadow.setVisibility(View.GONE); + mBarContents.setVisibility(View.VISIBLE); + try { mBarService.setSystemUiVisibility(View.STATUS_BAR_VISIBLE); } catch (RemoteException ex) { diff --git a/services/java/com/android/server/WindowManagerService.java b/services/java/com/android/server/WindowManagerService.java index 30a94327719b..faaa28d7e2d1 100644 --- a/services/java/com/android/server/WindowManagerService.java +++ b/services/java/com/android/server/WindowManagerService.java @@ -1315,7 +1315,20 @@ public class WindowManagerService extends IWindowManager.Stub static boolean canBeImeTarget(WindowState w) { final int fl = w.mAttrs.flags & (FLAG_NOT_FOCUSABLE|FLAG_ALT_FOCUSABLE_IM); - if (fl == 0 || fl == (FLAG_NOT_FOCUSABLE|FLAG_ALT_FOCUSABLE_IM)) { + if (fl == 0 || fl == (FLAG_NOT_FOCUSABLE|FLAG_ALT_FOCUSABLE_IM) + || w.mAttrs.type == WindowManager.LayoutParams.TYPE_APPLICATION_STARTING) { + if (DEBUG_INPUT_METHOD) { + Slog.i(TAG, "isVisibleOrAdding " + w + ": " + w.isVisibleOrAdding()); + if (!w.isVisibleOrAdding()) { + Slog.i(TAG, " mSurface=" + w.mSurface + " reportDestroy=" + w.mReportDestroySurface + + " relayoutCalled=" + w.mRelayoutCalled + " viewVis=" + w.mViewVisibility + + " policyVis=" + w.mPolicyVisibility + " attachHid=" + w.mAttachedHidden + + " exiting=" + w.mExiting + " destroying=" + w.mDestroying); + if (w.mAppToken != null) { + Slog.i(TAG, " mAppToken.hiddenRequested=" + w.mAppToken.hiddenRequested); + } + } + } return w.isVisibleOrAdding(); } return false; @@ -1330,8 +1343,8 @@ public class WindowManagerService extends IWindowManager.Stub i--; w = localmWindows.get(i); - //Slog.i(TAG, "Checking window @" + i + " " + w + " fl=0x" - // + Integer.toHexString(w.mAttrs.flags)); + if (DEBUG_INPUT_METHOD && willMove) Slog.i(TAG, "Checking window @" + i + + " " + w + " fl=0x" + Integer.toHexString(w.mAttrs.flags)); if (canBeImeTarget(w)) { //Slog.i(TAG, "Putting input method here!"); @@ -1353,6 +1366,8 @@ public class WindowManagerService extends IWindowManager.Stub } } + if (DEBUG_INPUT_METHOD && willMove) Slog.v(TAG, "Proposed new IME target: " + w); + // Now, a special case -- if the last target's window is in the // process of exiting, and is above the new target, keep on the // last target to avoid flicker. Consider for example a Dialog with @@ -1365,6 +1380,7 @@ public class WindowManagerService extends IWindowManager.Stub if (mInputMethodTarget.mAnimLayer > w.mAnimLayer) { w = mInputMethodTarget; i = localmWindows.indexOf(w); + if (DEBUG_INPUT_METHOD) Slog.v(TAG, "Current target higher, switching to: " + w); } } @@ -1420,6 +1436,7 @@ public class WindowManagerService extends IWindowManager.Stub // with an animation, and it is on top of the next target // we will be over, then hold off on moving until // that is done. + mInputMethodTargetWaitingAnim = true; mInputMethodTarget = highestTarget; return highestPos + 1; } @@ -1440,6 +1457,7 @@ public class WindowManagerService extends IWindowManager.Stub + mInputMethodTarget + " to " + w, e); } mInputMethodTarget = w; + mInputMethodTargetWaitingAnim = false; if (w.mAppToken != null) { setInputMethodAnimLayerAdjustment(w.mAppToken.animLayerAdjustment); } else { @@ -8539,7 +8557,7 @@ public class WindowManagerService extends IWindowManager.Stub w.mAnimLayer = w.mLayer + adj; if (DEBUG_LAYERS) Slog.v(TAG, "Updating layer " + w + ": " + w.mAnimLayer); - if (w == mInputMethodTarget) { + if (w == mInputMethodTarget && !mInputMethodTargetWaitingAnim) { setInputMethodAnimLayerAdjustment(adj); } if (w == mWallpaperTarget && mLowerWallpaperTarget == null) { @@ -8630,6 +8648,10 @@ public class WindowManagerService extends IWindowManager.Stub clearAnimation(); animating = false; + if (animLayerAdjustment != 0) { + animLayerAdjustment = 0; + updateLayers(); + } if (mInputMethodTarget != null && mInputMethodTarget.mAppToken == this) { moveInputMethodWindowsIfNeededLocked(true); } @@ -8639,10 +8661,6 @@ public class WindowManagerService extends IWindowManager.Stub + ": reportedVisible=" + reportedVisible); transformation.clear(); - if (animLayerAdjustment != 0) { - animLayerAdjustment = 0; - updateLayers(); - } final int N = windows.size(); for (int i=0; i<N; i++) { @@ -9248,11 +9266,47 @@ public class WindowManagerService extends IWindowManager.Stub WindowState imFocus; if (idx > 0) { imFocus = mWindows.get(idx-1); + //Log.i(TAG, "Desired input method target: " + imFocus); + //Log.i(TAG, "Current focus: " + this.mCurrentFocus); + //Log.i(TAG, "Last focus: " + this.mLastFocus); if (imFocus != null) { + // This may be a starting window, in which case we still want + // to count it as okay. + if (imFocus.mAttrs.type == LayoutParams.TYPE_APPLICATION_STARTING + && imFocus.mAppToken != null) { + // The client has definitely started, so it really should + // have a window in this app token. Let's look for it. + for (int i=0; i<imFocus.mAppToken.windows.size(); i++) { + WindowState w = imFocus.mAppToken.windows.get(i); + if (w != imFocus) { + //Log.i(TAG, "Switching to real app window: " + w); + imFocus = w; + break; + } + } + } + //Log.i(TAG, "IM target client: " + imFocus.mSession.mClient); + //if (imFocus.mSession.mClient != null) { + // Log.i(TAG, "IM target client binder: " + imFocus.mSession.mClient.asBinder()); + // Log.i(TAG, "Requesting client binder: " + client.asBinder()); + //} if (imFocus.mSession.mClient != null && imFocus.mSession.mClient.asBinder() == client.asBinder()) { return true; } + + // Okay, how about this... what is the current focus? + // It seems in some cases we may not have moved the IM + // target window, such as when it was in a pop-up window, + // so let's also look at the current focus. (An example: + // go to Gmail, start searching so the keyboard goes up, + // press home. Sometimes the IME won't go down.) + // Would be nice to fix this more correctly, but it's + // way at the end of a release, and this should be good enough. + if (mCurrentFocus != null && mCurrentFocus.mSession.mClient != null && + mCurrentFocus.mSession.mClient.asBinder() == client.asBinder()) { + return true; + } } } } @@ -11261,13 +11315,13 @@ public class WindowManagerService extends IWindowManager.Stub mInputMonitor.thawInputDispatchingLw(); + boolean configChanged; + // While the display is frozen we don't re-compute the orientation // to avoid inconsistent states. However, something interesting // could have actually changed during that time so re-evaluate it // now to catch that. - if (updateOrientationFromAppTokensLocked(false)) { - mH.sendEmptyMessage(H.SEND_NEW_CONFIGURATION); - } + configChanged = updateOrientationFromAppTokensLocked(false); // A little kludge: a lot could have happened while the // display was frozen, so now that we are coming back we @@ -11282,11 +11336,12 @@ public class WindowManagerService extends IWindowManager.Stub if (updateRotation) { if (DEBUG_ORIENTATION) Slog.d(TAG, "Performing post-rotate rotation"); - boolean changed = setRotationUncheckedLocked( + configChanged |= setRotationUncheckedLocked( WindowManagerPolicy.USE_LAST_ROTATION, 0, false); - if (changed) { - sendNewConfiguration(); - } + } + + if (configChanged) { + mH.sendEmptyMessage(H.SEND_NEW_CONFIGURATION); } } diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java index 6bb19b04736e..254a19b534ff 100755 --- a/services/java/com/android/server/am/ActivityManagerService.java +++ b/services/java/com/android/server/am/ActivityManagerService.java @@ -11944,28 +11944,6 @@ public final class ActivityManagerService extends ActivityManagerNative adj = FOREGROUND_APP_ADJ; schedGroup = Process.THREAD_GROUP_DEFAULT; app.adjType = "exec-service"; - } else if (app.foregroundServices) { - // The user is aware of this app, so make it visible. - adj = PERCEPTIBLE_APP_ADJ; - schedGroup = Process.THREAD_GROUP_DEFAULT; - app.adjType = "foreground-service"; - } else if (app.forcingToForeground != null) { - // The user is aware of this app, so make it visible. - adj = PERCEPTIBLE_APP_ADJ; - schedGroup = Process.THREAD_GROUP_DEFAULT; - app.adjType = "force-foreground"; - app.adjSource = app.forcingToForeground; - } else if (app == mHeavyWeightProcess) { - // We don't want to kill the current heavy-weight process. - adj = HEAVY_WEIGHT_APP_ADJ; - schedGroup = Process.THREAD_GROUP_BG_NONINTERACTIVE; - app.adjType = "heavy"; - } else if (app == mHomeProcess) { - // This process is hosting what we currently consider to be the - // home app, so we don't want to let it go into the background. - adj = HOME_APP_ADJ; - schedGroup = Process.THREAD_GROUP_BG_NONINTERACTIVE; - app.adjType = "home"; } else if ((N=app.activities.size()) != 0) { // This app is in the background with paused activities. app.hidden = true; @@ -11998,7 +11976,37 @@ public final class ActivityManagerService extends ActivityManagerNative adj = hiddenAdj; app.adjType = "bg-empty"; } + + if (adj > PERCEPTIBLE_APP_ADJ) { + if (app.foregroundServices) { + // The user is aware of this app, so make it visible. + adj = PERCEPTIBLE_APP_ADJ; + schedGroup = Process.THREAD_GROUP_DEFAULT; + app.adjType = "foreground-service"; + } else if (app.forcingToForeground != null) { + // The user is aware of this app, so make it visible. + adj = PERCEPTIBLE_APP_ADJ; + schedGroup = Process.THREAD_GROUP_DEFAULT; + app.adjType = "force-foreground"; + app.adjSource = app.forcingToForeground; + } + } + + if (adj > HEAVY_WEIGHT_APP_ADJ && app == mHeavyWeightProcess) { + // We don't want to kill the current heavy-weight process. + adj = HEAVY_WEIGHT_APP_ADJ; + schedGroup = Process.THREAD_GROUP_BG_NONINTERACTIVE; + app.adjType = "heavy"; + } + if (adj > HOME_APP_ADJ && app == mHomeProcess) { + // This process is hosting what we currently consider to be the + // home app, so we don't want to let it go into the background. + adj = HOME_APP_ADJ; + schedGroup = Process.THREAD_GROUP_BG_NONINTERACTIVE; + app.adjType = "home"; + } + //Slog.i(TAG, "OOM " + app + ": initial adj=" + adj); // By default, we use the computed adjustment. It may be changed if diff --git a/telephony/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java b/telephony/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java index 19e7faeaeb88..a7f786664fec 100755 --- a/telephony/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java +++ b/telephony/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java @@ -1069,6 +1069,8 @@ final class CdmaServiceStateTracker extends ServiceStateTracker { cdmaDataConnectionState = newCdmaDataConnectionState; networkType = newNetworkType; + // this new state has been applied - forget it until we get a new new state + newNetworkType = 0; newSS.setStateOutOfService(); // clean slate for next time diff --git a/telephony/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java b/telephony/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java index c107d174919f..bb99e4564c1d 100644 --- a/telephony/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java +++ b/telephony/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java @@ -957,6 +957,9 @@ final class GsmServiceStateTracker extends ServiceStateTracker { gprsState = newGPRSState; networkType = newNetworkType; + // this new state has been applied - forget it until we get a new new state + newNetworkType = 0; + newSS.setStateOutOfService(); // clean slate for next time diff --git a/tools/layoutlib/bridge/src/android/graphics/Gradient_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/Gradient_Delegate.java index 7a0c2f776775..38c092d8572b 100644 --- a/tools/layoutlib/bridge/src/android/graphics/Gradient_Delegate.java +++ b/tools/layoutlib/bridge/src/android/graphics/Gradient_Delegate.java @@ -95,7 +95,7 @@ public abstract class Gradient_Delegate extends Shader_Delegate { * Pre-computes the colors for the gradient. This must be called once before any call * to {@link #getGradientColor(float)} */ - protected synchronized void precomputeGradientColors() { + protected void precomputeGradientColors() { if (mGradient == null) { // actually create an array with an extra size, so that we can really go // from 0 to SIZE (100%), or currentPos in the loop below will never equal 1.0 diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java index bd52dc2ff219..0ed430575b62 100644 --- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java +++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java @@ -28,6 +28,7 @@ import com.android.layoutlib.bridge.android.BridgeAssetManager; import com.android.layoutlib.bridge.impl.FontLoader; import com.android.layoutlib.bridge.impl.RenderSessionImpl; import com.android.ninepatch.NinePatchChunk; +import com.android.resources.ResourceType; import com.android.tools.layoutlib.create.MethodAdapter; import com.android.tools.layoutlib.create.OverrideMethod; @@ -410,8 +411,9 @@ public final class Bridge extends com.android.ide.common.rendering.api.Bridge { * @param name the name of the resource. * @return an {@link Integer} containing the resource id, or null if no resource were found. */ - public static Integer getResourceValue(String type, String name) { - Map<String, Integer> map = sRFullMap.get(type); + public static Integer getResourceValue(ResourceType type, String name) { + String typeString = type.getName(); + Map<String, Integer> map = sRFullMap.get(typeString); if (map != null) { return map.get(name); } diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java index 79264d0bfa7a..abea8c70e978 100644 --- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java +++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java @@ -24,6 +24,7 @@ import com.android.ide.common.rendering.api.StyleResourceValue; import com.android.layoutlib.bridge.Bridge; import com.android.layoutlib.bridge.BridgeConstants; import com.android.layoutlib.bridge.impl.Stack; +import com.android.resources.ResourceType; import android.app.Activity; import android.app.Fragment; @@ -614,7 +615,7 @@ public final class BridgeContext extends Activity { return null; } - int getFrameworkResourceValue(String resType, String resName, int defValue) { + int getFrameworkResourceValue(ResourceType resType, String resName, int defValue) { Integer value = Bridge.getResourceValue(resType, resName); if (value != null) { return value.intValue(); @@ -623,7 +624,7 @@ public final class BridgeContext extends Activity { return defValue; } - int getProjectResourceValue(String resType, String resName, int defValue) { + int getProjectResourceValue(ResourceType resType, String resName, int defValue) { if (mProjectCallback != null) { Integer value = mProjectCallback.getResourceValue(resType, resName); if (value != null) { diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeInflater.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeInflater.java index 465bf1d956f8..edc92c20636b 100644 --- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeInflater.java +++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeInflater.java @@ -19,9 +19,9 @@ package com.android.layoutlib.bridge.android; import com.android.ide.common.rendering.api.IProjectCallback; import com.android.ide.common.rendering.api.LayoutLog; import com.android.ide.common.rendering.api.MergeCookie; -import com.android.ide.common.rendering.api.RenderResources; import com.android.ide.common.rendering.api.ResourceValue; import com.android.layoutlib.bridge.Bridge; +import com.android.resources.ResourceType; import org.kxml2.io.KXmlParser; import org.xmlpull.v1.XmlPullParser; @@ -158,13 +158,13 @@ public final class BridgeInflater extends LayoutInflater { String[] layoutInfo = Bridge.resolveResourceValue(resource); if (layoutInfo != null) { value = bridgeContext.getRenderResources().getFrameworkResource( - RenderResources.RES_LAYOUT, layoutInfo[0]); + ResourceType.LAYOUT, layoutInfo[0]); } else { layoutInfo = mProjectCallback.resolveResourceValue(resource); if (layoutInfo != null) { value = bridgeContext.getRenderResources().getProjectResource( - RenderResources.RES_LAYOUT, layoutInfo[0]); + ResourceType.LAYOUT, layoutInfo[0]); } } diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeResources.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeResources.java index 7b66809d3175..e71bbb234b63 100644 --- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeResources.java +++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeResources.java @@ -22,6 +22,7 @@ import com.android.ide.common.rendering.api.ResourceValue; import com.android.layoutlib.bridge.Bridge; import com.android.layoutlib.bridge.BridgeConstants; import com.android.layoutlib.bridge.impl.ResourceHelper; +import com.android.resources.ResourceType; import org.kxml2.io.KXmlParser; import org.xmlpull.v1.XmlPullParser; @@ -103,9 +104,14 @@ public final class BridgeResources extends Resources { String[] resourceInfo = Bridge.resolveResourceValue(id); if (resourceInfo != null) { + ResourceType resType = ResourceType.getEnum(resourceInfo[1]); + if (resType == null) { + return null; + } + platformResFlag_out[0] = true; return mContext.getRenderResources().getFrameworkResource( - resourceInfo[1], resourceInfo[0]); + resType, resourceInfo[0]); } // didn't find a match in the framework? look in the project. @@ -113,9 +119,14 @@ public final class BridgeResources extends Resources { resourceInfo = mProjectCallback.resolveResourceValue(id); if (resourceInfo != null) { + ResourceType resType = ResourceType.getEnum(resourceInfo[1]); + if (resType == null) { + return null; + } + platformResFlag_out[0] = false; return mContext.getRenderResources().getProjectResource( - resourceInfo[1], resourceInfo[0]); + resType, resourceInfo[0]); } } diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeTypedArray.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeTypedArray.java index 8d3c929d6ec2..2b48539228e8 100644 --- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeTypedArray.java +++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeTypedArray.java @@ -24,6 +24,7 @@ import com.android.internal.util.XmlUtils; import com.android.layoutlib.bridge.Bridge; import com.android.layoutlib.bridge.BridgeConstants; import com.android.layoutlib.bridge.impl.ResourceHelper; +import com.android.resources.ResourceType; import org.kxml2.io.KXmlParser; import org.xmlpull.v1.XmlPullParser; @@ -39,6 +40,7 @@ import android.view.ViewGroup.LayoutParams; import java.io.File; import java.io.FileReader; +import java.util.Arrays; import java.util.Map; /** @@ -587,17 +589,17 @@ public final class BridgeTypedArray extends TypedArray { // then the xml attribute value was "resolved" which leads us to a ResourceValue with a // valid getType() and getName() returning a resource name. // (and getValue() returning null!). We need to handle this! - if (resValue.getType() != null && resValue.getType().startsWith("@+") == false) { + if (resValue.getResourceType() != null && resValue.getType().startsWith("@+") == false) { // if this is a framework id if (mPlatformFile || resValue.isFramework()) { // look for idName in the android R classes return mContext.getFrameworkResourceValue( - resValue.getType(), resValue.getName(), defValue); + resValue.getResourceType(), resValue.getName(), defValue); } // look for idName in the project R class. return mContext.getProjectResourceValue( - resValue.getType(), resValue.getName(), defValue); + resValue.getResourceType(), resValue.getName(), defValue); } // else, try to get the value, and resolve it somehow. @@ -634,21 +636,22 @@ public final class BridgeTypedArray extends TypedArray { // if this is a framework id if (mPlatformFile || value.startsWith("@android") || value.startsWith("@+android")) { // look for idName in the android R classes - return mContext.getFrameworkResourceValue(RenderResources.RES_ID, idName, defValue); + return mContext.getFrameworkResourceValue(ResourceType.ID, idName, defValue); } // look for idName in the project R class. - return mContext.getProjectResourceValue(RenderResources.RES_ID, idName, defValue); + return mContext.getProjectResourceValue(ResourceType.ID, idName, defValue); } // not a direct id valid reference? resolve it Integer idValue = null; if (resValue.isFramework()) { - idValue = Bridge.getResourceValue(resValue.getType(), resValue.getName()); + idValue = Bridge.getResourceValue(resValue.getResourceType(), + resValue.getName()); } else { idValue = mContext.getProjectCallback().getResourceValue( - resValue.getType(), resValue.getName()); + resValue.getResourceType(), resValue.getName()); } if (idValue != null) { @@ -796,6 +799,6 @@ public final class BridgeTypedArray extends TypedArray { @Override public String toString() { - return mResourceData.toString(); + return Arrays.toString(mResourceData); } } diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeXmlPullAttributes.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeXmlPullAttributes.java index 4a6880b69002..f39961e09958 100644 --- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeXmlPullAttributes.java +++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeXmlPullAttributes.java @@ -20,6 +20,7 @@ import com.android.ide.common.rendering.api.RenderResources; import com.android.ide.common.rendering.api.ResourceValue; import com.android.layoutlib.bridge.Bridge; import com.android.layoutlib.bridge.BridgeConstants; +import com.android.resources.ResourceType; import org.xmlpull.v1.XmlPullParser; @@ -58,7 +59,7 @@ public class BridgeXmlPullAttributes extends XmlPullAttributes { String ns = mParser.getAttributeNamespace(index); if (BridgeConstants.NS_RESOURCES.equals(ns)) { - Integer v = Bridge.getResourceValue(RenderResources.RES_ATTR, name); + Integer v = Bridge.getResourceValue(ResourceType.ATTR, name); if (v != null) { return v.intValue(); } @@ -69,7 +70,7 @@ public class BridgeXmlPullAttributes extends XmlPullAttributes { // this is not an attribute in the android namespace, we query the customviewloader, if // the namespaces match. if (mContext.getProjectCallback().getNamespace().equals(ns)) { - Integer v = mContext.getProjectCallback().getResourceValue(RenderResources.RES_ATTR, + Integer v = mContext.getProjectCallback().getResourceValue(ResourceType.ATTR, name); if (v != null) { return v.intValue(); @@ -110,10 +111,10 @@ public class BridgeXmlPullAttributes extends XmlPullAttributes { if (resource != null) { Integer id = null; if (mPlatformFile || resource.isFramework()) { - id = Bridge.getResourceValue(resource.getType(), resource.getName()); + id = Bridge.getResourceValue(resource.getResourceType(), resource.getName()); } else { id = mContext.getProjectCallback().getResourceValue( - resource.getType(), resource.getName()); + resource.getResourceType(), resource.getName()); } if (id != null) { diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/FontLoader.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/FontLoader.java index 5d56370e7151..f62fad298bdd 100644 --- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/FontLoader.java +++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/FontLoader.java @@ -163,7 +163,7 @@ public final class FontLoader { mTtfToFontMap.put(ttf, styleMap); } - Font f = styleMap.get(style); + Font f = styleMap.get(style[0]); if (f != null) { return f; diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java index 978832ff41dd..19251f947d82 100644 --- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java +++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java @@ -48,6 +48,7 @@ import com.android.layoutlib.bridge.android.BridgeWindow; import com.android.layoutlib.bridge.android.BridgeWindowSession; import com.android.layoutlib.bridge.android.BridgeXmlBlockParser; import com.android.resources.Density; +import com.android.resources.ResourceType; import com.android.resources.ScreenSize; import android.animation.Animator; @@ -566,17 +567,16 @@ public class RenderSessionImpl extends FrameworkResourceIdProvider { int animationId = 0; if (isFrameworkAnimation) { animationResource = mContext.getRenderResources().getFrameworkResource( - RenderResources.RES_ANIMATOR, animationName); + ResourceType.ANIMATOR, animationName); if (animationResource != null) { - animationId = Bridge.getResourceValue(RenderResources.RES_ANIMATOR, - animationName); + animationId = Bridge.getResourceValue(ResourceType.ANIMATOR, animationName); } } else { animationResource = mContext.getRenderResources().getProjectResource( - RenderResources.RES_ANIMATOR, animationName); + ResourceType.ANIMATOR, animationName); if (animationResource != null) { animationId = mContext.getProjectCallback().getResourceValue( - RenderResources.RES_ANIMATOR, animationName); + ResourceType.ANIMATOR, animationName); } } @@ -1022,7 +1022,7 @@ public class RenderSessionImpl extends FrameworkResourceIdProvider { mStatusBarSize = DEFAULT_STATUS_BAR_HEIGHT; // get the real value - ResourceValue value = resources.getFrameworkResource(RenderResources.RES_DIMEN, + ResourceValue value = resources.getFrameworkResource(ResourceType.DIMEN, "status_bar_height"); if (value != null) { @@ -1110,7 +1110,7 @@ public class RenderSessionImpl extends FrameworkResourceIdProvider { mSystemBarSize = 56; // ?? // get the real value - ResourceValue value = resources.getFrameworkResource(RenderResources.RES_DIMEN, + ResourceValue value = resources.getFrameworkResource(ResourceType.DIMEN, "status_bar_height"); if (value != null) { @@ -1309,7 +1309,7 @@ public class RenderSessionImpl extends FrameworkResourceIdProvider { // --- FrameworkResourceIdProvider methods @Override - public Integer getId(String resType, String resName) { + public Integer getId(ResourceType resType, String resName) { return Bridge.getResourceValue(resType, resName); } } diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/ResourceHelper.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/ResourceHelper.java index 119dfb1f71f3..ae7a77f1f895 100644 --- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/ResourceHelper.java +++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/ResourceHelper.java @@ -298,7 +298,7 @@ public final class ResourceHelper { */ public static boolean stringToFloat(String s, TypedValue outValue) { // remove the space before and after - s.trim(); + s = s.trim(); int len = s.length(); if (len <= 0) { |