final String localPackageName = packageName;
final int localForegroundId = foregroundId;
final Notification _foregroundNoti = foregroundNoti;
+ final ServiceRecord record = this;
ams.mHandler.post(new Runnable() {
public void run() {
NotificationManagerInternal nm = LocalServices.getService(
Slog.w(TAG, "Error showing notification for service", e);
// If it gave us a garbage notification, it doesn't
// get to be foreground.
- ams.setServiceForeground(name, ServiceRecord.this,
- 0, null, 0);
- ams.crashApplication(appUid, appPid, localPackageName,
- "Bad notification for startForeground: " + e);
+ ams.mServices.killMisbehavingService(record,
+ appUid, appPid, localPackageName);
}
}
});
}
public void cancelNotification() {
- if (foregroundId != 0) {
- // 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.cancelNotificationWithTag(localPackageName, null,
- localForegroundId, userId);
- } catch (RuntimeException e) {
- Slog.w(TAG, "Error canceling notification for service", e);
- } 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.cancelNotificationWithTag(localPackageName, null,
+ localForegroundId, userId);
+ } catch (RuntimeException e) {
+ Slog.w(TAG, "Error canceling notification for service", e);
+ } catch (RemoteException e) {
+ }
+ }
+ });
}
public void stripForegroundServiceFlagFromNotification() {