Merge "Add missing delegate to the layoutlib."
diff --git a/cmds/bu/src/com/android/commands/bu/Backup.java b/cmds/bu/src/com/android/commands/bu/Backup.java
index e81f799..4c4bf98 100644
--- a/cmds/bu/src/com/android/commands/bu/Backup.java
+++ b/cmds/bu/src/com/android/commands/bu/Backup.java
@@ -22,8 +22,6 @@
import android.os.ServiceManager;
import android.util.Log;
-import java.io.FileDescriptor;
-import java.io.IOException;
import java.util.ArrayList;
public final class Backup {
@@ -51,17 +49,19 @@
return;
}
+ int socketFd = Integer.parseInt(nextArg());
+
String arg = nextArg();
if (arg.equals("backup")) {
- doFullBackup();
+ doFullBackup(socketFd);
} else if (arg.equals("restore")) {
- doFullRestore();
+ doFullRestore(socketFd);
} else {
Log.e(TAG, "Invalid operation '" + arg + "'");
}
}
- private void doFullBackup() {
+ private void doFullBackup(int socketFd) {
ArrayList<String> packages = new ArrayList<String>();
boolean saveApks = false;
boolean saveShared = false;
@@ -100,24 +100,20 @@
}
try {
- ParcelFileDescriptor fd = ParcelFileDescriptor.dup(FileDescriptor.out);
+ ParcelFileDescriptor fd = ParcelFileDescriptor.adoptFd(socketFd);
String[] packArray = new String[packages.size()];
mBackupManager.fullBackup(fd, saveApks, saveShared, doEverything,
packages.toArray(packArray));
- } catch (IOException e) {
- Log.e(TAG, "Can't dup out");
} catch (RemoteException e) {
Log.e(TAG, "Unable to invoke backup manager for backup");
}
}
- private void doFullRestore() {
+ private void doFullRestore(int socketFd) {
// No arguments to restore
try {
- ParcelFileDescriptor fd = ParcelFileDescriptor.dup(FileDescriptor.in);
+ ParcelFileDescriptor fd = ParcelFileDescriptor.adoptFd(socketFd);
mBackupManager.fullRestore(fd);
- } catch (IOException e) {
- Log.e(TAG, "Can't dup System.in");
} catch (RemoteException e) {
Log.e(TAG, "Unable to invoke backup manager for restore");
}
diff --git a/core/java/android/preference/PreferenceActivity.java b/core/java/android/preference/PreferenceActivity.java
index 14e7bed..c90de17 100644
--- a/core/java/android/preference/PreferenceActivity.java
+++ b/core/java/android/preference/PreferenceActivity.java
@@ -16,9 +16,6 @@
package android.preference;
-import com.android.internal.util.XmlUtils;
-
-import android.app.ActionBar;
import android.app.Fragment;
import android.app.FragmentBreadCrumbs;
import android.app.FragmentManager;
@@ -26,7 +23,6 @@
import android.app.ListActivity;
import android.content.Context;
import android.content.Intent;
-import android.content.res.Configuration;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.content.res.XmlResourceParser;
@@ -41,23 +37,26 @@
import android.util.Xml;
import android.view.LayoutInflater;
import android.view.View;
-import android.view.ViewGroup;
import android.view.View.OnClickListener;
+import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.ArrayAdapter;
+import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
+import com.android.internal.util.XmlUtils;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
/**
* This is the base class for an activity to show a hierarchy of preferences
* to the user. Prior to {@link android.os.Build.VERSION_CODES#HONEYCOMB}
@@ -66,7 +65,7 @@
* class. If you are using PreferenceActivity in its old mode, the documentation
* there applies to the deprecated APIs here.
*
- * <p>This activity shows one or more headers of preferences, each of with
+ * <p>This activity shows one or more headers of preferences, each of which
* is associated with a {@link PreferenceFragment} to display the preferences
* of that header. The actual layout and display of these associations can
* however vary; currently there are two major approaches it may take:
@@ -117,7 +116,6 @@
public abstract class PreferenceActivity extends ListActivity implements
PreferenceManager.OnPreferenceTreeClickListener,
PreferenceFragment.OnPreferenceStartFragmentCallback {
- private static final String TAG = "PreferenceActivity";
// Constants for state save/restore
private static final String HEADERS_TAG = ":android:headers";
@@ -182,8 +180,6 @@
private final ArrayList<Header> mHeaders = new ArrayList<Header>();
- private HeaderAdapter mAdapter;
-
private FrameLayout mListFooter;
private ViewGroup mPrefsContainer;
@@ -222,8 +218,8 @@
ArrayList<Header> oldHeaders = new ArrayList<Header>(mHeaders);
mHeaders.clear();
onBuildHeaders(mHeaders);
- if (mAdapter != null) {
- mAdapter.notifyDataSetChanged();
+ if (mAdapter instanceof BaseAdapter) {
+ ((BaseAdapter) mAdapter).notifyDataSetChanged();
}
Header header = onGetNewHeader();
if (header != null && header.fragment != null) {
@@ -387,6 +383,7 @@
public Bundle extras;
public Header() {
+ // Empty
}
/**
@@ -521,7 +518,7 @@
if (headers != null) {
mHeaders.addAll(headers);
int curHeader = savedInstanceState.getInt(CUR_HEADER_TAG,
- (int)HEADER_ID_UNDEFINED);
+ (int) HEADER_ID_UNDEFINED);
if (curHeader >= 0 && curHeader < mHeaders.size()) {
setSelectedHeader(mHeaders.get(curHeader));
}
@@ -567,8 +564,7 @@
findViewById(com.android.internal.R.id.headers).setVisibility(View.GONE);
mPrefsContainer.setVisibility(View.VISIBLE);
} else if (mHeaders.size() > 0) {
- mAdapter = new HeaderAdapter(this, mHeaders);
- setListAdapter(mAdapter);
+ setListAdapter(new HeaderAdapter(this, mHeaders));
if (!mSinglePane) {
// Multi-pane.
getListView().setChoiceMode(AbsListView.CHOICE_MODE_SINGLE);
@@ -715,6 +711,7 @@
* @param target The list in which to place the headers.
*/
public void onBuildHeaders(List<Header> target) {
+ // Should be overloaded by subclasses
}
/**
@@ -743,6 +740,7 @@
int type;
while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
&& type != XmlPullParser.START_TAG) {
+ // Parse next until start tag is found
}
String nodeName = parser.getName();
@@ -951,7 +949,8 @@
super.onListItemClick(l, v, position, id);
if (mAdapter != null) {
- onHeaderClick(mHeaders.get(position), position);
+ Object item = mAdapter.getItem(position);
+ if (item instanceof Header) onHeaderClick((Header) item, position);
}
}
@@ -993,7 +992,7 @@
* @param fragmentName The name of the fragment to display.
* @param args Optional arguments to supply to the fragment.
* @param titleRes Optional resource ID of title to show for this item.
- * @param titleRes Optional resource ID of short title to show for this item.
+ * @param shortTitleRes Optional resource ID of short title to show for this item.
* @return Returns an Intent that can be launched to display the given
* fragment.
*/
@@ -1032,7 +1031,7 @@
* code in which to report the result.
* @param titleRes Resource ID of string to display for the title of
* this set of preferences.
- * @param titleRes Resource ID of string to display for the short title of
+ * @param shortTitleRes Resource ID of string to display for the short title of
* this set of preferences.
*/
public void startWithFragment(String fragmentName, Bundle args,
diff --git a/core/java/android/server/BluetoothBondState.java b/core/java/android/server/BluetoothBondState.java
index a36cd24..39c3c88 100644
--- a/core/java/android/server/BluetoothBondState.java
+++ b/core/java/android/server/BluetoothBondState.java
@@ -79,6 +79,7 @@
mService = service;
mBluetoothInputProfileHandler =
BluetoothInputProfileHandler.getInstance(mContext, mService);
+ getProfileProxy();
}
synchronized void setPendingOutgoingBonding(String address) {
@@ -131,10 +132,6 @@
if (state == BluetoothDevice.BOND_BONDED) {
mService.addProfileState(address);
- } else if (state == BluetoothDevice.BOND_BONDING) {
- if (mA2dpProxy == null || mHeadsetProxy == null) {
- getProfileProxy();
- }
} else if (state == BluetoothDevice.BOND_NONE) {
mService.removeProfileState(address);
}
diff --git a/core/java/android/server/BluetoothService.java b/core/java/android/server/BluetoothService.java
index 62792f4..a4588ae 100755
--- a/core/java/android/server/BluetoothService.java
+++ b/core/java/android/server/BluetoothService.java
@@ -1247,18 +1247,9 @@
return true;
}
- boolean ret;
- // Just do the SDP if the device is already created and UUIDs are not
- // NULL, else create the device and then do SDP.
- if (mDeviceProperties.isInCache(address) && getRemoteUuids(address) != null) {
- String path = getObjectPathFromAddress(address);
- if (path == null) return false;
-
- // Use an empty string for the UUID pattern
- ret = discoverServicesNative(path, "");
- } else {
- ret = createDeviceNative(address);
- }
+ // If the device is already created, we will
+ // do the SDP on the callback of createDeviceNative.
+ boolean ret= createDeviceNative(address);
mUuidIntentTracker.add(address);
if (uuid != null) {
diff --git a/core/java/android/widget/GridLayout.java b/core/java/android/widget/GridLayout.java
index 46e4398..0e52869 100644
--- a/core/java/android/widget/GridLayout.java
+++ b/core/java/android/widget/GridLayout.java
@@ -170,7 +170,6 @@
private static final String TAG = GridLayout.class.getName();
private static final boolean DEBUG = false;
- private static Paint GRID_PAINT;
private static final double GOLDEN_RATIO = (1 + Math.sqrt(5)) / 2;
private static final int MIN = 0;
private static final int PRF = 1;
@@ -196,15 +195,6 @@
private static final int ROW_ORDER_PRESERVED = styleable.GridLayout_rowOrderPreserved;
private static final int COLUMN_ORDER_PRESERVED = styleable.GridLayout_columnOrderPreserved;
- // Static initialization
-
- static {
- if (DEBUG) {
- GRID_PAINT = new Paint();
- GRID_PAINT.setColor(Color.argb(50, 255, 255, 255));
- }
- }
-
// Instance variables
private final Axis mHorizontalAxis = new Axis(true);
@@ -605,7 +595,9 @@
int row = 0;
int col = 0;
for (int i = 0, N = getChildCount(); i < N; i++) {
- LayoutParams lp = getLayoutParams1(getChildAt(i));
+ View c = getChildAt(i);
+ if (isGone(c)) continue;
+ LayoutParams lp = getLayoutParams1(c);
Group colGroup = lp.columnGroup;
Interval cols = colGroup.span;
@@ -703,6 +695,15 @@
graphics.drawLine(dx + x1, dy + y1, dx + x2, dy + y2, paint);
}
+ private void drawRectangle(Canvas graphics, int x1, int y1, int x2, int y2, Paint paint) {
+ // x2 = x2 - 1;
+ // y2 = y2 - 1;
+ graphics.drawLine(x1, y1, x1, y2, paint);
+ graphics.drawLine(x1, y1, x2, y1, paint);
+ graphics.drawLine(x1, y2, x2, y2, paint);
+ graphics.drawLine(x2, y1, x2, y2, paint);
+ }
+
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
@@ -711,15 +712,46 @@
int height = getHeight() - getPaddingTop() - getPaddingBottom();
int width = getWidth() - getPaddingLeft() - getPaddingRight();
+ Paint paint = new Paint();
+ paint.setColor(Color.argb(50, 255, 255, 255));
+
int[] xs = mHorizontalAxis.locations;
- for (int i = 0, length = xs.length; i < length; i++) {
- int x = xs[i];
- drawLine(canvas, x, 0, x, height - 1, GRID_PAINT);
+ if (xs != null) {
+ for (int i = 0, length = xs.length; i < length; i++) {
+ int x = xs[i];
+ drawLine(canvas, x, 0, x, height - 1, paint);
+ }
}
+
int[] ys = mVerticalAxis.locations;
- for (int i = 0, length = ys.length; i < length; i++) {
- int y = ys[i];
- drawLine(canvas, 0, y, width - 1, y, GRID_PAINT);
+ if (ys != null) {
+ for (int i = 0, length = ys.length; i < length; i++) {
+ int y = ys[i];
+ drawLine(canvas, 0, y, width - 1, y, paint);
+ }
+ }
+ // Draw bounds
+ paint.setColor(Color.BLUE);
+
+ for (int i = 0; i < getChildCount(); i++) {
+ View c = getChildAt(i);
+ drawRectangle(canvas,
+ c.getLeft(),
+ c.getTop(),
+ c.getRight(),
+ c.getBottom(), paint);
+ }
+
+ // Draw margins
+ paint.setColor(Color.YELLOW);
+
+ for (int i = 0; i < getChildCount(); i++) {
+ View c = getChildAt(i);
+ drawRectangle(canvas,
+ c.getLeft() - getMargin(c, true, true),
+ c.getTop() - getMargin(c, true, false),
+ c.getRight() + getMargin(c, false, true),
+ c.getBottom() + getMargin(c, false, false), paint);
}
}
}
@@ -758,9 +790,35 @@
// Measurement
+ private boolean isGone(View c) {
+ return c.getVisibility() == View.GONE;
+ }
+
+ private void measureChildWithMargins(View child,
+ int parentWidthMeasureSpec, int parentHeightMeasureSpec) {
+
+ LayoutParams lp = getLayoutParams(child);
+ int hMargins = getMargin(child, true, true) + getMargin(child, false, true);
+ int childWidthMeasureSpec = getChildMeasureSpec(parentWidthMeasureSpec,
+ mPaddingLeft + mPaddingRight + hMargins, lp.width);
+ int vMargins = getMargin(child, true, false) + getMargin(child, false, false);
+ int childHeightMeasureSpec = getChildMeasureSpec(parentHeightMeasureSpec,
+ mPaddingTop + mPaddingBottom + vMargins, lp.height);
+
+ child.measure(childWidthMeasureSpec, childHeightMeasureSpec);
+ }
+
+ private void measureChildrenWithMargins(int widthMeasureSpec, int heightMeasureSpec) {
+ for (int i = 0, N = getChildCount(); i < N; i++) {
+ View c = getChildAt(i);
+ if (isGone(c)) continue;
+ measureChildWithMargins(c, widthMeasureSpec, heightMeasureSpec);
+ }
+ }
+
@Override
protected void onMeasure(int widthSpec, int heightSpec) {
- measureChildren(widthSpec, heightSpec);
+ measureChildrenWithMargins(widthSpec, heightSpec);
int computedWidth = getPaddingLeft() + mHorizontalAxis.getMin() + getPaddingRight();
int computedHeight = getPaddingTop() + mVerticalAxis.getMin() + getPaddingBottom();
@@ -824,26 +882,27 @@
mHorizontalAxis.layout(targetWidth - paddingLeft - paddingRight);
mVerticalAxis.layout(targetHeight - paddingTop - paddingBottom);
- for (int i = 0, size = getChildCount(); i < size; i++) {
- View view = getChildAt(i);
- LayoutParams lp = getLayoutParams(view);
+ for (int i = 0, N = getChildCount(); i < N; i++) {
+ View c = getChildAt(i);
+ if (isGone(c)) continue;
+ LayoutParams lp = getLayoutParams(c);
Group columnGroup = lp.columnGroup;
Group rowGroup = lp.rowGroup;
Interval colSpan = columnGroup.span;
Interval rowSpan = rowGroup.span;
- int x1 = mHorizontalAxis.getLocationIncludingMargin(view, true, colSpan.min);
- int y1 = mVerticalAxis.getLocationIncludingMargin(view, true, rowSpan.min);
+ int x1 = mHorizontalAxis.getLocationIncludingMargin(c, true, colSpan.min);
+ int y1 = mVerticalAxis.getLocationIncludingMargin(c, true, rowSpan.min);
- int x2 = mHorizontalAxis.getLocationIncludingMargin(view, false, colSpan.max);
- int y2 = mVerticalAxis.getLocationIncludingMargin(view, false, rowSpan.max);
+ int x2 = mHorizontalAxis.getLocationIncludingMargin(c, false, colSpan.max);
+ int y2 = mVerticalAxis.getLocationIncludingMargin(c, false, rowSpan.max);
int cellWidth = x2 - x1;
int cellHeight = y2 - y1;
- int pWidth = getMeasurement(view, true, PRF);
- int pHeight = getMeasurement(view, false, PRF);
+ int pWidth = getMeasurement(c, true, PRF);
+ int pHeight = getMeasurement(c, false, PRF);
Alignment hAlign = columnGroup.alignment;
Alignment vAlign = rowGroup.alignment;
@@ -859,18 +918,18 @@
int c2ay = protect(vAlign.getAlignmentValue(null, cellHeight - rowBounds.size(), type));
if (mAlignmentMode == ALIGN_MARGINS) {
- int leftMargin = getMargin(view, true, true);
- int topMargin = getMargin(view, true, false);
- int rightMargin = getMargin(view, false, true);
- int bottomMargin = getMargin(view, false, false);
+ int leftMargin = getMargin(c, true, true);
+ int topMargin = getMargin(c, true, false);
+ int rightMargin = getMargin(c, false, true);
+ int bottomMargin = getMargin(c, false, false);
// Same calculation as getMeasurementIncludingMargin()
int mWidth = leftMargin + pWidth + rightMargin;
int mHeight = topMargin + pHeight + bottomMargin;
// Alignment offsets: the location of the view relative to its alignment group.
- int a2vx = colBounds.before - hAlign.getAlignmentValue(view, mWidth, type);
- int a2vy = rowBounds.before - vAlign.getAlignmentValue(view, mHeight, type);
+ int a2vx = colBounds.before - hAlign.getAlignmentValue(c, mWidth, type);
+ int a2vy = rowBounds.before - vAlign.getAlignmentValue(c, mHeight, type);
dx = c2ax + a2vx + leftMargin;
dy = c2ay + a2vy + topMargin;
@@ -879,19 +938,19 @@
cellHeight -= topMargin + bottomMargin;
} else {
// Alignment offsets: the location of the view relative to its alignment group.
- int a2vx = colBounds.before - hAlign.getAlignmentValue(view, pWidth, type);
- int a2vy = rowBounds.before - vAlign.getAlignmentValue(view, pHeight, type);
+ int a2vx = colBounds.before - hAlign.getAlignmentValue(c, pWidth, type);
+ int a2vy = rowBounds.before - vAlign.getAlignmentValue(c, pHeight, type);
dx = c2ax + a2vx;
dy = c2ay + a2vy;
}
- int width = hAlign.getSizeInCell(view, pWidth, cellWidth, type);
- int height = vAlign.getSizeInCell(view, pHeight, cellHeight, type);
+ int width = hAlign.getSizeInCell(c, pWidth, cellWidth, type);
+ int height = vAlign.getSizeInCell(c, pHeight, cellHeight, type);
int cx = paddingLeft + x1 + dx;
int cy = paddingTop + y1 + dy;
- view.layout(cx, cy, cx + width, cy + height);
+ c.layout(cx, cy, cx + width, cy + height);
}
}
@@ -946,8 +1005,10 @@
private int maxIndex() {
// note the number Integer.MIN_VALUE + 1 comes up in undefined cells
int count = -1;
- for (int i = 0, size = getChildCount(); i < size; i++) {
- LayoutParams params = getLayoutParams(getChildAt(i));
+ for (int i = 0, N = getChildCount(); i < N; i++) {
+ View c = getChildAt(i);
+ if (isGone(c)) continue;
+ LayoutParams params = getLayoutParams(c);
Group g = horizontal ? params.columnGroup : params.rowGroup;
count = max(count, g.span.min);
count = max(count, g.span.max);
@@ -980,9 +1041,13 @@
private PackedMap<Group, Bounds> createGroupBounds() {
int N = getChildCount();
Group[] groups = new Group[N];
+ Arrays.fill(groups, Group.GONE);
Bounds[] bounds = new Bounds[N];
+ Arrays.fill(bounds, Bounds.GONE);
for (int i = 0; i < N; i++) {
- LayoutParams lp = getLayoutParams(getChildAt(i));
+ View c = getChildAt(i);
+ if (isGone(c)) continue;
+ LayoutParams lp = getLayoutParams(c);
Group group = horizontal ? lp.columnGroup : lp.rowGroup;
groups[i] = group;
@@ -993,11 +1058,13 @@
}
private void computeGroupBounds() {
- for (int i = 0; i < groupBounds.values.length; i++) {
- groupBounds.values[i].reset();
+ Bounds[] values = groupBounds.values;
+ for (int i = 0; i < values.length; i++) {
+ values[i].reset();
}
for (int i = 0, N = getChildCount(); i < N; i++) {
View c = getChildAt(i);
+ if (isGone(c)) continue;
LayoutParams lp = getLayoutParams(c);
Group g = horizontal ? lp.columnGroup : lp.rowGroup;
@@ -1110,7 +1177,7 @@
}
private Arc[] topologicalSort(final Arc[] arcs, int start) {
- // todo ensure the <start> vertex is added in edge cases
+ // todo ensure the <start> vertex is added in edge cases
final List<Arc> result = new ArrayList<Arc>();
new Object() {
Arc[][] arcsByFirstVertex = groupArcsByFirstVertex(arcs);
@@ -1159,11 +1226,13 @@
// todo unify with findUsed above. Both routines analyze which rows/columns are empty.
private Collection<Interval> getSpacers() {
List<Interval> result = new ArrayList<Interval>();
- int N = getCount() + 1;
- int[] leadingEdgeCount = new int[N];
- int[] trailingEdgeCount = new int[N];
- for (int i = 0, size = getChildCount(); i < size; i++) {
- LayoutParams lp = getLayoutParams(getChildAt(i));
+ int V = getCount() + 1;
+ int[] leadingEdgeCount = new int[V];
+ int[] trailingEdgeCount = new int[V];
+ for (int i = 0, N = getChildCount(); i < N; i++) {
+ View c = getChildAt(i);
+ if (isGone(c)) continue;
+ LayoutParams lp = getLayoutParams(c);
Group g = horizontal ? lp.columnGroup : lp.rowGroup;
Interval span = g.span;
leadingEdgeCount[span.min]++;
@@ -1174,9 +1243,9 @@
// treat the parent's edges like peer edges of the opposite type
trailingEdgeCount[0] = 1;
- leadingEdgeCount[N - 1] = 1;
+ leadingEdgeCount[V - 1] = 1;
- for (int i = 0; i < N; i++) {
+ for (int i = 0; i < V; i++) {
if (trailingEdgeCount[i] > 0) {
lastTrailingEdge = i;
continue; // if this is also a leading edge, don't add a space of length zero
@@ -1189,24 +1258,25 @@
}
private Arc[] createArcs() {
- List<Arc> spanToSize = new ArrayList<Arc>();
+ List<Arc> result = new ArrayList<Arc>();
// Add all the preferred elements that were not defined by the user.
PackedMap<Interval, MutableInt> spanSizes = getSpanSizes();
for (int i = 0; i < spanSizes.keys.length; i++) {
Interval key = spanSizes.keys[i];
+ if (key == Interval.GONE) continue;
MutableInt value = spanSizes.values[i];
// todo remove value duplicate
- include2(spanToSize, key, value, value, accommodateBothMinAndMax);
+ include2(result, key, value, value, accommodateBothMinAndMax);
}
// Find redundant rows/cols and glue them together with 0-length arcs to link the tree
- boolean[] used = findUsed(spanToSize);
+ boolean[] used = findUsed(result);
for (int i = 0; i < getCount(); i++) {
if (!used[i]) {
Interval span = new Interval(i, i + 1);
- include(spanToSize, span, new MutableInt(0));
- include(spanToSize, span.inverse(), new MutableInt(0));
+ include(result, span, new MutableInt(0));
+ include(result, span.inverse(), new MutableInt(0));
}
}
@@ -1214,15 +1284,15 @@
// Add preferred gaps
for (int i = 0; i < getCount(); i++) {
if (used[i]) {
- include2(spanToSize, new Interval(i, i + 1), 0, 0, false);
+ include2(result, new Interval(i, i + 1), 0, 0, false);
}
}
} else {
for (Interval gap : getSpacers()) {
- include2(spanToSize, gap, 0, 0, false);
+ include2(result, gap, 0, 0, false);
}
}
- Arc[] arcs = spanToSize.toArray(new Arc[spanToSize.size()]);
+ Arc[] arcs = result.toArray(new Arc[result.size()]);
return topologicalSort(arcs, 0);
}
@@ -1310,8 +1380,9 @@
private void computeMargins(boolean leading) {
int[] margins = leading ? leadingMargins : trailingMargins;
- for (int i = 0, size = getChildCount(); i < size; i++) {
+ for (int i = 0, N = getChildCount(); i < N; i++) {
View c = getChildAt(i);
+ if (isGone(c)) continue;
LayoutParams lp = getLayoutParams(c);
Group g = horizontal ? lp.columnGroup : lp.rowGroup;
Interval span = g.span;
@@ -1388,7 +1459,9 @@
private void computeWeights() {
for (int i = 0, N = getChildCount(); i < N; i++) {
- LayoutParams lp = getLayoutParams(getChildAt(i));
+ View c = getChildAt(i);
+ if (isGone(c)) continue;
+ LayoutParams lp = getLayoutParams(c);
Group g = horizontal ? lp.columnGroup : lp.rowGroup;
Interval span = g.span;
int penultimateIndex = span.max - 1;
@@ -1914,6 +1987,8 @@
of the values for each View.
*/
private static class Bounds {
+ private static final Bounds GONE = new Bounds();
+
public int before;
public int after;
@@ -1956,6 +2031,8 @@
* {@code x} such that {@code min <= x < max}.
*/
/* package */ static class Interval {
+ private static final Interval GONE = new Interval(UNDEFINED, UNDEFINED);
+
/**
* The minimum value.
*/
@@ -2041,6 +2118,8 @@
* {@code span} and {@code alignment}.
*/
public static class Group {
+ private static final Group GONE = new Group(Interval.GONE, Alignment.GONE);
+
/**
* The grid indices of the leading and trailing edges of this cell group for the
* appropriate axis.
@@ -2167,6 +2246,13 @@
* #BASELINE} and {@link #FILL}.
*/
public static abstract class Alignment {
+ private static final Alignment GONE = new Alignment() {
+ public int getAlignmentValue(View view, int viewSize, int measurementType) {
+ assert false;
+ return 0;
+ }
+ };
+
/**
* Returns an alignment value. In the case of vertical alignments the value
* returned should indicate the distance from the top of the view to the
@@ -2178,7 +2264,7 @@
* @param measurementType This parameter is currently unused as GridLayout only supports
* one type of measurement: {@link View#measure(int, int)}.
*
- * @return the alignment value
+ * @return the alignment value
*/
public abstract int getAlignmentValue(View view, int viewSize, int measurementType);
@@ -2195,7 +2281,7 @@
* @param measurementType This parameter is currently unused as GridLayout only supports
* one type of measurement: {@link View#measure(int, int)}.
*
- * @return the aligned size
+ * @return the aligned size
*/
public int getSizeInCell(View view, int viewSize, int cellSize, int measurementType) {
return viewSize;
@@ -2269,7 +2355,6 @@
return baseline;
}
}
-
};
/**
diff --git a/core/res/res/layout/keyguard_screen_unlock_portrait.xml b/core/res/res/layout/keyguard_screen_unlock_portrait.xml
index 4ffa3405..dd68d82 100644
--- a/core/res/res/layout/keyguard_screen_unlock_portrait.xml
+++ b/core/res/res/layout/keyguard_screen_unlock_portrait.xml
@@ -29,10 +29,7 @@
<com.android.internal.widget.DigitalClock android:id="@+id/time"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
android:layout_marginBottom="18dip"
- android:layout_marginRight="-4dip"
android:layout_gravity="right">
<!-- Because we can't have multi-tone fonts, we render two TextViews, one on
@@ -63,8 +60,6 @@
<LinearLayout
android:orientation="horizontal"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
android:layout_gravity="right">
<TextView
@@ -90,8 +85,6 @@
<TextView
android:id="@+id/status1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="@*android:dimen/keyguard_pattern_unlock_status_line_font_size"
android:drawablePadding="4dip"
@@ -100,8 +93,6 @@
<TextView
android:id="@+id/status2"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="@*android:dimen/keyguard_pattern_unlock_status_line_font_size"
@@ -112,9 +103,8 @@
<com.android.internal.widget.LockPatternView
android:id="@+id/lockPattern"
- android:layout_width="300dip"
- android:layout_height="300dip"
- android:layout_rowWeight="1"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
android:layout_marginTop="8dip"
android:layout_marginRight="8dip"
android:layout_marginBottom="4dip"
@@ -123,8 +113,6 @@
<TextView
android:id="@+id/carrier"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:singleLine="true"
android:ellipsize="marquee"
@@ -136,7 +124,6 @@
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
- android:layout_height="wrap_content"
android:layout_gravity="center">
<Button android:id="@+id/emergencyCallButton"
diff --git a/media/libstagefright/SampleTable.cpp b/media/libstagefright/SampleTable.cpp
index eb135ab..a8a094e 100644
--- a/media/libstagefright/SampleTable.cpp
+++ b/media/libstagefright/SampleTable.cpp
@@ -416,12 +416,16 @@
uint32_t delta = mTimeToSample[2 * i + 1];
for (uint32_t j = 0; j < n; ++j) {
- CHECK(sampleIndex < mNumSampleSizes);
+ if (sampleIndex < mNumSampleSizes) {
+ // Technically this should always be the case if the file
+ // is well-formed, but you know... there's (gasp) malformed
+ // content out there.
- mSampleTimeEntries[sampleIndex].mSampleIndex = sampleIndex;
+ mSampleTimeEntries[sampleIndex].mSampleIndex = sampleIndex;
- mSampleTimeEntries[sampleIndex].mCompositionTime =
- sampleTime + getCompositionTimeOffset(sampleIndex);
+ mSampleTimeEntries[sampleIndex].mCompositionTime =
+ sampleTime + getCompositionTimeOffset(sampleIndex);
+ }
++sampleIndex;
sampleTime += delta;
diff --git a/media/libstagefright/codecs/on2/dec/SoftVPX.cpp b/media/libstagefright/codecs/on2/dec/SoftVPX.cpp
index e9ce719..7e83163 100644
--- a/media/libstagefright/codecs/on2/dec/SoftVPX.cpp
+++ b/media/libstagefright/codecs/on2/dec/SoftVPX.cpp
@@ -117,11 +117,27 @@
addPort(def);
}
+static int GetCPUCoreCount() {
+ int cpuCoreCount = 1;
+#if defined(_SC_NPROCESSORS_ONLN)
+ cpuCoreCount = sysconf(_SC_NPROCESSORS_ONLN);
+#else
+ // _SC_NPROC_ONLN must be defined...
+ cpuCoreCount = sysconf(_SC_NPROC_ONLN);
+#endif
+ CHECK(cpuCoreCount >= 1);
+ LOGV("Number of CPU cores: %d", cpuCoreCount);
+ return cpuCoreCount;
+}
+
status_t SoftVPX::initDecoder() {
mCtx = new vpx_codec_ctx_t;
vpx_codec_err_t vpx_err;
+ vpx_codec_dec_cfg_t cfg;
+ memset(&cfg, 0, sizeof(vpx_codec_dec_cfg_t));
+ cfg.threads = GetCPUCoreCount();
if ((vpx_err = vpx_codec_dec_init(
- (vpx_codec_ctx_t *)mCtx, &vpx_codec_vp8_dx_algo, NULL, 0))) {
+ (vpx_codec_ctx_t *)mCtx, &vpx_codec_vp8_dx_algo, &cfg, 0))) {
LOGE("on2 decoder failed to initialize. (%d)", vpx_err);
return UNKNOWN_ERROR;
}
diff --git a/media/libstagefright/httplive/LiveSession.cpp b/media/libstagefright/httplive/LiveSession.cpp
index 012d9ad..165683e 100644
--- a/media/libstagefright/httplive/LiveSession.cpp
+++ b/media/libstagefright/httplive/LiveSession.cpp
@@ -296,6 +296,8 @@
new M3UParser(url, buffer->data(), buffer->size());
if (playlist->initCheck() != OK) {
+ LOGE("failed to parse .m3u8 playlist");
+
return NULL;
}
diff --git a/media/libstagefright/httplive/M3UParser.cpp b/media/libstagefright/httplive/M3UParser.cpp
index 2eb180a..765f795 100644
--- a/media/libstagefright/httplive/M3UParser.cpp
+++ b/media/libstagefright/httplive/M3UParser.cpp
@@ -179,7 +179,7 @@
if (mIsVariantPlaylist) {
return ERROR_MALFORMED;
}
- err = parseMetaData(line, &itemMeta, "duration");
+ err = parseMetaDataDuration(line, &itemMeta, "durationUs");
} else if (line.startsWith("#EXT-X-DISCONTINUITY")) {
if (mIsVariantPlaylist) {
return ERROR_MALFORMED;
@@ -203,9 +203,9 @@
if (!line.startsWith("#")) {
if (!mIsVariantPlaylist) {
- int32_t durationSecs;
+ int64_t durationUs;
if (itemMeta == NULL
- || !itemMeta->findInt32("duration", &durationSecs)) {
+ || !itemMeta->findInt64("durationUs", &durationUs)) {
return ERROR_MALFORMED;
}
}
@@ -252,6 +252,30 @@
}
// static
+status_t M3UParser::parseMetaDataDuration(
+ const AString &line, sp<AMessage> *meta, const char *key) {
+ ssize_t colonPos = line.find(":");
+
+ if (colonPos < 0) {
+ return ERROR_MALFORMED;
+ }
+
+ double x;
+ status_t err = ParseDouble(line.c_str() + colonPos + 1, &x);
+
+ if (err != OK) {
+ return err;
+ }
+
+ if (meta->get() == NULL) {
+ *meta = new AMessage;
+ }
+ (*meta)->setInt64(key, (int64_t)x * 1E6);
+
+ return OK;
+}
+
+// static
status_t M3UParser::parseStreamInf(
const AString &line, sp<AMessage> *meta) {
ssize_t colonPos = line.find(":");
@@ -412,4 +436,18 @@
return OK;
}
+// static
+status_t M3UParser::ParseDouble(const char *s, double *x) {
+ char *end;
+ double dval = strtod(s, &end);
+
+ if (end == s || (*end != '\0' && *end != ',')) {
+ return ERROR_MALFORMED;
+ }
+
+ *x = dval;
+
+ return OK;
+}
+
} // namespace android
diff --git a/media/libstagefright/include/M3UParser.h b/media/libstagefright/include/M3UParser.h
index 63895b4..478582d 100644
--- a/media/libstagefright/include/M3UParser.h
+++ b/media/libstagefright/include/M3UParser.h
@@ -63,6 +63,9 @@
static status_t parseMetaData(
const AString &line, sp<AMessage> *meta, const char *key);
+ static status_t parseMetaDataDuration(
+ const AString &line, sp<AMessage> *meta, const char *key);
+
static status_t parseStreamInf(
const AString &line, sp<AMessage> *meta);
@@ -70,6 +73,7 @@
const AString &line, sp<AMessage> *meta, const AString &baseURI);
static status_t ParseInt32(const char *s, int32_t *x);
+ static status_t ParseDouble(const char *s, double *x);
DISALLOW_EVIL_CONSTRUCTORS(M3UParser);
};
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
index 0b82123..f3c2623 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -1721,7 +1721,7 @@
|| Intent.ACTION_SCREEN_OFF.equals(action)) {
boolean excludeRecents = false;
if (Intent.ACTION_CLOSE_SYSTEM_DIALOGS.equals(action)) {
- String reason = intent.getExtras().getString("reason");
+ String reason = intent.getStringExtra("reason");
if (reason != null) {
excludeRecents = reason.equals("recentapps");
}
diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/FileFilter.java b/tests/DumpRenderTree/src/com/android/dumprendertree/FileFilter.java
index 4294254..d373d8d 100644
--- a/tests/DumpRenderTree/src/com/android/dumprendertree/FileFilter.java
+++ b/tests/DumpRenderTree/src/com/android/dumprendertree/FileFilter.java
@@ -85,6 +85,12 @@
// This first block of tests are for features for which Android
// should pass all tests. They are skipped only temporarily.
// TODO: Fix these failing tests and remove them from this list.
+ ignoreResultList.add("fast/dom/HTMLKeygenElement/keygen.html"); // Missing layoutTestController.shadowRoot()
+ ignoreResultList.add("fast/dom/Geolocation/window-close-crash.html"); // Missing layoutTestContoller.setCloseRemainingWindowsWhenComplete()
+ ignoreResultList.add("fast/dom/Geolocation/page-reload-cancel-permission-requests.html"); // Missing layoutTestController.numberOfPendingGeolocationPermissionRequests()
+ ignoreResultList.add("fast/dom/HTMLLinkElement/link-and-subresource-test.html"); // Missing layoutTestController.dumpResourceResponseMIMETypes()
+ ignoreResultList.add("fast/dom/HTMLLinkElement/prefetch.html"); // Missing layoutTestController.dumpResourceResponseMIMETypes()
+ ignoreResultList.add("fast/dom/HTMLLinkElement/subresource.html"); // Missing layoutTestController.dumpResourceResponseMIMETypes()
ignoreResultList.add("fast/encoding/char-decoding.html"); // fails in Java HTTP stack, see http://b/issue?id=3047156
ignoreResultList.add("fast/encoding/hanarei-blog32-fc2-com.html"); // fails in Java HTTP stack, see http://b/issue?id=3046986
ignoreResultList.add("fast/encoding/mailto-always-utf-8.html"); // Requires waitForPolicyDelegate(), see http://b/issue?id=3043468
@@ -100,9 +106,16 @@
ignoreResultList.add("storage/open-database-creation-callback-isolated-world.html"); // Requires layoutTestController.evaluateScriptInIsolatedWorld()
ignoreResultList.add("storage/statement-error-callback-isolated-world.html"); // Requires layoutTestController.evaluateScriptInIsolatedWorld()
ignoreResultList.add("storage/statement-success-callback-isolated-world.html"); // Requires layoutTestController.evaluateScriptInIsolatedWorld()
+ ignoreResultList.add("storage/storageinfo-query-usage.html"); // Need window.webkitStorageInfo
ignoreResultList.add("storage/transaction-callback-isolated-world.html"); // Requires layoutTestController.evaluateScriptInIsolatedWorld()
ignoreResultList.add("storage/transaction-error-callback-isolated-world.html"); // Requires layoutTestController.evaluateScriptInIsolatedWorld()
ignoreResultList.add("storage/transaction-success-callback-isolated-world.html"); // Requires layoutTestController.evaluateScriptInIsolatedWorld()
+ ignoreResultList.add("storage/domstorage/localstorage/storagetracker/storage-tracker-1-prepare.html"); // Missing layoutTestController.originsWithLocalStorage()
+ ignoreResultList.add("storage/domstorage/localstorage/storagetracker/storage-tracker-2-create.html"); // Missing layoutTestController.originsWithLocalStorage()
+ ignoreResultList.add("storage/domstorage/localstorage/storagetracker/storage-tracker-3-delete-all.html"); // Missing layoutTestController.originsWithLocalStorage()
+ ignoreResultList.add("storage/domstorage/localstorage/storagetracker/storage-tracker-4-create.html"); // Missing layoutTestController.originsWithLocalStorage()
+ ignoreResultList.add("storage/domstorage/localstorage/storagetracker/storage-tracker-5-delete-one.html"); // Missing layoutTestController.originsWithLocalStorage()
+
// Expected failures due to unsupported features or tests unsuitable for Android.
ignoreResultList.add("fast/encoding/char-decoding-mac.html"); // Mac-specific encodings (also marked Won't Fix in Chromium, bug 7388)
@@ -119,6 +132,7 @@
ignoreResultList.add("storage/domstorage/localstorage/private-browsing-affects-storage.html"); // private browsing not supported
ignoreResultList.add("storage/domstorage/sessionstorage/private-browsing-affects-storage.html"); // private browsing not supported
ignoreResultList.add("storage/indexeddb"); // indexeddb not supported
+ ignoreResultList.add("storage/private-browsing-noread-nowrite.html"); // private browsing not supported
ignoreResultList.add("storage/private-browsing-readonly.html"); // private browsing not supported
ignoreResultList.add("websocket/tests/workers"); // workers not supported
ignoreResultList.add("dom/xhtml/level2/html/htmldocument04.xhtml"); // /mnt/sdcard on SR uses lowercase filesystem, this test checks filename and is case senstive.
diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/TestShellActivity.java b/tests/DumpRenderTree/src/com/android/dumprendertree/TestShellActivity.java
index fa82070..f8c32dd 100644
--- a/tests/DumpRenderTree/src/com/android/dumprendertree/TestShellActivity.java
+++ b/tests/DumpRenderTree/src/com/android/dumprendertree/TestShellActivity.java
@@ -207,6 +207,11 @@
getWindow().setFeatureInt(Window.FEATURE_PROGRESS, progress);
Log.v(LOGTAG, " Loading " + mTestUrl);
+
+ if (mTestUrl.contains("/dumpAsText/")) {
+ dumpAsText(false);
+ }
+
mWebView.loadUrl(mTestUrl);
if (mTimeoutInMillis > 0) {
diff --git a/tools/layoutlib/bridge/tests/Android.mk b/tools/layoutlib/bridge/tests/Android.mk
index e303638..98cade9 100644
--- a/tools/layoutlib/bridge/tests/Android.mk
+++ b/tools/layoutlib/bridge/tests/Android.mk
@@ -19,6 +19,8 @@
# Only compile source java files in this lib.
LOCAL_SRC_FILES := $(call all-java-files-under, src)
+LOCAL_JAVA_RESOURCE_DIRS := res
+
LOCAL_MODULE := layoutlib-tests
LOCAL_MODULE_TAGS := optional
diff --git a/tools/layoutlib/bridge/tests/src/com/android/layoutlib/testdata/layout1.xml b/tools/layoutlib/bridge/tests/res/com/android/layoutlib/testdata/layout1.xml
similarity index 100%
rename from tools/layoutlib/bridge/tests/src/com/android/layoutlib/testdata/layout1.xml
rename to tools/layoutlib/bridge/tests/res/com/android/layoutlib/testdata/layout1.xml