diff options
Diffstat (limited to 'core/java/android')
7 files changed, 139 insertions, 29 deletions
diff --git a/core/java/android/accounts/AccountManagerService.java b/core/java/android/accounts/AccountManagerService.java index 1ba8eee..4f3405b 100644 --- a/core/java/android/accounts/AccountManagerService.java +++ b/core/java/android/accounts/AccountManagerService.java @@ -499,7 +499,7 @@ public class AccountManagerService if (response != null) { try { if (result == null) { - onError(AccountManager.ERROR_CODE_INVALID_RESPONSE, "null bundle"); + response.onError(AccountManager.ERROR_CODE_INVALID_RESPONSE, "null bundle"); return; } if (Log.isLoggable(TAG, Log.VERBOSE)) { @@ -1541,8 +1541,15 @@ public class AccountManagerService mAuthenticator = null; IAccountManagerResponse response = getResponseAndClose(); if (response != null) { - onError(AccountManager.ERROR_CODE_REMOTE_EXCEPTION, - "disconnected"); + try { + response.onError(AccountManager.ERROR_CODE_REMOTE_EXCEPTION, + "disconnected"); + } catch (RemoteException e) { + if (Log.isLoggable(TAG, Log.VERBOSE)) { + Log.v(TAG, "Session.onServiceDisconnected: " + + "caught RemoteException while responding", e); + } + } } } @@ -1551,8 +1558,15 @@ public class AccountManagerService public void onTimedOut() { IAccountManagerResponse response = getResponseAndClose(); if (response != null) { - onError(AccountManager.ERROR_CODE_REMOTE_EXCEPTION, - "timeout"); + try { + response.onError(AccountManager.ERROR_CODE_REMOTE_EXCEPTION, + "timeout"); + } catch (RemoteException e) { + if (Log.isLoggable(TAG, Log.VERBOSE)) { + Log.v(TAG, "Session.onTimedOut: caught RemoteException while responding", + e); + } + } } } diff --git a/core/java/android/bluetooth/BluetoothDeviceProfileState.java b/core/java/android/bluetooth/BluetoothDeviceProfileState.java index 48d0203..7addd4a 100644 --- a/core/java/android/bluetooth/BluetoothDeviceProfileState.java +++ b/core/java/android/bluetooth/BluetoothDeviceProfileState.java @@ -110,6 +110,7 @@ public final class BluetoothDeviceProfileState extends StateMachine { private BluetoothHeadset mHeadsetService; private BluetoothPbap mPbapService; private boolean mPbapServiceConnected; + private boolean mAutoConnectionPending; private static final String BLUETOOTH_ADMIN_PERM = android.Manifest.permission.BLUETOOTH_ADMIN; private BluetoothDevice mDevice; @@ -272,6 +273,10 @@ public final class BluetoothDeviceProfileState extends StateMachine { public void onServiceConnected(int profile, BluetoothProfile proxy) { synchronized(BluetoothDeviceProfileState.this) { mHeadsetService = (BluetoothHeadset) proxy; + if (mAutoConnectionPending) { + sendMessage(AUTO_CONNECT_PROFILES); + mAutoConnectionPending = false; + } } } public void onServiceDisconnected(int profile) { @@ -360,8 +365,9 @@ public final class BluetoothDeviceProfileState extends StateMachine { // Don't auto connect to docks. break; } else { - if (mHeadsetService != null && - mHeadsetService.getPriority(mDevice) == + if (mHeadsetService == null) { + mAutoConnectionPending = true; + } else if (mHeadsetService.getPriority(mDevice) == BluetoothHeadset.PRIORITY_AUTO_CONNECT && mHeadsetService.getDevicesMatchingConnectionStates( new int[] {BluetoothProfile.STATE_CONNECTED, diff --git a/core/java/android/database/sqlite/SQLiteCompiledSql.java b/core/java/android/database/sqlite/SQLiteCompiledSql.java index bdb96b1..dafbc79 100644 --- a/core/java/android/database/sqlite/SQLiteCompiledSql.java +++ b/core/java/android/database/sqlite/SQLiteCompiledSql.java @@ -49,7 +49,7 @@ import android.util.Log; /** the following are for debugging purposes */ private String mSqlStmt = null; - private Throwable mStackTrace = null; + private final Throwable mStackTrace; /** when in cache and is in use, this member is set */ private boolean mInUse = false; @@ -59,7 +59,11 @@ import android.util.Log; db.verifyLockOwner(); mDatabase = db; mSqlStmt = sql; - mStackTrace = new DatabaseObjectNotClosedException().fillInStackTrace(); + if (StrictMode.vmSqliteObjectLeaksEnabled()) { + mStackTrace = new DatabaseObjectNotClosedException().fillInStackTrace(); + } else { + mStackTrace = null; + } nHandle = db.mNativeHandle; native_compile(sql); } @@ -112,7 +116,7 @@ import android.util.Log; // but if the database itself is not closed and is GC'ed, then // all sub-objects attached to the database could end up getting GC'ed too. // in that case, don't print any warning. - if (mInUse && StrictMode.vmSqliteObjectLeaksEnabled()) { + if (mInUse && mStackTrace != null) { int len = mSqlStmt.length(); StrictMode.onSqliteObjectLeaked( "Releasing statement in a finalizer. Please ensure " + diff --git a/core/java/android/database/sqlite/SQLiteCursor.java b/core/java/android/database/sqlite/SQLiteCursor.java index 9574300..c24acd4 100644 --- a/core/java/android/database/sqlite/SQLiteCursor.java +++ b/core/java/android/database/sqlite/SQLiteCursor.java @@ -95,7 +95,11 @@ public class SQLiteCursor extends AbstractWindowedCursor { if (query.mDatabase == null) { throw new IllegalArgumentException("query.mDatabase cannot be null"); } - mStackTrace = new DatabaseObjectNotClosedException().fillInStackTrace(); + if (StrictMode.vmSqliteObjectLeaksEnabled()) { + mStackTrace = new DatabaseObjectNotClosedException().fillInStackTrace(); + } else { + mStackTrace = null; + } mDriver = driver; mEditTable = editTable; mColumnNameMap = null; @@ -319,7 +323,7 @@ public class SQLiteCursor extends AbstractWindowedCursor { try { // if the cursor hasn't been closed yet, close it first if (mWindow != null) { - if (StrictMode.vmSqliteObjectLeaksEnabled()) { + if (mStackTrace != null) { int len = mQuery.mSql.length(); StrictMode.onSqliteObjectLeaked( "Finalizing a Cursor that has not been deactivated or closed. " + diff --git a/core/java/android/text/style/SuggestionSpan.java b/core/java/android/text/style/SuggestionSpan.java index 6e95016..ed2af10 100644 --- a/core/java/android/text/style/SuggestionSpan.java +++ b/core/java/android/text/style/SuggestionSpan.java @@ -60,7 +60,6 @@ public class SuggestionSpan extends CharacterStyle implements ParcelableSpan { * Sets this flag if the auto correction is about to be applied to a word/text * that the user is typing/composing. This type of suggestion is rendered differently * to indicate the auto correction is happening. - * @hide */ public static final int FLAG_AUTO_CORRECTION = 0x0004; diff --git a/core/java/android/view/accessibility/AccessibilityNodeInfo.java b/core/java/android/view/accessibility/AccessibilityNodeInfo.java index 7671312..fa34ee7 100644 --- a/core/java/android/view/accessibility/AccessibilityNodeInfo.java +++ b/core/java/android/view/accessibility/AccessibilityNodeInfo.java @@ -293,7 +293,7 @@ public class AccessibilityNodeInfo implements Parcelable { */ public AccessibilityNodeInfo getParent() { enforceSealed(); - if (!canPerformRequestOverConnection(mAccessibilityViewId)) { + if (!canPerformRequestOverConnection(mParentAccessibilityViewId)) { return null; } AccessibilityInteractionClient client = AccessibilityInteractionClient.getInstance(); diff --git a/core/java/android/widget/NumberPicker.java b/core/java/android/widget/NumberPicker.java index cf015c4..320c650 100644 --- a/core/java/android/widget/NumberPicker.java +++ b/core/java/android/widget/NumberPicker.java @@ -203,6 +203,16 @@ public class NumberPicker extends LinearLayout { private final EditText mInputText; /** + * The max height of this widget. + */ + private final int mMaxHeight; + + /** + * The max width of this widget. + */ + private final int mMaxWidth; + + /** * The height of the text. */ private final int mTextSize; @@ -517,6 +527,8 @@ public class NumberPicker extends LinearLayout { getResources().getDisplayMetrics()); mSelectionDividerHeight = attributesArray.getDimensionPixelSize( R.styleable.NumberPicker_selectionDividerHeight, defSelectionDividerHeight); + mMaxHeight = attributesArray.getDimensionPixelSize(R.styleable.NumberPicker_maxHeight, 0); + mMaxWidth = attributesArray.getDimensionPixelSize(R.styleable.NumberPicker_maxWidth, 0); attributesArray.recycle(); mShowInputControlsAnimimationDuration = getResources().getInteger( @@ -665,7 +677,38 @@ public class NumberPicker extends LinearLayout { @Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { - super.onLayout(changed, left, top, right, bottom); + if (mMaxHeight <= 0 && mMaxWidth <= 0) { + super.onLayout(changed, left, top, right, bottom); + } else { + final int msrdWdth = getMeasuredWidth(); + final int msrdHght = getMeasuredHeight(); + + // Increment button at the top. + final int inctBtnMsrdWdth = mIncrementButton.getMeasuredWidth(); + final int incrBtnLeft = (msrdWdth - inctBtnMsrdWdth) / 2; + final int incrBtnTop = 0; + final int incrBtnRight = incrBtnLeft + inctBtnMsrdWdth; + final int incrBtnBottom = incrBtnTop + mIncrementButton.getMeasuredHeight(); + mIncrementButton.layout(incrBtnLeft, incrBtnTop, incrBtnRight, incrBtnBottom); + + // Input text centered horizontally. + final int inptTxtMsrdWdth = mInputText.getMeasuredWidth(); + final int inptTxtMsrdHght = mInputText.getMeasuredHeight(); + final int inptTxtLeft = (msrdWdth - inptTxtMsrdWdth) / 2; + final int inptTxtTop = (msrdHght - inptTxtMsrdHght) / 2; + final int inptTxtRight = inptTxtLeft + inptTxtMsrdWdth; + final int inptTxtBottom = inptTxtTop + inptTxtMsrdHght; + mInputText.layout(inptTxtLeft, inptTxtTop, inptTxtRight, inptTxtBottom); + + // Decrement button at the top. + final int decrBtnMsrdWdth = mIncrementButton.getMeasuredWidth(); + final int decrBtnLeft = (msrdWdth - decrBtnMsrdWdth) / 2; + final int decrBtnTop = msrdHght - mDecrementButton.getMeasuredHeight(); + final int decrBtnRight = decrBtnLeft + decrBtnMsrdWdth; + final int decrBtnBottom = msrdHght; + mDecrementButton.layout(decrBtnLeft, decrBtnTop, decrBtnRight, decrBtnBottom); + } + if (!mScrollWheelAndFadingEdgesInitialized) { mScrollWheelAndFadingEdgesInitialized = true; // need to do all this when we know our size @@ -675,6 +718,24 @@ public class NumberPicker extends LinearLayout { } @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + super.onMeasure(widthMeasureSpec, heightMeasureSpec); + final int measuredWidth; + if (mMaxWidth > 0) { + measuredWidth = getMaxSize(widthMeasureSpec, mMaxWidth); + } else { + measuredWidth = getMeasuredWidth(); + } + final int measuredHeight; + if (mMaxHeight > 0) { + measuredHeight = getMaxSize(heightMeasureSpec, mMaxHeight); + } else { + measuredHeight = getMeasuredHeight(); + } + setMeasuredDimension(measuredWidth, measuredHeight); + } + + @Override public boolean onInterceptTouchEvent(MotionEvent event) { if (!isEnabled() || !mFlingable) { return false; @@ -700,17 +761,14 @@ public class NumberPicker extends LinearLayout { hideInputControls(); return true; } - if (isEventInViewHitRect(event, mInputText) - || (!mIncrementButton.isShown() - && isEventInViewHitRect(event, mIncrementButton)) - || (!mDecrementButton.isShown() - && isEventInViewHitRect(event, mDecrementButton))) { - mAdjustScrollerOnUpEvent = false; - setSelectorWheelState(SELECTOR_WHEEL_STATE_LARGE); - hideInputControls(); - return true; + if (isEventInVisibleViewHitRect(event, mIncrementButton) + || isEventInVisibleViewHitRect(event, mDecrementButton)) { + return false; } - break; + mAdjustScrollerOnUpEvent = false; + setSelectorWheelState(SELECTOR_WHEEL_STATE_LARGE); + hideInputControls(); + return true; case MotionEvent.ACTION_MOVE: float currentMoveY = event.getY(); int deltaDownY = (int) Math.abs(currentMoveY - mLastDownEventY); @@ -1240,6 +1298,28 @@ public class NumberPicker extends LinearLayout { } /** + * Gets the max value for a size based on the measure spec passed by + * the parent and the max value for that size. + * + * @param measureSpec The measure spec. + * @param maxValue The max value for the size. + * @return The max size. + */ + private int getMaxSize(int measureSpec, int maxValue) { + final int mode = MeasureSpec.getMode(measureSpec); + switch (mode) { + case MeasureSpec.EXACTLY: + return MeasureSpec.getSize(measureSpec); + case MeasureSpec.AT_MOST: + return Math.min(MeasureSpec.getSize(measureSpec), maxValue); + case MeasureSpec.UNSPECIFIED: + return maxValue; + default: + throw new IllegalArgumentException(); + } + } + + /** * Resets the selector indices and clear the cached * string representation of these indices. */ @@ -1335,11 +1415,14 @@ public class NumberPicker extends LinearLayout { } /** - * @return If the <code>event</code> is in the <code>view</code>. + * @return If the <code>event</code> is in the visible <code>view</code>. */ - private boolean isEventInViewHitRect(MotionEvent event, View view) { - view.getHitRect(mTempRect); - return mTempRect.contains((int) event.getX(), (int) event.getY()); + private boolean isEventInVisibleViewHitRect(MotionEvent event, View view) { + if (view.getVisibility() == VISIBLE) { + view.getHitRect(mTempRect); + return mTempRect.contains((int) event.getX(), (int) event.getY()); + } + return false; } /** |
