Merge "Pass the context hub ID to getPreloadedNanoappIds in the Context Hub service" into udc-dev

This commit is contained in:
Matthew Sedam
2023-03-08 20:35:26 +00:00
committed by Android (Google) Code Review
3 changed files with 24 additions and 15 deletions

View File

@@ -1148,7 +1148,7 @@ public class ContextHubService extends IContextHubService.Stub {
super.getPreloadedNanoAppIds_enforcePermission();
Objects.requireNonNull(hubInfo, "hubInfo cannot be null");
long[] nanoappIds = mContextHubWrapper.getPreloadedNanoappIds();
long[] nanoappIds = mContextHubWrapper.getPreloadedNanoappIds(hubInfo.getId());
if (nanoappIds == null) {
return new long[0];
}
@@ -1261,13 +1261,19 @@ public class ContextHubService extends IContextHubService.Stub {
return;
}
long[] preloadedNanoappIds = mContextHubWrapper.getPreloadedNanoappIds();
if (preloadedNanoappIds == null) {
return;
}
for (long preloadedNanoappId : preloadedNanoappIds) {
pw.print("ID: 0x");
pw.println(Long.toHexString(preloadedNanoappId));
for (int contextHubId: mContextHubIdToInfoMap.keySet()) {
long[] preloadedNanoappIds = mContextHubWrapper.getPreloadedNanoappIds(contextHubId);
if (preloadedNanoappIds == null) {
return;
}
pw.print("Context Hub (id=");
pw.print(contextHubId);
pw.println("):");
for (long preloadedNanoappId : preloadedNanoappIds) {
pw.print(" ID: 0x");
pw.println(Long.toHexString(preloadedNanoappId));
}
}
}

View File

@@ -363,9 +363,11 @@ public abstract class IContextHubWrapper {
* Provides the list of preloaded nanoapp IDs on the system. The output of this API must
* not change.
*
* @return The list of preloaded nanoapp IDs
* @param contextHubId The context Hub ID.
*
* @return The list of preloaded nanoapp IDs.
*/
public abstract long[] getPreloadedNanoappIds();
public abstract long[] getPreloadedNanoappIds(int contextHubId);
/**
* Registers a callback with the Context Hub.
@@ -714,14 +716,14 @@ public abstract class IContextHubWrapper {
}
}
public long[] getPreloadedNanoappIds() {
public long[] getPreloadedNanoappIds(int contextHubId) {
android.hardware.contexthub.IContextHub hub = getHub();
if (hub == null) {
return null;
}
try {
return hub.getPreloadedNanoappIds();
return hub.getPreloadedNanoappIds(contextHubId);
} catch (RemoteException e) {
Log.e(TAG, "Exception while getting preloaded nanoapp IDs: " + e.getMessage());
return null;
@@ -924,7 +926,7 @@ public abstract class IContextHubWrapper {
mHub.queryApps(contextHubId));
}
public long[] getPreloadedNanoappIds() {
public long[] getPreloadedNanoappIds(int contextHubId) {
return new long[0];
}

View File

@@ -18,7 +18,8 @@ package com.android.server.location.contexthub;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Matchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -75,7 +76,7 @@ public class ContextHubServiceTest {
@Test
public void testDump_emptyPreloadedNanoappList() {
when(mMockContextHubWrapper.getPreloadedNanoappIds()).thenReturn(null);
when(mMockContextHubWrapper.getPreloadedNanoappIds(anyInt())).thenReturn(null);
StringWriter stringWriter = new StringWriter();
ContextHubService service = new ContextHubService(mContext, mMockContextHubWrapper);