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

Commit 0f0f7fa7 authored by Matthew Sedam's avatar Matthew Sedam Committed by Automerger Merge Worker
Browse files

Merge "Pass the context hub ID to getPreloadedNanoappIds in the Context Hub...

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

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/21793409



Change-Id: I0c02b45bb8db8811e9c5e9311437d70f81af7f9b
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 01cfb3fd 479af593
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);