diff options
-rw-r--r-- | core/java/android/accounts/AccountManagerService.java | 16 | ||||
-rw-r--r-- | core/java/android/bluetooth/BluetoothDeviceProfileState.java | 1 | ||||
-rw-r--r-- | core/java/android/os/Looper.java | 3 | ||||
-rw-r--r-- | core/java/android/os/Process.java | 2 | ||||
-rw-r--r-- | core/java/android/speech/RecognitionService.java | 14 | ||||
-rw-r--r-- | core/java/android/webkit/CacheManager.java | 8 | ||||
-rw-r--r-- | graphics/java/android/graphics/YuvImage.java | 6 | ||||
-rw-r--r-- | media/java/android/media/ThumbnailUtils.java | 4 | ||||
-rw-r--r-- | nfc-extras/java/com/android/nfc_extras/NfcAdapterExtras.java | 25 | ||||
-rwxr-xr-x | services/java/com/android/server/VibratorService.java | 12 | ||||
-rw-r--r-- | services/java/com/android/server/am/ActivityManagerService.java | 5 | ||||
-rwxr-xr-x | services/java/com/android/server/location/GpsLocationProvider.java | 2 | ||||
-rw-r--r--[-rwxr-xr-x] | telephony/java/com/android/internal/telephony/sip/SipPhone.java | 5 | ||||
-rw-r--r-- | tests/CoreTests/android/core/HttpHeaderTest.java | 42 | ||||
-rw-r--r-- | voip/java/com/android/server/sip/SipHelper.java | 8 |
15 files changed, 111 insertions, 42 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/bluetooth/BluetoothDeviceProfileState.java b/core/java/android/bluetooth/BluetoothDeviceProfileState.java index 9855709..f4693c2 100644 --- a/core/java/android/bluetooth/BluetoothDeviceProfileState.java +++ b/core/java/android/bluetooth/BluetoothDeviceProfileState.java @@ -679,7 +679,6 @@ public final class BluetoothDeviceProfileState extends HierarchicalStateMachine @Override protected 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/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..c8cb1de 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 = 1023; /** * Defines the GID for the group that allows write access to the internal media storage. 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/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/graphics/java/android/graphics/YuvImage.java b/graphics/java/android/graphics/YuvImage.java index 9368da6..af3f276 100644 --- a/graphics/java/android/graphics/YuvImage.java +++ b/graphics/java/android/graphics/YuvImage.java @@ -36,7 +36,7 @@ public class YuvImage { private final static int WORKING_COMPRESS_STORAGE = 4096; /** - * The YUV format as defined in {@link PixelFormat}. + * The YUV format as defined in {@link ImageFormat}. */ private int mFormat; @@ -67,7 +67,7 @@ public class YuvImage { * * @param yuv The YUV data. In the case of more than one image plane, all the planes must be * concatenated into a single byte array. - * @param format The YUV data format as defined in {@link PixelFormat}. + * @param format The YUV data format as defined in {@link ImageFormat}. * @param width The width of the YuvImage. * @param height The height of the YuvImage. * @param strides (Optional) Row bytes of each image plane. If yuv contains padding, the stride @@ -152,7 +152,7 @@ public class YuvImage { } /** - * @return the YUV format as defined in {@link PixelFormat}. + * @return the YUV format as defined in {@link ImageFormat}. */ public int getYuvFormat() { return mFormat; diff --git a/media/java/android/media/ThumbnailUtils.java b/media/java/android/media/ThumbnailUtils.java index 7fdf448..7c181ee 100644 --- a/media/java/android/media/ThumbnailUtils.java +++ b/media/java/android/media/ThumbnailUtils.java @@ -83,7 +83,7 @@ public class ThumbnailUtils { * * @param filePath the path of image file * @param kind could be MINI_KIND or MICRO_KIND - * @return Bitmap + * @return Bitmap, or null on failures * * @hide This method is only used by media framework and media provider internally. */ @@ -123,6 +123,8 @@ public class ThumbnailUtils { bitmap = BitmapFactory.decodeFileDescriptor(fd, null, options); } catch (IOException ex) { Log.e(TAG, "", ex); + } catch (OutOfMemoryError oom) { + Log.e(TAG, "Unable to decode file " + filePath + ". OutOfMemoryError.", oom); } } diff --git a/nfc-extras/java/com/android/nfc_extras/NfcAdapterExtras.java b/nfc-extras/java/com/android/nfc_extras/NfcAdapterExtras.java index cf38bd1..ed1af49 100644 --- a/nfc-extras/java/com/android/nfc_extras/NfcAdapterExtras.java +++ b/nfc-extras/java/com/android/nfc_extras/NfcAdapterExtras.java @@ -57,7 +57,6 @@ public final class NfcAdapterExtras { // protected by NfcAdapterExtras.class, and final after first construction private static INfcAdapterExtras sService; - private static boolean sIsInitialized = false; private static NfcAdapterExtras sSingleton; private static NfcExecutionEnvironment sEmbeddedEe; private static CardEmulationRoute sRouteOff; @@ -74,14 +73,22 @@ public final class NfcAdapterExtras { */ public static NfcAdapterExtras get(NfcAdapter adapter) { synchronized(NfcAdapterExtras.class) { - if (!sIsInitialized) { - sIsInitialized = true; - sService = adapter.getNfcAdapterExtrasInterface(); - sEmbeddedEe = new NfcExecutionEnvironment(sService); - sRouteOff = new CardEmulationRoute(CardEmulationRoute.ROUTE_OFF, null); - sRouteOnWhenScreenOn = new CardEmulationRoute( - CardEmulationRoute.ROUTE_ON_WHEN_SCREEN_ON, sEmbeddedEe); - sSingleton = new NfcAdapterExtras(); + if (sSingleton == null) { + try { + sService = adapter.getNfcAdapterExtrasInterface(); + sEmbeddedEe = new NfcExecutionEnvironment(sService); + sRouteOff = new CardEmulationRoute(CardEmulationRoute.ROUTE_OFF, null); + sRouteOnWhenScreenOn = new CardEmulationRoute( + CardEmulationRoute.ROUTE_ON_WHEN_SCREEN_ON, sEmbeddedEe); + sSingleton = new NfcAdapterExtras(); + } finally { + if (sSingleton == null) { + sService = null; + sEmbeddedEe = null; + sRouteOff = null; + sRouteOnWhenScreenOn = null; + } + } } return sSingleton; } diff --git a/services/java/com/android/server/VibratorService.java b/services/java/com/android/server/VibratorService.java index 2fcdb5d..c39dc80 100755 --- a/services/java/com/android/server/VibratorService.java +++ b/services/java/com/android/server/VibratorService.java @@ -247,6 +247,7 @@ public class VibratorService extends IVibratorService.Stub { // Lock held on mVibrations private void startNextVibrationLocked() { if (mVibrations.size() <= 0) { + mCurrentVibration = null; return; } mCurrentVibration = mVibrations.getFirst(); @@ -273,17 +274,27 @@ public class VibratorService extends IVibratorService.Stub { Vibration vib = iter.next(); if (vib.mToken == token) { iter.remove(); + unlinkVibration(vib); return vib; } } // We might be looking for a simple vibration which is only stored in // mCurrentVibration. if (mCurrentVibration != null && mCurrentVibration.mToken == token) { + unlinkVibration(mCurrentVibration); return mCurrentVibration; } return null; } + private void unlinkVibration(Vibration vib) { + if (vib.mPattern != null) { + // If Vibration object has a pattern, + // the Vibration object has also been linkedToDeath. + vib.mToken.unlinkToDeath(vib, 0); + } + } + private class VibrateThread extends Thread { final Vibration mVibration; boolean mDone; @@ -360,6 +371,7 @@ public class VibratorService extends IVibratorService.Stub { // If this vibration finished naturally, start the next // vibration. mVibrations.remove(mVibration); + unlinkVibration(mVibration); startNextVibrationLocked(); } } diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java index 267c76a..50fffd0 100644 --- a/services/java/com/android/server/am/ActivityManagerService.java +++ b/services/java/com/android/server/am/ActivityManagerService.java @@ -6996,8 +6996,9 @@ public final class ActivityManagerService extends ActivityManagerNative addErrorToDropBox("wtf", r, null, null, tag, null, null, crashInfo); - if (Settings.Secure.getInt(mContext.getContentResolver(), - Settings.Secure.WTF_IS_FATAL, 0) != 0) { + if (r != null && r.pid != Process.myPid() && + Settings.Secure.getInt(mContext.getContentResolver(), + Settings.Secure.WTF_IS_FATAL, 0) != 0) { crashApplication(r, crashInfo); return true; } else { diff --git a/services/java/com/android/server/location/GpsLocationProvider.java b/services/java/com/android/server/location/GpsLocationProvider.java index 3561862..63ce0bd 100755 --- a/services/java/com/android/server/location/GpsLocationProvider.java +++ b/services/java/com/android/server/location/GpsLocationProvider.java @@ -203,7 +203,7 @@ public class GpsLocationProvider implements LocationProviderInterface { // flags to trigger NTP or XTRA data download when network becomes available // initialized to true so we do NTP and XTRA when the network comes up after booting private boolean mInjectNtpTimePending = true; - private boolean mDownloadXtraDataPending = false; + private boolean mDownloadXtraDataPending = true; // true if GPS is navigating private boolean mNavigating; diff --git a/telephony/java/com/android/internal/telephony/sip/SipPhone.java b/telephony/java/com/android/internal/telephony/sip/SipPhone.java index 7373cbb..5471289 100755..100644 --- a/telephony/java/com/android/internal/telephony/sip/SipPhone.java +++ b/telephony/java/com/android/internal/telephony/sip/SipPhone.java @@ -40,6 +40,7 @@ import com.android.internal.telephony.PhoneNotifier; import java.text.ParseException; import java.util.List; +import java.util.regex.Pattern; /** * {@hide} @@ -386,8 +387,8 @@ public class SipPhone extends SipPhoneBase { Connection dial(String originalNumber) throws SipException { String calleeSipUri = originalNumber; if (!calleeSipUri.contains("@")) { - calleeSipUri = mProfile.getUriString().replaceFirst( - mProfile.getUserName() + "@", + String replaceStr = Pattern.quote(mProfile.getUserName() + "@"); + calleeSipUri = mProfile.getUriString().replaceFirst(replaceStr, calleeSipUri + "@"); } try { diff --git a/tests/CoreTests/android/core/HttpHeaderTest.java b/tests/CoreTests/android/core/HttpHeaderTest.java index a5d4857..eedbc3f 100644 --- a/tests/CoreTests/android/core/HttpHeaderTest.java +++ b/tests/CoreTests/android/core/HttpHeaderTest.java @@ -19,12 +19,19 @@ import android.test.AndroidTestCase; import org.apache.http.util.CharArrayBuffer; import android.net.http.Headers; +import android.util.Log; +import android.webkit.CacheManager; +import android.webkit.CacheManager.CacheResult; + +import java.lang.reflect.Method; public class HttpHeaderTest extends AndroidTestCase { static final String LAST_MODIFIED = "Last-Modified: Fri, 18 Jun 2010 09:56:47 GMT"; static final String CACHE_CONTROL_MAX_AGE = "Cache-Control:max-age=15"; static final String CACHE_CONTROL_PRIVATE = "Cache-Control: private"; + static final String CACHE_CONTROL_COMPOUND = "Cache-Control: no-cache, max-age=200000"; + static final String CACHE_CONTROL_COMPOUND2 = "Cache-Control: max-age=200000, no-cache"; /** * Tests that cache control header supports multiple instances of the header, @@ -59,4 +66,39 @@ public class HttpHeaderTest extends AndroidTestCase { h.parseHeader(buffer); assertEquals("max-age=15,private", h.getCacheControl()); } + + // Test that cache behaves correctly when receiving a compund + // cache-control statement containing no-cache and max-age argument. + // + // If a cache control header contains both a max-age arument and + // a no-cache argument the max-age argument should be ignored. + // The resource can be cached, but a validity check must be done on + // every request. Test case checks that the expiry time is 0 for + // this item, so item will be validated on subsequent requests. + public void testCacheControlMultipleArguments() throws Exception { + // get private method CacheManager.parseHeaders() + Method m = CacheManager.class.getDeclaredMethod("parseHeaders", + new Class[] {int.class, Headers.class, String.class}); + m.setAccessible(true); + + // create indata + Headers h = new Headers(); + CharArrayBuffer buffer = new CharArrayBuffer(64); + buffer.append(CACHE_CONTROL_COMPOUND); + h.parseHeader(buffer); + + CacheResult c = (CacheResult)m.invoke(null, 200, h, "text/html"); + + // Check that expires is set to 0, to ensure that no-cache has overridden + // the max-age argument + assertEquals(0, c.getExpires()); + + // check reverse order + buffer.clear(); + buffer.append(CACHE_CONTROL_COMPOUND2); + h.parseHeader(buffer); + + c = (CacheResult)m.invoke(null, 200, h, "text/html"); + assertEquals(0, c.getExpires()); + } } diff --git a/voip/java/com/android/server/sip/SipHelper.java b/voip/java/com/android/server/sip/SipHelper.java index ac580e7..4ee86b6 100644 --- a/voip/java/com/android/server/sip/SipHelper.java +++ b/voip/java/com/android/server/sip/SipHelper.java @@ -27,6 +27,8 @@ import java.text.ParseException; import java.util.ArrayList; import java.util.EventObject; import java.util.List; +import java.util.regex.Pattern; + import javax.sip.ClientTransaction; import javax.sip.Dialog; import javax.sip.DialogTerminatedEvent; @@ -215,9 +217,11 @@ class SipHelper { String tag) throws ParseException, SipException { FromHeader fromHeader = createFromHeader(userProfile, tag); ToHeader toHeader = createToHeader(userProfile); + + String replaceStr = Pattern.quote(userProfile.getUserName() + "@"); SipURI requestURI = mAddressFactory.createSipURI( - userProfile.getUriString().replaceFirst( - userProfile.getUserName() + "@", "")); + userProfile.getUriString().replaceFirst(replaceStr, "")); + List<ViaHeader> viaHeaders = createViaHeaders(); CallIdHeader callIdHeader = createCallIdHeader(); CSeqHeader cSeqHeader = createCSeqHeader(requestType); |