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

Commit e0ef793d authored by Marcin Oczeretko's avatar Marcin Oczeretko Committed by Android (Google) Code Review
Browse files

Merge changes If217a9a8,I35af3a9c

* changes:
  LooperStats - don't create entries for unsampled sessions
  Add work source uid collection to LooperStats
parents 3623c39c a674bc9e
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -2339,7 +2339,7 @@ message BinderCallsExceptions {
 * Next tag: 11
 * Next tag: 11
 */
 */
message LooperStats {
message LooperStats {
    // Currently not collected and always set to 0.
    // The uid that made a call to the System Server and caused the message to be enqueued.
    optional int32 uid = 1 [(is_uid) = true];
    optional int32 uid = 1 [(is_uid) = true];


    // Fully qualified class name of the handler target class.
    // Fully qualified class name of the handler target class.
+2 −0
Original line number Original line Diff line number Diff line
@@ -773,6 +773,7 @@ public class Binder implements IBinder {
            if (tracingEnabled) {
            if (tracingEnabled) {
                Trace.traceBegin(Trace.TRACE_TAG_ALWAYS, getClass().getName() + ":" + code);
                Trace.traceBegin(Trace.TRACE_TAG_ALWAYS, getClass().getName() + ":" + code);
            }
            }
            ThreadLocalWorkSourceUid.set(Binder.getCallingUid());
            res = onTransact(code, data, reply, flags);
            res = onTransact(code, data, reply, flags);
        } catch (RemoteException|RuntimeException e) {
        } catch (RemoteException|RuntimeException e) {
            if (observer != null) {
            if (observer != null) {
@@ -793,6 +794,7 @@ public class Binder implements IBinder {
            }
            }
            res = true;
            res = true;
        } finally {
        } finally {
            ThreadLocalWorkSourceUid.clear();
            if (tracingEnabled) {
            if (tracingEnabled) {
                Trace.traceEnd(Trace.TRACE_TAG_ALWAYS);
                Trace.traceEnd(Trace.TRACE_TAG_ALWAYS);
            }
            }
+2 −0
Original line number Original line Diff line number Diff line
@@ -739,6 +739,8 @@ public class Handler {


    private boolean enqueueMessage(MessageQueue queue, Message msg, long uptimeMillis) {
    private boolean enqueueMessage(MessageQueue queue, Message msg, long uptimeMillis) {
        msg.target = this;
        msg.target = this;
        msg.workSourceUid = ThreadLocalWorkSourceUid.get();

        if (mAsynchronous) {
        if (mAsynchronous) {
            msg.setAsynchronous(true);
            msg.setAsynchronous(true);
        }
        }
+2 −0
Original line number Original line Diff line number Diff line
@@ -205,6 +205,7 @@ public final class Looper {
                token = observer.messageDispatchStarting();
                token = observer.messageDispatchStarting();
            }
            }
            try {
            try {
                ThreadLocalWorkSourceUid.set(msg.workSourceUid);
                msg.target.dispatchMessage(msg);
                msg.target.dispatchMessage(msg);
                if (observer != null) {
                if (observer != null) {
                    observer.messageDispatched(token, msg);
                    observer.messageDispatched(token, msg);
@@ -216,6 +217,7 @@ public final class Looper {
                }
                }
                throw exception;
                throw exception;
            } finally {
            } finally {
                ThreadLocalWorkSourceUid.clear();
                if (traceTag != 0) {
                if (traceTag != 0) {
                    Trace.traceEnd(traceTag);
                    Trace.traceEnd(traceTag);
                }
                }
+21 −3
Original line number Original line Diff line number Diff line
@@ -16,7 +16,6 @@


package android.os;
package android.os;


import android.os.MessageProto;
import android.util.TimeUtils;
import android.util.TimeUtils;
import android.util.proto.ProtoOutputStream;
import android.util.proto.ProtoOutputStream;


@@ -73,12 +72,26 @@ public final class Message implements Parcelable {
     */
     */
    public Messenger replyTo;
    public Messenger replyTo;


    /**
     * Indicates that the uid is not set;
     *
     * @hide Only for use within the system server.
     */
    public static final int UID_NONE = -1;

    /**
    /**
     * Optional field indicating the uid that sent the message.  This is
     * Optional field indicating the uid that sent the message.  This is
     * only valid for messages posted by a {@link Messenger}; otherwise,
     * only valid for messages posted by a {@link Messenger}; otherwise,
     * it will be -1.
     * it will be -1.
     */
     */
    public int sendingUid = -1;
    public int sendingUid = UID_NONE;

    /**
     * Optional field indicating the uid that caused this message to be enqueued.
     *
     * @hide Only for use within the system server.
     */
    public int workSourceUid = UID_NONE;


    /** If set message is in use.
    /** If set message is in use.
     * This flag is set when the message is enqueued and remains set while it
     * This flag is set when the message is enqueued and remains set while it
@@ -151,6 +164,7 @@ public final class Message implements Parcelable {
        m.obj = orig.obj;
        m.obj = orig.obj;
        m.replyTo = orig.replyTo;
        m.replyTo = orig.replyTo;
        m.sendingUid = orig.sendingUid;
        m.sendingUid = orig.sendingUid;
        m.workSourceUid = orig.workSourceUid;
        if (orig.data != null) {
        if (orig.data != null) {
            m.data = new Bundle(orig.data);
            m.data = new Bundle(orig.data);
        }
        }
@@ -301,7 +315,8 @@ public final class Message implements Parcelable {
        arg2 = 0;
        arg2 = 0;
        obj = null;
        obj = null;
        replyTo = null;
        replyTo = null;
        sendingUid = -1;
        sendingUid = UID_NONE;
        workSourceUid = UID_NONE;
        when = 0;
        when = 0;
        target = null;
        target = null;
        callback = null;
        callback = null;
@@ -329,6 +344,7 @@ public final class Message implements Parcelable {
        this.obj = o.obj;
        this.obj = o.obj;
        this.replyTo = o.replyTo;
        this.replyTo = o.replyTo;
        this.sendingUid = o.sendingUid;
        this.sendingUid = o.sendingUid;
        this.workSourceUid = o.workSourceUid;


        if (o.data != null) {
        if (o.data != null) {
            this.data = (Bundle) o.data.clone();
            this.data = (Bundle) o.data.clone();
@@ -612,6 +628,7 @@ public final class Message implements Parcelable {
        dest.writeBundle(data);
        dest.writeBundle(data);
        Messenger.writeMessengerOrNullToParcel(replyTo, dest);
        Messenger.writeMessengerOrNullToParcel(replyTo, dest);
        dest.writeInt(sendingUid);
        dest.writeInt(sendingUid);
        dest.writeInt(workSourceUid);
    }
    }


    private void readFromParcel(Parcel source) {
    private void readFromParcel(Parcel source) {
@@ -625,5 +642,6 @@ public final class Message implements Parcelable {
        data = source.readBundle();
        data = source.readBundle();
        replyTo = Messenger.readMessengerOrNullFromParcel(source);
        replyTo = Messenger.readMessengerOrNullFromParcel(source);
        sendingUid = source.readInt();
        sendingUid = source.readInt();
        workSourceUid = source.readInt();
    }
    }
}
}
Loading