Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 42d02106 authored by Zim's avatar Zim Committed by Zimuzo Ezeozue
Browse files

Add a bindService sequence counter

This counter will be emitted in system_server and the bound app
and will help associate bindService requests all the way from binding app
through the system_server and to the bound app

Test: Manual
Bug: 271944973
Change-Id: I16994935a573311eeb82ed389104b94855a95878
parent a5991fc1
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -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);
        }
+1 −1
Original line number Diff line number Diff line
@@ -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);
+12 −1
Original line number Diff line number Diff line
@@ -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
@@ -4420,8 +4427,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;
                }