Merge "Add a bindService sequence counter" into udc-dev

This commit is contained in:
Zimuzo Ezeozue
2023-03-14 05:36:33 +00:00
committed by Android (Google) Code Review
3 changed files with 19 additions and 4 deletions

View File

@@ -849,8 +849,10 @@ public final class ActivityThread extends ClientTransactionHandler
@UnsupportedAppUsage
Intent intent;
boolean rebind;
long bindSeq;
public String toString() {
return "BindServiceData{token=" + token + " intent=" + intent + "}";
return "BindServiceData{token=" + token + " intent=" + intent
+ " bindSeq=" + bindSeq + "}";
}
}
@@ -1107,12 +1109,13 @@ public final class ActivityThread extends ClientTransactionHandler
}
public final void scheduleBindService(IBinder token, Intent intent,
boolean rebind, int processState) {
boolean rebind, int processState, long bindSeq) {
updateProcessState(processState, false);
BindServiceData s = new BindServiceData();
s.token = token;
s.intent = intent;
s.rebind = rebind;
s.bindSeq = bindSeq;
if (DEBUG_SERVICE)
Slog.v(TAG, "scheduleBindService token=" + token + " intent=" + intent + " uid="
@@ -1124,6 +1127,7 @@ public final class ActivityThread extends ClientTransactionHandler
BindServiceData s = new BindServiceData();
s.token = token;
s.intent = intent;
s.bindSeq = -1;
sendMessage(H.UNBIND_SERVICE, s);
}

View File

@@ -95,7 +95,7 @@ oneway interface IApplicationThread {
void processInBackground();
@UnsupportedAppUsage
void scheduleBindService(IBinder token,
in Intent intent, boolean rebind, int processState);
in Intent intent, boolean rebind, int processState, long bindSeq);
@UnsupportedAppUsage
void scheduleUnbindService(IBinder token,
in Intent intent);

View File

@@ -336,6 +336,13 @@ public final class ActiveServices {
*/
final ArrayMap<ForegroundServiceDelegation, ServiceRecord> mFgsDelegations = new ArrayMap<>();
/**
* A global counter for generating sequence numbers to uniquely identify bindService requests.
* It is purely for logging purposes.
*/
@GuardedBy("mAm")
private long mBindServiceSeqCounter = 0;
/**
* Whether there is a rate limit that suppresses immediate re-deferral of new FGS
* notifications from each app. On by default, disabled only by shell command for
@@ -4429,8 +4436,12 @@ public final class ActiveServices {
try {
bumpServiceExecutingLocked(r, execInFg, "bind",
OomAdjuster.OOM_ADJ_REASON_BIND_SERVICE);
if (Trace.isTagEnabled(Trace.TRACE_TAG_ACTIVITY_MANAGER)) {
Trace.instant(Trace.TRACE_TAG_ACTIVITY_MANAGER, "requestServiceBinding="
+ i.intent.getIntent() + ". bindSeq=" + mBindServiceSeqCounter);
}
r.app.getThread().scheduleBindService(r, i.intent.getIntent(), rebind,
r.app.mState.getReportedProcState());
r.app.mState.getReportedProcState(), mBindServiceSeqCounter++);
if (!rebind) {
i.requested = true;
}