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

Commit aea0d390 authored by Arthur Ishiguro's avatar Arthur Ishiguro
Browse files

Refresh cached hub and endpoint info before returning.

The `getHubs`, `findEndpoints`, and `findEndpointsWithService` methods now call the respective refresh methods to ensure the returned data is current.

Bug: 443346395
Flag: EXEMPT BUGFIX
Test: Presubmits
Change-Id: I20e66b3ef55174cf9b022fef5c6aae61afd6dcc2
parent cfa0e727
Loading
Loading
Loading
Loading
+3 −0
Original line number Original line Diff line number Diff line
@@ -168,6 +168,7 @@ class HubInfoRegistry implements ContextHubHalEndpointCallback.IEndpointLifecycl


    /** Retrieve the list of hubs available. */
    /** Retrieve the list of hubs available. */
    List<HubInfo> getHubs() {
    List<HubInfo> getHubs() {
        refreshCachedHubs();
        synchronized (mLock) {
        synchronized (mLock) {
            return mHubsInfo;
            return mHubsInfo;
        }
        }
@@ -265,6 +266,7 @@ class HubInfoRegistry implements ContextHubHalEndpointCallback.IEndpointLifecycl


    /** Return a list of {@link HubEndpointInfo} that represents endpoints with the matching id. */
    /** Return a list of {@link HubEndpointInfo} that represents endpoints with the matching id. */
    public List<HubEndpointInfo> findEndpoints(long endpointIdQuery) {
    public List<HubEndpointInfo> findEndpoints(long endpointIdQuery) {
        refreshCachedEndpoints();
        List<HubEndpointInfo> searchResult = new ArrayList<>();
        List<HubEndpointInfo> searchResult = new ArrayList<>();
        synchronized (mLock) {
        synchronized (mLock) {
            for (HubEndpointInfo.HubEndpointIdentifier endpointId : mHubEndpointInfos.keySet()) {
            for (HubEndpointInfo.HubEndpointIdentifier endpointId : mHubEndpointInfos.keySet()) {
@@ -280,6 +282,7 @@ class HubInfoRegistry implements ContextHubHalEndpointCallback.IEndpointLifecycl
     * Return a list of {@link HubEndpointInfo} that represents endpoints with the matching service.
     * Return a list of {@link HubEndpointInfo} that represents endpoints with the matching service.
     */
     */
    public List<HubEndpointInfo> findEndpointsWithService(String serviceDescriptor) {
    public List<HubEndpointInfo> findEndpointsWithService(String serviceDescriptor) {
        refreshCachedEndpoints();
        List<HubEndpointInfo> searchResult = new ArrayList<>();
        List<HubEndpointInfo> searchResult = new ArrayList<>();
        synchronized (mLock) {
        synchronized (mLock) {
            for (HubEndpointInfo endpointInfo : mHubEndpointInfos.values()) {
            for (HubEndpointInfo endpointInfo : mHubEndpointInfos.values()) {