diff --git a/core/api/system-current.txt b/core/api/system-current.txt index 3997d512519b3..1373ccfb8e3e3 100644 --- a/core/api/system-current.txt +++ b/core/api/system-current.txt @@ -4154,7 +4154,7 @@ package android.hardware.location { public class ContextHubClient implements java.io.Closeable { method public void close(); method @NonNull public android.hardware.location.ContextHubInfo getAttachedHub(); - method public int getId(); + method @IntRange(from=0, to=65535) public int getId(); method @RequiresPermission(android.Manifest.permission.ACCESS_CONTEXT_HUB) public int sendMessageToNanoApp(@NonNull android.hardware.location.NanoAppMessage); } diff --git a/core/java/android/hardware/location/ContextHubClient.java b/core/java/android/hardware/location/ContextHubClient.java index 9468ca2590bb5..54060cc0a784a 100644 --- a/core/java/android/hardware/location/ContextHubClient.java +++ b/core/java/android/hardware/location/ContextHubClient.java @@ -15,6 +15,7 @@ */ package android.hardware.location; +import android.annotation.IntRange; import android.annotation.NonNull; import android.annotation.RequiresPermission; import android.annotation.SystemApi; @@ -118,13 +119,14 @@ public class ContextHubClient implements Closeable { * is newly generated (e.g. any regeneration of a callback client, or generation * of a non-equal PendingIntent client), the ID will not be the same. * - * @return The ID of this ContextHubClient. + * @return The ID of this ContextHubClient, in the range [0, 65535]. */ + @IntRange(from = 0, to = 65535) public int getId() { if (mId == null) { throw new IllegalStateException("ID was not set"); } - return mId; + return (0x0000FFFF & mId); } /**