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

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

Adds package name to the endpoint

Bug: 381102105
Flag: android.chre.flags.offload_implementation
Test: Compile
Change-Id: I8f978e2d8716f4469c28f829ec7acca8b4d289f1
parent cad495eb
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -355,7 +355,10 @@ public class HubEndpoint {
        }
        try {
            IContextHubEndpoint serviceToken =
                    service.registerEndpoint(mPendingHubEndpointInfo, mServiceCallback);
                    service.registerEndpoint(
                            mPendingHubEndpointInfo,
                            mServiceCallback,
                            mPendingHubEndpointInfo.getTag());
            mAssignedHubEndpointInfo = serviceToken.getAssignedHubEndpointInfo();
            mServiceToken = serviceToken;
        } catch (RemoteException e) {
+1 −1
Original line number Diff line number Diff line
@@ -137,7 +137,7 @@ interface IContextHubService {

    // Register an endpoint with the context hub
    @EnforcePermission("ACCESS_CONTEXT_HUB")
    IContextHubEndpoint registerEndpoint(in HubEndpointInfo pendingEndpointInfo, in IContextHubEndpointCallback callback);
    IContextHubEndpoint registerEndpoint(in HubEndpointInfo pendingEndpointInfo, in IContextHubEndpointCallback callback, String packageName);

    // Register an endpoint discovery callback (id)
    @EnforcePermission("ACCESS_CONTEXT_HUB")
+6 −1
Original line number Diff line number Diff line
@@ -78,18 +78,23 @@ public class ContextHubEndpointBroker extends IContextHubEndpoint.Stub
    @GuardedBy("mOpenSessionLock")
    private final Set<Integer> mActiveRemoteSessionIds = new HashSet<>();

    /** The package name of the app that created the endpoint */
    private final String mPackageName;

    /* package */ ContextHubEndpointBroker(
            Context context,
            IContextHubWrapper contextHubProxy,
            ContextHubEndpointManager endpointManager,
            EndpointInfo halEndpointInfo,
            IContextHubEndpointCallback callback) {
            IContextHubEndpointCallback callback,
            String packageName) {
        mContext = context;
        mContextHubProxy = contextHubProxy;
        mEndpointManager = endpointManager;
        mEndpointInfo = new HubEndpointInfo(halEndpointInfo);
        mHalEndpointInfo = halEndpointInfo;
        mContextHubEndpointCallback = callback;
        mPackageName = packageName;
    }

    @Override
+6 −2
Original line number Diff line number Diff line
@@ -132,11 +132,14 @@ import java.util.concurrent.ConcurrentHashMap;
     *
     * @param pendingEndpointInfo the object describing the endpoint being registered
     * @param callback the callback interface of the endpoint to register
     * @param packageName the name of the package of the calling client
     * @return the endpoint interface
     * @throws IllegalStateException if max number of endpoints have already registered
     */
    /* package */ IContextHubEndpoint registerEndpoint(
            HubEndpointInfo pendingEndpointInfo, IContextHubEndpointCallback callback)
            HubEndpointInfo pendingEndpointInfo,
            IContextHubEndpointCallback callback,
            String packageName)
            throws RemoteException {
        if (!mSessionIdsValid) {
            throw new IllegalStateException("ContextHubEndpointManager failed to initialize");
@@ -158,7 +161,8 @@ import java.util.concurrent.ConcurrentHashMap;
                        mContextHubProxy,
                        this /* endpointManager */,
                        halEndpointInfo,
                        callback);
                        callback,
                        packageName);
        mEndpointMap.put(endpointId, broker);

        try {
+4 −2
Original line number Diff line number Diff line
@@ -794,14 +794,16 @@ public class ContextHubService extends IContextHubService.Stub {
    @android.annotation.EnforcePermission(android.Manifest.permission.ACCESS_CONTEXT_HUB)
    @Override
    public IContextHubEndpoint registerEndpoint(
            HubEndpointInfo pendingHubEndpointInfo, IContextHubEndpointCallback callback)
            HubEndpointInfo pendingHubEndpointInfo,
            IContextHubEndpointCallback callback,
            String packageName)
            throws RemoteException {
        super.registerEndpoint_enforcePermission();
        if (mEndpointManager == null) {
            Log.e(TAG, "Endpoint manager failed to initialize");
            throw new UnsupportedOperationException("Endpoint registration is not supported");
        }
        return mEndpointManager.registerEndpoint(pendingHubEndpointInfo, callback);
        return mEndpointManager.registerEndpoint(pendingHubEndpointInfo, callback, packageName);
    }

    @android.annotation.EnforcePermission(android.Manifest.permission.ACCESS_CONTEXT_HUB)