Merge "Enable dumpsys package in incidentd"

This commit is contained in:
Yi Jin
2017-10-17 18:01:29 +00:00
committed by Android (Google) Code Review
7 changed files with 61 additions and 16 deletions

View File

@@ -18,6 +18,7 @@ package android.content.pm;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.proto.ProtoOutputStream;
/**
* Definition of a single optional hardware or software feature of an Android
@@ -113,6 +114,18 @@ public class FeatureInfo implements Parcelable {
dest.writeInt(flags);
}
/** @hide */
public void writeToProto(ProtoOutputStream proto, long fieldId) {
long token = proto.start(fieldId);
if (name != null) {
proto.write(FeatureInfoProto.NAME, name);
}
proto.write(FeatureInfoProto.VERSION, version);
proto.write(FeatureInfoProto.GLES_VERSION, getGlEsVersion());
proto.write(FeatureInfoProto.FLAGS, flags);
proto.end(token);
}
public static final Creator<FeatureInfo> CREATOR = new Creator<FeatureInfo>() {
@Override
public FeatureInfo createFromParcel(Parcel source) {

View File

@@ -0,0 +1,29 @@
/*
* Copyright (C) 2016 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.content.pm";
option java_multiple_files = true;
package android.content.pm;
message FeatureInfoProto {
optional string name = 1;
optional int32 version = 2;
optional string gles_version = 3;
optional int32 flags = 4;
}

View File

@@ -100,7 +100,11 @@ message IncidentProto {
(section).args = "diskstats --proto"
];
optional android.service.pm.PackageServiceDumpProto package = 3008;
optional android.service.pm.PackageServiceDumpProto package = 3008 [
(section).type = SECTION_DUMPSYS,
(section).args = "package --proto"
];
optional android.service.power.PowerServiceDumpProto power = 3009;
optional android.service.print.PrintServiceDumpProto print = 3010;

View File

@@ -17,6 +17,8 @@
syntax = "proto2";
package android.service.pm;
import "frameworks/base/core/proto/android/content/featureinfo.proto";
option java_multiple_files = true;
option java_outer_classname = "PackageServiceProto";
@@ -36,10 +38,6 @@ message PackageServiceDumpProto {
// Should be filled if is_jar is false
optional string apk = 4;
}
message FeatureProto {
optional string name = 1;
optional int32 version = 2;
}
message SharedUserProto {
optional int32 user_id = 1;
optional string name = 2;
@@ -49,7 +47,7 @@ message PackageServiceDumpProto {
optional PackageShortProto required_verifier_package = 1;
optional PackageShortProto verifier_package = 2;
repeated SharedLibraryProto shared_libraries = 3;
repeated FeatureProto features = 4;
repeated android.content.pm.FeatureInfoProto features = 4;
repeated PackageProto packages = 5;
repeated SharedUserProto shared_users = 6;
// Messages from the settings problem file

View File

@@ -21860,11 +21860,7 @@ Slog.v(TAG, ":: stepped forward, applying functor at tag " + parser.getName());
synchronized (mAvailableFeatures) {
final int count = mAvailableFeatures.size();
for (int i = 0; i < count; i++) {
final FeatureInfo feat = mAvailableFeatures.valueAt(i);
final long featureToken = proto.start(PackageServiceDumpProto.FEATURES);
proto.write(PackageServiceDumpProto.FeatureProto.NAME, feat.name);
proto.write(PackageServiceDumpProto.FeatureProto.VERSION, feat.version);
proto.end(featureToken);
mAvailableFeatures.valueAt(i).writeToProto(proto, PackageServiceDumpProto.FEATURES);
}
}
}

View File

@@ -4929,11 +4929,7 @@ public final class Settings {
void dumpSharedUsersProto(ProtoOutputStream proto) {
final int count = mSharedUsers.size();
for (int i = 0; i < count; i++) {
final SharedUserSetting su = mSharedUsers.valueAt(i);
final long sharedUserToken = proto.start(PackageServiceDumpProto.SHARED_USERS);
proto.write(PackageServiceDumpProto.SharedUserProto.USER_ID, su.userId);
proto.write(PackageServiceDumpProto.SharedUserProto.NAME, su.name);
proto.end(sharedUserToken);
mSharedUsers.valueAt(i).writeToProto(proto, PackageServiceDumpProto.SHARED_USERS);
}
}

View File

@@ -18,7 +18,9 @@ package com.android.server.pm;
import android.annotation.Nullable;
import android.content.pm.PackageParser;
import android.service.pm.PackageServiceDumpProto;
import android.util.ArraySet;
import android.util.proto.ProtoOutputStream;
import java.util.ArrayList;
import java.util.Collection;
@@ -53,6 +55,13 @@ public final class SharedUserSetting extends SettingBase {
+ name + "/" + userId + "}";
}
public void writeToProto(ProtoOutputStream proto, long fieldId) {
long token = proto.start(fieldId);
proto.write(PackageServiceDumpProto.SharedUserProto.USER_ID, userId);
proto.write(PackageServiceDumpProto.SharedUserProto.NAME, name);
proto.end(token);
}
void removePackage(PackageSetting packageSetting) {
if (packages.remove(packageSetting)) {
// recalculate the pkgFlags for this shared user if needed