Merge "Small change to AppWidgetProviderInfo public field name and docs"
diff --git a/core/java/android/os/Parcel.java b/core/java/android/os/Parcel.java
index 31f8719..8944f12 100644
--- a/core/java/android/os/Parcel.java
+++ b/core/java/android/os/Parcel.java
@@ -31,6 +31,7 @@
import java.io.Serializable;
import java.lang.reflect.Field;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -356,7 +357,7 @@
public final native void enforceInterface(String interfaceName);
/**
- * Write a byte array into the parcel at the current {#link #dataPosition},
+ * Write a byte array into the parcel at the current {@link #dataPosition},
* growing {@link #dataCapacity} if needed.
* @param b Bytes to place into the parcel.
*/
@@ -365,7 +366,7 @@
}
/**
- * Write an byte array into the parcel at the current {#link #dataPosition},
+ * Write an byte array into the parcel at the current {@link #dataPosition},
* growing {@link #dataCapacity} if needed.
* @param b Bytes to place into the parcel.
* @param offset Index of first byte to be written.
@@ -376,9 +377,7 @@
writeInt(-1);
return;
}
- if (b.length < offset + len || len < 0 || offset < 0) {
- throw new ArrayIndexOutOfBoundsException();
- }
+ Arrays.checkOffsetAndCount(b.length, offset, len);
writeNative(b, offset, len);
}
diff --git a/core/java/android/widget/AbsListView.java b/core/java/android/widget/AbsListView.java
index c2c8d16..1d05d0b 100644
--- a/core/java/android/widget/AbsListView.java
+++ b/core/java/android/widget/AbsListView.java
@@ -3529,6 +3529,7 @@
post(this);
} else {
mTouchMode = TOUCH_MODE_REST;
+ reportScrollStateChange(OnScrollListener.SCROLL_STATE_IDLE);
}
}
diff --git a/core/java/android/widget/TabWidget.java b/core/java/android/widget/TabWidget.java
index 22f6f4e..d74ef24 100644
--- a/core/java/android/widget/TabWidget.java
+++ b/core/java/android/widget/TabWidget.java
@@ -174,8 +174,8 @@
void measureHorizontal(int widthMeasureSpec, int heightMeasureSpec) {
// First, measure with no constraint
final int unspecifiedWidth = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
- super.measureHorizontal(unspecifiedWidth, heightMeasureSpec);
mImposedTabsHeight = -1;
+ super.measureHorizontal(unspecifiedWidth, heightMeasureSpec);
int extraWidth = getMeasuredWidth() - MeasureSpec.getSize(widthMeasureSpec);
if (extraWidth > 0) {
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index 33d1225..09c1ac5 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -7091,6 +7091,11 @@
// Only track when onStartTemporaryDetach() is called directly,
// usually because this instance is an editable field in a list
if (!mDispatchTemporaryDetach) mTemporaryDetach = true;
+
+ // Because of View recycling in ListView, there is no easy way to know when a TextView with
+ // selection becomes visible again. Until a better solution is found, stop text selection
+ // mode (if any) as soon as this TextView is recycled.
+ stopSelectionActionMode();
}
@Override
diff --git a/core/jni/android_util_Binder.cpp b/core/jni/android_util_Binder.cpp
index ef3c31a..7226e31 100644
--- a/core/jni/android_util_Binder.cpp
+++ b/core/jni/android_util_Binder.cpp
@@ -1250,15 +1250,13 @@
if (parcel == NULL) {
return;
}
- void *dest;
const status_t err = parcel->writeInt32(length);
if (err != NO_ERROR) {
jniThrowException(env, "java/lang/OutOfMemoryError", NULL);
}
- dest = parcel->writeInplace(length);
-
+ void* dest = parcel->writeInplace(length);
if (dest == NULL) {
jniThrowException(env, "java/lang/OutOfMemoryError", NULL);
return;
@@ -1266,7 +1264,7 @@
jbyte* ar = (jbyte*)env->GetPrimitiveArrayCritical((jarray)data, 0);
if (ar) {
- memcpy(dest, ar, length);
+ memcpy(dest, ar + offset, length);
env->ReleasePrimitiveArrayCritical((jarray)data, ar, 0);
}
}
diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaFrameworkPerfTestRunner.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaFrameworkPerfTestRunner.java
index 988b229..a6cf355 100755
--- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaFrameworkPerfTestRunner.java
+++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaFrameworkPerfTestRunner.java
@@ -21,9 +21,10 @@
import com.android.mediaframeworktest.performance.VideoEditorPerformance;
import junit.framework.TestSuite;
+import android.os.Bundle;
import android.test.InstrumentationTestRunner;
import android.test.InstrumentationTestSuite;
-
+import android.util.Log;
/**
* Instrumentation Test Runner for all MediaPlayer tests.
@@ -36,19 +37,30 @@
public class MediaFrameworkPerfTestRunner extends InstrumentationTestRunner {
+ public static boolean mGetNativeHeapDump = false;
- @Override
- public TestSuite getAllTests() {
- TestSuite suite = new InstrumentationTestSuite(this);
- suite.addTestSuite(MediaPlayerPerformance.class);
- /*Video Editor performance Test cases*/
- suite.addTestSuite(VideoEditorPerformance.class);
- return suite;
- }
- @Override
- public ClassLoader getLoader() {
- return MediaFrameworkTestRunner.class.getClassLoader();
- }
+ @Override
+ public TestSuite getAllTests() {
+ TestSuite suite = new InstrumentationTestSuite(this);
+ suite.addTestSuite(MediaPlayerPerformance.class);
+ /* Video Editor performance Test cases */
+ suite.addTestSuite(VideoEditorPerformance.class);
+ return suite;
+ }
+
+ @Override
+ public ClassLoader getLoader() {
+ return MediaFrameworkTestRunner.class.getClassLoader();
+ }
+
+ @Override
+ public void onCreate(Bundle icicle) {
+ super.onCreate(icicle);
+ String get_heap_dump = (String) icicle.get("get_heap_dump");
+ if (get_heap_dump != null) {
+ mGetNativeHeapDump = true;
+ }
+ }
}
diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaTestUtil.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaTestUtil.java
new file mode 100755
index 0000000..0183b5d
--- /dev/null
+++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaTestUtil.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.mediaframeworktest;
+
+import java.io.FileOutputStream;
+
+import android.os.Debug;
+import android.os.Environment;
+
+/**
+ *
+ * Utilities for media framework test.
+ *
+ */
+public class MediaTestUtil {
+ private MediaTestUtil(){
+ }
+
+ private static final String STORAGE_PATH =
+ Environment.getExternalStorageDirectory().toString();
+
+ //Catpure the heapdump for memory leaksage analysis\
+ public static void getNativeHeapDump (String name) throws Exception {
+ System.gc();
+ System.runFinalization();
+ Thread.sleep(1000);
+ FileOutputStream o = new FileOutputStream(STORAGE_PATH + '/' +name + ".dump");
+ Debug.dumpNativeHeap(o.getFD());
+ o.close();
+ }
+}
\ No newline at end of file
diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/MediaRecorderTest.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/MediaRecorderTest.java
index ce6db68..82df6690 100644
--- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/MediaRecorderTest.java
+++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/MediaRecorderTest.java
@@ -28,7 +28,7 @@
import android.media.EncoderCapabilities;
import android.media.EncoderCapabilities.VideoEncoderCap;
import android.media.EncoderCapabilities.AudioEncoderCap;
-import android.test.ActivityInstrumentationTestCase;
+import android.test.ActivityInstrumentationTestCase2;
import android.util.Log;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
@@ -42,7 +42,7 @@
/**
* Junit / Instrumentation test case for the media recorder api
*/
-public class MediaRecorderTest extends ActivityInstrumentationTestCase<MediaFrameworkTest> {
+public class MediaRecorderTest extends ActivityInstrumentationTestCase2<MediaFrameworkTest> {
private String TAG = "MediaRecorderTest";
private int mOutputDuration =0;
private int mOutputVideoWidth = 0;
@@ -62,9 +62,9 @@
}
protected void setUp() throws Exception {
- super.setUp();
- Log.v(TAG,"create the media recorder");
+ getActivity();
mRecorder = new MediaRecorder();
+ super.setUp();
}
private void recordVideo(int frameRate, int width, int height,
@@ -199,8 +199,6 @@
return false;
}
-
-
private void getOutputVideoProperty(String outputFilePath) {
MediaPlayer mediaPlayer = new MediaPlayer();
try {
@@ -215,8 +213,6 @@
Thread.sleep(1000);
mOutputVideoHeight = mediaPlayer.getVideoHeight();
mOutputVideoWidth = mediaPlayer.getVideoWidth();
- //mOutputVideoHeight = CodecTest.videoHeight(outputFilePath);
- //mOutputVideoWidth = CodecTest.videoWidth(outputFilePath);
mediaPlayer.release();
} catch (Exception e) {
Log.v(TAG, e.toString());
@@ -224,11 +220,6 @@
}
}
- private void removeFile(String filePath) {
- File fileRemove = new File(filePath);
- fileRemove.delete();
- }
-
private boolean validateVideo(String filePath, int width, int height) {
boolean validVideo = false;
getOutputVideoProperty(filePath);
@@ -237,72 +228,9 @@
validVideo = true;
}
Log.v(TAG, "width = " + mOutputVideoWidth + " height = " + mOutputVideoHeight + " Duration = " + mOutputDuration);
- //removeFile(filePath);
return validVideo;
}
-
-
- //Format: HVGA h263
- @Suppress
- public void testHVGAH263() throws Exception {
- boolean videoRecordedResult = false;
- recordVideo(15, 480, 320, MediaRecorder.VideoEncoder.H263,
- MediaRecorder.OutputFormat.THREE_GPP, MediaNames.RECORDED_HVGA_H263, false);
- videoRecordedResult = validateVideo(MediaNames.RECORDED_HVGA_H263, 480, 320);
- assertTrue("HVGAH263", videoRecordedResult);
- }
-
- //Format: QVGA h263
- @Suppress
- public void testQVGAH263() throws Exception {
- boolean videoRecordedResult = false;
- recordVideo(15, 320, 240, MediaRecorder.VideoEncoder.H263,
- MediaRecorder.OutputFormat.THREE_GPP, MediaNames.RECORDED_QVGA_H263, false);
- videoRecordedResult = validateVideo(MediaNames.RECORDED_QVGA_H263, 320, 240);
- assertTrue("QVGAH263", videoRecordedResult);
- }
-
- //Format: SQVGA h263
- @Suppress
- public void testSQVGAH263() throws Exception {
- boolean videoRecordedResult = false;
- recordVideo(15, 240, 160, MediaRecorder.VideoEncoder.H263,
- MediaRecorder.OutputFormat.THREE_GPP, MediaNames.RECORDED_SQVGA_H263, false);
- videoRecordedResult = validateVideo(MediaNames.RECORDED_SQVGA_H263, 240, 160);
- assertTrue("SQVGAH263", videoRecordedResult);
- }
-
- //Format: QCIF h263
- @LargeTest
- public void testQCIFH263() throws Exception {
- boolean videoRecordedResult = false;
- recordVideo(15, 176, 144, MediaRecorder.VideoEncoder.H263,
- MediaRecorder.OutputFormat.THREE_GPP, MediaNames.RECORDED_QCIF_H263, false);
- videoRecordedResult = validateVideo(MediaNames.RECORDED_QCIF_H263, 176, 144);
- assertTrue("QCIFH263", videoRecordedResult);
- }
-
- //Format: CIF h263
- @LargeTest
- public void testCIFH263() throws Exception {
- boolean videoRecordedResult = false;
- recordVideo(15, 352, 288, MediaRecorder.VideoEncoder.H263,
- MediaRecorder.OutputFormat.THREE_GPP, MediaNames.RECORDED_CIF_H263, false);
- videoRecordedResult = validateVideo(MediaNames.RECORDED_CIF_H263, 352, 288);
- assertTrue("CIFH263", videoRecordedResult);
- }
-
-
-
- @LargeTest
- public void testVideoOnly() throws Exception {
- boolean videoRecordedResult = false;
- recordVideo(15, 176, 144, MediaRecorder.VideoEncoder.H263,
- MediaRecorder.OutputFormat.MPEG_4, MediaNames.RECORDED_VIDEO_3GP, true);
- videoRecordedResult = validateVideo(MediaNames.RECORDED_VIDEO_3GP, 176, 144);
- assertTrue("QCIFH263 Video Only", videoRecordedResult);
- }
-
+
@LargeTest
/*
* This test case set the camera in portrait mode.
@@ -332,74 +260,6 @@
assertTrue("PortraitH263", videoRecordedResult);
}
- @Suppress
- public void testHVGAMP4() throws Exception {
- boolean videoRecordedResult = false;
- recordVideo(15, 480, 320, MediaRecorder.VideoEncoder.MPEG_4_SP,
- MediaRecorder.OutputFormat.MPEG_4, MediaNames.RECORDED_HVGA_MP4, false);
- videoRecordedResult = validateVideo(MediaNames.RECORDED_HVGA_MP4, 480, 320);
- assertTrue("HVGAMP4", videoRecordedResult);
- }
-
- @Suppress
- public void testQVGAMP4() throws Exception {
- boolean videoRecordedResult = false;
- recordVideo(15, 320, 240, MediaRecorder.VideoEncoder.MPEG_4_SP,
- MediaRecorder.OutputFormat.MPEG_4, MediaNames.RECORDED_QVGA_MP4, false);
- videoRecordedResult = validateVideo(MediaNames.RECORDED_QVGA_MP4, 320, 240);
- assertTrue("QVGAMP4", videoRecordedResult);
- }
-
- @Suppress
- public void testSQVGAMP4() throws Exception {
- boolean videoRecordedResult = false;
- recordVideo(15, 240, 160, MediaRecorder.VideoEncoder.MPEG_4_SP,
- MediaRecorder.OutputFormat.MPEG_4, MediaNames.RECORDED_SQVGA_MP4, false);
- videoRecordedResult = validateVideo(MediaNames.RECORDED_SQVGA_MP4, 240, 160);
- assertTrue("SQVGAMP4", videoRecordedResult);
- }
-
- //Format: QCIF MP4
- @LargeTest
- public void testQCIFMP4() throws Exception {
- boolean videoRecordedResult = false;
- recordVideo(15, 176, 144, MediaRecorder.VideoEncoder.MPEG_4_SP,
- MediaRecorder.OutputFormat.MPEG_4, MediaNames.RECORDED_QCIF_MP4, false);
- videoRecordedResult = validateVideo(MediaNames.RECORDED_QCIF_MP4, 176, 144);
- assertTrue("QCIFMP4", videoRecordedResult);
- }
-
-
- //Format: CIF MP4
- @LargeTest
- public void testCIFMP4() throws Exception {
- boolean videoRecordedResult = false;
- recordVideo(15, 352, 288, MediaRecorder.VideoEncoder.MPEG_4_SP,
- MediaRecorder.OutputFormat.MPEG_4, MediaNames.RECORDED_CIF_MP4, false);
- videoRecordedResult = validateVideo(MediaNames.RECORDED_CIF_MP4, 352, 288);
- assertTrue("CIFMP4", videoRecordedResult);
- }
-
-
- //Format: CIF MP4 output format 3gpp
- @LargeTest
- public void testCIFMP43GPP() throws Exception {
- boolean videoRecordedResult = false;
- recordVideo(15, 352, 288, MediaRecorder.VideoEncoder.MPEG_4_SP,
- MediaRecorder.OutputFormat.THREE_GPP, MediaNames.RECORDED_VIDEO_3GP, false);
- videoRecordedResult = validateVideo(MediaNames.RECORDED_VIDEO_3GP, 352, 288);
- assertTrue("CIFMP4 3GPP", videoRecordedResult);
- }
-
- @LargeTest
- public void testQCIFH2633GPP() throws Exception {
- boolean videoRecordedResult = false;
- recordVideo(15, 176, 144, MediaRecorder.VideoEncoder.H263,
- MediaRecorder.OutputFormat.THREE_GPP, MediaNames.RECORDED_VIDEO_3GP, false);
- videoRecordedResult = validateVideo(MediaNames.RECORDED_VIDEO_3GP, 176, 144);
- assertTrue("QCIFH263 3GPP", videoRecordedResult);
- }
-
@LargeTest
public void testInvalidVideoPath() throws Exception {
boolean isTestInvalidVideoPathSuccessful = false;
@@ -408,23 +268,6 @@
assertTrue("Invalid outputFile Path", isTestInvalidVideoPathSuccessful);
}
- @Suppress
- public void testInvalidVideoSize() throws Exception {
- boolean isTestInvalidVideoSizeSuccessful = false;
- isTestInvalidVideoSizeSuccessful = invalidRecordSetting(15, 800, 600, MediaRecorder.VideoEncoder.H263,
- MediaRecorder.OutputFormat.THREE_GPP, MediaNames.RECORDED_VIDEO_3GP, false);
- assertTrue("Invalid video Size", isTestInvalidVideoSizeSuccessful);
- }
-
- @Suppress
- @LargeTest
- public void testInvalidFrameRate() throws Exception {
- boolean isTestInvalidFrameRateSuccessful = false;
- isTestInvalidFrameRateSuccessful = invalidRecordSetting(50, 176, 144, MediaRecorder.VideoEncoder.H263,
- MediaRecorder.OutputFormat.THREE_GPP, MediaNames.RECORDED_VIDEO_3GP, false);
- assertTrue("Invalid FrameRate", isTestInvalidFrameRateSuccessful);
- }
-
@LargeTest
//test cases for the new codec
public void testDeviceSpecificCodec() throws Exception {
diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/performance/MediaPlayerPerformance.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/performance/MediaPlayerPerformance.java
index 0e3029b..34affa7 100644
--- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/performance/MediaPlayerPerformance.java
+++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/performance/MediaPlayerPerformance.java
@@ -17,7 +17,9 @@
package com.android.mediaframeworktest.performance;
import com.android.mediaframeworktest.MediaFrameworkTest;
+import com.android.mediaframeworktest.MediaFrameworkPerfTestRunner;
import com.android.mediaframeworktest.MediaNames;
+import com.android.mediaframeworktest.MediaTestUtil;
import android.database.sqlite.SQLiteDatabase;
import android.hardware.Camera;
@@ -27,7 +29,7 @@
import android.os.ConditionVariable;
import android.os.Looper;
import android.os.SystemClock;
-import android.test.ActivityInstrumentationTestCase;
+import android.test.ActivityInstrumentationTestCase2;
import android.test.suitebuilder.annotation.LargeTest;
import android.test.suitebuilder.annotation.Suppress;
import android.util.Log;
@@ -52,7 +54,7 @@
* Junit / Instrumentation - performance measurement for media player and
* recorder
*/
-public class MediaPlayerPerformance extends ActivityInstrumentationTestCase<MediaFrameworkTest> {
+public class MediaPlayerPerformance extends ActivityInstrumentationTestCase2<MediaFrameworkTest> {
private String TAG = "MediaPlayerPerformance";
@@ -87,6 +89,15 @@
protected void setUp() throws Exception {
super.setUp();
+ getActivity();
+ if (MediaFrameworkPerfTestRunner.mGetNativeHeapDump)
+ MediaTestUtil.getNativeHeapDump(this.getName() + "_before");
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ if (MediaFrameworkPerfTestRunner.mGetNativeHeapDump)
+ MediaTestUtil.getNativeHeapDump(this.getName() + "_after");
}
public void createDB() {