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

Limit the return value range based on feedback to reflect the 16-bit
value returned from the framework.

Fixes: 214028356
Test: None
Change-Id: Idaecebd9219e38fd5e04122043274b8a524d8bae
This commit is contained in:
Arthur Ishiguro
2022-01-11 17:34:40 +00:00
parent cb2fb6825f
commit 71c765985b
2 changed files with 5 additions and 3 deletions

View File

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