diff --git a/core/proto/android/server/activitymanagerservice.proto b/core/proto/android/server/activitymanagerservice.proto index 7393c6f9324ae..18d84d50aa7d1 100644 --- a/core/proto/android/server/activitymanagerservice.proto +++ b/core/proto/android/server/activitymanagerservice.proto @@ -457,6 +457,7 @@ message ServiceRecordProto { optional bool stop_if_killed = 3; optional bool call_start = 4; optional int32 last_start_id = 5; + optional int32 start_command_result = 6; } optional Start start = 19; @@ -499,7 +500,21 @@ message ServiceRecordProto { repeated ConnectionRecordProto connections = 26; optional bool allow_while_in_use_permission_in_fgs = 27; - // Next Tag: 28 + + message ShortFgsInfo { + option (.android.msg_privacy).dest = DEST_AUTOMATIC; + + optional int64 start_time = 1; + optional int32 start_foreground_count = 2; + optional int32 start_id = 3; + optional int64 timeout_time = 4; + optional int64 proc_state_demote_time = 5; + optional int64 anr_time = 6; + } + + optional ShortFgsInfo short_fgs_info = 28; + + // Next Tag: 29 } message ConnectionRecordProto { diff --git a/services/core/java/com/android/server/am/ActiveServices.java b/services/core/java/com/android/server/am/ActiveServices.java index 2a44e3037b50a..2d19f71272181 100644 --- a/services/core/java/com/android/server/am/ActiveServices.java +++ b/services/core/java/com/android/server/am/ActiveServices.java @@ -5421,6 +5421,13 @@ public final class ActiveServices { // This is a call from a service start... take care of // book-keeping. r.callStart = true; + + // Set the result to startCommandResult. + // START_TASK_REMOVED_COMPLETE is _not_ a result from onStartCommand(), so + // let's ignore. + if (res != Service.START_TASK_REMOVED_COMPLETE) { + r.startCommandResult = res; + } switch (res) { case Service.START_STICKY_COMPATIBILITY: case Service.START_STICKY: { diff --git a/services/core/java/com/android/server/am/ServiceRecord.java b/services/core/java/com/android/server/am/ServiceRecord.java index 0d1a6d5e0b64f..ef195aa13354b 100644 --- a/services/core/java/com/android/server/am/ServiceRecord.java +++ b/services/core/java/com/android/server/am/ServiceRecord.java @@ -128,6 +128,7 @@ final class ServiceRecord extends Binder implements ComponentName.WithComponentN boolean delayedStop; // service has been stopped but is in a delayed start? boolean stopIfKilled; // last onStart() said to stop if service killed? boolean callStart; // last onStart() has asked to always be called on restart. + int startCommandResult; // last result from onStartCommand(), only for dumpsys. int executeNesting; // number of outstanding operations keeping foreground. boolean executeFg; // should we be executing in the foreground? long executingStart; // start time of last execute request. @@ -478,6 +479,7 @@ final class ServiceRecord extends Binder implements ComponentName.WithComponentN proto.write(ServiceRecordProto.Start.DELAYED_STOP, delayedStop); proto.write(ServiceRecordProto.Start.STOP_IF_KILLED, stopIfKilled); proto.write(ServiceRecordProto.Start.LAST_START_ID, lastStartId); + proto.write(ServiceRecordProto.Start.START_COMMAND_RESULT, startCommandResult); proto.end(startToken); } @@ -533,9 +535,22 @@ final class ServiceRecord extends Binder implements ComponentName.WithComponentN } } } - proto.end(token); + if (mShortFgsInfo != null && mShortFgsInfo.isCurrent()) { + final long shortFgsToken = proto.start(ServiceRecordProto.SHORT_FGS_INFO); + proto.write(ServiceRecordProto.ShortFgsInfo.START_TIME, + mShortFgsInfo.getStartTime()); + proto.write(ServiceRecordProto.ShortFgsInfo.START_ID, + mShortFgsInfo.getStartId()); + proto.write(ServiceRecordProto.ShortFgsInfo.TIMEOUT_TIME, + mShortFgsInfo.getTimeoutTime()); + proto.write(ServiceRecordProto.ShortFgsInfo.PROC_STATE_DEMOTE_TIME, + mShortFgsInfo.getProcStateDemoteTime()); + proto.write(ServiceRecordProto.ShortFgsInfo.ANR_TIME, + mShortFgsInfo.getAnrTime()); + proto.end(shortFgsToken); + } - // TODO(short-service) Add FGS info + proto.end(token); } void dump(PrintWriter pw, String prefix) { @@ -632,6 +647,7 @@ final class ServiceRecord extends Binder implements ComponentName.WithComponentN pw.print(" stopIfKilled="); pw.print(stopIfKilled); pw.print(" callStart="); pw.print(callStart); pw.print(" lastStartId="); pw.println(lastStartId); + pw.print(" startCommandResult="); pw.println(startCommandResult); } if (executeNesting != 0) { pw.print(prefix); pw.print("executeNesting="); pw.print(executeNesting);