diff --git a/core/api/test-current.txt b/core/api/test-current.txt index 121741e07d432..272a394004c34 100644 --- a/core/api/test-current.txt +++ b/core/api/test-current.txt @@ -1312,6 +1312,14 @@ package android.hardware.lights { } +package android.hardware.location { + + public final class ContextHubManager { + method @NonNull @RequiresPermission(android.Manifest.permission.ACCESS_CONTEXT_HUB) public long[] getPreloadedNanoAppIds(@NonNull android.hardware.location.ContextHubInfo); + } + +} + package android.hardware.soundtrigger { public class KeyphraseEnrollmentInfo { diff --git a/core/java/android/hardware/location/ContextHubManager.java b/core/java/android/hardware/location/ContextHubManager.java index b54da6c6eaea8..ac23af4396de0 100644 --- a/core/java/android/hardware/location/ContextHubManager.java +++ b/core/java/android/hardware/location/ContextHubManager.java @@ -24,6 +24,7 @@ import android.annotation.RequiresPermission; import android.annotation.SuppressLint; import android.annotation.SystemApi; import android.annotation.SystemService; +import android.annotation.TestApi; import android.app.ActivityThread; import android.app.PendingIntent; import android.content.Context; @@ -965,6 +966,34 @@ public final class ContextHubManager { return createClient(null /* context */, hubInfo, pendingIntent, nanoAppId); } + /** + * Queries for the list of preloaded nanoapp IDs on the system. + * + * @param hubInfo The Context Hub to query a list of nanoapp IDs from. + * + * @return The list of 64-bit IDs of the preloaded nanoapps. + * + * @throws NullPointerException if hubInfo is null + * @hide + */ + @TestApi + @RequiresPermission(android.Manifest.permission.ACCESS_CONTEXT_HUB) + @NonNull public long[] getPreloadedNanoAppIds(@NonNull ContextHubInfo hubInfo) { + Objects.requireNonNull(hubInfo, "hubInfo cannot be null"); + + long[] nanoappIds = null; + try { + nanoappIds = mService.getPreloadedNanoAppIds(hubInfo); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); + } + + if (nanoappIds == null) { + nanoappIds = new long[0]; + } + return nanoappIds; + } + /** * Unregister a callback for receive messages from the context hub. *