X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=services%2Fcore%2Fjava%2Fcom%2Fandroid%2Fserver%2Fam%2FServiceRecord.java;h=f87ba716926e8bfff16ae4b5bc4db6944763cc68;hb=c6fd63a7a80f06a89b34aa1894694922c3af9f20;hp=71c7fd348fb3d9bd325a3ead54ab4d712aa16846;hpb=f0f1b1fe9e9240ec6b25cef70c733a36087c3438;p=android-x86%2Fframeworks-base.git diff --git a/services/core/java/com/android/server/am/ServiceRecord.java b/services/core/java/com/android/server/am/ServiceRecord.java index 71c7fd348fb3..f87ba716926e 100644 --- a/services/core/java/com/android/server/am/ServiceRecord.java +++ b/services/core/java/com/android/server/am/ServiceRecord.java @@ -33,6 +33,7 @@ import android.content.pm.PackageManager; import android.content.pm.ServiceInfo; import android.net.Uri; import android.os.Binder; +import android.os.Build; import android.os.IBinder; import android.os.RemoteException; import android.os.SystemClock; @@ -92,6 +93,8 @@ final class ServiceRecord extends Binder { ServiceState restartTracker; // tracking service restart boolean whitelistManager; // any bindings to this service have BIND_ALLOW_WHITELIST_MANAGEMENT? boolean delayed; // are we waiting to start this service in the background? + boolean fgRequired; // is the service required to go foreground after starting? + boolean fgWaiting; // is a timeout for going foreground already scheduled? boolean isForeground; // is service currently in foreground mode? int foregroundId; // Notification ID of last foreground req. Notification foregroundNoti; // Notification record of foreground state. @@ -115,13 +118,14 @@ final class ServiceRecord extends Binder { long destroyTime; // time at which destory was initiated. String stringName; // caching of toString - + private int lastStartId; // identifier of most recent start request. static class StartItem { final ServiceRecord sr; final boolean taskRemoved; final int id; + final int callingId; final Intent intent; final ActivityManagerService.NeededUriGrants neededGrants; long deliveredTime; @@ -132,12 +136,13 @@ final class ServiceRecord extends Binder { String stringName; // caching of toString StartItem(ServiceRecord _sr, boolean _taskRemoved, int _id, Intent _intent, - ActivityManagerService.NeededUriGrants _neededGrants) { + ActivityManagerService.NeededUriGrants _neededGrants, int _callingId) { sr = _sr; taskRemoved = _taskRemoved; id = _id; intent = _intent; neededGrants = _neededGrants; + callingId = _callingId; } UriPermissionOwner getUriPermissionsLocked() { @@ -203,7 +208,7 @@ final class ServiceRecord extends Binder { } } } - + void dump(PrintWriter pw, String prefix) { pw.print(prefix); pw.print("intent={"); pw.print(intent.getIntent().toShortString(false, true, false, true)); @@ -413,7 +418,7 @@ final class ServiceRecord extends Binder { restartDelay = 0; restartTime = 0; } - + public StartItem findDeliveredStart(int id, boolean remove) { final int N = deliveredStarts.size(); for (int i=0; i= Build.VERSION_CODES.O_MR1) { + throw new RuntimeException( + "invalid channel for service notification: " + + foregroundNoti); + } + } if (localForegroundNoti.getSmallIcon() == null) { // Notifications whose icon is 0 are defined to not show // a notification, silently ignoring it. We don't want to @@ -522,26 +543,23 @@ final class ServiceRecord extends Binder { throw new RuntimeException("invalid service notification: " + foregroundNoti); } - int[] outId = new int[1]; nm.enqueueNotification(localPackageName, localPackageName, appUid, appPid, null, localForegroundId, localForegroundNoti, - outId, userId); + userId); foregroundNoti = localForegroundNoti; // save it for amending next time } catch (RuntimeException e) { 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() { // Do asynchronous communication with notification manager to // avoid deadlocks. @@ -588,7 +606,7 @@ final class ServiceRecord extends Binder { } }); } - + public void clearDeliveredStartsLocked() { for (int i=deliveredStarts.size()-1; i>=0; i--) { deliveredStarts.get(i).removeUriPermissionsLocked();