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

Commit 52418b56 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Implement Activity Manager Dumpsys --service option"

parents aedbfdfa 6b514141
Loading
Loading
Loading
Loading
+25 −0
Original line number Diff line number Diff line
@@ -68,6 +68,7 @@ import android.text.style.TextAppearanceSpan;
import android.util.ArraySet;
import android.util.Log;
import android.util.SparseArray;
import android.util.proto.ProtoOutputStream;
import android.view.Gravity;
import android.view.NotificationHeaderView;
import android.view.View;
@@ -2447,6 +2448,30 @@ public class Notification implements Parcelable
        notification.extras.putParcelable(EXTRA_BUILDER_APPLICATION_INFO, ai);
    }

    /**
     * @hide
     */
    public void writeToProto(ProtoOutputStream proto, long fieldId) {
        long token = proto.start(fieldId);
        proto.write(NotificationProto.CHANNEL_ID, getChannelId());
        proto.write(NotificationProto.HAS_TICKER_TEXT, this.tickerText != null);
        proto.write(NotificationProto.FLAGS, this.flags);
        proto.write(NotificationProto.COLOR, this.color);
        proto.write(NotificationProto.CATEGORY, this.category);
        proto.write(NotificationProto.GROUP_KEY, this.mGroupKey);
        proto.write(NotificationProto.SORT_KEY, this.mSortKey);
        if (this.actions != null) {
            proto.write(NotificationProto.ACTION_LENGTH, this.actions.length);
        }
        if (this.visibility >= VISIBILITY_SECRET && this.visibility <= VISIBILITY_PUBLIC) {
            proto.write(NotificationProto.VISIBILITY, this.visibility);
        }
        if (publicVersion != null) {
            publicVersion.writeToProto(proto, NotificationProto.PUBLIC_VERSION);
        }
        proto.end(token);
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
+12 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package android.util.proto;

import android.util.AggStats;
import android.util.Duration;

/**
 * This class contains a list of helper functions to write common proto in
@@ -36,4 +37,15 @@ public class ProtoUtils {
        proto.write(AggStats.MAX, max);
        proto.end(aggStatsToken);
    }

    /**
     * Dump Duration to ProtoOutputStream
     * @hide
     */
    public static void toDuration(ProtoOutputStream proto, long fieldId, long startMs, long endMs) {
        final long token = proto.start(fieldId);
        proto.write(Duration.START_MS, startMs);
        proto.write(Duration.END_MS, endMs);
        proto.end(token);
    }
}
+45 −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 = "proto2";
option java_package = "android.app";
option java_multiple_files = true;

package android.app;

/**
 * An android.app.Notification object.
 * Deprecated fields are not included in the proto.
 */
message NotificationProto {
    optional string channel_id = 1;
    optional bool has_ticker_text = 2;
    optional int32 flags = 3;
    optional int32 color = 4;
    optional string category = 5;
    optional string group_key = 6;
    optional string sort_key = 7;
    optional int32 action_length = 8;

    // If this field is not set, then the value is unknown.
    enum Visibility {
        VISIBILITY_SECRET = -1;
        VISIBILITY_PRIVATE = 0;
        VISIBILITY_PUBLIC = 1;
    }
    optional Visibility visibility = 9;
    optional NotificationProto public_version = 10;
}
+5 −1
Original line number Diff line number Diff line
@@ -143,7 +143,11 @@ message IncidentProto {
        (section).args = "activity --proto broadcasts"
    ];

    optional com.android.server.am.proto.ServiceProto amservices = 3014;
    optional com.android.server.am.proto.ActiveServicesProto amservices = 3014 [
        (section).type = SECTION_DUMPSYS,
        (section).args = "activity --proto service"
    ];

    optional com.android.server.am.proto.ProcessProto amprocesses = 3015;

    optional com.android.server.AlarmManagerServiceProto alarm = 3016 [
+157 −4
Original line number Diff line number Diff line
@@ -15,11 +15,14 @@
 */

syntax = "proto2";

import "frameworks/base/core/proto/android/app/notification.proto";
import "frameworks/base/core/proto/android/content/intent.proto";
import "frameworks/base/core/proto/android/server/intentresolver.proto";
import "frameworks/base/core/proto/android/server/windowmanagerservice.proto";
import "frameworks/base/core/proto/android/graphics/rect.proto";
import "frameworks/base/core/proto/android/os/looper.proto";
import "frameworks/base/core/proto/android/util/common.proto";

package com.android.server.am.proto;

@@ -30,11 +33,12 @@ message ActivityManagerServiceProto {

  optional BroadcastProto broadcasts = 2;

  optional ServiceProto services = 3;
  optional ActiveServicesProto services = 3;

  optional ProcessProto processes = 4;
}

// "dumpsys activity --proto activities"
message ActivityStackSupervisorProto {
  optional .com.android.server.wm.proto.ConfigurationContainerProto configuration_container = 1;
  repeated ActivityDisplayProto displays = 2;
@@ -90,6 +94,7 @@ message KeyguardControllerProto {
  optional bool keyguard_occluded = 2;
}

// "dumpsys activity --proto broadcasts"
message BroadcastProto {
  repeated ReceiverListProto  receiver_list = 1;

@@ -164,10 +169,158 @@ message StickyBroadcastProto {
  repeated StickyAction actions = 2;
}

message ServiceProto {
  // TODO: "dumpsys activity --proto services"
// "dumpsys activity --proto service"
message ActiveServicesProto {

  message ServicesByUser {
    optional int32 user_id = 1;
    repeated ServiceRecordProto service_records = 2;
  }
  repeated ServicesByUser services_by_users = 1;
}

// corresponds to ActivityManagerService.GrantUri Java class
message GrantUriProto {
  optional int32 source_user_id = 1;
  optional string uri = 2;
}

message NeededUriGrantsProto {
  optional string target_package = 1;
  optional int32 target_uid = 2;
  optional int32 flags = 3;

  repeated GrantUriProto grants = 4;
}

message UriPermissionOwnerProto {
  optional string owner = 1;
  repeated GrantUriProto read_perms = 2;
  repeated GrantUriProto write_perms = 3;
}

message ServiceRecordProto {
  optional string short_name = 1;
  optional string hex_hash = 2;
  optional bool is_running = 3; // false if the application service is null
  optional int32 pid = 4;
  optional .android.content.IntentProto intent = 5;
  optional string package_name = 6;
  optional string process_name = 7;
  optional string permission = 8;

  message AppInfo {
    optional string base_dir = 1;
    optional string res_dir = 2;
    optional string data_dir = 3;
  }
  optional AppInfo appinfo = 9;
  optional ProcessRecordProto app = 10;
  optional ProcessRecordProto isolated_proc = 11;
  optional bool whitelist_manager = 12;
  optional bool delayed = 13;

  message Foreground {
    optional int32 id = 1;
    optional .android.app.NotificationProto notification = 2;
  }
  optional Foreground foreground = 14;

  optional .android.util.Duration create_real_time = 15;
  optional .android.util.Duration starting_bg_timeout = 16;
  optional .android.util.Duration last_activity_time = 17;
  optional .android.util.Duration restart_time = 18;
  optional bool created_from_fg = 19;

  // variables used to track states related to service start
  message Start {
    optional bool start_requested = 1;
    optional bool delayed_stop = 2;
    optional bool stop_if_killed = 3;
    optional bool call_start = 4;
    optional int32 last_start_id = 5;
  }
  optional Start start = 20;

  message ExecuteNesting {
    optional int32 execute_nesting = 1;
    optional bool execute_fg = 2;
    optional .android.util.Duration executing_start = 3;
  }
  optional ExecuteNesting execute = 21;

  optional .android.util.Duration destory_time = 22;

  message Crash {
    optional int32 restart_count = 1;
    optional .android.util.Duration restart_delay = 2;
    optional .android.util.Duration next_restart_time = 3;
    optional int32 crash_count = 4;
  }
  optional Crash crash = 23;

  message StartItemProto {
    optional int32 id = 1;
    optional .android.util.Duration duration = 2;
    optional int32 delivery_count = 3;
    optional int32 done_executing_count = 4;
    optional .android.content.IntentProto intent = 5;
    optional NeededUriGrantsProto needed_grants = 6;
    optional UriPermissionOwnerProto uri_permissions = 7;
  }
  repeated StartItemProto delivered_starts = 24;
  repeated StartItemProto pending_starts = 25;

  repeated IntentBindRecordProto bindings = 26;
  repeated ConnectionRecordProto connections = 27;
}

message ConnectionRecordProto {
  optional string hex_hash = 1;
  optional int32 user_id = 2;

  enum Flag {
    AUTO_CREATE = 0;
    DEBUG_UNBIND = 1;
    NOT_FG = 2;
    IMPORTANT_BG = 3;
    ABOVE_CLIENT = 4;
    ALLOW_OOM_MANAGEMENT = 5;
    WAIVE_PRIORITY = 6;
    IMPORTANT = 7;
    ADJUST_WITH_ACTIVITY = 8;
    FG_SERVICE_WHILE_WAKE = 9;
    FG_SERVICE = 10;
    TREAT_LIKE_ACTIVITY = 11;
    VISIBLE = 12;
    SHOWING_UI = 13;
    NOT_VISIBLE = 14;
    DEAD = 15;
  }
  repeated Flag flags = 3;
  optional string service_name = 4;
  optional string conn_hex_hash = 5;
}

message AppBindRecordProto {
  optional string hex_hash = 1;
  optional ProcessRecordProto client = 2;
  repeated ConnectionRecordProto connections = 3;
}

message IntentBindRecordProto {
  optional string hex_hash = 1;
  optional bool is_create = 2;
  optional .android.content.IntentProto intent = 3;
  optional string binder = 4;
  optional bool requested = 5;
  optional bool received = 6;
  optional bool has_bound = 7;
  optional bool do_rebind = 8;

  repeated AppBindRecordProto apps = 9;
}

message ProcessProto {
// TODO: "dumpsys activity --proto processes"
message ProcessProto {
}
Loading