diff options
Diffstat (limited to 'core/java')
20 files changed, 177 insertions, 55 deletions
diff --git a/core/java/android/animation/LayoutTransition.java b/core/java/android/animation/LayoutTransition.java index f383af9..7f0ea99 100644 --- a/core/java/android/animation/LayoutTransition.java +++ b/core/java/android/animation/LayoutTransition.java @@ -657,6 +657,15 @@ public class LayoutTransition { */ private void setupChangeAnimation(final ViewGroup parent, final int changeReason, Animator baseAnimator, final long duration, final View child) { + + // If we already have a listener for this child, then we've already set up the + // changing animation we need. Multiple calls for a child may occur when several + // add/remove operations are run at once on a container; each one will trigger + // changes for the existing children in the container. + if (layoutChangeListenerMap.get(child) != null) { + return; + } + // Make a copy of the appropriate animation final Animator anim = baseAnimator.clone(); diff --git a/core/java/android/app/backup/BackupAgent.java b/core/java/android/app/backup/BackupAgent.java index 9542874..9ad33a5 100644 --- a/core/java/android/app/backup/BackupAgent.java +++ b/core/java/android/app/backup/BackupAgent.java @@ -46,9 +46,15 @@ import libcore.io.StructStat; * {@link #onBackup(ParcelFileDescriptor, BackupDataOutput, ParcelFileDescriptor) onBackup()} * and {@link #onRestore(BackupDataInput, int, ParcelFileDescriptor) onRestore()} methods, * and provide the name of its backup agent class in its {@code AndroidManifest.xml} file via - * the <code><a - * href="{@docRoot}guide/topics/manifest/application-element.html"><application></a></code> + * the <code> + * <a href="{@docRoot}guide/topics/manifest/application-element.html"><application></a></code> * tag's {@code android:backupAgent} attribute. + * + * <div class="special reference"> + * <h3>Developer Guides</h3> + * <p>For more information about using BackupAgent, read the + * <a href="{@docRoot}guide/topics/data/backup.html">Data Backup</a> developer guide.</p></div> + * * <h3>Basic Operation</h3> * <p> * When the application makes changes to data that it wishes to keep backed up, diff --git a/core/java/android/app/backup/BackupAgentHelper.java b/core/java/android/app/backup/BackupAgentHelper.java index d47ca22..45daead 100644 --- a/core/java/android/app/backup/BackupAgentHelper.java +++ b/core/java/android/app/backup/BackupAgentHelper.java @@ -42,6 +42,12 @@ import java.io.IOException; * {@link BackupAgentHelper} framework. See the {@link BackupHelper} interface * documentation for details. * + * <div class="special reference"> + * <h3>Developer Guides</h3> + * <p>For more information about using BackupAgentHelper, read the + * <a href="{@docRoot}guide/topics/data/backup.html">Data Backup</a> developer guide.</p> + * </div> + * * @see BackupHelper * @see FileBackupHelper * @see SharedPreferencesBackupHelper diff --git a/core/java/android/app/backup/BackupManager.java b/core/java/android/app/backup/BackupManager.java index 80656a1..6eebed2 100644 --- a/core/java/android/app/backup/BackupManager.java +++ b/core/java/android/app/backup/BackupManager.java @@ -41,10 +41,15 @@ import android.util.Log; * of how the operation then proceeds. * <p> * Several attributes affecting the operation of the backup and restore mechanism - * can be set on the <code><a - * href="{@docRoot}guide/topics/manifest/application-element.html"><application></a></code> + * can be set on the <code> + * <a href="{@docRoot}guide/topics/manifest/application-element.html"><application></a></code> * tag in your application's AndroidManifest.xml file. * + * <div class="special reference"> + * <h3>Developer Guides</h3> + * <p>For more information about using BackupManager, read the + * <a href="{@docRoot}guide/topics/data/backup.html">Data Backup</a> developer guide.</p></div> + * * @attr ref android.R.styleable#AndroidManifestApplication_allowBackup * @attr ref android.R.styleable#AndroidManifestApplication_backupAgent * @attr ref android.R.styleable#AndroidManifestApplication_killAfterRestore 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/content/SharedPreferences.java b/core/java/android/content/SharedPreferences.java index 4d9ee54..bdc38d6 100644 --- a/core/java/android/content/SharedPreferences.java +++ b/core/java/android/content/SharedPreferences.java @@ -30,6 +30,12 @@ import java.util.Set; * <p><em>Note: currently this class does not support use across multiple * processes. This will be added later.</em> * + * <div class="special reference"> + * <h3>Developer Guides</h3> + * <p>For more information about using SharedPreferences, read the + * <a href="{@docRoot}guide/topics/data/data-storage.html#pref">Data Storage</a> + * developer guide.</p></div> + * * @see Context#getSharedPreferences */ public interface SharedPreferences { diff --git a/core/java/android/database/CursorWindow.java b/core/java/android/database/CursorWindow.java index a18a721..a1be121 100644 --- a/core/java/android/database/CursorWindow.java +++ b/core/java/android/database/CursorWindow.java @@ -55,6 +55,7 @@ public class CursorWindow extends SQLiteClosable implements Parcelable { public int mWindowPtr; private int mStartPos; + private final String mName; private final CloseGuard mCloseGuard = CloseGuard.get(); @@ -85,6 +86,8 @@ public class CursorWindow extends SQLiteClosable implements Parcelable { private static native boolean nativePutDouble(int windowPtr, double value, int row, int column); private static native boolean nativePutNull(int windowPtr, int row, int column); + private static native String nativeGetName(int windowPtr); + /** * Creates a new empty cursor window and gives it a name. * <p> @@ -100,6 +103,7 @@ public class CursorWindow extends SQLiteClosable implements Parcelable { */ public CursorWindow(String name, boolean localWindow) { mStartPos = 0; + mName = name; mWindowPtr = nativeCreate(name, sCursorWindowSize, localWindow); if (mWindowPtr == 0) { throw new CursorWindowAllocationException("Cursor window allocation of " + @@ -130,6 +134,7 @@ public class CursorWindow extends SQLiteClosable implements Parcelable { throw new CursorWindowAllocationException("Cursor window could not be " + "created from binder."); } + mName = nativeGetName(mWindowPtr); mCloseGuard.open("close"); } @@ -157,6 +162,14 @@ public class CursorWindow extends SQLiteClosable implements Parcelable { } /** + * Gets the name of this cursor window. + * @hide + */ + public String getName() { + return mName; + } + + /** * Closes the cursor window and frees its underlying resources when all other * remaining references have been released. */ @@ -478,7 +491,7 @@ public class CursorWindow extends SQLiteClosable implements Parcelable { } acquireReference(); try { - nativeCopyStringToBuffer(mWindowPtr, row, column, buffer); + nativeCopyStringToBuffer(mWindowPtr, row - mStartPos, column, buffer); } finally { releaseReference(); } @@ -778,4 +791,9 @@ public class CursorWindow extends SQLiteClosable implements Parcelable { String s = (buff.length() > 980) ? buff.substring(0, 980) : buff.toString(); return "# Open Cursors=" + total + s; } + + @Override + public String toString() { + return getName() + " {" + Integer.toHexString(mWindowPtr) + "}"; + } } diff --git a/core/java/android/database/sqlite/SQLiteDatabase.java b/core/java/android/database/sqlite/SQLiteDatabase.java index 00d7ce8..f990be6 100644 --- a/core/java/android/database/sqlite/SQLiteDatabase.java +++ b/core/java/android/database/sqlite/SQLiteDatabase.java @@ -306,10 +306,6 @@ public class SQLiteDatabase extends SQLiteClosable { /** Used to find out where this object was created in case it never got closed. */ private final Throwable mStackTrace; - // System property that enables logging of slow queries. Specify the threshold in ms. - private static final String LOG_SLOW_QUERIES_PROPERTY = "db.log.slow_query_threshold"; - private final int mSlowQueryThreshold; - /** stores the list of statement ids that need to be finalized by sqlite */ private final ArrayList<Integer> mClosedStatementIds = new ArrayList<Integer>(); @@ -1559,11 +1555,6 @@ public class SQLiteDatabase extends SQLiteClosable { String editTable) { verifyDbIsOpen(); BlockGuard.getThreadPolicy().onReadFromDisk(); - long timeStart = 0; - - if (false || mSlowQueryThreshold != -1) { - timeStart = System.currentTimeMillis(); - } SQLiteDatabase db = getDbConnection(sql); SQLiteCursorDriver driver = new SQLiteDirectCursorDriver(db, sql, editTable); @@ -1574,24 +1565,6 @@ public class SQLiteDatabase extends SQLiteClosable { cursorFactory != null ? cursorFactory : mFactory, selectionArgs); } finally { - if (false || mSlowQueryThreshold != -1) { - - // Force query execution - int count = -1; - if (cursor != null) { - count = cursor.getCount(); - } - - long duration = System.currentTimeMillis() - timeStart; - - if (false || duration >= mSlowQueryThreshold) { - Log.v(SQLiteCursor.TAG, - "query (" + duration + " ms): " + driver.toString() + ", args are " - + (selectionArgs != null - ? TextUtils.join(",", selectionArgs) - : "<null>") + ", count is " + count); - } - } releaseDbConnection(db); } return cursor; @@ -1967,7 +1940,6 @@ public class SQLiteDatabase extends SQLiteClosable { setMaxSqlCacheSize(DEFAULT_SQL_CACHE_SIZE); mFlags = flags; mPath = path; - mSlowQueryThreshold = SystemProperties.getInt(LOG_SLOW_QUERIES_PROPERTY, -1); mStackTrace = new DatabaseObjectNotClosedException().fillInStackTrace(); mFactory = factory; mPrograms = new WeakHashMap<SQLiteClosable,Object>(); diff --git a/core/java/android/database/sqlite/SQLiteDebug.java b/core/java/android/database/sqlite/SQLiteDebug.java index 9496079..cc057e0 100644 --- a/core/java/android/database/sqlite/SQLiteDebug.java +++ b/core/java/android/database/sqlite/SQLiteDebug.java @@ -18,6 +18,8 @@ package android.database.sqlite; import java.util.ArrayList; +import android.os.Build; +import android.os.SystemProperties; import android.util.Log; /** @@ -65,6 +67,28 @@ public final class SQLiteDebug { Log.isLoggable("SQLiteLockStackTrace", Log.VERBOSE); /** + * True to enable database performance testing instrumentation. + * @hide + */ + public static final boolean DEBUG_LOG_SLOW_QUERIES = Build.IS_DEBUGGABLE; + + /** + * Determines whether a query should be logged. + * + * Reads the "db.log.slow_query_threshold" system property, which can be changed + * by the user at any time. If the value is zero, then all queries will + * be considered slow. If the value does not exist, then no queries will + * be considered slow. + * + * This value can be changed dynamically while the system is running. + * @hide + */ + public static final boolean shouldLogSlowQuery(long elapsedTimeMillis) { + int slowQueryMillis = SystemProperties.getInt("db.log.slow_query_threshold", -1); + return slowQueryMillis >= 0 && elapsedTimeMillis > slowQueryMillis; + } + + /** * Contains statistics about the active pagers in the current process. * * @see #getPagerStats(PagerStats) diff --git a/core/java/android/database/sqlite/SQLiteQuery.java b/core/java/android/database/sqlite/SQLiteQuery.java index 7db0914..faf6cba 100644 --- a/core/java/android/database/sqlite/SQLiteQuery.java +++ b/core/java/android/database/sqlite/SQLiteQuery.java @@ -18,6 +18,7 @@ package android.database.sqlite; import android.database.CursorWindow; import android.os.SystemClock; +import android.text.TextUtils; import android.util.Log; /** @@ -32,6 +33,7 @@ public class SQLiteQuery extends SQLiteProgram { private static native int nativeFillWindow(int databasePtr, int statementPtr, int windowPtr, int startPos, int offsetParam); + private static native int nativeColumnCount(int statementPtr); private static native String nativeColumnName(int statementPtr, int columnIndex); @@ -80,8 +82,24 @@ public class SQLiteQuery extends SQLiteProgram { acquireReference(); try { window.acquireReference(); + int startPos = window.getStartPosition(); int numRows = nativeFillWindow(nHandle, nStatement, window.mWindowPtr, - window.getStartPosition(), mOffsetIndex); + startPos, mOffsetIndex); + if (SQLiteDebug.DEBUG_LOG_SLOW_QUERIES) { + long elapsed = SystemClock.uptimeMillis() - timeStart; + if (SQLiteDebug.shouldLogSlowQuery(elapsed)) { + Log.d(TAG, "fillWindow took " + elapsed + + " ms: window=\"" + window + + "\", startPos=" + startPos + + ", offset=" + mOffsetIndex + + ", filledRows=" + window.getNumRows() + + ", countedRows=" + numRows + + ", query=\"" + mSql + "\"" + + ", args=[" + (mBindArgs != null ? + TextUtils.join(", ", mBindArgs.values()) : "") + + "]"); + } + } mDatabase.logTimeStat(mSql, timeStart); return numRows; } catch (IllegalStateException e){ diff --git a/core/java/android/hardware/Camera.java b/core/java/android/hardware/Camera.java index caad6fd..68f0247 100644 --- a/core/java/android/hardware/Camera.java +++ b/core/java/android/hardware/Camera.java @@ -1687,15 +1687,18 @@ public class Camera { * aggressive than {@link #FOCUS_MODE_CONTINUOUS_VIDEO}. Auto focus * starts when the parameter is set. * - * <p>If applications call {@link #autoFocus(AutoFocusCallback)} in this - * mode, the focus callback will immediately return with a boolean that - * indicates whether the focus is sharp or not. The apps can then decide - * if they want to take a picture immediately or to change the focus - * mode to auto, and run a full autofocus cycle. The focus position is - * locked after autoFocus call. If applications want to resume the - * continuous focus, cancelAutoFocus must be called. Restarting the - * preview will not resume the continuous autofocus. To stop continuous - * focus, applications should change the focus mode to other modes. + * <p>Applications can call {@link #autoFocus(AutoFocusCallback)} in + * this mode. If the autofocus is in the middle of scanning, the focus + * callback will return when it completes. If the autofocus is not + * scanning, the focus callback will immediately return with a boolean + * that indicates whether the focus is sharp or not. The apps can then + * decide if they want to take a picture immediately or to change the + * focus mode to auto, and run a full autofocus cycle. The focus + * position is locked after autoFocus call. If applications want to + * resume the continuous focus, cancelAutoFocus must be called. + * Restarting the preview will not resume the continuous autofocus. To + * stop continuous focus, applications should change the focus mode to + * other modes. * * @see #FOCUS_MODE_CONTINUOUS_VIDEO */ diff --git a/core/java/android/nfc/NfcFragment.java b/core/java/android/nfc/NfcFragment.java index 17278dc..d6b15ad 100644 --- a/core/java/android/nfc/NfcFragment.java +++ b/core/java/android/nfc/NfcFragment.java @@ -48,7 +48,10 @@ public final class NfcFragment extends Fragment { FragmentManager manager = activity.getFragmentManager(); Fragment fragment = manager.findFragmentByTag(FRAGMENT_TAG); if (fragment != null) { - manager.beginTransaction().remove(fragment).commit(); + // We allow state loss at this point, because the state is only + // lost when activity is being paused *AND* subsequently destroyed. + // In that case, the app will setup foreground dispatch again anyway. + manager.beginTransaction().remove(fragment).commitAllowingStateLoss(); } } diff --git a/core/java/android/os/Build.java b/core/java/android/os/Build.java index 5faab36..17a882d 100644 --- a/core/java/android/os/Build.java +++ b/core/java/android/os/Build.java @@ -326,6 +326,13 @@ public class Build { public static final String HOST = getString("ro.build.host"); /** + * Returns true if we are running a debug build such as "user-debug" or "eng". + * @hide + */ + public static final boolean IS_DEBUGGABLE = + SystemProperties.getInt("ro.debuggable", 0) == 1; + + /** * Returns the version string for the radio firmware. May return * null (if, for instance, the radio is not currently on). */ diff --git a/core/java/android/os/INetworkManagementService.aidl b/core/java/android/os/INetworkManagementService.aidl index be87946..6ecc640 100644 --- a/core/java/android/os/INetworkManagementService.aidl +++ b/core/java/android/os/INetworkManagementService.aidl @@ -105,6 +105,18 @@ interface INetworkManagementService void removeRoute(String iface, in RouteInfo route); /** + * Add the specified route to a secondary interface + * This will go into a special route table to be accessed + * via ip rules + */ + void addSecondaryRoute(String iface, in RouteInfo route); + + /** + * Remove the specified secondary route. + */ + void removeSecondaryRoute(String iface, in RouteInfo route); + + /** * Shuts down the service */ void shutdown(); diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index 5754e60..a0652f7 100644 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -3620,6 +3620,13 @@ public final class Settings { "pdp_watchdog_max_pdp_reset_fail_count"; /** + * The number of milliseconds to delay when checking for data stalls + * @hide + */ + public static final String DATA_STALL_ALARM_DELAY_IN_MS = + "data_stall_alarm_delay_in_ms"; + + /** * The interval in milliseconds at which to check gprs registration * after the first registration mismatch of gprs and voice service, * to detect possible data network registration problems. diff --git a/core/java/android/service/textservice/package.html b/core/java/android/service/textservice/package.html index b498719..0b5113b 100644 --- a/core/java/android/service/textservice/package.html +++ b/core/java/android/service/textservice/package.html @@ -31,8 +31,10 @@ checker. For example:</p> </service> </pre> -<p>For example code, see the <a +<p>For example code, see the sample <a href="{@docRoot}resources/samples/SpellChecker/SampleSpellCheckerService/index.html">Spell -Checker</a> sample app.</p> +Checker service</a> app, and the sample <a +href="{@docRoot}resources/samples/SpellChecker/HelloSpellChecker/index.html">Spell +Checker client</a> app.</p> </BODY> </HTML> diff --git a/core/java/android/view/VolumePanel.java b/core/java/android/view/VolumePanel.java index 83df8a5..b657204 100644 --- a/core/java/android/view/VolumePanel.java +++ b/core/java/android/view/VolumePanel.java @@ -352,6 +352,10 @@ public class VolumePanel extends Handler implements OnSeekBarChangeListener, Vie sc.seekbarView.setProgress(mAudioManager.getLastAudibleStreamVolume(sc.streamType)); final boolean muted = isMuted(sc.streamType); sc.icon.setImageResource(muted ? sc.iconMuteRes : sc.iconRes); + if (sc.streamType == AudioManager.STREAM_RING && muted + && mAudioManager.shouldVibrate(AudioManager.VIBRATE_TYPE_RINGER)) { + sc.icon.setImageResource(R.drawable.ic_audio_ring_notif_vibrate); + } sc.seekbarView.setEnabled(!muted); } @@ -695,8 +699,14 @@ public class VolumePanel extends Handler implements OnSeekBarChangeListener, Vie expand(); } else if (v.getTag() instanceof StreamControl) { StreamControl sc = (StreamControl) v.getTag(); - mAudioManager.setRingerMode(mAudioManager.isSilentMode() - ? AudioManager.RINGER_MODE_NORMAL : AudioManager.RINGER_MODE_SILENT); + boolean vibeInSilent = Settings.System.getInt(mContext.getContentResolver(), + System.VIBRATE_IN_SILENT, 1) == 1; + int newMode = mAudioManager.isSilentMode() + ? AudioManager.RINGER_MODE_NORMAL + : (vibeInSilent + ? AudioManager.RINGER_MODE_VIBRATE + : AudioManager.RINGER_MODE_SILENT); + mAudioManager.setRingerMode(newMode); // Expand the dialog if it hasn't been expanded yet. if (mShowCombinedVolumes && !isExpanded()) expand(); } diff --git a/core/java/android/widget/AdapterView.java b/core/java/android/widget/AdapterView.java index 5d01a0f..40df168 100644 --- a/core/java/android/widget/AdapterView.java +++ b/core/java/android/widget/AdapterView.java @@ -38,6 +38,12 @@ import android.view.accessibility.AccessibilityNodeInfo; * <p> * See {@link ListView}, {@link GridView}, {@link Spinner} and * {@link Gallery} for commonly used subclasses of AdapterView. + * + * <div class="special reference"> + * <h3>Developer Guides</h3> + * <p>For more information about using AdapterView, read the + * <a href="{@docRoot}guide/topics/ui/binding.html">Binding to Data with AdapterView</a> + * developer guide.</p></div> */ public abstract class AdapterView<T extends Adapter> extends ViewGroup { diff --git a/core/java/android/widget/PopupWindow.java b/core/java/android/widget/PopupWindow.java index 8ba7bee..5fa4ad0 100644 --- a/core/java/android/widget/PopupWindow.java +++ b/core/java/android/widget/PopupWindow.java @@ -1248,6 +1248,8 @@ public class PopupWindow { */ public void dismiss() { if (isShowing() && mPopupView != null) { + mIsShowing = false; + unregisterForScrollChanged(); try { @@ -1257,7 +1259,6 @@ public class PopupWindow { ((ViewGroup) mPopupView).removeView(mContentView); } mPopupView = null; - mIsShowing = false; if (mOnDismissListener != null) { mOnDismissListener.onDismiss(); diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java index 7f03adf..0a2365e 100644 --- a/core/java/android/widget/TextView.java +++ b/core/java/android/widget/TextView.java @@ -9409,8 +9409,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener return false; } - int posX = mPositionX + positionX - getScrollX(); - int posY = mPositionY + positionY - getScrollY(); + int posX = mPositionX + positionX; + int posY = mPositionY + positionY; // Offset by 1 to take into account 0.5 and int rounding around getPrimaryHorizontal. return posX >= clip.left - 1 && posX <= clip.right + 1 && @@ -9421,7 +9421,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener final int line = mLayout.getLineForOffset(offset); final int lineBottom = mLayout.getLineBottom(line); final int primaryHorizontal = (int) mLayout.getPrimaryHorizontal(offset); - return isVisible(primaryHorizontal, lineBottom); + return isVisible(primaryHorizontal + viewportToContentHorizontalOffset(), + lineBottom + viewportToContentVerticalOffset()); } public void onScrollChanged() { @@ -10561,7 +10562,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener mPositionX = (int) (mLayout.getPrimaryHorizontal(offset) - 0.5f - mHotspotX); mPositionY = mLayout.getLineBottom(line); - // Take TextView's padding into account. + // Take TextView's padding and scroll into account. mPositionX += viewportToContentHorizontalOffset(); mPositionY += viewportToContentVerticalOffset(); |
