Merge "Ensure outValue is set, even when an error occurs."
diff --git a/api/current.txt b/api/current.txt
index 8151243..8f3b38f 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -190,6 +190,8 @@
field public static final int accountPreferences = 16843423; // 0x101029f
field public static final int accountType = 16843407; // 0x101028f
field public static final int action = 16842797; // 0x101002d
+ field public static final int actionBarDivider = 16843685; // 0x10103a5
+ field public static final int actionBarItemBackground = 16843686; // 0x10103a6
field public static final int actionBarSize = 16843499; // 0x10102eb
field public static final int actionBarSplitStyle = 16843666; // 0x1010392
field public static final int actionBarStyle = 16843470; // 0x10102ce
diff --git a/core/java/android/animation/ValueAnimator.java b/core/java/android/animation/ValueAnimator.java
index 5df8bdc..edd0fa3 100755
--- a/core/java/android/animation/ValueAnimator.java
+++ b/core/java/android/animation/ValueAnimator.java
@@ -54,8 +54,8 @@
* Messages sent to timing handler: START is sent when an animation first begins, FRAME is sent
* by the handler to itself to process the next animation frame
*/
- private static final int ANIMATION_START = 0;
- private static final int ANIMATION_FRAME = 1;
+ static final int ANIMATION_START = 0;
+ static final int ANIMATION_FRAME = 1;
/**
* Values used with internal variable mPlayingState to indicate the current state of an
diff --git a/core/java/android/content/res/AssetManager.java b/core/java/android/content/res/AssetManager.java
index 931cb18..ffefaa2 100644
--- a/core/java/android/content/res/AssetManager.java
+++ b/core/java/android/content/res/AssetManager.java
@@ -62,7 +62,7 @@
private static final boolean DEBUG_REFS = false;
private static final Object sSync = new Object();
- private static AssetManager sSystem = null;
+ /*package*/ static AssetManager sSystem = null;
private final TypedValue mValue = new TypedValue();
private final long[] mOffsets = new long[2];
@@ -252,7 +252,7 @@
}
}
- private final void makeStringBlocks(boolean copyFromSystem) {
+ /*package*/ final void makeStringBlocks(boolean copyFromSystem) {
final int sysNum = copyFromSystem ? sSystem.mStringBlocks.length : 0;
final int num = getStringBlockCount();
mStringBlocks = new StringBlock[num];
diff --git a/core/java/android/content/res/Resources.java b/core/java/android/content/res/Resources.java
index 324c9fd..f526923 100755
--- a/core/java/android/content/res/Resources.java
+++ b/core/java/android/content/res/Resources.java
@@ -77,7 +77,7 @@
private static final int ID_OTHER = 0x01000004;
private static final Object mSync = new Object();
- private static Resources mSystem = null;
+ /*package*/ static Resources mSystem = null;
// Information about preloaded resources. Note that they are not
// protected by a lock, because while preloading in zygote we are all
diff --git a/core/java/android/content/res/TypedArray.java b/core/java/android/content/res/TypedArray.java
index 37fdeb6..2df492e 100644
--- a/core/java/android/content/res/TypedArray.java
+++ b/core/java/android/content/res/TypedArray.java
@@ -42,7 +42,7 @@
/*package*/ int[] mData;
/*package*/ int[] mIndices;
/*package*/ int mLength;
- private TypedValue mValue = new TypedValue();
+ /*package*/ TypedValue mValue = new TypedValue();
/**
* Return the number of values in this array.
diff --git a/core/java/android/os/HandlerThread.java b/core/java/android/os/HandlerThread.java
index 911439a..d61b3b4 100644
--- a/core/java/android/os/HandlerThread.java
+++ b/core/java/android/os/HandlerThread.java
@@ -21,9 +21,9 @@
* used to create handler classes. Note that start() must still be called.
*/
public class HandlerThread extends Thread {
- private int mPriority;
- private int mTid = -1;
- private Looper mLooper;
+ int mPriority;
+ int mTid = -1;
+ Looper mLooper;
public HandlerThread(String name) {
super(name);
diff --git a/core/java/android/os/Looper.java b/core/java/android/os/Looper.java
index c61f28a..5607f7f 100644
--- a/core/java/android/os/Looper.java
+++ b/core/java/android/os/Looper.java
@@ -54,7 +54,7 @@
private static final String TAG = "Looper";
// sThreadLocal.get() will return null unless you've called prepare().
- private static final ThreadLocal<Looper> sThreadLocal = new ThreadLocal<Looper>();
+ static final ThreadLocal<Looper> sThreadLocal = new ThreadLocal<Looper>();
final MessageQueue mQueue;
final Thread mThread;
diff --git a/core/java/android/text/TextLine.java b/core/java/android/text/TextLine.java
index 3e5f32e..376e4f5 100644
--- a/core/java/android/text/TextLine.java
+++ b/core/java/android/text/TextLine.java
@@ -16,8 +16,6 @@
package android.text;
-import com.android.internal.util.ArrayUtils;
-
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
@@ -30,6 +28,8 @@
import android.text.style.ReplacementSpan;
import android.util.Log;
+import com.android.internal.util.ArrayUtils;
+
/**
* Represents a line of styled text, for measuring in visual order and
* for rendering.
@@ -720,7 +720,7 @@
float ret = 0;
int contextLen = contextEnd - contextStart;
- if (needWidth || (c != null && (wp.bgColor != 0 || runIsRtl))) {
+ if (needWidth || (c != null && (wp.bgColor != 0 || wp.underlineColor !=0 || runIsRtl))) {
int flags = runIsRtl ? Paint.DIRECTION_RTL : Paint.DIRECTION_LTR;
if (mCharsValid) {
ret = wp.getTextRunAdvances(mChars, start, runLen,
@@ -739,15 +739,32 @@
}
if (wp.bgColor != 0) {
- int color = wp.getColor();
- Paint.Style s = wp.getStyle();
+ int previousColor = wp.getColor();
+ Paint.Style previousStyle = wp.getStyle();
+
wp.setColor(wp.bgColor);
wp.setStyle(Paint.Style.FILL);
-
c.drawRect(x, top, x + ret, bottom, wp);
- wp.setStyle(s);
- wp.setColor(color);
+ wp.setStyle(previousStyle);
+ wp.setColor(previousColor);
+ }
+
+ if (wp.underlineColor != 0) {
+ // kStdUnderline_Offset = 1/9, defined in SkTextFormatParams.h
+ float middle = y + wp.baselineShift + (1.0f / 9.0f) * wp.getTextSize();
+ // kStdUnderline_Thickness = 1/18, defined in SkTextFormatParams.h
+ float halfHeight = wp.underlineThickness * (1.0f / 18.0f / 2.0f) * wp.getTextSize();
+
+ int previousColor = wp.getColor();
+ Paint.Style previousStyle = wp.getStyle();
+
+ wp.setColor(wp.underlineColor);
+ wp.setStyle(Paint.Style.FILL);
+ c.drawRect(x, middle - halfHeight, x + ret, middle + halfHeight, wp);
+
+ wp.setStyle(previousStyle);
+ wp.setColor(previousColor);
}
drawTextRun(c, wp, start, end, contextStart, contextEnd, runIsRtl,
diff --git a/core/java/android/text/TextPaint.java b/core/java/android/text/TextPaint.java
index f9e7cac..de57dfa 100644
--- a/core/java/android/text/TextPaint.java
+++ b/core/java/android/text/TextPaint.java
@@ -23,11 +23,22 @@
* data used during text measuring and drawing.
*/
public class TextPaint extends Paint {
+ // Special value 0 means no background paint
public int bgColor;
public int baselineShift;
public int linkColor;
public int[] drawableState;
public float density = 1.0f;
+ /**
+ * Special value 0 means no custom underline
+ * @hide
+ */
+ public int underlineColor;
+ /**
+ * Defined as a multiplier of the default underline thickness. Use 1.0f for default thickness.
+ * @hide
+ */
+ public float underlineThickness;
public TextPaint() {
super();
@@ -53,5 +64,24 @@
linkColor = tp.linkColor;
drawableState = tp.drawableState;
density = tp.density;
+ underlineColor = tp.underlineColor;
+ underlineThickness = tp.underlineThickness;
+ }
+
+ /**
+ * Defines a custom underline for this Paint.
+ * @param color underline solid color
+ * @param thickness underline thickness, defined as a multiplier of the default underline
+ * thickness.
+ * @hide
+ */
+ public void setUnderlineText(boolean isUnderlined, int color, float thickness) {
+ setUnderlineText(false);
+ if (isUnderlined) {
+ underlineColor = color;
+ underlineThickness = thickness;
+ } else {
+ underlineColor = 0;
+ }
}
}
diff --git a/core/java/android/util/XmlPullAttributes.java b/core/java/android/util/XmlPullAttributes.java
index ecedbe1..6c8bb39 100644
--- a/core/java/android/util/XmlPullAttributes.java
+++ b/core/java/android/util/XmlPullAttributes.java
@@ -143,5 +143,5 @@
return getAttributeResourceValue(null, "style", 0);
}
- private XmlPullParser mParser;
+ /*package*/ XmlPullParser mParser;
}
diff --git a/core/java/android/view/Display.java b/core/java/android/view/Display.java
index d9efe0c..85e990aa 100644
--- a/core/java/android/view/Display.java
+++ b/core/java/android/view/Display.java
@@ -366,9 +366,9 @@
// Following fields are initialized from native code
private int mPixelFormat;
private float mRefreshRate;
- private float mDensity;
- private float mDpiX;
- private float mDpiY;
+ /*package*/ float mDensity;
+ /*package*/ float mDpiX;
+ /*package*/ float mDpiY;
private final Point mTmpPoint = new Point();
private final DisplayMetrics mTmpMetrics = new DisplayMetrics();
diff --git a/core/java/android/view/GLES20Canvas.java b/core/java/android/view/GLES20Canvas.java
index a7fe95d..e586370 100644
--- a/core/java/android/view/GLES20Canvas.java
+++ b/core/java/android/view/GLES20Canvas.java
@@ -509,13 +509,6 @@
private static native void nSetMatrix(int renderer, int matrix);
@Override
- public int getNativeMatrix() {
- return nGetMatrix(mRenderer);
- }
-
- private static native int nGetMatrix(int renderer);
-
- @Override
public void getMatrix(Matrix matrix) {
nGetMatrix(mRenderer, matrix.native_instance);
}
diff --git a/core/java/android/view/LayoutInflater.java b/core/java/android/view/LayoutInflater.java
index 332a0fa..9628d6b 100644
--- a/core/java/android/view/LayoutInflater.java
+++ b/core/java/android/view/LayoutInflater.java
@@ -75,9 +75,9 @@
private Factory2 mPrivateFactory;
private Filter mFilter;
- private final Object[] mConstructorArgs = new Object[2];
+ final Object[] mConstructorArgs = new Object[2];
- private static final Class<?>[] mConstructorSignature = new Class[] {
+ static final Class<?>[] mConstructorSignature = new Class[] {
Context.class, AttributeSet.class};
private static final HashMap<String, Constructor<? extends View>> sConstructorMap =
@@ -705,7 +705,7 @@
* Recursive method used to descend down the xml hierarchy and instantiate
* views, instantiate their children, and then call onFinishInflate().
*/
- private void rInflate(XmlPullParser parser, View parent, final AttributeSet attrs,
+ void rInflate(XmlPullParser parser, View parent, final AttributeSet attrs,
boolean finishInflate) throws XmlPullParserException, IOException {
final int depth = parser.getDepth();
diff --git a/core/java/android/view/ViewConfiguration.java b/core/java/android/view/ViewConfiguration.java
index 9520958..5e104f9e 100644
--- a/core/java/android/view/ViewConfiguration.java
+++ b/core/java/android/view/ViewConfiguration.java
@@ -225,7 +225,7 @@
private boolean sHasPermanentMenuKey;
private boolean sHasPermanentMenuKeySet;
- private static final SparseArray<ViewConfiguration> sConfigurations =
+ static final SparseArray<ViewConfiguration> sConfigurations =
new SparseArray<ViewConfiguration>(2);
/**
diff --git a/core/java/com/android/internal/app/ActionBarImpl.java b/core/java/com/android/internal/app/ActionBarImpl.java
index 0df7bcc..31360e1 100644
--- a/core/java/com/android/internal/app/ActionBarImpl.java
+++ b/core/java/com/android/internal/app/ActionBarImpl.java
@@ -253,7 +253,7 @@
@Override
public void setCustomView(int resId) {
- setCustomView(LayoutInflater.from(mContext).inflate(resId, mActionView, false));
+ setCustomView(LayoutInflater.from(getThemedContext()).inflate(resId, mActionView, false));
}
@Override
@@ -630,14 +630,14 @@
public ActionModeImpl(ActionMode.Callback callback) {
mCallback = callback;
- mMenu = new MenuBuilder(mActionView.getContext())
+ mMenu = new MenuBuilder(getThemedContext())
.setDefaultShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
mMenu.setCallback(this);
}
@Override
public MenuInflater getMenuInflater() {
- return new MenuInflater(mContext);
+ return new MenuInflater(getThemedContext());
}
@Override
@@ -755,7 +755,7 @@
return true;
}
- new MenuPopupHelper(mContext, subMenu).show();
+ new MenuPopupHelper(getThemedContext(), subMenu).show();
return true;
}
@@ -819,7 +819,8 @@
@Override
public Tab setCustomView(int layoutResId) {
- return setCustomView(LayoutInflater.from(mContext).inflate(layoutResId, null));
+ return setCustomView(LayoutInflater.from(getThemedContext())
+ .inflate(layoutResId, null));
}
@Override
diff --git a/core/java/com/android/internal/widget/ActionBarContainer.java b/core/java/com/android/internal/widget/ActionBarContainer.java
index b4d2d72..fd9ee08 100644
--- a/core/java/com/android/internal/widget/ActionBarContainer.java
+++ b/core/java/com/android/internal/widget/ActionBarContainer.java
@@ -25,6 +25,7 @@
import android.view.ActionMode;
import android.view.MotionEvent;
import android.view.View;
+import android.view.ViewGroup;
import android.widget.FrameLayout;
/**
@@ -109,7 +110,9 @@
mTabContainer = tabView;
if (tabView != null) {
addView(tabView);
- tabView.getLayoutParams().width = LayoutParams.MATCH_PARENT;
+ final ViewGroup.LayoutParams lp = tabView.getLayoutParams();
+ lp.width = LayoutParams.MATCH_PARENT;
+ lp.height = LayoutParams.WRAP_CONTENT;
tabView.setAllowCollapse(false);
}
}
diff --git a/core/java/com/android/internal/widget/ScrollingTabContainerView.java b/core/java/com/android/internal/widget/ScrollingTabContainerView.java
index 0e4c9ef..71f9364 100644
--- a/core/java/com/android/internal/widget/ScrollingTabContainerView.java
+++ b/core/java/com/android/internal/widget/ScrollingTabContainerView.java
@@ -68,6 +68,11 @@
super(context);
setHorizontalScrollBarEnabled(false);
+ TypedArray a = getContext().obtainStyledAttributes(null, R.styleable.ActionBar,
+ com.android.internal.R.attr.actionBarStyle, 0);
+ setContentHeight(a.getLayoutDimension(R.styleable.ActionBar_height, 0));
+ a.recycle();
+
mTabLayout = createTabLayout();
addView(mTabLayout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.MATCH_PARENT));
@@ -91,16 +96,7 @@
mMaxTabWidth = -1;
}
- int heightMode = MeasureSpec.getMode(heightMeasureSpec);
- int heightSize = MeasureSpec.getSize(heightMeasureSpec);
- if (heightMode != MeasureSpec.UNSPECIFIED) {
- if (mContentHeight == 0 && heightMode == MeasureSpec.EXACTLY) {
- // Use this as our content height.
- mContentHeight = heightSize;
- }
- heightSize = Math.min(heightSize, mContentHeight);
- heightMeasureSpec = MeasureSpec.makeMeasureSpec(heightSize, heightMode);
- }
+ heightMeasureSpec = MeasureSpec.makeMeasureSpec(mContentHeight, MeasureSpec.EXACTLY);
final boolean canCollapse = !lockedExpanded && mAllowCollapse;
diff --git a/core/jni/android_view_GLES20Canvas.cpp b/core/jni/android_view_GLES20Canvas.cpp
index b3f2d51..039c5ba 100644
--- a/core/jni/android_view_GLES20Canvas.cpp
+++ b/core/jni/android_view_GLES20Canvas.cpp
@@ -289,11 +289,6 @@
renderer->setMatrix(matrix);
}
-static const float* android_view_GLES20Canvas_getNativeMatrix(JNIEnv* env,
- jobject clazz, OpenGLRenderer* renderer) {
- return renderer->getMatrix();
-}
-
static void android_view_GLES20Canvas_getMatrix(JNIEnv* env, jobject clazz,
OpenGLRenderer* renderer, SkMatrix* matrix) {
renderer->getMatrix(matrix);
@@ -776,7 +771,6 @@
{ "nSkew", "(IFF)V", (void*) android_view_GLES20Canvas_skew },
{ "nSetMatrix", "(II)V", (void*) android_view_GLES20Canvas_setMatrix },
- { "nGetMatrix", "(I)I", (void*) android_view_GLES20Canvas_getNativeMatrix },
{ "nGetMatrix", "(II)V", (void*) android_view_GLES20Canvas_getMatrix },
{ "nConcatMatrix", "(II)V", (void*) android_view_GLES20Canvas_concatMatrix },
diff --git a/core/res/res/drawable-hdpi/spinner_16_inner_holo.png b/core/res/res/drawable-hdpi/spinner_16_inner_holo.png
index 8c93779..01f4278 100644
--- a/core/res/res/drawable-hdpi/spinner_16_inner_holo.png
+++ b/core/res/res/drawable-hdpi/spinner_16_inner_holo.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/spinner_16_outer_holo.png b/core/res/res/drawable-hdpi/spinner_16_outer_holo.png
index d272f93..20fc20a 100644
--- a/core/res/res/drawable-hdpi/spinner_16_outer_holo.png
+++ b/core/res/res/drawable-hdpi/spinner_16_outer_holo.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/spinner_20_inner_holo.png b/core/res/res/drawable-hdpi/spinner_20_inner_holo.png
index 3c371b2d..4c9849f 100644
--- a/core/res/res/drawable-hdpi/spinner_20_inner_holo.png
+++ b/core/res/res/drawable-hdpi/spinner_20_inner_holo.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/spinner_20_outer_holo.png b/core/res/res/drawable-hdpi/spinner_20_outer_holo.png
index 2820b5f..82b5671 100644
--- a/core/res/res/drawable-hdpi/spinner_20_outer_holo.png
+++ b/core/res/res/drawable-hdpi/spinner_20_outer_holo.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/spinner_48_inner_holo.png b/core/res/res/drawable-hdpi/spinner_48_inner_holo.png
index a992251..5d15e74 100644
--- a/core/res/res/drawable-hdpi/spinner_48_inner_holo.png
+++ b/core/res/res/drawable-hdpi/spinner_48_inner_holo.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/spinner_48_outer_holo.png b/core/res/res/drawable-hdpi/spinner_48_outer_holo.png
index 27452b1..5648af0 100644
--- a/core/res/res/drawable-hdpi/spinner_48_outer_holo.png
+++ b/core/res/res/drawable-hdpi/spinner_48_outer_holo.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/spinner_76_inner_holo.png b/core/res/res/drawable-hdpi/spinner_76_inner_holo.png
index 3d426e0..cc8affe 100644
--- a/core/res/res/drawable-hdpi/spinner_76_inner_holo.png
+++ b/core/res/res/drawable-hdpi/spinner_76_inner_holo.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/spinner_76_outer_holo.png b/core/res/res/drawable-hdpi/spinner_76_outer_holo.png
index 92f77a3..1efa5eb 100644
--- a/core/res/res/drawable-hdpi/spinner_76_outer_holo.png
+++ b/core/res/res/drawable-hdpi/spinner_76_outer_holo.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/spinner_default_holo_dark.9.png b/core/res/res/drawable-hdpi/spinner_default_holo_dark.9.png
index ac36c06..80bba6b 100644
--- a/core/res/res/drawable-hdpi/spinner_default_holo_dark.9.png
+++ b/core/res/res/drawable-hdpi/spinner_default_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/spinner_default_holo_light.9.png b/core/res/res/drawable-hdpi/spinner_default_holo_light.9.png
index 6821599..ffd9e37 100644
--- a/core/res/res/drawable-hdpi/spinner_default_holo_light.9.png
+++ b/core/res/res/drawable-hdpi/spinner_default_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/spinner_disabled_holo_dark.9.png b/core/res/res/drawable-hdpi/spinner_disabled_holo_dark.9.png
index adde694..ea20276 100644
--- a/core/res/res/drawable-hdpi/spinner_disabled_holo_dark.9.png
+++ b/core/res/res/drawable-hdpi/spinner_disabled_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/spinner_disabled_holo_light.9.png b/core/res/res/drawable-hdpi/spinner_disabled_holo_light.9.png
index fdb4bdf..c2b031c 100644
--- a/core/res/res/drawable-hdpi/spinner_disabled_holo_light.9.png
+++ b/core/res/res/drawable-hdpi/spinner_disabled_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/spinner_focused_holo_dark.9.png b/core/res/res/drawable-hdpi/spinner_focused_holo_dark.9.png
index d40d165..a3fc804 100644
--- a/core/res/res/drawable-hdpi/spinner_focused_holo_dark.9.png
+++ b/core/res/res/drawable-hdpi/spinner_focused_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/spinner_focused_holo_light.9.png b/core/res/res/drawable-hdpi/spinner_focused_holo_light.9.png
index 096b977..a3fc804 100644
--- a/core/res/res/drawable-hdpi/spinner_focused_holo_light.9.png
+++ b/core/res/res/drawable-hdpi/spinner_focused_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/spinner_pressed_holo_dark.9.png b/core/res/res/drawable-hdpi/spinner_pressed_holo_dark.9.png
index 3b26017..86aa7da 100644
--- a/core/res/res/drawable-hdpi/spinner_pressed_holo_dark.9.png
+++ b/core/res/res/drawable-hdpi/spinner_pressed_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/spinner_pressed_holo_light.9.png b/core/res/res/drawable-hdpi/spinner_pressed_holo_light.9.png
index 33b661b..c8ec05d 100644
--- a/core/res/res/drawable-hdpi/spinner_pressed_holo_light.9.png
+++ b/core/res/res/drawable-hdpi/spinner_pressed_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/spinner_16_inner_holo.png b/core/res/res/drawable-mdpi/spinner_16_inner_holo.png
index 392e1f8..a322a02 100644
--- a/core/res/res/drawable-mdpi/spinner_16_inner_holo.png
+++ b/core/res/res/drawable-mdpi/spinner_16_inner_holo.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/spinner_16_outer_holo.png b/core/res/res/drawable-mdpi/spinner_16_outer_holo.png
index d862a25..07df4cb 100644
--- a/core/res/res/drawable-mdpi/spinner_16_outer_holo.png
+++ b/core/res/res/drawable-mdpi/spinner_16_outer_holo.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/spinner_20_inner_holo.png b/core/res/res/drawable-mdpi/spinner_20_inner_holo.png
index f5e7f73..538788a 100644
--- a/core/res/res/drawable-mdpi/spinner_20_inner_holo.png
+++ b/core/res/res/drawable-mdpi/spinner_20_inner_holo.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/spinner_20_outer_holo.png b/core/res/res/drawable-mdpi/spinner_20_outer_holo.png
index b7ecfff..f345311 100644
--- a/core/res/res/drawable-mdpi/spinner_20_outer_holo.png
+++ b/core/res/res/drawable-mdpi/spinner_20_outer_holo.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/spinner_48_inner_holo.png b/core/res/res/drawable-mdpi/spinner_48_inner_holo.png
index 5231a5b..b59dc64 100644
--- a/core/res/res/drawable-mdpi/spinner_48_inner_holo.png
+++ b/core/res/res/drawable-mdpi/spinner_48_inner_holo.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/spinner_48_outer_holo.png b/core/res/res/drawable-mdpi/spinner_48_outer_holo.png
index e1e5b52..024f0f2 100644
--- a/core/res/res/drawable-mdpi/spinner_48_outer_holo.png
+++ b/core/res/res/drawable-mdpi/spinner_48_outer_holo.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/spinner_76_inner_holo.png b/core/res/res/drawable-mdpi/spinner_76_inner_holo.png
index 982f037..e7d654c 100644
--- a/core/res/res/drawable-mdpi/spinner_76_inner_holo.png
+++ b/core/res/res/drawable-mdpi/spinner_76_inner_holo.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/spinner_76_outer_holo.png b/core/res/res/drawable-mdpi/spinner_76_outer_holo.png
index 01b6ab38..e81bb06 100644
--- a/core/res/res/drawable-mdpi/spinner_76_outer_holo.png
+++ b/core/res/res/drawable-mdpi/spinner_76_outer_holo.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/spinner_default_holo_dark.9.png b/core/res/res/drawable-mdpi/spinner_default_holo_dark.9.png
index 99b1605..ddc2b22 100644
--- a/core/res/res/drawable-mdpi/spinner_default_holo_dark.9.png
+++ b/core/res/res/drawable-mdpi/spinner_default_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/spinner_default_holo_light.9.png b/core/res/res/drawable-mdpi/spinner_default_holo_light.9.png
index c820e40..eb0d501 100644
--- a/core/res/res/drawable-mdpi/spinner_default_holo_light.9.png
+++ b/core/res/res/drawable-mdpi/spinner_default_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/spinner_disabled_holo_dark.9.png b/core/res/res/drawable-mdpi/spinner_disabled_holo_dark.9.png
index 95d7c86..8ba2a42 100644
--- a/core/res/res/drawable-mdpi/spinner_disabled_holo_dark.9.png
+++ b/core/res/res/drawable-mdpi/spinner_disabled_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/spinner_disabled_holo_light.9.png b/core/res/res/drawable-mdpi/spinner_disabled_holo_light.9.png
index 2dba270..cf50964 100644
--- a/core/res/res/drawable-mdpi/spinner_disabled_holo_light.9.png
+++ b/core/res/res/drawable-mdpi/spinner_disabled_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/spinner_focused_holo_dark.9.png b/core/res/res/drawable-mdpi/spinner_focused_holo_dark.9.png
index 2e2fadd..7ab9428 100644
--- a/core/res/res/drawable-mdpi/spinner_focused_holo_dark.9.png
+++ b/core/res/res/drawable-mdpi/spinner_focused_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/spinner_focused_holo_light.9.png b/core/res/res/drawable-mdpi/spinner_focused_holo_light.9.png
index 5bbbf63..7ab9428 100644
--- a/core/res/res/drawable-mdpi/spinner_focused_holo_light.9.png
+++ b/core/res/res/drawable-mdpi/spinner_focused_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/spinner_pressed_holo_dark.9.png b/core/res/res/drawable-mdpi/spinner_pressed_holo_dark.9.png
index 083194a..5654920 100644
--- a/core/res/res/drawable-mdpi/spinner_pressed_holo_dark.9.png
+++ b/core/res/res/drawable-mdpi/spinner_pressed_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/spinner_pressed_holo_light.9.png b/core/res/res/drawable-mdpi/spinner_pressed_holo_light.9.png
index 29cbc46..655339d 100644
--- a/core/res/res/drawable-mdpi/spinner_pressed_holo_light.9.png
+++ b/core/res/res/drawable-mdpi/spinner_pressed_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/spinner_16_inner_holo.png b/core/res/res/drawable-xhdpi/spinner_16_inner_holo.png
index f5e9164..d49d67a 100644
--- a/core/res/res/drawable-xhdpi/spinner_16_inner_holo.png
+++ b/core/res/res/drawable-xhdpi/spinner_16_inner_holo.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/spinner_16_outer_holo.png b/core/res/res/drawable-xhdpi/spinner_16_outer_holo.png
index 6f977a2..583e4a2 100644
--- a/core/res/res/drawable-xhdpi/spinner_16_outer_holo.png
+++ b/core/res/res/drawable-xhdpi/spinner_16_outer_holo.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/spinner_20_inner_holo.png b/core/res/res/drawable-xhdpi/spinner_20_inner_holo.png
index 16c8430..5eec6f3 100644
--- a/core/res/res/drawable-xhdpi/spinner_20_inner_holo.png
+++ b/core/res/res/drawable-xhdpi/spinner_20_inner_holo.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/spinner_20_outer_holo.png b/core/res/res/drawable-xhdpi/spinner_20_outer_holo.png
index 9593616..34fbbf0 100644
--- a/core/res/res/drawable-xhdpi/spinner_20_outer_holo.png
+++ b/core/res/res/drawable-xhdpi/spinner_20_outer_holo.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/spinner_48_inner_holo.png b/core/res/res/drawable-xhdpi/spinner_48_inner_holo.png
index cebf1d8..6f824026 100644
--- a/core/res/res/drawable-xhdpi/spinner_48_inner_holo.png
+++ b/core/res/res/drawable-xhdpi/spinner_48_inner_holo.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/spinner_48_outer_holo.png b/core/res/res/drawable-xhdpi/spinner_48_outer_holo.png
index 5a9e001..fd202f4 100644
--- a/core/res/res/drawable-xhdpi/spinner_48_outer_holo.png
+++ b/core/res/res/drawable-xhdpi/spinner_48_outer_holo.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/spinner_76_inner_holo.png b/core/res/res/drawable-xhdpi/spinner_76_inner_holo.png
index c68cc37..af88495 100644
--- a/core/res/res/drawable-xhdpi/spinner_76_inner_holo.png
+++ b/core/res/res/drawable-xhdpi/spinner_76_inner_holo.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/spinner_76_outer_holo.png b/core/res/res/drawable-xhdpi/spinner_76_outer_holo.png
index 611dc5a..a416478 100644
--- a/core/res/res/drawable-xhdpi/spinner_76_outer_holo.png
+++ b/core/res/res/drawable-xhdpi/spinner_76_outer_holo.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/spinner_default_holo_dark.9.png b/core/res/res/drawable-xhdpi/spinner_default_holo_dark.9.png
new file mode 100644
index 0000000..06b6dc7
--- /dev/null
+++ b/core/res/res/drawable-xhdpi/spinner_default_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/spinner_default_holo_light.9.png b/core/res/res/drawable-xhdpi/spinner_default_holo_light.9.png
new file mode 100644
index 0000000..aa32bcf
--- /dev/null
+++ b/core/res/res/drawable-xhdpi/spinner_default_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/spinner_disabled_holo_dark.9.png b/core/res/res/drawable-xhdpi/spinner_disabled_holo_dark.9.png
new file mode 100644
index 0000000..ba25eb04
--- /dev/null
+++ b/core/res/res/drawable-xhdpi/spinner_disabled_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/spinner_disabled_holo_light.9.png b/core/res/res/drawable-xhdpi/spinner_disabled_holo_light.9.png
new file mode 100644
index 0000000..7a015ba
--- /dev/null
+++ b/core/res/res/drawable-xhdpi/spinner_disabled_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/spinner_focused_holo_dark.9.png b/core/res/res/drawable-xhdpi/spinner_focused_holo_dark.9.png
new file mode 100644
index 0000000..c6aad24
--- /dev/null
+++ b/core/res/res/drawable-xhdpi/spinner_focused_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/spinner_focused_holo_light.9.png b/core/res/res/drawable-xhdpi/spinner_focused_holo_light.9.png
new file mode 100644
index 0000000..c6aad24
--- /dev/null
+++ b/core/res/res/drawable-xhdpi/spinner_focused_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/spinner_pressed_holo_dark.9.png b/core/res/res/drawable-xhdpi/spinner_pressed_holo_dark.9.png
new file mode 100644
index 0000000..a0a7867
--- /dev/null
+++ b/core/res/res/drawable-xhdpi/spinner_pressed_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/spinner_pressed_holo_light.9.png b/core/res/res/drawable-xhdpi/spinner_pressed_holo_light.9.png
new file mode 100644
index 0000000..85a3cae
--- /dev/null
+++ b/core/res/res/drawable-xhdpi/spinner_pressed_holo_light.9.png
Binary files differ
diff --git a/core/res/res/layout/action_bar_home.xml b/core/res/res/layout/action_bar_home.xml
index 9612710..96467d0 100644
--- a/core/res/res/layout/action_bar_home.xml
+++ b/core/res/res/layout/action_bar_home.xml
@@ -18,7 +18,7 @@
class="com.android.internal.widget.ActionBarView$HomeView"
android:layout_width="wrap_content"
android:layout_height="match_parent"
- android:background="?android:attr/selectableItemBackground" >
+ android:background="?android:attr/actionBarItemBackground" >
<ImageView android:id="@android:id/up"
android:src="?android:attr/homeAsUpIndicator"
android:layout_gravity="center_vertical|left"
diff --git a/core/res/res/layout/search_bar.xml b/core/res/res/layout/search_bar.xml
index f6b5b53..673c96c 100644
--- a/core/res/res/layout/search_bar.xml
+++ b/core/res/res/layout/search_bar.xml
@@ -75,5 +75,5 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="fitXY"
- android:src="@drawable/title_bar_shadow"/>
+ android:src="@drawable/ab_solid_shadow_holo"/>
</view>
diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml
index f4c0240..140a8c9 100755
--- a/core/res/res/values/attrs.xml
+++ b/core/res/res/values/attrs.xml
@@ -633,6 +633,10 @@
<attr name="actionBarSize" format="dimension" >
<enum name="wrap_content" value="0" />
</attr>
+ <!-- Custom divider drawable to use for elements in the action bar. -->
+ <attr name="actionBarDivider" format="reference" />
+ <!-- Custom item state list drawable background for action bar items. -->
+ <attr name="actionBarItemBackground" format="reference" />
<!-- TextAppearance style that will be applied to text that
appears within action menu items. -->
<attr name="actionMenuTextAppearance" format="reference" />
diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml
index 1ba54cf..44995c8 100644
--- a/core/res/res/values/public.xml
+++ b/core/res/res/values/public.xml
@@ -1788,6 +1788,9 @@
<public type="attr" name="subtypeLocale" />
<public type="attr" name="subtypeExtraValue" />
+ <public type="attr" name="actionBarDivider" />
+ <public type="attr" name="actionBarItemBackground" />
+
<public type="style" name="TextAppearance.SuggestionHighlight" />
<public type="style" name="Theme.Holo.Light.DarkActionBar" />
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index 583310d..71e302f 100755
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -916,18 +916,19 @@
applications can use this to erase or modify your contact data.</string>
<!-- Title of the read profile permission, listed so the user can decide whether to allow the application to read the user's personal profile data. [CHAR LIMIT=30] -->
- <string name="permlab_readProfile">read profile data</string>
+ <string name="permlab_readProfile">read your profile data</string>
<!-- Description of the read profile permission, listed so the user can decide whether to allow the application to read the user's personal profile data. [CHAR LIMIT=NONE] -->
- <string name="permdesc_readProfile" product="default">Allows an application to read all
- of your personal profile information. Malicious applications can use this to identify
- you and send your personal information to other people.</string>
+ <string name="permdesc_readProfile" product="default">Allows the application to read personal
+ profile information stored on your device, such as your name and contact information. This
+ means the application can identify you and send your profile information to others.</string>
<!-- Title of the write profile permission, listed so the user can decide whether to allow the application to write to the user's personal profile data. [CHAR LIMIT=30] -->
- <string name="permlab_writeProfile">write profile data</string>
+ <string name="permlab_writeProfile">write to your profile data</string>
<!-- Description of the write profile permission, listed so the user can decide whether to allow the application to write to the user's personal profile data. [CHAR LIMIT=NONE] -->
- <string name="permdesc_writeProfile" product="default">Allows an application to modify
- your personal profile information. Malicious applications can use this to erase or
- modify your profile data.</string>
+ <string name="permdesc_writeProfile" product="default">Allows the application to change or add
+ to personal profile information stored on your device, such as your name and contact
+ information. This means other applications can identify you and send your profile
+ information to others.</string>
<!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
<string name="permlab_readCalendar">read calendar events plus confidential information</string>
diff --git a/core/res/res/values/styles.xml b/core/res/res/values/styles.xml
index 0c6e20f..1f6b50a 100644
--- a/core/res/res/values/styles.xml
+++ b/core/res/res/values/styles.xml
@@ -1113,7 +1113,7 @@
</style>
<style name="Widget.ActionButton">
- <item name="android:background">?android:attr/selectableItemBackground</item>
+ <item name="android:background">?android:attr/actionBarItemBackground</item>
<item name="android:paddingLeft">12dip</item>
<item name="android:paddingRight">12dip</item>
<item name="android:minWidth">56dip</item>
@@ -1847,9 +1847,9 @@
</style>
<style name="Widget.Holo.ActionBar.TabBar" parent="Widget.ActionBar.TabBar">
- <item name="android:divider">?android:attr/dividerVertical</item>
+ <item name="android:divider">?android:attr/actionBarDivider</item>
<item name="android:showDividers">middle</item>
- <item name="android:dividerPadding">8dip</item>
+ <item name="android:dividerPadding">12dip</item>
</style>
<style name="Widget.Holo.ActionBar.TabText" parent="Widget.ActionBar.TabText">
diff --git a/core/res/res/values/themes.xml b/core/res/res/values/themes.xml
index 82299b8..add7dc8 100644
--- a/core/res/res/values/themes.xml
+++ b/core/res/res/values/themes.xml
@@ -308,6 +308,8 @@
<item name="actionMenuTextAppearance">@android:style/TextAppearance.Holo.Widget.ActionBar.Menu</item>
<item name="actionMenuTextColor">?android:attr/textColorPrimary</item>
<item name="actionBarWidgetTheme">@null</item>
+ <item name="actionBarDivider">?android:attr/dividerVertical</item>
+ <item name="actionBarItemBackground">?android:attr/selectableItemBackground</item>
<item name="dividerVertical">@drawable/divider_vertical_dark</item>
<item name="dividerHorizontal">@drawable/divider_vertical_dark</item>
@@ -1429,7 +1431,7 @@
with an inverse color profile. The dark action bar sharply stands out against
the light content. -->
<style name="Theme.Holo.Light.DarkActionBar">
- <item name="android:windowContentOverlay">@android:drawable/title_bar_shadow</item>
+ <item name="android:windowContentOverlay">@android:drawable/ab_solid_shadow_holo</item>
<item name="android:actionBarStyle">@android:style/Widget.Holo.Light.ActionBar.Solid.Inverse</item>
<item name="actionBarWidgetTheme">@android:style/Theme.Holo</item>
@@ -1442,6 +1444,8 @@
<item name="actionBarTabStyle">@style/Widget.Holo.Light.ActionBar.TabView.Inverse</item>
<item name="actionBarTabBarStyle">@style/Widget.Holo.Light.ActionBar.TabBar.Inverse</item>
<item name="actionBarTabTextStyle">@style/Widget.Holo.Light.ActionBar.TabText.Inverse</item>
+ <item name="actionBarDivider">@android:drawable/list_divider_holo_dark</item>
+ <item name="actionBarItemBackground">@android:drawable/item_background_holo_dark</item>
<item name="actionMenuTextColor">?android:attr/textColorPrimaryInverse</item>
<item name="actionModeStyle">@style/Widget.Holo.Light.ActionMode.Inverse</item>
<item name="actionModeCloseButtonStyle">@style/Widget.Holo.ActionButton.CloseMode</item>
diff --git a/docs/html/guide/practices/design/jni.jd b/docs/html/guide/practices/design/jni.jd
index 1d0e26e..6e984b0 100644
--- a/docs/html/guide/practices/design/jni.jd
+++ b/docs/html/guide/practices/design/jni.jd
@@ -18,9 +18,9 @@
<li><a href="#native_libraries">Native Libraries</a></li>
<li><a href="#64_bit">64-bit Considerations</a></li>
<li><a href="#unsupported">Unsupported Features</a></li>
- <li><a href="#faq_ULE">FAQ: UnsatisfiedLinkError</a></li>
- <li><a href="#faq_FindClass">FAQ: FindClass didn't find my class</a></li>
- <li><a href="#faq_sharing">FAQ: Sharing raw data with native code</a></li>
+ <li><a href="#faq_ULE">FAQ: Why do I get <code>UnsatisfiedLinkError</code></a></li>
+ <li><a href="#faq_FindClass">FAQ: Why didn't <code>FindClass</code> find my class?</a></li>
+ <li><a href="#faq_sharing">FAQ: How do I share raw data with native code?</a></li>
</ol>
</div>
@@ -28,7 +28,7 @@
<p>JNI is the Java Native Interface. It defines a way for code written in the
Java programming language to interact with native
-code, e.g. functions written in C/C++. It's VM-neutral, has support for loading code from
+code: functions written in C/C++. It's VM-neutral, has support for loading code from
dynamic shared libraries, and while cumbersome at times is reasonably efficient.</p>
<p>You really should read through the
@@ -36,8 +36,7 @@
to get a sense for how JNI works and what features are available. Some
aspects of the interface aren't immediately obvious on
first reading, so you may find the next few sections handy.
-The more detailed <i>JNI Programmer's Guide and Specification</i> can be found
-<a href="http://java.sun.com/docs/books/jni/html/jniTOC.html">here</a>.</p>
+There's a more detailed <a href="http://java.sun.com/docs/books/jni/html/jniTOC.html">JNI Programmer's Guide and Specification</a>.</p>
<a name="JavaVM_and_JNIEnv" id="JavaVM_and_JNIEnv"></a>
@@ -55,20 +54,20 @@
<p>On some VMs, the JNIEnv is used for thread-local storage. For this reason, <strong>you cannot share a JNIEnv between threads</strong>.
If a piece of code has no other way to get its JNIEnv, you should share
-the JavaVM, and use JavaVM->GetEnv to discover the thread's JNIEnv. (Assuming it has one; see <code>AttachCurrentThread</code> below.)</p>
+the JavaVM, and use <code>GetEnv</code> to discover the thread's JNIEnv. (Assuming it has one; see <code>AttachCurrentThread</code> below.)</p>
<p>The C declarations of JNIEnv and JavaVM are different from the C++
-declarations. "jni.h" provides different typedefs
-depending on whether it's included into ".c" or ".cpp". For this reason it's a bad idea to
+declarations. The <code>"jni.h"</code> include file provides different typedefs
+depending on whether it's included into C or C++. For this reason it's a bad idea to
include JNIEnv arguments in header files included by both languages. (Put another way: if your
-header file requires "#ifdef __cplusplus", you may have to do some extra work if anything in
+header file requires <code>#ifdef __cplusplus</code>, you may have to do some extra work if anything in
that header refers to JNIEnv.)</p>
<a name="threads" id="threads"></a>
<h2>Threads</h2>
<p>All VM threads are Linux threads, scheduled by the kernel. They're usually
-started using Java language features (notably <code>Thread.start()</code>),
+started using Java language features (notably <code>Thread.start</code>),
but they can also be created elsewhere and then attached to the VM. For
example, a thread started with <code>pthread_create</code> can be attached
with the JNI <code>AttachCurrentThread</code> or
@@ -87,7 +86,7 @@
<p>Threads attached through JNI <strong>must call
<code>DetachCurrentThread</code> before they exit</strong>.
-If coding this directly is awkward, in Android >= 2.0 ("Eclair") you
+If coding this directly is awkward, in Android 2.0 (Eclair) and higher you
can use <code>pthread_key_create</code> to define a destructor
function that will be called before the thread exits, and
call <code>DetachCurrentThread</code> from there. (Use that
@@ -104,7 +103,7 @@
<ul>
<li> Get the class object reference for the class with <code>FindClass</code></li>
<li> Get the field ID for the field with <code>GetFieldID</code></li>
-<li> Get the contents of the field with something appropriate, e.g.
+<li> Get the contents of the field with something appropriate, such as
<code>GetIntField</code></li>
</ul>
@@ -114,12 +113,12 @@
is very quick.</p>
<p>If performance is important, it's useful to look the values up once and cache the results
-in your native code. Because we are limiting ourselves to one VM per process, it's reasonable
+in your native code. Because there is a limit of one VM per process, it's reasonable
to store this data in a static local structure.</p>
<p>The class references, field IDs, and method IDs are guaranteed valid until the class is unloaded. Classes
are only unloaded if all classes associated with a ClassLoader can be garbage collected,
-which is rare but will not be impossible in our system. Note however that
+which is rare but will not be impossible in Android. Note however that
the <code>jclass</code>
is a class reference and <strong>must be protected</strong> with a call
to <code>NewGlobalRef</code> (see the next section).</p>
@@ -130,27 +129,18 @@
<pre> /*
* We use a class initializer to allow the native code to cache some
- * field offsets.
+ * field offsets. This native function looks up and caches interesting
+ * class/field/method IDs. Throws on failure.
*/
+ private static native void nativeInit();
- /*
- * A native function that looks up and caches interesting
- * class/field/method IDs for this class. Returns false on failure.
- */
- native private static boolean nativeClassInit();
-
- /*
- * Invoke the native initializer when the class is loaded.
- */
static {
- if (!nativeClassInit())
- throw new RuntimeException("native init failed");
+ nativeInit();
}</pre>
-<p>Create a nativeClassInit method in your C/C++ code that performs the ID lookups. The code
+<p>Create a <code>nativeClassInit</code> method in your C/C++ code that performs the ID lookups. The code
will be executed once, when the class is initialized. If the class is ever unloaded and
-then reloaded, it will be executed again. (See the implementation of java.io.FileDescriptor
-for an example in our source tree.)</p>
+then reloaded, it will be executed again.</p>
<a name="local_and_global_references" id="local_and_global_references"></a>
<h2>Local and Global References</h2>
@@ -175,12 +165,12 @@
jclass globalClass = reinterpret_cast<jclass>(env->NewGlobalRef(localClass));</pre>
<p>All JNI methods accept both local and global references as arguments.
-It's possible for references to the same object to have different values;
-for example, the return values from consecutive calls to
+It's possible for references to the same object to have different values.
+For example, the return values from consecutive calls to
<code>NewGlobalRef</code> on the same object may be different.
<strong>To see if two references refer to the same object,
you must use the <code>IsSameObject</code> function.</strong> Never compare
-references with "==" in native code.</p>
+references with <code>==</code> in native code.</p>
<p>One consequence of this is that you
<strong>must not assume object references are constant or unique</strong>
@@ -197,13 +187,13 @@
16 local references, so if you need more than that you should either delete as you go or use
<code>EnsureLocalCapacity</code> to reserve more.</p>
-<p>Note: method and field IDs are just 32-bit identifiers, not object
+<p>Note that <code>jfieldID</code>s and <code>jmethodID</code>s are just integers, not object
references, and should not be passed to <code>NewGlobalRef</code>. The raw data
pointers returned by functions like <code>GetStringUTFChars</code>
and <code>GetByteArrayElements</code> are also not objects.</p>
<p>One unusual case deserves separate mention. If you attach a native
-thread to the VM with AttachCurrentThread, the code you are running will
+thread to the VM with <code>AttachCurrentThread</code>, the code you are running will
never "return" to the VM until the thread detaches from the VM. Any local
references you create will have to be deleted manually unless you're going
to detach the thread soon.</p>
@@ -217,17 +207,17 @@
suitable for use with standard libc string functions. The down side is that you cannot pass
arbitrary UTF-8 data into the VM and expect it to work correctly.</p>
-<p>It's usually best to operate with UTF-16 strings. With our current VMs, the
+<p>It's usually best to operate with UTF-16 strings. With Android's current VMs, the
<code>GetStringChars</code> method
does not require a copy, whereas <code>GetStringUTFChars</code> requires a malloc and a UTF conversion. Note that
<strong>UTF-16 strings are not zero-terminated</strong>, and \u0000 is allowed,
so you need to hang on to the string length as well as
the string pointer.</p>
-<p><strong>Don't forget to Release the strings you Get</strong>. The
+<p><strong>Don't forget to <code>Release</code> the strings you <code>Get</code></strong>. The
string functions return <code>jchar*</code> or <code>jbyte*</code>, which
are C-style pointers to primitive data rather than local references. They
-are guaranteed valid until Release is called, which means they are not
+are guaranteed valid until <code>Release</code> is called, which means they are not
released when the native method returns.</p>
<p><strong>Data passed to NewStringUTF must be in Modified UTF-8 format</strong>. A
@@ -254,8 +244,8 @@
is guaranteed to be valid until the corresponding <code>Release</code> call
is issued (which implies that, if the data wasn't copied, the array object
will be pinned down and can't be relocated as part of compacting the heap).
-<strong>You must Release every array you Get.</strong> Also, if the Get
-call fails, you must ensure that your code doesn't try to Release a NULL
+<strong>You must <code>Release</code> every array you <code>Get</code>.</strong> Also, if the <code>Get</code>
+call fails, you must ensure that your code doesn't try to <code>Release</code> a NULL
pointer later.</p>
<p>You can determine whether or not the data was copied by passing in a
@@ -298,12 +288,12 @@
you, there's no need to create another "editable" copy. If JNI is passing
you the original, then you do need to make your own copy.</p>
-<p>Some have asserted that you can skip the <code>Release</code> call if
+<p>It is a common mistake (repeated in example code) to assume that you can skip the <code>Release</code> call if
<code>*isCopy</code> is false. This is not the case. If no copy buffer was
allocated, then the original memory must be pinned down and can't be moved by
the garbage collector.</p>
-<p>Also note that the <code>JNI_COMMIT</code> flag does NOT release the array,
+<p>Also note that the <code>JNI_COMMIT</code> flag does <strong>not</strong> release the array,
and you will need to call <code>Release</code> again with a different flag
eventually.</p>
@@ -315,8 +305,7 @@
and <code>GetStringChars</code> that may be very helpful when all you want
to do is copy data in or out. Consider the following:</p>
-<pre>
- jbyte* data = env->GetByteArrayElements(array, NULL);
+<pre> jbyte* data = env->GetByteArrayElements(array, NULL);
if (data != NULL) {
memcpy(buffer, data, len);
env->ReleaseByteArrayElements(array, data, JNI_ABORT);
@@ -325,12 +314,11 @@
<p>This grabs the array, copies the first <code>len</code> byte
elements out of it, and then releases the array. Depending upon the VM
policies the <code>Get</code> call will either pin or copy the array contents.
-We copy the data (for perhaps a second time), then call Release; in this case
-we use <code>JNI_ABORT</code> so there's no chance of a third copy.</p>
+The code copies the data (for perhaps a second time), then calls <code>Release</code>; in this case
+<code>JNI_ABORT</code> ensures there's no chance of a third copy.</p>
-<p>We can accomplish the same thing with this:</p>
-<pre>
- env->GetByteArrayRegion(array, 0, len, buffer);</pre>
+<p>One can accomplish the same thing more simply:</p>
+<pre> env->GetByteArrayRegion(array, 0, len, buffer);</pre>
<p>This has several advantages:</p>
<ul>
@@ -349,29 +337,29 @@
<a name="exceptions" id="exceptions"></a>
<h2>Exception</h2>
-<p><strong>You may not call most JNI functions while an exception is pending.</strong>
+<p><strong>You must not call most JNI functions while an exception is pending.</strong>
Your code is expected to notice the exception (via the function's return value,
-<code>ExceptionCheck()</code>, or <code>ExceptionOccurred()</code>) and return,
+<code>ExceptionCheck</code>, or <code>ExceptionOccurred</code>) and return,
or clear the exception and handle it.</p>
<p>The only JNI functions that you are allowed to call while an exception is
pending are:</p>
<ul>
- <li>DeleteGlobalRef
- <li>DeleteLocalRef
- <li>DeleteWeakGlobalRef
- <li>ExceptionCheck
- <li>ExceptionClear
- <li>ExceptionDescribe
- <li>ExceptionOccurred
- <li>MonitorExit
- <li>PopLocalFrame
- <li>PushLocalFrame
- <li>Release<PrimitiveType>ArrayElements
- <li>ReleasePrimitiveArrayCritical
- <li>ReleaseStringChars
- <li>ReleaseStringCritical
- <li>ReleaseStringUTFChars
+ <li><code>DeleteGlobalRef</code>
+ <li><code>DeleteLocalRef</code>
+ <li><code>DeleteWeakGlobalRef</code>
+ <li><code>ExceptionCheck</code>
+ <li><code>ExceptionClear</code>
+ <li><code>ExceptionDescribe</code>
+ <li><code>ExceptionOccurred</code>
+ <li><code>MonitorExit</code>
+ <li><code>PopLocalFrame</code>
+ <li><code>PushLocalFrame</code>
+ <li><code>Release<PrimitiveType>ArrayElements</code>
+ <li><code>ReleasePrimitiveArrayCritical</code>
+ <li><code>ReleaseStringChars</code>
+ <li><code>ReleaseStringCritical</code>
+ <li><code>ReleaseStringUTFChars</code>
</ul>
<p>Many JNI calls can throw an exception, but often provide a simpler way
@@ -392,86 +380,80 @@
<code>ExceptionClear</code>. As usual,
discarding exceptions without handling them can lead to problems.</p>
-<p>There are no built-in functions for manipulating the Throwable object
+<p>There are no built-in functions for manipulating the <code>Throwable</code> object
itself, so if you want to (say) get the exception string you will need to
-find the Throwable class, look up the method ID for
+find the <code>Throwable</code> class, look up the method ID for
<code>getMessage "()Ljava/lang/String;"</code>, invoke it, and if the result
is non-NULL use <code>GetStringUTFChars</code> to get something you can
-hand to printf or a LOG macro.</p>
+hand to <code>printf(3)</code> or equivalent.</p>
<a name="extended_checking" id="extended_checking"></a>
<h2>Extended Checking</h2>
-<p>JNI does very little error checking. Calling <code>SetIntField</code>
-on an Object field will succeed, even if the field is marked
-<code>private</code> and <code>final</code>. The
-goal is to minimize the overhead on the assumption that, if you've written it in native code,
-you probably did it for performance reasons.</p>
+<p>JNI does very little error checking. Errors usually result in a crash. Android also offers a mode called CheckJNI, where the JavaVM and JNIEnv function table pointers are switched to tables of functions that perform an extended series of checks before calling the standard implementation.</p>
-<p>In Dalvik, you can enable additional checks by setting the
-"<code>-Xcheck:jni</code>" flag. If the flag is set, the VM directs
-the JavaVM and JNIEnv pointers to a different table of functions.
-These functions perform an extended series of checks before calling the
-standard implementation.</p>
-
-<p>The additional tests include:</p>
+<p>The additional checks include:</p>
<ul>
-<li> Check for null pointers where not allowed.</li>
-<li> Verify argument type correctness (jclass is a class object,
-jfieldID points to field data, jstring is a java.lang.String).</li>
-<li> Field type correctness, e.g. don't store a HashMap in a String field.</li>
-<li> Ensure jmethodID is appropriate when making a static or virtual
-method call.</li>
-<li> Check to see if an exception is pending on calls where pending exceptions are not legal.</li>
-<li> Check for calls to inappropriate functions between Critical get/release calls.</li>
-<li> Check that JNIEnv structs aren't being shared between threads.</li>
-<li> Make sure local references aren't used outside their allowed lifespan.</li>
-<li> UTF-8 strings contain only valid <a href="http://en.wikipedia.org/wiki/UTF-8#Modified_UTF-8">Modified UTF-8</a> data.</li>
+<li>Arrays: attempting to allocate a negative-sized array.</li>
+<li>Bad pointers: passing a bad jarray/jclass/jobject/jstring to a JNI call, or passing a NULL pointer to a JNI call with a non-nullable argument.</li>
+<li>Class names: passing anything but the “java/lang/String” style of class name to a JNI call.</li>
+<li>Critical calls: making a JNI call between a “critical” get and its corresponding release.</li>
+<li>Direct ByteBuffers: passing bad arguments to <code>NewDirectByteBuffer</code>.</li>
+<li>Exceptions: making a JNI call while there’s an exception pending.</li>
+<li>JNIEnv*s: using a JNIEnv* from the wrong thread.</li>
+<li>jfieldIDs: using a NULL jfieldID, or using a jfieldID to set a field to a value of the wrong type (trying to assign a StringBuilder to a String field, say), or using a jfieldID for a static field to set an instance field or vice versa, or using a jfieldID from one class with instances of another class.</li>
+<li>jmethodIDs: using the wrong kind of jmethodID when making a <code>Call*Method</code> JNI call: incorrect return type, static/non-static mismatch, wrong type for ‘this’ (for non-static calls) or wrong class (for static calls).</li>
+<li>References: using <code>DeleteGlobalRef</code>/<code>DeleteLocalRef</code> on the wrong kind of reference.</li>
+<li>Release modes: passing a bad release mode to a release call (something other than <code>0</code>, <code>JNI_ABORT</code>, or <code>JNI_COMMIT</code>).</li>
+<li>Type safety: returning an incompatible type from your native method (returning a StringBuilder from a method declared to return a String, say).</li>
+<li>UTF-8: passing an invalid <a href="http://en.wikipedia.org/wiki/UTF-8#Modified_UTF-8">Modified UTF-8</a> byte sequence to a JNI call.</li>
</ul>
-<p>Accessibility of methods and fields (i.e. public vs. private) is not
-checked.</p>
+<p>(Accessibility of methods and fields is still not checked: access restrictions don't apply to native code.)</p>
-<p>For a description of how to enable CheckJNI for Android apps, see
-<a href="embedded-vm-control.html">Controlling the Embedded VM</a>.
-It's currently enabled by default in the Android emulator and on
-"engineering" device builds.</p>
+<p>There are several ways to enable CheckJNI.</p>
-<p>JNI checks can be modified with the <code>-Xjniopts</code> command-line
-flag. Currently supported values include:</p>
+<p>If you’re using the emulator, CheckJNI is on by default.</p>
-<dl>
-<dt>forcecopy
-<dd>When set, any function that can return a copy of the original data
-(array of primitive values, UTF-16 chars) will always do so. The buffers
-are over-allocated and surrounded with a guard pattern to help identify
-code writing outside the buffer, and the contents are erased before the
-storage is freed to trip up code that uses the data after calling Release.
-This will have a noticeable performance impact on some applications.
-<dt>warnonly
-<dd>By default, JNI "warnings" cause the VM to abort. With this flag
-it continues on.
-</dl>
+<p>If you have a rooted device, you can use the following sequence of commands to restart the runtime with CheckJNI enabled:</p>
+
+<pre>adb shell stop
+adb shell setprop dalvik.vm.checkjni true
+adb shell start</pre>
+
+<p>In either of these cases, you’ll see something like this in your logcat output when the runtime starts:</p>
+
+<pre>D AndroidRuntime: CheckJNI is ON</pre>
+
+<p>If you have a regular device, you can use the following command:</p>
+
+<pre>adb shell setprop debug.checkjni 1</pre>
+
+<p>This won’t affect already-running apps, but any app launched from that point on will have CheckJNI enabled. (Change the property to any other value or simply rebooting will disable CheckJNI again.) In this case, you’ll see something like this in your logcat output the next time an app starts:</p>
+
+<pre>D Late-enabling CheckJNI</pre>
+
+
<a name="native_libraries" id="native_libraries"></a>
<h2>Native Libraries</h2>
<p>You can load native code from shared libraries with the standard
-<code>System.loadLibrary()</code> call. The
+<code>System.loadLibrary</code> call. The
preferred way to get at your native code is:</p>
<ul>
-<li> Call <code>System.loadLibrary()</code> from a static class
+<li> Call <code>System.loadLibrary</code> from a static class
initializer. (See the earlier example, where one is used to call
-<code>nativeClassInit()</code>.) The argument is the "undecorated"
-library name, e.g. to load "libfubar.so" you would pass in "fubar".</li>
+<code>nativeClassInit</code>.) The argument is the "undecorated"
+library name, so to load "libfubar.so" you would pass in "fubar".</li>
<li> Provide a native function: <code><strong>jint JNI_OnLoad(JavaVM* vm, void* reserved)</strong></code></li>
<li>In <code>JNI_OnLoad</code>, register all of your native methods. You
should declare
-the functions <code>static</code> so the names don't take up space in the symbol table
+the methods "static" so the names don't take up space in the symbol table
on the device.</li>
</ul>
@@ -490,7 +472,7 @@
return JNI_VERSION_1_6;
}</pre>
-<p>You can also call <code>System.load()</code> with the full path name of the
+<p>You can also call <code>System.load</code> with the full path name of the
shared library. For Android apps, you may find it useful to get the full
path to the application's private data storage area from the context object.</p>
@@ -549,28 +531,28 @@
<p>For backward compatibility, you may need to be aware of:</p>
<ul>
- <li>Until Android 2.0 ("Eclair"), the '$' character was not properly
+ <li>Until Android 2.0 (Eclair), the '$' character was not properly
converted to "_00024" during searches for method names. Working
around this requires using explicit registration or moving the
native methods out of inner classes.
- <li>Until Android 2.0 ("Eclair"), it was not possible to use a <code>pthread_key_create</code>
+ <li>Until Android 2.0 (Eclair), it was not possible to use a <code>pthread_key_create</code>
destructor function to avoid the VM's "thread must be detached before
exit" check. (The VM also uses a pthread key destructor function,
so it'd be a race to see which gets called first.)
- <li>"Weak global" references were not implemented until Android 2.2 ("Froyo").
+ <li>Until Android 2.2 (Froyo), weak global references were not implemented.
Older VMs will vigorously reject attempts to use them. You can use
the Android platform version constants to test for support.
</ul>
<a name="faq_ULE" id="faq_ULE"></a>
-<h2>FAQ: UnsatisfiedLinkError</h2>
+<h2>FAQ: Why do I get <code>UnsatisfiedLinkError</code>?</h2>
<p>When working on native code it's not uncommon to see a failure like this:</p>
<pre>java.lang.UnsatisfiedLinkError: Library foo not found</pre>
<p>In some cases it means what it says — the library wasn't found. In
-other cases the library exists but couldn't be opened by dlopen(), and
+other cases the library exists but couldn't be opened by <code>dlopen(3)</code>, and
the details of the failure can be found in the exception's detail message.</p>
<p>Common reasons why you might encounter "library not found" exceptions:</p>
@@ -601,7 +583,7 @@
<li>For lazy method lookup, failing to declare C++ functions
with <code>extern "C"</code>. You can use <code>arm-eabi-nm</code>
to see the symbols as they appear in the library; if they look
- mangled (e.g. <code>_Z15Java_Foo_myfuncP7_JNIEnvP7_jclass</code>
+ mangled (something like <code>_Z15Java_Foo_myfuncP7_JNIEnvP7_jclass</code>
rather than <code>Java_Foo_myfunc</code>) then you need to
adjust the declaration.
<li>For explicit registration, minor errors when entering the
@@ -610,8 +592,7 @@
Remember that 'B' is <code>byte</code> and 'Z' is <code>boolean</code>.
Class name components in signatures start with 'L', end with ';',
use '/' to separate package/class names, and use '$' to separate
- inner-class names
- (e.g. <code>Ljava/util/Map$Entry;</code>).
+ inner-class names (<code>Ljava/util/Map$Entry;</code>, say).
</ul>
</ul>
@@ -620,11 +601,11 @@
<a name="faq_FindClass" id="faq_FindClass"></a>
-<h2>FAQ: FindClass didn't find my class</h2>
+<h2>FAQ: Why didn't <code>FindClass</code> find my class?</h2>
<p>Make sure that the class name string has the correct format. JNI class
names start with the package name and are separated with slashes,
-e.g. <code>java/lang/String</code>. If you're looking up an array class,
+such as <code>java/lang/String</code>. If you're looking up an array class,
you need to start with the appropriate number of square brackets and
must also wrap the class with 'L' and ';', so a one-dimensional array of
<code>String</code> would be <code>[Ljava/lang/String;</code>.</p>
@@ -663,8 +644,8 @@
If your app code is loading the library, <code>FindClass</code>
will use the correct class loader.
<li>Pass an instance of the class into the functions that need
- it, e.g. declare your native method to take a Class argument and
- then pass <code>Foo.class</code> in.
+ it, by declaring your native method to take a Class argument and
+ then passing <code>Foo.class</code> in.
<li>Cache a reference to the <code>ClassLoader</code> object somewhere
handy, and issue <code>loadClass</code> calls directly. This requires
some effort.
@@ -672,7 +653,7 @@
<a name="faq_sharing" id="faq_sharing"></a>
-<h2>FAQ: Sharing raw data with native code</h2>
+<h2>FAQ: How do I share raw data with native code?</h2>
<p>You may find yourself in a situation where you need to access a large
buffer of raw data from code written in Java and C/C++. Common examples
diff --git a/graphics/java/android/graphics/Bitmap.java b/graphics/java/android/graphics/Bitmap.java
index 3fc6463..79acd55 100644
--- a/graphics/java/android/graphics/Bitmap.java
+++ b/graphics/java/android/graphics/Bitmap.java
@@ -93,7 +93,7 @@
This can be called from JNI code.
*/
- private Bitmap(int nativeBitmap, byte[] buffer, boolean isMutable, byte[] ninePatchChunk,
+ /*package*/ Bitmap(int nativeBitmap, byte[] buffer, boolean isMutable, byte[] ninePatchChunk,
int density) {
if (nativeBitmap == 0) {
throw new RuntimeException("internal error: native bitmap is 0");
diff --git a/graphics/java/android/graphics/Canvas.java b/graphics/java/android/graphics/Canvas.java
index 6ae8c9b..eefd21e 100644
--- a/graphics/java/android/graphics/Canvas.java
+++ b/graphics/java/android/graphics/Canvas.java
@@ -508,17 +508,6 @@
}
/**
- * Returns a pointer to an internal 4x4 native matrix. The returned
- * pointer is a pointer to an array of 16 floats.
- *
- * @hide
- */
- @SuppressWarnings({"UnusedDeclaration"})
- public int getNativeMatrix() {
- return 0;
- }
-
- /**
* Return a new matrix with a copy of the canvas' current transformation
* matrix.
*/
diff --git a/graphics/java/android/graphics/Paint.java b/graphics/java/android/graphics/Paint.java
index fe4b082..828bafd 100644
--- a/graphics/java/android/graphics/Paint.java
+++ b/graphics/java/android/graphics/Paint.java
@@ -70,16 +70,16 @@
*/
public int mBidiFlags = BIDI_DEFAULT_LTR;
- private static final Style[] sStyleArray = {
+ static final Style[] sStyleArray = {
Style.FILL, Style.STROKE, Style.FILL_AND_STROKE
};
- private static final Cap[] sCapArray = {
+ static final Cap[] sCapArray = {
Cap.BUTT, Cap.ROUND, Cap.SQUARE
};
- private static final Join[] sJoinArray = {
+ static final Join[] sJoinArray = {
Join.MITER, Join.ROUND, Join.BEVEL
};
- private static final Align[] sAlignArray = {
+ static final Align[] sAlignArray = {
Align.LEFT, Align.CENTER, Align.RIGHT
};
@@ -103,7 +103,7 @@
public static final int DEV_KERN_TEXT_FLAG = 0x100;
// we use this when we first create a paint
- private static final int DEFAULT_PAINT_FLAGS = DEV_KERN_TEXT_FLAG;
+ static final int DEFAULT_PAINT_FLAGS = DEV_KERN_TEXT_FLAG;
/**
* Bidi flag to set LTR paragraph direction.
diff --git a/graphics/java/android/graphics/Path.java b/graphics/java/android/graphics/Path.java
index c5d7500..b4f1e84d 100644
--- a/graphics/java/android/graphics/Path.java
+++ b/graphics/java/android/graphics/Path.java
@@ -115,7 +115,7 @@
}
// these must be in the same order as their native values
- private static final FillType[] sFillTypeArray = {
+ static final FillType[] sFillTypeArray = {
FillType.WINDING,
FillType.EVEN_ODD,
FillType.INVERSE_WINDING,
diff --git a/graphics/java/android/graphics/Typeface.java b/graphics/java/android/graphics/Typeface.java
index bc92d3a..ed6fa08 100644
--- a/graphics/java/android/graphics/Typeface.java
+++ b/graphics/java/android/graphics/Typeface.java
@@ -43,7 +43,7 @@
/** The NORMAL style of the default monospace typeface. */
public static final Typeface MONOSPACE;
- private static Typeface[] sDefaults;
+ /* package */ static Typeface[] sDefaults;
/* package */ int native_instance;
diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp
index ed2fa3c..4864cff 100644
--- a/libs/hwui/OpenGLRenderer.cpp
+++ b/libs/hwui/OpenGLRenderer.cpp
@@ -924,13 +924,6 @@
mSnapshot->transform->load(*matrix);
}
-const float* OpenGLRenderer::getMatrix() const {
- if (mSnapshot->fbo != 0) {
- return &mSnapshot->transform->data[0];
- }
- return &mIdentity.data[0];
-}
-
void OpenGLRenderer::getMatrix(SkMatrix* matrix) {
mSnapshot->transform->copyTo(*matrix);
}
diff --git a/libs/hwui/OpenGLRenderer.h b/libs/hwui/OpenGLRenderer.h
index fa893f0..14b22b3 100644
--- a/libs/hwui/OpenGLRenderer.h
+++ b/libs/hwui/OpenGLRenderer.h
@@ -87,7 +87,6 @@
virtual void scale(float sx, float sy);
virtual void skew(float sx, float sy);
- const float* getMatrix() const;
void getMatrix(SkMatrix* matrix);
virtual void setMatrix(SkMatrix* matrix);
virtual void concatMatrix(SkMatrix* matrix);
diff --git a/media/java/android/media/MediaScanner.java b/media/java/android/media/MediaScanner.java
index 1ba4c4f..2d1761f 100644
--- a/media/java/android/media/MediaScanner.java
+++ b/media/java/android/media/MediaScanner.java
@@ -327,6 +327,8 @@
// used when scanning the image database so we know whether we have to prune
// old thumbnail files
private int mOriginalCount;
+ /** Whether the database had any entries in it before the scan started */
+ private boolean mWasEmptyPriorToScan = false;
/** Whether the scanner has set a default sound for the ringer ringtone. */
private boolean mDefaultRingtoneSet;
/** Whether the scanner has set a default sound for the notification ringtone. */
@@ -547,6 +549,7 @@
return entry;
}
+ @Override
public void scanFile(String path, long lastModified, long fileSize,
boolean isDirectory, boolean noMedia) {
// This is the callback funtion from native codes.
@@ -901,19 +904,19 @@
mMediaProvider.update(result, values, null, null);
}
- if (notifications && !mDefaultNotificationSet) {
+ if (notifications && mWasEmptyPriorToScan && !mDefaultNotificationSet) {
if (TextUtils.isEmpty(mDefaultNotificationFilename) ||
doesPathHaveFilename(entry.mPath, mDefaultNotificationFilename)) {
setSettingIfNotSet(Settings.System.NOTIFICATION_SOUND, tableUri, rowId);
mDefaultNotificationSet = true;
}
- } else if (ringtones && !mDefaultRingtoneSet) {
+ } else if (ringtones && mWasEmptyPriorToScan && !mDefaultRingtoneSet) {
if (TextUtils.isEmpty(mDefaultRingtoneFilename) ||
doesPathHaveFilename(entry.mPath, mDefaultRingtoneFilename)) {
setSettingIfNotSet(Settings.System.RINGTONE, tableUri, rowId);
mDefaultRingtoneSet = true;
}
- } else if (alarms && !mDefaultAlarmSet) {
+ } else if (alarms && mWasEmptyPriorToScan && !mDefaultAlarmSet) {
if (TextUtils.isEmpty(mDefaultAlarmAlertFilename) ||
doesPathHaveFilename(entry.mPath, mDefaultAlarmAlertFilename)) {
setSettingIfNotSet(Settings.System.ALARM_ALERT, tableUri, rowId);
@@ -997,6 +1000,7 @@
where, selectionArgs, null);
if (c != null) {
+ mWasEmptyPriorToScan = c.getCount() == 0;
while (c.moveToNext()) {
long rowId = c.getLong(FILES_PRESCAN_ID_COLUMN_INDEX);
String path = c.getString(FILES_PRESCAN_PATH_COLUMN_INDEX);
diff --git a/packages/SystemUI/res/layout-sw600dp/status_bar_notification_area.xml b/packages/SystemUI/res/layout-sw600dp/status_bar_notification_area.xml
index 17fa653..c735dbd 100644
--- a/packages/SystemUI/res/layout-sw600dp/status_bar_notification_area.xml
+++ b/packages/SystemUI/res/layout-sw600dp/status_bar_notification_area.xml
@@ -24,6 +24,8 @@
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:orientation="horizontal"
+ android:background="?android:attr/listChoiceBackgroundIndicator"
+ android:clickable="true"
>
<LinearLayout
@@ -65,14 +67,7 @@
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:layout_marginLeft="8dp"
- />
- <View
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_alignLeft="@id/icons"
- android:layout_alignRight="@id/icons"
- android:background="@drawable/notification_icon_area_smoke"
- android:clickable="false"
+ android:alpha="0.4"
/>
</com.android.systemui.statusbar.tablet.NotificationIconArea>
</LinearLayout>
@@ -88,7 +83,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="3dip"
- android:layout_marginLeft="4dip"
+ android:layout_marginLeft="8dip"
android:layout_marginRight="4dip"
>
<TextView android:id="@+id/time_solid"
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 7f56d45..e90aad4 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java
@@ -103,6 +103,11 @@
// Fitts' Law assistance for LatinIME; see policy.EventHole
private static final boolean FAKE_SPACE_BAR = true;
+ // Notification "peeking" (flyover preview of individual notifications)
+ final static boolean NOTIFICATION_PEEK_ENABLED = false;
+ final static int NOTIFICATION_PEEK_HOLD_THRESH = 200; // ms
+ final static int NOTIFICATION_PEEK_FADE_DELAY = 3000; // ms
+
// The height of the bar, as definied by the build. It may be taller if we're plugged
// into hdmi.
int mNaturalBarHeight = -1;
@@ -250,43 +255,45 @@
WindowManagerImpl.getDefault().addView(mNotificationPanel, lp);
// Notification preview window
- mNotificationPeekWindow = (NotificationPeekPanel) View.inflate(context,
- R.layout.status_bar_notification_peek, null);
- mNotificationPeekWindow.setBar(this);
+ if (NOTIFICATION_PEEK_ENABLED) {
+ mNotificationPeekWindow = (NotificationPeekPanel) View.inflate(context,
+ R.layout.status_bar_notification_peek, null);
+ mNotificationPeekWindow.setBar(this);
- mNotificationPeekRow = (ViewGroup) mNotificationPeekWindow.findViewById(R.id.content);
- mNotificationPeekWindow.setVisibility(View.GONE);
- mNotificationPeekWindow.setOnTouchListener(
- new TouchOutsideListener(MSG_CLOSE_NOTIFICATION_PEEK, mNotificationPeekWindow));
- mNotificationPeekScrubRight = new LayoutTransition();
- mNotificationPeekScrubRight.setAnimator(LayoutTransition.APPEARING,
- ObjectAnimator.ofInt(null, "left", -512, 0));
- mNotificationPeekScrubRight.setAnimator(LayoutTransition.DISAPPEARING,
- ObjectAnimator.ofInt(null, "left", -512, 0));
- mNotificationPeekScrubRight.setDuration(500);
+ mNotificationPeekRow = (ViewGroup) mNotificationPeekWindow.findViewById(R.id.content);
+ mNotificationPeekWindow.setVisibility(View.GONE);
+ mNotificationPeekWindow.setOnTouchListener(
+ new TouchOutsideListener(MSG_CLOSE_NOTIFICATION_PEEK, mNotificationPeekWindow));
+ mNotificationPeekScrubRight = new LayoutTransition();
+ mNotificationPeekScrubRight.setAnimator(LayoutTransition.APPEARING,
+ ObjectAnimator.ofInt(null, "left", -512, 0));
+ mNotificationPeekScrubRight.setAnimator(LayoutTransition.DISAPPEARING,
+ ObjectAnimator.ofInt(null, "left", -512, 0));
+ mNotificationPeekScrubRight.setDuration(500);
- mNotificationPeekScrubLeft = new LayoutTransition();
- mNotificationPeekScrubLeft.setAnimator(LayoutTransition.APPEARING,
- ObjectAnimator.ofInt(null, "left", 512, 0));
- mNotificationPeekScrubLeft.setAnimator(LayoutTransition.DISAPPEARING,
- ObjectAnimator.ofInt(null, "left", 512, 0));
- mNotificationPeekScrubLeft.setDuration(500);
+ mNotificationPeekScrubLeft = new LayoutTransition();
+ mNotificationPeekScrubLeft.setAnimator(LayoutTransition.APPEARING,
+ ObjectAnimator.ofInt(null, "left", 512, 0));
+ mNotificationPeekScrubLeft.setAnimator(LayoutTransition.DISAPPEARING,
+ ObjectAnimator.ofInt(null, "left", 512, 0));
+ mNotificationPeekScrubLeft.setDuration(500);
- // XXX: setIgnoreChildren?
- lp = new WindowManager.LayoutParams(
- 512, // ViewGroup.LayoutParams.WRAP_CONTENT,
- ViewGroup.LayoutParams.WRAP_CONTENT,
- WindowManager.LayoutParams.TYPE_STATUS_BAR_PANEL,
- WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
- | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM
- | WindowManager.LayoutParams.FLAG_SPLIT_TOUCH,
- PixelFormat.TRANSLUCENT);
- lp.gravity = Gravity.BOTTOM | Gravity.RIGHT;
- lp.y = res.getDimensionPixelOffset(R.dimen.peek_window_y_offset);
- lp.setTitle("NotificationPeekWindow");
- lp.windowAnimations = com.android.internal.R.style.Animation_Toast;
+ // XXX: setIgnoreChildren?
+ lp = new WindowManager.LayoutParams(
+ 512, // ViewGroup.LayoutParams.WRAP_CONTENT,
+ ViewGroup.LayoutParams.WRAP_CONTENT,
+ WindowManager.LayoutParams.TYPE_STATUS_BAR_PANEL,
+ WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
+ | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM
+ | WindowManager.LayoutParams.FLAG_SPLIT_TOUCH,
+ PixelFormat.TRANSLUCENT);
+ lp.gravity = Gravity.BOTTOM | Gravity.RIGHT;
+ lp.y = res.getDimensionPixelOffset(R.dimen.peek_window_y_offset);
+ lp.setTitle("NotificationPeekWindow");
+ lp.windowAnimations = com.android.internal.R.style.Animation_Toast;
- WindowManagerImpl.getDefault().addView(mNotificationPeekWindow, lp);
+ WindowManagerImpl.getDefault().addView(mNotificationPeekWindow, lp);
+ }
// Recents Panel
mRecentsPanel = (RecentsPanelView) View.inflate(context,
@@ -444,17 +451,24 @@
// the whole right-hand side of the bar
mNotificationArea = sb.findViewById(R.id.notificationArea);
+ if (!NOTIFICATION_PEEK_ENABLED) {
+ mNotificationArea.setOnTouchListener(new NotificationTriggerTouchListener());
+ }
// the button to open the notification area
mNotificationTrigger = sb.findViewById(R.id.notificationTrigger);
- mNotificationTrigger.setOnTouchListener(new NotificationTriggerTouchListener());
+ if (NOTIFICATION_PEEK_ENABLED) {
+ mNotificationTrigger.setOnTouchListener(new NotificationTriggerTouchListener());
+ }
// the more notifications icon
mNotificationIconArea = (NotificationIconArea)sb.findViewById(R.id.notificationIcons);
// where the icons go
mIconLayout = (NotificationIconArea.IconLayout) sb.findViewById(R.id.icons);
- mIconLayout.setOnTouchListener(new NotificationIconTouchListener());
+ if (NOTIFICATION_PEEK_ENABLED) {
+ mIconLayout.setOnTouchListener(new NotificationIconTouchListener());
+ }
ViewConfiguration vc = ViewConfiguration.get(context);
mNotificationPeekTapDuration = vc.getTapTimeout();
@@ -684,7 +698,9 @@
case MSG_OPEN_NOTIFICATION_PANEL:
if (DEBUG) Slog.d(TAG, "opening notifications panel");
if (!mNotificationPanel.isShowing()) {
- mNotificationPeekWindow.setVisibility(View.GONE);
+ if (NOTIFICATION_PEEK_ENABLED) {
+ mNotificationPeekWindow.setVisibility(View.GONE);
+ }
mNotificationPanel.show(true, true);
mNotificationArea.setVisibility(View.INVISIBLE);
mTicker.halt();
@@ -863,7 +879,7 @@
oldEntry.largeIcon.setVisibility(View.INVISIBLE);
}
- if (key == mNotificationPeekKey) {
+ if (NOTIFICATION_PEEK_ENABLED && key == mNotificationPeekKey) {
// must update the peek window
Message peekMsg = mHandler.obtainMessage(MSG_OPEN_NOTIFICATION_PEEK);
peekMsg.arg1 = mNotificationPeekIndex;
@@ -1010,9 +1026,11 @@
}
public void animateExpand() {
- mHandler.removeMessages(MSG_CLOSE_NOTIFICATION_PEEK);
- mHandler.removeMessages(MSG_OPEN_NOTIFICATION_PEEK);
- mHandler.sendEmptyMessage(MSG_CLOSE_NOTIFICATION_PEEK);
+ if (NOTIFICATION_PEEK_ENABLED) {
+ mHandler.removeMessages(MSG_CLOSE_NOTIFICATION_PEEK);
+ mHandler.removeMessages(MSG_OPEN_NOTIFICATION_PEEK);
+ mHandler.sendEmptyMessage(MSG_CLOSE_NOTIFICATION_PEEK);
+ }
mHandler.removeMessages(MSG_OPEN_NOTIFICATION_PANEL);
mHandler.sendEmptyMessage(MSG_OPEN_NOTIFICATION_PANEL);
}
@@ -1026,8 +1044,10 @@
mHandler.sendEmptyMessage(MSG_CLOSE_INPUT_METHODS_PANEL);
mHandler.removeMessages(MSG_CLOSE_COMPAT_MODE_PANEL);
mHandler.sendEmptyMessage(MSG_CLOSE_COMPAT_MODE_PANEL);
- mHandler.removeMessages(MSG_CLOSE_NOTIFICATION_PEEK);
- mHandler.sendEmptyMessage(MSG_CLOSE_NOTIFICATION_PEEK);
+ if (NOTIFICATION_PEEK_ENABLED) {
+ mHandler.removeMessages(MSG_CLOSE_NOTIFICATION_PEEK);
+ mHandler.sendEmptyMessage(MSG_CLOSE_NOTIFICATION_PEEK);
+ }
}
private void notifyUiVisibilityChanged() {
@@ -1328,7 +1348,7 @@
ViewGroup rowParent = (ViewGroup)entry.row.getParent();
if (rowParent != null) rowParent.removeView(entry.row);
- if (key == mNotificationPeekKey) {
+ if (NOTIFICATION_PEEK_ENABLED && key == mNotificationPeekKey) {
// must close the peek as well, since it's gone
mHandler.sendEmptyMessage(MSG_CLOSE_NOTIFICATION_PEEK);
}
@@ -1349,6 +1369,19 @@
mTouchSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop();
}
+ private Runnable mHiliteOnR = new Runnable() { public void run() {
+ mNotificationArea.setBackgroundResource(
+ com.android.internal.R.drawable.list_selector_pressed_holo_dark);
+ }};
+ public void hilite(final boolean on) {
+ if (on) {
+ mNotificationArea.postDelayed(mHiliteOnR, 100);
+ } else {
+ mNotificationArea.removeCallbacks(mHiliteOnR);
+ mNotificationArea.setBackgroundDrawable(null);
+ }
+ }
+
public boolean onTouch(View v, MotionEvent event) {
// Slog.d(TAG, String.format("touch: (%.1f, %.1f) initial: (%.1f, %.1f)",
// event.getX(),
@@ -1361,6 +1394,7 @@
mVT = VelocityTracker.obtain();
mInitialTouchX = event.getX();
mInitialTouchY = event.getY();
+ hilite(true);
// fall through
case MotionEvent.ACTION_OUTSIDE:
case MotionEvent.ACTION_MOVE:
@@ -1371,6 +1405,7 @@
// require a little more oomph once we're already in peekaboo mode
if (mVT.getYVelocity() < -mNotificationFlingVelocity) {
animateExpand();
+ hilite(false);
mVT.recycle();
mVT = null;
}
@@ -1378,6 +1413,7 @@
return true;
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
+ hilite(false);
if (mVT != null) {
if (action == MotionEvent.ACTION_UP
// was this a sloppy tap?
@@ -1399,9 +1435,6 @@
}
}
- final static int NOTIFICATION_PEEK_HOLD_THRESH = 200; // ms
- final static int NOTIFICATION_PEEK_FADE_DELAY = 3000; // ms
-
public void resetNotificationPeekFadeTimer() {
if (DEBUG) {
Slog.d(TAG, "setting peek fade timer for " + NOTIFICATION_PEEK_FADE_DELAY
diff --git a/services/java/com/android/server/BackupManagerService.java b/services/java/com/android/server/BackupManagerService.java
index 8b7d3a8..1c06636 100644
--- a/services/java/com/android/server/BackupManagerService.java
+++ b/services/java/com/android/server/BackupManagerService.java
@@ -2105,10 +2105,13 @@
backupOnePackage(pkg, out);
}
- // Finally, shared storage if requested
+ // Shared storage if requested
if (mIncludeShared) {
backupSharedStorage();
}
+
+ // Done!
+ finalizeBackup(out);
} catch (RemoteException e) {
Slog.e(TAG, "App died during full backup");
} finally {
@@ -2326,6 +2329,16 @@
}
}
+ private void finalizeBackup(OutputStream out) {
+ try {
+ // A standard 'tar' EOF sequence: two 512-byte blocks of all zeroes.
+ byte[] eof = new byte[512 * 2]; // newly allocated == zero filled
+ out.write(eof);
+ } catch (IOException e) {
+ Slog.w(TAG, "Error attempting to finalize backup stream");
+ }
+ }
+
private void writeAppManifest(PackageInfo pkg, File manifestFile, boolean withApk)
throws IOException {
// Manifest format. All data are strings ending in LF:
@@ -3186,9 +3199,11 @@
void skipTarPadding(long size, InputStream instream) throws IOException {
long partial = (size + 512) % 512;
if (partial > 0) {
- byte[] buffer = new byte[512];
- int nRead = instream.read(buffer, 0, 512 - (int)partial);
- if (nRead >= 0) mBytes += nRead;
+ final int needed = 512 - (int)partial;
+ byte[] buffer = new byte[needed];
+ if (readExactly(instream, buffer, 0, needed) == needed) {
+ mBytes += needed;
+ } else throw new IOException("Unexpected EOF in padding");
}
}
@@ -3199,12 +3214,11 @@
if (info.size > 64 * 1024) {
throw new IOException("Restore manifest too big; corrupt? size=" + info.size);
}
+
byte[] buffer = new byte[(int) info.size];
- int nRead = 0;
- while (nRead < info.size) {
- nRead += instream.read(buffer, nRead, (int)info.size - nRead);
- }
- if (nRead >= 0) mBytes += nRead;
+ if (readExactly(instream, buffer, 0, (int)info.size) == info.size) {
+ mBytes += info.size;
+ } else throw new IOException("Unexpected EOF in manifest");
RestorePolicy policy = RestorePolicy.IGNORE;
String[] str = new String[1];
@@ -3453,7 +3467,7 @@
}
} catch (IOException e) {
if (DEBUG) {
- Slog.e(TAG, "Parse error in header. Hexdump:");
+ Slog.e(TAG, "Parse error in header: " + e.getMessage());
HEXLOG(block);
}
throw e;
@@ -3479,22 +3493,31 @@
}
}
- boolean readTarHeader(InputStream instream, byte[] block) throws IOException {
- int totalRead = 0;
- while (totalRead < 512) {
- int nRead = instream.read(block, totalRead, 512 - totalRead);
- if (nRead >= 0) {
- mBytes += nRead;
- totalRead += nRead;
- } else {
- if (totalRead == 0) {
- // EOF instead of a new header; we're done
- break;
- }
- throw new IOException("Unable to read full block header, t=" + totalRead);
+ // Read exactly the given number of bytes into a buffer at the stated offset.
+ // Returns false if EOF is encountered before the requested number of bytes
+ // could be read.
+ int readExactly(InputStream in, byte[] buffer, int offset, int size)
+ throws IOException {
+ if (size <= 0) throw new IllegalArgumentException("size must be > 0");
+
+ int soFar = 0;
+ while (soFar < size) {
+ int nRead = in.read(buffer, offset + soFar, size - soFar);
+ if (nRead <= 0) {
+ if (MORE_DEBUG) Slog.w(TAG, "- wanted exactly " + size + " but got only " + soFar);
+ break;
}
+ soFar += nRead;
}
- return (totalRead == 512);
+ return soFar;
+ }
+
+ boolean readTarHeader(InputStream instream, byte[] block) throws IOException {
+ final int got = readExactly(instream, block, 0, 512);
+ if (got == 0) return false; // Clean EOF
+ if (got < 512) throw new IOException("Unable to read full block header");
+ mBytes += 512;
+ return true;
}
// overwrites 'info' fields based on the pax extended header
@@ -3510,11 +3533,10 @@
// read whole blocks, not just the content size
int numBlocks = (int)((info.size + 511) >> 9);
byte[] data = new byte[numBlocks * 512];
- int nRead = instream.read(data);
- if (nRead >= 0) mBytes += nRead;
- if (nRead != data.length) {
- return false;
+ if (readExactly(instream, data, 0, data.length) < data.length) {
+ throw new IOException("Unable to read full pax header");
}
+ mBytes += data.length;
final int contentSize = (int) info.size;
int offset = 0;
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/AnimationThread.java b/tools/layoutlib/bridge/src/android/animation/AnimationThread.java
similarity index 98%
rename from tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/AnimationThread.java
rename to tools/layoutlib/bridge/src/android/animation/AnimationThread.java
index 4c18656..2b5e4fa 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/AnimationThread.java
+++ b/tools/layoutlib/bridge/src/android/animation/AnimationThread.java
@@ -14,13 +14,14 @@
* limitations under the License.
*/
-package com.android.layoutlib.bridge.impl;
+package android.animation;
import com.android.ide.common.rendering.api.IAnimationListener;
import com.android.ide.common.rendering.api.RenderSession;
import com.android.ide.common.rendering.api.Result;
import com.android.ide.common.rendering.api.Result.Status;
import com.android.layoutlib.bridge.Bridge;
+import com.android.layoutlib.bridge.impl.RenderSessionImpl;
import android.animation.ValueAnimator;
import android.os.Handler;
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeAssetManager.java b/tools/layoutlib/bridge/src/android/content/res/BridgeAssetManager.java
similarity index 94%
rename from tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeAssetManager.java
rename to tools/layoutlib/bridge/src/android/content/res/BridgeAssetManager.java
index a825060..a953918 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeAssetManager.java
+++ b/tools/layoutlib/bridge/src/android/content/res/BridgeAssetManager.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.layoutlib.bridge.android;
+package android.content.res;
import com.android.layoutlib.bridge.Bridge;
@@ -30,7 +30,7 @@
* <p/>
* {@link Bridge} calls this method after setting up a new bridge.
*/
- /*package*/ public static AssetManager initSystem() {
+ public static AssetManager initSystem() {
if (!(AssetManager.sSystem instanceof BridgeAssetManager)) {
// Note that AssetManager() creates a system AssetManager and we override it
// with our BridgeAssetManager.
diff --git a/tools/layoutlib/bridge/src/android/content/res/BridgeResources.java b/tools/layoutlib/bridge/src/android/content/res/BridgeResources.java
index 0928ec5..7b672da 100644
--- a/tools/layoutlib/bridge/src/android/content/res/BridgeResources.java
+++ b/tools/layoutlib/bridge/src/android/content/res/BridgeResources.java
@@ -214,7 +214,15 @@
Pair<String, ResourceValue> value = getResourceValue(id, mPlatformResourceFlag);
if (value != null) {
- return value.getSecond().getValue();
+ ResourceValue resValue = value.getSecond();
+
+ assert resValue != null;
+ if (resValue != null) {
+ String v = resValue.getValue();
+ if (v != null) {
+ return v;
+ }
+ }
}
// id was not found or not resolved. Throw a NotFoundException.
@@ -318,20 +326,24 @@
Pair<String, ResourceValue> value = getResourceValue(id, mPlatformResourceFlag);
if (value != null) {
- String v = value.getSecond().getValue();
+ ResourceValue resValue = value.getSecond();
- if (v != null) {
- if (v.equals(BridgeConstants.MATCH_PARENT) ||
- v.equals(BridgeConstants.FILL_PARENT)) {
- return LayoutParams.MATCH_PARENT;
- } else if (v.equals(BridgeConstants.WRAP_CONTENT)) {
- return LayoutParams.WRAP_CONTENT;
- }
+ assert resValue != null;
+ if (resValue != null) {
+ String v = resValue.getValue();
+ if (v != null) {
+ if (v.equals(BridgeConstants.MATCH_PARENT) ||
+ v.equals(BridgeConstants.FILL_PARENT)) {
+ return LayoutParams.MATCH_PARENT;
+ } else if (v.equals(BridgeConstants.WRAP_CONTENT)) {
+ return LayoutParams.WRAP_CONTENT;
+ }
- if (ResourceHelper.parseFloatAttribute(
- value.getFirst(), v, mTmpValue, true /*requireUnit*/) &&
- mTmpValue.type == TypedValue.TYPE_DIMENSION) {
- return mTmpValue.getDimension(getDisplayMetrics());
+ if (ResourceHelper.parseFloatAttribute(
+ value.getFirst(), v, mTmpValue, true /*requireUnit*/) &&
+ mTmpValue.type == TypedValue.TYPE_DIMENSION) {
+ return mTmpValue.getDimension(getDisplayMetrics());
+ }
}
}
}
@@ -348,14 +360,18 @@
Pair<String, ResourceValue> value = getResourceValue(id, mPlatformResourceFlag);
if (value != null) {
- String v = value.getSecond().getValue();
+ ResourceValue resValue = value.getSecond();
- if (v != null) {
- if (ResourceHelper.parseFloatAttribute(
- value.getFirst(), v, mTmpValue, true /*requireUnit*/) &&
- mTmpValue.type == TypedValue.TYPE_DIMENSION) {
- return TypedValue.complexToDimensionPixelOffset(mTmpValue.data,
- getDisplayMetrics());
+ assert resValue != null;
+ if (resValue != null) {
+ String v = resValue.getValue();
+ if (v != null) {
+ if (ResourceHelper.parseFloatAttribute(
+ value.getFirst(), v, mTmpValue, true /*requireUnit*/) &&
+ mTmpValue.type == TypedValue.TYPE_DIMENSION) {
+ return TypedValue.complexToDimensionPixelOffset(mTmpValue.data,
+ getDisplayMetrics());
+ }
}
}
}
@@ -372,14 +388,18 @@
Pair<String, ResourceValue> value = getResourceValue(id, mPlatformResourceFlag);
if (value != null) {
- String v = value.getSecond().getValue();
+ ResourceValue resValue = value.getSecond();
- if (v != null) {
- if (ResourceHelper.parseFloatAttribute(
- value.getFirst(), v, mTmpValue, true /*requireUnit*/) &&
- mTmpValue.type == TypedValue.TYPE_DIMENSION) {
- return TypedValue.complexToDimensionPixelSize(mTmpValue.data,
- getDisplayMetrics());
+ assert resValue != null;
+ if (resValue != null) {
+ String v = resValue.getValue();
+ if (v != null) {
+ if (ResourceHelper.parseFloatAttribute(
+ value.getFirst(), v, mTmpValue, true /*requireUnit*/) &&
+ mTmpValue.type == TypedValue.TYPE_DIMENSION) {
+ return TypedValue.complexToDimensionPixelSize(mTmpValue.data,
+ getDisplayMetrics());
+ }
}
}
}
@@ -395,17 +415,24 @@
public int getInteger(int id) throws NotFoundException {
Pair<String, ResourceValue> value = getResourceValue(id, mPlatformResourceFlag);
- if (value != null && value.getSecond().getValue() != null) {
- String v = value.getSecond().getValue();
- int radix = 10;
- if (v.startsWith("0x")) {
- v = v.substring(2);
- radix = 16;
- }
- try {
- return Integer.parseInt(v, radix);
- } catch (NumberFormatException e) {
- // return exception below
+ if (value != null) {
+ ResourceValue resValue = value.getSecond();
+
+ assert resValue != null;
+ if (resValue != null) {
+ String v = resValue.getValue();
+ if (v != null) {
+ int radix = 10;
+ if (v.startsWith("0x")) {
+ v = v.substring(2);
+ radix = 16;
+ }
+ try {
+ return Integer.parseInt(v, radix);
+ } catch (NumberFormatException e) {
+ // return exception below
+ }
+ }
}
}
@@ -420,9 +447,16 @@
public boolean getBoolean(int id) throws NotFoundException {
Pair<String, ResourceValue> value = getResourceValue(id, mPlatformResourceFlag);
- if (value != null && value.getSecond().getValue() != null) {
- String v = value.getSecond().getValue();
- return Boolean.parseBoolean(v);
+ if (value != null) {
+ ResourceValue resValue = value.getSecond();
+
+ assert resValue != null;
+ if (resValue != null) {
+ String v = resValue.getValue();
+ if (v != null) {
+ return Boolean.parseBoolean(v);
+ }
+ }
}
// id was not found or not resolved. Throw a NotFoundException.
diff --git a/tools/layoutlib/bridge/src/android/content/res/BridgeTypedArray.java b/tools/layoutlib/bridge/src/android/content/res/BridgeTypedArray.java
index 9deed32..8fdac02 100644
--- a/tools/layoutlib/bridge/src/android/content/res/BridgeTypedArray.java
+++ b/tools/layoutlib/bridge/src/android/content/res/BridgeTypedArray.java
@@ -33,9 +33,6 @@
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
-import android.content.res.ColorStateList;
-import android.content.res.Resources;
-import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.util.DisplayMetrics;
import android.util.TypedValue;
@@ -897,12 +894,6 @@
}
@Override
- public boolean getValueAt(int index, TypedValue outValue) {
- // pass
- return false;
- }
-
- @Override
public String toString() {
return Arrays.toString(mResourceData);
}
diff --git a/tools/layoutlib/bridge/src/android/content/res/TypedArray_Delegate.java b/tools/layoutlib/bridge/src/android/content/res/TypedArray_Delegate.java
new file mode 100644
index 0000000..0a7899a
--- /dev/null
+++ b/tools/layoutlib/bridge/src/android/content/res/TypedArray_Delegate.java
@@ -0,0 +1,30 @@
+/*
+ * 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 android.content.res;
+
+import com.android.tools.layoutlib.annotations.LayoutlibDelegate;
+
+import android.util.TypedValue;
+
+public class TypedArray_Delegate {
+
+ @LayoutlibDelegate
+ public static boolean getValueAt(TypedArray theTypedArray, int index, TypedValue outValue) {
+ // pass
+ return false;
+ }
+}
diff --git a/tools/layoutlib/bridge/src/android/graphics/Bitmap_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/Bitmap_Delegate.java
index 66e59d8..eadec02 100644
--- a/tools/layoutlib/bridge/src/android/graphics/Bitmap_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/Bitmap_Delegate.java
@@ -22,7 +22,6 @@
import com.android.resources.Density;
import com.android.tools.layoutlib.annotations.LayoutlibDelegate;
-import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.os.Parcel;
@@ -149,7 +148,7 @@
}
public static int getBufferedImageType(int nativeBitmapConfig) {
- switch (Config.sConfigs[nativeBitmapConfig]) {
+ switch (Config.nativeToConfig(nativeBitmapConfig)) {
case ALPHA_8:
return BufferedImage.TYPE_INT_ARGB;
case RGB_565:
@@ -210,7 +209,7 @@
}
// create a delegate with the content of the stream.
- Bitmap_Delegate delegate = new Bitmap_Delegate(image, Config.sConfigs[nativeConfig]);
+ Bitmap_Delegate delegate = new Bitmap_Delegate(image, Config.nativeToConfig(nativeConfig));
return createBitmap(delegate, mutable, Bitmap.getDefaultDensity());
}
@@ -238,7 +237,7 @@
image.setRGB(0, 0, width, height, argb, 0, width);
// create a delegate with the content of the stream.
- Bitmap_Delegate delegate = new Bitmap_Delegate(image, Config.sConfigs[nativeConfig]);
+ Bitmap_Delegate delegate = new Bitmap_Delegate(image, Config.nativeToConfig(nativeConfig));
return createBitmap(delegate, isMutable, Bitmap.getDefaultDensity());
}
diff --git a/tools/layoutlib/bridge/src/android/graphics/Typeface_Accessor.java b/tools/layoutlib/bridge/src/android/graphics/Typeface_Accessor.java
new file mode 100644
index 0000000..2745770
--- /dev/null
+++ b/tools/layoutlib/bridge/src/android/graphics/Typeface_Accessor.java
@@ -0,0 +1,24 @@
+/*
+ * 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 android.graphics;
+
+public class Typeface_Accessor {
+
+ public static void resetDefaults() {
+ Typeface.sDefaults = null;
+ }
+}
diff --git a/tools/layoutlib/bridge/src/android/os/Looper_Accessor.java b/tools/layoutlib/bridge/src/android/os/Looper_Accessor.java
new file mode 100644
index 0000000..ad95fcc
--- /dev/null
+++ b/tools/layoutlib/bridge/src/android/os/Looper_Accessor.java
@@ -0,0 +1,24 @@
+/*
+ * 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 android.os;
+
+public class Looper_Accessor {
+
+ public static void cleanupThread() {
+ // clean up the looper
+ Looper.sThreadLocal.remove();
+ }
+}
diff --git a/tools/layoutlib/bridge/src/android/os/SystemClock_Delegate.java b/tools/layoutlib/bridge/src/android/os/SystemClock_Delegate.java
index 63711a7..bd332a6 100644
--- a/tools/layoutlib/bridge/src/android/os/SystemClock_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/os/SystemClock_Delegate.java
@@ -68,4 +68,28 @@
/*package*/ static long currentThreadTimeMillis() {
return System.currentTimeMillis();
}
+
+ /**
+ * Returns microseconds running in the current thread.
+ *
+ * @return elapsed microseconds in the thread
+ *
+ * @hide
+ */
+ @LayoutlibDelegate
+ /*package*/ static long currentThreadTimeMicro() {
+ return System.currentTimeMillis() * 1000;
+ }
+
+ /**
+ * Returns current wall time in microseconds.
+ *
+ * @return elapsed microseconds in wall time
+ *
+ * @hide
+ */
+ @LayoutlibDelegate
+ /*package*/ static long currentTimeMicro() {
+ return elapsedRealtime() * 1000;
+ }
}
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeXmlPullAttributes.java b/tools/layoutlib/bridge/src/android/util/BridgeXmlPullAttributes.java
similarity index 97%
rename from tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeXmlPullAttributes.java
rename to tools/layoutlib/bridge/src/android/util/BridgeXmlPullAttributes.java
index ba856e0..0a3cdc6 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeXmlPullAttributes.java
+++ b/tools/layoutlib/bridge/src/android/util/BridgeXmlPullAttributes.java
@@ -14,12 +14,13 @@
* limitations under the License.
*/
-package com.android.layoutlib.bridge.android;
+package android.util;
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.layoutlib.bridge.android.BridgeContext;
import com.android.resources.ResourceType;
import org.xmlpull.v1.XmlPullParser;
diff --git a/tools/layoutlib/bridge/src/android/view/AttachInfo_Accessor.java b/tools/layoutlib/bridge/src/android/view/AttachInfo_Accessor.java
new file mode 100644
index 0000000..e3778b1
--- /dev/null
+++ b/tools/layoutlib/bridge/src/android/view/AttachInfo_Accessor.java
@@ -0,0 +1,40 @@
+/*
+ * 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 android.view;
+
+import com.android.layoutlib.bridge.android.BridgeWindow;
+import com.android.layoutlib.bridge.android.BridgeWindowSession;
+
+import android.os.Handler;
+import android.view.View.AttachInfo;
+
+public class AttachInfo_Accessor {
+
+ public static void setAttachInfo(View view) {
+ AttachInfo info = new AttachInfo(new BridgeWindowSession(), new BridgeWindow(),
+ new Handler(), null);
+ info.mHasWindowFocus = true;
+ info.mWindowVisibility = View.VISIBLE;
+ info.mInTouchMode = false; // this is so that we can display selections.
+ info.mHardwareAccelerated = false;
+ view.dispatchAttachedToWindow(info, 0);
+ }
+
+ public static void dispatchOnPreDraw(View view) {
+ view.mAttachInfo.mTreeObserver.dispatchOnPreDraw();
+ }
+}
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeInflater.java b/tools/layoutlib/bridge/src/android/view/BridgeInflater.java
similarity index 98%
rename from tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeInflater.java
rename to tools/layoutlib/bridge/src/android/view/BridgeInflater.java
index 4a6393d..941f1ce6 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeInflater.java
+++ b/tools/layoutlib/bridge/src/android/view/BridgeInflater.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.layoutlib.bridge.android;
+package android.view;
import com.android.ide.common.rendering.api.IProjectCallback;
import com.android.ide.common.rendering.api.LayoutLog;
@@ -22,6 +22,8 @@
import com.android.ide.common.rendering.api.ResourceReference;
import com.android.ide.common.rendering.api.ResourceValue;
import com.android.layoutlib.bridge.Bridge;
+import com.android.layoutlib.bridge.android.BridgeContext;
+import com.android.layoutlib.bridge.android.BridgeXmlBlockParser;
import com.android.layoutlib.bridge.impl.ParserFactory;
import com.android.resources.ResourceType;
import com.android.util.Pair;
diff --git a/tools/layoutlib/bridge/src/android/view/Display_Delegate.java b/tools/layoutlib/bridge/src/android/view/Display_Delegate.java
index 83f9cc2..9732530 100644
--- a/tools/layoutlib/bridge/src/android/view/Display_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/view/Display_Delegate.java
@@ -46,31 +46,17 @@
}
@LayoutlibDelegate
- /** @hide Returns the actual screen size, not including any decor. */
- /*package*/ static int getRealWidth(Display theDisplay) {
- // always dynamically query for the current window manager
- return RenderAction.getCurrentContext().getIWindowManager().getMetrics().widthPixels;
- }
-
- @LayoutlibDelegate
- /** @hide Returns the actual screen size, not including any decor. */
- /*package*/ static int getRealHeight(Display theDisplay) {
- // always dynamically query for the current window manager
- return RenderAction.getCurrentContext().getIWindowManager().getMetrics().heightPixels;
- }
-
- @LayoutlibDelegate
/** @hide special for when we are faking the screen size. */
/*package*/ static int getRawWidth(Display theDisplay) {
// same as real since we're not faking compatibility mode.
- return getRealWidth(theDisplay);
+ return RenderAction.getCurrentContext().getIWindowManager().getMetrics().widthPixels;
}
@LayoutlibDelegate
/** @hide special for when we are faking the screen size. */
/*package*/ static int getRawHeight(Display theDisplay) {
// same as real since we're not faking compatibility mode.
- return getRealHeight(theDisplay);
+ return RenderAction.getCurrentContext().getIWindowManager().getMetrics().heightPixels;
}
@LayoutlibDelegate
diff --git a/tools/layoutlib/bridge/src/android/view/LayoutInflater_Delegate.java b/tools/layoutlib/bridge/src/android/view/LayoutInflater_Delegate.java
index 64efa7e..3db3a1b 100644
--- a/tools/layoutlib/bridge/src/android/view/LayoutInflater_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/view/LayoutInflater_Delegate.java
@@ -16,7 +16,6 @@
package android.view;
-import com.android.layoutlib.bridge.android.BridgeInflater;
import com.android.tools.layoutlib.annotations.LayoutlibDelegate;
import org.xmlpull.v1.XmlPullParser;
diff --git a/tools/layoutlib/bridge/src/android/view/ViewConfiguration_Accessor.java b/tools/layoutlib/bridge/src/android/view/ViewConfiguration_Accessor.java
new file mode 100644
index 0000000..01db34e
--- /dev/null
+++ b/tools/layoutlib/bridge/src/android/view/ViewConfiguration_Accessor.java
@@ -0,0 +1,26 @@
+/*
+ * 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 android.view;
+
+public class ViewConfiguration_Accessor {
+
+ public static void clearConfigurations() {
+ // clear the stored ViewConfiguration since the map is per density and not per context.
+ ViewConfiguration.sConfigurations.clear();
+ }
+
+}
diff --git a/tools/layoutlib/bridge/src/android/view/inputmethod/InputMethodManager_Accessor.java b/tools/layoutlib/bridge/src/android/view/inputmethod/InputMethodManager_Accessor.java
new file mode 100644
index 0000000..875336a
--- /dev/null
+++ b/tools/layoutlib/bridge/src/android/view/inputmethod/InputMethodManager_Accessor.java
@@ -0,0 +1,24 @@
+/*
+ * 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 android.view.inputmethod;
+
+public class InputMethodManager_Accessor {
+
+ public static void resetInstance() {
+ InputMethodManager.mInstance = null;
+ }
+}
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 3ba3257..33bf7bc 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java
@@ -26,7 +26,6 @@
import com.android.ide.common.rendering.api.Result;
import com.android.ide.common.rendering.api.SessionParams;
import com.android.ide.common.rendering.api.Result.Status;
-import com.android.layoutlib.bridge.android.BridgeAssetManager;
import com.android.layoutlib.bridge.impl.FontLoader;
import com.android.layoutlib.bridge.impl.RenderDrawable;
import com.android.layoutlib.bridge.impl.RenderSessionImpl;
@@ -36,10 +35,12 @@
import com.android.tools.layoutlib.create.OverrideMethod;
import com.android.util.Pair;
+import android.content.res.BridgeAssetManager;
import android.graphics.Bitmap;
-import android.graphics.Typeface;
+import android.graphics.Typeface_Accessor;
import android.graphics.Typeface_Delegate;
import android.os.Looper;
+import android.os.Looper_Accessor;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
@@ -295,7 +296,7 @@
BridgeAssetManager.clearSystem();
// dispose of the default typeface.
- Typeface.sDefaults = null;
+ Typeface_Accessor.resetDefaults();
return true;
}
@@ -429,7 +430,7 @@
*/
public static void cleanupThread() {
// clean up the looper
- Looper.sThreadLocal.remove();
+ Looper_Accessor.cleanupThread();
}
public static LayoutLog getLog() {
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 b38b3b8..0453a5e 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
@@ -33,8 +33,6 @@
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
-import android.app.Activity;
-import android.app.Fragment;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.ContentResolver;
@@ -65,7 +63,7 @@
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.util.TypedValue;
-import android.view.LayoutInflater;
+import android.view.BridgeInflater;
import android.view.Surface;
import android.view.View;
import android.view.ViewGroup;
@@ -87,7 +85,7 @@
/**
* Custom implementation of Context/Activity to handle non compiled resources.
*/
-public final class BridgeContext extends Activity {
+public final class BridgeContext extends Context {
private Resources mSystemResources;
private final HashMap<View, Object> mViewKeyMap = new HashMap<View, Object>();
@@ -97,9 +95,10 @@
private final Configuration mConfig;
private final ApplicationInfo mApplicationInfo;
private final IProjectCallback mProjectCallback;
-
private final BridgeWindowManager mIWindowManager;
+ private Resources.Theme mTheme;
+
private final Map<Object, Map<String, String>> mDefaultPropMaps =
new IdentityHashMap<Object, Map<String,String>>();
@@ -139,9 +138,6 @@
mIWindowManager = new BridgeWindowManager(mConfig, metrics, Surface.ROTATION_0);
- mFragments.mCurState = Fragment.CREATED;
- mFragments.mActivity = this;
-
mApplicationInfo = new ApplicationInfo();
mApplicationInfo.targetSdkVersion = targetSdkVersion;
}
@@ -395,13 +391,6 @@
return Pair.of(null, false);
}
- // ------------- Activity Methods
-
- @Override
- public LayoutInflater getLayoutInflater() {
- return mBridgeInflater;
- }
-
// ------------ Context methods
@Override
@@ -1275,7 +1264,7 @@
@Override
public Context getApplicationContext() {
- throw new UnsupportedOperationException();
+ return this;
}
@Override
@@ -1288,4 +1277,10 @@
public boolean isRestricted() {
return false;
}
+
+ @Override
+ public File getObbDir() {
+ Bridge.getLog().error(LayoutLog.TAG_UNSUPPORTED, "OBB not supported", null);
+ return null;
+ }
}
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeWindow.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeWindow.java
index a8da377..8e673ad 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeWindow.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeWindow.java
@@ -26,10 +26,9 @@
import android.view.IWindow;
import android.view.KeyEvent;
import android.view.MotionEvent;
-import android.view.View.AttachInfo;
/**
- * Implementation of {@link IWindow} to pass to the {@link AttachInfo}.
+ * Implementation of {@link IWindow} to pass to the AttachInfo.
*/
public final class BridgeWindow implements IWindow {
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeWindowManager.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeWindowManager.java
index 5952c37..7d83a9f 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeWindowManager.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeWindowManager.java
@@ -456,9 +456,7 @@
return null;
}
- @Override
public int getPreferredOptionsPanelGravity() throws RemoteException {
return Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM;
}
-
}
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeXmlBlockParser.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeXmlBlockParser.java
index 1016b32..f8ed4f7 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeXmlBlockParser.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeXmlBlockParser.java
@@ -25,7 +25,7 @@
import android.content.res.XmlResourceParser;
import android.util.AttributeSet;
-import android.util.XmlPullAttributes;
+import android.util.BridgeXmlPullAttributes;
import java.io.IOException;
import java.io.InputStream;
@@ -34,12 +34,12 @@
/**
* {@link BridgeXmlBlockParser} reimplements most of android.xml.XmlBlock.Parser.
* It delegates to both an instance of {@link XmlPullParser} and an instance of
- * {@link XmlPullAttributes} (for the {@link AttributeSet} part).
+ * XmlPullAttributes (for the {@link AttributeSet} part).
*/
public class BridgeXmlBlockParser implements XmlResourceParser {
private final XmlPullParser mParser;
- private final XmlPullAttributes mAttrib;
+ private final BridgeXmlPullAttributes mAttrib;
private final BridgeContext mContext;
private final boolean mPlatformFile;
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/PhoneSystemBar.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/PhoneSystemBar.java
index 5569e06..7521011 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/PhoneSystemBar.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/PhoneSystemBar.java
@@ -32,7 +32,8 @@
public PhoneSystemBar(Context context, Density density) throws XmlPullParserException {
super(context, density, "/bars/phone_system_bar.xml", "phone_system_bar.xml");
- setGravity(mGravity | Gravity.RIGHT);
+ // FIXME: use FILL_H?
+ setGravity(Gravity.START | Gravity.TOP | Gravity.RIGHT);
setBackgroundColor(0xFF000000);
// Cannot access the inside items through id because no R.id values have been
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/PlayAnimationThread.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/PlayAnimationThread.java
index 35e5987..7b70180 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/PlayAnimationThread.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/PlayAnimationThread.java
@@ -20,6 +20,7 @@
import com.android.ide.common.rendering.api.Result;
import com.android.ide.common.rendering.api.Result.Status;
+import android.animation.AnimationThread;
import android.animation.Animator;
public class PlayAnimationThread extends AnimationThread {
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderAction.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderAction.java
index d40222f..7323c6a 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderAction.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderAction.java
@@ -35,8 +35,9 @@
import android.os.HandlerThread_Delegate;
import android.os.Looper;
import android.util.DisplayMetrics;
-import android.view.ViewConfiguration;
+import android.view.ViewConfiguration_Accessor;
import android.view.inputmethod.InputMethodManager;
+import android.view.inputmethod.InputMethodManager_Accessor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.ReentrantLock;
@@ -248,10 +249,10 @@
HandlerThread_Delegate.cleanUp(sCurrentContext);
// clear the stored ViewConfiguration since the map is per density and not per context.
- ViewConfiguration.sConfigurations.clear();
+ ViewConfiguration_Accessor.clearConfigurations();
// remove the InputMethodManager
- InputMethodManager.mInstance = null;
+ InputMethodManager_Accessor.resetInstance();
sCurrentContext = null;
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderDrawable.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderDrawable.java
index 953d8cf..8133210 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderDrawable.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderDrawable.java
@@ -23,17 +23,13 @@
import com.android.ide.common.rendering.api.Result;
import com.android.ide.common.rendering.api.Result.Status;
import com.android.layoutlib.bridge.android.BridgeContext;
-import com.android.layoutlib.bridge.android.BridgeWindow;
-import com.android.layoutlib.bridge.android.BridgeWindowSession;
import com.android.resources.ResourceType;
import android.graphics.Bitmap;
import android.graphics.Bitmap_Delegate;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
-import android.os.Handler;
-import android.view.View;
-import android.view.View.AttachInfo;
+import android.view.AttachInfo_Accessor;
import android.view.View.MeasureSpec;
import android.widget.FrameLayout;
@@ -82,13 +78,7 @@
content.setBackgroundDrawable(d);
// set the AttachInfo on the root view.
- AttachInfo info = new AttachInfo(new BridgeWindowSession(), new BridgeWindow(),
- new Handler(), null);
- info.mHasWindowFocus = true;
- info.mWindowVisibility = View.VISIBLE;
- info.mInTouchMode = false; // this is so that we can display selections.
- info.mHardwareAccelerated = false;
- content.dispatchAttachedToWindow(info, 0);
+ AttachInfo_Accessor.setAttachInfo(content);
// measure
@@ -102,7 +92,7 @@
content.layout(0, 0, w, h);
// preDraw setup
- content.mAttachInfo.mTreeObserver.dispatchOnPreDraw();
+ AttachInfo_Accessor.dispatchOnPreDraw(content);
// draw into a new image
BufferedImage image = getImage(w, h);
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 aa30e29..d5400d7 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
@@ -40,10 +40,7 @@
import com.android.internal.util.XmlUtils;
import com.android.layoutlib.bridge.Bridge;
import com.android.layoutlib.bridge.android.BridgeContext;
-import com.android.layoutlib.bridge.android.BridgeInflater;
import com.android.layoutlib.bridge.android.BridgeLayoutParamsMapAttributes;
-import com.android.layoutlib.bridge.android.BridgeWindow;
-import com.android.layoutlib.bridge.android.BridgeWindowSession;
import com.android.layoutlib.bridge.android.BridgeXmlBlockParser;
import com.android.layoutlib.bridge.bars.FakeActionBar;
import com.android.layoutlib.bridge.bars.PhoneSystemBar;
@@ -57,6 +54,7 @@
import org.xmlpull.v1.XmlPullParserException;
+import android.animation.AnimationThread;
import android.animation.Animator;
import android.animation.AnimatorInflater;
import android.animation.LayoutTransition;
@@ -66,12 +64,12 @@
import android.graphics.Bitmap_Delegate;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
-import android.os.Handler;
import android.util.DisplayMetrics;
import android.util.TypedValue;
+import android.view.AttachInfo_Accessor;
+import android.view.BridgeInflater;
import android.view.View;
import android.view.ViewGroup;
-import android.view.View.AttachInfo;
import android.view.View.MeasureSpec;
import android.view.ViewGroup.LayoutParams;
import android.view.ViewGroup.MarginLayoutParams;
@@ -190,7 +188,6 @@
// build the inflater and parser.
mInflater = new BridgeInflater(context, params.getProjectCallback());
context.setBridgeInflater(mInflater);
- mInflater.setFactory2(context);
mBlockParser = new BridgeXmlBlockParser(
params.getLayoutDescription(), context, false /* platformResourceFlag */);
@@ -329,13 +326,7 @@
Fragment_Delegate.setProjectCallback(null);
// set the AttachInfo on the root view.
- AttachInfo info = new AttachInfo(new BridgeWindowSession(), new BridgeWindow(),
- new Handler(), null);
- info.mHasWindowFocus = true;
- info.mWindowVisibility = View.VISIBLE;
- info.mInTouchMode = false; // this is so that we can display selections.
- info.mHardwareAccelerated = false;
- mViewRoot.dispatchAttachedToWindow(info, 0);
+ AttachInfo_Accessor.setAttachInfo(mViewRoot);
// post-inflate process. For now this supports TabHost/TabWidget
postInflateProcess(view, params.getProjectCallback());
@@ -462,7 +453,7 @@
mImage = null;
mCanvas = null;
} else {
- mViewRoot.mAttachInfo.mTreeObserver.dispatchOnPreDraw();
+ AttachInfo_Accessor.dispatchOnPreDraw(mViewRoot);
// draw the views
// create the BufferedImage into which the layout will be rendered.
diff --git a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/CreateInfo.java b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/CreateInfo.java
index 7c02f7e..0a15627 100644
--- a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/CreateInfo.java
+++ b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/CreateInfo.java
@@ -95,10 +95,11 @@
/**
* The list of methods to rewrite as delegates.
*/
- private final static String[] DELEGATE_METHODS = new String[] {
+ public final static String[] DELEGATE_METHODS = new String[] {
"android.app.Fragment#instantiate", //(Landroid/content/Context;Ljava/lang/String;Landroid/os/Bundle;)Landroid/app/Fragment;",
"android.content.res.Resources$Theme#obtainStyledAttributes",
"android.content.res.Resources$Theme#resolveAttribute",
+ "android.content.res.TypedArray#getValueAt",
"android.graphics.BitmapFactory#finishDecode",
"android.os.Handler#sendMessageAtTime",
"android.os.HandlerThread#run",
@@ -116,7 +117,7 @@
/**
* The list of classes on which to delegate all native methods.
*/
- private final static String[] DELEGATE_CLASS_NATIVES = new String[] {
+ public final static String[] DELEGATE_CLASS_NATIVES = new String[] {
"android.animation.PropertyValuesHolder",
"android.graphics.AvoidXfermode",
"android.graphics.Bitmap",
diff --git a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/Main.java b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/Main.java
index b027b6a..4b7a348 100644
--- a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/Main.java
+++ b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/Main.java
@@ -165,6 +165,8 @@
return false;
}
+ sOptions.generatePublicAccess = false;
+
return true;
}
}