Update ServiceRecord dumpsys/proto

- Dump the result from onStartCommand
- Add proto for ShortFgsInfo

Bug: 257270313
Bug: 260748204
Test: Manual inspection of `incident_report amservices` output
Test: atest CtsShortFgsTestCases CtsAppFgsTestCases
Change-Id: I2c17bd194c684f739e83cc4a87a1b0d4f9a13a23
This commit is contained in:
Makoto Onuki
2022-12-02 16:21:10 -08:00
parent 95d7aa9fef
commit 8255d175b5
3 changed files with 41 additions and 3 deletions

View File

@@ -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 {

View File

@@ -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: {

View File

@@ -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);