diff options
Diffstat (limited to 'sched/src')
31 files changed, 259 insertions, 31 deletions
diff --git a/sched/src/com/android/sched/item/ManagedItem.java b/sched/src/com/android/sched/item/ManagedItem.java index 3e69e75..dd42e28 100644 --- a/sched/src/com/android/sched/item/ManagedItem.java +++ b/sched/src/com/android/sched/item/ManagedItem.java @@ -16,13 +16,15 @@ package com.android.sched.item; +import com.android.sched.util.HasDescription; + import javax.annotation.CheckForNull; import javax.annotation.Nonnull; /** * Represents an {@link Item} composed of other items. */ -public class ManagedItem { +public class ManagedItem implements HasDescription { // Bitmap, representing this item in conjunction with @ComposedOf, inheritance or inner @CheckForNull protected long[] bitmap; @@ -62,6 +64,7 @@ public class ManagedItem { return name; } + @Override @Nonnull public String getDescription() { return description; diff --git a/sched/src/com/android/sched/marker/ManagedMarker.java b/sched/src/com/android/sched/marker/ManagedMarker.java index 3496f49..7b75f11 100644 --- a/sched/src/com/android/sched/marker/ManagedMarker.java +++ b/sched/src/com/android/sched/marker/ManagedMarker.java @@ -18,6 +18,7 @@ package com.android.sched.marker; import com.android.sched.item.Description; import com.android.sched.item.Items; +import com.android.sched.util.HasDescription; import com.android.sched.util.findbugs.SuppressFBWarnings; import com.android.sched.util.log.LoggerFactory; @@ -33,7 +34,7 @@ import javax.annotation.Nonnull; /** * Represents a {@link Marker} with all annotations extracted. */ -public class ManagedMarker { +public class ManagedMarker implements HasDescription { private static final Logger logger = LoggerFactory.getLogger(); // @Name @@ -108,6 +109,7 @@ public class ManagedMarker { return name; } + @Override @Nonnull public String getDescription() { return description; diff --git a/sched/src/com/android/sched/scheduler/ManagedSchedulable.java b/sched/src/com/android/sched/scheduler/ManagedSchedulable.java index fd0390d..24dae82 100644 --- a/sched/src/com/android/sched/scheduler/ManagedSchedulable.java +++ b/sched/src/com/android/sched/scheduler/ManagedSchedulable.java @@ -21,13 +21,14 @@ import com.android.sched.item.Description; import com.android.sched.item.Items; import com.android.sched.item.Synchronized; import com.android.sched.schedulable.Schedulable; +import com.android.sched.util.HasDescription; import javax.annotation.Nonnull; /** * Represents a {@link Schedulable} with all annotations and signatures extracted. */ -public abstract class ManagedSchedulable { +public abstract class ManagedSchedulable implements HasDescription { @Nonnull private final Class<? extends Schedulable> schedulable; @@ -92,6 +93,7 @@ public abstract class ManagedSchedulable { @Nonnull public abstract Class<? extends Component> getRunOn(); + @Override @Nonnull public String getDescription() { return description; diff --git a/sched/src/com/android/sched/scheduler/Plan.java b/sched/src/com/android/sched/scheduler/Plan.java index 6c6e945..8299f65 100644 --- a/sched/src/com/android/sched/scheduler/Plan.java +++ b/sched/src/com/android/sched/scheduler/Plan.java @@ -38,7 +38,7 @@ import javax.annotation.Nonnull; * * @param <T> the type of the root <i>data</i> */ -public class Plan<T extends Component> implements Iterable<PlanStep> { +public class Plan<T extends Component> implements Iterable<PlanStep> { @Nonnull private final Logger logger = LoggerFactory.getLogger(); diff --git a/sched/src/com/android/sched/util/HasDescription.java b/sched/src/com/android/sched/util/HasDescription.java new file mode 100644 index 0000000..095a703 --- /dev/null +++ b/sched/src/com/android/sched/util/HasDescription.java @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2014 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. + */ + +package com.android.sched.util; + +import javax.annotation.Nonnull; + +/** + * Interface implemented by descriptive classes. + */ +public interface HasDescription { + @Nonnull + String getDescription(); +}
\ No newline at end of file diff --git a/sched/src/com/android/sched/util/codec/DoubleCodec.java b/sched/src/com/android/sched/util/codec/DoubleCodec.java index a2be42f..6fc2277 100644 --- a/sched/src/com/android/sched/util/codec/DoubleCodec.java +++ b/sched/src/com/android/sched/util/codec/DoubleCodec.java @@ -18,6 +18,9 @@ package com.android.sched.util.codec; import com.android.sched.util.config.ConfigurationError; +import java.util.Collections; +import java.util.List; + import javax.annotation.Nonnull; /** @@ -48,6 +51,12 @@ public class DoubleCodec implements StringCodec<Double> { @Override @Nonnull + public List<ValueDescription> getValueDescriptions() { + return Collections.<ValueDescription> emptyList(); + } + + @Override + @Nonnull public Double checkString(@Nonnull CodecContext context, @Nonnull String string) throws ParsingException { try { diff --git a/sched/src/com/android/sched/util/codec/EnumCodec.java b/sched/src/com/android/sched/util/codec/EnumCodec.java index 5c74e28..b31b245 100644 --- a/sched/src/com/android/sched/util/codec/EnumCodec.java +++ b/sched/src/com/android/sched/util/codec/EnumCodec.java @@ -16,8 +16,11 @@ package com.android.sched.util.codec; +import com.android.sched.util.HasDescription; import com.android.sched.util.codec.KeyValueCodec.Entry; +import java.util.List; + import javax.annotation.CheckForNull; import javax.annotation.Nonnull; @@ -31,12 +34,23 @@ public class EnumCodec<T extends Enum<T>> implements StringCodec<T> { KeyValueCodec<T> parser; public EnumCodec(@Nonnull T[] values) { + assert values.length > 0; + @SuppressWarnings("unchecked") Entry<T>[] entries = new Entry[values.length]; int idx = 0; - for (T value : values) { - entries[idx++] = new Entry<T>(value.name().replace('_', '-'), value); + if (values instanceof HasDescription[]) { + for (T value : values) { + entries[idx++] = + new Entry<T>(value.name().replace('_', '-'), value, + ((HasDescription) value).getDescription()); + } + } else { + for (T value : values) { + + entries[idx++] = new Entry<T>(value.name().replace('_', '-'), value); + } } parser = new KeyValueCodec<T>(entries); @@ -83,6 +97,12 @@ public class EnumCodec<T extends Enum<T>> implements StringCodec<T> { @Override @Nonnull + public List<ValueDescription> getValueDescriptions() { + return parser.getValueDescriptions(); + } + + @Override + @Nonnull public String formatValue(@Nonnull T value) { return parser.formatValue(value); } diff --git a/sched/src/com/android/sched/util/codec/FileOrDirCodec.java b/sched/src/com/android/sched/util/codec/FileOrDirCodec.java index 67e07a2..fa5d77a 100644 --- a/sched/src/com/android/sched/util/codec/FileOrDirCodec.java +++ b/sched/src/com/android/sched/util/codec/FileOrDirCodec.java @@ -16,9 +16,13 @@ package com.android.sched.util.codec; +import com.android.sched.util.codec.Parser.ValueDescription; import com.android.sched.util.file.FileOrDirectory.ChangePermission; import com.android.sched.util.file.FileOrDirectory.Existence; +import java.util.Collections; +import java.util.List; + import javax.annotation.Nonnull; /** @@ -81,4 +85,9 @@ public abstract class FileOrDirCodec { return sb.toString(); } } + + @Nonnull + public List<ValueDescription> getValueDescriptions() { + return Collections.<ValueDescription> emptyList(); + } } diff --git a/sched/src/com/android/sched/util/codec/ImplementationName.java b/sched/src/com/android/sched/util/codec/ImplementationName.java index 01a53fc..d072ca6 100644 --- a/sched/src/com/android/sched/util/codec/ImplementationName.java +++ b/sched/src/com/android/sched/util/codec/ImplementationName.java @@ -29,5 +29,6 @@ import java.lang.annotation.Target; public @interface ImplementationName { Class<?> iface(); String name(); + String description() default ""; Class<? extends ImplementationFilter> filter() default ImplementationAlwaysValid.class; } diff --git a/sched/src/com/android/sched/util/codec/KeyValueCodec.java b/sched/src/com/android/sched/util/codec/KeyValueCodec.java index 4f16b47..c8923fb 100644 --- a/sched/src/com/android/sched/util/codec/KeyValueCodec.java +++ b/sched/src/com/android/sched/util/codec/KeyValueCodec.java @@ -18,11 +18,14 @@ package com.android.sched.util.codec; import com.android.sched.util.config.ConfigurationError; +import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.HashSet; +import java.util.List; import java.util.Set; +import javax.annotation.CheckForNull; import javax.annotation.Nonnull; /** @@ -34,6 +37,8 @@ public class KeyValueCodec<T> implements StringCodec<T> { private boolean ignoreCase = false; @Nonnull private final Entry<T>[] entries; + @CheckForNull + private List<ValueDescription> descriptions; public KeyValueCodec(@Nonnull Entry<T>[] entries) { this.entries = Arrays.copyOf(entries, entries.length); @@ -86,6 +91,23 @@ public class KeyValueCodec<T> implements StringCodec<T> { @Override @Nonnull + public List<ValueDescription> getValueDescriptions() { + if (descriptions == null) { + descriptions = new ArrayList<ValueDescription>(entries.length); + + for (Entry<T> entry : entries) { + if (entry.description != null) { + descriptions.add(new ValueDescription(entry.key, entry.description)); + } + } + } + + assert descriptions != null; + return descriptions; + } + + @Override + @Nonnull public T checkString(@Nonnull CodecContext context, @Nonnull String string) throws ParsingException { if (ignoreCase) { @@ -153,11 +175,22 @@ public class KeyValueCodec<T> implements StringCodec<T> { String key; @Nonnull T value; + @CheckForNull + String description; public Entry (@Nonnull String key, @Nonnull T value) { this.key = key; this.value = value; } + + public Entry (@Nonnull String key, @Nonnull T value, @CheckForNull String description) { + this.key = key; + this.value = value; + + if (description != null && !description.isEmpty()) { + this.description = description; + } + } } @Override diff --git a/sched/src/com/android/sched/util/codec/KeywordsCodec.java b/sched/src/com/android/sched/util/codec/KeywordsCodec.java index d75d3c4..d990975 100644 --- a/sched/src/com/android/sched/util/codec/KeywordsCodec.java +++ b/sched/src/com/android/sched/util/codec/KeywordsCodec.java @@ -18,6 +18,8 @@ package com.android.sched.util.codec; import com.android.sched.util.codec.KeyValueCodec.Entry; +import java.util.List; + import javax.annotation.CheckForNull; import javax.annotation.Nonnull; @@ -29,12 +31,17 @@ public class KeywordsCodec implements StringCodec<String> { KeyValueCodec<String> parser; public KeywordsCodec(@Nonnull String[] keywords) { + this(keywords, new String[keywords.length]); + } + + public KeywordsCodec(@Nonnull String[] keywords, @Nonnull String[] descriptions) { @SuppressWarnings("unchecked") Entry<String>[] entries = new Entry[keywords.length]; int idx = 0; for (String keyword : keywords) { - entries[idx++] = new Entry<String>(keyword, keyword); + entries[idx] = new Entry<String>(keyword, keyword, descriptions[idx]); + idx++; } parser = new KeyValueCodec<String>(entries); @@ -81,6 +88,12 @@ public class KeywordsCodec implements StringCodec<String> { @Override @Nonnull + public List<ValueDescription> getValueDescriptions() { + return parser.getValueDescriptions(); + } + + @Override + @Nonnull public String formatValue(@Nonnull String value) { return parser.formatValue(value); } diff --git a/sched/src/com/android/sched/util/codec/ListCodec.java b/sched/src/com/android/sched/util/codec/ListCodec.java index 01d106e..25f5c75 100644 --- a/sched/src/com/android/sched/util/codec/ListCodec.java +++ b/sched/src/com/android/sched/util/codec/ListCodec.java @@ -237,6 +237,12 @@ public class ListCodec<T> implements StringCodec<List<T>> { @Override @Nonnull + public List<ValueDescription> getValueDescriptions() { + return parser.getValueDescriptions(); + } + + @Override + @Nonnull public String formatValue(@Nonnull List<T> list) { StringBuilder sb = new StringBuilder(); diff --git a/sched/src/com/android/sched/util/codec/LongCodec.java b/sched/src/com/android/sched/util/codec/LongCodec.java index cf9b8da..8bdd98c 100644 --- a/sched/src/com/android/sched/util/codec/LongCodec.java +++ b/sched/src/com/android/sched/util/codec/LongCodec.java @@ -18,6 +18,9 @@ package com.android.sched.util.codec; import com.android.sched.util.config.ConfigurationError; +import java.util.Collections; +import java.util.List; + import javax.annotation.Nonnull; /** @@ -52,6 +55,12 @@ public class LongCodec implements StringCodec<Long>{ @Override @Nonnull + public List<ValueDescription> getValueDescriptions() { + return Collections.<ValueDescription> emptyList(); + } + + @Override + @Nonnull public Long checkString(@Nonnull CodecContext context, @Nonnull String string) throws ParsingException { try { diff --git a/sched/src/com/android/sched/util/codec/Parser.java b/sched/src/com/android/sched/util/codec/Parser.java index 35871fd..0b72823 100644 --- a/sched/src/com/android/sched/util/codec/Parser.java +++ b/sched/src/com/android/sched/util/codec/Parser.java @@ -16,6 +16,10 @@ package com.android.sched.util.codec; +import com.android.sched.util.HasDescription; + +import java.util.List; + import javax.annotation.CheckForNull; import javax.annotation.Nonnull; @@ -49,4 +53,36 @@ public interface Parser<T> { */ @Nonnull public String getUsage(); + + /** + * @return a description for some possible values. + */ + @Nonnull + public List<ValueDescription> getValueDescriptions(); + + /** + * Description of a value. + */ + public static class ValueDescription implements HasDescription { + @Nonnull + private final String value; + @Nonnull + private final String description; + + public ValueDescription(@Nonnull String value, @Nonnull String description) { + this.value = value; + this.description = description; + } + + @Nonnull + public String getValue() { + return value; + } + + @Override + @Nonnull + public String getDescription() { + return description; + } + } } diff --git a/sched/src/com/android/sched/util/codec/PathCodec.java b/sched/src/com/android/sched/util/codec/PathCodec.java index a1b2485..c221fb7 100644 --- a/sched/src/com/android/sched/util/codec/PathCodec.java +++ b/sched/src/com/android/sched/util/codec/PathCodec.java @@ -18,6 +18,8 @@ package com.android.sched.util.codec; import java.io.File; +import java.util.Collections; +import java.util.List; import javax.annotation.CheckForNull; import javax.annotation.Nonnull; @@ -33,6 +35,12 @@ public class PathCodec implements StringCodec<File> { } @Override + @Nonnull + public List<ValueDescription> getValueDescriptions() { + return Collections.<ValueDescription> emptyList(); + } + + @Override @CheckForNull public File checkString(@Nonnull CodecContext context, @Nonnull String value) { return null; diff --git a/sched/src/com/android/sched/util/codec/Selector.java b/sched/src/com/android/sched/util/codec/Selector.java index 3e4d90e..4b3046f 100644 --- a/sched/src/com/android/sched/util/codec/Selector.java +++ b/sched/src/com/android/sched/util/codec/Selector.java @@ -20,6 +20,7 @@ import com.google.common.base.Joiner; import com.android.sched.reflections.ReflectionFactory; import com.android.sched.reflections.ReflectionManager; +import com.android.sched.util.codec.Parser.ValueDescription; import com.android.sched.util.config.ConfigurationError; import com.android.sched.util.config.ReflectDefaultCtorFactory; @@ -47,6 +48,8 @@ public abstract class Selector<T> { private final Class<T> type; @CheckForNull private Map<String, Class<? extends T>> propertyValues; + @CheckForNull + private List<ValueDescription> descriptions; public Selector(@Nonnull Class<T> type) { this.type = type; @@ -69,9 +72,39 @@ public abstract class Selector<T> { } @Nonnull + public List<ValueDescription> getValueDescriptions() { + if (descriptions == null) { + ensureScan(); + assert propertyValues != null; + + descriptions = new ArrayList<ValueDescription>(propertyValues.size()); + + for (Class<? extends T> subClass : propertyValues.values()) { + ImplementationName value = subClass.getAnnotation(ImplementationName.class); + assert value != null; + + if (!value.description().isEmpty()) { + descriptions.add(new ValueDescription(value.name(), value.description())); + } + } + + Collections.sort(descriptions, new Comparator<ValueDescription>(){ + @Override + public int compare(ValueDescription o1, ValueDescription o2) { + return o1.getValue().compareToIgnoreCase(o2.getValue()); + }}); + + } + + assert descriptions != null; + return descriptions; + } + + @Nonnull public Class<? extends T> getClass(@Nonnull String string) throws ParsingException { ensureScan(); assert propertyValues != null; + Class<? extends T> value = propertyValues.get(string); if (value == null) { @@ -143,6 +176,7 @@ public abstract class Selector<T> { private synchronized void ensureScan() { if (propertyValues == null) { propertyValues = new HashMap<String, Class<? extends T>>(); + ReflectionManager reflectionManager = ReflectionFactory.getManager(); Set<Class<? extends T>> propertyValueClasses = reflectionManager.getSubTypesOf(type); propertyValueClasses.add(type); diff --git a/sched/src/com/android/sched/util/config/expression/Expression.java b/sched/src/com/android/sched/util/config/expression/Expression.java index d2fbf5d..4dc3c31 100644 --- a/sched/src/com/android/sched/util/config/expression/Expression.java +++ b/sched/src/com/android/sched/util/config/expression/Expression.java @@ -16,6 +16,7 @@ package com.android.sched.util.config.expression; +import com.android.sched.util.HasDescription; import com.android.sched.util.config.ConfigChecker; import com.android.sched.util.config.PropertyIdException; import com.android.sched.util.config.id.PropertyId; @@ -27,9 +28,7 @@ import javax.annotation.Nonnull; /** * Abstract class representing an expression. */ -public abstract class Expression { - @Nonnull - public abstract String getDescription(); +public abstract class Expression implements HasDescription { @Nonnull public abstract String getCause(@Nonnull ConfigChecker checker) throws PropertyIdException; diff --git a/sched/src/com/android/sched/util/config/id/PropertyId.java b/sched/src/com/android/sched/util/config/id/PropertyId.java index c2579ee..e567b4f 100644 --- a/sched/src/com/android/sched/util/config/id/PropertyId.java +++ b/sched/src/com/android/sched/util/config/id/PropertyId.java @@ -17,6 +17,7 @@ package com.android.sched.util.config.id; +import com.android.sched.util.HasDescription; import com.android.sched.util.codec.CodecContext; import com.android.sched.util.codec.ParsingException; import com.android.sched.util.codec.StringCodec; @@ -33,7 +34,7 @@ import javax.annotation.Nonnull; * An instance of this type identifies a particular configuration property. * @param <T> Type of the configuration property. */ -public class PropertyId<T> extends KeyId<T, String> { +public class PropertyId<T> extends KeyId<T, String> implements HasDescription { @Nonnull private final String description; @@ -105,6 +106,7 @@ public class PropertyId<T> extends KeyId<T, String> { return defaultValues; } + @Override @Nonnull public String getDescription() { return description; diff --git a/sched/src/com/android/sched/util/location/Location.java b/sched/src/com/android/sched/util/location/Location.java index 2fa2fed..f3a2208 100644 --- a/sched/src/com/android/sched/util/location/Location.java +++ b/sched/src/com/android/sched/util/location/Location.java @@ -16,12 +16,10 @@ package com.android.sched.util.location; -import javax.annotation.Nonnull; +import com.android.sched.util.HasDescription; /** * Base class to describe a location. */ -public abstract class Location { - @Nonnull - public abstract String getDescription(); +public abstract class Location implements HasDescription { } diff --git a/sched/src/com/android/sched/util/log/StatisticOnlyTracer.java b/sched/src/com/android/sched/util/log/StatisticOnlyTracer.java index 81095e5..a3c2be1 100644 --- a/sched/src/com/android/sched/util/log/StatisticOnlyTracer.java +++ b/sched/src/com/android/sched/util/log/StatisticOnlyTracer.java @@ -60,7 +60,8 @@ import javax.annotation.Nonnull; /** * Tracer implementation which only collects statistics on a pseudo-single event. */ -@ImplementationName(iface = Tracer.class, name = "stat-only") +@ImplementationName(iface = Tracer.class, name = "stat-only", + description = "collect statistics without event information") public final class StatisticOnlyTracer implements Tracer { @Nonnull private final Logger logger = LoggerFactory.getLogger(); diff --git a/sched/src/com/android/sched/util/log/stats/Statistic.java b/sched/src/com/android/sched/util/log/stats/Statistic.java index 93d2535..0ece4eb 100644 --- a/sched/src/com/android/sched/util/log/stats/Statistic.java +++ b/sched/src/com/android/sched/util/log/stats/Statistic.java @@ -18,6 +18,7 @@ package com.android.sched.util.log.stats; import com.google.common.collect.Iterators; +import com.android.sched.util.HasDescription; import com.android.sched.util.codec.Formatter; import com.android.sched.util.codec.ToStringFormatter; import com.android.sched.util.table.DataHeader; @@ -29,7 +30,7 @@ import javax.annotation.Nonnull; /** * Represents a statistic. */ -public abstract class Statistic implements DataHeader { +public abstract class Statistic implements DataHeader, HasDescription { @Nonnull private final StatisticId<? extends Statistic> id; @@ -44,9 +45,6 @@ public abstract class Statistic implements DataHeader { return id; } - @Nonnull - public abstract String getDescription(); - @Override @Nonnull public String toString() { diff --git a/sched/src/com/android/sched/util/log/stats/StatisticId.java b/sched/src/com/android/sched/util/log/stats/StatisticId.java index 30444c5..181e5d0 100644 --- a/sched/src/com/android/sched/util/log/stats/StatisticId.java +++ b/sched/src/com/android/sched/util/log/stats/StatisticId.java @@ -16,6 +16,7 @@ package com.android.sched.util.log.stats; +import com.android.sched.util.HasDescription; import com.android.sched.util.config.ReflectFactory; import java.util.Collection; @@ -29,7 +30,7 @@ import javax.annotation.Nonnull; * * @param <T> Type of the statistic. */ -public class StatisticId<T extends Statistic> { +public class StatisticId<T extends Statistic> implements HasDescription { @Nonnull private static Map<Class<? extends Statistic>, Statistic> dummies = new ConcurrentHashMap<Class<? extends Statistic>, Statistic>(); @@ -75,6 +76,7 @@ public class StatisticId<T extends Statistic> { return name; } + @Override @Nonnull public String getDescription() { return description; diff --git a/sched/src/com/android/sched/util/log/tracer/ProbeManagerCodec.java b/sched/src/com/android/sched/util/log/tracer/ProbeManagerCodec.java index 2b20ef2..7a5b471 100644 --- a/sched/src/com/android/sched/util/log/tracer/ProbeManagerCodec.java +++ b/sched/src/com/android/sched/util/log/tracer/ProbeManagerCodec.java @@ -83,6 +83,12 @@ public class ProbeManagerCodec implements StringCodec<ProbeManager> { @Override @Nonnull + public List<com.android.sched.util.codec.Parser.ValueDescription> getValueDescriptions() { + return parser.getValueDescriptions(); + } + + @Override + @Nonnull public String formatValue(@Nonnull ProbeManager data) { return parser.formatValue(data.getProbes()); } diff --git a/sched/src/com/android/sched/util/log/tracer/filter/EventFilter.java b/sched/src/com/android/sched/util/log/tracer/filter/EventFilter.java index c2eb616..7586046 100644 --- a/sched/src/com/android/sched/util/log/tracer/filter/EventFilter.java +++ b/sched/src/com/android/sched/util/log/tracer/filter/EventFilter.java @@ -16,6 +16,7 @@ package com.android.sched.util.log.tracer.filter; +import com.android.sched.util.HasDescription; import com.android.sched.util.log.EventType; import javax.annotation.Nonnull; @@ -23,8 +24,6 @@ import javax.annotation.Nonnull; /** * Interface of a {@link EventType} filter. */ -public interface EventFilter { +public interface EventFilter extends HasDescription { public boolean isEnabled(@Nonnull EventType type); - @Nonnull - public String getDescription(); } diff --git a/sched/src/com/android/sched/util/log/tracer/probe/Probe.java b/sched/src/com/android/sched/util/log/tracer/probe/Probe.java index d311e9f..df937e5 100644 --- a/sched/src/com/android/sched/util/log/tracer/probe/Probe.java +++ b/sched/src/com/android/sched/util/log/tracer/probe/Probe.java @@ -16,6 +16,8 @@ package com.android.sched.util.log.tracer.probe; +import com.android.sched.util.HasDescription; + import javax.annotation.CheckForNull; import javax.annotation.Nonnegative; import javax.annotation.Nonnull; @@ -23,7 +25,7 @@ import javax.annotation.Nonnull; /** * Abstract class for a Probe. */ -public abstract class Probe implements Comparable<Probe> { +public abstract class Probe implements Comparable<Probe>, HasDescription { public static final int MAX_PRIORITY = 0; public static final int MIN_PRIORITY = 12; @@ -55,6 +57,7 @@ public abstract class Probe implements Comparable<Probe> { this.priority = priority; } + @Override @Nonnull public String getDescription() { return this.description; diff --git a/sched/src/com/android/sched/util/log/tracer/probe/ThreadTimeProbe.java b/sched/src/com/android/sched/util/log/tracer/probe/ThreadTimeProbe.java index 1a180f2..f1d2de9 100644 --- a/sched/src/com/android/sched/util/log/tracer/probe/ThreadTimeProbe.java +++ b/sched/src/com/android/sched/util/log/tracer/probe/ThreadTimeProbe.java @@ -27,7 +27,7 @@ import javax.annotation.Nonnull; /** * Probe which take the usage of per thread CPU time. */ -@ImplementationName(iface = Probe.class, name = "thread-time") +@ImplementationName(iface = Probe.class, name = "thread-cpu-time") public class ThreadTimeProbe extends TimeNanosProbe { @Nonnull private final ThreadMXBean threadMXBean; diff --git a/sched/src/com/android/sched/util/log/tracer/watcher/AllocationWatcher.java b/sched/src/com/android/sched/util/log/tracer/watcher/AllocationWatcher.java index 78fd9b8..af85d00 100644 --- a/sched/src/com/android/sched/util/log/tracer/watcher/AllocationWatcher.java +++ b/sched/src/com/android/sched/util/log/tracer/watcher/AllocationWatcher.java @@ -89,7 +89,8 @@ public class AllocationWatcher implements ObjectWatcher<Object> { /** * Install a {@link AllocationWatcher} */ - @ImplementationName(iface = WatcherInstaller.class, name = "object-alloc") + @ImplementationName(iface = WatcherInstaller.class, name = "object-alloc", + description = "record object and array allocations globally") public static class AllocationWatcherInstaller implements WatcherInstaller { @Override public void install(@Nonnull Tracer tracer) { diff --git a/sched/src/com/android/sched/util/log/tracer/watcher/ArrayListWatcher.java b/sched/src/com/android/sched/util/log/tracer/watcher/ArrayListWatcher.java index 76db58a..65862a0 100644 --- a/sched/src/com/android/sched/util/log/tracer/watcher/ArrayListWatcher.java +++ b/sched/src/com/android/sched/util/log/tracer/watcher/ArrayListWatcher.java @@ -152,7 +152,8 @@ public class ArrayListWatcher implements ObjectWatcher<ArrayList<?>> { /** * Install a {@link ArrayListWatcher} */ - @ImplementationName(iface = WatcherInstaller.class, name = "arraylist-capacity") + @ImplementationName(iface = WatcherInstaller.class, name = "arraylist-capacity", + description = "record state of the array backed by ArrayList") public static class ArrayListWatcherInstaller implements WatcherInstaller { @Override public void install(@Nonnull Tracer tracer) { diff --git a/sched/src/com/android/sched/util/log/tracer/watcher/DetailedAllocationWatcher.java b/sched/src/com/android/sched/util/log/tracer/watcher/DetailedAllocationWatcher.java index f8a97e3..0349359 100644 --- a/sched/src/com/android/sched/util/log/tracer/watcher/DetailedAllocationWatcher.java +++ b/sched/src/com/android/sched/util/log/tracer/watcher/DetailedAllocationWatcher.java @@ -122,7 +122,8 @@ public class DetailedAllocationWatcher implements ObjectWatcher<Object> { /** * Install a {@link DetailedAllocationWatcher} */ - @ImplementationName(iface = WatcherInstaller.class, name = "detailed-object-alloc") + @ImplementationName(iface = WatcherInstaller.class, name = "detailed-object-alloc", + description = "record object and array allocations type by type") public static class DetailedAllocationWatcherInstaller implements WatcherInstaller { @Override public void install(@Nonnull Tracer tracer) { diff --git a/sched/src/com/android/sched/util/table/Report.java b/sched/src/com/android/sched/util/table/Report.java index 32b75d5..7c0e8d9 100644 --- a/sched/src/com/android/sched/util/table/Report.java +++ b/sched/src/com/android/sched/util/table/Report.java @@ -16,6 +16,8 @@ package com.android.sched.util.table; +import com.android.sched.util.HasDescription; + import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; @@ -26,7 +28,7 @@ import javax.annotation.Nonnull; /** * A collection of {@link Table}s. */ -public class Report implements Iterable<Table> { +public class Report implements Iterable<Table>, HasDescription { @Nonnull private final String name; @Nonnull @@ -63,6 +65,7 @@ public class Report implements Iterable<Table> { return name; } + @Override @Nonnull public String getDescription() { return description; diff --git a/sched/src/com/android/sched/util/table/Table.java b/sched/src/com/android/sched/util/table/Table.java index 5468dc6..6f1b02f 100644 --- a/sched/src/com/android/sched/util/table/Table.java +++ b/sched/src/com/android/sched/util/table/Table.java @@ -16,6 +16,7 @@ package com.android.sched.util.table; +import com.android.sched.util.HasDescription; import com.android.sched.util.codec.Formatter; import java.util.Iterator; @@ -26,7 +27,7 @@ import javax.annotation.Nonnull; /** * Interface representing a table. */ -public interface Table extends Iterable<Iterable<String>> { +public interface Table extends Iterable<Iterable<String>>, HasDescription { @Nonnull public Formatter<?>[] getFormatters(); @@ -34,6 +35,7 @@ public interface Table extends Iterable<Iterable<String>> { public String getName(); public void setName(@Nonnull String name); + @Override @Nonnull public String getDescription(); public void setDescription(@Nonnull String description); |