summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Dianne Hackborn <hackbod@google.com> 2010-01-22 11:59:41 -0800
committer Android Git Automerger <android-git-automerger@android.com> 2010-01-22 11:59:41 -0800
commitc0cea4857683c83e5b5df370ae1c90cc11ed25ae (patch)
tree19651d952c8afb9eec07369215efae5948fb2d9d
parentf226e9f27baa5a29aacffab87e0c0fc52d59fe13 (diff)
parent5f64128568d815f91dcd37db43d4e26a0566b41c (diff)
am 5f641285: am b1c4a2a3: Fix issue #2364506: Phone locked up while listening to music and attempting to download an update
Merge commit '5f64128568d815f91dcd37db43d4e26a0566b41c' * commit '5f64128568d815f91dcd37db43d4e26a0566b41c': Fix issue #2364506: Phone locked up while listening to music and attempting to download an update
-rw-r--r--services/java/com/android/server/am/ActivityManagerService.java2
-rw-r--r--services/java/com/android/server/am/ServiceRecord.java52
2 files changed, 38 insertions, 16 deletions
diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java
index 5b50a3ac7390..b7e55d561aea 100644
--- a/services/java/com/android/server/am/ActivityManagerService.java
+++ b/services/java/com/android/server/am/ActivityManagerService.java
@@ -10448,7 +10448,7 @@ public final class ActivityManagerService extends ActivityManagerNative implemen
sInfo.applicationInfo.uid, sInfo.packageName,
sInfo.name);
}
- r = new ServiceRecord(ss, name, filter, sInfo, res);
+ r = new ServiceRecord(this, ss, name, filter, sInfo, res);
res.setService(r);
mServices.put(name, r);
mServicesByIntent.put(filter, r);
diff --git a/services/java/com/android/server/am/ServiceRecord.java b/services/java/com/android/server/am/ServiceRecord.java
index 25344100f62b..89761a8860de 100644
--- a/services/java/com/android/server/am/ServiceRecord.java
+++ b/services/java/com/android/server/am/ServiceRecord.java
@@ -40,6 +40,7 @@ import java.util.List;
* A running application service.
*/
class ServiceRecord extends Binder {
+ final ActivityManagerService ams;
final BatteryStatsImpl.Uid.Pkg.Serv stats;
final ComponentName name; // service component.
final String shortName; // name.flattenToShortString().
@@ -192,8 +193,10 @@ class ServiceRecord extends Binder {
}
}
- ServiceRecord(BatteryStatsImpl.Uid.Pkg.Serv servStats, ComponentName name,
+ ServiceRecord(ActivityManagerService ams,
+ BatteryStatsImpl.Uid.Pkg.Serv servStats, ComponentName name,
Intent.FilterComparison intent, ServiceInfo sInfo, Runnable restarter) {
+ this.ams = ams;
this.stats = servStats;
this.name = name;
shortName = name.flattenToShortString();
@@ -249,27 +252,46 @@ class ServiceRecord extends Binder {
public void postNotification() {
if (foregroundId != 0 && foregroundNoti != null) {
- INotificationManager inm = NotificationManager.getService();
- if (inm != null) {
- try {
- int[] outId = new int[1];
- inm.enqueueNotification(packageName, foregroundId,
- foregroundNoti, outId);
- } catch (RemoteException e) {
+ // Do asynchronous communication with notification manager to
+ // avoid deadlocks.
+ final String localPackageName = packageName;
+ final int localForegroundId = foregroundId;
+ final Notification localForegroundNoti = foregroundNoti;
+ ams.mHandler.post(new Runnable() {
+ public void run() {
+ INotificationManager inm = NotificationManager.getService();
+ if (inm == null) {
+ return;
+ }
+ try {
+ int[] outId = new int[1];
+ inm.enqueueNotification(localPackageName, localForegroundId,
+ localForegroundNoti, outId);
+ } catch (RemoteException e) {
+ }
}
- }
+ });
}
}
public void cancelNotification() {
if (foregroundId != 0) {
- INotificationManager inm = NotificationManager.getService();
- if (inm != null) {
- try {
- inm.cancelNotification(packageName, foregroundId);
- } catch (RemoteException e) {
+ // Do asynchronous communication with notification manager to
+ // avoid deadlocks.
+ final String localPackageName = packageName;
+ final int localForegroundId = foregroundId;
+ ams.mHandler.post(new Runnable() {
+ public void run() {
+ INotificationManager inm = NotificationManager.getService();
+ if (inm == null) {
+ return;
+ }
+ try {
+ inm.cancelNotification(localPackageName, localForegroundId);
+ } catch (RemoteException e) {
+ }
}
- }
+ });
}
}