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

Commit 4f906f88 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Makes iterator internal in NanoAppStateManager"

parents 005489c0 11946345
Loading
Loading
Loading
Loading
+7 −7
Original line number Original line Diff line number Diff line
@@ -415,10 +415,12 @@ public class ContextHubService extends IContextHubService.Stub {
        checkPermissions();
        checkPermissions();


        ArrayList<Integer> foundInstances = new ArrayList<>();
        ArrayList<Integer> foundInstances = new ArrayList<>();
        for (NanoAppInstanceInfo info : mNanoAppStateManager.getNanoAppInstanceInfoCollection()) {
        if (filter != null) {
            mNanoAppStateManager.foreachNanoAppInstanceInfo((info) -> {
                if (filter.testMatch(info)) {
                if (filter.testMatch(info)) {
                    foundInstances.add(info.getHandle());
                    foundInstances.add(info.getHandle());
                }
                }
            });
        }
        }


        int[] retArray = new int[foundInstances.size()];
        int[] retArray = new int[foundInstances.size()];
@@ -767,9 +769,7 @@ public class ContextHubService extends IContextHubService.Stub {
        pw.println("");
        pw.println("");
        pw.println("=================== NANOAPPS ====================");
        pw.println("=================== NANOAPPS ====================");
        // Dump nanoAppHash
        // Dump nanoAppHash
        for (NanoAppInstanceInfo info : mNanoAppStateManager.getNanoAppInstanceInfoCollection()) {
        mNanoAppStateManager.foreachNanoAppInstanceInfo((info) -> pw.println(info));
            pw.println(info);
        }


        // dump eventLog
        // dump eventLog
    }
    }
+8 −4
Original line number Original line Diff line number Diff line
@@ -21,11 +21,11 @@ import android.hardware.contexthub.V1_0.HubAppInfo;
import android.hardware.location.NanoAppInstanceInfo;
import android.hardware.location.NanoAppInstanceInfo;
import android.util.Log;
import android.util.Log;


import java.util.Collection;
import java.util.HashMap;
import java.util.HashMap;
import java.util.HashSet;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Iterator;
import java.util.List;
import java.util.List;
import java.util.function.Consumer;


/**
/**
 * Manages the state of loaded nanoapps at the Context Hubs.
 * Manages the state of loaded nanoapps at the Context Hubs.
@@ -70,11 +70,15 @@ import java.util.List;
    }
    }


    /**
    /**
     * @return a collection of NanoAppInstanceInfo objects in the cache
     * Invokes a Consumer operation for each NanoAppInstanceInfo entry in the cache
     *
     * @param consumer the Consumer operation to perform
     */
     */
    /* package */
    /* package */
    synchronized Collection<NanoAppInstanceInfo> getNanoAppInstanceInfoCollection() {
    synchronized void foreachNanoAppInstanceInfo(Consumer<NanoAppInstanceInfo> consumer) {
        return mNanoAppHash.values();
        for (NanoAppInstanceInfo info : mNanoAppHash.values()) {
            consumer.accept(info);
        }
    }
    }


    /**
    /**