From 214b6b9ef91320cd7b2eab592fbe0eec1614f3cb Mon Sep 17 00:00:00 2001 From: Bryan Mawhinney Date: Wed, 7 Oct 2009 13:02:35 +0100 Subject: [PATCH 01/10] Only dismiss search dialog after launching intent. This fixes an NPE that occurs when launching the intent tries to access state cleared by onStop. Bug: 2171752 Change-Id: I29232f2a44d8dfa27b2c79933093c0c8983b2e92 --- core/java/android/app/SearchDialog.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/java/android/app/SearchDialog.java b/core/java/android/app/SearchDialog.java index 933c2fc2fa794..697ac7654f94c 100644 --- a/core/java/android/app/SearchDialog.java +++ b/core/java/android/app/SearchDialog.java @@ -1314,13 +1314,13 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS // source. this is because GlobalSearch may not have permission to launch the // intent, and to avoid the extra step of going through GlobalSearch. if (mGlobalSearchMode) { + launchGlobalSearchIntent(intent); if (mStoredComponentName != null) { // If we're embedded in an application, dismiss the dialog. // This ensures that if the intent is handled by the current // activity, it's not obscured by the dialog. dismiss(); } - launchGlobalSearchIntent(intent); } else { // If the intent was created from a suggestion, it will always have an explicit // component here. From ea48361d47a2d566922ef26a41ea12d719347618 Mon Sep 17 00:00:00 2001 From: Fred Quintana Date: Wed, 7 Oct 2009 16:36:48 -0700 Subject: [PATCH 02/10] fix an NPE on a race condition that occurs when unbinding from an authenticator at the samer time that its process dies: bug 2171204 --- .../accounts/AuthenticatorBindHelper.java | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/core/java/android/accounts/AuthenticatorBindHelper.java b/core/java/android/accounts/AuthenticatorBindHelper.java index 91e23ab8aca05..2ca1f0e492cd6 100644 --- a/core/java/android/accounts/AuthenticatorBindHelper.java +++ b/core/java/android/accounts/AuthenticatorBindHelper.java @@ -146,7 +146,7 @@ public class AuthenticatorBindHelper { Log.v(TAG, "there are no more callbacks for service " + authenticatorType + ", unbinding service"); } - unbindFromService(authenticatorType); + unbindFromServiceLocked(authenticatorType); } else { if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.v(TAG, "leaving service " + authenticatorType @@ -161,7 +161,10 @@ public class AuthenticatorBindHelper { } } - private void unbindFromService(String authenticatorType) { + /** + * You must synchronized on mServiceConnections before calling this + */ + private void unbindFromServiceLocked(String authenticatorType) { if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.v(TAG, "unbindService from " + authenticatorType); } @@ -217,15 +220,18 @@ public class AuthenticatorBindHelper { // post a message for each service user to tell them that the service is disconnected, // and unbind from the service. synchronized (mServiceConnections) { - for (Callback callback : mServiceUsers.get(mAuthenticatorType)) { - if (Log.isLoggable(TAG, Log.VERBOSE)) { - Log.v(TAG, "the service became disconnected, scheduling a " - + "disconnected message for " - + mAuthenticatorType); + final ArrayList callbackList = mServiceUsers.get(mAuthenticatorType); + if (callbackList != null) { + for (Callback callback : callbackList) { + if (Log.isLoggable(TAG, Log.VERBOSE)) { + Log.v(TAG, "the service became disconnected, scheduling a " + + "disconnected message for " + + mAuthenticatorType); + } + mHandler.obtainMessage(mMessageWhatDisconnected, callback).sendToTarget(); } - mHandler.obtainMessage(mMessageWhatDisconnected, callback).sendToTarget(); + unbindFromServiceLocked(mAuthenticatorType); } - unbindFromService(mAuthenticatorType); } } } From b977f2bdef563d39fd0af318e6d2ab483edebf5c Mon Sep 17 00:00:00 2001 From: Daisuke Miyakawa Date: Wed, 7 Oct 2009 17:25:50 -0700 Subject: [PATCH 03/10] Make vCard import Photo from vCard file :( Internal issue number: 2174296 --- core/java/android/pim/vcard/ContactStruct.java | 1 + 1 file changed, 1 insertion(+) diff --git a/core/java/android/pim/vcard/ContactStruct.java b/core/java/android/pim/vcard/ContactStruct.java index b6a453af9e675..36e5e233d6a32 100644 --- a/core/java/android/pim/vcard/ContactStruct.java +++ b/core/java/android/pim/vcard/ContactStruct.java @@ -698,6 +698,7 @@ public class ContactStruct { mPhotoList = new ArrayList(1); } final PhotoData photoData = new PhotoData(0, null, photoBytes); + mPhotoList.add(photoData); } /** From 2133640028ef53b33a93ecfb593d30c95fed84c6 Mon Sep 17 00:00:00 2001 From: Dave Sparks Date: Wed, 7 Oct 2009 19:18:20 -0700 Subject: [PATCH 04/10] Retry overlay create if it fails. Bug 2153980. Occasionally we see references to the overlay hanging around long enough to cause problems in applications when they tried to destroy the overlay and re-create it. This patch causes the camera HAL to retry the overlay creation call if it fails every 20ms up to 50 times before it gives up. --- camera/libcameraservice/CameraService.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/camera/libcameraservice/CameraService.cpp b/camera/libcameraservice/CameraService.cpp index 8279914f976a7..b63e97fdc4a97 100644 --- a/camera/libcameraservice/CameraService.cpp +++ b/camera/libcameraservice/CameraService.cpp @@ -563,7 +563,19 @@ status_t CameraService::Client::setOverlay() status_t ret = NO_ERROR; if (mSurface != 0) { if (mOverlayRef.get() == NULL) { - mOverlayRef = mSurface->createOverlay(w, h, OVERLAY_FORMAT_DEFAULT); + + // FIXME: + // Surfaceflinger may hold onto the previous overlay reference for some + // time after we try to destroy it. retry a few times. In the future, we + // should make the destroy call block, or possibly specify that we can + // wait in the createOverlay call if the previous overlay is in the + // process of being destroyed. + for (int retry = 0; retry < 50; ++retry) { + mOverlayRef = mSurface->createOverlay(w, h, OVERLAY_FORMAT_DEFAULT); + if (mOverlayRef != NULL) break; + LOGD("Overlay create failed - retrying"); + usleep(20000); + } if ( mOverlayRef.get() == NULL ) { LOGE("Overlay Creation Failed!"); From 3d163f073f5cf3b3bf0287fc7d60fabce0269748 Mon Sep 17 00:00:00 2001 From: Dianne Hackborn Date: Wed, 7 Oct 2009 21:26:57 -0700 Subject: [PATCH 05/10] More fix #2163209: alarm clock rings but is hidden behind lock screen There was another way we could ignore the application windows flags while the lock screen was displayed. This is the infrastructure to deal with that. Change-Id: Id8c9cb2f7081df6757ccb797a7cde618e82f7b38 --- core/java/android/view/WindowManagerPolicy.java | 7 +++++++ .../com/android/server/WindowManagerService.java | 15 +++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/core/java/android/view/WindowManagerPolicy.java b/core/java/android/view/WindowManagerPolicy.java index 78999fa51bbab..916fc2d78cb52 100644 --- a/core/java/android/view/WindowManagerPolicy.java +++ b/core/java/android/view/WindowManagerPolicy.java @@ -262,6 +262,13 @@ public interface WindowManagerPolicy { */ boolean isVisibleLw(); + /** + * Like {@link #isVisibleLw}, but also counts a window that is currently + * "hidden" behind the keyguard as visible. This allows us to apply + * things like window flags that impact the keyguard. + */ + boolean isVisibleOrBehindKeyguardLw(); + /** * Is this window currently visible to the user on-screen? It is * displayed either if it is visible or it is currently running an diff --git a/services/java/com/android/server/WindowManagerService.java b/services/java/com/android/server/WindowManagerService.java index 67b8a855ed6bb..00636c400ae52 100644 --- a/services/java/com/android/server/WindowManagerService.java +++ b/services/java/com/android/server/WindowManagerService.java @@ -7573,6 +7573,21 @@ public class WindowManagerService extends IWindowManager.Stub && !mExiting && !mDestroying; } + /** + * Like {@link #isVisibleLw}, but also counts a window that is currently + * "hidden" behind the keyguard as visible. This allows us to apply + * things like window flags that impact the keyguard. + * XXX I am starting to think we need to have ANOTHER visibility flag + * for this "hidden behind keyguard" state rather than overloading + * mPolicyVisibility. Ungh. + */ + public boolean isVisibleOrBehindKeyguardLw() { + final AppWindowToken atoken = mAppToken; + return mSurface != null && !mAttachedHidden + && (atoken == null ? mPolicyVisibility : !atoken.hiddenRequested) + && !mExiting && !mDestroying; + } + /** * Is this window visible, ignoring its app token? It is not visible * if there is no surface, or we are in the process of running an exit animation From e5d93b7ed983f98855555d560faf060836f1a52f Mon Sep 17 00:00:00 2001 From: Jaikumar Ganesh Date: Thu, 8 Oct 2009 02:27:52 -0700 Subject: [PATCH 06/10] Set the Bond State to NONE when we receive a Agent Cancel. Sometimes during OPP, we can get stuck in Pairing state when the remote end, cancels the Pairing process - we will just get onAgentCancel and thus not set the Pairing state properly. DrNo: Eastham Bug:2174874 --- .../android/bluetooth/BluetoothDevice.java | 6 +++++- .../android/server/BluetoothEventLoop.java | 21 +++++++++++++++++++ .../java/android/server/BluetoothService.java | 2 +- 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/core/java/android/bluetooth/BluetoothDevice.java b/core/java/android/bluetooth/BluetoothDevice.java index 9c23746494a4f..39a74acee888e 100644 --- a/core/java/android/bluetooth/BluetoothDevice.java +++ b/core/java/android/bluetooth/BluetoothDevice.java @@ -287,9 +287,13 @@ public final class BluetoothDevice implements Parcelable { /** A bond attempt failed because of repeated attempts * @hide */ public static final int UNBOND_REASON_REPEATED_ATTEMPTS = 7; + /** A bond attempt failed because we received an Authentication Cancel + * by remote end + * @hide */ + public static final int UNBOND_REASON_REMOTE_AUTH_CANCELED = 8; /** An existing bond was explicitly revoked * @hide */ - public static final int UNBOND_REASON_REMOVED = 8; + public static final int UNBOND_REASON_REMOVED = 9; /** The user will be prompted to enter a pin * @hide */ diff --git a/core/java/android/server/BluetoothEventLoop.java b/core/java/android/server/BluetoothEventLoop.java index da1918a83bee6..c0b9a6843ea17 100644 --- a/core/java/android/server/BluetoothEventLoop.java +++ b/core/java/android/server/BluetoothEventLoop.java @@ -54,6 +54,7 @@ class BluetoothEventLoop { private static final int EVENT_AUTO_PAIRING_FAILURE_ATTEMPT_DELAY = 1; private static final int EVENT_RESTART_BLUETOOTH = 2; private static final int EVENT_PAIRING_CONSENT_DELAYED_ACCEPT = 3; + private static final int EVENT_AGENT_CANCEL = 4; private static final int CREATE_DEVICE_ALREADY_EXISTS = 1; private static final int CREATE_DEVICE_SUCCESS = 0; @@ -90,6 +91,22 @@ class BluetoothEventLoop { mBluetoothService.setPairingConfirmation(address, true); } break; + case EVENT_AGENT_CANCEL: + // Set the Bond State to BOND_NONE. + // We always have only 1 device in BONDING state. + String[] devices = + mBluetoothService.getBondState().listInState(BluetoothDevice.BOND_BONDING); + if (devices.length == 0) { + break; + } else if (devices.length > 1) { + Log.e(TAG, " There is more than one device in the Bonding State"); + break; + } + address = devices[0]; + mBluetoothService.getBondState().setBondState(address, + BluetoothDevice.BOND_NONE, + BluetoothDevice.UNBOND_REASON_REMOTE_AUTH_CANCELED); + break; } } }; @@ -544,6 +561,10 @@ class BluetoothEventLoop { private void onAgentCancel() { Intent intent = new Intent(BluetoothDevice.ACTION_PAIRING_CANCEL); mContext.sendBroadcast(intent, BLUETOOTH_ADMIN_PERM); + + mHandler.sendMessageDelayed(mHandler.obtainMessage(EVENT_AGENT_CANCEL), + 1500); + return; } diff --git a/core/java/android/server/BluetoothService.java b/core/java/android/server/BluetoothService.java index 6d4d1527a9292..7ebd91dd4d741 100644 --- a/core/java/android/server/BluetoothService.java +++ b/core/java/android/server/BluetoothService.java @@ -571,7 +571,7 @@ public class BluetoothService extends IBluetooth.Stub { return state.intValue(); } - private synchronized String[] listInState(int state) { + /*package*/ synchronized String[] listInState(int state) { ArrayList result = new ArrayList(mState.size()); for (Map.Entry e : mState.entrySet()) { if (e.getValue().intValue() == state) { From 080b61ba17014b8c93914f642ccbe05c76dc611d Mon Sep 17 00:00:00 2001 From: Joshua Bartel Date: Mon, 5 Oct 2009 12:44:46 -0400 Subject: [PATCH 07/10] LocationManagerService: Fix race when removing LocationListener In LocationManagerService if a LocationListener is removed while it has a pending broadcast the wake lock held while pending broadcasts are outstanding do not get cleared properly. There are 2 cases of this race that are fixed: 1. locationCallbackFinished was changed to check the mReceivers HashMap directly instead of calling getReceiver. getReceiver would add the ILocationListener as a new Receiver if it did not exist which caused a receiver that was removed when it still had a broadcast pending to be added back in a bad state when the pending broadcast completed. 2. removeUpdatesLocked was changed to decrement the pending broadcasts when a Receiver is removed that has pending broadcasts. Fixes bug b/2163871 Change-Id: I50a321c9b3359bf69845236dc4a4b9e38e847335 Signed-off-by: Mike Lockwood --- .../com/android/server/LocationManagerService.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/services/java/com/android/server/LocationManagerService.java b/services/java/com/android/server/LocationManagerService.java index f6a1be73328fb..c8fa4c39ad03f 100644 --- a/services/java/com/android/server/LocationManagerService.java +++ b/services/java/com/android/server/LocationManagerService.java @@ -382,7 +382,12 @@ public class LocationManagerService extends ILocationManager.Stub implements Run } public void locationCallbackFinished(ILocationListener listener) { - Receiver receiver = getReceiver(listener); + //Do not use getReceiver here as that will add the ILocationListener to + //the receiver list if it is not found. If it is not found then the + //LocationListener was removed when it had a pending broadcast and should + //not be added back. + IBinder binder = listener.asBinder(); + Receiver receiver = mReceivers.get(binder); if (receiver != null) { synchronized (receiver) { // so wakelock calls will succeed @@ -921,6 +926,12 @@ public class LocationManagerService extends ILocationManager.Stub implements Run try { if (mReceivers.remove(receiver.mKey) != null && receiver.isListener()) { receiver.getListener().asBinder().unlinkToDeath(receiver, 0); + synchronized(receiver) { + if(receiver.mPendingBroadcasts > 0) { + decrementPendingBroadcasts(); + receiver.mPendingBroadcasts = 0; + } + } } // Record which providers were associated with this listener From b7c34cecd107bb79fa88f51eee99c94c4256212d Mon Sep 17 00:00:00 2001 From: San Mehat Date: Wed, 7 Oct 2009 17:03:00 -0700 Subject: [PATCH 08/10] dumpstate: 'RAMCONSOLE' -> 'LAST KMSG' Signed-off-by: San Mehat --- cmds/dumpstate/dumpstate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmds/dumpstate/dumpstate.c b/cmds/dumpstate/dumpstate.c index 4a71dc66a9c49..9c2becf34f508 100644 --- a/cmds/dumpstate/dumpstate.c +++ b/cmds/dumpstate/dumpstate.c @@ -110,7 +110,7 @@ static void dumpstate(int full) { PRINT("------ PACKAGE UID ERRORS ------"); DUMP("/data/system/uiderrors.txt"); - dump_kernel_log("/data/dontpanic/last_kmsg", "RAMCONSOLE"); + dump_kernel_log("/data/dontpanic/last_kmsg", "LAST KMSG"); dump_kernel_log("/data/dontpanic/apanic_console", "PANIC CONSOLE"); dump_kernel_log("/data/dontpanic/apanic_threads", From a62e4705d51e6f36ba1c02350813b6a12af49703 Mon Sep 17 00:00:00 2001 From: Romain Guy Date: Thu, 8 Oct 2009 10:48:54 -0700 Subject: [PATCH 09/10] Fixes #2175599. Prevents an NPE when AttachInfo is null. This bug was introduced by a change made to query the window's opacity. Approved by mcleron. Change-Id: I95319bde72b0faade095bbbbb317e84b9be8efa8 --- core/java/android/view/View.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index 4c91b6bc5cd7b..eb3e52398825c 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -6189,7 +6189,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility final int drawingCacheBackgroundColor = mDrawingCacheBackgroundColor; final boolean opaque = drawingCacheBackgroundColor != 0 || isOpaque(); - final boolean translucentWindow = attachInfo.mTranslucentWindow; + final boolean translucentWindow = attachInfo != null && attachInfo.mTranslucentWindow; if (width <= 0 || height <= 0 || // Projected bitmap size in bytes From 33e21fcc99dd91061ea245984c4e9a1544cb943f Mon Sep 17 00:00:00 2001 From: John Wang Date: Thu, 8 Oct 2009 10:35:27 -0700 Subject: [PATCH 10/10] Control H icon display in Status bar. Bug 2138275. Add a config setting to control if status bar should show different icons for UMTS and HSPA connnection. --- core/res/res/values/config.xml | 2 ++ .../android/server/status/StatusBarPolicy.java | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml index 9040edb7a58c2..6fd7657979023 100644 --- a/core/res/res/values/config.xml +++ b/core/res/res/values/config.xml @@ -158,4 +158,6 @@ false + + false diff --git a/services/java/com/android/server/status/StatusBarPolicy.java b/services/java/com/android/server/status/StatusBarPolicy.java index 3d1fb83ee1327..d590c40286122 100644 --- a/services/java/com/android/server/status/StatusBarPolicy.java +++ b/services/java/com/android/server/status/StatusBarPolicy.java @@ -272,6 +272,7 @@ public class StatusBarPolicy { private IBinder mDataIcon; private IconData mDataData; private boolean mDataIconVisible; + private boolean mHspaDataDistinguishable; // ringer volume private IBinder mVolumeIcon; @@ -517,6 +518,14 @@ public class StatusBarPolicy { filter.addAction(TelephonyIntents.ACTION_SIM_STATE_CHANGED); filter.addAction(TtyIntent.TTY_ENABLED_CHANGE_ACTION); mContext.registerReceiver(mIntentReceiver, filter, null, mHandler); + + // load config to determine if to distinguish Hspa data icon + try { + mHspaDataDistinguishable = mContext.getResources().getBoolean( + com.android.internal.R.bool.config_hspa_data_distinguishable); + } catch (Exception e) { + mHspaDataDistinguishable = false; + } } public static void installIcons(Context context, StatusBarService service) { @@ -960,7 +969,11 @@ public class StatusBarPolicy { case TelephonyManager.NETWORK_TYPE_HSDPA: case TelephonyManager.NETWORK_TYPE_HSUPA: case TelephonyManager.NETWORK_TYPE_HSPA: - mDataIconList = sDataNetType_h; + if (mHspaDataDistinguishable) { + mDataIconList = sDataNetType_h; + } else { + mDataIconList = sDataNetType_3g; + } break; case TelephonyManager.NETWORK_TYPE_CDMA: // display 1xRTT for IS95A/B