Merge "Fix app switch latency optimization." into gingerbread
diff --git a/api/current.xml b/api/current.xml
index 0bf6aa3..aff615c 100644
--- a/api/current.xml
+++ b/api/current.xml
@@ -177751,17 +177751,6 @@
visibility="public"
>
</field>
-<field name="SOURCE_CLASS_JOYSTICK"
- type="int"
- transient="false"
- volatile="false"
- value="16"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
<field name="SOURCE_CLASS_MASK"
type="int"
transient="false"
@@ -177817,39 +177806,6 @@
visibility="public"
>
</field>
-<field name="SOURCE_GAMEPAD"
- type="int"
- transient="false"
- volatile="false"
- value="1025"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="SOURCE_JOYSTICK_LEFT"
- type="int"
- transient="false"
- volatile="false"
- value="16777232"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="SOURCE_JOYSTICK_RIGHT"
- type="int"
- transient="false"
- volatile="false"
- value="33554448"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
<field name="SOURCE_KEYBOARD"
type="int"
transient="false"
diff --git a/cmds/stagefright/stagefright.cpp b/cmds/stagefright/stagefright.cpp
index 4a1d27b..8ab94ad 100644
--- a/cmds/stagefright/stagefright.cpp
+++ b/cmds/stagefright/stagefright.cpp
@@ -60,7 +60,7 @@
return (int64_t)tv.tv_usec + tv.tv_sec * 1000000ll;
}
-static void playSource(OMXClient *client, const sp<MediaSource> &source) {
+static void playSource(OMXClient *client, sp<MediaSource> &source) {
sp<MetaData> meta = source->getFormat();
const char *mime;
@@ -81,6 +81,8 @@
}
}
+ source.clear();
+
status_t err = rawSource->start();
if (err != OK) {
diff --git a/core/java/android/net/DownloadManager.java b/core/java/android/net/DownloadManager.java
index e8237c9..5320da3 100644
--- a/core/java/android/net/DownloadManager.java
+++ b/core/java/android/net/DownloadManager.java
@@ -17,6 +17,7 @@
package android.net;
import android.content.ContentResolver;
+import android.content.ContentUris;
import android.content.ContentValues;
import android.database.Cursor;
import android.database.CursorWrapper;
@@ -536,12 +537,12 @@
* @param projection the projection to pass to ContentResolver.query()
* @return the Cursor returned by ContentResolver.query()
*/
- Cursor runQuery(ContentResolver resolver, String[] projection) {
- Uri uri = Downloads.CONTENT_URI;
+ Cursor runQuery(ContentResolver resolver, String[] projection, Uri baseUri) {
+ Uri uri = baseUri;
List<String> selectionParts = new ArrayList<String>();
if (mId != null) {
- uri = Uri.withAppendedPath(uri, mId.toString());
+ uri = ContentUris.withAppendedId(uri, mId);
}
if (mStatusFlags != null) {
@@ -597,6 +598,7 @@
private ContentResolver mResolver;
private String mPackageName;
+ private Uri mBaseUri = Downloads.Impl.CONTENT_URI;
/**
* @hide
@@ -607,6 +609,19 @@
}
/**
+ * Makes this object access the download provider through /all_downloads URIs rather than
+ * /my_downloads URIs, for clients that have permission to do so.
+ * @hide
+ */
+ public void setAccessAllDownloads(boolean accessAllDownloads) {
+ if (accessAllDownloads) {
+ mBaseUri = Downloads.Impl.ALL_DOWNLOADS_CONTENT_URI;
+ } else {
+ mBaseUri = Downloads.Impl.CONTENT_URI;
+ }
+ }
+
+ /**
* Enqueue a new download. The download will start automatically once the download manager is
* ready to execute it and connectivity is available.
*
@@ -642,11 +657,11 @@
* COLUMN_* constants.
*/
public Cursor query(Query query) {
- Cursor underlyingCursor = query.runQuery(mResolver, UNDERLYING_COLUMNS);
+ Cursor underlyingCursor = query.runQuery(mResolver, UNDERLYING_COLUMNS, mBaseUri);
if (underlyingCursor == null) {
return null;
}
- return new CursorTranslator(underlyingCursor);
+ return new CursorTranslator(underlyingCursor, mBaseUri);
}
/**
@@ -690,9 +705,8 @@
/**
* Get the DownloadProvider URI for the download with the given ID.
*/
- private Uri getDownloadUri(long id) {
- Uri downloadUri = Uri.withAppendedPath(Downloads.CONTENT_URI, Long.toString(id));
- return downloadUri;
+ Uri getDownloadUri(long id) {
+ return ContentUris.withAppendedId(mBaseUri, id);
}
/**
@@ -702,8 +716,11 @@
* underlying data.
*/
private static class CursorTranslator extends CursorWrapper {
- public CursorTranslator(Cursor cursor) {
+ private Uri mBaseUri;
+
+ public CursorTranslator(Cursor cursor, Uri baseUri) {
super(cursor);
+ mBaseUri = baseUri;
}
@Override
@@ -799,11 +816,24 @@
}
assert column.equals(COLUMN_LOCAL_URI);
- String localUri = getUnderlyingString(Downloads._DATA);
+ return getLocalUri();
+ }
+
+ private String getLocalUri() {
+ String localUri = getUnderlyingString(Downloads.Impl._DATA);
if (localUri == null) {
return null;
}
- return Uri.fromFile(new File(localUri)).toString();
+
+ long destinationType = getUnderlyingLong(Downloads.Impl.COLUMN_DESTINATION);
+ if (destinationType == Downloads.Impl.DESTINATION_FILE_URI) {
+ // return file URI for external download
+ return Uri.fromFile(new File(localUri)).toString();
+ }
+
+ // return content URI for cache download
+ long downloadId = getUnderlyingLong(Downloads.Impl._ID);
+ return ContentUris.withAppendedId(mBaseUri, downloadId).toString();
}
private long translateLong(String column) {
diff --git a/core/java/android/provider/Downloads.java b/core/java/android/provider/Downloads.java
index 603e598..74c7372 100644
--- a/core/java/android/provider/Downloads.java
+++ b/core/java/android/provider/Downloads.java
@@ -60,7 +60,7 @@
* @hide
*/
public static final Uri CONTENT_URI =
- Uri.parse("content://downloads/download");
+ Uri.parse("content://downloads/my_downloads");
/**
* Broadcast Action: this is sent by the download manager to the app
@@ -637,10 +637,17 @@
"android.permission.DOWNLOAD_WITHOUT_NOTIFICATION";
/**
- * The content:// URI for the data table in the provider
+ * The content:// URI to access downloads owned by the caller's UID.
*/
public static final Uri CONTENT_URI =
- Uri.parse("content://downloads/download");
+ Uri.parse("content://downloads/my_downloads");
+
+ /**
+ * The content URI for accessing all downloads across all UIDs (requires the
+ * ACCESS_ALL_DOWNLOADS permission).
+ */
+ public static final Uri ALL_DOWNLOADS_CONTENT_URI =
+ Uri.parse("content://downloads/all_downloads");
/**
* Broadcast Action: this is sent by the download manager to the app
diff --git a/core/jni/AndroidRuntime.cpp b/core/jni/AndroidRuntime.cpp
index 2751a82..17ab46c 100644
--- a/core/jni/AndroidRuntime.cpp
+++ b/core/jni/AndroidRuntime.cpp
@@ -703,42 +703,6 @@
}
}
- /* enable poisoning of memory of freed objects */
- property_get("dalvik.vm.gc.overwritefree", propBuf, "false");
- if (strcmp(propBuf, "true") == 0) {
- opt.optionString = "-Xgc:overwritefree";
- mOptions.add(opt);
- } else if (strcmp(propBuf, "false") != 0) {
- LOGW("dalvik.vm.gc.overwritefree should be 'true' or 'false'");
- }
-
- /* enable heap verification before each gc */
- property_get("dalvik.vm.gc.preverify", propBuf, "false");
- if (strcmp(propBuf, "true") == 0) {
- opt.optionString = "-Xgc:preverify";
- mOptions.add(opt);
- } else if (strcmp(propBuf, "false") != 0) {
- LOGW("dalvik.vm.gc.preverify should be 'true' or 'false'");
- }
-
- /* enable heap verification after each gc */
- property_get("dalvik.vm.gc.postverify", propBuf, "false");
- if (strcmp(propBuf, "true") == 0) {
- opt.optionString = "-Xgc:postverify";
- mOptions.add(opt);
- } else if (strcmp(propBuf, "false") != 0) {
- LOGW("dalvik.vm.gc.postverify should be 'true' or 'false'");
- }
-
- /* enable card table verification for partial gc */
- property_get("dalvik.vm.gc.verifycardtable", propBuf, "false");
- if (strcmp(propBuf, "true") == 0) {
- opt.optionString = "-Xgc:verifycardtable";
- mOptions.add(opt);
- } else if (strcmp(propBuf, "false") != 0) {
- LOGW("dalvik.vm.gc.verifycardtable should be 'true' or 'false'");
- }
-
/* enable debugging; set suspend=y to pause during VM init */
#ifdef HAVE_ANDROID_OS
/* use android ADB transport */
diff --git a/media/libstagefright/WAVExtractor.cpp b/media/libstagefright/WAVExtractor.cpp
index 57c1075..aff06bc 100644
--- a/media/libstagefright/WAVExtractor.cpp
+++ b/media/libstagefright/WAVExtractor.cpp
@@ -331,9 +331,20 @@
return err;
}
+ size_t maxBytesToRead =
+ mBitsPerSample == 8 ? kMaxFrameSize / 2 : kMaxFrameSize;
+
+ size_t maxBytesAvailable =
+ (mCurrentPos - mOffset >= (off_t)mSize)
+ ? 0 : mSize - (mCurrentPos - mOffset);
+
+ if (maxBytesToRead > maxBytesAvailable) {
+ maxBytesToRead = maxBytesAvailable;
+ }
+
ssize_t n = mDataSource->readAt(
mCurrentPos, buffer->data(),
- mBitsPerSample == 8 ? kMaxFrameSize / 2 : kMaxFrameSize);
+ maxBytesToRead);
if (n <= 0) {
buffer->release();