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

Commit 14e8573a authored by Yifei Zhang's avatar Yifei Zhang Committed by Android (Google) Code Review
Browse files

Merge "contexthub: throw when mHubInfoRegistry is null" into main

parents 9547a525 5698c0ee
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -697,6 +697,7 @@ public final class ContextHubManager {
     *
     * @param endpointId Statically generated ID for an endpoint.
     * @return A list of {@link HubDiscoveryInfo} objects that represents the result of discovery.
     * @throws UnsupportedOperationException If the operation is not supported.
     */
    @FlaggedApi(Flags.FLAG_OFFLOAD_API)
    @RequiresPermission(android.Manifest.permission.ACCESS_CONTEXT_HUB)
@@ -733,6 +734,7 @@ public final class ContextHubManager {
     *     cannot be null or empty.
     * @return A list of {@link HubDiscoveryInfo} objects that represents the result of discovery.
     * @throws IllegalArgumentException if the serviceDescriptor is empty/null.
     * @throws UnsupportedOperationException If the operation is not supported.
     */
    @FlaggedApi(Flags.FLAG_OFFLOAD_API)
    @RequiresPermission(android.Manifest.permission.ACCESS_CONTEXT_HUB)
+10 −9
Original line number Diff line number Diff line
@@ -756,9 +756,7 @@ public class ContextHubService extends IContextHubService.Stub {
    @Override
    public List<HubInfo> getHubs() throws RemoteException {
        super.getHubs_enforcePermission();
        if (mHubInfoRegistry == null) {
            return Collections.emptyList();
        }
        checkHubDiscoveryPreconditions();
        return mHubInfoRegistry.getHubs();
    }

@@ -766,9 +764,7 @@ public class ContextHubService extends IContextHubService.Stub {
    @Override
    public List<HubEndpointInfo> findEndpoints(long endpointId) {
        super.findEndpoints_enforcePermission();
        if (mHubInfoRegistry == null) {
            return Collections.emptyList();
        }
        checkEndpointDiscoveryPreconditions();
        return mHubInfoRegistry.findEndpoints(endpointId);
    }

@@ -776,9 +772,7 @@ public class ContextHubService extends IContextHubService.Stub {
    @Override
    public List<HubEndpointInfo> findEndpointsWithService(String serviceDescriptor) {
        super.findEndpointsWithService_enforcePermission();
        if (mHubInfoRegistry == null) {
            return Collections.emptyList();
        }
        checkEndpointDiscoveryPreconditions();
        return mHubInfoRegistry.findEndpointsWithService(serviceDescriptor);
    }

@@ -834,6 +828,13 @@ public class ContextHubService extends IContextHubService.Stub {
        }
    }

    private void checkHubDiscoveryPreconditions() {
        if (mHubInfoRegistry == null) {
            Log.e(TAG, "Hub registry failed to initialize");
            throw new UnsupportedOperationException("Hub discovery is not supported");
        }
    }

    /**
     * Creates an internal load transaction callback to be used for old API clients
     *