incidentd: Adding Notification Listener and Disabling Effects Data to NotificationManager proto output.

RankingHelper will be done in another CL...that's likely a large CL on
its own.

BUG: 65750824
Test: flash on device and check incident.proto output
Change-Id: I740166aed6ac6769ee3e013cf2bd403256eb77dc
This commit is contained in:
Kweku Adams
2017-09-20 17:03:00 -07:00
parent e57a4f85bf
commit 93304b6850
5 changed files with 181 additions and 32 deletions

View File

@@ -21,9 +21,9 @@ import android.annotation.Nullable;
import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;
import android.util.proto.ProtoOutputStream;
import java.io.PrintWriter;
import java.lang.Comparable;
/**
* Identifier for a specific application component
@@ -33,7 +33,7 @@ import java.lang.Comparable;
* pieces of information, encapsulated here, are required to identify
* a component: the package (a String) it exists in, and the class (a String)
* name inside of that package.
*
*
*/
public final class ComponentName implements Parcelable, Cloneable, Comparable<ComponentName> {
private final String mPackage;
@@ -91,7 +91,7 @@ public final class ComponentName implements Parcelable, Cloneable, Comparable<Co
/**
* Create a new component identifier.
*
*
* @param pkg The name of the package that the component exists in. Can
* not be null.
* @param cls The name of the class inside of <var>pkg</var> that
@@ -106,7 +106,7 @@ public final class ComponentName implements Parcelable, Cloneable, Comparable<Co
/**
* Create a new component identifier from a Context and class name.
*
*
* @param pkg A Context for the package implementing the component,
* from which the actual package name will be retrieved.
* @param cls The name of the class inside of <var>pkg</var> that
@@ -120,7 +120,7 @@ public final class ComponentName implements Parcelable, Cloneable, Comparable<Co
/**
* Create a new component identifier from a Context and Class object.
*
*
* @param pkg A Context for the package implementing the component, from
* which the actual package name will be retrieved.
* @param cls The Class object of the desired component, from which the
@@ -141,14 +141,14 @@ public final class ComponentName implements Parcelable, Cloneable, Comparable<Co
public @NonNull String getPackageName() {
return mPackage;
}
/**
* Return the class name of this component.
*/
public @NonNull String getClassName() {
return mClass;
}
/**
* Return the class name, either fully qualified or in a shortened form
* (with a leading '.') if it is a suffix of the package.
@@ -163,7 +163,7 @@ public final class ComponentName implements Parcelable, Cloneable, Comparable<Co
}
return mClass;
}
private static void appendShortClassName(StringBuilder sb, String packageName,
String className) {
if (className.startsWith(packageName)) {
@@ -195,26 +195,26 @@ public final class ComponentName implements Parcelable, Cloneable, Comparable<Co
* class names contained in the ComponentName. You can later recover
* the ComponentName from this string through
* {@link #unflattenFromString(String)}.
*
*
* @return Returns a new String holding the package and class names. This
* is represented as the package name, concatenated with a '/' and then the
* class name.
*
*
* @see #unflattenFromString(String)
*/
public @NonNull String flattenToString() {
return mPackage + "/" + mClass;
}
/**
* The same as {@link #flattenToString()}, but abbreviates the class
* name if it is a suffix of the package. The result can still be used
* with {@link #unflattenFromString(String)}.
*
*
* @return Returns a new String holding the package and class names. This
* is represented as the package name, concatenated with a '/' and then the
* class name.
*
*
* @see #unflattenFromString(String)
*/
public @NonNull String flattenToShortString() {
@@ -250,11 +250,11 @@ public final class ComponentName implements Parcelable, Cloneable, Comparable<Co
* followed by a '.' then the final class name will be the concatenation
* of the package name with the string following the '/'. Thus
* "com.foo/.Blah" becomes package="com.foo" class="com.foo.Blah".
*
*
* @param str The String that was returned by flattenToString().
* @return Returns a new ComponentName containing the package and class
* names that were encoded in <var>str</var>
*
*
* @see #flattenToString()
*/
public static @Nullable ComponentName unflattenFromString(@NonNull String str) {
@@ -269,7 +269,7 @@ public final class ComponentName implements Parcelable, Cloneable, Comparable<Co
}
return new ComponentName(pkg, cls);
}
/**
* Return string representation of this class without the class's name
* as a prefix.
@@ -283,6 +283,12 @@ public final class ComponentName implements Parcelable, Cloneable, Comparable<Co
return "ComponentInfo{" + mPackage + "/" + mClass + "}";
}
/** Put this here so that individual services don't have to reimplement this. @hide */
public void toProto(ProtoOutputStream proto) {
proto.write(ComponentNameProto.PACKAGE_NAME, mPackage);
proto.write(ComponentNameProto.CLASS_NAME, mClass);
}
@Override
public boolean equals(Object obj) {
try {
@@ -311,7 +317,7 @@ public final class ComponentName implements Parcelable, Cloneable, Comparable<Co
}
return this.mClass.compareTo(that.mClass);
}
public int describeContents() {
return 0;
}
@@ -324,10 +330,10 @@ public final class ComponentName implements Parcelable, Cloneable, Comparable<Co
/**
* Write a ComponentName to a Parcel, handling null pointers. Must be
* read with {@link #readFromParcel(Parcel)}.
*
*
* @param c The ComponentName to be written.
* @param out The Parcel in which the ComponentName will be placed.
*
*
* @see #readFromParcel(Parcel)
*/
public static void writeToParcel(ComponentName c, Parcel out) {
@@ -337,23 +343,23 @@ public final class ComponentName implements Parcelable, Cloneable, Comparable<Co
out.writeString(null);
}
}
/**
* Read a ComponentName from a Parcel that was previously written
* with {@link #writeToParcel(ComponentName, Parcel)}, returning either
* a null or new object as appropriate.
*
*
* @param in The Parcel from which to read the ComponentName
* @return Returns a new ComponentName matching the previously written
* object, or null if a null had been written.
*
*
* @see #writeToParcel(ComponentName, Parcel)
*/
public static ComponentName readFromParcel(Parcel in) {
String pkg = in.readString();
return pkg != null ? new ComponentName(pkg, in) : null;
}
public static final Parcelable.Creator<ComponentName> CREATOR
= new Parcelable.Creator<ComponentName>() {
public ComponentName createFromParcel(Parcel in) {
@@ -371,7 +377,7 @@ public final class ComponentName implements Parcelable, Cloneable, Comparable<Co
* must not use this with data written by
* {@link #writeToParcel(ComponentName, Parcel)} since it is not possible
* to handle a null ComponentObject here.
*
*
* @param in The Parcel containing the previously written ComponentName,
* positioned at the location in the buffer where it was written.
*/