Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 479af593 authored by Matthew Sedam's avatar Matthew Sedam Committed by Android (Google) Code Review
Browse files

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

parents 5b64be2f 61c49ed1
Loading
Loading
Loading
Loading
+14 −8
Original line number Diff line number Diff line
@@ -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,15 +1261,21 @@ public class ContextHubService extends IContextHubService.Stub {
            return;
        }

        long[] preloadedNanoappIds = mContextHubWrapper.getPreloadedNanoappIds();
        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));
            }
        }
    }

    private void checkPermissions() {
        ContextHubServiceUtil.checkPermissions(mContext);
+7 −5
Original line number Diff line number Diff line
@@ -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];
        }

+3 −2
Original line number Diff line number Diff line
@@ -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);