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

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

Merge changes Ic6b623a7,Ib6811066

* changes:
  Makes minor modifications to Intent-based Service APIs
  Adds AIDL definitions for register/unregisterIntent
parents 8d71ec09 2640f0b7
Loading
Loading
Loading
Loading
+20 −8
Original line number Diff line number Diff line
@@ -130,30 +130,42 @@ public class ContextHubClient implements Closeable {
     * {@link PendingIntent} through a {@link BroadcastReceiver}, and maps an {@link Intent} to a
     * {@link ContextHubClientCallback}.
     *
     * @param intent    The PendingIntent to register for this client
     * @param pendingIntent the PendingIntent to register for this client
     * @param nanoAppId     the unique ID of the nanoapp to receive events for
     * @return true on success, false otherwise
     *
     * @hide
     */
    @RequiresPermission(android.Manifest.permission.LOCATION_HARDWARE)
    public boolean registerIntent(@NonNull PendingIntent intent, long nanoAppId) {
        // TODO: Implement this
        return false;
    public boolean registerIntent(@NonNull PendingIntent pendingIntent, long nanoAppId) {
        Preconditions.checkNotNull(pendingIntent, "PendingIntent cannot be null");

        try {
            return mClientProxy.registerIntent(pendingIntent, nanoAppId);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * Unregisters an intent previously registered via {@link #registerIntent(PendingIntent, long)}.
     * If this intent has not been registered for this client, this method returns false.
     *
     * @param pendingIntent the PendingIntent to unregister
     *
     * @return true on success, false otherwise
     *
     * @hide
     */
    @RequiresPermission(android.Manifest.permission.LOCATION_HARDWARE)
    public boolean unregisterIntent(@NonNull PendingIntent intent) {
        // TODO: Implement this
        return false;
    public boolean unregisterIntent(@NonNull PendingIntent pendingIntent) {
        Preconditions.checkNotNull(pendingIntent, "PendingIntent cannot be null");

        try {
            return mClientProxy.unregisterIntent(pendingIntent);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
+16 −15
Original line number Diff line number Diff line
@@ -800,22 +800,22 @@ public final class ContextHubManager {
     * through {@link #createClient(ContextHubInfo, ContextHubClientCallback, Executor)} or
     * equivalent at an earlier time.
     *
     * @param intent   the intent that is associated with a client
     * @param pendingIntent the PendingIntent that has been registered with a client
     * @param hubInfo       the hub to attach this client to
     * @param callback      the notification callback to register
     * @param executor      the executor to invoke the callback
     * @return the registered client object
     *
     * @throws IllegalArgumentException if hubInfo does not represent a valid hub, or the intent
     * @throws IllegalArgumentException if hubInfo does not represent a valid hub, or pendingIntent
     *                                  was not associated with a client
     * @throws IllegalStateException    if there were too many registered clients at the service
     * @throws NullPointerException     if intent, hubInfo, callback, or executor is null
     * @throws NullPointerException     if pendingIntent, hubInfo, callback, or executor is null
     *
     * @hide
     */
    @RequiresPermission(android.Manifest.permission.LOCATION_HARDWARE)
    @NonNull public ContextHubClient createClient(
            @NonNull PendingIntent intent, @NonNull ContextHubInfo hubInfo,
            @NonNull PendingIntent pendingIntent, @NonNull ContextHubInfo hubInfo,
            @NonNull ContextHubClientCallback callback,
            @NonNull @CallbackExecutor Executor executor) {
        // TODO: Implement this
@@ -823,26 +823,27 @@ public final class ContextHubManager {
    }

    /**
     * Equivalent to {@link #createClient(Intent, ContextHubInfo, ContextHubClientCallback,
     * Equivalent to {@link #createClient(PendingIntent, ContextHubInfo, ContextHubClientCallback,
     * Executor)} with the executor using the main thread's Looper.
     *
     * @param intent   the intent that is associated with a client
     * @param pendingIntent the PendingIntent that has been registered with a client
     * @param hubInfo       the hub to attach this client to
     * @param callback      the notification callback to register
     * @return the registered client object
     *
     * @throws IllegalArgumentException if hubInfo does not represent a valid hub, or the intent
     * @throws IllegalArgumentException if hubInfo does not represent a valid hub, or pendingIntent
     *                                  was not associated with a client
     * @throws IllegalStateException    if there were too many registered clients at the service
     * @throws NullPointerException     if intent, hubInfo, or callback is null
     * @throws NullPointerException     if pendingIntent, hubInfo, or callback is null
     *
     * @hide
     */
    @RequiresPermission(android.Manifest.permission.LOCATION_HARDWARE)
    @NonNull public ContextHubClient createClient(
            @NonNull PendingIntent intent, @NonNull ContextHubInfo hubInfo,
            @NonNull PendingIntent pendingIntent, @NonNull ContextHubInfo hubInfo,
            @NonNull ContextHubClientCallback callback) {
        return createClient(intent, hubInfo, callback, new HandlerExecutor(Handler.getMain()));
        return createClient(
                pendingIntent, hubInfo, callback, new HandlerExecutor(Handler.getMain()));
    }

    /**
+7 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package android.hardware.location;

import android.app.PendingIntent;
import android.hardware.location.NanoAppMessage;

/**
@@ -28,4 +29,10 @@ interface IContextHubClient {

    // Closes the connection with the Context Hub
    void close();

    // Registers a PendingIntent with the client
    boolean registerIntent(in PendingIntent intent, long nanoAppId);

    // Unregisters a PendingIntent from the client
    boolean unregisterIntent(in PendingIntent intent);
}
+22 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.server.location;

import android.app.PendingIntent;
import android.content.Context;
import android.hardware.contexthub.V1_0.ContextHubMsg;
import android.hardware.contexthub.V1_0.IContexthub;
@@ -137,6 +138,27 @@ public class ContextHubClientBroker extends IContextHubClient.Stub
        return ContextHubServiceUtil.toTransactionResult(result);
    }

    /**
     * @param intent the intent to register
     * @param nanoAppId the ID of the nanoapp to send events for
     * @return true on success, false otherwise
     */
    @Override
    public boolean registerIntent(PendingIntent intent, long nanoAppId) {
        // TODO: Implement this
        return false;
    }

    /**
     * @param intent the intent to unregister
     * @return true on success, false otherwise
     */
    @Override
    public boolean unregisterIntent(PendingIntent intent) {
        // TODO: Implement this
        return false;
    }

    /**
     * Closes the connection for this client with the service.
     */