Merge "A few changes around SHORT_SERVICE" into udc-dev

This commit is contained in:
Makoto Onuki
2023-03-06 17:08:24 +00:00
committed by Android (Google) Code Review
3 changed files with 14 additions and 0 deletions

View File

@@ -439,6 +439,7 @@ message ServiceRecordProto {
optional int32 id = 1;
optional .android.app.NotificationProto notification = 2;
optional int32 foregroundServiceType = 3;
}
optional Foreground foreground = 13;

View File

@@ -2092,6 +2092,17 @@ public final class ActiveServices {
r.appInfo.uid, r.intent.getIntent(), r, r.userId,
BackgroundStartPrivileges.NONE,
false /* isBindService */);
if (r.mAllowStartForeground == REASON_DENIED) {
Slog.w(TAG_SERVICE, "FGS type change to/from SHORT_SERVICE: "
+ " BFSL DENIED.");
} else {
if (DEBUG_SHORT_SERVICE) {
Slog.w(TAG_SERVICE, "FGS type change to/from SHORT_SERVICE: "
+ " BFSL Allowed: "
+ PowerExemptionManager.reasonCodeToString(
r.mAllowStartForeground));
}
}
final boolean fgsStartAllowed =
!isBgFgsRestrictionEnabledForService

View File

@@ -468,6 +468,8 @@ final class ServiceRecord extends Binder implements ComponentName.WithComponentN
long fgToken = proto.start(ServiceRecordProto.FOREGROUND);
proto.write(ServiceRecordProto.Foreground.ID, foregroundId);
foregroundNoti.dumpDebug(proto, ServiceRecordProto.Foreground.NOTIFICATION);
proto.write(ServiceRecordProto.Foreground.FOREGROUND_SERVICE_TYPE,
foregroundServiceType);
proto.end(fgToken);
}
ProtoUtils.toDuration(proto, ServiceRecordProto.CREATE_REAL_TIME, createRealTime, nowReal);