diff options
| -rw-r--r-- | cmds/content/Android.mk | 2 | ||||
| -rw-r--r-- | core/java/android/pim/ContactsAsyncHelper.java | 342 | ||||
| -rw-r--r-- | core/java/android/pim/package.html | 7 | ||||
| -rw-r--r-- | core/java/android/webkit/WebTextView.java | 16 | ||||
| -rw-r--r-- | core/java/android/webkit/WebView.java | 91 | ||||
| -rw-r--r-- | core/java/android/webkit/WebViewCore.java | 27 | ||||
| -rw-r--r-- | core/java/android/widget/AbsListView.java | 27 | ||||
| -rw-r--r-- | core/java/android/widget/GridView.java | 10 | ||||
| -rw-r--r-- | core/java/android/widget/ListView.java | 6 | ||||
| -rw-r--r-- | media/java/android/media/MediaRecorder.java | 14 | ||||
| -rw-r--r-- | media/libmedia/AudioEffect.cpp | 8 | ||||
| -rw-r--r-- | media/libmediaplayerservice/StagefrightRecorder.cpp | 6 | ||||
| -rw-r--r-- | services/audioflinger/AudioFlinger.cpp | 2 |
13 files changed, 161 insertions, 397 deletions
diff --git a/cmds/content/Android.mk b/cmds/content/Android.mk index a3d83cf8848a..88c46f2792d5 100644 --- a/cmds/content/Android.mk +++ b/cmds/content/Android.mk @@ -7,8 +7,6 @@ LOCAL_SRC_FILES := $(call all-subdir-java-files) LOCAL_MODULE := content -LOCAL_MODULE_TAGS := optional - include $(BUILD_JAVA_LIBRARY) include $(CLEAR_VARS) diff --git a/core/java/android/pim/ContactsAsyncHelper.java b/core/java/android/pim/ContactsAsyncHelper.java deleted file mode 100644 index 21fc5940d1f0..000000000000 --- a/core/java/android/pim/ContactsAsyncHelper.java +++ /dev/null @@ -1,342 +0,0 @@ -/* - * Copyright (C) 2008 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 android.pim; - -import com.android.internal.telephony.CallerInfo; -import com.android.internal.telephony.Connection; - -import android.content.ContentUris; -import android.content.Context; -import android.graphics.drawable.Drawable; -import android.net.Uri; -import android.os.Handler; -import android.os.HandlerThread; -import android.os.Looper; -import android.os.Message; -import android.provider.ContactsContract.Contacts; -import android.util.Log; -import android.view.View; -import android.widget.ImageView; - -import java.io.InputStream; - -/** - * Helper class for async access of images. - */ -public class ContactsAsyncHelper extends Handler { - - private static final boolean DBG = false; - private static final String LOG_TAG = "ContactsAsyncHelper"; - - /** - * Interface for a WorkerHandler result return. - */ - public interface OnImageLoadCompleteListener { - /** - * Called when the image load is complete. - * - * @param imagePresent true if an image was found - */ - public void onImageLoadComplete(int token, Object cookie, ImageView iView, - boolean imagePresent); - } - - // constants - private static final int EVENT_LOAD_IMAGE = 1; - private static final int DEFAULT_TOKEN = -1; - - // static objects - private static Handler sThreadHandler; - private static ContactsAsyncHelper sInstance; - - static { - sInstance = new ContactsAsyncHelper(); - } - - private static final class WorkerArgs { - public Context context; - public ImageView view; - public Uri uri; - public int defaultResource; - public Object result; - public Object cookie; - public OnImageLoadCompleteListener listener; - public CallerInfo info; - } - - /** - * public inner class to help out the ContactsAsyncHelper callers - * with tracking the state of the CallerInfo Queries and image - * loading. - * - * Logic contained herein is used to remove the race conditions - * that exist as the CallerInfo queries run and mix with the image - * loads, which then mix with the Phone state changes. - */ - public static class ImageTracker { - - // Image display states - public static final int DISPLAY_UNDEFINED = 0; - public static final int DISPLAY_IMAGE = -1; - public static final int DISPLAY_DEFAULT = -2; - - // State of the image on the imageview. - private CallerInfo mCurrentCallerInfo; - private int displayMode; - - public ImageTracker() { - mCurrentCallerInfo = null; - displayMode = DISPLAY_UNDEFINED; - } - - /** - * Used to see if the requested call / connection has a - * different caller attached to it than the one we currently - * have in the CallCard. - */ - public boolean isDifferentImageRequest(CallerInfo ci) { - // note, since the connections are around for the lifetime of the - // call, and the CallerInfo-related items as well, we can - // definitely use a simple != comparison. - return (mCurrentCallerInfo != ci); - } - - public boolean isDifferentImageRequest(Connection connection) { - // if the connection does not exist, see if the - // mCurrentCallerInfo is also null to match. - if (connection == null) { - if (DBG) Log.d(LOG_TAG, "isDifferentImageRequest: connection is null"); - return (mCurrentCallerInfo != null); - } - Object o = connection.getUserData(); - - // if the call does NOT have a callerInfo attached - // then it is ok to query. - boolean runQuery = true; - if (o instanceof CallerInfo) { - runQuery = isDifferentImageRequest((CallerInfo) o); - } - return runQuery; - } - - /** - * Simple setter for the CallerInfo object. - */ - public void setPhotoRequest(CallerInfo ci) { - mCurrentCallerInfo = ci; - } - - /** - * Convenience method used to retrieve the URI - * representing the Photo file recorded in the attached - * CallerInfo Object. - */ - public Uri getPhotoUri() { - if (mCurrentCallerInfo != null) { - return ContentUris.withAppendedId(Contacts.CONTENT_URI, - mCurrentCallerInfo.person_id); - } - return null; - } - - /** - * Simple setter for the Photo state. - */ - public void setPhotoState(int state) { - displayMode = state; - } - - /** - * Simple getter for the Photo state. - */ - public int getPhotoState() { - return displayMode; - } - } - - /** - * Thread worker class that handles the task of opening the stream and loading - * the images. - */ - private class WorkerHandler extends Handler { - public WorkerHandler(Looper looper) { - super(looper); - } - - @Override - public void handleMessage(Message msg) { - WorkerArgs args = (WorkerArgs) msg.obj; - - switch (msg.arg1) { - case EVENT_LOAD_IMAGE: - InputStream inputStream = null; - try { - inputStream = Contacts.openContactPhotoInputStream( - args.context.getContentResolver(), args.uri, true); - } catch (Exception e) { - Log.e(LOG_TAG, "Error opening photo input stream", e); - } - - if (inputStream != null) { - args.result = Drawable.createFromStream(inputStream, args.uri.toString()); - - if (DBG) Log.d(LOG_TAG, "Loading image: " + msg.arg1 + - " token: " + msg.what + " image URI: " + args.uri); - } else { - args.result = null; - if (DBG) Log.d(LOG_TAG, "Problem with image: " + msg.arg1 + - " token: " + msg.what + " image URI: " + args.uri + - ", using default image."); - } - break; - default: - } - - // send the reply to the enclosing class. - Message reply = ContactsAsyncHelper.this.obtainMessage(msg.what); - reply.arg1 = msg.arg1; - reply.obj = msg.obj; - reply.sendToTarget(); - } - } - - /** - * Private constructor for static class - */ - private ContactsAsyncHelper() { - HandlerThread thread = new HandlerThread("ContactsAsyncWorker"); - thread.start(); - sThreadHandler = new WorkerHandler(thread.getLooper()); - } - - /** - * Convenience method for calls that do not want to deal with listeners and tokens. - */ - public static final void updateImageViewWithContactPhotoAsync(Context context, - ImageView imageView, Uri person, int placeholderImageResource) { - // Added additional Cookie field in the callee. - updateImageViewWithContactPhotoAsync (null, DEFAULT_TOKEN, null, null, context, - imageView, person, placeholderImageResource); - } - - /** - * Convenience method for calls that do not want to deal with listeners and tokens, but have - * a CallerInfo object to cache the image to. - */ - public static final void updateImageViewWithContactPhotoAsync(CallerInfo info, Context context, - ImageView imageView, Uri person, int placeholderImageResource) { - // Added additional Cookie field in the callee. - updateImageViewWithContactPhotoAsync (info, DEFAULT_TOKEN, null, null, context, - imageView, person, placeholderImageResource); - } - - - /** - * Start an image load, attach the result to the specified CallerInfo object. - * Note, when the query is started, we make the ImageView INVISIBLE if the - * placeholderImageResource value is -1. When we're given a valid (!= -1) - * placeholderImageResource value, we make sure the image is visible. - */ - public static final void updateImageViewWithContactPhotoAsync(CallerInfo info, int token, - OnImageLoadCompleteListener listener, Object cookie, Context context, - ImageView imageView, Uri person, int placeholderImageResource) { - - // in case the source caller info is null, the URI will be null as well. - // just update using the placeholder image in this case. - if (person == null) { - if (DBG) Log.d(LOG_TAG, "target image is null, just display placeholder."); - imageView.setVisibility(View.VISIBLE); - imageView.setImageResource(placeholderImageResource); - return; - } - - // Added additional Cookie field in the callee to handle arguments - // sent to the callback function. - - // setup arguments - WorkerArgs args = new WorkerArgs(); - args.cookie = cookie; - args.context = context; - args.view = imageView; - args.uri = person; - args.defaultResource = placeholderImageResource; - args.listener = listener; - args.info = info; - - // setup message arguments - Message msg = sThreadHandler.obtainMessage(token); - msg.arg1 = EVENT_LOAD_IMAGE; - msg.obj = args; - - if (DBG) Log.d(LOG_TAG, "Begin loading image: " + args.uri + - ", displaying default image for now."); - - // set the default image first, when the query is complete, we will - // replace the image with the correct one. - if (placeholderImageResource != -1) { - imageView.setVisibility(View.VISIBLE); - imageView.setImageResource(placeholderImageResource); - } else { - imageView.setVisibility(View.INVISIBLE); - } - - // notify the thread to begin working - sThreadHandler.sendMessage(msg); - } - - /** - * Called when loading is done. - */ - @Override - public void handleMessage(Message msg) { - WorkerArgs args = (WorkerArgs) msg.obj; - switch (msg.arg1) { - case EVENT_LOAD_IMAGE: - boolean imagePresent = false; - - // if the image has been loaded then display it, otherwise set default. - // in either case, make sure the image is visible. - if (args.result != null) { - args.view.setVisibility(View.VISIBLE); - args.view.setImageDrawable((Drawable) args.result); - // make sure the cached photo data is updated. - if (args.info != null) { - args.info.cachedPhoto = (Drawable) args.result; - } - imagePresent = true; - } else if (args.defaultResource != -1) { - args.view.setVisibility(View.VISIBLE); - args.view.setImageResource(args.defaultResource); - } - - // Note that the data is cached. - if (args.info != null) { - args.info.isCachedPhotoCurrent = true; - } - - // notify the listener if it is there. - if (args.listener != null) { - if (DBG) Log.d(LOG_TAG, "Notifying listener: " + args.listener.toString() + - " image: " + args.uri + " completed"); - args.listener.onImageLoadComplete(msg.what, args.cookie, args.view, - imagePresent); - } - break; - default: - } - } -} diff --git a/core/java/android/pim/package.html b/core/java/android/pim/package.html deleted file mode 100644 index 75237c902131..000000000000 --- a/core/java/android/pim/package.html +++ /dev/null @@ -1,7 +0,0 @@ -<HTML> -<BODY> -{@hide} -Provides helpers for working with PIM (Personal Information Manager) data used -by contact lists and calendars. -</BODY> -</HTML>
\ No newline at end of file diff --git a/core/java/android/webkit/WebTextView.java b/core/java/android/webkit/WebTextView.java index 2b59b80cd889..510c1685bcae 100644 --- a/core/java/android/webkit/WebTextView.java +++ b/core/java/android/webkit/WebTextView.java @@ -160,14 +160,14 @@ import java.util.ArrayList; private MyResultReceiver mReceiver; // Types used with setType. Keep in sync with CachedInput.h - private static final int NORMAL_TEXT_FIELD = 0; - private static final int TEXT_AREA = 1; - private static final int PASSWORD = 2; - private static final int SEARCH = 3; - private static final int EMAIL = 4; - private static final int NUMBER = 5; - private static final int TELEPHONE = 6; - private static final int URL = 7; + static final int NORMAL_TEXT_FIELD = 0; + static final int TEXT_AREA = 1; + static final int PASSWORD = 2; + static final int SEARCH = 3; + static final int EMAIL = 4; + static final int NUMBER = 5; + static final int TELEPHONE = 6; + static final int URL = 7; private static final int AUTOFILL_FORM = 100; private Handler mHandler; diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java index 3dbe66d3127a..6dc3be540f0e 100644 --- a/core/java/android/webkit/WebView.java +++ b/core/java/android/webkit/WebView.java @@ -98,6 +98,7 @@ import android.view.inputmethod.InputMethodManager; import android.webkit.WebTextView.AutoCompleteAdapter; import android.webkit.WebViewCore.DrawData; import android.webkit.WebViewCore.EventHub; +import android.webkit.WebViewCore.TextFieldInitData; import android.webkit.WebViewCore.TouchEventData; import android.webkit.WebViewCore.TouchHighlightData; import android.webkit.WebViewCore.WebKitHitTest; @@ -371,6 +372,9 @@ public class WebView extends AbsoluteLayout // Used for mapping characters to keys typed. private KeyCharacterMap mKeyCharacterMap; private boolean mIsKeySentByMe; + private int mInputType; + private int mImeOptions; + private String mHint; public WebViewInputConnection() { super(WebView.this, true); @@ -452,6 +456,77 @@ public class WebView extends AbsoluteLayout return super.deleteSurroundingText(leftLength, rightLength); } + public void initEditorInfo(WebViewCore.TextFieldInitData initData) { + int type = initData.mType; + int inputType = InputType.TYPE_CLASS_TEXT + | InputType.TYPE_TEXT_VARIATION_WEB_EDIT_TEXT; + int imeOptions = EditorInfo.IME_FLAG_NO_EXTRACT_UI + | EditorInfo.IME_FLAG_NO_FULLSCREEN; + if (!initData.mIsSpellCheckEnabled) { + inputType |= InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS; + } + if (WebTextView.TEXT_AREA != type + && initData.mIsTextFieldNext) { + imeOptions |= EditorInfo.IME_FLAG_NAVIGATE_NEXT; + } + switch (type) { + case WebTextView.NORMAL_TEXT_FIELD: + imeOptions |= EditorInfo.IME_ACTION_GO; + break; + case WebTextView.TEXT_AREA: + inputType |= InputType.TYPE_TEXT_FLAG_MULTI_LINE + | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES + | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT; + imeOptions |= EditorInfo.IME_ACTION_NONE; + break; + case WebTextView.PASSWORD: + inputType |= EditorInfo.TYPE_TEXT_VARIATION_WEB_PASSWORD; + imeOptions |= EditorInfo.IME_ACTION_GO; + break; + case WebTextView.SEARCH: + imeOptions |= EditorInfo.IME_ACTION_SEARCH; + break; + case WebTextView.EMAIL: + // inputType needs to be overwritten because of the different text variation. + inputType = InputType.TYPE_CLASS_TEXT + | InputType.TYPE_TEXT_VARIATION_WEB_EMAIL_ADDRESS; + imeOptions |= EditorInfo.IME_ACTION_GO; + break; + case WebTextView.NUMBER: + // inputType needs to be overwritten because of the different class. + inputType = InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_VARIATION_NORMAL + | InputType.TYPE_NUMBER_FLAG_SIGNED | InputType.TYPE_NUMBER_FLAG_DECIMAL; + // Number and telephone do not have both a Tab key and an + // action, so set the action to NEXT + imeOptions |= EditorInfo.IME_ACTION_NEXT; + break; + case WebTextView.TELEPHONE: + // inputType needs to be overwritten because of the different class. + inputType = InputType.TYPE_CLASS_PHONE; + imeOptions |= EditorInfo.IME_ACTION_NEXT; + break; + case WebTextView.URL: + // TYPE_TEXT_VARIATION_URI prevents Tab key from showing, so + // exclude it for now. + imeOptions |= EditorInfo.IME_ACTION_GO; + inputType |= InputType.TYPE_TEXT_VARIATION_URI; + break; + default: + imeOptions |= EditorInfo.IME_ACTION_GO; + break; + } + mHint = initData.mLabel; + mInputType = inputType; + mImeOptions = imeOptions; + } + + public void setupEditorInfo(EditorInfo outAttrs) { + outAttrs.inputType = mInputType; + outAttrs.imeOptions = mImeOptions; + outAttrs.hintText = mHint; + outAttrs.initialCapsMode = getCursorCapsMode(InputType.TYPE_CLASS_TEXT); + } + /** * Sends a text change to webkit indirectly. If it is a single- * character add or delete, it sends it as a key stroke. If it cannot @@ -5159,18 +5234,10 @@ public class WebView extends AbsoluteLayout @Override public InputConnection onCreateInputConnection(EditorInfo outAttrs) { - outAttrs.inputType = EditorInfo.IME_FLAG_NO_FULLSCREEN - | EditorInfo.TYPE_CLASS_TEXT - | EditorInfo.TYPE_TEXT_VARIATION_WEB_EDIT_TEXT - | EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE - | EditorInfo.TYPE_TEXT_FLAG_AUTO_CORRECT - | EditorInfo.TYPE_TEXT_FLAG_CAP_SENTENCES; - outAttrs.imeOptions = EditorInfo.IME_ACTION_NONE; - if (mInputConnection == null) { mInputConnection = new WebViewInputConnection(); } - outAttrs.initialCapsMode = mInputConnection.getCursorCapsMode(InputType.TYPE_CLASS_TEXT); + mInputConnection.setupEditorInfo(outAttrs); return mInputConnection; } @@ -9081,9 +9148,11 @@ public class WebView extends AbsoluteLayout case INIT_EDIT_FIELD: if (mInputConnection != null) { + TextFieldInitData initData = (TextFieldInitData) msg.obj; mTextGeneration = 0; - mFieldPointer = msg.arg1; - mInputConnection.setTextAndKeepSelection((String) msg.obj); + mFieldPointer = initData.mFieldPointer; + mInputConnection.initEditorInfo(initData); + mInputConnection.setTextAndKeepSelection(initData.mText); } break; diff --git a/core/java/android/webkit/WebViewCore.java b/core/java/android/webkit/WebViewCore.java index ee27dd4b67ac..84f0b9c845e5 100644 --- a/core/java/android/webkit/WebViewCore.java +++ b/core/java/android/webkit/WebViewCore.java @@ -919,6 +919,25 @@ public final class WebViewCore { private String mPreview; } + static class TextFieldInitData { + public TextFieldInitData(int fieldPointer, + String text, int type, boolean isSpellCheckEnabled, + boolean isTextFieldNext, String label) { + mFieldPointer = fieldPointer; + mText = text; + mType = type; + mIsSpellCheckEnabled = isSpellCheckEnabled; + mIsTextFieldNext = isTextFieldNext; + mLabel = label; + } + int mFieldPointer; + String mText; + int mType; + boolean mIsSpellCheckEnabled; + boolean mIsTextFieldNext; + String mLabel; + } + // mAction of TouchEventData can be MotionEvent.getAction() which uses the // last two bytes or one of the following values static final int ACTION_LONGPRESS = 0x100; @@ -2813,12 +2832,16 @@ public final class WebViewCore { } // called by JNI - private void initEditField(int pointer, String text, int start, int end) { + private void initEditField(int pointer, String text, int inputType, + boolean isSpellCheckEnabled, boolean nextFieldIsText, + String label, int start, int end) { if (mWebView == null) { return; } + TextFieldInitData initData = new TextFieldInitData(pointer, + text, inputType, isSpellCheckEnabled, nextFieldIsText, label); Message.obtain(mWebView.mPrivateHandler, - WebView.INIT_EDIT_FIELD, pointer, 0, text).sendToTarget(); + WebView.INIT_EDIT_FIELD, initData).sendToTarget(); Message.obtain(mWebView.mPrivateHandler, WebView.REQUEST_KEYBOARD_WITH_SELECTION_MSG_ID, pointer, 0, new TextSelectionData(start, end, 0)) diff --git a/core/java/android/widget/AbsListView.java b/core/java/android/widget/AbsListView.java index e7bc1e1f661b..2602523c283f 100644 --- a/core/java/android/widget/AbsListView.java +++ b/core/java/android/widget/AbsListView.java @@ -2035,13 +2035,6 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te } child = mAdapter.getView(position, scrapView, this); - if (mAdapterHasStableIds) { - LayoutParams lp = (LayoutParams) child.getLayoutParams(); - if (lp == null) { - lp = (LayoutParams) generateDefaultLayoutParams(); - } - lp.itemId = mAdapter.getItemId(position); - } if (ViewDebug.TRACE_RECYCLER) { ViewDebug.trace(child, ViewDebug.RecyclerTraceType.BIND_VIEW, @@ -2072,6 +2065,20 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te } } + if (mAdapterHasStableIds) { + final ViewGroup.LayoutParams vlp = child.getLayoutParams(); + LayoutParams lp; + if (vlp == null) { + lp = (LayoutParams) generateDefaultLayoutParams(); + } else if (!checkLayoutParams(vlp)) { + lp = (LayoutParams) generateLayoutParams(vlp); + } else { + lp = (LayoutParams) vlp; + } + lp.itemId = mAdapter.getItemId(position); + child.setLayoutParams(lp); + } + return child; } @@ -5383,6 +5390,12 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te } @Override + protected ViewGroup.LayoutParams generateDefaultLayoutParams() { + return new AbsListView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, + ViewGroup.LayoutParams.WRAP_CONTENT, 0); + } + + @Override protected ViewGroup.LayoutParams generateLayoutParams(ViewGroup.LayoutParams p) { return new LayoutParams(p); } diff --git a/core/java/android/widget/GridView.java b/core/java/android/widget/GridView.java index 6bc5a15f531d..0dedf8b61d32 100644 --- a/core/java/android/widget/GridView.java +++ b/core/java/android/widget/GridView.java @@ -1029,10 +1029,9 @@ public class GridView extends AbsListView { if (count > 0) { final View child = obtainView(0, mIsScrap); - AbsListView.LayoutParams p = (AbsListView.LayoutParams)child.getLayoutParams(); + AbsListView.LayoutParams p = (AbsListView.LayoutParams) child.getLayoutParams(); if (p == null) { - p = new AbsListView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, - ViewGroup.LayoutParams.WRAP_CONTENT, 0); + p = (AbsListView.LayoutParams) generateDefaultLayoutParams(); child.setLayoutParams(p); } p.viewType = mAdapter.getItemViewType(0); @@ -1362,10 +1361,9 @@ public class GridView extends AbsListView { // Respect layout params that are already in the view. Otherwise make // some up... - AbsListView.LayoutParams p = (AbsListView.LayoutParams)child.getLayoutParams(); + AbsListView.LayoutParams p = (AbsListView.LayoutParams) child.getLayoutParams(); if (p == null) { - p = new AbsListView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, - ViewGroup.LayoutParams.WRAP_CONTENT, 0); + p = (AbsListView.LayoutParams) generateDefaultLayoutParams(); } p.viewType = mAdapter.getItemViewType(position); diff --git a/core/java/android/widget/ListView.java b/core/java/android/widget/ListView.java index 46c2c0725d0d..71700b367b40 100644 --- a/core/java/android/widget/ListView.java +++ b/core/java/android/widget/ListView.java @@ -1163,8 +1163,7 @@ public class ListView extends AbsListView { private void measureScrapChild(View child, int position, int widthMeasureSpec) { LayoutParams p = (LayoutParams) child.getLayoutParams(); if (p == null) { - p = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, - ViewGroup.LayoutParams.WRAP_CONTENT, 0); + p = (AbsListView.LayoutParams) generateDefaultLayoutParams(); child.setLayoutParams(p); } p.viewType = mAdapter.getItemViewType(position); @@ -1808,8 +1807,7 @@ public class ListView extends AbsListView { // noinspection unchecked AbsListView.LayoutParams p = (AbsListView.LayoutParams) child.getLayoutParams(); if (p == null) { - p = new AbsListView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, - ViewGroup.LayoutParams.WRAP_CONTENT, 0); + p = (AbsListView.LayoutParams) generateDefaultLayoutParams(); } p.viewType = mAdapter.getItemViewType(position); diff --git a/media/java/android/media/MediaRecorder.java b/media/java/android/media/MediaRecorder.java index 85d99c153298..63196308364c 100644 --- a/media/java/android/media/MediaRecorder.java +++ b/media/java/android/media/MediaRecorder.java @@ -303,6 +303,8 @@ public class MediaRecorder /** * Uses the settings from a CamcorderProfile object for recording. This method should * be called after the video AND audio sources are set, and before setOutputFile(). + * If a time lapse CamcorderProfile is used, audio related source or recording + * parameters are ignored. * * @param profile the CamcorderProfile to use * @see android.media.CamcorderProfile @@ -315,8 +317,8 @@ public class MediaRecorder setVideoEncoder(profile.videoCodec); if (profile.quality >= CamcorderProfile.QUALITY_TIME_LAPSE_LOW && profile.quality <= CamcorderProfile.QUALITY_TIME_LAPSE_QVGA) { - // Enable time lapse. Also don't set audio for time lapse. - setParameter(String.format("time-lapse-enable=1")); + // Nothing needs to be done. Call to setCaptureRate() enables + // time lapse video recording. } else { setAudioEncodingBitRate(profile.audioBitRate); setAudioChannels(profile.audioChannels); @@ -327,7 +329,10 @@ public class MediaRecorder /** * Set video frame capture rate. This can be used to set a different video frame capture - * rate than the recorded video's playback rate. Currently this works only for time lapse mode. + * rate than the recorded video's playback rate. This method also sets the recording mode + * to time lapse. In time lapse video recording, only video is recorded. Audio related + * parameters are ignored when a time lapse recording session starts, if an application + * sets them. * * @param fps Rate at which frames should be captured in frames per second. * The fps can go as low as desired. However the fastest fps will be limited by the hardware. @@ -339,6 +344,9 @@ public class MediaRecorder * possible. */ public void setCaptureRate(double fps) { + // Make sure that time lapse is enabled when this method is called. + setParameter(String.format("time-lapse-enable=1")); + double timeBetweenFrameCapture = 1 / fps; int timeBetweenFrameCaptureMs = (int) (1000 * timeBetweenFrameCapture); setParameter(String.format("time-between-time-lapse-frame-capture=%d", diff --git a/media/libmedia/AudioEffect.cpp b/media/libmedia/AudioEffect.cpp index 19b7e324b32b..6808aa22b6c9 100644 --- a/media/libmedia/AudioEffect.cpp +++ b/media/libmedia/AudioEffect.cpp @@ -202,7 +202,7 @@ bool AudioEffect::getEnabled() const status_t AudioEffect::setEnabled(bool enabled) { if (mStatus != NO_ERROR) { - return (mStatus == ALREADY_EXISTS) ? INVALID_OPERATION : mStatus; + return (mStatus == ALREADY_EXISTS) ? (status_t) INVALID_OPERATION : mStatus; } status_t status = NO_ERROR; @@ -263,7 +263,7 @@ status_t AudioEffect::command(uint32_t cmdCode, status_t AudioEffect::setParameter(effect_param_t *param) { if (mStatus != NO_ERROR) { - return (mStatus == ALREADY_EXISTS) ? INVALID_OPERATION : mStatus; + return (mStatus == ALREADY_EXISTS) ? (status_t) INVALID_OPERATION : mStatus; } if (param == NULL || param->psize == 0 || param->vsize == 0) { @@ -281,7 +281,7 @@ status_t AudioEffect::setParameter(effect_param_t *param) status_t AudioEffect::setParameterDeferred(effect_param_t *param) { if (mStatus != NO_ERROR) { - return (mStatus == ALREADY_EXISTS) ? INVALID_OPERATION : mStatus; + return (mStatus == ALREADY_EXISTS) ? (status_t) INVALID_OPERATION : mStatus; } if (param == NULL || param->psize == 0 || param->vsize == 0) { @@ -307,7 +307,7 @@ status_t AudioEffect::setParameterDeferred(effect_param_t *param) status_t AudioEffect::setParameterCommit() { if (mStatus != NO_ERROR) { - return (mStatus == ALREADY_EXISTS) ? INVALID_OPERATION : mStatus; + return (mStatus == ALREADY_EXISTS) ? (status_t) INVALID_OPERATION : mStatus; } Mutex::Autolock _l(mCblk->lock); diff --git a/media/libmediaplayerservice/StagefrightRecorder.cpp b/media/libmediaplayerservice/StagefrightRecorder.cpp index fe519b095f30..c5f4f86d38de 100644 --- a/media/libmediaplayerservice/StagefrightRecorder.cpp +++ b/media/libmediaplayerservice/StagefrightRecorder.cpp @@ -1291,6 +1291,12 @@ status_t StagefrightRecorder::setupCameraSource( videoSize.width = mVideoWidth; videoSize.height = mVideoHeight; if (mCaptureTimeLapse) { + if (mTimeBetweenTimeLapseFrameCaptureUs < 0) { + ALOGE("Invalid mTimeBetweenTimeLapseFrameCaptureUs value: %lld", + mTimeBetweenTimeLapseFrameCaptureUs); + return BAD_VALUE; + } + mCameraSourceTimeLapse = CameraSourceTimeLapse::CreateFromCamera( mCamera, mCameraProxy, mCameraId, videoSize, mFrameRate, mPreviewSurface, diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp index 2e2834c3c7f6..ded7cf63e846 100644 --- a/services/audioflinger/AudioFlinger.cpp +++ b/services/audioflinger/AudioFlinger.cpp @@ -4122,7 +4122,7 @@ void AudioFlinger::PlaybackThread::TimedTrack::releaseBuffer( TimedBuffer& head = mTimedBufferQueue.editItemAt(0); void* start = head.buffer()->pointer(); - void* end = head.buffer()->pointer() + head.buffer()->size(); + void* end = (char *) head.buffer()->pointer() + head.buffer()->size(); if ((buffer->raw >= start) && (buffer->raw <= end)) { head.setPosition(head.position() + |