diff options
Diffstat (limited to 'core/java')
29 files changed, 355 insertions, 61 deletions
diff --git a/core/java/android/accounts/AccountManagerService.java b/core/java/android/accounts/AccountManagerService.java index 894e196..93983a6 100644 --- a/core/java/android/accounts/AccountManagerService.java +++ b/core/java/android/accounts/AccountManagerService.java @@ -1786,22 +1786,6 @@ public class AccountManagerService } } - private String getMetaValue(String key) { - synchronized (mCacheLock) { - final SQLiteDatabase db = mOpenHelper.getReadableDatabase(); - Cursor c = db.query(TABLE_META, - new String[]{META_VALUE}, META_KEY + "=?", new String[]{key}, null, null, null); - try { - if (c.moveToNext()) { - return c.getString(0); - } - return null; - } finally { - c.close(); - } - } - } - public IBinder onBind(Intent intent) { return asBinder(); } diff --git a/core/java/android/app/Dialog.java b/core/java/android/app/Dialog.java index 087753b..82186dd 100644 --- a/core/java/android/app/Dialog.java +++ b/core/java/android/app/Dialog.java @@ -931,7 +931,7 @@ public class Dialog implements DialogInterface, Window.Callback, // associate search with owner activity final ComponentName appName = getAssociatedActivity(); - if (appName != null) { + if (appName != null && searchManager.getSearchableInfo(appName) != null) { searchManager.startSearch(null, false, appName, null, false); dismiss(); return true; diff --git a/core/java/android/bluetooth/BluetoothAdapter.java b/core/java/android/bluetooth/BluetoothAdapter.java index e1c9044..88e00b3 100644 --- a/core/java/android/bluetooth/BluetoothAdapter.java +++ b/core/java/android/bluetooth/BluetoothAdapter.java @@ -873,10 +873,10 @@ public final class BluetoothAdapter { /** * Create a listening, insecure RFCOMM Bluetooth socket with Service Record. - * <p>The link key will be unauthenticated i.e the communication is + * <p>The link key is not required to be authenticated, i.e the communication may be * vulnerable to Man In the Middle attacks. For Bluetooth 2.1 devices, - * the link key will be encrypted, as encryption is mandartory. - * For legacy devices (pre Bluetooth 2.1 devices) the link key will not + * the link will be encrypted, as encryption is mandartory. + * For legacy devices (pre Bluetooth 2.1 devices) the link will not * be encrypted. Use {@link #listenUsingRfcommWithServiceRecord}, if an * encrypted and authenticated communication channel is desired. * <p>Use {@link BluetoothServerSocket#accept} to retrieve incoming @@ -902,6 +902,44 @@ public final class BluetoothAdapter { return createNewRfcommSocketAndRecord(name, uuid, false, false); } + /** + * Create a listening, encrypted, + * RFCOMM Bluetooth socket with Service Record. + * <p>The link will be encrypted, but the link key is not required to be authenticated + * i.e the communication is vulnerable to Man In the Middle attacks. Use + * {@link #listenUsingRfcommWithServiceRecord}, to ensure an authenticated link key. + * <p> Use this socket if authentication of link key is not possible. + * For example, for Bluetooth 2.1 devices, if any of the devices does not have + * an input and output capability or just has the ability to display a numeric key, + * a secure socket connection is not possible and this socket can be used. + * Use {@link #listenUsingInsecureRfcommWithServiceRecord}, if encryption is not required. + * For Bluetooth 2.1 devices, the link will be encrypted, as encryption is mandartory. + * For more details, refer to the Security Model section 5.2 (vol 3) of + * Bluetooth Core Specification version 2.1 + EDR. + * <p>Use {@link BluetoothServerSocket#accept} to retrieve incoming + * connections from a listening {@link BluetoothServerSocket}. + * <p>The system will assign an unused RFCOMM channel to listen on. + * <p>The system will also register a Service Discovery + * Protocol (SDP) record with the local SDP server containing the specified + * UUID, service name, and auto-assigned channel. Remote Bluetooth devices + * can use the same UUID to query our SDP server and discover which channel + * to connect to. This SDP record will be removed when this socket is + * closed, or if this application closes unexpectedly. + * <p>Use {@link BluetoothDevice#createRfcommSocketToServiceRecord} to + * connect to this socket from another device using the same {@link UUID}. + * <p>Requires {@link android.Manifest.permission#BLUETOOTH} + * @param name service name for SDP record + * @param uuid uuid for SDP record + * @return a listening RFCOMM BluetoothServerSocket + * @throws IOException on error, for example Bluetooth not available, or + * insufficient permissions, or channel in use. + * @hide + */ + public BluetoothServerSocket listenUsingEncryptedRfcommWithServiceRecord( + String name, UUID uuid) throws IOException { + return createNewRfcommSocketAndRecord(name, uuid, false, true); + } + private BluetoothServerSocket createNewRfcommSocketAndRecord(String name, UUID uuid, boolean auth, boolean encrypt) throws IOException { RfcommChannelPicker picker = new RfcommChannelPicker(uuid); @@ -973,6 +1011,28 @@ public final class BluetoothAdapter { return socket; } + /** + * Construct an encrypted, RFCOMM server socket. + * Call #accept to retrieve connections to this socket. + * @return An RFCOMM BluetoothServerSocket + * @throws IOException On error, for example Bluetooth not available, or + * insufficient permissions. + * @hide + */ + public BluetoothServerSocket listenUsingEncryptedRfcommOn(int port) + throws IOException { + BluetoothServerSocket socket = new BluetoothServerSocket( + BluetoothSocket.TYPE_RFCOMM, false, true, port); + int errno = socket.mSocket.bindListen(); + if (errno != 0) { + try { + socket.close(); + } catch (IOException e) {} + socket.mSocket.throwErrnoNative(errno); + } + return socket; + } + /** * Construct a SCO server socket. * Call #accept to retrieve connections to this socket. diff --git a/core/java/android/bluetooth/BluetoothDeviceProfileState.java b/core/java/android/bluetooth/BluetoothDeviceProfileState.java index 6f3a2e7..56f236d 100644 --- a/core/java/android/bluetooth/BluetoothDeviceProfileState.java +++ b/core/java/android/bluetooth/BluetoothDeviceProfileState.java @@ -679,7 +679,6 @@ public final class BluetoothDeviceProfileState extends StateMachine { @Override public boolean processMessage(Message message) { log("IncomingA2dp State->Processing Message: " + message.what); - Message deferMsg = new Message(); switch(message.what) { case CONNECT_HFP_OUTGOING: deferMessage(message); diff --git a/core/java/android/content/res/AssetManager.java b/core/java/android/content/res/AssetManager.java index 72fca0a..dbb4271 100644 --- a/core/java/android/content/res/AssetManager.java +++ b/core/java/android/content/res/AssetManager.java @@ -235,6 +235,7 @@ public final class AssetManager { StringBlock[] blocks = mStringBlocks; if (blocks == null) { ensureStringBlocks(); + blocks = mStringBlocks; } outValue.string = blocks[block].get(outValue.data); return true; diff --git a/core/java/android/hardware/Sensor.java b/core/java/android/hardware/Sensor.java index f2b907b..595c7d1 100644 --- a/core/java/android/hardware/Sensor.java +++ b/core/java/android/hardware/Sensor.java @@ -97,6 +97,13 @@ public class Sensor { */ public static final int TYPE_ROTATION_VECTOR = 11; + /** + * A constant describing a relative humidity sensor type. + * See {@link android.hardware.SensorEvent SensorEvent} + * for more details. + */ + public static final int TYPE_RELATIVE_HUMIDITY = 12; + /** * A constant describing all sensor types. */ diff --git a/core/java/android/hardware/SensorEvent.java b/core/java/android/hardware/SensorEvent.java index 78d7991..9b62a68 100644 --- a/core/java/android/hardware/SensorEvent.java +++ b/core/java/android/hardware/SensorEvent.java @@ -304,7 +304,65 @@ public class SensorEvent { * in the clockwise direction (mathematically speaking, it should be * positive in the counter-clockwise direction). * </p> - * + * + * <h4>{@link android.hardware.Sensor#TYPE_RELATIVE_HUMIDITY + * Sensor.TYPE_RELATIVE_HUMIDITY}:</h4> + * <ul> + * <p> + * values[0]: Relative ambient air humidity in percent + * </p> + * </ul> + * <p> + * When relative ambient air humidity and ambient temperature are + * measured, the dew point and absolute humidity can be calculated. + * </p> + * <u>Dew Point</u> + * <p> + * The dew point is the temperature to which a given parcel of air must be + * cooled, at constant barometric pressure, for water vapor to condense + * into water. + * </p> + * <center><pre> + * ln(RH/100%) + m·t/(T<sub>n</sub>+t) + * t<sub>d</sub>(t,RH) = T<sub>n</sub> · ------------------------------ + * m - [ln(RH/100%) + m·t/(T<sub>n</sub>+t)] + * </pre></center> + * <dl> + * <dt>t<sub>d</sub></dt> <dd>dew point temperature in °C</dd> + * <dt>t</dt> <dd>actual temperature in °C</dd> + * <dt>RH</dt> <dd>actual relative humidity in %</dd> + * <dt>m</dt> <dd>17.62</dd> + * <dt>T<sub>n</sub></dt> <dd>243.12 °C</dd> + * </dl> + * <p>for example:</p> + * <pre class="prettyprint"> + * h = Math.log(rh / 100.0) + (17.62 * t) / (243.12 + t); + * td = 243.12 * h / (17.62 - h); + * </pre> + * <u>Absolute Humidity</u> + * <p> + * The absolute humidity is the mass of water vapor in a particular volume + * of dry air. The unit is g/m<sup>3</sup>. + * </p> + * <center><pre> + * RH/100%·A·exp(m·t/(T<sub>n</sub>+t)) + * d<sub>v</sub>(t,RH) = 216.7 · ------------------------- + * 273.15 + t + * </pre></center> + * <dl> + * <dt>d<sub>v</sub></dt> <dd>absolute humidity in g/m<sup>3</sup></dd> + * <dt>t</dt> <dd>actual temperature in °C</dd> + * <dt>RH</dt> <dd>actual relative humidity in %</dd> + * <dt>m</dt> <dd>17.62</dd> + * <dt>T<sub>n</sub></dt> <dd>243.12 °C</dd> + * <dt>A</dt> <dd>6.112 hPa</dd> + * </dl> + * <p>for example:</p> + * <pre class="prettyprint"> + * dv = 216.7 * + * (rh / 100.0 * 6.112 * Math.exp(17.62 * t / (243.12 + t)) / (273.15 + t)); + * </pre> + * * @see SensorEvent * @see GeomagneticField */ diff --git a/core/java/android/nfc/ApduList.aidl b/core/java/android/nfc/ApduList.aidl new file mode 100644 index 0000000..f6236b2 --- /dev/null +++ b/core/java/android/nfc/ApduList.aidl @@ -0,0 +1,19 @@ +/* + * 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 android.nfc; + +parcelable ApduList;
\ No newline at end of file diff --git a/core/java/android/nfc/ApduList.java b/core/java/android/nfc/ApduList.java new file mode 100644 index 0000000..85b0547 --- /dev/null +++ b/core/java/android/nfc/ApduList.java @@ -0,0 +1,68 @@ +package android.nfc; + +import android.os.Parcel; +import android.os.Parcelable; + +import java.util.ArrayList; +import java.util.List; + +/** + * @hide + */ +public class ApduList implements Parcelable { + + private ArrayList<byte[]> commands = new ArrayList<byte[]>(); + + public ApduList() { + } + + public void add(byte[] command) { + commands.add(command); + } + + public List<byte[]> get() { + return commands; + } + + public static final Parcelable.Creator<ApduList> CREATOR = + new Parcelable.Creator<ApduList>() { + @Override + public ApduList createFromParcel(Parcel in) { + return new ApduList(in); + } + + @Override + public ApduList[] newArray(int size) { + return new ApduList[size]; + } + }; + + private ApduList(Parcel in) { + int count = in.readInt(); + + for (int i = 0 ; i < count ; i++) { + + int length = in.readInt(); + byte[] cmd = new byte[length]; + in.readByteArray(cmd); + commands.add(cmd); + } + } + + @Override + public int describeContents() { + return 0; + } + + @Override + public void writeToParcel(Parcel dest, int flags) { + dest.writeInt(commands.size()); + + for (byte[] cmd : commands) { + dest.writeInt(cmd.length); + dest.writeByteArray(cmd); + } + } +} + + diff --git a/core/java/android/nfc/INfcAdapterExtras.aidl b/core/java/android/nfc/INfcAdapterExtras.aidl index ab5c1a6..8677a50 100755 --- a/core/java/android/nfc/INfcAdapterExtras.aidl +++ b/core/java/android/nfc/INfcAdapterExtras.aidl @@ -16,8 +16,10 @@ package android.nfc; +import android.nfc.ApduList; import android.os.Bundle; + /** * {@hide} */ @@ -26,5 +28,7 @@ interface INfcAdapterExtras { Bundle close(); Bundle transceive(in byte[] data_in); int getCardEmulationRoute(); - void setCardEmulationRoute(int route); + void setCardEmulationRoute(int route); + void registerTearDownApdus(String packageName, in ApduList apdu); + void unregisterTearDownApdus(String packageName); } diff --git a/core/java/android/os/BatteryStats.java b/core/java/android/os/BatteryStats.java index 90e2e79..1d6bc4e 100644 --- a/core/java/android/os/BatteryStats.java +++ b/core/java/android/os/BatteryStats.java @@ -1883,7 +1883,6 @@ public abstract class BatteryStats implements Parcelable { final int NU = uidStats.size(); boolean didPid = false; long nowRealtime = SystemClock.elapsedRealtime(); - StringBuilder sb = new StringBuilder(64); for (int i=0; i<NU; i++) { Uid uid = uidStats.valueAt(i); SparseArray<? extends Uid.Pid> pids = uid.getPidStats(); diff --git a/core/java/android/os/Looper.java b/core/java/android/os/Looper.java index 8204e3c..ccf642c 100644 --- a/core/java/android/os/Looper.java +++ b/core/java/android/os/Looper.java @@ -141,7 +141,8 @@ public class Looper { Log.wtf("Looper", "Thread identity changed from 0x" + Long.toHexString(ident) + " to 0x" + Long.toHexString(newIdent) + " while dispatching to " - + msg.target + " " + msg.callback + " what=" + msg.what); + + msg.target.getClass().getName() + " " + + msg.callback + " what=" + msg.what); } msg.recycle(); diff --git a/core/java/android/os/Process.java b/core/java/android/os/Process.java index 0c6ab9e..2bfada0 100644 --- a/core/java/android/os/Process.java +++ b/core/java/android/os/Process.java @@ -95,7 +95,7 @@ public class Process { * Defines the UID/GID for the NFC service process. * @hide */ - public static final int NFC_UID = 1022; + public static final int NFC_UID = 1025; /** * Defines the GID for the group that allows write access to the internal media storage. diff --git a/core/java/android/os/RecoverySystem.java b/core/java/android/os/RecoverySystem.java index 4991914..c1dd911 100644 --- a/core/java/android/os/RecoverySystem.java +++ b/core/java/android/os/RecoverySystem.java @@ -16,6 +16,11 @@ package android.os; +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.util.Log; + import java.io.ByteArrayInputStream; import java.io.File; import java.io.FileNotFoundException; @@ -37,9 +42,6 @@ import java.util.List; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; -import android.content.Context; -import android.util.Log; - import org.apache.harmony.security.asn1.BerInputStream; import org.apache.harmony.security.pkcs7.ContentInfo; import org.apache.harmony.security.pkcs7.SignedData; @@ -336,8 +338,21 @@ public class RecoverySystem { * @throws IOException if writing the recovery command file * fails, or if the reboot itself fails. */ - public static void rebootWipeUserData(Context context) - throws IOException { + public static void rebootWipeUserData(Context context) throws IOException { + final ConditionVariable condition = new ConditionVariable(); + + Intent intent = new Intent("android.intent.action.MASTER_CLEAR_NOTIFICATION"); + context.sendOrderedBroadcast(intent, android.Manifest.permission.MASTER_CLEAR, + new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + condition.open(); + } + }, null, 0, null, null); + + // Block until the ordered broadcast has completed. + condition.block(); + bootCommand(context, "--wipe_data"); } diff --git a/core/java/android/provider/Telephony.java b/core/java/android/provider/Telephony.java index d2d2557..3a06b61 100644 --- a/core/java/android/provider/Telephony.java +++ b/core/java/android/provider/Telephony.java @@ -542,7 +542,7 @@ public final class Telephony { * values:</p> * * <ul> - * <li><em>pdus</em> - An Object[] od byte[]s containing the PDUs + * <li><em>pdus</em> - An Object[] of byte[]s containing the PDUs * that make up the message.</li> * </ul> * @@ -586,6 +586,46 @@ public final class Telephony { "android.provider.Telephony.WAP_PUSH_RECEIVED"; /** + * Broadcast Action: A new Cell Broadcast message has been received + * by the device. The intent will have the following extra + * values:</p> + * + * <ul> + * <li><em>pdus</em> - An Object[] of byte[]s containing the PDUs + * that make up the message.</li> + * </ul> + * + * <p>The extra values can be extracted using + * {@link #getMessagesFromIntent(Intent)}.</p> + * + * <p>If a BroadcastReceiver encounters an error while processing + * this intent it should set the result code appropriately.</p> + */ + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String SMS_CB_RECEIVED_ACTION = + "android.provider.Telephony.SMS_CB_RECEIVED"; + + /** + * Broadcast Action: A new Emergency Broadcast message has been received + * by the device. The intent will have the following extra + * values:</p> + * + * <ul> + * <li><em>pdus</em> - An Object[] of byte[]s containing the PDUs + * that make up the message.</li> + * </ul> + * + * <p>The extra values can be extracted using + * {@link #getMessagesFromIntent(Intent)}.</p> + * + * <p>If a BroadcastReceiver encounters an error while processing + * this intent it should set the result code appropriately.</p> + */ + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String SMS_EMERGENCY_CB_RECEIVED_ACTION = + "android.provider.Telephony.SMS_EMERGENCY_CB_RECEIVED"; + + /** * Broadcast Action: The SIM storage for SMS messages is full. If * space is not freed, messages targeted for the SIM (class 2) may * not be saved. @@ -618,7 +658,7 @@ public final class Telephony { * @param intent the intent to read from * @return an array of SmsMessages for the PDUs */ - public static final SmsMessage[] getMessagesFromIntent( + public static SmsMessage[] getMessagesFromIntent( Intent intent) { Object[] messages = (Object[]) intent.getSerializableExtra("pdus"); byte[][] pduObjs = new byte[messages.length][]; diff --git a/core/java/android/server/BluetoothService.java b/core/java/android/server/BluetoothService.java index f98d275..b3cbf50 100644..100755 --- a/core/java/android/server/BluetoothService.java +++ b/core/java/android/server/BluetoothService.java @@ -1104,7 +1104,7 @@ public class BluetoothService extends IBluetooth.Stub { } /*package*/ synchronized boolean setBondState(String address, int state, int reason) { - mBondState.setBondState(address.toUpperCase(), state); + mBondState.setBondState(address.toUpperCase(), state, reason); return true; } diff --git a/core/java/android/speech/RecognitionService.java b/core/java/android/speech/RecognitionService.java index 75a5ed5..32b2d8f 100644 --- a/core/java/android/speech/RecognitionService.java +++ b/core/java/android/speech/RecognitionService.java @@ -68,6 +68,8 @@ public abstract class RecognitionService extends Service { private static final int MSG_CANCEL = 3; + private static final int MSG_RESET = 4; + private final Handler mHandler = new Handler() { @Override public void handleMessage(Message msg) { @@ -81,6 +83,10 @@ public abstract class RecognitionService extends Service { break; case MSG_CANCEL: dispatchCancel((IRecognitionListener) msg.obj); + break; + case MSG_RESET: + dispatchClearCallback(); + break; } } }; @@ -128,6 +134,10 @@ public abstract class RecognitionService extends Service { } } + private void dispatchClearCallback() { + mCurrentCallback = null; + } + private class StartListeningArgs { public final Intent mIntent; @@ -241,7 +251,7 @@ public abstract class RecognitionService extends Service { * @param error code is defined in {@link SpeechRecognizer} */ public void error(int error) throws RemoteException { - mCurrentCallback = null; + Message.obtain(mHandler, MSG_RESET).sendToTarget(); mListener.onError(error); } @@ -278,7 +288,7 @@ public abstract class RecognitionService extends Service { * {@link SpeechRecognizer#RESULTS_RECOGNITION} as a parameter */ public void results(Bundle results) throws RemoteException { - mCurrentCallback = null; + Message.obtain(mHandler, MSG_RESET).sendToTarget(); mListener.onResults(results); } diff --git a/core/java/android/text/Layout.java b/core/java/android/text/Layout.java index 1e4cca9..4107c5a 100644 --- a/core/java/android/text/Layout.java +++ b/core/java/android/text/Layout.java @@ -1170,7 +1170,7 @@ public abstract class Layout { if (h2 < 0.5f) h2 = 0.5f; - if (h1 == h2) { + if (Float.compare(h1, h2) == 0) { dest.moveTo(h1, top); dest.lineTo(h1, bottom); } else { diff --git a/core/java/android/text/TextUtils.java b/core/java/android/text/TextUtils.java index d5010c6..cdb7228 100644 --- a/core/java/android/text/TextUtils.java +++ b/core/java/android/text/TextUtils.java @@ -624,10 +624,16 @@ public class TextUtils { public CharSequence createFromParcel(Parcel p) { int kind = p.readInt(); - if (kind == 1) - return p.readString(); + String string = p.readString(); + if (string == null) { + return null; + } + + if (kind == 1) { + return string; + } - SpannableString sp = new SpannableString(p.readString()); + SpannableString sp = new SpannableString(string); while (true) { kind = p.readInt(); diff --git a/core/java/android/text/method/MultiTapKeyListener.java b/core/java/android/text/method/MultiTapKeyListener.java index 6d94788..2a739fa 100644 --- a/core/java/android/text/method/MultiTapKeyListener.java +++ b/core/java/android/text/method/MultiTapKeyListener.java @@ -116,7 +116,7 @@ public class MultiTapKeyListener extends BaseKeyListener content.replace(selStart, selEnd, String.valueOf(current).toUpperCase()); removeTimeouts(content); - Timeout t = new Timeout(content); + new Timeout(content); // for its side effects return true; } @@ -124,7 +124,7 @@ public class MultiTapKeyListener extends BaseKeyListener content.replace(selStart, selEnd, String.valueOf(current).toLowerCase()); removeTimeouts(content); - Timeout t = new Timeout(content); + new Timeout(content); // for its side effects return true; } @@ -140,7 +140,7 @@ public class MultiTapKeyListener extends BaseKeyListener content.replace(selStart, selEnd, val, ix, ix + 1); removeTimeouts(content); - Timeout t = new Timeout(content); + new Timeout(content); // for its side effects return true; } @@ -206,7 +206,7 @@ public class MultiTapKeyListener extends BaseKeyListener } removeTimeouts(content); - Timeout t = new Timeout(content); + new Timeout(content); // for its side effects // Set up the callback so we can remove the timeout if the // cursor moves. diff --git a/core/java/android/text/style/DrawableMarginSpan.java b/core/java/android/text/style/DrawableMarginSpan.java index 3c471a5..c2564d5 100644 --- a/core/java/android/text/style/DrawableMarginSpan.java +++ b/core/java/android/text/style/DrawableMarginSpan.java @@ -50,9 +50,6 @@ implements LeadingMarginSpan, LineHeightSpan int dw = mDrawable.getIntrinsicWidth(); int dh = mDrawable.getIntrinsicHeight(); - if (dir < 0) - x -= dw; - // XXX What to do about Paint? mDrawable.setBounds(ix, itop, ix+dw, itop+dh); mDrawable.draw(c); diff --git a/core/java/android/text/util/Rfc822Tokenizer.java b/core/java/android/text/util/Rfc822Tokenizer.java index 69cf93c..68334e4 100644 --- a/core/java/android/text/util/Rfc822Tokenizer.java +++ b/core/java/android/text/util/Rfc822Tokenizer.java @@ -256,7 +256,7 @@ public class Rfc822Tokenizer implements MultiAutoCompleteTextView.Tokenizer { if (c == '"') { i++; break; - } else if (c == '\\') { + } else if (c == '\\' && i + 1 < len) { i += 2; } else { i++; @@ -275,7 +275,7 @@ public class Rfc822Tokenizer implements MultiAutoCompleteTextView.Tokenizer { } else if (c == '(') { level++; i++; - } else if (c == '\\') { + } else if (c == '\\' && i + 1 < len) { i += 2; } else { i++; diff --git a/core/java/android/view/GestureDetector.java b/core/java/android/view/GestureDetector.java index c1e1049..79b3d42 100644..100755 --- a/core/java/android/view/GestureDetector.java +++ b/core/java/android/view/GestureDetector.java @@ -193,10 +193,8 @@ public class GestureDetector { } } - // TODO: ViewConfiguration - private int mBiggerTouchSlopSquare = 20 * 20; - private int mTouchSlopSquare; + private int mLargeTouchSlopSquare; private int mDoubleTapSlopSquare; private int mMinimumFlingVelocity; private int mMaximumFlingVelocity; @@ -384,10 +382,11 @@ public class GestureDetector { mIgnoreMultitouch = ignoreMultitouch; // Fallback to support pre-donuts releases - int touchSlop, doubleTapSlop; + int touchSlop, largeTouchSlop, doubleTapSlop; if (context == null) { //noinspection deprecation touchSlop = ViewConfiguration.getTouchSlop(); + largeTouchSlop = touchSlop + 2; doubleTapSlop = ViewConfiguration.getDoubleTapSlop(); //noinspection deprecation mMinimumFlingVelocity = ViewConfiguration.getMinimumFlingVelocity(); @@ -395,11 +394,13 @@ public class GestureDetector { } else { final ViewConfiguration configuration = ViewConfiguration.get(context); touchSlop = configuration.getScaledTouchSlop(); + largeTouchSlop = configuration.getScaledLargeTouchSlop(); doubleTapSlop = configuration.getScaledDoubleTapSlop(); mMinimumFlingVelocity = configuration.getScaledMinimumFlingVelocity(); mMaximumFlingVelocity = configuration.getScaledMaximumFlingVelocity(); } mTouchSlopSquare = touchSlop * touchSlop; + mLargeTouchSlopSquare = largeTouchSlop * largeTouchSlop; mDoubleTapSlopSquare = doubleTapSlop * doubleTapSlop; } @@ -534,7 +535,7 @@ public class GestureDetector { mHandler.removeMessages(SHOW_PRESS); mHandler.removeMessages(LONG_PRESS); } - if (distance > mBiggerTouchSlopSquare) { + if (distance > mLargeTouchSlopSquare) { mAlwaysInBiggerTapRegion = false; } } else if ((Math.abs(scrollX) >= 1) || (Math.abs(scrollY) >= 1)) { diff --git a/core/java/android/view/ViewConfiguration.java b/core/java/android/view/ViewConfiguration.java index 392797c..df8f7d6 100644..100755 --- a/core/java/android/view/ViewConfiguration.java +++ b/core/java/android/view/ViewConfiguration.java @@ -143,6 +143,12 @@ public class ViewConfiguration { private static final int TOUCH_SLOP = 16; /** + * Distance a touch can wander before we think the user is the first touch + * in a sequence of double tap + */ + private static final int LARGE_TOUCH_SLOP = 18; + + /** * Distance a touch can wander before we think the user is attempting a paged scroll * (in dips) */ @@ -197,6 +203,7 @@ public class ViewConfiguration { private final int mMaximumFlingVelocity; private final int mScrollbarSize; private final int mTouchSlop; + private final int mLargeTouchSlop; private final int mPagingTouchSlop; private final int mDoubleTapSlop; private final int mWindowTouchSlop; @@ -218,6 +225,7 @@ public class ViewConfiguration { mMaximumFlingVelocity = MAXIMUM_FLING_VELOCITY; mScrollbarSize = SCROLL_BAR_SIZE; mTouchSlop = TOUCH_SLOP; + mLargeTouchSlop = LARGE_TOUCH_SLOP; mPagingTouchSlop = PAGING_TOUCH_SLOP; mDoubleTapSlop = DOUBLE_TAP_SLOP; mWindowTouchSlop = WINDOW_TOUCH_SLOP; @@ -254,6 +262,7 @@ public class ViewConfiguration { mMaximumFlingVelocity = (int) (density * MAXIMUM_FLING_VELOCITY + 0.5f); mScrollbarSize = (int) (density * SCROLL_BAR_SIZE + 0.5f); mTouchSlop = (int) (sizeAndDensity * TOUCH_SLOP + 0.5f); + mLargeTouchSlop = (int) (sizeAndDensity * LARGE_TOUCH_SLOP + 0.5f); mPagingTouchSlop = (int) (sizeAndDensity * PAGING_TOUCH_SLOP + 0.5f); mDoubleTapSlop = (int) (sizeAndDensity * DOUBLE_TAP_SLOP + 0.5f); mWindowTouchSlop = (int) (sizeAndDensity * WINDOW_TOUCH_SLOP + 0.5f); @@ -450,6 +459,14 @@ public class ViewConfiguration { } /** + * @return Distance a touch can wander before we think the user is the first touch + * in a sequence of double tap + */ + public int getScaledLargeTouchSlop() { + return mLargeTouchSlop; + } + + /** * @return Distance a touch can wander before we think the user is scrolling a full page * in dips */ diff --git a/core/java/android/webkit/CacheManager.java b/core/java/android/webkit/CacheManager.java index 3ce0730..e21a02e 100644 --- a/core/java/android/webkit/CacheManager.java +++ b/core/java/android/webkit/CacheManager.java @@ -857,6 +857,7 @@ public final class CacheManager { String cacheControl = headers.getCacheControl(); if (cacheControl != null) { String[] controls = cacheControl.toLowerCase().split("[ ,;]"); + boolean noCache = false; for (int i = 0; i < controls.length; i++) { if (NO_STORE.equals(controls[i])) { return null; @@ -867,7 +868,12 @@ public final class CacheManager { // can only be used in CACHE_MODE_CACHE_ONLY case if (NO_CACHE.equals(controls[i])) { ret.expires = 0; - } else if (controls[i].startsWith(MAX_AGE)) { + noCache = true; + // if cache control = no-cache has been received, ignore max-age + // header, according to http spec: + // If a request includes the no-cache directive, it SHOULD NOT + // include min-fresh, max-stale, or max-age. + } else if (controls[i].startsWith(MAX_AGE) && !noCache) { int separator = controls[i].indexOf('='); if (separator < 0) { separator = controls[i].indexOf(':'); diff --git a/core/java/android/webkit/WebSettings.java b/core/java/android/webkit/WebSettings.java index b884853..8e57260 100644 --- a/core/java/android/webkit/WebSettings.java +++ b/core/java/android/webkit/WebSettings.java @@ -1241,7 +1241,7 @@ public class WebSettings { */ @Deprecated public synchronized void setPluginsEnabled(boolean flag) { - setPluginState(PluginState.ON); + setPluginState(flag ? PluginState.ON : PluginState.OFF); } /** diff --git a/core/java/android/widget/PopupWindow.java b/core/java/android/widget/PopupWindow.java index 4fcd7a9..a5b7281 100644 --- a/core/java/android/widget/PopupWindow.java +++ b/core/java/android/widget/PopupWindow.java @@ -1488,6 +1488,10 @@ public class PopupWindow { @Override public boolean dispatchKeyEvent(KeyEvent event) { if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) { + if (getKeyDispatcherState() == null) { + return super.dispatchKeyEvent(event); + } + if (event.getAction() == KeyEvent.ACTION_DOWN && event.getRepeatCount() == 0) { KeyEvent.DispatcherState state = getKeyDispatcherState(); diff --git a/core/java/android/widget/ScrollView.java b/core/java/android/widget/ScrollView.java index 4b4f5f2..ade3a0a 100644 --- a/core/java/android/widget/ScrollView.java +++ b/core/java/android/widget/ScrollView.java @@ -873,7 +873,7 @@ public class ScrollView extends FrameLayout { int count = getChildCount(); if (count > 0) { View view = getChildAt(count - 1); - mTempRect.bottom = view.getBottom(); + mTempRect.bottom = view.getBottom() + mPaddingBottom; mTempRect.top = mTempRect.bottom - height; } } @@ -949,9 +949,7 @@ public class ScrollView extends FrameLayout { } else if (direction == View.FOCUS_DOWN) { if (getChildCount() > 0) { int daBottom = getChildAt(0).getBottom(); - - int screenBottom = getScrollY() + getHeight(); - + int screenBottom = getScrollY() + getHeight() - mPaddingBottom; if (daBottom - screenBottom < maxJump) { scrollDelta = daBottom - screenBottom; } diff --git a/core/java/com/android/internal/os/BatteryStatsImpl.java b/core/java/com/android/internal/os/BatteryStatsImpl.java index d86504d..2847cf3 100644 --- a/core/java/com/android/internal/os/BatteryStatsImpl.java +++ b/core/java/com/android/internal/os/BatteryStatsImpl.java @@ -4708,7 +4708,7 @@ public final class BatteryStatsImpl extends BatteryStats { mHistory = mHistoryEnd = mHistoryCache = null; mHistoryBaseTime = 0; long time; - while ((time=in.readLong()) >= 0) { + while (in.dataAvail() > 0 && (time=in.readLong()) >= 0) { HistoryItem rec = new HistoryItem(time, in); addHistoryRecordLocked(rec); if (rec.time > mHistoryBaseTime) { |