Loading services/core/java/com/android/server/location/ContextHubService.java +7 −7 Original line number Original line Diff line number Diff line Loading @@ -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()]; Loading Loading @@ -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 } } Loading services/core/java/com/android/server/location/NanoAppStateManager.java +8 −4 Original line number Original line Diff line number Diff line Loading @@ -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. Loading Loading @@ -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); } } } /** /** Loading Loading
services/core/java/com/android/server/location/ContextHubService.java +7 −7 Original line number Original line Diff line number Diff line Loading @@ -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()]; Loading Loading @@ -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 } } Loading
services/core/java/com/android/server/location/NanoAppStateManager.java +8 −4 Original line number Original line Diff line number Diff line Loading @@ -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. Loading Loading @@ -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); } } } /** /** Loading