Merge "Fix paths rendering issues."
diff --git a/api/current.xml b/api/current.xml
index a97bde6..874c74a 100644
--- a/api/current.xml
+++ b/api/current.xml
@@ -153982,6 +153982,17 @@
visibility="public"
>
</method>
+<method name="getTitleRes"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
<method name="getView"
return="android.view.View"
abstract="false"
@@ -154889,6 +154900,10 @@
</parameter>
<parameter name="args" type="android.os.Bundle">
</parameter>
+<parameter name="titleRes" type="int">
+</parameter>
+<parameter name="shortTitleRes" type="int">
+</parameter>
</method>
<method name="onGetInitialHeader"
return="android.preference.PreferenceActivity.Header"
@@ -155094,6 +155109,29 @@
<parameter name="resultRequestCode" type="int">
</parameter>
</method>
+<method name="startWithFragment"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="fragmentName" type="java.lang.String">
+</parameter>
+<parameter name="args" type="android.os.Bundle">
+</parameter>
+<parameter name="resultTo" type="android.app.Fragment">
+</parameter>
+<parameter name="resultRequestCode" type="int">
+</parameter>
+<parameter name="titleRes" type="int">
+</parameter>
+<parameter name="shortTitleRes" type="int">
+</parameter>
+</method>
<method name="switchToHeader"
return="void"
abstract="false"
@@ -155155,6 +155193,28 @@
visibility="public"
>
</field>
+<field name="EXTRA_SHOW_FRAGMENT_SHORT_TITLE"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value="":android:show_fragment_short_title""
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="EXTRA_SHOW_FRAGMENT_TITLE"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value="":android:show_fragment_title""
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
<field name="HEADER_ID_UNDEFINED"
type="long"
transient="false"
diff --git a/core/java/android/preference/Preference.java b/core/java/android/preference/Preference.java
index 7d37e5b..5e1be21 100644
--- a/core/java/android/preference/Preference.java
+++ b/core/java/android/preference/Preference.java
@@ -89,6 +89,7 @@
private int mOrder = DEFAULT_ORDER;
private CharSequence mTitle;
+ private int mTitleRes;
private CharSequence mSummary;
/**
* mIconResId is overridden by mIcon, if mIcon is specified.
@@ -214,6 +215,7 @@
break;
case com.android.internal.R.styleable.Preference_title:
+ mTitleRes = a.getResourceId(attr, 0);
mTitle = a.getString(attr);
break;
@@ -582,6 +584,7 @@
*/
public void setTitle(CharSequence title) {
if (title == null && mTitle != null || title != null && !title.equals(mTitle)) {
+ mTitleRes = 0;
mTitle = title;
notifyChanged();
}
@@ -595,9 +598,21 @@
*/
public void setTitle(int titleResId) {
setTitle(mContext.getString(titleResId));
+ mTitleRes = titleResId;
}
/**
+ * Returns the title resource ID of this Preference. If the title did
+ * not come from a resource, 0 is returned.
+ *
+ * @return The title resource.
+ * @see #setTitle(int)
+ */
+ public int getTitleRes() {
+ return mTitleRes;
+ }
+
+ /**
* Returns the title of this Preference.
*
* @return The title.
diff --git a/core/java/android/preference/PreferenceActivity.java b/core/java/android/preference/PreferenceActivity.java
index db50bfc..15d5898 100644
--- a/core/java/android/preference/PreferenceActivity.java
+++ b/core/java/android/preference/PreferenceActivity.java
@@ -132,13 +132,28 @@
/**
* When starting this activity and using {@link #EXTRA_SHOW_FRAGMENT},
- * this extra can also be specify to supply a Bundle of arguments to pass
+ * this extra can also be specified to supply a Bundle of arguments to pass
* to that fragment when it is instantiated during the initial creation
* of PreferenceActivity.
*/
public static final String EXTRA_SHOW_FRAGMENT_ARGUMENTS = ":android:show_fragment_args";
/**
+ * When starting this activity and using {@link #EXTRA_SHOW_FRAGMENT},
+ * this extra can also be specify to supply the title to be shown for
+ * that fragment.
+ */
+ public static final String EXTRA_SHOW_FRAGMENT_TITLE = ":android:show_fragment_title";
+
+ /**
+ * When starting this activity and using {@link #EXTRA_SHOW_FRAGMENT},
+ * this extra can also be specify to supply the short title to be shown for
+ * that fragment.
+ */
+ public static final String EXTRA_SHOW_FRAGMENT_SHORT_TITLE
+ = ":android:show_fragment_short_title";
+
+ /**
* When starting this activity, the invoking Intent can contain this extra
* boolean that the header list should not be displayed. This is most often
* used in conjunction with {@link #EXTRA_SHOW_FRAGMENT} to launch
@@ -488,7 +503,12 @@
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(com.android.internal.R.layout.preference_list_content);
+ if (getResources().getConfiguration().isLayoutSizeAtLeast(
+ Configuration.SCREENLAYOUT_SIZE_LARGE)) {
+ setContentView(com.android.internal.R.layout.preference_list_content_large);
+ } else {
+ setContentView(com.android.internal.R.layout.preference_list_content);
+ }
mListFooter = (FrameLayout)findViewById(com.android.internal.R.id.list_footer);
mPrefsContainer = (ViewGroup) findViewById(com.android.internal.R.id.prefs_frame);
@@ -496,6 +516,8 @@
mSinglePane = hidingHeaders || !onIsMultiPane();
String initialFragment = getIntent().getStringExtra(EXTRA_SHOW_FRAGMENT);
Bundle initialArguments = getIntent().getBundleExtra(EXTRA_SHOW_FRAGMENT_ARGUMENTS);
+ int initialTitle = getIntent().getIntExtra(EXTRA_SHOW_FRAGMENT_TITLE, 0);
+ int initialShortTitle = getIntent().getIntExtra(EXTRA_SHOW_FRAGMENT_SHORT_TITLE, 0);
if (savedInstanceState != null) {
// We are restarting from a previous saved state; used that to
@@ -516,6 +538,12 @@
// new fragment mode, but don't need to compute and show
// the headers.
switchToHeader(initialFragment, initialArguments);
+ if (initialTitle != 0) {
+ CharSequence initialTitleStr = getText(initialTitle);
+ CharSequence initialShortTitleStr = initialShortTitle != 0
+ ? getText(initialShortTitle) : null;
+ showBreadCrumbs(initialTitleStr, initialShortTitleStr);
+ }
} else {
// We need to try to build the headers.
@@ -557,7 +585,12 @@
} else {
// If there are no headers, we are in the old "just show a screen
// of preferences" mode.
- setContentView(com.android.internal.R.layout.preference_list_content_single);
+ if (getResources().getConfiguration().isLayoutSizeAtLeast(
+ Configuration.SCREENLAYOUT_SIZE_LARGE)) {
+ setContentView(com.android.internal.R.layout.preference_list_content_single_large);
+ } else {
+ setContentView(com.android.internal.R.layout.preference_list_content_single);
+ }
mListFooter = (FrameLayout) findViewById(com.android.internal.R.id.list_footer);
mPrefsContainer = (ViewGroup) findViewById(com.android.internal.R.id.prefs);
mPreferenceManager = new PreferenceManager(this, FIRST_REQUEST_CODE);
@@ -942,7 +975,8 @@
/**
* Called when the user selects an item in the header list. The default
- * implementation will call either {@link #startWithFragment(String, Bundle, Fragment, int)}
+ * implementation will call either
+ * {@link #startWithFragment(String, Bundle, Fragment, int, int, int)}
* or {@link #switchToHeader(Header)} as appropriate.
*
* @param header The header that was selected.
@@ -951,7 +985,14 @@
public void onHeaderClick(Header header, int position) {
if (header.fragment != null) {
if (mSinglePane) {
- startWithFragment(header.fragment, header.fragmentArguments, null, 0);
+ int titleRes = header.breadCrumbTitleRes;
+ int shortTitleRes = header.breadCrumbShortTitleRes;
+ if (titleRes == 0) {
+ titleRes = header.titleRes;
+ shortTitleRes = 0;
+ }
+ startWithFragment(header.fragment, header.fragmentArguments, null, 0,
+ titleRes, shortTitleRes);
} else {
switchToHeader(header);
}
@@ -961,7 +1002,7 @@
}
/**
- * Called by {@link #startWithFragment(String, Bundle, Fragment, int)} when
+ * Called by {@link #startWithFragment(String, Bundle, Fragment, int, int, int)} when
* in single-pane mode, to build an Intent to launch a new activity showing
* the selected fragment. The default implementation constructs an Intent
* that re-launches the current activity with the appropriate arguments to
@@ -969,19 +1010,33 @@
*
* @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.
* @return Returns an Intent that can be launched to display the given
* fragment.
*/
- public Intent onBuildStartFragmentIntent(String fragmentName, Bundle args) {
+ public Intent onBuildStartFragmentIntent(String fragmentName, Bundle args,
+ int titleRes, int shortTitleRes) {
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setClass(this, getClass());
intent.putExtra(EXTRA_SHOW_FRAGMENT, fragmentName);
intent.putExtra(EXTRA_SHOW_FRAGMENT_ARGUMENTS, args);
+ intent.putExtra(EXTRA_SHOW_FRAGMENT_TITLE, titleRes);
+ intent.putExtra(EXTRA_SHOW_FRAGMENT_SHORT_TITLE, shortTitleRes);
intent.putExtra(EXTRA_NO_HEADERS, true);
return intent;
}
/**
+ * Like {@link #startWithFragment(String, Bundle, Fragment, int, int, int)}
+ * but uses a 0 titleRes.
+ */
+ public void startWithFragment(String fragmentName, Bundle args,
+ Fragment resultTo, int resultRequestCode) {
+ startWithFragment(fragmentName, args, resultTo, resultRequestCode, 0, 0);
+ }
+
+ /**
* Start a new instance of this activity, showing only the given
* preference fragment. When launched in this mode, the header list
* will be hidden and the given preference fragment will be instantiated
@@ -993,10 +1048,14 @@
* the activity launch.
* @param resultRequestCode If resultTo is non-null, this is the request
* 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
+ * this set of preferences.
*/
public void startWithFragment(String fragmentName, Bundle args,
- Fragment resultTo, int resultRequestCode) {
- Intent intent = onBuildStartFragmentIntent(fragmentName, args);
+ Fragment resultTo, int resultRequestCode, int titleRes, int shortTitleRes) {
+ Intent intent = onBuildStartFragmentIntent(fragmentName, args, titleRes, shortTitleRes);
if (resultTo == null) {
startActivity(intent);
} else {
@@ -1013,16 +1072,16 @@
if (mFragmentBreadCrumbs == null) {
View crumbs = findViewById(android.R.id.title);
// For screens with a different kind of title, don't create breadcrumbs.
- if (!(crumbs instanceof FragmentBreadCrumbs)) return;
- mFragmentBreadCrumbs = (FragmentBreadCrumbs) findViewById(android.R.id.title);
+ try {
+ mFragmentBreadCrumbs = (FragmentBreadCrumbs)crumbs;
+ } catch (ClassCastException e) {
+ return;
+ }
if (mFragmentBreadCrumbs == null) {
- mFragmentBreadCrumbs = new FragmentBreadCrumbs(this);
- ActionBar actionBar = getActionBar();
- if (actionBar != null) {
- actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM,
- ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_SHOW_CUSTOM);
- actionBar.setCustomView(mFragmentBreadCrumbs);
+ if (title != null) {
+ setTitle(title);
}
+ return;
}
mFragmentBreadCrumbs.setMaxVisible(2);
mFragmentBreadCrumbs.setActivity(this);
@@ -1190,7 +1249,7 @@
public void startPreferencePanel(String fragmentClass, Bundle args, int titleRes,
CharSequence titleText, Fragment resultTo, int resultRequestCode) {
if (mSinglePane) {
- startWithFragment(fragmentClass, args, resultTo, resultRequestCode);
+ startWithFragment(fragmentClass, args, resultTo, resultRequestCode, titleRes, 0);
} else {
Fragment f = Fragment.instantiate(this, fragmentClass, args);
if (resultTo != null) {
@@ -1236,7 +1295,8 @@
@Override
public boolean onPreferenceStartFragment(PreferenceFragment caller, Preference pref) {
- startPreferencePanel(pref.getFragment(), pref.getExtras(), 0, pref.getTitle(), null, 0);
+ startPreferencePanel(pref.getFragment(), pref.getExtras(), pref.getTitleRes(),
+ pref.getTitle(), null, 0);
return true;
}
diff --git a/core/java/android/preference/PreferenceFragment.java b/core/java/android/preference/PreferenceFragment.java
index 4e22ba0..7511e14 100644
--- a/core/java/android/preference/PreferenceFragment.java
+++ b/core/java/android/preference/PreferenceFragment.java
@@ -20,6 +20,7 @@
import android.app.Fragment;
import android.content.Intent;
import android.content.SharedPreferences;
+import android.content.res.Configuration;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
@@ -151,8 +152,14 @@
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
- return inflater.inflate(com.android.internal.R.layout.preference_list_fragment,
- container, false);
+ if (getResources().getConfiguration().isLayoutSizeAtLeast(
+ Configuration.SCREENLAYOUT_SIZE_LARGE)) {
+ return inflater.inflate(com.android.internal.R.layout.preference_list_fragment_large,
+ container, false);
+ } else {
+ return inflater.inflate(com.android.internal.R.layout.preference_list_fragment,
+ container, false);
+ }
}
@Override
diff --git a/core/java/android/webkit/ZoomManager.java b/core/java/android/webkit/ZoomManager.java
index 72052a6..f2a1ec3 100644
--- a/core/java/android/webkit/ZoomManager.java
+++ b/core/java/android/webkit/ZoomManager.java
@@ -504,7 +504,7 @@
}
public boolean isFixedLengthAnimationInProgress() {
- return mZoomScale != 0;
+ return mZoomScale != 0 || mInHWAcceleratedZoom;
}
public void refreshZoomScale(boolean reflowText) {
diff --git a/core/java/android/widget/DatePicker.java b/core/java/android/widget/DatePicker.java
index 1d442db..7210e21 100644
--- a/core/java/android/widget/DatePicker.java
+++ b/core/java/android/widget/DatePicker.java
@@ -410,73 +410,27 @@
}
/**
- * Reorders the spinners according to the date format in the current
- * {@link Locale}.
+ * Reorders the spinners according to the date format that is
+ * explicitly set by the user and if no such is set fall back
+ * to the current locale's default format.
*/
private void reorderSpinners() {
- java.text.DateFormat format;
- String order;
-
- /*
- * If the user is in a locale where the medium date format is still
- * numeric (Japanese and Czech, for example), respect the date format
- * order setting. Otherwise, use the order that the locale says is
- * appropriate for a spelled-out date.
- */
-
- if (getShortMonths()[0].startsWith("1")) {
- format = DateFormat.getDateFormat(getContext());
- } else {
- format = DateFormat.getMediumDateFormat(getContext());
- }
-
- if (format instanceof SimpleDateFormat) {
- order = ((SimpleDateFormat) format).toPattern();
- } else {
- // Shouldn't happen, but just in case.
- order = new String(DateFormat.getDateFormatOrder(getContext()));
- }
-
- /*
- * Remove the 3 spinners from their parent and then add them back in the
- * required order.
- */
- LinearLayout parent = mSpinners;
- parent.removeAllViews();
-
- boolean quoted = false;
- boolean didDay = false, didMonth = false, didYear = false;
-
- for (int i = 0; i < order.length(); i++) {
- char c = order.charAt(i);
-
- if (c == '\'') {
- quoted = !quoted;
+ mSpinners.removeAllViews();
+ char[] order = DateFormat.getDateFormatOrder(getContext());
+ for (int i = 0; i < order.length; i++) {
+ switch (order[i]) {
+ case DateFormat.DATE:
+ mSpinners.addView(mDaySpinner);
+ break;
+ case DateFormat.MONTH:
+ mSpinners.addView(mMonthSpinner);
+ break;
+ case DateFormat.YEAR:
+ mSpinners.addView(mYearSpinner);
+ break;
+ default:
+ throw new IllegalArgumentException();
}
-
- if (!quoted) {
- if (c == DateFormat.DATE && !didDay) {
- parent.addView(mDaySpinner);
- didDay = true;
- } else if ((c == DateFormat.MONTH || c == 'L') && !didMonth) {
- parent.addView(mMonthSpinner);
- didMonth = true;
- } else if (c == DateFormat.YEAR && !didYear) {
- parent.addView(mYearSpinner);
- didYear = true;
- }
- }
- }
-
- // Shouldn't happen, but just in case.
- if (!didMonth) {
- parent.addView(mMonthSpinner);
- }
- if (!didDay) {
- parent.addView(mDaySpinner);
- }
- if (!didYear) {
- parent.addView(mYearSpinner);
}
}
diff --git a/core/java/com/android/internal/app/LocalePicker.java b/core/java/com/android/internal/app/LocalePicker.java
index e32c62d..52cb679 100644
--- a/core/java/com/android/internal/app/LocalePicker.java
+++ b/core/java/com/android/internal/app/LocalePicker.java
@@ -88,7 +88,7 @@
public static ArrayAdapter<LocaleInfo> constructAdapter(Context context,
int layoutId, int fieldId) {
final Resources resources = context.getResources();
- final String[] locales = context.getAssets().getLocales();
+ final String[] locales = Resources.getSystem().getAssets().getLocales();
final String[] specialLocaleCodes = resources.getStringArray(R.array.special_locale_codes);
final String[] specialLocaleNames = resources.getStringArray(R.array.special_locale_names);
Arrays.sort(locales);
diff --git a/core/res/res/drawable-hdpi/ic_media_video_poster.png b/core/res/res/drawable-hdpi/ic_media_video_poster.png
new file mode 100644
index 0000000..6c1fd6b
--- /dev/null
+++ b/core/res/res/drawable-hdpi/ic_media_video_poster.png
Binary files differ
diff --git a/core/res/res/drawable-ldpi/ic_media_video_poster.png b/core/res/res/drawable-ldpi/ic_media_video_poster.png
new file mode 100644
index 0000000..786d0e6
--- /dev/null
+++ b/core/res/res/drawable-ldpi/ic_media_video_poster.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/ic_media_video_poster.png b/core/res/res/drawable-mdpi/ic_media_video_poster.png
new file mode 100644
index 0000000..10bbd74
--- /dev/null
+++ b/core/res/res/drawable-mdpi/ic_media_video_poster.png
Binary files differ
diff --git a/core/res/res/layout/preference_list_content.xml b/core/res/res/layout/preference_list_content.xml
index 5d034a5..925b715 100644
--- a/core/res/res/layout/preference_list_content.xml
+++ b/core/res/res/layout/preference_list_content.xml
@@ -36,8 +36,6 @@
android:layout_height="match_parent"
android:layout_marginRight="@dimen/preference_screen_side_margin_negative"
android:layout_marginLeft="@dimen/preference_screen_side_margin"
- android:layout_marginTop="32dp"
- android:layout_marginBottom="32dp"
android:layout_weight="10">
<ListView android:id="@android:id/list"
@@ -61,33 +59,9 @@
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_weight="20"
- android:layout_marginLeft="@dimen/preference_screen_side_margin"
- android:layout_marginRight="@dimen/preference_screen_side_margin"
- android:layout_marginTop="16dp"
- android:layout_marginBottom="16dp"
- android:background="?attr/detailsElementBackground"
android:orientation="vertical"
android:visibility="gone" >
- <!-- Breadcrumb inserted here -->
- <android.app.FragmentBreadCrumbs
- android:id="@android:id/title"
- android:layout_height="72dip"
- android:layout_width="match_parent"
- android:paddingTop="16dip"
- android:paddingBottom="8dip"
- android:gravity="center_vertical|left"
- android:layout_marginLeft="48dip"
- android:layout_marginRight="48dip"
- />
-
- <ImageView
- android:layout_width="match_parent"
- android:layout_height="1dip"
- android:paddingLeft="32dip"
- android:paddingRight="32dip"
- android:src="#404040"
- />
<android.preference.PreferenceFrameLayout android:id="@+id/prefs"
android:layout_width="match_parent"
android:layout_height="0dip"
diff --git a/core/res/res/layout/preference_list_content_large.xml b/core/res/res/layout/preference_list_content_large.xml
new file mode 100644
index 0000000..14d188e
--- /dev/null
+++ b/core/res/res/layout/preference_list_content_large.xml
@@ -0,0 +1,140 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/* //device/apps/common/assets/res/layout/list_content.xml
+**
+** Copyright 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.
+*/
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical"
+ android:layout_height="match_parent"
+ android:layout_width="match_parent">
+
+ <LinearLayout
+ android:orientation="horizontal"
+ android:layout_width="match_parent"
+ android:layout_height="0px"
+ android:layout_weight="1">
+
+ <LinearLayout
+ android:id="@+id/headers"
+ android:orientation="vertical"
+ android:layout_width="0px"
+ android:layout_height="match_parent"
+ android:layout_marginRight="@dimen/preference_screen_side_margin_negative"
+ android:layout_marginLeft="@dimen/preference_screen_side_margin"
+ android:layout_marginTop="32dp"
+ android:layout_marginBottom="32dp"
+ android:layout_weight="10">
+
+ <ListView android:id="@android:id/list"
+ android:layout_width="match_parent"
+ android:layout_height="0px"
+ android:layout_weight="1"
+ android:drawSelectorOnTop="false"
+ android:cacheColorHint="@android:color/transparent"
+ android:listPreferredItemHeight="48dp"
+ android:scrollbarAlwaysDrawVerticalTrack="true" />
+
+ <FrameLayout android:id="@+id/list_footer"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="0" />
+
+ </LinearLayout>
+
+ <LinearLayout
+ android:id="@+id/prefs_frame"
+ android:layout_width="0px"
+ android:layout_height="match_parent"
+ android:layout_weight="20"
+ android:layout_marginLeft="@dimen/preference_screen_side_margin"
+ android:layout_marginRight="@dimen/preference_screen_side_margin"
+ android:layout_marginTop="16dp"
+ android:layout_marginBottom="16dp"
+ android:background="?attr/detailsElementBackground"
+ android:orientation="vertical"
+ android:visibility="gone" >
+
+ <!-- Breadcrumb inserted here -->
+ <android.app.FragmentBreadCrumbs
+ android:id="@android:id/title"
+ android:layout_height="72dip"
+ android:layout_width="match_parent"
+ android:paddingTop="16dip"
+ android:paddingBottom="8dip"
+ android:gravity="center_vertical|left"
+ android:layout_marginLeft="48dip"
+ android:layout_marginRight="48dip"
+ />
+
+ <ImageView
+ android:layout_width="match_parent"
+ android:layout_height="1dip"
+ android:paddingLeft="32dip"
+ android:paddingRight="32dip"
+ android:src="#404040"
+ />
+ <android.preference.PreferenceFrameLayout android:id="@+id/prefs"
+ android:layout_width="match_parent"
+ android:layout_height="0dip"
+ android:layout_weight="1"
+ android:layout_marginTop="-1dip"
+ />
+ </LinearLayout>
+ </LinearLayout>
+
+ <RelativeLayout android:id="@+id/button_bar"
+ android:layout_height="wrap_content"
+ android:layout_width="match_parent"
+ android:layout_weight="0"
+ android:background="@android:drawable/bottom_bar"
+ android:visibility="gone">
+
+ <Button android:id="@+id/back_button"
+ android:layout_width="150dip"
+ android:layout_height="wrap_content"
+ android:layout_margin="5dip"
+ android:layout_alignParentLeft="true"
+ android:drawableLeft="@drawable/ic_btn_back"
+ android:drawablePadding="3dip"
+ android:text="@string/back_button_label"
+ />
+ <LinearLayout
+ android:orientation="horizontal"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentRight="true">
+
+ <Button android:id="@+id/skip_button"
+ android:layout_width="150dip"
+ android:layout_height="wrap_content"
+ android:layout_margin="5dip"
+ android:text="@string/skip_button_label"
+ android:visibility="gone"
+ />
+
+ <Button android:id="@+id/next_button"
+ android:layout_width="150dip"
+ android:layout_height="wrap_content"
+ android:layout_margin="5dip"
+ android:drawableRight="@drawable/ic_btn_next"
+ android:drawablePadding="3dip"
+ android:text="@string/next_button_label"
+ />
+ </LinearLayout>
+ </RelativeLayout>
+</LinearLayout>
diff --git a/core/res/res/layout-xlarge/preference_list_content_single.xml b/core/res/res/layout/preference_list_content_single_large.xml
similarity index 100%
rename from core/res/res/layout-xlarge/preference_list_content_single.xml
rename to core/res/res/layout/preference_list_content_single_large.xml
diff --git a/core/res/res/layout/preference_list_fragment.xml b/core/res/res/layout/preference_list_fragment.xml
index 393cecf..4044371 100644
--- a/core/res/res/layout/preference_list_fragment.xml
+++ b/core/res/res/layout/preference_list_fragment.xml
@@ -28,10 +28,6 @@
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight="1"
- android:paddingTop="0dip"
- android:paddingBottom="48dip"
- android:paddingLeft="32dip"
- android:paddingRight="32dip"
android:clipToPadding="false"
android:drawSelectorOnTop="false"
android:cacheColorHint="@android:color/transparent"
diff --git a/core/res/res/layout/preference_list_fragment_large.xml b/core/res/res/layout/preference_list_fragment_large.xml
new file mode 100644
index 0000000..cde84ff
--- /dev/null
+++ b/core/res/res/layout/preference_list_fragment_large.xml
@@ -0,0 +1,80 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+** Copyright 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.
+*/
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical"
+ android:layout_height="match_parent"
+ android:layout_width="match_parent"
+ android:background="@android:color/transparent"
+ android:layout_removeBorders="true">
+
+ <ListView android:id="@android:id/list"
+ android:layout_width="match_parent"
+ android:layout_height="0px"
+ android:layout_weight="1"
+ android:paddingTop="0dip"
+ android:paddingBottom="48dip"
+ android:paddingLeft="32dip"
+ android:paddingRight="32dip"
+ android:clipToPadding="false"
+ android:drawSelectorOnTop="false"
+ android:cacheColorHint="@android:color/transparent"
+ android:scrollbarAlwaysDrawVerticalTrack="true" />
+
+ <RelativeLayout android:id="@+id/button_bar"
+ android:layout_height="wrap_content"
+ android:layout_width="match_parent"
+ android:layout_weight="0"
+ android:background="@android:drawable/bottom_bar"
+ android:visibility="gone">
+
+ <Button android:id="@+id/back_button"
+ android:layout_width="150dip"
+ android:layout_height="wrap_content"
+ android:layout_margin="5dip"
+ android:layout_alignParentLeft="true"
+ android:drawableLeft="@drawable/ic_btn_back"
+ android:drawablePadding="3dip"
+ android:text="@string/back_button_label"
+ />
+ <LinearLayout
+ android:orientation="horizontal"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentRight="true">
+
+ <Button android:id="@+id/skip_button"
+ android:layout_width="150dip"
+ android:layout_height="wrap_content"
+ android:layout_margin="5dip"
+ android:text="@string/skip_button_label"
+ android:visibility="gone"
+ />
+
+ <Button android:id="@+id/next_button"
+ android:layout_width="150dip"
+ android:layout_height="wrap_content"
+ android:layout_margin="5dip"
+ android:drawableRight="@drawable/ic_btn_next"
+ android:drawablePadding="3dip"
+ android:text="@string/next_button_label"
+ />
+ </LinearLayout>
+ </RelativeLayout>
+</LinearLayout>
diff --git a/core/res/res/values-large/dimens.xml b/core/res/res/values-large/dimens.xml
index 5691548..cd1847f 100644
--- a/core/res/res/values-large/dimens.xml
+++ b/core/res/res/values-large/dimens.xml
@@ -19,4 +19,7 @@
<resources>
<item type="dimen" name="dialog_min_width_major">55%</item>
<item type="dimen" name="dialog_min_width_minor">80%</item>
+
+ <!-- Preference UI dimensions for larger screens. -->
+ <dimen name="preference_widget_width">56dp</dimen>
</resources>
diff --git a/core/res/res/values-large/styles.xml b/core/res/res/values-large/styles.xml
new file mode 100644
index 0000000..96a8c84
--- /dev/null
+++ b/core/res/res/values-large/styles.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<resources>
+ <style name="Widget.Holo.PreferenceFrameLayout">
+ <item name="android:borderTop">0dip</item>
+ <item name="android:borderBottom">48dip</item>
+ <item name="android:borderLeft">32dip</item>
+ <item name="android:borderRight">32dip</item>
+ </style>
+</resources>
diff --git a/core/res/res/values/dimens.xml b/core/res/res/values/dimens.xml
index 8a590cd..cca7d8b 100644
--- a/core/res/res/values/dimens.xml
+++ b/core/res/res/values/dimens.xml
@@ -52,12 +52,13 @@
<dimen name="password_keyboard_key_height_numeric">56dip</dimen>
<!-- Default correction for the space key in the password keyboard -->
<dimen name="password_keyboard_spacebar_vertical_correction">4dip</dimen>
+
<!-- Preference activity side margins -->
<dimen name="preference_screen_side_margin">0dp</dimen>
<!-- Preference activity side margins negative-->
<dimen name="preference_screen_side_margin_negative">0dp</dimen>
<!-- Preference widget area width (to the left of the text) -->
- <dimen name="preference_widget_width">56dp</dimen>
+ <dimen name="preference_widget_width">8dp</dimen>
<!-- The platform's desired minimum size for a dialog's width when it
is along the major axis (that is the screen is landscape). This may
diff --git a/core/res/res/values/styles.xml b/core/res/res/values/styles.xml
index 11c3916..08f5410 100644
--- a/core/res/res/values/styles.xml
+++ b/core/res/res/values/styles.xml
@@ -2179,8 +2179,8 @@
<style name="Widget.Holo.PreferenceFrameLayout">
<item name="android:borderTop">0dip</item>
- <item name="android:borderBottom">48dip</item>
- <item name="android:borderLeft">32dip</item>
- <item name="android:borderRight">32dip</item>
+ <item name="android:borderBottom">0dip</item>
+ <item name="android:borderLeft">0dip</item>
+ <item name="android:borderRight">0dip</item>
</style>
</resources>
diff --git a/include/media/mediarecorder.h b/include/media/mediarecorder.h
index a710546..67d940b 100644
--- a/include/media/mediarecorder.h
+++ b/include/media/mediarecorder.h
@@ -104,35 +104,62 @@
};
/*
- * The state machine of the media_recorder uses a set of different state names.
- * The mapping between the media_recorder and the pvauthorengine is shown below:
- *
- * mediarecorder pvauthorengine
- * ----------------------------------------------------------------
- * MEDIA_RECORDER_ERROR ERROR
- * MEDIA_RECORDER_IDLE IDLE
- * MEDIA_RECORDER_INITIALIZED OPENED
- * MEDIA_RECORDER_DATASOURCE_CONFIGURED
- * MEDIA_RECORDER_PREPARED INITIALIZED
- * MEDIA_RECORDER_RECORDING RECORDING
+ * The state machine of the media_recorder.
*/
enum media_recorder_states {
+ // Error state.
MEDIA_RECORDER_ERROR = 0,
+
+ // Recorder was just created.
MEDIA_RECORDER_IDLE = 1 << 0,
+
+ // Recorder has been initialized.
MEDIA_RECORDER_INITIALIZED = 1 << 1,
+
+ // Configuration of the recorder has been completed.
MEDIA_RECORDER_DATASOURCE_CONFIGURED = 1 << 2,
+
+ // Recorder is ready to start.
MEDIA_RECORDER_PREPARED = 1 << 3,
+
+ // Recording is in progress.
MEDIA_RECORDER_RECORDING = 1 << 4,
};
// The "msg" code passed to the listener in notify.
enum media_recorder_event_type {
+ MEDIA_RECORDER_EVENT_LIST_START = 1,
MEDIA_RECORDER_EVENT_ERROR = 1,
- MEDIA_RECORDER_EVENT_INFO = 2
+ MEDIA_RECORDER_EVENT_INFO = 2,
+ MEDIA_RECORDER_EVENT_LIST_END = 99,
+
+ // Track related event types
+ MEDIA_RECORDER_TRACK_EVENT_LIST_START = 100,
+ MEDIA_RECORDER_TRACK_EVENT_ERROR = 100,
+ MEDIA_RECORDER_TRACK_EVENT_INFO = 101,
+ MEDIA_RECORDER_TRACK_EVENT_LIST_END = 1000,
};
+/*
+ * The (part of) "what" code passed to the listener in notify.
+ * When the error or info type is track specific, the what has
+ * the following layout:
+ * the left-most 16-bit is meant for error or info type.
+ * the right-most 4-bit is meant for track id.
+ * the rest is reserved.
+ *
+ * | track id | reserved | error or info type |
+ * 31 28 16 0
+ *
+ */
enum media_recorder_error_type {
- MEDIA_RECORDER_ERROR_UNKNOWN = 1
+ MEDIA_RECORDER_ERROR_UNKNOWN = 1,
+
+ // Track related error type
+ MEDIA_RECORDER_TRACK_ERROR_LIST_START = 100,
+ MEDIA_RECORDER_TRACK_ERROR_GENERAL = 100,
+ MEDIA_RECORDER_ERROR_VIDEO_NO_SYNC_FRAME = 200,
+ MEDIA_RECORDER_TRACK_ERROR_LIST_END = 1000,
};
// The codes are distributed as follow:
@@ -141,11 +168,15 @@
//
enum media_recorder_info_type {
MEDIA_RECORDER_INFO_UNKNOWN = 1,
+
MEDIA_RECORDER_INFO_MAX_DURATION_REACHED = 800,
MEDIA_RECORDER_INFO_MAX_FILESIZE_REACHED = 801,
- MEDIA_RECORDER_INFO_COMPLETION_STATUS = 802,
- MEDIA_RECORDER_INFO_PROGRESS_FRAME_STATUS = 803,
- MEDIA_RECORDER_INFO_PROGRESS_TIME_STATUS = 804,
+
+ // All track related informtional events start here
+ MEDIA_RECORDER_TRACK_INFO_LIST_START = 1000,
+ MEDIA_RECORDER_TRACK_INFO_COMPLETION_STATUS = 1000,
+ MEDIA_RECORDER_TRACK_INFO_PROGRESS_IN_TIME = 1001,
+ MEDIA_RECORDER_TRACK_INFO_LIST_END = 2000,
};
// ----------------------------------------------------------------------------
diff --git a/include/media/stagefright/MPEG4Writer.h b/include/media/stagefright/MPEG4Writer.h
index 5c5229d..15f86ea 100644
--- a/include/media/stagefright/MPEG4Writer.h
+++ b/include/media/stagefright/MPEG4Writer.h
@@ -157,7 +157,7 @@
bool use32BitFileOffset() const;
bool exceedsFileDurationLimit();
bool isFileStreamable() const;
- void trackProgressStatus(const Track* track, int64_t timeUs, status_t err = OK);
+ void trackProgressStatus(size_t trackId, int64_t timeUs, status_t err = OK);
void writeCompositionMatrix(int32_t degrees);
MPEG4Writer(const MPEG4Writer &);
diff --git a/media/libmedia/AudioRecord.cpp b/media/libmedia/AudioRecord.cpp
index a18bedb2..cee1c75 100644
--- a/media/libmedia/AudioRecord.cpp
+++ b/media/libmedia/AudioRecord.cpp
@@ -722,9 +722,12 @@
// Manage overrun callback
if (mActive && (cblk->framesAvailable() == 0)) {
LOGV("Overrun user: %x, server: %x, flags %04x", cblk->user, cblk->server, cblk->flags);
+ AutoMutex _l(cblk->lock);
if ((cblk->flags & CBLK_UNDERRUN_MSK) == CBLK_UNDERRUN_OFF) {
- mCbf(EVENT_OVERRUN, mUserData, 0);
cblk->flags |= CBLK_UNDERRUN_ON;
+ cblk->lock.unlock();
+ mCbf(EVENT_OVERRUN, mUserData, 0);
+ cblk->lock.lock();
}
}
diff --git a/media/libmedia/AudioTrack.cpp b/media/libmedia/AudioTrack.cpp
index 8d8f67b..02e1570 100644
--- a/media/libmedia/AudioTrack.cpp
+++ b/media/libmedia/AudioTrack.cpp
@@ -329,6 +329,7 @@
if (mActive == 0) {
mActive = 1;
mNewPosition = cblk->server + mUpdatePeriod;
+ cblk->lock.lock();
cblk->bufferTimeoutMs = MAX_STARTUP_TIMEOUT_MS;
cblk->waitTimeMs = 0;
cblk->flags &= ~CBLK_DISABLED_ON;
@@ -339,7 +340,6 @@
}
LOGV("start %p before lock cblk %p", this, mCblk);
- cblk->lock.lock();
if (!(cblk->flags & CBLK_INVALID_MSK)) {
cblk->lock.unlock();
status = mAudioTrack->start();
@@ -893,9 +893,14 @@
// restart track if it was disabled by audioflinger due to previous underrun
if (mActive && (cblk->flags & CBLK_DISABLED_MSK)) {
- cblk->flags &= ~CBLK_DISABLED_ON;
- LOGW("obtainBuffer() track %p disabled, restarting", this);
- mAudioTrack->start();
+ AutoMutex _l(cblk->lock);
+ if (mActive && (cblk->flags & CBLK_DISABLED_MSK)) {
+ cblk->flags &= ~CBLK_DISABLED_ON;
+ cblk->lock.unlock();
+ LOGW("obtainBuffer() track %p disabled, restarting", this);
+ mAudioTrack->start();
+ cblk->lock.lock();
+ }
}
cblk->waitTimeMs = 0;
@@ -957,9 +962,10 @@
ssize_t written = 0;
const int8_t *src = (const int8_t *)buffer;
Buffer audioBuffer;
+ size_t frameSz = (size_t)frameSize();
do {
- audioBuffer.frameCount = userSize/frameSize();
+ audioBuffer.frameCount = userSize/frameSz;
// Calling obtainBuffer() with a negative wait count causes
// an (almost) infinite wait time.
@@ -991,7 +997,7 @@
written += toWrite;
releaseBuffer(&audioBuffer);
- } while (userSize);
+ } while (userSize >= frameSz);
return written;
}
@@ -1015,12 +1021,15 @@
// Manage underrun callback
if (mActive && (cblk->framesReady() == 0)) {
LOGV("Underrun user: %x, server: %x, flags %04x", cblk->user, cblk->server, cblk->flags);
+ AutoMutex _l(cblk->lock);
if ((cblk->flags & CBLK_UNDERRUN_MSK) == CBLK_UNDERRUN_OFF) {
+ cblk->flags |= CBLK_UNDERRUN_ON;
+ cblk->lock.unlock();
mCbf(EVENT_UNDERRUN, mUserData, 0);
if (cblk->server == cblk->frameCount) {
mCbf(EVENT_BUFFER_END, mUserData, 0);
}
- cblk->flags |= CBLK_UNDERRUN_ON;
+ cblk->lock.lock();
if (mSharedBuffer != 0) return false;
}
}
@@ -1279,7 +1288,12 @@
this->user = u;
// Clear flow control error condition as new data has been written/read to/from buffer.
- flags &= ~CBLK_UNDERRUN_MSK;
+ if (flags & CBLK_UNDERRUN_MSK) {
+ AutoMutex _l(lock);
+ if (flags & CBLK_UNDERRUN_MSK) {
+ flags &= ~CBLK_UNDERRUN_MSK;
+ }
+ }
return u;
}
diff --git a/media/libstagefright/AMRWriter.cpp b/media/libstagefright/AMRWriter.cpp
index 0db3d1d..69846eb 100644
--- a/media/libstagefright/AMRWriter.cpp
+++ b/media/libstagefright/AMRWriter.cpp
@@ -269,7 +269,7 @@
}
if (stoppedPrematurely) {
- notify(MEDIA_RECORDER_EVENT_INFO, MEDIA_RECORDER_INFO_COMPLETION_STATUS, UNKNOWN_ERROR);
+ notify(MEDIA_RECORDER_EVENT_INFO, MEDIA_RECORDER_TRACK_INFO_COMPLETION_STATUS, UNKNOWN_ERROR);
}
close(mFd);
diff --git a/media/libstagefright/AwesomePlayer.cpp b/media/libstagefright/AwesomePlayer.cpp
index 7a00d7a..35bc0b8 100644
--- a/media/libstagefright/AwesomePlayer.cpp
+++ b/media/libstagefright/AwesomePlayer.cpp
@@ -876,6 +876,17 @@
cropLeft, cropTop, cropRight, cropBottom);
}
+ int32_t displayWidth;
+ if (meta->findInt32(kKeyDisplayWidth, &displayWidth)) {
+ LOGV("Display width changed (%d=>%d)", mDisplayWidth, displayWidth);
+ mDisplayWidth = displayWidth;
+ }
+ int32_t displayHeight;
+ if (meta->findInt32(kKeyDisplayHeight, &displayHeight)) {
+ LOGV("Display height changed (%d=>%d)", mDisplayHeight, displayHeight);
+ mDisplayHeight = displayHeight;
+ }
+
int32_t usableWidth = cropRight - cropLeft + 1;
int32_t usableHeight = cropBottom - cropTop + 1;
if (mDisplayWidth != 0) {
diff --git a/media/libstagefright/MPEG4Writer.cpp b/media/libstagefright/MPEG4Writer.cpp
index 5d6ea7c..edf76b5 100644
--- a/media/libstagefright/MPEG4Writer.cpp
+++ b/media/libstagefright/MPEG4Writer.cpp
@@ -52,7 +52,7 @@
class MPEG4Writer::Track {
public:
- Track(MPEG4Writer *owner, const sp<MediaSource> &source);
+ Track(MPEG4Writer *owner, const sp<MediaSource> &source, size_t trackId);
~Track();
@@ -82,6 +82,7 @@
bool mIsAvc;
bool mIsAudio;
bool mIsMPEG4;
+ int32_t mTrackId;
int64_t mTrackDurationUs;
// For realtime applications, we need to adjust the media clock
@@ -295,7 +296,12 @@
}
status_t MPEG4Writer::addSource(const sp<MediaSource> &source) {
- Track *track = new Track(this, source);
+ Mutex::Autolock l(mLock);
+ if (mStarted) {
+ LOGE("Attempt to add source AFTER recording is started");
+ return UNKNOWN_ERROR;
+ }
+ Track *track = new Track(this, source, mTracks.size());
mTracks.push_back(track);
return OK;
@@ -945,7 +951,7 @@
////////////////////////////////////////////////////////////////////////////////
MPEG4Writer::Track::Track(
- MPEG4Writer *owner, const sp<MediaSource> &source)
+ MPEG4Writer *owner, const sp<MediaSource> &source, size_t trackId)
: mOwner(owner),
mMeta(source->getFormat()),
mSource(source),
@@ -953,6 +959,7 @@
mPaused(false),
mResumed(false),
mStarted(false),
+ mTrackId(trackId),
mTrackDurationUs(0),
mEstimatedTrackSizeBytes(0),
mSamplesHaveSameSize(true),
@@ -2030,7 +2037,7 @@
(OK != checkCodecSpecificData())) { // no codec specific data
err = ERROR_MALFORMED;
}
- mOwner->trackProgressStatus(this, -1, err);
+ mOwner->trackProgressStatus(mTrackId, -1, err);
// Last chunk
if (mOwner->numTracks() == 1) {
@@ -2077,41 +2084,34 @@
if (mTrackEveryTimeDurationUs > 0 &&
timeUs - mPreviousTrackTimeUs >= mTrackEveryTimeDurationUs) {
LOGV("Fire time tracking progress status at %lld us", timeUs);
- mOwner->trackProgressStatus(this, timeUs - mPreviousTrackTimeUs, err);
+ mOwner->trackProgressStatus(mTrackId, timeUs - mPreviousTrackTimeUs, err);
mPreviousTrackTimeUs = timeUs;
}
}
void MPEG4Writer::trackProgressStatus(
- const MPEG4Writer::Track* track, int64_t timeUs, status_t err) {
+ size_t trackId, int64_t timeUs, status_t err) {
Mutex::Autolock lock(mLock);
- int32_t nTracks = mTracks.size();
- CHECK(nTracks >= 1);
- CHECK(nTracks < 64); // Arbitrary number
-
- int32_t trackNum = 0;
- CHECK(trackNum < nTracks);
- trackNum <<= 16;
+ int32_t trackNum = (trackId << 28);
// Error notification
// Do not consider ERROR_END_OF_STREAM an error
if (err != OK && err != ERROR_END_OF_STREAM) {
- notify(MEDIA_RECORDER_EVENT_ERROR,
- trackNum | MEDIA_RECORDER_ERROR_UNKNOWN,
+ notify(MEDIA_RECORDER_TRACK_EVENT_ERROR,
+ trackNum | MEDIA_RECORDER_TRACK_ERROR_GENERAL,
err);
return;
}
if (timeUs == -1) {
// Send completion notification
- notify(MEDIA_RECORDER_EVENT_INFO,
- trackNum | MEDIA_RECORDER_INFO_COMPLETION_STATUS,
+ notify(MEDIA_RECORDER_TRACK_EVENT_INFO,
+ trackNum | MEDIA_RECORDER_TRACK_INFO_COMPLETION_STATUS,
err);
- return;
} else {
// Send progress status
- notify(MEDIA_RECORDER_EVENT_INFO,
- trackNum | MEDIA_RECORDER_INFO_PROGRESS_TIME_STATUS,
+ notify(MEDIA_RECORDER_TRACK_EVENT_INFO,
+ trackNum | MEDIA_RECORDER_TRACK_INFO_PROGRESS_IN_TIME,
timeUs / 1000);
}
}
diff --git a/media/libstagefright/OMXCodec.cpp b/media/libstagefright/OMXCodec.cpp
index 3e26a95..a6a34b3 100644
--- a/media/libstagefright/OMXCodec.cpp
+++ b/media/libstagefright/OMXCodec.cpp
@@ -2215,13 +2215,15 @@
if (data2 == 0 || data2 == OMX_IndexParamPortDefinition) {
onPortSettingsChanged(data1);
- } else if (data1 == kPortIndexOutput
- && data2 == OMX_IndexConfigCommonOutputCrop) {
+ } else if (data1 == kPortIndexOutput &&
+ (data2 == OMX_IndexConfigCommonOutputCrop ||
+ data2 == OMX_IndexConfigCommonScale)) {
sp<MetaData> oldOutputFormat = mOutputFormat;
initOutputFormat(mSource->getFormat());
- if (formatHasNotablyChanged(oldOutputFormat, mOutputFormat)) {
+ if (data2 == OMX_IndexConfigCommonOutputCrop &&
+ formatHasNotablyChanged(oldOutputFormat, mOutputFormat)) {
mOutputPortSettingsHaveChanged = true;
if (mNativeWindow != NULL) {
@@ -2240,6 +2242,39 @@
// already invalid, we'll know soon enough.
native_window_set_crop(mNativeWindow.get(), &crop);
}
+ } else if (data2 == OMX_IndexConfigCommonScale) {
+ OMX_CONFIG_SCALEFACTORTYPE scale;
+ InitOMXParams(&scale);
+ scale.nPortIndex = kPortIndexOutput;
+
+ // Change display dimension only when necessary.
+ if (OK == mOMX->getConfig(
+ mNode,
+ OMX_IndexConfigCommonScale,
+ &scale, sizeof(scale))) {
+ int32_t left, top, right, bottom;
+ CHECK(mOutputFormat->findRect(kKeyCropRect,
+ &left, &top,
+ &right, &bottom));
+
+ // The scale is in 16.16 format.
+ // scale 1.0 = 0x010000. When there is no
+ // need to change the display, skip it.
+ LOGV("Get OMX_IndexConfigScale: 0x%lx/0x%lx",
+ scale.xWidth, scale.xHeight);
+
+ if (scale.xWidth != 0x010000) {
+ mOutputFormat->setInt32(kKeyDisplayWidth,
+ ((right - left + 1) * scale.xWidth) >> 16);
+ mOutputPortSettingsHaveChanged = true;
+ }
+
+ if (scale.xHeight != 0x010000) {
+ mOutputFormat->setInt32(kKeyDisplayHeight,
+ ((bottom - top + 1) * scale.xHeight) >> 16);
+ mOutputPortSettingsHaveChanged = true;
+ }
+ }
}
}
break;
diff --git a/media/libstagefright/codecs/avc/dec/AVCDecoder.cpp b/media/libstagefright/codecs/avc/dec/AVCDecoder.cpp
index 5bbba35..490129f 100644
--- a/media/libstagefright/codecs/avc/dec/AVCDecoder.cpp
+++ b/media/libstagefright/codecs/avc/dec/AVCDecoder.cpp
@@ -534,7 +534,8 @@
default:
{
LOGE("Should not be here, unknown nalType %d", nalType);
- CHECK(!"Should not be here");
+
+ err = ERROR_MALFORMED;
break;
}
}
diff --git a/media/libstagefright/matroska/MatroskaExtractor.cpp b/media/libstagefright/matroska/MatroskaExtractor.cpp
index 733de92..b3e29b9 100644
--- a/media/libstagefright/matroska/MatroskaExtractor.cpp
+++ b/media/libstagefright/matroska/MatroskaExtractor.cpp
@@ -60,7 +60,10 @@
virtual int Length(long long* total, long long* available) {
off64_t size;
if (mSource->getSize(&size) != OK) {
- return -1;
+ *total = -1;
+ *available = (long long)((1ull << 63) - 1);
+
+ return 0;
}
if (total) {
@@ -84,7 +87,7 @@
////////////////////////////////////////////////////////////////////////////////
struct BlockIterator {
- BlockIterator(mkvparser::Segment *segment, unsigned long trackNum);
+ BlockIterator(MatroskaExtractor *extractor, unsigned long trackNum);
bool eos() const;
@@ -96,11 +99,14 @@
int64_t blockTimeUs() const;
private:
- mkvparser::Segment *mSegment;
+ MatroskaExtractor *mExtractor;
unsigned long mTrackNum;
- mkvparser::Cluster *mCluster;
+ const mkvparser::Cluster *mCluster;
const mkvparser::BlockEntry *mBlockEntry;
+ long mBlockEntryIndex;
+
+ void advance_l();
BlockIterator(const BlockIterator &);
BlockIterator &operator=(const BlockIterator &);
@@ -150,7 +156,7 @@
: mExtractor(extractor),
mTrackIndex(index),
mType(OTHER),
- mBlockIter(mExtractor->mSegment,
+ mBlockIter(mExtractor.get(),
mExtractor->mTracks.itemAt(index).mTrackNum),
mNALSizeLen(0) {
sp<MetaData> meta = mExtractor->mTracks.itemAt(index).mMeta;
@@ -199,11 +205,12 @@
////////////////////////////////////////////////////////////////////////////////
BlockIterator::BlockIterator(
- mkvparser::Segment *segment, unsigned long trackNum)
- : mSegment(segment),
+ MatroskaExtractor *extractor, unsigned long trackNum)
+ : mExtractor(extractor),
mTrackNum(trackNum),
mCluster(NULL),
- mBlockEntry(NULL) {
+ mBlockEntry(NULL),
+ mBlockEntryIndex(0) {
reset();
}
@@ -212,45 +219,97 @@
}
void BlockIterator::advance() {
- while (!eos()) {
- if (mBlockEntry != NULL) {
- mBlockEntry = mCluster->GetNext(mBlockEntry);
- } else if (mCluster != NULL) {
- mCluster = mSegment->GetNext(mCluster);
+ Mutex::Autolock autoLock(mExtractor->mLock);
+ advance_l();
+}
- if (eos()) {
+void BlockIterator::advance_l() {
+ for (;;) {
+ long res = mCluster->GetEntry(mBlockEntryIndex, mBlockEntry);
+ LOGV("GetEntry returned %ld", res);
+
+ long long pos;
+ long len;
+ if (res < 0) {
+ // Need to parse this cluster some more
+
+ CHECK_EQ(res, mkvparser::E_BUFFER_NOT_FULL);
+
+ res = mCluster->Parse(pos, len);
+ LOGV("Parse returned %ld", res);
+
+ if (res < 0) {
+ // I/O error
+
+ LOGE("Cluster::Parse returned result %ld", res);
+
+ mCluster = NULL;
break;
}
- mBlockEntry = mCluster->GetFirst();
+ continue;
+ } else if (res == 0) {
+ // We're done with this cluster
+
+ const mkvparser::Cluster *nextCluster;
+ res = mExtractor->mSegment->ParseNext(
+ mCluster, nextCluster, pos, len);
+ LOGV("ParseNext returned %ld", res);
+
+ if (res > 0) {
+ // EOF
+
+ mCluster = NULL;
+ break;
+ }
+
+ CHECK_EQ(res, 0);
+ CHECK(nextCluster != NULL);
+ CHECK(!nextCluster->EOS());
+
+ mCluster = nextCluster;
+
+ res = mCluster->Parse(pos, len);
+ LOGV("Parse (2) returned %ld", res);
+ CHECK_GE(res, 0);
+
+ mBlockEntryIndex = 0;
+ continue;
}
- if (mBlockEntry != NULL
- && mBlockEntry->GetBlock()->GetTrackNumber() == mTrackNum) {
+ CHECK(mBlockEntry != NULL);
+ CHECK(mBlockEntry->GetBlock() != NULL);
+ ++mBlockEntryIndex;
+
+ if (mBlockEntry->GetBlock()->GetTrackNumber() == mTrackNum) {
break;
}
}
}
void BlockIterator::reset() {
- mCluster = mSegment->GetFirst();
- mBlockEntry = mCluster->GetFirst();
+ Mutex::Autolock autoLock(mExtractor->mLock);
- while (!eos() && block()->GetTrackNumber() != mTrackNum) {
- advance();
- }
+ mCluster = mExtractor->mSegment->GetFirst();
+ mBlockEntryIndex = 0;
+
+ do {
+ advance_l();
+ } while (!eos() && block()->GetTrackNumber() != mTrackNum);
}
void BlockIterator::seek(int64_t seekTimeUs) {
- mCluster = mSegment->FindCluster(seekTimeUs * 1000ll);
- mBlockEntry = mCluster != NULL ? mCluster->GetFirst() : NULL;
+ Mutex::Autolock autoLock(mExtractor->mLock);
+
+ mCluster = mExtractor->mSegment->FindCluster(seekTimeUs * 1000ll);
+ mBlockEntryIndex = 0;
while (!eos() && block()->GetTrackNumber() != mTrackNum) {
- advance();
+ advance_l();
}
while (!eos() && !mBlockEntry->GetBlock()->IsKey()) {
- advance();
+ advance_l();
}
}
@@ -291,16 +350,6 @@
}
}
-#define BAIL(err) \
- do { \
- if (bigbuf) { \
- bigbuf->release(); \
- bigbuf = NULL; \
- } \
- \
- return err; \
- } while (0)
-
status_t MatroskaSource::readBlock() {
CHECK(mPendingFrames.empty());
@@ -310,181 +359,39 @@
const mkvparser::Block *block = mBlockIter.block();
- size_t size = block->GetSize();
int64_t timeUs = mBlockIter.blockTimeUs();
- int32_t isSync = block->IsKey();
- MediaBuffer *bigbuf = new MediaBuffer(size);
+ for (int i = 0; i < block->GetFrameCount(); ++i) {
+ const mkvparser::Block::Frame &frame = block->GetFrame(i);
- long res = block->Read(
- mExtractor->mReader, (unsigned char *)bigbuf->data());
+ MediaBuffer *mbuf = new MediaBuffer(frame.len);
+ mbuf->meta_data()->setInt64(kKeyTime, timeUs);
+ mbuf->meta_data()->setInt32(kKeyIsSyncFrame, block->IsKey());
- if (res != 0) {
- bigbuf->release();
- bigbuf = NULL;
+ long n = frame.Read(mExtractor->mReader, (unsigned char *)mbuf->data());
+ if (n != 0) {
+ mPendingFrames.clear();
- return ERROR_END_OF_STREAM;
+ mBlockIter.advance();
+ return ERROR_IO;
+ }
+
+ mPendingFrames.push_back(mbuf);
}
mBlockIter.advance();
- bigbuf->meta_data()->setInt64(kKeyTime, timeUs);
- bigbuf->meta_data()->setInt32(kKeyIsSyncFrame, isSync);
-
- unsigned lacing = (block->Flags() >> 1) & 3;
-
- if (lacing == 0) {
- mPendingFrames.push_back(bigbuf);
- return OK;
- }
-
- LOGV("lacing = %u, size = %d", lacing, size);
-
- const uint8_t *data = (const uint8_t *)bigbuf->data();
- // hexdump(data, size);
-
- if (size == 0) {
- BAIL(ERROR_MALFORMED);
- }
-
- unsigned numFrames = (unsigned)data[0] + 1;
- ++data;
- --size;
-
- Vector<uint64_t> frameSizes;
-
- switch (lacing) {
- case 1: // Xiph
- {
- for (size_t i = 0; i < numFrames - 1; ++i) {
- size_t frameSize = 0;
- uint8_t byte;
- do {
- if (size == 0) {
- BAIL(ERROR_MALFORMED);
- }
- byte = data[0];
- ++data;
- --size;
-
- frameSize += byte;
- } while (byte == 0xff);
-
- frameSizes.push(frameSize);
- }
-
- break;
- }
-
- case 2: // fixed-size
- {
- if ((size % numFrames) != 0) {
- BAIL(ERROR_MALFORMED);
- }
-
- size_t frameSize = size / numFrames;
- for (size_t i = 0; i < numFrames - 1; ++i) {
- frameSizes.push(frameSize);
- }
-
- break;
- }
-
- case 3: // EBML
- {
- uint64_t lastFrameSize = 0;
- for (size_t i = 0; i < numFrames - 1; ++i) {
- uint8_t byte;
-
- if (size == 0) {
- BAIL(ERROR_MALFORMED);
- }
- byte = data[0];
- ++data;
- --size;
-
- size_t numLeadingZeroes = clz(byte);
-
- uint64_t frameSize = byte & ~(0x80 >> numLeadingZeroes);
- for (size_t j = 0; j < numLeadingZeroes; ++j) {
- if (size == 0) {
- BAIL(ERROR_MALFORMED);
- }
-
- frameSize = frameSize << 8;
- frameSize |= data[0];
- ++data;
- --size;
- }
-
- if (i == 0) {
- frameSizes.push(frameSize);
- } else {
- size_t shift =
- 7 - numLeadingZeroes + 8 * numLeadingZeroes;
-
- int64_t delta =
- (int64_t)frameSize - (1ll << (shift - 1)) + 1;
-
- frameSize = lastFrameSize + delta;
-
- frameSizes.push(frameSize);
- }
-
- lastFrameSize = frameSize;
- }
- break;
- }
-
- default:
- TRESPASS();
- }
-
-#if 0
- AString out;
- for (size_t i = 0; i < frameSizes.size(); ++i) {
- if (i > 0) {
- out.append(", ");
- }
- out.append(StringPrintf("%llu", frameSizes.itemAt(i)));
- }
- LOGV("sizes = [%s]", out.c_str());
-#endif
-
- for (size_t i = 0; i < frameSizes.size(); ++i) {
- uint64_t frameSize = frameSizes.itemAt(i);
-
- if (size < frameSize) {
- BAIL(ERROR_MALFORMED);
- }
-
- MediaBuffer *mbuf = new MediaBuffer(frameSize);
- mbuf->meta_data()->setInt64(kKeyTime, timeUs);
- mbuf->meta_data()->setInt32(kKeyIsSyncFrame, isSync);
- memcpy(mbuf->data(), data, frameSize);
- mPendingFrames.push_back(mbuf);
-
- data += frameSize;
- size -= frameSize;
- }
-
- size_t offset = bigbuf->range_length() - size;
- bigbuf->set_range(offset, size);
-
- mPendingFrames.push_back(bigbuf);
-
return OK;
}
-#undef BAIL
-
status_t MatroskaSource::read(
MediaBuffer **out, const ReadOptions *options) {
*out = NULL;
int64_t seekTimeUs;
ReadOptions::SeekMode mode;
- if (options && options->getSeekTo(&seekTimeUs, &mode)) {
+ if (options && options->getSeekTo(&seekTimeUs, &mode)
+ && !mExtractor->isLiveStreaming()) {
clearPendingFrames();
mBlockIter.seek(seekTimeUs);
}
@@ -584,6 +491,13 @@
mReader(new DataSourceReader(mDataSource)),
mSegment(NULL),
mExtractedThumbnails(false) {
+ off64_t size;
+ mIsLiveStreaming =
+ (mDataSource->flags()
+ & (DataSource::kWantsPrefetching
+ | DataSource::kIsCachingDataSource))
+ && mDataSource->getSize(&size) != OK;
+
mkvparser::EBMLHeader ebmlHeader;
long long pos;
if (ebmlHeader.Parse(mReader, pos) < 0) {
@@ -598,7 +512,16 @@
return;
}
- ret = mSegment->Load();
+ if (isLiveStreaming()) {
+ ret = mSegment->ParseHeaders();
+ CHECK_EQ(ret, 0);
+
+ long len;
+ ret = mSegment->LoadCluster(pos, len);
+ CHECK_EQ(ret, 0);
+ } else {
+ ret = mSegment->Load();
+ }
if (ret < 0) {
delete mSegment;
@@ -635,7 +558,8 @@
return NULL;
}
- if ((flags & kIncludeExtensiveMetaData) && !mExtractedThumbnails) {
+ if ((flags & kIncludeExtensiveMetaData) && !mExtractedThumbnails
+ && !isLiveStreaming()) {
findThumbnails();
mExtractedThumbnails = true;
}
@@ -643,6 +567,10 @@
return mTracks.itemAt(index).mMeta;
}
+bool MatroskaExtractor::isLiveStreaming() const {
+ return mIsLiveStreaming;
+}
+
static void addESDSFromAudioSpecificInfo(
const sp<MetaData> &meta, const void *asi, size_t asiSize) {
static const uint8_t kStaticESDS[] = {
@@ -794,7 +722,7 @@
continue;
}
- BlockIterator iter(mSegment, info->mTrackNum);
+ BlockIterator iter(this, info->mTrackNum);
int32_t i = 0;
int64_t thumbnailTimeUs = 0;
size_t maxBlockSize = 0;
@@ -802,7 +730,11 @@
if (iter.block()->IsKey()) {
++i;
- size_t blockSize = iter.block()->GetSize();
+ size_t blockSize = 0;
+ for (int i = 0; i < iter.block()->GetFrameCount(); ++i) {
+ blockSize += iter.block()->GetFrame(i).len;
+ }
+
if (blockSize > maxBlockSize) {
maxBlockSize = blockSize;
thumbnailTimeUs = iter.blockTimeUs();
@@ -821,6 +753,15 @@
return meta;
}
+uint32_t MatroskaExtractor::flags() const {
+ uint32_t x = CAN_PAUSE;
+ if (!isLiveStreaming()) {
+ x |= CAN_SEEK_BACKWARD | CAN_SEEK_FORWARD | CAN_SEEK;
+ }
+
+ return x;
+}
+
bool SniffMatroska(
const sp<DataSource> &source, String8 *mimeType, float *confidence,
sp<AMessage> *) {
diff --git a/media/libstagefright/matroska/MatroskaExtractor.h b/media/libstagefright/matroska/MatroskaExtractor.h
index fa20b84..38ebd61 100644
--- a/media/libstagefright/matroska/MatroskaExtractor.h
+++ b/media/libstagefright/matroska/MatroskaExtractor.h
@@ -20,6 +20,7 @@
#include <media/stagefright/MediaExtractor.h>
#include <utils/Vector.h>
+#include <utils/threads.h>
namespace mkvparser {
struct Segment;
@@ -45,26 +46,34 @@
virtual sp<MetaData> getMetaData();
+ virtual uint32_t flags() const;
+
protected:
virtual ~MatroskaExtractor();
private:
friend struct MatroskaSource;
+ friend struct BlockIterator;
struct TrackInfo {
unsigned long mTrackNum;
sp<MetaData> mMeta;
};
+
+ Mutex mLock;
Vector<TrackInfo> mTracks;
sp<DataSource> mDataSource;
DataSourceReader *mReader;
mkvparser::Segment *mSegment;
bool mExtractedThumbnails;
+ bool mIsLiveStreaming;
void addTracks();
void findThumbnails();
+ bool isLiveStreaming() const;
+
MatroskaExtractor(const MatroskaExtractor &);
MatroskaExtractor &operator=(const MatroskaExtractor &);
};
diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/MediaItemThumbnailTest.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/MediaItemThumbnailTest.java
index 895ca25..154f691 100755
--- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/MediaItemThumbnailTest.java
+++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/MediaItemThumbnailTest.java
@@ -585,7 +585,9 @@
try{
final MediaImageItem mii = new MediaImageItem(mVideoEditor, "m1",
imageItemFileName, 3000, renderingMode);
- }catch (IllegalArgumentException e){
+ } catch (IllegalArgumentException e) {
+ flagForException = true;
+ } catch (IOException e) {
flagForException = true;
}
assertTrue(" Invalid File Path", flagForException);
diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/MediaPropertiesTest.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/MediaPropertiesTest.java
index 3efa5b2..958bbb0 100755
--- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/MediaPropertiesTest.java
+++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/MediaPropertiesTest.java
@@ -513,6 +513,8 @@
MediaItem.RENDERING_MODE_BLACK_BORDER);
} catch (IllegalArgumentException e) {
flagForException = true;
+ } catch (IOException e) {
+ flagForException = true;
}
assertTrue("Media Properties for non exsisting file", flagForException);
}
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindow.java b/policy/src/com/android/internal/policy/impl/PhoneWindow.java
index 64857ed..36e6b8e6 100644
--- a/policy/src/com/android/internal/policy/impl/PhoneWindow.java
+++ b/policy/src/com/android/internal/policy/impl/PhoneWindow.java
@@ -903,7 +903,7 @@
}
private void reopenMenu(boolean toggleMenuMode) {
- if (mActionBar != null) {
+ if (mActionBar != null && mActionBar.isOverflowReserved()) {
final Callback cb = getCallback();
if (!mActionBar.isOverflowMenuShowing() || !toggleMenuMode) {
if (cb != null && !isDestroyed() && mActionBar.getVisibility() == View.VISIBLE) {
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp
index 2b08ab5..2702242 100644
--- a/services/audioflinger/AudioFlinger.cpp
+++ b/services/audioflinger/AudioFlinger.cpp
@@ -1738,7 +1738,10 @@
LOGV("BUFFER TIMEOUT: remove(%d) from active list on thread %p", track->name(), this);
tracksToRemove->add(track);
// indicate to client process that the track was disabled because of underrun
- cblk->flags |= CBLK_DISABLED_ON;
+ {
+ AutoMutex _l(cblk->lock);
+ cblk->flags |= CBLK_DISABLED_ON;
+ }
} else if (mixerStatus != MIXER_TRACKS_READY) {
mixerStatus = MIXER_TRACKS_ENABLED;
}
@@ -1787,10 +1790,9 @@
for (size_t i = 0; i < size; i++) {
sp<Track> t = mTracks[i];
if (t->type() == streamType) {
- t->mCblk->lock.lock();
+ AutoMutex _lcblk(t->mCblk->lock);
t->mCblk->flags |= CBLK_INVALID_ON;
t->mCblk->cv.signal();
- t->mCblk->lock.unlock();
}
}
}
@@ -2948,6 +2950,7 @@
if (mCblk->framesReady() >= mCblk->frameCount ||
(mCblk->flags & CBLK_FORCEREADY_MSK)) {
+ AutoMutex _l(mCblk->lock);
mFillingUpStatus = FS_FILLED;
mCblk->flags &= ~CBLK_FORCEREADY_MSK;
return true;
@@ -3063,19 +3066,18 @@
// STOPPED state
mState = STOPPED;
- mCblk->lock.lock();
// NOTE: reset() will reset cblk->user and cblk->server with
// the risk that at the same time, the AudioMixer is trying to read
// data. In this case, getNextBuffer() would return a NULL pointer
// as audio buffer => the AudioMixer code MUST always test that pointer
// returned by getNextBuffer() is not NULL!
reset();
- mCblk->lock.unlock();
}
}
void AudioFlinger::PlaybackThread::Track::reset()
{
+ AutoMutex _l(mCblk->lock);
// Do not reset twice to avoid discarding data written just after a flush and before
// the audioflinger thread detects the track is stopped.
if (!mResetDone) {
@@ -3209,10 +3211,13 @@
if (thread != 0) {
RecordThread *recordThread = (RecordThread *)thread.get();
recordThread->stop(this);
- TrackBase::reset();
- // Force overerrun condition to avoid false overrun callback until first data is
- // read from buffer
- mCblk->flags |= CBLK_UNDERRUN_ON;
+ {
+ AutoMutex _l(mCblk->lock);
+ TrackBase::reset();
+ // Force overerrun condition to avoid false overrun callback until first data is
+ // read from buffer
+ mCblk->flags |= CBLK_UNDERRUN_ON;
+ }
}
}