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

Commit be6de301 authored by Yi Jin's avatar Yi Jin
Browse files

Enable Window Dumpsys Section

Protobuf defines classes, which can have self recursive message
definitions and cause a bug in generating privacy flags.
Solve the problem here. The details is in incident_section_gen/main.cpp.
The logic is a bit complicated to address more than one level of self
recursion proto message definition.

Also solve a bug when PrivacyBuffer strips fields.
Modify PRIVACY_POLICY_LIST to be type Privacy** in order to allow
initialization by a method.

Bug: 68162512
Test: unit tested and on device tests
Change-Id: I1d0b79f6813e5fd66c4cf5823d0fa17efc57bb1d
parent 6b0ea8ae
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -87,12 +87,12 @@ PrivacyBuffer::stripField(const Privacy* parentPolicy, const PrivacySpec& spec)
    // current field is message type and its sub-fields have extra privacy policies
    uint32_t msgSize = mData.readRawVarint();
    EncodedBuffer::Pointer start = mData.rp()->copy();
    while (mData.rp()->pos() - start.pos() != msgSize) {
    long long token = mProto.start(policy->EncodedFieldId());
    while (mData.rp()->pos() - start.pos() != msgSize) {
        status_t err = stripField(policy, spec);
        if (err != NO_ERROR) return err;
        mProto.end(token);
    }
    mProto.end(token);
    return NO_ERROR;
}

+1 −1
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@ extern const Section* SECTION_LIST[];
 * This is the mapping of section IDs to each section's privacy policy.
 * The section IDs are guaranteed in ascending order, not NULL-terminated since size is provided.
 */
extern const Privacy* PRIVACY_POLICY_LIST[];
extern const Privacy** PRIVACY_POLICY_LIST;

extern const int PRIVACY_POLICY_COUNT;

+10 −0
Original line number Diff line number Diff line
@@ -260,3 +260,13 @@ TEST_F(PrivacyBufferTest, BadDataInNestedMessage) {
    PrivacySpec spec;
    ASSERT_EQ(privacyBuf.strip(spec), BAD_VALUE);
}

TEST_F(PrivacyBufferTest, SelfRecursionMessage) {
    string input = "\x2a\"" + VARINT_FIELD_1 + STRING_FIELD_2 + MESSAGE_FIELD_5;
    writeToFdBuffer(input);
    Privacy* field5 = create_message_privacy(5, NULL);
    Privacy* list[] = { create_privacy(1, OTHER_TYPE, LOCAL), field5, NULL };
    field5->children = list;
    string expected = "\x2a\x1c" + STRING_FIELD_2 + "\x2a\xd" + STRING_FIELD_2;
    assertStrip(EXPLICIT, expected, field5);
}
+4 −2
Original line number Diff line number Diff line
@@ -20,9 +20,11 @@ Privacy* list[] = {
Privacy field_0 { 0, 11, list, EXPLICIT, NULL };
Privacy field_1 { 1, 9, NULL, AUTOMATIC, NULL };

const Privacy* PRIVACY_POLICY_LIST[] = {
Privacy* final_list[] = {
    &field_0,
    &field_1
};

const Privacy** PRIVACY_POLICY_LIST = const_cast<const Privacy**>(final_list);

const int PRIVACY_POLICY_COUNT = 2;
+6 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import "frameworks/base/core/proto/android/os/pagetypeinfo.proto";
import "frameworks/base/core/proto/android/os/procrank.proto";
import "frameworks/base/core/proto/android/server/activitymanagerservice.proto";
import "frameworks/base/core/proto/android/server/alarmmanagerservice.proto";
import "frameworks/base/core/proto/android/server/windowmanagerservice.proto";
import "frameworks/base/core/proto/android/server/fingerprint.proto";
import "frameworks/base/core/proto/android/server/powermanagerservice.proto";
import "frameworks/base/core/proto/android/service/appwidget.proto";
@@ -135,4 +136,9 @@ message IncidentProto {
        (section).type = SECTION_DUMPSYS,
        (section).args = "alarm --proto"
    ];

    optional com.android.server.wm.proto.WindowManagerServiceProto window = 3017 [
        (section).type = SECTION_DUMPSYS,
        (section).args = "window --proto"
    ];
}
Loading