diff options
43 files changed, 484 insertions, 171 deletions
diff --git a/api/current.xml b/api/current.xml index 881c71fd7aab..6059946c97c4 100644 --- a/api/current.xml +++ b/api/current.xml @@ -7489,6 +7489,17 @@ visibility="public" > </field> +<field name="supportsUploading" + type="int" + transient="false" + volatile="false" + value="16843414" + static="true" + final="true" + deprecated="not deprecated" + visibility="public" +> +</field> <field name="syncable" type="int" transient="false" @@ -36124,6 +36135,8 @@ </parameter> <parameter name="userVisible" type="boolean"> </parameter> +<parameter name="supportsUploading" type="boolean"> +</parameter> </constructor> <constructor name="SyncAdapterType" type="android.content.SyncAdapterType" @@ -36146,6 +36159,17 @@ visibility="public" > </method> +<method name="isUserVisible" + return="boolean" + abstract="false" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +</method> <method name="newKey" return="android.content.SyncAdapterType" abstract="false" @@ -36161,6 +36185,17 @@ <parameter name="accountType" type="java.lang.String"> </parameter> </method> +<method name="supportsUploading" + return="boolean" + abstract="false" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +</method> <method name="writeToParcel" return="void" abstract="false" @@ -36206,7 +36241,7 @@ visibility="public" > </field> -<field name="userVisible" +<field name="isKey" type="boolean" transient="false" volatile="false" diff --git a/cmds/stagefright/JPEGSource.cpp b/cmds/stagefright/JPEGSource.cpp index 338a3d5b9afa..a7994ed3594f 100644 --- a/cmds/stagefright/JPEGSource.cpp +++ b/cmds/stagefright/JPEGSource.cpp @@ -60,6 +60,7 @@ JPEGSource::JPEGSource(const sp<DataSource> &source) mHeight(0), mOffset(0) { CHECK_EQ(parseJPEG(), OK); + CHECK(mSource->getSize(&mSize) == OK); } JPEGSource::~JPEGSource() { @@ -73,10 +74,6 @@ status_t JPEGSource::start(MetaData *) { return UNKNOWN_ERROR; } - if (mSource->getSize(&mSize) != OK) { - return UNKNOWN_ERROR; - } - mGroup = new MediaBufferGroup; mGroup->add_buffer(new MediaBuffer(mSize)); @@ -105,6 +102,7 @@ sp<MetaData> JPEGSource::getFormat() { meta->setCString(kKeyMIMEType, "image/jpeg"); meta->setInt32(kKeyWidth, mWidth); meta->setInt32(kKeyHeight, mHeight); + meta->setInt32(kKeyCompressedSize, mSize); return meta; } diff --git a/cmds/stagefright/stagefright.cpp b/cmds/stagefright/stagefright.cpp index 185e6ac0213c..6b2d8ad37002 100644 --- a/cmds/stagefright/stagefright.cpp +++ b/cmds/stagefright/stagefright.cpp @@ -23,6 +23,8 @@ #include <binder/IServiceManager.h> #include <binder/ProcessState.h> #include <media/IMediaPlayerService.h> +#include <media/stagefright/CachingDataSource.h> +#include <media/stagefright/HTTPDataSource.h> #include <media/stagefright/MediaDebug.h> #include <media/stagefright/MediaPlayerImpl.h> #include <media/stagefright/MediaExtractor.h> @@ -191,7 +193,13 @@ int main(int argc, char **argv) { for (int k = 0; k < argc; ++k) { const char *filename = argv[k]; - sp<MmapSource> dataSource = new MmapSource(filename); + sp<DataSource> dataSource; + if (!strncasecmp("http://", filename, 7)) { + dataSource = new HTTPDataSource(filename); + dataSource = new CachingDataSource(dataSource, 64 * 1024, 10); + } else { + dataSource = new MmapSource(filename); + } bool isJPEG = false; diff --git a/core/java/android/content/SyncAdapterType.java b/core/java/android/content/SyncAdapterType.java index 93b61ecc9a92..25cbdb195f5e 100644 --- a/core/java/android/content/SyncAdapterType.java +++ b/core/java/android/content/SyncAdapterType.java @@ -27,9 +27,12 @@ import android.os.Parcel; public class SyncAdapterType implements Parcelable { public final String authority; public final String accountType; - public final boolean userVisible; + public final boolean isKey; + private final boolean userVisible; + private final boolean supportsUploading; - public SyncAdapterType(String authority, String accountType, boolean userVisible) { + public SyncAdapterType(String authority, String accountType, boolean userVisible, + boolean supportsUploading) { if (TextUtils.isEmpty(authority)) { throw new IllegalArgumentException("the authority must not be empty: " + authority); } @@ -39,17 +42,49 @@ public class SyncAdapterType implements Parcelable { this.authority = authority; this.accountType = accountType; this.userVisible = userVisible; + this.supportsUploading = supportsUploading; + this.isKey = false; + } + + private SyncAdapterType(String authority, String accountType) { + if (TextUtils.isEmpty(authority)) { + throw new IllegalArgumentException("the authority must not be empty: " + authority); + } + if (TextUtils.isEmpty(accountType)) { + throw new IllegalArgumentException("the accountType must not be empty: " + accountType); + } + this.authority = authority; + this.accountType = accountType; + this.userVisible = true; + this.supportsUploading = true; + this.isKey = true; + } + + public boolean supportsUploading() { + if (isKey) { + throw new IllegalStateException( + "this method is not allowed to be called when this is a key"); + } + return supportsUploading; + } + + public boolean isUserVisible() { + if (isKey) { + throw new IllegalStateException( + "this method is not allowed to be called when this is a key"); + } + return userVisible; } public static SyncAdapterType newKey(String authority, String accountType) { - return new SyncAdapterType(authority, accountType, true); + return new SyncAdapterType(authority, accountType); } public boolean equals(Object o) { if (o == this) return true; if (!(o instanceof SyncAdapterType)) return false; final SyncAdapterType other = (SyncAdapterType)o; - // don't include userVisible in the equality check + // don't include userVisible or supportsUploading in the equality check return authority.equals(other.authority) && accountType.equals(other.accountType); } @@ -57,13 +92,22 @@ public class SyncAdapterType implements Parcelable { int result = 17; result = 31 * result + authority.hashCode(); result = 31 * result + accountType.hashCode(); - // don't include userVisible in the hash + // don't include userVisible or supportsUploading the hash return result; } public String toString() { - return "SyncAdapterType {name=" + authority + ", type=" + accountType - + ", userVisible=" + userVisible + "}"; + if (isKey) { + return "SyncAdapterType Key {name=" + authority + + ", type=" + accountType + + "}"; + } else { + return "SyncAdapterType {name=" + authority + + ", type=" + accountType + + ", userVisible=" + userVisible + + ", supportsUploading=" + supportsUploading + + "}"; + } } public int describeContents() { @@ -71,13 +115,22 @@ public class SyncAdapterType implements Parcelable { } public void writeToParcel(Parcel dest, int flags) { + if (isKey) { + throw new IllegalStateException("keys aren't parcelable"); + } + dest.writeString(authority); dest.writeString(accountType); dest.writeInt(userVisible ? 1 : 0); + dest.writeInt(supportsUploading ? 1 : 0); } public SyncAdapterType(Parcel source) { - this(source.readString(), source.readString(), source.readInt() != 0); + this( + source.readString(), + source.readString(), + source.readInt() != 0, + source.readInt() != 0); } public static final Creator<SyncAdapterType> CREATOR = new Creator<SyncAdapterType>() { diff --git a/core/java/android/content/SyncAdaptersCache.java b/core/java/android/content/SyncAdaptersCache.java index c27fd259ee12..7d9f1de9da92 100644 --- a/core/java/android/content/SyncAdaptersCache.java +++ b/core/java/android/content/SyncAdaptersCache.java @@ -49,7 +49,10 @@ import android.util.AttributeSet; } final boolean userVisible = sa.getBoolean(com.android.internal.R.styleable.SyncAdapter_userVisible, true); - return new SyncAdapterType(authority, accountType, userVisible); + final boolean supportsUploading = + sa.getBoolean(com.android.internal.R.styleable.SyncAdapter_supportsUploading, + true); + return new SyncAdapterType(authority, accountType, userVisible, supportsUploading); } finally { sa.recycle(); } diff --git a/core/java/android/content/SyncManager.java b/core/java/android/content/SyncManager.java index 34efc51f21d5..82cf23f13b0b 100644 --- a/core/java/android/content/SyncManager.java +++ b/core/java/android/content/SyncManager.java @@ -526,13 +526,6 @@ class SyncManager implements OnAccountsUpdatedListener { public void scheduleSync(Account requestedAccount, String requestedAuthority, Bundle extras, long delay, boolean onlyThoseWithUnkownSyncableState) { boolean isLoggable = Log.isLoggable(TAG, Log.VERBOSE); - if (isLoggable) { - Log.v(TAG, "scheduleSync:" - + " delay " + delay - + ", account " + requestedAccount - + ", authority " + requestedAuthority - + ", extras " + ((extras == null) ? "(null)" : extras)); - } if (!isSyncEnabled()) { if (isLoggable) { @@ -617,13 +610,27 @@ class SyncManager implements OnAccountsUpdatedListener { if (onlyThoseWithUnkownSyncableState && isSyncable >= 0) { continue; } - if (mSyncAdapters.getServiceInfo(SyncAdapterType.newKey(authority, account.type)) - != null) { + final RegisteredServicesCache.ServiceInfo<SyncAdapterType> syncAdapterInfo = + mSyncAdapters.getServiceInfo( + SyncAdapterType.newKey(authority, account.type)); + if (syncAdapterInfo != null) { + if (!syncAdapterInfo.type.supportsUploading() && uploadOnly) { + continue; + } // make this an initialization sync if the isSyncable state is unknown - Bundle extrasCopy = new Bundle(extras); + Bundle extrasCopy = extras; if (isSyncable < 0) { + extrasCopy = new Bundle(extras); extrasCopy.putBoolean(ContentResolver.SYNC_EXTRAS_INITIALIZE, true); } + if (isLoggable) { + Log.v(TAG, "scheduleSync:" + + " delay " + delay + + ", source " + source + + ", account " + account + + ", authority " + authority + + ", extras " + extrasCopy); + } scheduleSyncOperation( new SyncOperation(account, source, authority, extrasCopy, delay)); } diff --git a/core/java/android/preference/CheckBoxPreference.java b/core/java/android/preference/CheckBoxPreference.java index cf5664c3814e..f16a7e479cb1 100644 --- a/core/java/android/preference/CheckBoxPreference.java +++ b/core/java/android/preference/CheckBoxPreference.java @@ -149,14 +149,12 @@ public class CheckBoxPreference extends Preference { * @param checked The checked state. */ public void setChecked(boolean checked) { - - mChecked = checked; - - persistBoolean(checked); - - notifyDependencyChange(shouldDisableDependents()); - - notifyChanged(); + if (mChecked != checked) { + mChecked = checked; + persistBoolean(checked); + notifyDependencyChange(shouldDisableDependents()); + notifyChanged(); + } } /** diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index 18610959a5df..84e07f08aa8b 100644 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -3390,6 +3390,13 @@ public final class Settings { "google_calendar_sync_window_days"; /** + * How often to update the calendar sync window. + * The window will be advanced every n days. + */ + public static final String GOOGLE_CALENDAR_SYNC_WINDOW_UPDATE_DAYS = + "google_calendar_sync_window_update_days"; + + /** * @deprecated * @hide */ diff --git a/core/java/android/widget/AbsSeekBar.java b/core/java/android/widget/AbsSeekBar.java index f92eb997d3a4..2a0e5e5161f5 100644 --- a/core/java/android/widget/AbsSeekBar.java +++ b/core/java/android/widget/AbsSeekBar.java @@ -64,10 +64,10 @@ public abstract class AbsSeekBar extends ProgressBar { TypedArray a = context.obtainStyledAttributes(attrs, com.android.internal.R.styleable.SeekBar, defStyle, 0); Drawable thumb = a.getDrawable(com.android.internal.R.styleable.SeekBar_thumb); - setThumb(thumb); + setThumb(thumb); // will guess mThumbOffset if thumb != null... + // ...but allow layout to override this int thumbOffset = - a.getDimensionPixelOffset(com.android.internal.R.styleable.SeekBar_thumbOffset, 0); - setThumbOffset(thumbOffset); + a.getDimensionPixelOffset(com.android.internal.R.styleable.SeekBar_thumbOffset, getThumbOffset()); a.recycle(); a = context.obtainStyledAttributes(attrs, @@ -77,13 +77,21 @@ public abstract class AbsSeekBar extends ProgressBar { } /** - * Sets the thumb that will be drawn at the end of the progress meter within the SeekBar + * Sets the thumb that will be drawn at the end of the progress meter within the SeekBar. + * <p> + * If the thumb is a valid drawable (i.e. not null), half its width will be + * used as the new thumb offset (@see #setThumbOffset(int)). * * @param thumb Drawable representing the thumb */ public void setThumb(Drawable thumb) { if (thumb != null) { thumb.setCallback(this); + + // Assuming the thumb drawable is symmetric, set the thumb offset + // such that the thumb will hang halfway off either edge of the + // progress bar. + mThumbOffset = (int)thumb.getIntrinsicWidth() / 2; } mThumb = thumb; invalidate(); diff --git a/core/java/android/widget/FastScroller.java b/core/java/android/widget/FastScroller.java index 2da777a47920..67c0def552e8 100644 --- a/core/java/android/widget/FastScroller.java +++ b/core/java/android/widget/FastScroller.java @@ -55,7 +55,7 @@ class FastScroller { private int mThumbY; private RectF mOverlayPos; - private int mOverlaySize = 104; + private int mOverlaySize; private AbsListView mList; private boolean mScrollCompleted; @@ -119,10 +119,10 @@ class FastScroller { private void useThumbDrawable(Context context, Drawable drawable) { mThumbDrawable = drawable; - mThumbW = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, - 64, context.getResources().getDisplayMetrics()); - mThumbH = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, - 52, context.getResources().getDisplayMetrics()); + mThumbW = context.getResources().getDimensionPixelSize( + com.android.internal.R.dimen.fastscroll_thumb_width); + mThumbH = context.getResources().getDimensionPixelSize( + com.android.internal.R.dimen.fastscroll_thumb_height); mChangedBounds = true; } @@ -138,7 +138,9 @@ class FastScroller { mScrollCompleted = true; getSectionsFromIndexer(); - + + mOverlaySize = context.getResources().getDimensionPixelSize( + com.android.internal.R.dimen.fastscroll_overlay_size); mOverlayPos = new RectF(); mScrollFade = new ScrollFade(); mPaint = new Paint(); diff --git a/core/java/android/widget/MediaController.java b/core/java/android/widget/MediaController.java index 9910c3715df9..446a992595ca 100644 --- a/core/java/android/widget/MediaController.java +++ b/core/java/android/widget/MediaController.java @@ -282,6 +282,9 @@ public class MediaController extends FrameLayout { if (!mShowing && mAnchor != null) { setProgress(); + if (mPauseButton != null) { + mPauseButton.requestFocus(); + } disableUnsupportedButtons(); int [] anchorpos = new int[2]; @@ -416,6 +419,9 @@ public class MediaController extends FrameLayout { keyCode == KeyEvent.KEYCODE_SPACE)) { doPauseResume(); show(sDefaultTimeout); + if (mPauseButton != null) { + mPauseButton.requestFocus(); + } return true; } else if (keyCode == KeyEvent.KEYCODE_MEDIA_STOP) { if (mPlayer.isPlaying()) { diff --git a/core/java/android/widget/VideoView.java b/core/java/android/widget/VideoView.java index e60ff25703f9..549f98420dc8 100644 --- a/core/java/android/widget/VideoView.java +++ b/core/java/android/widget/VideoView.java @@ -267,12 +267,17 @@ public class VideoView extends SurfaceView implements MediaPlayerControl { // Get the capabilities of the player for this stream Metadata data = mp.getMetadata(MediaPlayer.METADATA_ALL, MediaPlayer.BYPASS_METADATA_FILTER); - mCanPause = !data.has(Metadata.PAUSE_AVAILABLE) - || data.getBoolean(Metadata.PAUSE_AVAILABLE); - mCanSeekBack = !data.has(Metadata.SEEK_BACKWARD_AVAILABLE) - || data.getBoolean(Metadata.SEEK_BACKWARD_AVAILABLE); - mCanSeekForward = !data.has(Metadata.SEEK_FORWARD_AVAILABLE) - || data.getBoolean(Metadata.SEEK_FORWARD_AVAILABLE); + + if (data != null) { + mCanPause = !data.has(Metadata.PAUSE_AVAILABLE) + || data.getBoolean(Metadata.PAUSE_AVAILABLE); + mCanSeekBack = !data.has(Metadata.SEEK_BACKWARD_AVAILABLE) + || data.getBoolean(Metadata.SEEK_BACKWARD_AVAILABLE); + mCanSeekForward = !data.has(Metadata.SEEK_FORWARD_AVAILABLE) + || data.getBoolean(Metadata.SEEK_FORWARD_AVAILABLE); + } else { + mCanPause = mCanSeekForward = mCanSeekForward = true; + } if (mOnPreparedListener != null) { mOnPreparedListener.onPrepared(mMediaPlayer); diff --git a/core/java/com/android/internal/widget/ContactHeaderWidget.java b/core/java/com/android/internal/widget/ContactHeaderWidget.java index 30349b3a35f2..70f277950417 100644 --- a/core/java/com/android/internal/widget/ContactHeaderWidget.java +++ b/core/java/com/android/internal/widget/ContactHeaderWidget.java @@ -116,7 +116,7 @@ public class ContactHeaderWidget extends FrameLayout implements View.OnClickList //Projection used for looking up contact id from phone number protected static final String[] PHONE_LOOKUP_PROJECTION = new String[] { - RawContacts.CONTACT_ID, + PhoneLookup._ID, }; protected static final int PHONE_LOOKUP_CONTACT_ID_COLUMN_INDEX = 0; diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml index e03211d00de0..729b1db5c499 100644 --- a/core/res/res/values/attrs.xml +++ b/core/res/res/values/attrs.xml @@ -3410,6 +3410,7 @@ <attr name="contentAuthority" format="string"/> <attr name="accountType"/> <attr name="userVisible" format="boolean"/> + <attr name="supportsUploading" format="boolean"/> </declare-styleable> <!-- =============================== --> diff --git a/core/res/res/values/dimens.xml b/core/res/res/values/dimens.xml index 6461460a3eac..6a3538d24e78 100644 --- a/core/res/res/values/dimens.xml +++ b/core/res/res/values/dimens.xml @@ -28,4 +28,10 @@ <dimen name="toast_y_offset">64dip</dimen> <!-- Height of the status bar --> <dimen name="status_bar_height">25dip</dimen> + <!-- Size of the fastscroll hint letter --> + <dimen name="fastscroll_overlay_size">104dp</dimen> + <!-- Width of the fastscroll thumb --> + <dimen name="fastscroll_thumb_width">64dp</dimen> + <!-- Height of the fastscroll thumb --> + <dimen name="fastscroll_thumb_height">52dp</dimen> </resources> diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml index bbeb78da0fcc..4bc376b946fa 100644 --- a/core/res/res/values/public.xml +++ b/core/res/res/values/public.xml @@ -1159,4 +1159,5 @@ <public type="style" name="Theme.Wallpaper.NoTitleBar" /> <public type="style" name="Theme.Wallpaper.NoTitleBar.Fullscreen" /> + <public type="attr" name="supportsUploading" /> </resources> diff --git a/docs/html/guide/guide_toc.cs b/docs/html/guide/guide_toc.cs index 11f8c7bd72d9..0b3373952feb 100644 --- a/docs/html/guide/guide_toc.cs +++ b/docs/html/guide/guide_toc.cs @@ -139,6 +139,7 @@ <li><a href="<?cs var:toroot ?>guide/topics/manifest/intent-filter-element.html"><intent-filter></a></li> <li><a href="<?cs var:toroot ?>guide/topics/manifest/manifest-element.html"><manifest></a></li> <li><a href="<?cs var:toroot ?>guide/topics/manifest/meta-data-element.html"><meta-data></a></li> + <li><a href="<?cs var:toroot ?>guide/topics/manifest/path-permission-element.html"><path-permission></a></li> <li><a href="<?cs var:toroot ?>guide/topics/manifest/permission-element.html"><permission></a></li> <li><a href="<?cs var:toroot ?>guide/topics/manifest/permission-group-element.html"><permission-group></a></li> <li><a href="<?cs var:toroot ?>guide/topics/manifest/permission-tree-element.html"><permission-tree></a></li> diff --git a/docs/html/guide/topics/manifest/manifest-intro.jd b/docs/html/guide/topics/manifest/manifest-intro.jd index 9e1b18ddfa33..89171c1d42f1 100644 --- a/docs/html/guide/topics/manifest/manifest-intro.jd +++ b/docs/html/guide/topics/manifest/manifest-intro.jd @@ -112,6 +112,7 @@ other mention of the element name. <a href="{@docRoot}guide/topics/manifest/provider-element.html"><provider></a> <a href="{@docRoot}guide/topics/manifest/grant-uri-permission-element.html"><grant-uri-permission /></a> + <a href="{@docRoot}guide/topics/manifest/path-permission-element.html"><path-permission /></a> <a href="{@docRoot}guide/topics/manifest/meta-data-element.html"><meta-data /></a> <a href="{@docRoot}guide/topics/manifest/provider-element.html"></provider></a> @@ -140,6 +141,7 @@ add your own elements or attributes. <br/><code><a href="{@docRoot}guide/topics/manifest/intent-filter-element.html"><intent-filter></a></code> <br/><code><a href="{@docRoot}guide/topics/manifest/manifest-element.html"><manifest></a></code> <br/><code><a href="{@docRoot}guide/topics/manifest/meta-data-element.html"><meta-data></a></code> +<br/><code><a href="{@docRoot}guide/topics/manifest/path-permission-element.html"><path-permission /></a></code> <br/><code><a href="{@docRoot}guide/topics/manifest/permission-element.html"><permission></a></code> <br/><code><a href="{@docRoot}guide/topics/manifest/permission-group-element.html"><permission-group></a></code> <br/><code><a href="{@docRoot}guide/topics/manifest/permission-tree-element.html"><permission-tree></a></code> diff --git a/docs/html/guide/topics/manifest/path-permission-element.jd b/docs/html/guide/topics/manifest/path-permission-element.jd new file mode 100644 index 000000000000..5c271a73b86f --- /dev/null +++ b/docs/html/guide/topics/manifest/path-permission-element.jd @@ -0,0 +1,104 @@ +page.title=<path-permission> +@jd:body + +<dl class="xml"> +<dt>syntax:</dt> +<dd><pre class="stx"> +<path-permission android:<a href="#path">path</a>="<i>string</i>" + android:<a href="#pathPrefix">pathPrefix</a>="<i>string</i>" + android:<a href="#pathPattern">pathPattern</a>="<i>string</i>" + android:<a href="#permission">permission</a>="<i>string</i>" + android:<a href="#readPermission">readPermission</a>="<i>string</i>" + android:<a href="#writePermission">writePermission</a>="<i>string</i>" /> +</pre></dd> + +<dt>contained in:</dt> +<dd><code><a href="{@docRoot}guide/topics/manifest/provider-element.html"><provider></a></code></dd> + +<!-- +<dt>can contain:</dt> +</dd> +--> + +<dt>description:</dt> +<dd>Defines the path and required permissions for a specific subset of data +within a content provider. This element can be +specified multiple times to supply multiple paths. + +</dd> + +<dt>attributes:</dt> + +<dd><dl class="attr"> +<dt><a name="path"></a>{@code android:path}</dt> +<dd>A complete URI path for a subset of content provider data. +Permission can be granted only to the particular data identified by this path. +When used to provide search suggestion content, it must be appended +with "/search_suggest_query". +</dd> + +<dt><a name="pathPrefix"></a>{@code android:pathPrefix}</dt> +<dd>The initial part of a URI path for a subset of content provider data. +Permission can be granted to all data subsets with paths that share this initial part. +</dd> + +<dt><a name="pathPattern"></a>{@code android:pathPattern}</dt> +<dd>A complete URI path for a subset of content provider data, +but one that can use the following wildcards: + +<ul> +<li>An asterisk ('<code class="Code prettyprint">*</code>'). This matches a sequence of 0 to many occurrences of +the immediately preceding character.</li> + +<li>A period followed by an asterisk ("<code class="Code prettyprint">.*</code>"). This matches any sequence of +0 or more characters.</li> +</ul> + +<p> +Because '<code class="Code prettyprint">\</code>' is used as an escape character when the string is read +from XML (before it is parsed as a pattern), you will need to double-escape. +For example, a literal '<code class="Code prettyprint">*</code>' would be written as "<code class="Code prettyprint">\\*</code>" and a +literal '<code class="Code prettyprint">\</code>' would be written as "<code class="Code prettyprint">\\</code>". This is basically +the same as what you would need to write if constructing the string in Java code. +</p> +<p> +For more information on these types of patterns, see the descriptions of +<a href="/reference/android/os/PatternMatcher.html#PATTERN_LITERAL">PATTERN_LITERAL</a>, +<a href="/reference/android/os/PatternMatcher.html#PATTERN_PREFIX">PATTERN_PREFIX</a>, and +<a href="/reference/android/os/PatternMatcher.html#PATTERN_SIMPLE_GLOB">PATTERN_SIMPLE_GLOB</a> in the +<a href="/reference/android/os/PatternMatcher.html">PatternMatcher</a> class. +</p> +</dd> + +<dt><a name="permission"></a>{@code android:permission}</dt> +<dd>The name of a permission that clients must have in order to read or write the +content provider's data. This attribute is a convenient way of setting a +single permission for both reading and writing. However, the +<code>readPermission</code> and +<code>writePermission</code> attributes take precedence +over this one. +</dd> + +<dt><a name="readPermission"></a>{@code android:readPermission}</dt> +<dd>A permission that clients must have in order to query the content provider. +</dd> + +<dt><a name="writePermission"></a>{@code android:writePermission}</dt> +<dd>A permission that clients must have in order to make changes to the data controlled by the content provider. +</dd> + + + +</dl></dd> + +<!-- ##api level indication## --> +<dt>introduced in:</dt> +<dd>API Level 4</dd> + +<dt>see also:</dt> +<dd>{@link android.app.SearchManager}</dd> +<dd>{@link android.Manifest.permission}</dd> +<dd><a href="/guide/topics/security/security.html">Security and +Permissions</a></dd> + +</dl> diff --git a/docs/html/guide/topics/manifest/provider-element.jd b/docs/html/guide/topics/manifest/provider-element.jd index 2bb4ff40f03b..3942f95084be 100644 --- a/docs/html/guide/topics/manifest/provider-element.jd +++ b/docs/html/guide/topics/manifest/provider-element.jd @@ -25,7 +25,9 @@ page.title=<provider> <dt>can contain:</dt> <dd><code><a href="{@docRoot}guide/topics/manifest/meta-data-element.html"><meta-data></a></code> -<br/><code><a href="{@docRoot}guide/topics/manifest/grant-uri-permission-element.html"><grant-uri-permission></a></code></dd> +<br/><code><a href="{@docRoot}guide/topics/manifest/grant-uri-permission-element.html"><grant-uri-permission></a></code> +<br/><code><a href="{@docRoot}guide/topics/manifest/path-permission-element.html"><path-permission /></a></code> +</dd> <dt>description:</dt> <dd>Declares a content provider — a subclass of diff --git a/graphics/java/android/renderscript/Element.java b/graphics/java/android/renderscript/Element.java index 3f750690bd93..aeec739dd644 100644 --- a/graphics/java/android/renderscript/Element.java +++ b/graphics/java/android/renderscript/Element.java @@ -111,7 +111,8 @@ public class Element extends BaseObj { NX (15), NY (16), NZ (17), - INDEX (18); + INDEX (18), + POINT_SIZE(19); int mID; DataKind(int id) { @@ -241,13 +242,18 @@ public class Element extends BaseObj { add(DataType.FLOAT, DataKind.Z, false, 32, null); return this; } - + public Builder addFloatST() { add(DataType.FLOAT, DataKind.S, false, 32, null); add(DataType.FLOAT, DataKind.T, false, 32, null); return this; } + public Builder addFloatPointSize() { + add(DataType.FLOAT, DataKind.POINT_SIZE, false, 32, null); + return this; + } + public Builder addFloatRGB() { add(DataType.FLOAT, DataKind.RED, false, 32, null); add(DataType.FLOAT, DataKind.GREEN, false, 32, null); diff --git a/graphics/java/android/renderscript/ProgramFragment.java b/graphics/java/android/renderscript/ProgramFragment.java index aad09f6df9d0..392d93d22278 100644 --- a/graphics/java/android/renderscript/ProgramFragment.java +++ b/graphics/java/android/renderscript/ProgramFragment.java @@ -68,6 +68,7 @@ public class ProgramFragment extends BaseObj { RenderScript mRS; Element mIn; Element mOut; + boolean mPointSpriteEnable; private class Slot { Type mType; @@ -85,6 +86,7 @@ public class ProgramFragment extends BaseObj { mIn = in; mOut = out; mSlots = new Slot[MAX_SLOT]; + mPointSpriteEnable = false; for(int ct=0; ct < MAX_SLOT; ct++) { mSlots[ct] = new Slot(); } @@ -117,6 +119,9 @@ public class ProgramFragment extends BaseObj { mSlots[slot].mEnv = env; } + public void setPointSpriteTexCoordinateReplacement(boolean enable) { + mPointSpriteEnable = enable; + } static synchronized ProgramFragment internalCreate(RenderScript rs, Builder b) { int inID = 0; @@ -127,21 +132,18 @@ public class ProgramFragment extends BaseObj { if (b.mOut != null) { outID = b.mOut.mID; } - rs.nProgramFragmentBegin(inID, outID); + rs.nProgramFragmentBegin(inID, outID, b.mPointSpriteEnable); for(int ct=0; ct < MAX_SLOT; ct++) { if(b.mSlots[ct].mTexEnable) { Slot s = b.mSlots[ct]; + int typeID = 0; if(s.mType != null) { - rs.nProgramFragmentSetType(ct, s.mType.mID); - } - rs.nProgramFragmentSetTexEnable(ct, true); - if(s.mEnv != null) { - rs.nProgramFragmentSetEnvMode(ct, s.mEnv.mID); + typeID = s.mType.mID; } + rs.nProgramFragmentSetSlot(ct, true, s.mEnv.mID, typeID); } } - int id = rs.nProgramFragmentCreate(); return new ProgramFragment(id, rs); } diff --git a/graphics/java/android/renderscript/RenderScript.java b/graphics/java/android/renderscript/RenderScript.java index fca1c7ad78d0..076a5d43f5c4 100644 --- a/graphics/java/android/renderscript/RenderScript.java +++ b/graphics/java/android/renderscript/RenderScript.java @@ -158,12 +158,10 @@ public class RenderScript { native void nProgramFragmentStoreDither(boolean enable); native int nProgramFragmentStoreCreate(); - native void nProgramFragmentBegin(int in, int out); + native void nProgramFragmentBegin(int in, int out, boolean pointSpriteEnable); native void nProgramFragmentBindTexture(int vpf, int slot, int a); native void nProgramFragmentBindSampler(int vpf, int slot, int s); - native void nProgramFragmentSetType(int slot, int vt); - native void nProgramFragmentSetEnvMode(int slot, int env); - native void nProgramFragmentSetTexEnable(int slot, boolean enable); + native void nProgramFragmentSetSlot(int slot, boolean enable, int env, int vt); native int nProgramFragmentCreate(); native void nProgramVertexBindAllocation(int pv, int mID); diff --git a/graphics/jni/android_renderscript_RenderScript.cpp b/graphics/jni/android_renderscript_RenderScript.cpp index 001ecd0f03a5..fede0e50b015 100644 --- a/graphics/jni/android_renderscript_RenderScript.cpp +++ b/graphics/jni/android_renderscript_RenderScript.cpp @@ -952,11 +952,11 @@ nProgramFragmentStoreCreate(JNIEnv *_env, jobject _this) // --------------------------------------------------------------------------- static void -nProgramFragmentBegin(JNIEnv *_env, jobject _this, jint in, jint out) +nProgramFragmentBegin(JNIEnv *_env, jobject _this, jint in, jint out, jboolean pointSpriteEnable) { RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); - LOG_API("nProgramFragmentBegin, con(%p), in(%p), out(%p)", con, (RsElement)in, (RsElement)out); - rsProgramFragmentBegin(con, (RsElement)in, (RsElement)out); + LOG_API("nProgramFragmentBegin, con(%p), in(%p), out(%p) PointSprite(%i)", con, (RsElement)in, (RsElement)out, pointSpriteEnable); + rsProgramFragmentBegin(con, (RsElement)in, (RsElement)out, pointSpriteEnable); } static void @@ -976,27 +976,11 @@ nProgramFragmentBindSampler(JNIEnv *_env, jobject _this, jint vpf, jint slot, ji } static void -nProgramFragmentSetType(JNIEnv *_env, jobject _this, jint slot, jint vt) +nProgramFragmentSetSlot(JNIEnv *_env, jobject _this, jint slot, jboolean enable, jint env, jint vt) { RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); - LOG_API("nProgramFragmentSetType, con(%p), slot(%i), vt(%p)", con, slot, (RsType)vt); - rsProgramFragmentSetType(con, slot, (RsType)vt); -} - -static void -nProgramFragmentSetEnvMode(JNIEnv *_env, jobject _this, jint slot, jint env) -{ - RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); - LOG_API("nProgramFragmentSetEnvMode, con(%p), slot(%i), vt(%i)", con, slot, env); - rsProgramFragmentSetEnvMode(con, slot, (RsTexEnvMode)env); -} - -static void -nProgramFragmentSetTexEnable(JNIEnv *_env, jobject _this, jint slot, jboolean enable) -{ - RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); - LOG_API("nProgramFragmentSetTexEnable, con(%p), slot(%i), enable(%i)", con, slot, enable); - rsProgramFragmentSetTexEnable(con, slot, enable); + LOG_API("nProgramFragmentSetType, con(%p), slot(%i), enable(%i), env(%i), vt(%p)", con, slot, enable, env, (RsType)vt); + rsProgramFragmentSetSlot(con, slot, enable, (RsTexEnvMode)env, (RsType)vt); } static jint @@ -1305,12 +1289,10 @@ static JNINativeMethod methods[] = { {"nProgramFragmentStoreDither", "(Z)V", (void*)nProgramFragmentStoreDither }, {"nProgramFragmentStoreCreate", "()I", (void*)nProgramFragmentStoreCreate }, -{"nProgramFragmentBegin", "(II)V", (void*)nProgramFragmentBegin }, +{"nProgramFragmentBegin", "(IIZ)V", (void*)nProgramFragmentBegin }, {"nProgramFragmentBindTexture", "(III)V", (void*)nProgramFragmentBindTexture }, {"nProgramFragmentBindSampler", "(III)V", (void*)nProgramFragmentBindSampler }, -{"nProgramFragmentSetType", "(II)V", (void*)nProgramFragmentSetType }, -{"nProgramFragmentSetEnvMode", "(II)V", (void*)nProgramFragmentSetEnvMode }, -{"nProgramFragmentSetTexEnable", "(IZ)V", (void*)nProgramFragmentSetTexEnable }, +{"nProgramFragmentSetSlot", "(IZII)V", (void*)nProgramFragmentSetSlot }, {"nProgramFragmentCreate", "()I", (void*)nProgramFragmentCreate }, {"nProgramVertexBindAllocation", "(II)V", (void*)nProgramVertexBindAllocation }, diff --git a/include/binder/MemoryHeapBase.h b/include/binder/MemoryHeapBase.h index 83c72835e240..435540e8c60c 100644 --- a/include/binder/MemoryHeapBase.h +++ b/include/binder/MemoryHeapBase.h @@ -42,7 +42,7 @@ public: * maps the memory referenced by fd. but DOESN'T take ownership * of the filedescriptor (it makes a copy with dup() */ - MemoryHeapBase(int fd, size_t size, uint32_t flags = 0); + MemoryHeapBase(int fd, size_t size, uint32_t flags = 0, uint32_t offset = 0); /* * maps memory from the given device @@ -82,7 +82,7 @@ protected: int flags = 0, const char* device = NULL); private: - status_t mapfd(int fd, size_t size); + status_t mapfd(int fd, size_t size, uint32_t offset = 0); int mFD; size_t mSize; diff --git a/include/media/stagefright/MetaData.h b/include/media/stagefright/MetaData.h index 6ce258121a47..be60565ac43a 100644 --- a/include/media/stagefright/MetaData.h +++ b/include/media/stagefright/MetaData.h @@ -45,6 +45,7 @@ enum { kKeyPlatformPrivate = 'priv', kKeyDecoderComponent = 'decC', kKeyBufferID = 'bfID', + kKeyCompressedSize = 'cmpS', }; enum { diff --git a/include/media/stagefright/OMXCodec.h b/include/media/stagefright/OMXCodec.h index c8ee2551d435..0b941180affa 100644 --- a/include/media/stagefright/OMXCodec.h +++ b/include/media/stagefright/OMXCodec.h @@ -108,7 +108,7 @@ private: Vector<CodecSpecificData *> mCodecSpecificData; size_t mCodecSpecificDataIndex; - sp<MemoryDealer> mDealer; + sp<MemoryDealer> mDealer[2]; State mState; Vector<BufferInfo> mPortBuffers[2]; @@ -148,6 +148,9 @@ private: void setImageOutputFormat( OMX_COLOR_FORMATTYPE format, OMX_U32 width, OMX_U32 height); + void setJPEGInputFormat( + OMX_U32 width, OMX_U32 height, OMX_U32 compressedSize); + status_t allocateBuffers(); status_t allocateBuffersOnPort(OMX_U32 portIndex); diff --git a/libs/binder/MemoryHeapBase.cpp b/libs/binder/MemoryHeapBase.cpp index ac38f515dcfb..5df078f8bdbb 100644 --- a/libs/binder/MemoryHeapBase.cpp +++ b/libs/binder/MemoryHeapBase.cpp @@ -78,13 +78,13 @@ MemoryHeapBase::MemoryHeapBase(const char* device, size_t size, uint32_t flags) } } -MemoryHeapBase::MemoryHeapBase(int fd, size_t size, uint32_t flags) +MemoryHeapBase::MemoryHeapBase(int fd, size_t size, uint32_t flags, uint32_t offset) : mFD(-1), mSize(0), mBase(MAP_FAILED), mFlags(flags), mDevice(0), mNeedUnmap(false) { const size_t pagesize = getpagesize(); size = ((size + pagesize-1) & ~(pagesize-1)); - mapfd(dup(fd), size); + mapfd(dup(fd), size, offset); } status_t MemoryHeapBase::init(int fd, void *base, int size, int flags, const char* device) @@ -100,7 +100,7 @@ status_t MemoryHeapBase::init(int fd, void *base, int size, int flags, const cha return NO_ERROR; } -status_t MemoryHeapBase::mapfd(int fd, size_t size) +status_t MemoryHeapBase::mapfd(int fd, size_t size, uint32_t offset) { if (size == 0) { // try to figure out the size automatically @@ -121,7 +121,7 @@ status_t MemoryHeapBase::mapfd(int fd, size_t size) if ((mFlags & DONT_MAP_LOCALLY) == 0) { void* base = (uint8_t*)mmap(0, size, - PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0); + PROT_READ|PROT_WRITE, MAP_SHARED, fd, offset); if (base == MAP_FAILED) { LOGE("mmap(fd=%d, size=%u) failed (%s)", fd, uint32_t(size), strerror(errno)); diff --git a/libs/rs/RenderScript.h b/libs/rs/RenderScript.h index e4cf00f0d4fc..2f60c9fe77f3 100644 --- a/libs/rs/RenderScript.h +++ b/libs/rs/RenderScript.h @@ -80,7 +80,8 @@ enum RsDataKind { RS_KIND_NX, RS_KIND_NY, RS_KIND_NZ, - RS_KIND_INDEX + RS_KIND_INDEX, + RS_KIND_POINT_SIZE }; enum RsElementPredefined { diff --git a/libs/rs/rs.spec b/libs/rs/rs.spec index 1a8102175ee3..e275f278b65a 100644 --- a/libs/rs/rs.spec +++ b/libs/rs/rs.spec @@ -361,6 +361,7 @@ ProgramFragmentStoreCreate { ProgramFragmentBegin { param RsElement in param RsElement out + param bool pointSpriteEnable } ProgramFragmentBindTexture { @@ -375,19 +376,11 @@ ProgramFragmentBindSampler { param RsSampler s } -ProgramFragmentSetType { - param uint32_t slot - param RsType t - } - -ProgramFragmentSetEnvMode { - param uint32_t slot - param RsTexEnvMode env - } - -ProgramFragmentSetTexEnable { +ProgramFragmentSetSlot { param uint32_t slot param bool enable + param RsTexEnvMode env + param RsType t } ProgramFragmentCreate { diff --git a/libs/rs/rsComponent.cpp b/libs/rs/rsComponent.cpp index b88710c8d448..4a043f3b714d 100644 --- a/libs/rs/rsComponent.cpp +++ b/libs/rs/rsComponent.cpp @@ -24,7 +24,7 @@ using namespace android::renderscript; Component::Component() { mType = FLOAT; - mKind = NONE; + mKind = USER; mIsNormalized = false; mBits = 0; } diff --git a/libs/rs/rsComponent.h b/libs/rs/rsComponent.h index 6342f1bc1b78..58565246b69a 100644 --- a/libs/rs/rsComponent.h +++ b/libs/rs/rsComponent.h @@ -34,13 +34,13 @@ public: }; enum DataKind { - NONE, + USER, RED, GREEN, BLUE, ALPHA, LUMINANCE, INTENSITY, X, Y, Z, W, S, T, Q, R, NX, NY, NZ, INDEX, - USER + POINT_SIZE }; diff --git a/libs/rs/rsProgramFragment.cpp b/libs/rs/rsProgramFragment.cpp index 9df07bfd0467..4ef6835271ba 100644 --- a/libs/rs/rsProgramFragment.cpp +++ b/libs/rs/rsProgramFragment.cpp @@ -24,7 +24,7 @@ using namespace android; using namespace android::renderscript; -ProgramFragment::ProgramFragment(Element *in, Element *out) : +ProgramFragment::ProgramFragment(Element *in, Element *out, bool pointSpriteEnable) : Program(in, out) { for (uint32_t ct=0; ct < MAX_TEXTURE; ct++) { @@ -32,6 +32,7 @@ ProgramFragment::ProgramFragment(Element *in, Element *out) : mTextureDimensions[ct] = 2; } mTextureEnableMask = 0; + mPointSpriteEnable = pointSpriteEnable; mEnvModes[1] = RS_TEX_ENV_MODE_DECAL; } @@ -54,6 +55,7 @@ void ProgramFragment::setupGL(ProgramFragmentState *state) } glEnable(GL_TEXTURE_2D); + //glTexEnvi(GL_POINT_SPRITE_OES, GL_COORD_REPLACE_OES, mPointSpriteEnable); glBindTexture(GL_TEXTURE_2D, mTextures[ct]->getTextureID()); switch(mEnvModes[ct]) { @@ -94,7 +96,6 @@ void ProgramFragment::setupGL(ProgramFragmentState *state) glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, GL_SRC_ALPHA); } } - glActiveTexture(GL_TEXTURE0); mDirty = false; } @@ -178,7 +179,7 @@ ProgramFragmentState::~ProgramFragmentState() void ProgramFragmentState::init(Context *rsc, int32_t w, int32_t h) { - ProgramFragment *pf = new ProgramFragment(NULL, NULL); + ProgramFragment *pf = new ProgramFragment(NULL, NULL, false); mDefault.set(pf); } @@ -186,10 +187,10 @@ void ProgramFragmentState::init(Context *rsc, int32_t w, int32_t h) namespace android { namespace renderscript { -void rsi_ProgramFragmentBegin(Context * rsc, RsElement in, RsElement out) +void rsi_ProgramFragmentBegin(Context * rsc, RsElement in, RsElement out, bool pointSpriteEnable) { delete rsc->mStateFragment.mPF; - rsc->mStateFragment.mPF = new ProgramFragment((Element *)in, (Element *)out); + rsc->mStateFragment.mPF = new ProgramFragment((Element *)in, (Element *)out, pointSpriteEnable); } void rsi_ProgramFragmentBindTexture(Context *rsc, RsProgramFragment vpf, uint32_t slot, RsAllocation a) @@ -204,27 +205,20 @@ void rsi_ProgramFragmentBindSampler(Context *rsc, RsProgramFragment vpf, uint32_ pf->bindSampler(slot, static_cast<Sampler *>(s)); } -void rsi_ProgramFragmentSetType(Context *rsc, uint32_t slot, RsType vt) +void rsi_ProgramFragmentSetSlot(Context *rsc, uint32_t slot, bool enable, RsTexEnvMode env, RsType vt) { const Type *t = static_cast<const Type *>(vt); - uint32_t dim = 1; - if (t->getDimY()) { - dim ++; - if (t->getDimZ()) { + if (t) { + uint32_t dim = 1; + if (t->getDimY()) { dim ++; + if (t->getDimZ()) { + dim ++; + } } + rsc->mStateFragment.mPF->setType(slot, t->getElement(), dim); } - - rsc->mStateFragment.mPF->setType(slot, t->getElement(), dim); -} - -void rsi_ProgramFragmentSetEnvMode(Context *rsc, uint32_t slot, RsTexEnvMode env) -{ rsc->mStateFragment.mPF->setEnvMode(slot, env); -} - -void rsi_ProgramFragmentSetTexEnable(Context *rsc, uint32_t slot, bool enable) -{ rsc->mStateFragment.mPF->setTexEnable(slot, enable); } diff --git a/libs/rs/rsProgramFragment.h b/libs/rs/rsProgramFragment.h index 57fb6a55af4a..bd4534202a31 100644 --- a/libs/rs/rsProgramFragment.h +++ b/libs/rs/rsProgramFragment.h @@ -32,7 +32,7 @@ public: - ProgramFragment(Element *in, Element *out); + ProgramFragment(Element *in, Element *out, bool pointSpriteEnable); virtual ~ProgramFragment(); virtual void setupGL(ProgramFragmentState *); @@ -64,6 +64,7 @@ protected: // Hacks to create a program for now RsTexEnvMode mEnvModes[MAX_TEXTURE]; uint32_t mTextureEnableMask; + bool mPointSpriteEnable; }; class ProgramFragmentState diff --git a/libs/rs/rsSampler.cpp b/libs/rs/rsSampler.cpp index c14c37170ec9..332d532d9a9f 100644 --- a/libs/rs/rsSampler.cpp +++ b/libs/rs/rsSampler.cpp @@ -143,6 +143,7 @@ RsSampler rsi_SamplerCreate(Context *rsc) ss->mWrapS, ss->mWrapT, ss->mWrapR); + s->incRef(); return s; } diff --git a/libs/rs/rsTriangleMesh.cpp b/libs/rs/rsTriangleMesh.cpp index 8c7bc920dd7f..99f8adbf158a 100644 --- a/libs/rs/rsTriangleMesh.cpp +++ b/libs/rs/rsTriangleMesh.cpp @@ -199,6 +199,7 @@ RsTriangleMesh rsi_TriangleMeshCreate(Context *rsc) memcpy(tm->mIndexData, tmc->mIndexData.array(), tm->mIndexDataSize); tm->analyzeElement(); + tm->incRef(); return tm; } @@ -248,16 +249,16 @@ void rsi_TriangleMeshRenderRange(Context *rsc, RsTriangleMesh vtm, uint32_t firs glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, tm->mBufferObjects[1]); glEnableClientState(GL_VERTEX_ARRAY); - glVertexPointer(tm->mSizeCoord, - GL_FLOAT, - tm->mVertexElement->getSizeBytes(), + glVertexPointer(tm->mSizeCoord, + GL_FLOAT, + tm->mVertexElement->getSizeBytes(), (void *)tm->mVertexElement->getComponentOffsetBytes(tm->mOffsetCoord)); if (tm->mSizeTex) { glEnableClientState(GL_TEXTURE_COORD_ARRAY); - glTexCoordPointer(tm->mSizeTex, - GL_FLOAT, - tm->mVertexElement->getSizeBytes(), + glTexCoordPointer(tm->mSizeTex, + GL_FLOAT, + tm->mVertexElement->getSizeBytes(), (void *)tm->mVertexElement->getComponentOffsetBytes(tm->mOffsetTex)); } else { glDisableClientState(GL_TEXTURE_COORD_ARRAY); @@ -265,8 +266,8 @@ void rsi_TriangleMeshRenderRange(Context *rsc, RsTriangleMesh vtm, uint32_t firs if (tm->mSizeNorm) { glEnableClientState(GL_NORMAL_ARRAY); - glNormalPointer(GL_FLOAT, - tm->mVertexElement->getSizeBytes(), + glNormalPointer(GL_FLOAT, + tm->mVertexElement->getSizeBytes(), (void *)tm->mVertexElement->getComponentOffsetBytes(tm->mOffsetNorm)); } else { glDisableClientState(GL_NORMAL_ARRAY); diff --git a/libs/rs/rsType.cpp b/libs/rs/rsType.cpp index a40a1520f594..5a9090e2e0e1 100644 --- a/libs/rs/rsType.cpp +++ b/libs/rs/rsType.cpp @@ -230,6 +230,13 @@ void Type::makeGLComponents() mGL.mTex[texNum].size = 4; break; + case Component::POINT_SIZE: + rsAssert(!mGL.mPointSize.size); + mGL.mPointSize.size = 1; + mGL.mPointSize.offset = mElement->getComponentOffsetBytes(ct); + mGL.mPointSize.type = c->getGLType(); + break; + default: break; } @@ -280,6 +287,13 @@ void Type::enableGLVertexBuffer() const } glClientActiveTexture(GL_TEXTURE0); + if (mGL.mPointSize.size) { + glEnableClientState(GL_POINT_SIZE_ARRAY_OES); + glPointSizePointerOES(mGL.mPointSize.type, + stride, + (void *)mGL.mPointSize.offset); + } + } diff --git a/libs/rs/rsType.h b/libs/rs/rsType.h index 60d75d79a9dd..6c39a4ce2396 100644 --- a/libs/rs/rsType.h +++ b/libs/rs/rsType.h @@ -118,6 +118,7 @@ protected: VertexComponent_t mNorm; VertexComponent_t mColor; VertexComponent_t mTex[RS_MAX_TEXTURE]; + VertexComponent_t mPointSize; }; GLState_t mGL; void makeGLComponents(); diff --git a/media/libstagefright/OMXCodec.cpp b/media/libstagefright/OMXCodec.cpp index 1774eafaccbd..ec9f6d319d57 100644 --- a/media/libstagefright/OMXCodec.cpp +++ b/media/libstagefright/OMXCodec.cpp @@ -302,7 +302,7 @@ sp<OMXCodec> OMXCodec::Create( int32_t width, height; bool success = meta->findInt32(kKeyWidth, &width); success = success && meta->findInt32(kKeyHeight, &height); - assert(success); + CHECK(success); if (createEncoder) { codec->setVideoInputFormat(mime, width, height); @@ -321,9 +321,16 @@ sp<OMXCodec> OMXCodec::Create( int32_t width, height; bool success = meta->findInt32(kKeyWidth, &width); success = success && meta->findInt32(kKeyHeight, &height); - assert(success); + + int32_t compressedSize; + success = success && meta->findInt32( + kKeyCompressedSize, &compressedSize); + + CHECK(success); + CHECK(compressedSize > 0); codec->setImageOutputFormat(format, width, height); + codec->setJPEGInputFormat(width, height, (OMX_U32)compressedSize); } codec->initOutputFormat(meta); @@ -355,7 +362,7 @@ status_t OMXCodec::setVideoPortFormatType( } // The following assertion is violated by TI's video decoder. - // assert(format.nIndex == index); + // CHECK_EQ(format.nIndex, index); #if 1 LOGI("portIndex: %ld, index: %ld, eCompressionFormat=%d eColorFormat=%d", @@ -618,7 +625,6 @@ OMXCodec::OMXCodec( mComponentName(strdup(componentName)), mSource(source), mCodecSpecificDataIndex(0), - mDealer(new MemoryDealer(5 * 1024 * 1024)), mState(LOADED), mSignalledEOS(false), mNoMoreOutputData(false), @@ -716,8 +722,11 @@ status_t OMXCodec::allocateBuffersOnPort(OMX_U32 portIndex) { return err; } + size_t totalSize = def.nBufferCountActual * def.nBufferSize; + mDealer[portIndex] = new MemoryDealer(totalSize); + for (OMX_U32 i = 0; i < def.nBufferCountActual; ++i) { - sp<IMemory> mem = mDealer->allocate(def.nBufferSize); + sp<IMemory> mem = mDealer[portIndex]->allocate(def.nBufferSize); CHECK(mem.get() != NULL); IOMX::buffer_id buffer; @@ -1491,23 +1500,33 @@ void OMXCodec::setImageOutputFormat( break; } + def.nBufferCountActual = def.nBufferCountMin; + err = mOMX->set_parameter( mNode, OMX_IndexParamPortDefinition, &def, sizeof(def)); CHECK_EQ(err, OK); +} - //// - +void OMXCodec::setJPEGInputFormat( + OMX_U32 width, OMX_U32 height, OMX_U32 compressedSize) { + OMX_PARAM_PORTDEFINITIONTYPE def; + def.nSize = sizeof(def); + def.nVersion.s.nVersionMajor = 1; + def.nVersion.s.nVersionMinor = 1; def.nPortIndex = kPortIndexInput; - err = mOMX->get_parameter( + status_t err = mOMX->get_parameter( mNode, OMX_IndexParamPortDefinition, &def, sizeof(def)); CHECK_EQ(err, OK); + CHECK_EQ(def.eDomain, OMX_PortDomainImage); + OMX_IMAGE_PORTDEFINITIONTYPE *imageDef = &def.format.image; + CHECK_EQ(imageDef->eCompressionFormat, OMX_IMAGE_CodingJPEG); imageDef->nFrameWidth = width; imageDef->nFrameHeight = height; - def.nBufferSize = 128 * 1024; + def.nBufferSize = compressedSize; def.nBufferCountActual = def.nBufferCountMin; err = mOMX->set_parameter( @@ -1558,7 +1577,7 @@ status_t OMXCodec::start(MetaData *) { } status_t OMXCodec::stop() { - LOGI("stop"); + LOGV("stop"); Mutex::Autolock autoLock(mLock); diff --git a/opengl/libagl/egl.cpp b/opengl/libagl/egl.cpp index 0762ebf605fc..9c0f7fd41f1e 100644 --- a/opengl/libagl/egl.cpp +++ b/opengl/libagl/egl.cpp @@ -141,7 +141,8 @@ struct egl_surface_t egl_surface_t(EGLDisplay dpy, EGLConfig config, int32_t depthFormat); virtual ~egl_surface_t(); - virtual bool isValid() const = 0; + bool isValid() const; + virtual bool initCheck() const = 0; virtual EGLBoolean bindDrawSurface(ogles_context_t* gl) = 0; virtual EGLBoolean bindReadSurface(ogles_context_t* gl) = 0; @@ -175,6 +176,11 @@ egl_surface_t::~egl_surface_t() magic = 0; free(depth.data); } +bool egl_surface_t::isValid() const { + LOGE_IF(magic != MAGIC, "invalid EGLSurface (%p)", this); + return magic == MAGIC; +} + EGLBoolean egl_surface_t::swapBuffers() { return EGL_FALSE; } @@ -208,9 +214,9 @@ struct egl_window_surface_v2_t : public egl_surface_t int32_t depthFormat, android_native_window_t* window); - ~egl_window_surface_v2_t(); + ~egl_window_surface_v2_t(); - virtual bool isValid() const { return nativeWindow->common.magic == ANDROID_NATIVE_WINDOW_MAGIC; } + virtual bool initCheck() const { return true; } // TODO: report failure if ctor fails virtual EGLBoolean swapBuffers(); virtual EGLBoolean bindDrawSurface(ogles_context_t* gl); virtual EGLBoolean bindReadSurface(ogles_context_t* gl); @@ -704,7 +710,7 @@ struct egl_pixmap_surface_t : public egl_surface_t virtual ~egl_pixmap_surface_t() { } - virtual bool isValid() const { return nativePixmap.version == sizeof(egl_native_pixmap_t); } + virtual bool initCheck() const { return !depth.format || depth.data!=0; } virtual EGLBoolean bindDrawSurface(ogles_context_t* gl); virtual EGLBoolean bindReadSurface(ogles_context_t* gl); virtual EGLint getWidth() const { return nativePixmap.width; } @@ -726,7 +732,6 @@ egl_pixmap_surface_t::egl_pixmap_surface_t(EGLDisplay dpy, depth.data = (GGLubyte*)malloc(depth.stride*depth.height*2); if (depth.data == 0) { setError(EGL_BAD_ALLOC, EGL_NO_SURFACE); - return; } } } @@ -768,7 +773,7 @@ struct egl_pbuffer_surface_t : public egl_surface_t virtual ~egl_pbuffer_surface_t(); - virtual bool isValid() const { return pbuffer.data != 0; } + virtual bool initCheck() const { return pbuffer.data != 0; } virtual EGLBoolean bindDrawSurface(ogles_context_t* gl); virtual EGLBoolean bindReadSurface(ogles_context_t* gl); virtual EGLint getWidth() const { return pbuffer.width; } @@ -1196,6 +1201,11 @@ static EGLSurface createWindowSurface(EGLDisplay dpy, EGLConfig config, if (!(surfaceType & EGL_WINDOW_BIT)) return setError(EGL_BAD_MATCH, EGL_NO_SURFACE); + if (static_cast<android_native_window_t*>(window)->common.magic != + ANDROID_NATIVE_WINDOW_MAGIC) { + return setError(EGL_BAD_NATIVE_WINDOW, EGL_NO_SURFACE); + } + EGLint configID; if (getConfigAttrib(dpy, config, EGL_CONFIG_ID, &configID) == EGL_FALSE) return EGL_FALSE; @@ -1241,7 +1251,7 @@ static EGLSurface createWindowSurface(EGLDisplay dpy, EGLConfig config, surface = new egl_window_surface_v2_t(dpy, config, depthFormat, static_cast<android_native_window_t*>(window)); - if (!surface->isValid()) { + if (!surface->initCheck()) { // there was a problem in the ctor, the error // flag has been set. delete surface; @@ -1265,6 +1275,11 @@ static EGLSurface createPixmapSurface(EGLDisplay dpy, EGLConfig config, if (!(surfaceType & EGL_PIXMAP_BIT)) return setError(EGL_BAD_MATCH, EGL_NO_SURFACE); + if (static_cast<egl_native_pixmap_t*>(pixmap)->version != + sizeof(egl_native_pixmap_t)) { + return setError(EGL_BAD_NATIVE_PIXMAP, EGL_NO_SURFACE); + } + EGLint configID; if (getConfigAttrib(dpy, config, EGL_CONFIG_ID, &configID) == EGL_FALSE) return EGL_FALSE; @@ -1307,7 +1322,7 @@ static EGLSurface createPixmapSurface(EGLDisplay dpy, EGLConfig config, new egl_pixmap_surface_t(dpy, config, depthFormat, static_cast<egl_native_pixmap_t*>(pixmap)); - if (!surface->isValid()) { + if (!surface->initCheck()) { // there was a problem in the ctor, the error // flag has been set. delete surface; @@ -1375,7 +1390,7 @@ static EGLSurface createPbufferSurface(EGLDisplay dpy, EGLConfig config, egl_surface_t* surface = new egl_pbuffer_surface_t(dpy, config, depthFormat, w, h, pixelFormat); - if (!surface->isValid()) { + if (!surface->initCheck()) { // there was a problem in the ctor, the error // flag has been set. delete surface; @@ -1590,7 +1605,7 @@ EGLBoolean eglDestroySurface(EGLDisplay dpy, EGLSurface eglSurface) return setError(EGL_BAD_DISPLAY, EGL_FALSE); if (eglSurface != EGL_NO_SURFACE) { egl_surface_t* surface( static_cast<egl_surface_t*>(eglSurface) ); - if (surface->magic != egl_surface_t::MAGIC) + if (!surface->isValid()) return setError(EGL_BAD_SURFACE, EGL_FALSE); if (surface->dpy != dpy) return setError(EGL_BAD_DISPLAY, EGL_FALSE); @@ -1610,6 +1625,8 @@ EGLBoolean eglQuerySurface( EGLDisplay dpy, EGLSurface eglSurface, if (egl_display_t::is_valid(dpy) == EGL_FALSE) return setError(EGL_BAD_DISPLAY, EGL_FALSE); egl_surface_t* surface = static_cast<egl_surface_t*>(eglSurface); + if (!surface->isValid()) + return setError(EGL_BAD_SURFACE, EGL_FALSE); if (surface->dpy != dpy) return setError(EGL_BAD_DISPLAY, EGL_FALSE); @@ -1702,9 +1719,19 @@ EGLBoolean eglMakeCurrent( EGLDisplay dpy, EGLSurface draw, return setError(EGL_BAD_DISPLAY, EGL_FALSE); if (draw) { egl_surface_t* s = (egl_surface_t*)draw; + if (!s->isValid()) + return setError(EGL_BAD_SURFACE, EGL_FALSE); + if (s->dpy != dpy) + return setError(EGL_BAD_DISPLAY, EGL_FALSE); + // TODO: check that draw is compatible with the context + } + if (read && read!=draw) { + egl_surface_t* s = (egl_surface_t*)read; + if (!s->isValid()) + return setError(EGL_BAD_SURFACE, EGL_FALSE); if (s->dpy != dpy) return setError(EGL_BAD_DISPLAY, EGL_FALSE); - // TODO: check that draw and read are compatible with the context + // TODO: check that read is compatible with the context } EGLContext current_ctx = EGL_NO_CONTEXT; @@ -1737,7 +1764,8 @@ EGLBoolean eglMakeCurrent( EGLDisplay dpy, EGLSurface draw, egl_surface_t* r = (egl_surface_t*)read; if (c->draw) { - reinterpret_cast<egl_surface_t*>(c->draw)->disconnect(); + egl_surface_t* s = reinterpret_cast<egl_surface_t*>(c->draw); + s->disconnect(); } if (c->read) { // FIXME: unlock/disconnect the read surface too @@ -1860,6 +1888,8 @@ EGLBoolean eglSwapBuffers(EGLDisplay dpy, EGLSurface draw) return setError(EGL_BAD_DISPLAY, EGL_FALSE); egl_surface_t* d = static_cast<egl_surface_t*>(draw); + if (!d->isValid()) + return setError(EGL_BAD_SURFACE, EGL_FALSE); if (d->dpy != dpy) return setError(EGL_BAD_DISPLAY, EGL_FALSE); @@ -2073,6 +2103,8 @@ EGLBoolean eglSetSwapRectangleANDROID(EGLDisplay dpy, EGLSurface draw, return setError(EGL_BAD_DISPLAY, EGL_FALSE); egl_surface_t* d = static_cast<egl_surface_t*>(draw); + if (!d->isValid()) + return setError(EGL_BAD_SURFACE, EGL_FALSE); if (d->dpy != dpy) return setError(EGL_BAD_DISPLAY, EGL_FALSE); @@ -2088,6 +2120,8 @@ EGLClientBuffer eglGetRenderBufferANDROID(EGLDisplay dpy, EGLSurface draw) return setError(EGL_BAD_DISPLAY, (EGLClientBuffer)0); egl_surface_t* d = static_cast<egl_surface_t*>(draw); + if (!d->isValid()) + return setError(EGL_BAD_SURFACE, (EGLClientBuffer)0); if (d->dpy != dpy) return setError(EGL_BAD_DISPLAY, (EGLClientBuffer)0); diff --git a/telephony/java/com/android/internal/telephony/cdma/SmsMessage.java b/telephony/java/com/android/internal/telephony/cdma/SmsMessage.java index 9c043057498c..15974271eb4f 100755 --- a/telephony/java/com/android/internal/telephony/cdma/SmsMessage.java +++ b/telephony/java/com/android/internal/telephony/cdma/SmsMessage.java @@ -29,6 +29,7 @@ import com.android.internal.telephony.cdma.sms.BearerData; import com.android.internal.telephony.cdma.sms.CdmaSmsAddress; import com.android.internal.telephony.cdma.sms.SmsEnvelope; import com.android.internal.telephony.cdma.sms.UserData; +import com.android.internal.util.HexDump; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; @@ -67,6 +68,7 @@ import static android.telephony.SmsMessage.MessageClass; */ public class SmsMessage extends SmsMessageBase { static final String LOG_TAG = "CDMA"; + private final static Boolean DBG_SMS = false; /** * Status of a previously submitted SMS. @@ -541,6 +543,11 @@ public class SmsMessage extends SmsMessageBase { return; } mBearerData = BearerData.decode(mEnvelope.bearerData); + if (DBG_SMS) { + Log.d(LOG_TAG, "MT raw BearerData = '" + + HexDump.toHexString(mEnvelope.bearerData) + "'"); + Log.d(LOG_TAG, "MT (decoded) BearerData = " + mBearerData); + } messageRef = mBearerData.messageId; if (mBearerData.userData != null) { userData = mBearerData.userData.payload; @@ -644,14 +651,17 @@ public class SmsMessage extends SmsMessageBase { bearerData.reportReq = false; bearerData.userData = userData; - bearerData.hasUserDataHeader = (userData.userDataHeader != null); - - int teleservice = bearerData.hasUserDataHeader ? - SmsEnvelope.TELESERVICE_WEMT : SmsEnvelope.TELESERVICE_WMT; byte[] encodedBearerData = BearerData.encode(bearerData); + if (DBG_SMS) { + Log.d(LOG_TAG, "MO (encoded) BearerData = " + bearerData); + Log.d(LOG_TAG, "MO raw BearerData = '" + HexDump.toHexString(encodedBearerData) + "'"); + } if (encodedBearerData == null) return null; + int teleservice = bearerData.hasUserDataHeader ? + SmsEnvelope.TELESERVICE_WEMT : SmsEnvelope.TELESERVICE_WMT; + SmsEnvelope envelope = new SmsEnvelope(); envelope.messageType = SmsEnvelope.MESSAGE_TYPE_POINT_TO_POINT; envelope.teleService = teleservice; diff --git a/telephony/java/com/android/internal/telephony/cdma/sms/BearerData.java b/telephony/java/com/android/internal/telephony/cdma/sms/BearerData.java index fefeb12b4584..721729d9bf27 100644 --- a/telephony/java/com/android/internal/telephony/cdma/sms/BearerData.java +++ b/telephony/java/com/android/internal/telephony/cdma/sms/BearerData.java @@ -484,7 +484,7 @@ public final class BearerData { Gsm7bitCodingResult result = new Gsm7bitCodingResult(); result.data = new byte[fullData.length - 1]; System.arraycopy(fullData, 1, result.data, 0, fullData.length - 1); - result.septets = fullData[0]; + result.septets = fullData[0] & 0x00FF; return result; } catch (com.android.internal.telephony.EncodeException ex) { throw new CodingException("7bit GSM encode failed: " + ex); @@ -498,6 +498,7 @@ public final class BearerData { int udhSeptets = ((udhBytes * 8) + 6) / 7; Gsm7bitCodingResult gcr = encode7bitGsm(uData.payloadStr, udhSeptets, force); uData.msgEncoding = UserData.ENCODING_GSM_7BIT_ALPHABET; + uData.msgEncodingSet = true; uData.numFields = gcr.septets; uData.payload = gcr.data; uData.payload[0] = (byte)udhData.length; @@ -512,6 +513,8 @@ public final class BearerData { int udhCodeUnits = (udhBytes + 1) / 2; int udhPadding = udhBytes % 2; int payloadCodeUnits = payload.length / 2; + uData.msgEncoding = UserData.ENCODING_UNICODE_16; + uData.msgEncodingSet = true; uData.numFields = udhCodeUnits + payloadCodeUnits; uData.payload = new byte[uData.numFields * 2]; uData.payload[0] = (byte)udhData.length; @@ -606,14 +609,16 @@ public final class BearerData { * copies by passing outStream directly. */ encodeUserDataPayload(bData.userData); + bData.hasUserDataHeader = bData.userData.userDataHeader != null; + if (bData.userData.payload.length > SmsMessage.MAX_USER_DATA_BYTES) { throw new CodingException("encoded user data too large (" + bData.userData.payload.length + " > " + SmsMessage.MAX_USER_DATA_BYTES + " bytes)"); } - /** - * XXX/TODO: figure out what the right answer is WRT padding bits + /* + * TODO(cleanup): figure out what the right answer is WRT paddingBits field * * userData.paddingBits = (userData.payload.length * 8) - (userData.numFields * 7); * userData.paddingBits = 0; // XXX this seems better, but why? diff --git a/telephony/java/com/android/internal/telephony/cdma/sms/UserData.java b/telephony/java/com/android/internal/telephony/cdma/sms/UserData.java index 9b6e19d7d674..d93852cb0061 100644 --- a/telephony/java/com/android/internal/telephony/cdma/sms/UserData.java +++ b/telephony/java/com/android/internal/telephony/cdma/sms/UserData.java @@ -154,7 +154,7 @@ public class UserData { builder.append("{ msgEncoding=" + (msgEncodingSet ? msgEncoding : "unset")); builder.append(", msgType=" + msgType); builder.append(", paddingBits=" + paddingBits); - builder.append(", numFields=" + (int)numFields); + builder.append(", numFields=" + numFields); builder.append(", userDataHeader=" + userDataHeader); builder.append(", payload='" + HexDump.toHexString(payload) + "'"); builder.append(", payloadStr='" + payloadStr + "'"); |