Merge "Fix for 4087846 Crash reported by monkey report (Java/Jni)" into honeycomb-mr1

This commit is contained in:
Rajneesh Chowdury
2011-03-16 16:03:15 -07:00
committed by Android (Google) Code Review
2 changed files with 24 additions and 0 deletions

View File

@ -904,6 +904,10 @@ public class VideoEditorImpl implements VideoEditor {
throw new IllegalArgumentException("Surface could not be retrieved from Surface holder"); throw new IllegalArgumentException("Surface could not be retrieved from Surface holder");
} }
if (surface.isValid() == false) {
throw new IllegalStateException("Surface is not valid");
}
if (timeMs < 0) { if (timeMs < 0) {
throw new IllegalArgumentException("requested time not correct"); throw new IllegalArgumentException("requested time not correct");
} else if (timeMs > mDurationMs) { } else if (timeMs > mDurationMs) {
@ -1627,6 +1631,10 @@ public class VideoEditorImpl implements VideoEditor {
throw new IllegalArgumentException("Surface could not be retrieved from surface holder"); throw new IllegalArgumentException("Surface could not be retrieved from surface holder");
} }
if (surface.isValid() == false) {
throw new IllegalStateException("Surface is not valid");
}
if (listener == null) { if (listener == null) {
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} }
@ -1863,6 +1871,10 @@ public class VideoEditorImpl implements VideoEditor {
throw new IllegalArgumentException("Surface could not be retrieved from surface holder"); throw new IllegalArgumentException("Surface could not be retrieved from surface holder");
} }
if (surface.isValid() == false) {
throw new IllegalStateException("Surface is not valid");
}
if (mMANativeHelper != null) { if (mMANativeHelper != null) {
mMANativeHelper.clearPreviewSurface(surface); mMANativeHelper.clearPreviewSurface(surface);
} else { } else {

View File

@ -557,6 +557,10 @@ static void videoEditor_clearSurface(JNIEnv* pEnv,
Surface* const p = (Surface*)pEnv->GetIntField(surface, surface_native); Surface* const p = (Surface*)pEnv->GetIntField(surface, surface_native);
sp<Surface> previewSurface = sp<Surface>(p); sp<Surface> previewSurface = sp<Surface>(p);
// Validate the mSurface's mNativeSurface field
videoEditJava_checkAndThrowIllegalStateException(&needToBeLoaded, pEnv,
(NULL == previewSurface.get()),
"mNativeSurface is null");
frameStr.pBuffer = M4OSA_NULL; frameStr.pBuffer = M4OSA_NULL;
frameStr.timeMs = 0; frameStr.timeMs = 0;
@ -634,6 +638,10 @@ static int videoEditor_renderPreviewFrame(JNIEnv* pEnv,
Surface* const p = (Surface*)pEnv->GetIntField(mSurface, surface_native); Surface* const p = (Surface*)pEnv->GetIntField(mSurface, surface_native);
sp<Surface> previewSurface = sp<Surface>(p); sp<Surface> previewSurface = sp<Surface>(p);
// Validate the mSurface's mNativeSurface field
videoEditJava_checkAndThrowIllegalStateException(&needToBeLoaded, pEnv,
(NULL == previewSurface.get()),
"mNativeSurface is null");
/* Determine the total number of clips, total duration*/ /* Determine the total number of clips, total duration*/
uiNumberOfClipsInStoryBoard = pContext->pEditSettings->uiClipNumber; uiNumberOfClipsInStoryBoard = pContext->pEditSettings->uiClipNumber;
@ -2058,6 +2066,10 @@ videoEditor_startPreview(
Surface* const p = (Surface*)pEnv->GetIntField(mSurface, surface_native); Surface* const p = (Surface*)pEnv->GetIntField(mSurface, surface_native);
sp<Surface> previewSurface = sp<Surface>(p); sp<Surface> previewSurface = sp<Surface>(p);
// Validate the mSurface's mNativeSurface field
videoEditJava_checkAndThrowIllegalStateException(&needToBeLoaded, pEnv,
(NULL == previewSurface.get()),
"mNativeSurface is null");
result = pContext->mPreviewController->setSurface(previewSurface); result = pContext->mPreviewController->setSurface(previewSurface);
videoEditJava_checkAndThrowRuntimeException(&needToBeLoaded, pEnv, videoEditJava_checkAndThrowRuntimeException(&needToBeLoaded, pEnv,