Merge "Make ContextHubClient.getId() return a 16-bit value"

This commit is contained in:
Arthur Ishiguro
2022-01-13 17:06:28 +00:00
committed by Android (Google) Code Review
2 changed files with 5 additions and 3 deletions

View File

@@ -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);
}

View File

@@ -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);
}
/**