blob: b06c60ae760c4ca26a4711cbb8325b11d38bc588 [file] [log] [blame]
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001/*
2 * Copyright (C) 2006 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.server.am;
18
19import com.android.internal.os.BatteryStatsImpl;
Daniel Sandlerd0a2f862010-08-03 15:29:31 -040020import com.android.server.NotificationManagerService;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080021
Dianne Hackbornd8a43f62009-08-17 23:33:56 -070022import android.app.INotificationManager;
23import android.app.Notification;
24import android.app.NotificationManager;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080025import android.content.ComponentName;
Dianne Hackborn0c380492012-08-20 17:23:30 -070026import android.content.Context;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080027import android.content.Intent;
28import android.content.pm.ApplicationInfo;
Amith Yamasani742a6712011-05-04 14:49:28 -070029import android.content.pm.PackageManager;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080030import android.content.pm.ServiceInfo;
31import android.os.Binder;
32import android.os.IBinder;
Dianne Hackbornd8a43f62009-08-17 23:33:56 -070033import android.os.RemoteException;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080034import android.os.SystemClock;
Dianne Hackbornf02b60a2012-08-16 10:48:27 -070035import android.os.UserHandle;
Joe Onorato8a9b2202010-02-26 18:56:32 -080036import android.util.Slog;
Dianne Hackborn1ebccf52010-08-15 13:04:34 -070037import android.util.TimeUtils;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080038
39import java.io.PrintWriter;
40import java.util.ArrayList;
41import java.util.HashMap;
Dianne Hackborn39792d22010-08-19 18:01:52 -070042import java.util.HashSet;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080043import java.util.Iterator;
44import java.util.List;
45
46/**
47 * A running application service.
48 */
49class ServiceRecord extends Binder {
Dianne Hackborn39792d22010-08-19 18:01:52 -070050 // Maximum number of delivery attempts before giving up.
51 static final int MAX_DELIVERY_COUNT = 3;
52
53 // Maximum number of times it can fail during execution before giving up.
54 static final int MAX_DONE_EXECUTING_COUNT = 6;
55
Dianne Hackbornb1c4a2a2010-01-19 15:36:42 -080056 final ActivityManagerService ams;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080057 final BatteryStatsImpl.Uid.Pkg.Serv stats;
58 final ComponentName name; // service component.
59 final String shortName; // name.flattenToShortString().
60 final Intent.FilterComparison intent;
61 // original intent used to find service.
62 final ServiceInfo serviceInfo;
63 // all information about the service.
64 final ApplicationInfo appInfo;
65 // information about service's app.
Amith Yamasani742a6712011-05-04 14:49:28 -070066 final int userId; // user that this service is running as
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080067 final String packageName; // the package implementing intent's component
68 final String processName; // process where this component wants to run
69 final String permission;// permission needed to access service
70 final String baseDir; // where activity source (resources etc) located
71 final String resDir; // where public activity source (public resources etc) located
72 final String dataDir; // where activity data should go
73 final boolean exported; // from ServiceInfo.exported
74 final Runnable restarter; // used to schedule retries of starting the service
75 final long createTime; // when this service was created
76 final HashMap<Intent.FilterComparison, IntentBindRecord> bindings
77 = new HashMap<Intent.FilterComparison, IntentBindRecord>();
78 // All active bindings to the service.
Dianne Hackborn43d9ac82010-08-25 15:06:25 -070079 final HashMap<IBinder, ArrayList<ConnectionRecord>> connections
80 = new HashMap<IBinder, ArrayList<ConnectionRecord>>();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080081 // IBinder -> ConnectionRecord of all bound clients
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080082
Dianne Hackbornd8a43f62009-08-17 23:33:56 -070083 ProcessRecord app; // where this service is running or null.
Dianne Hackborna0c283e2012-02-09 10:47:01 -080084 ProcessRecord isolatedProc; // keep track of isolated process, if requested
Dianne Hackbornd8a43f62009-08-17 23:33:56 -070085 boolean isForeground; // is service currently in foreground mode?
86 int foregroundId; // Notification ID of last foreground req.
87 Notification foregroundNoti; // Notification record of foreground state.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080088 long lastActivity; // last time there was some activity on the service.
89 boolean startRequested; // someone explicitly called start?
Dianne Hackbornf6f9f2d2009-08-21 16:26:03 -070090 boolean stopIfKilled; // last onStart() said to stop if service killed?
91 boolean callStart; // last onStart() has asked to alway be called on restart.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080092 int executeNesting; // number of outstanding operations keeping foreground.
93 long executingStart; // start time of last execute request.
94 int crashCount; // number of times proc has crashed with service running
95 int totalRestartCount; // number of times we have had to restart.
96 int restartCount; // number of restarts performed in a row.
97 long restartDelay; // delay until next restart attempt.
98 long restartTime; // time of last restart.
99 long nextRestartTime; // time when restartDelay will expire.
100
Dianne Hackbornf210d6b2009-04-13 18:42:49 -0700101 String stringName; // caching of toString
102
Dianne Hackborn0c5001d2011-04-12 18:16:08 -0700103 private int lastStartId; // identifier of most recent start request.
104
Dianne Hackborn7e269642010-08-25 19:50:20 -0700105 static class StartItem {
Dianne Hackborn39792d22010-08-19 18:01:52 -0700106 final ServiceRecord sr;
Dianne Hackborn0c5001d2011-04-12 18:16:08 -0700107 final boolean taskRemoved;
Dianne Hackborn39792d22010-08-19 18:01:52 -0700108 final int id;
109 final Intent intent;
Dianne Hackborn21c241e2012-03-08 13:57:23 -0800110 final ActivityManagerService.NeededUriGrants neededGrants;
Dianne Hackborn39792d22010-08-19 18:01:52 -0700111 long deliveredTime;
112 int deliveryCount;
113 int doneExecutingCount;
Dianne Hackborn7e269642010-08-25 19:50:20 -0700114 UriPermissionOwner uriPermissions;
Dianne Hackborn39792d22010-08-19 18:01:52 -0700115
116 String stringName; // caching of toString
117
Dianne Hackborn0c5001d2011-04-12 18:16:08 -0700118 StartItem(ServiceRecord _sr, boolean _taskRemoved, int _id, Intent _intent,
Dianne Hackborn21c241e2012-03-08 13:57:23 -0800119 ActivityManagerService.NeededUriGrants _neededGrants) {
Dianne Hackborn39792d22010-08-19 18:01:52 -0700120 sr = _sr;
Dianne Hackborn0c5001d2011-04-12 18:16:08 -0700121 taskRemoved = _taskRemoved;
Dianne Hackborn39792d22010-08-19 18:01:52 -0700122 id = _id;
123 intent = _intent;
Dianne Hackborn21c241e2012-03-08 13:57:23 -0800124 neededGrants = _neededGrants;
Dianne Hackborn39792d22010-08-19 18:01:52 -0700125 }
126
Dianne Hackborn7e269642010-08-25 19:50:20 -0700127 UriPermissionOwner getUriPermissionsLocked() {
128 if (uriPermissions == null) {
129 uriPermissions = new UriPermissionOwner(sr.ams, this);
130 }
131 return uriPermissions;
132 }
133
Dianne Hackborn39792d22010-08-19 18:01:52 -0700134 void removeUriPermissionsLocked() {
Dianne Hackborn7e269642010-08-25 19:50:20 -0700135 if (uriPermissions != null) {
136 uriPermissions.removeUriPermissionsLocked();
137 uriPermissions = null;
Dianne Hackborn39792d22010-08-19 18:01:52 -0700138 }
139 }
140
141 public String toString() {
142 if (stringName != null) {
143 return stringName;
144 }
145 StringBuilder sb = new StringBuilder(128);
146 sb.append("ServiceRecord{")
147 .append(Integer.toHexString(System.identityHashCode(sr)))
148 .append(' ').append(sr.shortName)
149 .append(" StartItem ")
150 .append(Integer.toHexString(System.identityHashCode(this)))
151 .append(" id=").append(id).append('}');
152 return stringName = sb.toString();
153 }
154 }
155
156 final ArrayList<StartItem> deliveredStarts = new ArrayList<StartItem>();
157 // start() arguments which been delivered.
158 final ArrayList<StartItem> pendingStarts = new ArrayList<StartItem>();
159 // start() arguments that haven't yet been delivered.
160
Dianne Hackbornf6f9f2d2009-08-21 16:26:03 -0700161 void dumpStartList(PrintWriter pw, String prefix, List<StartItem> list, long now) {
162 final int N = list.size();
163 for (int i=0; i<N; i++) {
164 StartItem si = list.get(i);
165 pw.print(prefix); pw.print("#"); pw.print(i);
166 pw.print(" id="); pw.print(si.id);
Dianne Hackborn1ebccf52010-08-15 13:04:34 -0700167 if (now != 0) {
168 pw.print(" dur=");
169 TimeUtils.formatDuration(si.deliveredTime, now, pw);
170 }
Dianne Hackbornf6f9f2d2009-08-21 16:26:03 -0700171 if (si.deliveryCount != 0) {
172 pw.print(" dc="); pw.print(si.deliveryCount);
173 }
174 if (si.doneExecutingCount != 0) {
175 pw.print(" dxc="); pw.print(si.doneExecutingCount);
176 }
Dianne Hackborn39792d22010-08-19 18:01:52 -0700177 pw.println("");
178 pw.print(prefix); pw.print(" intent=");
Dianne Hackbornf6f9f2d2009-08-21 16:26:03 -0700179 if (si.intent != null) pw.println(si.intent.toString());
180 else pw.println("null");
Dianne Hackborn21c241e2012-03-08 13:57:23 -0800181 if (si.neededGrants != null) {
182 pw.print(prefix); pw.print(" neededGrants=");
183 pw.println(si.neededGrants);
Dianne Hackborn39792d22010-08-19 18:01:52 -0700184 }
Dianne Hackborn7e269642010-08-25 19:50:20 -0700185 if (si.uriPermissions != null) {
186 if (si.uriPermissions.readUriPermissions != null) {
187 pw.print(prefix); pw.print(" readUriPermissions=");
188 pw.println(si.uriPermissions.readUriPermissions);
189 }
190 if (si.uriPermissions.writeUriPermissions != null) {
191 pw.print(prefix); pw.print(" writeUriPermissions=");
192 pw.println(si.uriPermissions.writeUriPermissions);
193 }
Dianne Hackborn39792d22010-08-19 18:01:52 -0700194 }
Dianne Hackbornf6f9f2d2009-08-21 16:26:03 -0700195 }
196 }
197
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800198 void dump(PrintWriter pw, String prefix) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -0700199 pw.print(prefix); pw.print("intent={");
Dianne Hackborn21c241e2012-03-08 13:57:23 -0800200 pw.print(intent.getIntent().toShortString(false, true, false, true));
Dianne Hackborn1d442e02009-04-20 18:14:05 -0700201 pw.println('}');
202 pw.print(prefix); pw.print("packageName="); pw.println(packageName);
203 pw.print(prefix); pw.print("processName="); pw.println(processName);
204 if (permission != null) {
205 pw.print(prefix); pw.print("permission="); pw.println(permission);
206 }
Dianne Hackbornfd12af42009-08-27 00:44:33 -0700207 long now = SystemClock.uptimeMillis();
Dianne Hackborn1ebccf52010-08-15 13:04:34 -0700208 long nowReal = SystemClock.elapsedRealtime();
209 pw.print(prefix); pw.print("baseDir="); pw.println(baseDir);
Marco Nelissena301fe62011-05-04 08:44:59 -0700210 if (!resDir.equals(baseDir)) {
211 pw.print(prefix); pw.print("resDir="); pw.println(resDir);
212 }
Dianne Hackborn1ebccf52010-08-15 13:04:34 -0700213 pw.print(prefix); pw.print("dataDir="); pw.println(dataDir);
Dianne Hackborn1d442e02009-04-20 18:14:05 -0700214 pw.print(prefix); pw.print("app="); pw.println(app);
Dianne Hackborna0c283e2012-02-09 10:47:01 -0800215 if (isolatedProc != null) {
216 pw.print(prefix); pw.print("isolatedProc="); pw.println(isolatedProc);
217 }
Dianne Hackbornd8a43f62009-08-17 23:33:56 -0700218 if (isForeground || foregroundId != 0) {
219 pw.print(prefix); pw.print("isForeground="); pw.print(isForeground);
220 pw.print(" foregroundId="); pw.print(foregroundId);
221 pw.print(" foregroundNoti="); pw.println(foregroundNoti);
222 }
Dianne Hackborn9adb9c32010-08-13 14:09:56 -0700223 pw.print(prefix); pw.print("createTime=");
Dianne Hackborn1ebccf52010-08-15 13:04:34 -0700224 TimeUtils.formatDuration(createTime, nowReal, pw);
225 pw.print(" lastActivity=");
226 TimeUtils.formatDuration(lastActivity, now, pw);
227 pw.println("");
Dianne Hackborne17aeb32011-04-07 15:11:57 -0700228 pw.print(prefix); pw.print("executingStart=");
Dianne Hackborn1ebccf52010-08-15 13:04:34 -0700229 TimeUtils.formatDuration(executingStart, now, pw);
230 pw.print(" restartTime=");
231 TimeUtils.formatDuration(restartTime, now, pw);
232 pw.println("");
Dianne Hackbornd8a43f62009-08-17 23:33:56 -0700233 if (startRequested || lastStartId != 0) {
234 pw.print(prefix); pw.print("startRequested="); pw.print(startRequested);
Dianne Hackbornf6f9f2d2009-08-21 16:26:03 -0700235 pw.print(" stopIfKilled="); pw.print(stopIfKilled);
236 pw.print(" callStart="); pw.print(callStart);
Dianne Hackbornd8a43f62009-08-17 23:33:56 -0700237 pw.print(" lastStartId="); pw.println(lastStartId);
238 }
239 if (executeNesting != 0 || crashCount != 0 || restartCount != 0
240 || restartDelay != 0 || nextRestartTime != 0) {
241 pw.print(prefix); pw.print("executeNesting="); pw.print(executeNesting);
242 pw.print(" restartCount="); pw.print(restartCount);
Dianne Hackborn1ebccf52010-08-15 13:04:34 -0700243 pw.print(" restartDelay=");
244 TimeUtils.formatDuration(restartDelay, now, pw);
245 pw.print(" nextRestartTime=");
246 TimeUtils.formatDuration(nextRestartTime, now, pw);
Dianne Hackbornd8a43f62009-08-17 23:33:56 -0700247 pw.print(" crashCount="); pw.println(crashCount);
248 }
Dianne Hackbornf6f9f2d2009-08-21 16:26:03 -0700249 if (deliveredStarts.size() > 0) {
250 pw.print(prefix); pw.println("Delivered Starts:");
Dianne Hackborn1ebccf52010-08-15 13:04:34 -0700251 dumpStartList(pw, prefix, deliveredStarts, now);
Dianne Hackbornf6f9f2d2009-08-21 16:26:03 -0700252 }
253 if (pendingStarts.size() > 0) {
254 pw.print(prefix); pw.println("Pending Starts:");
255 dumpStartList(pw, prefix, pendingStarts, 0);
256 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800257 if (bindings.size() > 0) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800258 Iterator<IntentBindRecord> it = bindings.values().iterator();
Dianne Hackbornf6f9f2d2009-08-21 16:26:03 -0700259 pw.print(prefix); pw.println("Bindings:");
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800260 while (it.hasNext()) {
261 IntentBindRecord b = it.next();
Dianne Hackborn1d442e02009-04-20 18:14:05 -0700262 pw.print(prefix); pw.print("* IntentBindRecord{");
263 pw.print(Integer.toHexString(System.identityHashCode(b)));
Dianne Hackborn0c380492012-08-20 17:23:30 -0700264 if ((b.collectFlags()&Context.BIND_AUTO_CREATE) != 0) {
265 pw.append(" CREATE");
266 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -0700267 pw.println("}:");
268 b.dumpInService(pw, prefix + " ");
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800269 }
270 }
271 if (connections.size() > 0) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -0700272 pw.print(prefix); pw.println("All Connections:");
Dianne Hackborn43d9ac82010-08-25 15:06:25 -0700273 Iterator<ArrayList<ConnectionRecord>> it = connections.values().iterator();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800274 while (it.hasNext()) {
Dianne Hackborn43d9ac82010-08-25 15:06:25 -0700275 ArrayList<ConnectionRecord> c = it.next();
276 for (int i=0; i<c.size(); i++) {
277 pw.print(prefix); pw.print(" "); pw.println(c.get(i));
278 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800279 }
280 }
281 }
282
Dianne Hackbornb1c4a2a2010-01-19 15:36:42 -0800283 ServiceRecord(ActivityManagerService ams,
284 BatteryStatsImpl.Uid.Pkg.Serv servStats, ComponentName name,
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800285 Intent.FilterComparison intent, ServiceInfo sInfo, Runnable restarter) {
Dianne Hackbornb1c4a2a2010-01-19 15:36:42 -0800286 this.ams = ams;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800287 this.stats = servStats;
288 this.name = name;
289 shortName = name.flattenToShortString();
290 this.intent = intent;
291 serviceInfo = sInfo;
292 appInfo = sInfo.applicationInfo;
293 packageName = sInfo.applicationInfo.packageName;
294 processName = sInfo.processName;
295 permission = sInfo.permission;
296 baseDir = sInfo.applicationInfo.sourceDir;
297 resDir = sInfo.applicationInfo.publicSourceDir;
298 dataDir = sInfo.applicationInfo.dataDir;
299 exported = sInfo.exported;
300 this.restarter = restarter;
Dianne Hackborn9adb9c32010-08-13 14:09:56 -0700301 createTime = SystemClock.elapsedRealtime();
302 lastActivity = SystemClock.uptimeMillis();
Dianne Hackbornf02b60a2012-08-16 10:48:27 -0700303 userId = UserHandle.getUserId(appInfo.uid);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800304 }
305
306 public AppBindRecord retrieveAppBindingLocked(Intent intent,
307 ProcessRecord app) {
308 Intent.FilterComparison filter = new Intent.FilterComparison(intent);
309 IntentBindRecord i = bindings.get(filter);
310 if (i == null) {
311 i = new IntentBindRecord(this, filter);
312 bindings.put(filter, i);
313 }
314 AppBindRecord a = i.apps.get(app);
315 if (a != null) {
316 return a;
317 }
318 a = new AppBindRecord(this, i, app);
319 i.apps.put(app, a);
320 return a;
321 }
322
323 public void resetRestartCounter() {
324 restartCount = 0;
325 restartDelay = 0;
326 restartTime = 0;
327 }
328
Dianne Hackbornf6f9f2d2009-08-21 16:26:03 -0700329 public StartItem findDeliveredStart(int id, boolean remove) {
330 final int N = deliveredStarts.size();
331 for (int i=0; i<N; i++) {
332 StartItem si = deliveredStarts.get(i);
333 if (si.id == id) {
334 if (remove) deliveredStarts.remove(i);
335 return si;
336 }
337 }
338
339 return null;
340 }
341
Dianne Hackborn0c5001d2011-04-12 18:16:08 -0700342 public int getLastStartId() {
343 return lastStartId;
344 }
345
346 public int makeNextStartId() {
347 lastStartId++;
348 if (lastStartId < 1) {
349 lastStartId = 1;
350 }
351 return lastStartId;
352 }
353
Dianne Hackbornd8a43f62009-08-17 23:33:56 -0700354 public void postNotification() {
Daniel Sandlerd0a2f862010-08-03 15:29:31 -0400355 final int appUid = appInfo.uid;
356 final int appPid = app.pid;
Dianne Hackbornd8a43f62009-08-17 23:33:56 -0700357 if (foregroundId != 0 && foregroundNoti != null) {
Dianne Hackbornb1c4a2a2010-01-19 15:36:42 -0800358 // Do asynchronous communication with notification manager to
359 // avoid deadlocks.
360 final String localPackageName = packageName;
361 final int localForegroundId = foregroundId;
362 final Notification localForegroundNoti = foregroundNoti;
363 ams.mHandler.post(new Runnable() {
364 public void run() {
Daniel Sandlerd0a2f862010-08-03 15:29:31 -0400365 NotificationManagerService nm =
366 (NotificationManagerService) NotificationManager.getService();
367 if (nm == null) {
Dianne Hackbornb1c4a2a2010-01-19 15:36:42 -0800368 return;
369 }
370 try {
371 int[] outId = new int[1];
Dianne Hackbornf265ea92013-01-31 15:00:51 -0800372 nm.enqueueNotificationInternal(localPackageName, localPackageName,
373 appUid, appPid, null, localForegroundId, localForegroundNoti,
374 outId, userId);
Joe Onorato34fcf972010-02-18 07:45:17 -0500375 } catch (RuntimeException e) {
Joe Onorato8a9b2202010-02-26 18:56:32 -0800376 Slog.w(ActivityManagerService.TAG,
Dianne Hackborn9e0f5d92010-02-22 15:05:42 -0800377 "Error showing notification for service", e);
378 // If it gave us a garbage notification, it doesn't
379 // get to be foreground.
380 ams.setServiceForeground(name, ServiceRecord.this,
Joe Onoratoeaa07182010-09-23 16:49:20 -0700381 0, null, true);
382 ams.crashApplication(appUid, appPid, localPackageName,
383 "Bad notification for startForeground: " + e);
Dianne Hackbornb1c4a2a2010-01-19 15:36:42 -0800384 }
Dianne Hackbornd8a43f62009-08-17 23:33:56 -0700385 }
Dianne Hackbornb1c4a2a2010-01-19 15:36:42 -0800386 });
Dianne Hackbornd8a43f62009-08-17 23:33:56 -0700387 }
388 }
389
390 public void cancelNotification() {
391 if (foregroundId != 0) {
Dianne Hackbornb1c4a2a2010-01-19 15:36:42 -0800392 // Do asynchronous communication with notification manager to
393 // avoid deadlocks.
394 final String localPackageName = packageName;
395 final int localForegroundId = foregroundId;
396 ams.mHandler.post(new Runnable() {
397 public void run() {
398 INotificationManager inm = NotificationManager.getService();
399 if (inm == null) {
400 return;
401 }
402 try {
Dianne Hackborn41203752012-08-31 14:05:51 -0700403 inm.cancelNotificationWithTag(localPackageName, null,
404 localForegroundId, userId);
Joe Onorato34fcf972010-02-18 07:45:17 -0500405 } catch (RuntimeException e) {
Joe Onorato8a9b2202010-02-26 18:56:32 -0800406 Slog.w(ActivityManagerService.TAG,
Dianne Hackborn9e0f5d92010-02-22 15:05:42 -0800407 "Error canceling notification for service", e);
Dianne Hackbornb1c4a2a2010-01-19 15:36:42 -0800408 } catch (RemoteException e) {
409 }
Dianne Hackbornd8a43f62009-08-17 23:33:56 -0700410 }
Dianne Hackbornb1c4a2a2010-01-19 15:36:42 -0800411 });
Dianne Hackbornd8a43f62009-08-17 23:33:56 -0700412 }
413 }
414
Dianne Hackborn39792d22010-08-19 18:01:52 -0700415 public void clearDeliveredStartsLocked() {
416 for (int i=deliveredStarts.size()-1; i>=0; i--) {
417 deliveredStarts.get(i).removeUriPermissionsLocked();
418 }
419 deliveredStarts.clear();
420 }
421
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800422 public String toString() {
Dianne Hackbornf210d6b2009-04-13 18:42:49 -0700423 if (stringName != null) {
424 return stringName;
425 }
426 StringBuilder sb = new StringBuilder(128);
Dianne Hackborn1d442e02009-04-20 18:14:05 -0700427 sb.append("ServiceRecord{")
428 .append(Integer.toHexString(System.identityHashCode(this)))
Dianne Hackbornb12e1352012-09-26 11:39:20 -0700429 .append(" u").append(userId)
Dianne Hackborn1d442e02009-04-20 18:14:05 -0700430 .append(' ').append(shortName).append('}');
Dianne Hackbornf210d6b2009-04-13 18:42:49 -0700431 return stringName = sb.toString();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800432 }
433}