diff options
Diffstat (limited to 'core/java/android')
-rw-r--r-- | core/java/android/net/IpPrefix.java | 15 | ||||
-rw-r--r-- | core/java/android/net/RouteInfo.java | 8 | ||||
-rw-r--r-- | core/java/android/nfc/cardemulation/ApduServiceInfo.java | 15 | ||||
-rw-r--r-- | core/java/android/os/Debug.java | 90 |
4 files changed, 120 insertions, 8 deletions
diff --git a/core/java/android/net/IpPrefix.java b/core/java/android/net/IpPrefix.java index b268986..6b4f2d5 100644 --- a/core/java/android/net/IpPrefix.java +++ b/core/java/android/net/IpPrefix.java @@ -170,6 +170,21 @@ public final class IpPrefix implements Parcelable { } /** + * Determines whether the prefix contains the specified address. + * + * @param address An {@link InetAddress} to test. + * @return {@code true} if the prefix covers the given address. + */ + public boolean contains(InetAddress address) { + byte[] addrBytes = (address == null) ? null : address.getAddress(); + if (addrBytes == null || addrBytes.length != this.address.length) { + return false; + } + NetworkUtils.maskRawAddress(addrBytes, prefixLength); + return Arrays.equals(this.address, addrBytes); + } + + /** * Returns a string representation of this {@code IpPrefix}. * * @return a string such as {@code "192.0.2.0/24"} or {@code "2001:db8:1:2::/64"}. diff --git a/core/java/android/net/RouteInfo.java b/core/java/android/net/RouteInfo.java index cfd20a0..90a2460 100644 --- a/core/java/android/net/RouteInfo.java +++ b/core/java/android/net/RouteInfo.java @@ -367,13 +367,7 @@ public final class RouteInfo implements Parcelable { * @return {@code true} if the destination and prefix length cover the given address. */ public boolean matches(InetAddress destination) { - if (destination == null) return false; - - // match the route destination and destination with prefix length - InetAddress dstNet = NetworkUtils.getNetworkPart(destination, - mDestination.getPrefixLength()); - - return mDestination.getAddress().equals(dstNet); + return mDestination.contains(destination); } /** diff --git a/core/java/android/nfc/cardemulation/ApduServiceInfo.java b/core/java/android/nfc/cardemulation/ApduServiceInfo.java index 00b2ee3..f10e530 100644 --- a/core/java/android/nfc/cardemulation/ApduServiceInfo.java +++ b/core/java/android/nfc/cardemulation/ApduServiceInfo.java @@ -40,6 +40,7 @@ import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; /** @@ -262,7 +263,7 @@ public final class ApduServiceInfo implements Parcelable { * for that category. * @return List of AIDs registered by the service */ - public ArrayList<String> getAids() { + public List<String> getAids() { final ArrayList<String> aids = new ArrayList<String>(); for (AidGroup group : getAidGroups()) { aids.addAll(group.aids); @@ -270,6 +271,18 @@ public final class ApduServiceInfo implements Parcelable { return aids; } + public List<String> getPrefixAids() { + final ArrayList<String> prefixAids = new ArrayList<String>(); + for (AidGroup group : getAidGroups()) { + for (String aid : group.aids) { + if (aid.endsWith("*")) { + prefixAids.add(aid); + } + } + } + return prefixAids; + } + /** * Returns the registered AID group for this category. */ diff --git a/core/java/android/os/Debug.java b/core/java/android/os/Debug.java index 2d92c7b..2a60b4d 100644 --- a/core/java/android/os/Debug.java +++ b/core/java/android/os/Debug.java @@ -34,6 +34,7 @@ import java.lang.annotation.Target; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; +import java.util.Map; import org.apache.harmony.dalvik.ddmc.Chunk; import org.apache.harmony.dalvik.ddmc.ChunkHandler; @@ -1035,6 +1036,95 @@ href="{@docRoot}guide/developing/tools/traceview.html">Traceview: A Graphical Lo } /** + * Returns the value of a particular runtime statistic or {@code null} if no + * such runtime statistic exists. + * + * <p>The following table lists the runtime statistics that the runtime supports. + * Note runtime statistics may be added or removed in a future API level.</p> + * + * <table> + * <thead> + * <tr> + * <th>Runtime statistic name</th> + * <th>Meaning</th> + * <th>Example</th> + * <th>Supported (API Levels)</th> + * </tr> + * </thead> + * <tbody> + * <tr> + * <td>art.gc.gc-count</td> + * <td>The number of garbage collection runs.</td> + * <td>{@code 164}</td> + * <td>23</td> + * </tr> + * <tr> + * <td>art.gc.gc-time</td> + * <td>The total duration of garbage collection runs in ms.</td> + * <td>{@code 62364}</td> + * <td>23</td> + * </tr> + * <tr> + * <td>art.gc.bytes-allocated</td> + * <td>The total number of bytes that the application allocated.</td> + * <td>{@code 1463948408}</td> + * <td>23</td> + * </tr> + * <tr> + * <td>art.gc.bytes-freed</td> + * <td>The total number of bytes that garbage collection reclaimed.</td> + * <td>{@code 1313493084}</td> + * <td>23</td> + * </tr> + * <tr> + * <td>art.gc.blocking-gc-count</td> + * <td>The number of blocking garbage collection runs.</td> + * <td>{@code 2}</td> + * <td>23</td> + * </tr> + * <tr> + * <td>art.gc.blocking-gc-time</td> + * <td>The total duration of blocking garbage collection runs in ms.</td> + * <td>{@code 804}</td> + * <td>23</td> + * </tr> + * <tr> + * <td>art.gc.gc-count-rate-histogram</td> + * <td>The histogram of the number of garbage collection runs per 10 seconds.</td> + * <td>{@code 0:34503,1:45350,2:11281,3:8088,4:43,5:8}</td> + * <td>23</td> + * </tr> + * <tr> + * <td>art.gc.blocking-gc-count-rate-histogram</td> + * <td>The histogram of the number of garbage collection runs per 10 seconds.</td> + * <td>{@code 0:99269,1:1,2:1}</td> + * <td>23</td> + * </tr> + * </tbody> + * </table> + * + * @param statName + * the name of the runtime statistic to look up. + * @return the value of the specified runtime statistic or {@code null} if the + * runtime statistic doesn't exist. + * @hide + */ + public static String getRuntimeStat(String statName) { + return VMDebug.getRuntimeStat(statName); + } + + /** + * Returns a map of the names/values of the runtime statistics + * that {@link #getRuntimeStat(String)} supports. + * + * @return a map of the names/values of the supported runtime statistics. + * @hide + */ + public static Map<String, String> getRuntimeStats() { + return VMDebug.getRuntimeStats(); + } + + /** * Returns the size of the native heap. * @return The size of the native heap in bytes. */ |