Merge "Remove all ringtones except default on Xoom Bug: 5032006"
diff --git a/api/current.txt b/api/current.txt
index 4f50bf3..49e9285 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -20702,7 +20702,6 @@
public class EasyEditSpan implements android.text.ParcelableSpan {
ctor public EasyEditSpan();
- ctor public EasyEditSpan(android.os.Parcel);
method public int describeContents();
method public int getSpanTypeId();
method public void writeToParcel(android.os.Parcel, int);
@@ -23046,7 +23045,6 @@
method public boolean willNotDraw();
field public static android.util.Property ALPHA;
field protected static int DEFAULT_TEXT_DIRECTION;
- field protected static float DEFAULT_TEXT_DIRECTION_CHAR_COUNT_THRESHOLD;
field public static final int DRAWING_CACHE_QUALITY_AUTO = 0; // 0x0
field public static final int DRAWING_CACHE_QUALITY_HIGH = 1048576; // 0x100000
field public static final int DRAWING_CACHE_QUALITY_LOW = 524288; // 0x80000
diff --git a/core/java/android/database/AbstractCursor.java b/core/java/android/database/AbstractCursor.java
index b6487bd..5fe42db 100644
--- a/core/java/android/database/AbstractCursor.java
+++ b/core/java/android/database/AbstractCursor.java
@@ -36,6 +36,8 @@
DataSetObservable mDataSetObservable = new DataSetObservable();
ContentObservable mContentObservable = new ContentObservable();
+ Bundle mExtras = Bundle.EMPTY;
+
/* -------------------------------------------------------- */
/* These need to be implemented by subclasses */
abstract public int getCount();
@@ -71,11 +73,11 @@
public int getColumnCount() {
return getColumnNames().length;
}
-
+
public void deactivate() {
deactivateInternal();
}
-
+
/**
* @hide
*/
@@ -99,7 +101,7 @@
public boolean isClosed() {
return mClosed;
}
-
+
public void close() {
mClosed = true;
mContentObservable.unregisterAll();
@@ -120,7 +122,7 @@
return true;
}
-
+
public void copyStringToBuffer(int columnIndex, CharArrayBuffer buffer) {
// Default implementation, uses getString
String result = getString(columnIndex);
@@ -136,7 +138,7 @@
buffer.sizeCopied = 0;
}
}
-
+
/* -------------------------------------------------------- */
/* Implementation */
public AbstractCursor() {
@@ -181,7 +183,7 @@
return result;
}
-
+
/**
* Copy data from cursor to CursorWindow
* @param position start position of data
@@ -199,7 +201,7 @@
window.setStartPosition(position);
int columnNum = getColumnCount();
window.setNumColumns(columnNum);
- while (moveToNext() && window.allocRow()) {
+ while (moveToNext() && window.allocRow()) {
for (int i = 0; i < columnNum; i++) {
String field = getString(i);
if (field != null) {
@@ -215,7 +217,7 @@
}
}
}
-
+
mPos = oldpos;
} catch (IllegalStateException e){
// simply ignore it
@@ -314,7 +316,7 @@
mContentObservable.unregisterObserver(observer);
}
}
-
+
/**
* This is hidden until the data set change model has been re-evaluated.
* @hide
@@ -322,14 +324,14 @@
protected void notifyDataSetChange() {
mDataSetObservable.notifyChanged();
}
-
+
/**
* This is hidden until the data set change model has been re-evaluated.
* @hide
*/
protected DataSetObservable getDataSetObservable() {
return mDataSetObservable;
-
+
}
public void registerDataSetObserver(DataSetObserver observer) {
@@ -383,8 +385,19 @@
return false;
}
+ /**
+ * Sets a {@link Bundle} that will be returned by {@link #getExtras()}. <code>null</code> will
+ * be converted into {@link Bundle#EMPTY}.
+ *
+ * @param extras {@link Bundle} to set.
+ * @hide
+ */
+ public void setExtras(Bundle extras) {
+ mExtras = (extras == null) ? Bundle.EMPTY : extras;
+ }
+
public Bundle getExtras() {
- return Bundle.EMPTY;
+ return mExtras;
}
public Bundle respond(Bundle extras) {
diff --git a/core/java/android/text/TextUtils.java b/core/java/android/text/TextUtils.java
index e914316..355d467 100644
--- a/core/java/android/text/TextUtils.java
+++ b/core/java/android/text/TextUtils.java
@@ -24,8 +24,8 @@
import android.text.style.BackgroundColorSpan;
import android.text.style.BulletSpan;
import android.text.style.CharacterStyle;
-import android.text.style.ForegroundColorSpan;
import android.text.style.EasyEditSpan;
+import android.text.style.ForegroundColorSpan;
import android.text.style.LeadingMarginSpan;
import android.text.style.MetricAffectingSpan;
import android.text.style.QuoteSpan;
@@ -748,11 +748,11 @@
break;
case SUGGESTION_RANGE_SPAN:
- readSpan(p, sp, new SuggestionRangeSpan());
+ readSpan(p, sp, new SuggestionRangeSpan(p));
break;
case EASY_EDIT_SPAN:
- readSpan(p, sp, new EasyEditSpan(p));
+ readSpan(p, sp, new EasyEditSpan());
break;
default:
diff --git a/core/java/android/text/style/EasyEditSpan.java b/core/java/android/text/style/EasyEditSpan.java
index e6e4d2c..2feb719 100644
--- a/core/java/android/text/style/EasyEditSpan.java
+++ b/core/java/android/text/style/EasyEditSpan.java
@@ -33,10 +33,6 @@
// Empty
}
- public EasyEditSpan(Parcel src) {
- this();
- }
-
@Override
public int describeContents() {
return 0;
diff --git a/core/java/android/text/style/SuggestionRangeSpan.java b/core/java/android/text/style/SuggestionRangeSpan.java
index fc91697..a637b1c 100644
--- a/core/java/android/text/style/SuggestionRangeSpan.java
+++ b/core/java/android/text/style/SuggestionRangeSpan.java
@@ -16,7 +16,6 @@
package android.text.style;
-import android.graphics.Color;
import android.os.Parcel;
import android.text.ParcelableSpan;
import android.text.TextPaint;
@@ -29,12 +28,20 @@
* @hide
*/
public class SuggestionRangeSpan extends CharacterStyle implements ParcelableSpan {
+ private final int mBackgroundColor;
+
@Override
public void updateDrawState(TextPaint tp) {
- tp.setColor(Color.GREEN);
+ tp.bgColor = mBackgroundColor;
}
- public SuggestionRangeSpan() { /* Nothing to do*/ }
+ public SuggestionRangeSpan(int color) {
+ mBackgroundColor = color;
+ }
+
+ public SuggestionRangeSpan(Parcel src) {
+ mBackgroundColor = src.readInt();
+ }
@Override
public int describeContents() {
@@ -42,7 +49,9 @@
}
@Override
- public void writeToParcel(Parcel dest, int flags) { /* Nothing to do*/ }
+ public void writeToParcel(Parcel dest, int flags) {
+ dest.writeInt(mBackgroundColor);
+ }
@Override
public int getSpanTypeId() {
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 14677e1..bb12a57 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -2595,11 +2595,6 @@
protected static int DEFAULT_TEXT_DIRECTION = TEXT_DIRECTION_INHERIT;
/**
- * Default threshold for "char count" heuristic.
- */
- protected static float DEFAULT_TEXT_DIRECTION_CHAR_COUNT_THRESHOLD = 0.6f;
-
- /**
* The text direction that has been defined by {@link #setTextDirection(int)}.
*
* {@hide}
@@ -6052,23 +6047,29 @@
* @see #onHoverChanged
*/
public boolean onHoverEvent(MotionEvent event) {
- switch (event.getAction()) {
- case MotionEvent.ACTION_HOVER_ENTER:
- if (!hasHoveredChild() && !mSendingHoverAccessibilityEvents) {
- mSendingHoverAccessibilityEvents = true;
- sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_HOVER_ENTER);
- }
- break;
- case MotionEvent.ACTION_HOVER_EXIT:
- if (mSendingHoverAccessibilityEvents) {
- mSendingHoverAccessibilityEvents = false;
- sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_HOVER_EXIT);
- }
- break;
+ // The root view may receive hover (or touch) events that are outside the bounds of
+ // the window. This code ensures that we only send accessibility events for
+ // hovers that are actually within the bounds of the root view.
+ final int action = event.getAction();
+ if (!mSendingHoverAccessibilityEvents) {
+ if ((action == MotionEvent.ACTION_HOVER_ENTER
+ || action == MotionEvent.ACTION_HOVER_MOVE)
+ && !hasHoveredChild()
+ && pointInView(event.getX(), event.getY())) {
+ mSendingHoverAccessibilityEvents = true;
+ sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_HOVER_ENTER);
+ }
+ } else {
+ if (action == MotionEvent.ACTION_HOVER_EXIT
+ || (action == MotionEvent.ACTION_HOVER_MOVE
+ && !pointInView(event.getX(), event.getY()))) {
+ mSendingHoverAccessibilityEvents = false;
+ sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_HOVER_EXIT);
+ }
}
if (isHoverable()) {
- switch (event.getAction()) {
+ switch (action) {
case MotionEvent.ACTION_HOVER_ENTER:
setHovered(true);
break;
diff --git a/core/java/android/view/WindowOrientationListener.java b/core/java/android/view/WindowOrientationListener.java
index 5d4fbbe..76b47ca 100755
--- a/core/java/android/view/WindowOrientationListener.java
+++ b/core/java/android/view/WindowOrientationListener.java
@@ -332,7 +332,7 @@
// we perform an orientation change under ideal conditions. It will take
// proportionally longer than this to effect an orientation change when
// the proposed orientation confidence is low.
- private static final float ORIENTATION_SETTLE_TIME_MS = 100;
+ private static final float ORIENTATION_SETTLE_TIME_MS = 250;
// The confidence that we have abount effecting each orientation change.
// When one of these values exceeds 1.0, we have determined our new orientation!
diff --git a/core/java/android/widget/SpellChecker.java b/core/java/android/widget/SpellChecker.java
index b89b8ec..14cbf6f 100644
--- a/core/java/android/widget/SpellChecker.java
+++ b/core/java/android/widget/SpellChecker.java
@@ -1,4 +1,18 @@
-// Copyright 2011 Google Inc. All Rights Reserved.
+/*
+ * 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.widget;
@@ -32,7 +46,7 @@
private final TextView mTextView;
- final SpellCheckerSession spellCheckerSession;
+ final SpellCheckerSession mSpellCheckerSession;
final int mCookie;
// Paired arrays for the (id, spellCheckSpan) pair. mIndex is the next available position
@@ -49,7 +63,7 @@
final TextServicesManager textServicesManager = (TextServicesManager) textView.getContext().
getSystemService(Context.TEXT_SERVICES_MANAGER_SERVICE);
- spellCheckerSession = textServicesManager.newSpellCheckerSession(
+ mSpellCheckerSession = textServicesManager.newSpellCheckerSession(
null /* not currently used by the textServicesManager */, Locale.getDefault(),
this, true /* means use the languages defined in Settings */);
mCookie = hashCode();
@@ -112,7 +126,7 @@
private void scheduleSpellCheck() {
if (mLength == 0) return;
- if (spellCheckerSession == null) return;
+ if (mSpellCheckerSession == null) return;
if (mChecker != null) {
mTextView.removeCallbacks(mChecker);
@@ -157,7 +171,7 @@
System.arraycopy(textInfos, 0, textInfosCopy, 0, textInfosCount);
textInfos = textInfosCopy;
}
- spellCheckerSession.getSuggestions(textInfos, SuggestionSpan.SUGGESTIONS_MAX_SIZE,
+ mSpellCheckerSession.getSuggestions(textInfos, SuggestionSpan.SUGGESTIONS_MAX_SIZE,
false /* TODO Set sequentialWords to true for initial spell check */);
}
}
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index 4ce2d90..1aa009b 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -63,8 +63,8 @@
import android.text.TextDirectionHeuristics;
import android.text.TextPaint;
import android.text.TextUtils;
-import android.text.TextWatcher;
import android.text.TextUtils.TruncateAt;
+import android.text.TextWatcher;
import android.text.method.AllCapsTransformationMethod;
import android.text.method.ArrowKeyMovementMethod;
import android.text.method.DateKeyListener;
@@ -82,7 +82,6 @@
import android.text.method.TransformationMethod;
import android.text.method.TransformationMethod2;
import android.text.method.WordIterator;
-import android.text.style.CharacterStyle;
import android.text.style.ClickableSpan;
import android.text.style.EasyEditSpan;
import android.text.style.ParagraphStyle;
@@ -131,6 +130,7 @@
import android.view.inputmethod.ExtractedTextRequest;
import android.view.inputmethod.InputConnection;
import android.view.inputmethod.InputMethodManager;
+import android.widget.AdapterView.OnItemClickListener;
import android.widget.RemoteViews.RemoteView;
import com.android.internal.util.FastMath;
@@ -7868,7 +7868,9 @@
@Override
protected void initContentView() {
- mContentView.setOrientation(LinearLayout.HORIZONTAL);
+ LinearLayout linearLayout = new LinearLayout(TextView.this.getContext());
+ linearLayout.setOrientation(LinearLayout.HORIZONTAL);
+ mContentView = linearLayout;
mContentView.setBackgroundResource(
com.android.internal.R.drawable.text_edit_side_paste_window);
@@ -8177,17 +8179,6 @@
startStopMarquee(hasWindowFocus);
}
- private void removeSpans(int start, int end, Class<?> type) {
- if (mText instanceof Editable) {
- Editable editable = ((Editable) mText);
- Object[] spans = editable.getSpans(start, end, type);
- final int length = spans.length;
- for (int i = 0; i < length; i++) {
- editable.removeSpan(spans[i]);
- }
- }
- }
-
@Override
protected void onVisibilityChanged(View changedView, int visibility) {
super.onVisibilityChanged(changedView, visibility);
@@ -9326,7 +9317,7 @@
private abstract class PinnedPopupWindow implements TextViewPositionListener {
protected PopupWindow mPopupWindow;
- protected LinearLayout mContentView;
+ protected ViewGroup mContentView;
int mPositionX, mPositionY;
protected abstract void createPopupWindow();
@@ -9342,23 +9333,16 @@
mPopupWindow.setWidth(ViewGroup.LayoutParams.WRAP_CONTENT);
mPopupWindow.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
- mContentView = new LinearLayout(TextView.this.getContext());
- LayoutParams wrapContent = new LayoutParams(
- ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
+ initContentView();
+
+ LayoutParams wrapContent = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
+ ViewGroup.LayoutParams.WRAP_CONTENT);
mContentView.setLayoutParams(wrapContent);
- initContentView();
mPopupWindow.setContentView(mContentView);
}
public void show() {
- final DisplayMetrics displayMetrics = mContext.getResources().getDisplayMetrics();
- mContentView.measure(
- View.MeasureSpec.makeMeasureSpec(displayMetrics.widthPixels,
- View.MeasureSpec.AT_MOST),
- View.MeasureSpec.makeMeasureSpec(displayMetrics.heightPixels,
- View.MeasureSpec.AT_MOST));
-
TextView.this.getPositionListener().addSubscriber(this, false);
computeLocalPosition();
@@ -9366,11 +9350,24 @@
final PositionListener positionListener = TextView.this.getPositionListener();
updatePosition(positionListener.getPositionX(), positionListener.getPositionY());
}
+
+ protected void measureContent() {
+ final DisplayMetrics displayMetrics = mContext.getResources().getDisplayMetrics();
+ mContentView.measure(
+ View.MeasureSpec.makeMeasureSpec(displayMetrics.widthPixels,
+ View.MeasureSpec.AT_MOST),
+ View.MeasureSpec.makeMeasureSpec(displayMetrics.heightPixels,
+ View.MeasureSpec.AT_MOST));
+ }
+ /* The popup window will be horizontally centered on the getTextOffset() and vertically
+ * positioned according to viewportToContentHorizontalOffset.
+ *
+ * This method assumes that mContentView has properly been measured from its content. */
private void computeLocalPosition() {
- final int offset = getTextOffset();
-
+ measureContent();
final int width = mContentView.getMeasuredWidth();
+ final int offset = getTextOffset();
mPositionX = (int) (mLayout.getPrimaryHorizontal(offset) - width / 2.0f);
mPositionX += viewportToContentHorizontalOffset();
@@ -9418,42 +9415,17 @@
}
}
- private static class SuggestionRangeSpan extends CharacterStyle {
-
- private final int mTextColor;
- private final int mBackgroundColor;
-
- public SuggestionRangeSpan(Context context) {
- TypedArray typedArray = context.obtainStyledAttributes(null,
- com.android.internal.R.styleable.SuggestionRangeSpan,
- com.android.internal.R.attr.textAppearanceSuggestionRange, 0);
-
- mTextColor = typedArray.getColor(
- com.android.internal.R.styleable.SuggestionRangeSpan_textColor, 0);
- mBackgroundColor = typedArray.getColor(
- com.android.internal.R.styleable.SuggestionRangeSpan_colorBackground, 0);
- }
-
- @Override
- public void updateDrawState(TextPaint tp) {
- if (mTextColor != 0) {
- tp.setColor(mTextColor);
- }
-
- if (mBackgroundColor != 0) {
- tp.bgColor = mBackgroundColor;
- }
- }
- }
-
- private class SuggestionsPopupWindow extends PinnedPopupWindow implements OnClickListener {
+ private class SuggestionsPopupWindow extends PinnedPopupWindow implements OnItemClickListener {
private static final int MAX_NUMBER_SUGGESTIONS = SuggestionSpan.SUGGESTIONS_MAX_SIZE;
private static final int NO_SUGGESTIONS = -1;
private static final float AVERAGE_HIGHLIGHTS_PER_SUGGESTION = 1.4f;
private WordIterator mSuggestionWordIterator;
private TextAppearanceSpan[] mHighlightSpans = new TextAppearanceSpan
[(int) (AVERAGE_HIGHLIGHTS_PER_SUGGESTION * MAX_NUMBER_SUGGESTIONS)];
+ private SuggestionInfo[] mSuggestionInfos;
+ private int mNumberOfSuggestions;
private boolean mCursorWasVisibleBeforeSuggestions;
+ private SuggestionAdapter mSuggestionsAdapter;
private class CustomPopupWindow extends PopupWindow {
public CustomPopupWindow(Context context, int defStyle) {
@@ -9494,29 +9466,16 @@
@Override
protected void initContentView() {
- mContentView.setOrientation(LinearLayout.VERTICAL);
-
- LayoutInflater inflater = (LayoutInflater) TextView.this.mContext.
- getSystemService(Context.LAYOUT_INFLATER_SERVICE);
-
- if (inflater == null) {
- throw new IllegalArgumentException(
- "Unable to create inflater for TextEdit suggestions");
- }
+ ListView listView = new ListView(TextView.this.getContext());
+ mSuggestionsAdapter = new SuggestionAdapter();
+ listView.setAdapter(mSuggestionsAdapter);
+ listView.setOnItemClickListener(this);
+ mContentView = listView;
// Inflate the suggestion items once and for all.
+ mSuggestionInfos = new SuggestionInfo[MAX_NUMBER_SUGGESTIONS];
for (int i = 0; i < MAX_NUMBER_SUGGESTIONS; i++) {
- View childView = inflater.inflate(mTextEditSuggestionItemLayout,
- mContentView, false);
-
- if (! (childView instanceof TextView)) {
- throw new IllegalArgumentException(
- "Inflated TextEdit suggestion item is not a TextView: " + childView);
- }
-
- childView.setTag(new SuggestionInfo());
- mContentView.addView(childView);
- childView.setOnClickListener(this);
+ mSuggestionInfos[i] = new SuggestionInfo();
}
}
@@ -9525,6 +9484,40 @@
int spanStart, spanEnd; // range in TextView where text should be inserted
SuggestionSpan suggestionSpan; // the SuggestionSpan that this TextView represents
int suggestionIndex; // the index of the suggestion inside suggestionSpan
+ SpannableStringBuilder text = new SpannableStringBuilder();
+ }
+
+ private class SuggestionAdapter extends BaseAdapter {
+ private LayoutInflater mInflater = (LayoutInflater) TextView.this.mContext.
+ getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+
+ @Override
+ public int getCount() {
+ return mNumberOfSuggestions;
+ }
+
+ @Override
+ public Object getItem(int position) {
+ return mSuggestionInfos[position];
+ }
+
+ @Override
+ public long getItemId(int position) {
+ return position;
+ }
+
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent) {
+ TextView textView = (TextView) convertView;
+
+ if (textView == null) {
+ textView = (TextView) mInflater.inflate(mTextEditSuggestionItemLayout, parent,
+ false);
+ }
+
+ textView.setText(mSuggestionInfos[position].text);
+ return textView;
+ }
}
/**
@@ -9569,6 +9562,36 @@
}
@Override
+ protected void measureContent() {
+ final DisplayMetrics displayMetrics = mContext.getResources().getDisplayMetrics();
+ final int horizontalMeasure = View.MeasureSpec.makeMeasureSpec(
+ displayMetrics.widthPixels, View.MeasureSpec.AT_MOST);
+ final int verticalMeasure = View.MeasureSpec.makeMeasureSpec(
+ displayMetrics.heightPixels, View.MeasureSpec.AT_MOST);
+
+ int width = 0;
+ View view = null;
+ for (int i = 0; i < mNumberOfSuggestions; i++) {
+ view = mSuggestionsAdapter.getView(i, view, mContentView);
+ view.measure(horizontalMeasure, verticalMeasure);
+ width = Math.max(width, view.getMeasuredWidth());
+ }
+
+ // Enforce the width based on actual text widths
+ mContentView.measure(
+ View.MeasureSpec.makeMeasureSpec(width, View.MeasureSpec.EXACTLY),
+ verticalMeasure);
+
+ Drawable popupBackground = mPopupWindow.getBackground();
+ if (popupBackground != null) {
+ if (mTempRect == null) mTempRect = new Rect();
+ popupBackground.getPadding(mTempRect);
+ width += mTempRect.left + mTempRect.right;
+ }
+ mPopupWindow.setWidth(width);
+ }
+
+ @Override
protected int getTextOffset() {
return getSelectionStart();
}
@@ -9596,7 +9619,7 @@
final int nbSpans = suggestionSpans.length;
- int totalNbSuggestions = 0;
+ mNumberOfSuggestions = 0;
int spanUnionStart = mText.length();
int spanUnionEnd = 0;
@@ -9610,17 +9633,15 @@
String[] suggestions = suggestionSpan.getSuggestions();
int nbSuggestions = suggestions.length;
for (int suggestionIndex = 0; suggestionIndex < nbSuggestions; suggestionIndex++) {
- TextView textView = (TextView) mContentView.getChildAt(
- totalNbSuggestions);
- textView.setText(suggestions[suggestionIndex]);
- SuggestionInfo suggestionInfo = (SuggestionInfo) textView.getTag();
+ SuggestionInfo suggestionInfo = mSuggestionInfos[mNumberOfSuggestions];
suggestionInfo.spanStart = spanStart;
suggestionInfo.spanEnd = spanEnd;
suggestionInfo.suggestionSpan = suggestionSpan;
suggestionInfo.suggestionIndex = suggestionIndex;
+ suggestionInfo.text = new SpannableStringBuilder(suggestions[suggestionIndex]);
- totalNbSuggestions++;
- if (totalNbSuggestions == MAX_NUMBER_SUGGESTIONS) {
+ mNumberOfSuggestions++;
+ if (mNumberOfSuggestions == MAX_NUMBER_SUGGESTIONS) {
// Also end outer for loop
spanIndex = nbSpans;
break;
@@ -9628,31 +9649,18 @@
}
}
- if (totalNbSuggestions == 0) return false;
+ if (mNumberOfSuggestions == 0) return false;
- if (mSuggestionRangeSpan == null) {
- mSuggestionRangeSpan = new SuggestionRangeSpan(getContext());
- }
-
- ((Editable) mText).setSpan(mSuggestionRangeSpan, spanUnionStart, spanUnionEnd,
- Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
+ if (mSuggestionRangeSpan == null) mSuggestionRangeSpan =
+ new SuggestionRangeSpan(mHighlightColor);
- if (mSuggestionRangeSpan == null) mSuggestionRangeSpan =
- new SuggestionRangeSpan(getContext());
((Editable) mText).setSpan(mSuggestionRangeSpan, spanUnionStart, spanUnionEnd,
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
- for (int i = 0; i < totalNbSuggestions; i++) {
- final TextView textView = (TextView) mContentView.getChildAt(i);
- highlightTextDifferences(textView, spanUnionStart, spanUnionEnd);
+ for (int i = 0; i < mNumberOfSuggestions; i++) {
+ highlightTextDifferences(mSuggestionInfos[i], spanUnionStart, spanUnionEnd);
}
-
- for (int i = 0; i < totalNbSuggestions; i++) {
- mContentView.getChildAt(i).setVisibility(VISIBLE);
- }
- for (int i = totalNbSuggestions; i < MAX_NUMBER_SUGGESTIONS; i++) {
- mContentView.getChildAt(i).setVisibility(GONE);
- }
+ mSuggestionsAdapter.notifyDataSetChanged();
return true;
}
@@ -9719,13 +9727,13 @@
return highlightSpan;
}
- private void highlightTextDifferences(TextView textView, int unionStart, int unionEnd) {
- SuggestionInfo suggestionInfo = (SuggestionInfo) textView.getTag();
+ private void highlightTextDifferences(SuggestionInfo suggestionInfo,
+ int unionStart, int unionEnd) {
final int spanStart = suggestionInfo.spanStart;
final int spanEnd = suggestionInfo.spanEnd;
// Remove all text formating by converting to Strings
- final String text = textView.getText().toString();
+ final String text = suggestionInfo.text.toString();
final String sourceText = mText.subSequence(spanStart, spanEnd).toString();
long[] sourceWordLimits = getWordLimits(sourceText);
@@ -9800,7 +9808,7 @@
if (previousCommonWordIndex < words.length - 1) {
int firstDifferentPosition = previousCommonWordIndex < 0 ? 0 :
extractRangeEndFromLong(wordLimits[previousCommonWordIndex]);
- int lastDifferentPosition = textView.length();
+ int lastDifferentPosition = text.length();
ssb.setSpan(highlightSpan(nbHighlightSpans++),
shift + firstDifferentPosition, shift + lastDifferentPosition,
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
@@ -9811,25 +9819,24 @@
int lastCommonTextWordEnd = previousCommonWordIndex < 0 ? 0 :
extractRangeEndFromLong(wordLimits[previousCommonWordIndex]);
- String textSpaces = text.substring(lastCommonTextWordEnd, textView.length());
+ String textSpaces = text.substring(lastCommonTextWordEnd, text.length());
if (!sourceSpaces.equals(textSpaces) && textSpaces.length() > 0) {
ssb.setSpan(highlightSpan(nbHighlightSpans++),
- shift + lastCommonTextWordEnd, shift + textView.length(),
+ shift + lastCommonTextWordEnd, shift + text.length(),
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
}
// Final part, text after the current suggestion range.
ssb.append(mText.subSequence(spanEnd, unionEnd).toString());
- textView.setText(ssb);
}
@Override
- public void onClick(View view) {
+ public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
if (view instanceof TextView) {
TextView textView = (TextView) view;
- SuggestionInfo suggestionInfo = (SuggestionInfo) textView.getTag();
+ SuggestionInfo suggestionInfo = mSuggestionInfos[position];
final int spanStart = suggestionInfo.spanStart;
final int spanEnd = suggestionInfo.spanEnd;
if (spanStart != NO_SUGGESTIONS) {
@@ -10190,9 +10197,11 @@
@Override
protected void initContentView() {
- mContentView.setOrientation(LinearLayout.HORIZONTAL);
+ LinearLayout linearLayout = new LinearLayout(TextView.this.getContext());
+ linearLayout.setOrientation(LinearLayout.HORIZONTAL);
+ mContentView = linearLayout;
mContentView.setBackgroundResource(
- com.android.internal.R.drawable.text_edit_side_paste_window);
+ com.android.internal.R.drawable.text_edit_paste_window);
LayoutInflater inflater = (LayoutInflater)TextView.this.mContext.
getSystemService(Context.LAYOUT_INFLATER_SERVICE);
@@ -11282,7 +11291,7 @@
private final TextPaint mTextPaint;
private boolean mUserSetTextScaleX;
private final Paint mHighlightPaint;
- private int mHighlightColor = 0xCC475925;
+ private int mHighlightColor = 0x4C33B5E5;
/**
* This is temporarily visible to fix bug 3085564 in webView. Do not rely on
* this field being protected. Will be restored as private when lineHeight
diff --git a/core/res/res/drawable-hdpi/text_edit_paste_window.9.png b/core/res/res/drawable-hdpi/text_edit_paste_window.9.png
index 6654e4d..b74f37b 100644
--- a/core/res/res/drawable-hdpi/text_edit_paste_window.9.png
+++ b/core/res/res/drawable-hdpi/text_edit_paste_window.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/text_edit_suggestions_window.9.png b/core/res/res/drawable-hdpi/text_edit_suggestions_window.9.png
index c97514f..b74f37b 100644
--- a/core/res/res/drawable-hdpi/text_edit_suggestions_window.9.png
+++ b/core/res/res/drawable-hdpi/text_edit_suggestions_window.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/text_edit_paste_window.9.png b/core/res/res/drawable-mdpi/text_edit_paste_window.9.png
index 41886eb..16f623d 100644
--- a/core/res/res/drawable-mdpi/text_edit_paste_window.9.png
+++ b/core/res/res/drawable-mdpi/text_edit_paste_window.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/text_edit_suggestions_window.9.png b/core/res/res/drawable-mdpi/text_edit_suggestions_window.9.png
index 88be6e1..16f623d 100644
--- a/core/res/res/drawable-mdpi/text_edit_suggestions_window.9.png
+++ b/core/res/res/drawable-mdpi/text_edit_suggestions_window.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/text_edit_paste_window.9.png b/core/res/res/drawable-xhdpi/text_edit_paste_window.9.png
new file mode 100644
index 0000000..5c043b6
--- /dev/null
+++ b/core/res/res/drawable-xhdpi/text_edit_paste_window.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/text_edit_suggestions_window.9.png b/core/res/res/drawable-xhdpi/text_edit_suggestions_window.9.png
new file mode 100644
index 0000000..5c043b6
--- /dev/null
+++ b/core/res/res/drawable-xhdpi/text_edit_suggestions_window.9.png
Binary files differ
diff --git a/core/res/res/layout/text_edit_action_popup_text.xml b/core/res/res/layout/text_edit_action_popup_text.xml
index aa6a5e1..42e6f2e 100644
--- a/core/res/res/layout/text_edit_action_popup_text.xml
+++ b/core/res/res/layout/text_edit_action_popup_text.xml
@@ -25,4 +25,5 @@
android:textAppearance="?android:attr/textAppearanceSmallInverse"
android:textColor="@android:color/black"
android:textAllCaps="true"
+ android:textStyle="bold"
/>
diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml
index fed5651..b50c063 100755
--- a/core/res/res/values/attrs.xml
+++ b/core/res/res/values/attrs.xml
@@ -158,10 +158,6 @@
<!-- The underline color and thickness for misspelled suggestion -->
<attr name="textAppearanceMisspelledSuggestion" format="reference" />
- <!-- The text color and the background for suggestion range span. This span identifies the
- portion of text the suggestions refer to). -->
- <attr name="textAppearanceSuggestionRange" format="reference" />
-
<!-- The underline color -->
<attr name="textUnderlineColor" format="reference|color" />
<!-- The underline thickness -->
@@ -3154,10 +3150,6 @@
<attr name="textUnderlineColor" />
<attr name="textUnderlineThickness" />
</declare-styleable>
- <declare-styleable name="SuggestionRangeSpan">
- <attr name="textColor" />
- <attr name="colorBackground" />
- </declare-styleable>
<!-- An <code>input-extras</code> is a container for extra data to supply to
an input method. Contains
one more more {@link #Extra <extra>} tags. -->
diff --git a/core/res/res/values/colors.xml b/core/res/res/values/colors.xml
index aee7ea4..fd525f3 100644
--- a/core/res/res/values/colors.xml
+++ b/core/res/res/values/colors.xml
@@ -54,8 +54,6 @@
<color name="dim_foreground_light_inverse">#bebebe</color>
<color name="dim_foreground_light_inverse_disabled">#80bebebe</color>
<color name="hint_foreground_light">#808080</color>
- <color name="highlight_background">#cc475925</color>
- <color name="highlight_background_inverse">#ccd2e461</color>
<color name="highlighted_text_dark">#9983CC39</color>
<color name="highlighted_text_light">#9983CC39</color>
<color name="link_text_dark">#5c5cff</color>
@@ -135,10 +133,8 @@
<color name="dim_foreground_inverse_holo_light">#bebebe</color>
<color name="dim_foreground_inverse_disabled_holo_light">#80bebebe</color>
<color name="hint_foreground_holo_light">#808080</color>
- <color name="highlight_background_holo">#cc475925</color>
- <color name="highlight_background_inverse_holo">#ccd2e461</color>
- <color name="highlighted_text_holo_dark">#9983CC39</color>
- <color name="highlighted_text_holo_light">#9983CC39</color>
+ <color name="highlighted_text_holo_dark">#4c33b5e5</color>
+ <color name="highlighted_text_holo_light">#4c33b5e5</color>
<color name="link_text_holo_dark">#5c5cff</color>
<color name="link_text_holo_light">#0000ee</color>
diff --git a/core/res/res/values/styles.xml b/core/res/res/values/styles.xml
index 1a2ad05..fba1cd1 100644
--- a/core/res/res/values/styles.xml
+++ b/core/res/res/values/styles.xml
@@ -255,11 +255,6 @@
<item name="android:textUnderlineColor">@color/holo_red_light</item>
</style>
- <style name="TextAppearance.SuggestionRange">
- <item name="android:textColor">@color/white</item>
- <item name="android:colorBackground">@color/holo_blue_dark</item>
- </style>
-
<!-- Widget Styles -->
<style name="Widget">
diff --git a/core/res/res/values/themes.xml b/core/res/res/values/themes.xml
index 899c9d5..f434ce8 100644
--- a/core/res/res/values/themes.xml
+++ b/core/res/res/values/themes.xml
@@ -91,7 +91,6 @@
<item name="textAppearanceEasyCorrectSuggestion">@android:style/TextAppearance.EasyCorrectSuggestion</item>
<item name="textAppearanceMisspelledSuggestion">@android:style/TextAppearance.MisspelledSuggestion</item>
- <item name="textAppearanceSuggestionRange">@android:style/TextAppearance.SuggestionRange</item>
<item name="textAppearanceButton">@android:style/TextAppearance.Widget.Button</item>
diff --git a/graphics/java/android/graphics/Paint.java b/graphics/java/android/graphics/Paint.java
index 896f81e..ee65223 100644
--- a/graphics/java/android/graphics/Paint.java
+++ b/graphics/java/android/graphics/Paint.java
@@ -1594,7 +1594,7 @@
}
/**
- * Return the glypth Ids for the characters in the string.
+ * Return the glyph Ids for the characters in the string.
*
* @param text The text to measure
* @param start The index of the first char to to measure
@@ -1613,7 +1613,7 @@
*
* Used only for BiDi / RTL Tests
*/
- public int getTextGlypths(String text, int start, int end, int contextStart, int contextEnd,
+ public int getTextGlyphs(String text, int start, int end, int contextStart, int contextEnd,
int flags, char[] glyphs) {
if (text == null) {
throw new IllegalArgumentException("text cannot be null");
diff --git a/libs/rs/scriptc/rs_cl.rsh b/libs/rs/scriptc/rs_cl.rsh
index 98b0b1d..bbc8fc5 100644
--- a/libs/rs/scriptc/rs_cl.rsh
+++ b/libs/rs/scriptc/rs_cl.rsh
@@ -660,7 +660,6 @@
extern float __attribute__((overloadable)) trunc(float);
FN_FUNC_FN(trunc)
-// Int ops (partial), 6.11.3
#define XN_FUNC_YN(typeout, fnc, typein) \
extern typeout __attribute__((overloadable)) fnc(typein); \
@@ -704,14 +703,29 @@
UIN_FUNC_IN(abs)
IN_FUNC_IN(clz)
+/**
+ * Return the minimum of two values.
+ *
+ * Supports 1,2,3,4 components of uchar, char, ushort, short, uint, int, float.
+ */
IN_FUNC_IN_IN_BODY(min, (v1 < v2 ? v1 : v2))
FN_FUNC_FN_F(min)
+/**
+ * Return the maximum of two values.
+ *
+ * Supports 1,2,3,4 components of uchar, char, ushort, short, uint, int, float.
+ */
IN_FUNC_IN_IN_BODY(max, (v1 > v2 ? v1 : v2))
FN_FUNC_FN_F(max)
-// 6.11.4
-
+/**
+ * Clamp a value to a specified high and low bound.
+ *
+ * @param amount value to be clamped. Supports 1,2,3,4 components
+ * @param low Lower bound, must be scalar or matching vector.
+ * @param high High bound, must match type of low
+ */
_RS_RUNTIME float __attribute__((overloadable)) clamp(float amount, float low, float high);
_RS_RUNTIME float2 __attribute__((overloadable)) clamp(float2 amount, float2 low, float2 high);
_RS_RUNTIME float3 __attribute__((overloadable)) clamp(float3 amount, float3 low, float3 high);
@@ -720,9 +734,19 @@
_RS_RUNTIME float3 __attribute__((overloadable)) clamp(float3 amount, float low, float high);
_RS_RUNTIME float4 __attribute__((overloadable)) clamp(float4 amount, float low, float high);
+/**
+ * Convert from radians to degrees.
+ *
+ * Supports 1,2,3,4 components
+ */
_RS_RUNTIME float __attribute__((overloadable)) degrees(float radians);
FN_FUNC_FN(degrees)
+/**
+ * return start + ((stop - start) * amount);
+ *
+ * Supports 1,2,3,4 components
+ */
_RS_RUNTIME float __attribute__((overloadable)) mix(float start, float stop, float amount);
_RS_RUNTIME float2 __attribute__((overloadable)) mix(float2 start, float2 stop, float2 amount);
_RS_RUNTIME float3 __attribute__((overloadable)) mix(float3 start, float3 stop, float3 amount);
@@ -731,9 +755,22 @@
_RS_RUNTIME float3 __attribute__((overloadable)) mix(float3 start, float3 stop, float amount);
_RS_RUNTIME float4 __attribute__((overloadable)) mix(float4 start, float4 stop, float amount);
+/**
+ * Convert from degrees to radians.
+ *
+ * Supports 1,2,3,4 components
+ */
_RS_RUNTIME float __attribute__((overloadable)) radians(float degrees);
FN_FUNC_FN(radians)
+/**
+ * if (v < edge)
+ * return 0.f;
+ * else
+ * return 1.f;
+ *
+ * Supports 1,2,3,4 components
+ */
_RS_RUNTIME float __attribute__((overloadable)) step(float edge, float v);
_RS_RUNTIME float2 __attribute__((overloadable)) step(float2 edge, float2 v);
_RS_RUNTIME float3 __attribute__((overloadable)) step(float3 edge, float3 v);
@@ -742,6 +779,7 @@
_RS_RUNTIME float3 __attribute__((overloadable)) step(float3 edge, float v);
_RS_RUNTIME float4 __attribute__((overloadable)) step(float4 edge, float v);
+// not implemented
extern float __attribute__((overloadable)) smoothstep(float, float, float);
extern float2 __attribute__((overloadable)) smoothstep(float2, float2, float2);
extern float3 __attribute__((overloadable)) smoothstep(float3, float3, float3);
@@ -750,29 +788,59 @@
extern float3 __attribute__((overloadable)) smoothstep(float, float, float3);
extern float4 __attribute__((overloadable)) smoothstep(float, float, float4);
+/**
+ * if (v < 0) return -1.f;
+ * else if (v > 0) return 1.f;
+ * else return 0.f;
+ *
+ * Supports 1,2,3,4 components
+ */
_RS_RUNTIME float __attribute__((overloadable)) sign(float v);
FN_FUNC_FN(sign)
-// 6.11.5
+/**
+ * Compute the cross product of two vectors.
+ *
+ * Supports 3,4 components
+ */
_RS_RUNTIME float3 __attribute__((overloadable)) cross(float3 lhs, float3 rhs);
-
_RS_RUNTIME float4 __attribute__((overloadable)) cross(float4 lhs, float4 rhs);
+/**
+ * Compute the dot product of two vectors.
+ *
+ * Supports 1,2,3,4 components
+ */
_RS_RUNTIME float __attribute__((overloadable)) dot(float lhs, float rhs);
_RS_RUNTIME float __attribute__((overloadable)) dot(float2 lhs, float2 rhs);
_RS_RUNTIME float __attribute__((overloadable)) dot(float3 lhs, float3 rhs);
_RS_RUNTIME float __attribute__((overloadable)) dot(float4 lhs, float4 rhs);
+/**
+ * Compute the length of a vector.
+ *
+ * Supports 1,2,3,4 components
+ */
_RS_RUNTIME float __attribute__((overloadable)) length(float v);
_RS_RUNTIME float __attribute__((overloadable)) length(float2 v);
_RS_RUNTIME float __attribute__((overloadable)) length(float3 v);
_RS_RUNTIME float __attribute__((overloadable)) length(float4 v);
+/**
+ * Compute the distance between two points.
+ *
+ * Supports 1,2,3,4 components
+ */
_RS_RUNTIME float __attribute__((overloadable)) distance(float lhs, float rhs);
_RS_RUNTIME float __attribute__((overloadable)) distance(float2 lhs, float2 rhs);
_RS_RUNTIME float __attribute__((overloadable)) distance(float3 lhs, float3 rhs);
_RS_RUNTIME float __attribute__((overloadable)) distance(float4 lhs, float4 rhs);
+/**
+ * Normalize a vector.
+ *
+ * Supports 1,2,3,4 components
+ */
_RS_RUNTIME float __attribute__((overloadable)) normalize(float v);
_RS_RUNTIME float2 __attribute__((overloadable)) normalize(float2 v);
_RS_RUNTIME float3 __attribute__((overloadable)) normalize(float3 v);
diff --git a/media/libstagefright/AwesomePlayer.cpp b/media/libstagefright/AwesomePlayer.cpp
index f98b0de..47224cc 100644
--- a/media/libstagefright/AwesomePlayer.cpp
+++ b/media/libstagefright/AwesomePlayer.cpp
@@ -978,7 +978,7 @@
CHECK(!mAudioPlayer->isSeeking());
// We will have finished the seek while starting the audio player.
- postAudioSeekComplete_l();
+ postAudioSeekComplete();
}
} else {
mAudioPlayer->resume();
@@ -1877,7 +1877,8 @@
mQueue.postEventWithDelay(mVideoLagEvent, 1000000ll);
}
-void AwesomePlayer::postCheckAudioStatusEvent_l(int64_t delayUs) {
+void AwesomePlayer::postCheckAudioStatusEvent(int64_t delayUs) {
+ Mutex::Autolock autoLock(mAudioLock);
if (mAudioStatusEventPending) {
return;
}
@@ -1886,14 +1887,18 @@
}
void AwesomePlayer::onCheckAudioStatus() {
- Mutex::Autolock autoLock(mLock);
- if (!mAudioStatusEventPending) {
- // Event was dispatched and while we were blocking on the mutex,
- // has already been cancelled.
- return;
+ {
+ Mutex::Autolock autoLock(mAudioLock);
+ if (!mAudioStatusEventPending) {
+ // Event was dispatched and while we were blocking on the mutex,
+ // has already been cancelled.
+ return;
+ }
+
+ mAudioStatusEventPending = false;
}
- mAudioStatusEventPending = false;
+ Mutex::Autolock autoLock(mLock);
if (mWatchForAudioSeekComplete && !mAudioPlayer->isSeeking()) {
mWatchForAudioSeekComplete = false;
@@ -2239,17 +2244,11 @@
}
void AwesomePlayer::postAudioEOS(int64_t delayUs) {
- Mutex::Autolock autoLock(mLock);
- postCheckAudioStatusEvent_l(delayUs);
+ postCheckAudioStatusEvent(delayUs);
}
void AwesomePlayer::postAudioSeekComplete() {
- Mutex::Autolock autoLock(mLock);
- postAudioSeekComplete_l();
-}
-
-void AwesomePlayer::postAudioSeekComplete_l() {
- postCheckAudioStatusEvent_l(0 /* delayUs */);
+ postCheckAudioStatusEvent(0);
}
status_t AwesomePlayer::setParameter(int key, const Parcel &request) {
diff --git a/media/libstagefright/include/AwesomePlayer.h b/media/libstagefright/include/AwesomePlayer.h
index 24cf77c..8e73121 100644
--- a/media/libstagefright/include/AwesomePlayer.h
+++ b/media/libstagefright/include/AwesomePlayer.h
@@ -148,6 +148,7 @@
mutable Mutex mLock;
Mutex mMiscStateLock;
mutable Mutex mStatsLock;
+ Mutex mAudioLock;
OMXClient mClient;
TimedEventQueue mQueue;
@@ -223,7 +224,7 @@
void postVideoEvent_l(int64_t delayUs = -1);
void postBufferingEvent_l();
void postStreamDoneEvent_l(status_t status);
- void postCheckAudioStatusEvent_l(int64_t delayUs);
+ void postCheckAudioStatusEvent(int64_t delayUs);
void postVideoLagEvent_l();
status_t play_l();
@@ -295,7 +296,6 @@
void ensureCacheIsFetching_l();
status_t startAudioPlayer_l(bool sendErrorNotification = true);
- void postAudioSeekComplete_l();
void shutdownVideoDecoder_l();
status_t setNativeWindow_l(const sp<ANativeWindow> &native);
diff --git a/media/libstagefright/mpeg2ts/ATSParser.cpp b/media/libstagefright/mpeg2ts/ATSParser.cpp
index 017d01c..e13464e 100644
--- a/media/libstagefright/mpeg2ts/ATSParser.cpp
+++ b/media/libstagefright/mpeg2ts/ATSParser.cpp
@@ -89,7 +89,7 @@
unsigned pid() const { return mElementaryPID; }
void setPID(unsigned pid) { mElementaryPID = pid; }
- void parse(
+ status_t parse(
unsigned payload_unit_start_indicator,
ABitReader *br);
@@ -114,8 +114,8 @@
ElementaryStreamQueue *mQueue;
- void flush();
- void parsePES(ABitReader *br);
+ status_t flush();
+ status_t parsePES(ABitReader *br);
void onPayloadData(
unsigned PTS_DTS_flags, uint64_t PTS, uint64_t DTS,
@@ -159,7 +159,7 @@
return false;
}
- mStreams.editValueAt(index)->parse(
+ *err = mStreams.editValueAt(index)->parse(
payload_unit_start_indicator, br);
return true;
@@ -438,10 +438,10 @@
mQueue = NULL;
}
-void ATSParser::Stream::parse(
+status_t ATSParser::Stream::parse(
unsigned payload_unit_start_indicator, ABitReader *br) {
if (mQueue == NULL) {
- return;
+ return OK;
}
if (payload_unit_start_indicator) {
@@ -450,14 +450,18 @@
// of a PES packet that we never saw the start of and assuming
// we have a a complete PES packet.
- flush();
+ status_t err = flush();
+
+ if (err != OK) {
+ return err;
+ }
}
mPayloadStarted = true;
}
if (!mPayloadStarted) {
- return;
+ return OK;
}
size_t payloadSizeBits = br->numBitsLeft();
@@ -478,6 +482,8 @@
memcpy(mBuffer->data() + mBuffer->size(), br->data(), payloadSizeBits / 8);
mBuffer->setRange(0, mBuffer->size() + payloadSizeBits / 8);
+
+ return OK;
}
void ATSParser::Stream::signalDiscontinuity(
@@ -526,7 +532,7 @@
}
}
-void ATSParser::Stream::parsePES(ABitReader *br) {
+status_t ATSParser::Stream::parsePES(ABitReader *br) {
unsigned packet_startcode_prefix = br->getBits(24);
LOGV("packet_startcode_prefix = 0x%08x", packet_startcode_prefix);
@@ -534,7 +540,8 @@
if (packet_startcode_prefix != 1) {
LOGV("Supposedly payload_unit_start=1 unit does not start "
"with startcode.");
- return;
+
+ return ERROR_MALFORMED;
}
CHECK_EQ(packet_startcode_prefix, 0x000001u);
@@ -661,6 +668,14 @@
unsigned dataLength =
PES_packet_length - 3 - PES_header_data_length;
+ if (br->numBitsLeft() < dataLength * 8) {
+ LOGE("PES packet does not carry enough data to contain "
+ "payload. (numBitsLeft = %d, required = %d)",
+ br->numBitsLeft(), dataLength * 8);
+
+ return ERROR_MALFORMED;
+ }
+
CHECK_GE(br->numBitsLeft(), dataLength * 8);
onPayloadData(
@@ -684,19 +699,24 @@
CHECK_NE(PES_packet_length, 0u);
br->skipBits(PES_packet_length * 8);
}
+
+ return OK;
}
-void ATSParser::Stream::flush() {
+status_t ATSParser::Stream::flush() {
if (mBuffer->size() == 0) {
- return;
+ return OK;
}
LOGV("flushing stream 0x%04x size = %d", mElementaryPID, mBuffer->size());
ABitReader br(mBuffer->data(), mBuffer->size());
- parsePES(&br);
+
+ status_t err = parsePES(&br);
mBuffer->setRange(0, 0);
+
+ return err;
}
void ATSParser::Stream::onPayloadData(
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
index e6c0b96..98dca92 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
@@ -70,6 +70,14 @@
return mCurrentView.findViewById(R.id.menu);
}
+ public View getBackButton() {
+ return mCurrentView.findViewById(R.id.back);
+ }
+
+ public View getHomeButton() {
+ return mCurrentView.findViewById(R.id.home);
+ }
+
public NavigationBarView(Context context, AttributeSet attrs) {
super(context, attrs);
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 7868626..4ba514a 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -1091,18 +1091,9 @@
}
}
- if ((diff & StatusBarManager.DISABLE_NAVIGATION) != 0) {
- if ((state & StatusBarManager.DISABLE_NAVIGATION) != 0) {
- Slog.d(TAG, "DISABLE_NAVIGATION: yes");
-
- // close recents if it's visible
- mHandler.removeMessages(MSG_CLOSE_RECENTS_PANEL);
- mHandler.sendEmptyMessage(MSG_CLOSE_RECENTS_PANEL);
- }
-
- if (mNavigationBarView != null) {
- mNavigationBarView.setEnabled((state & StatusBarManager.DISABLE_NAVIGATION) == 0);
- }
+ if ((diff & (StatusBarManager.DISABLE_NAVIGATION | StatusBarManager.DISABLE_BACK)) != 0) {
+ setNavigationVisibility(state &
+ (StatusBarManager.DISABLE_NAVIGATION | StatusBarManager.DISABLE_BACK));
}
if ((diff & StatusBarManager.DISABLE_NOTIFICATION_ICONS) != 0) {
@@ -1127,6 +1118,30 @@
}
}
+ private void setNavigationVisibility(int visibility) {
+ boolean disableNavigation = ((visibility & StatusBarManager.DISABLE_NAVIGATION) != 0);
+ boolean disableBack = ((visibility & StatusBarManager.DISABLE_BACK) != 0);
+
+ Slog.i(TAG, "DISABLE_BACK: " + (disableBack ? "yes" : "no"));
+ Slog.i(TAG, "DISABLE_NAVIGATION: " + (disableNavigation ? "yes" : "no"));
+
+ if (disableNavigation && disableBack) {
+ mNavigationBarView.setEnabled(false);
+ } else {
+ mNavigationBarView.getBackButton().setEnabled(!disableBack);
+ mNavigationBarView.getHomeButton().setEnabled(!disableNavigation);
+ mNavigationBarView.getRecentsButton().setEnabled(!disableNavigation);
+
+ if (disableNavigation) {
+ // close recents if it's visible
+ mHandler.removeMessages(MSG_CLOSE_RECENTS_PANEL);
+ mHandler.sendEmptyMessage(MSG_CLOSE_RECENTS_PANEL);
+ }
+
+ mNavigationBarView.setEnabled(true);
+ }
+ }
+
/**
* All changes to the status bar and notifications funnel through here and are batched.
*/
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 2ab667d..00f611f 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java
@@ -949,29 +949,34 @@
mTicker.halt();
}
}
- if ((diff & StatusBarManager.DISABLE_NAVIGATION) != 0) {
- if ((state & StatusBarManager.DISABLE_NAVIGATION) != 0) {
- Slog.i(TAG, "DISABLE_NAVIGATION: yes");
- mNavigationArea.setVisibility(View.INVISIBLE);
- mInputMethodSwitchButton.setScreenLocked(true);
- } else {
- Slog.i(TAG, "DISABLE_NAVIGATION: no");
- mNavigationArea.setVisibility(View.VISIBLE);
- mInputMethodSwitchButton.setScreenLocked(false);
- }
+ if ((diff & (StatusBarManager.DISABLE_NAVIGATION | StatusBarManager.DISABLE_BACK)) != 0) {
+ setNavigationVisibility(state &
+ (StatusBarManager.DISABLE_NAVIGATION | StatusBarManager.DISABLE_BACK));
}
- if ((diff & StatusBarManager.DISABLE_BACK) != 0) {
- if ((state & StatusBarManager.DISABLE_BACK) != 0) {
- Slog.i(TAG, "DISABLE_BACK: yes");
- mBackButton.setEnabled(false);
- mInputMethodSwitchButton.setScreenLocked(true);
- } else {
- Slog.i(TAG, "DISABLE_BACK: no");
- mBackButton.setEnabled(true);
- mInputMethodSwitchButton.setScreenLocked(false);
- }
+ }
+
+ private void setNavigationVisibility(int visibility) {
+ boolean disableNavigation = ((visibility & StatusBarManager.DISABLE_NAVIGATION) != 0);
+ boolean disableBack = ((visibility & StatusBarManager.DISABLE_BACK) != 0);
+
+ Slog.i(TAG, "DISABLE_BACK: " + (disableBack ? "yes" : "no"));
+ Slog.i(TAG, "DISABLE_NAVIGATION: " + (disableNavigation ? "yes" : "no"));
+
+ if (disableNavigation && disableBack) {
+ mNavigationArea.setVisibility(View.INVISIBLE);
+ } else {
+ int backVisiblity = (disableBack ? View.INVISIBLE : View.VISIBLE);
+ int navVisibility = (disableNavigation ? View.INVISIBLE : View.VISIBLE);
+
+ mBackButton.setVisibility(backVisiblity);
+ mHomeButton.setVisibility(navVisibility);
+ mRecentButton.setVisibility(navVisibility);
+ // don't change menu button visibility here
+
+ mNavigationArea.setVisibility(View.VISIBLE);
}
+ mInputMethodSwitchButton.setScreenLocked(disableNavigation);
}
private boolean hasTicker(Notification n) {
diff --git a/policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java b/policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java
index 162381d..a544167 100644
--- a/policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java
+++ b/policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java
@@ -1185,15 +1185,19 @@
}
int flags = StatusBarManager.DISABLE_NONE;
- if (mShowing && !mHidden) {
- // showing lockscreen exclusively; disable various extra
- // statusbar components.
+ if (mShowing) {
+ // disable navigation status bar components if lock screen is up
flags |= StatusBarManager.DISABLE_NAVIGATION;
- flags |= StatusBarManager.DISABLE_CLOCK;
- }
- if (mShowing && (isSecure() || !ENABLE_INSECURE_STATUS_BAR_EXPAND)) {
- // showing secure lockscreen; disable expanding.
- flags |= StatusBarManager.DISABLE_EXPAND;
+ if (!mHidden) {
+ // showing lockscreen exclusively (no activities in front of it)
+ // disable clock and back button too
+ flags |= StatusBarManager.DISABLE_BACK;
+ flags |= StatusBarManager.DISABLE_CLOCK;
+ }
+ if (isSecure() || !ENABLE_INSECURE_STATUS_BAR_EXPAND) {
+ // showing secure lockscreen; disable expanding.
+ flags |= StatusBarManager.DISABLE_EXPAND;
+ }
}
if (DEBUG) {