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

Commit 129fc6ce authored by Yi Jin's avatar Yi Jin
Browse files

Implement Activity Manager Broadcasts dump protos

Bug: 66729158
Test: Manually build and flash the system.img and test "activity --proto
broadcasts"
Change-Id: I3cb7474c4a3ab092f38ed6a121b4d034cadfc402
parent bc8e230c
Loading
Loading
Loading
Loading
+52 −0
Original line number Diff line number Diff line
@@ -53,6 +53,7 @@ import android.provider.OpenableColumns;
import android.util.ArraySet;
import android.util.AttributeSet;
import android.util.Log;
import android.util.proto.ProtoOutputStream;

import com.android.internal.util.XmlUtils;

@@ -9371,6 +9372,57 @@ public class Intent implements Parcelable, Cloneable {
        }
    }

    /** @hide */
    public void writeToProto(ProtoOutputStream proto, long fieldId, boolean secure, boolean comp,
            boolean extras, boolean clip) {
        long token = proto.start(fieldId);
        if (mAction != null) {
            proto.write(IntentProto.ACTION, mAction);
        }
        if (mCategories != null)  {
            for (String category : mCategories) {
                proto.write(IntentProto.CATEGORIES, category);
            }
        }
        if (mData != null) {
            proto.write(IntentProto.DATA, secure ? mData.toSafeString() : mData.toString());
        }
        if (mType != null) {
            proto.write(IntentProto.TYPE, mType);
        }
        if (mFlags != 0) {
            proto.write(IntentProto.FLAG, "0x" + Integer.toHexString(mFlags));
        }
        if (mPackage != null) {
            proto.write(IntentProto.PACKAGE, mPackage);
        }
        if (comp && mComponent != null) {
            proto.write(IntentProto.COMPONENT, mComponent.flattenToShortString());
        }
        if (mSourceBounds != null) {
            proto.write(IntentProto.SOURCE_BOUNDS, mSourceBounds.toShortString());
        }
        if (mClipData != null) {
            StringBuilder b = new StringBuilder();
            if (clip) {
                mClipData.toShortString(b);
            } else {
                mClipData.toShortStringShortItems(b, false);
            }
            proto.write(IntentProto.CLIP_DATA, b.toString());
        }
        if (extras && mExtras != null) {
            proto.write(IntentProto.EXTRAS, mExtras.toShortString());
        }
        if (mContentUserHint != 0) {
            proto.write(IntentProto.CONTENT_USER_HINT, mContentUserHint);
        }
        if (mSelector != null) {
            proto.write(IntentProto.SELECTOR, mSelector.toShortString(secure, comp, extras, clip));
        }
        proto.end(token);
    }

    /**
     * Call {@link #toUri} with 0 flags.
     * @deprecated Use {@link #toUri} instead.
+63 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import android.text.TextUtils;
import android.util.AndroidException;
import android.util.Log;
import android.util.Printer;
import android.util.proto.ProtoOutputStream;

import com.android.internal.util.XmlUtils;

@@ -918,6 +919,15 @@ public class IntentFilter implements Parcelable {
            dest.writeInt(mPort);
        }

        void writeToProto(ProtoOutputStream proto, long fieldId) {
            long token = proto.start(fieldId);
            // The original host information is already contained in host and wild, no output now.
            proto.write(AuthorityEntryProto.HOST, mHost);
            proto.write(AuthorityEntryProto.WILD, mWild);
            proto.write(AuthorityEntryProto.PORT, mPort);
            proto.end(token);
        }

        public String getHost() {
            return mOrigHost;
        }
@@ -1739,6 +1749,59 @@ public class IntentFilter implements Parcelable {
        }
    }

    /** @hide */
    public void writeToProto(ProtoOutputStream proto, long fieldId) {
        long token = proto.start(fieldId);
        if (mActions.size() > 0) {
            Iterator<String> it = mActions.iterator();
            while (it.hasNext()) {
                proto.write(IntentFilterProto.ACTIONS, it.next());
            }
        }
        if (mCategories != null) {
            Iterator<String> it = mCategories.iterator();
            while (it.hasNext()) {
                proto.write(IntentFilterProto.CATEGORIES, it.next());
            }
        }
        if (mDataSchemes != null) {
            Iterator<String> it = mDataSchemes.iterator();
            while (it.hasNext()) {
                proto.write(IntentFilterProto.DATA_SCHEMES, it.next());
            }
        }
        if (mDataSchemeSpecificParts != null) {
            Iterator<PatternMatcher> it = mDataSchemeSpecificParts.iterator();
            while (it.hasNext()) {
                it.next().writeToProto(proto, IntentFilterProto.DATA_SCHEME_SPECS);
            }
        }
        if (mDataAuthorities != null) {
            Iterator<AuthorityEntry> it = mDataAuthorities.iterator();
            while (it.hasNext()) {
                it.next().writeToProto(proto, IntentFilterProto.DATA_AUTHORITIES);
            }
        }
        if (mDataPaths != null) {
            Iterator<PatternMatcher> it = mDataPaths.iterator();
            while (it.hasNext()) {
                it.next().writeToProto(proto, IntentFilterProto.DATA_PATHS);
            }
        }
        if (mDataTypes != null) {
            Iterator<String> it = mDataTypes.iterator();
            while (it.hasNext()) {
                proto.write(IntentFilterProto.DATA_TYPES, it.next());
            }
        }
        if (mPriority != 0 || mHasPartialTypes) {
            proto.write(IntentFilterProto.PRIORITY, mPriority);
            proto.write(IntentFilterProto.HAS_PARTIAL_TYPES, mHasPartialTypes);
        }
        proto.write(IntentFilterProto.GET_AUTO_VERIFY, getAutoVerify());
        proto.end(token);
    }

    public void dump(Printer du, String prefix) {
        StringBuilder sb = new StringBuilder(256);
        if (mActions.size() > 0) {
+13 −3
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@

package android.os;

import android.util.Log;
import android.util.proto.ProtoOutputStream;

import java.util.Arrays;

@@ -132,6 +132,16 @@ public class PatternMatcher implements Parcelable {
        return "PatternMatcher{" + type + mPattern + "}";
    }

    /** @hide */
    public void writeToProto(ProtoOutputStream proto, long fieldId) {
        long token = proto.start(fieldId);
        proto.write(PatternMatcherProto.PATTERN, mPattern);
        proto.write(PatternMatcherProto.TYPE, mType);
        // PatternMatcherProto.PARSED_PATTERN is too much to dump, but the field is reserved to
        // match the current data structure.
        proto.end(token);
    }

    public int describeContents() {
        return 0;
    }
+60 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2017 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

syntax = "proto3";

option java_package = "android.content";
option java_multiple_files = true;

import "frameworks/base/core/proto/android/os/patternmatcher.proto";

package android.content;

// Next Tag: 13
message IntentProto {
    string action = 1;
    repeated string categories = 2;
    string data = 3;
    string type = 4;
    string flag = 5;
    string package = 6;
    string component = 7;
    string source_bounds = 8;
    string clip_data = 9;
    string extras = 10;
    int32 content_user_hint = 11;
    string selector = 12;
}

// Next Tag: 11
message IntentFilterProto {
    repeated string actions = 1;
    repeated string categories = 2;
    repeated string data_schemes = 3;
    repeated android.os.PatternMatcherProto data_scheme_specs = 4;
    repeated AuthorityEntryProto data_authorities = 5;
    repeated android.os.PatternMatcherProto data_paths = 6;
    repeated string data_types = 7;
    int32 priority = 8;
    bool has_partial_types = 9;
    bool get_auto_verify = 10;
}

message AuthorityEntryProto {
    string host = 1;
    bool wild = 2;
    int32 port = 3;
}
+14 −0
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import "frameworks/base/core/proto/android/service/package.proto";
import "frameworks/base/core/proto/android/service/power.proto";
import "frameworks/base/core/proto/android/service/print.proto";
import "frameworks/base/core/proto/android/service/procstats.proto";
import "frameworks/base/core/proto/android/server/activitymanagerservice.proto";
import "frameworks/base/core/proto/android/providers/settings.proto";
import "frameworks/base/core/proto/android/os/incidentheader.proto";
import "frameworks/base/core/proto/android/os/kernelwake.proto";
@@ -108,4 +109,17 @@ message IncidentProto {
        (section).type = SECTION_DUMPSYS,
        (section).args = "procstats --proto"
    ];

    com.android.server.am.proto.ActivityStackSupervisorProto activities = 3012 [
        (section).type = SECTION_DUMPSYS,
        (section).args = "activity --proto activities"
    ];

    com.android.server.am.proto.BroadcastProto broadcasts = 3013 [
        (section).type = SECTION_DUMPSYS,
        (section).args = "activity --proto broadcasts"
    ];

    com.android.server.am.proto.ServiceProto amservices = 3014;
    com.android.server.am.proto.ProcessProto amprocesses = 3015;
}
Loading