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

Commit 2640f0b7 authored by Arthur Ishiguro's avatar Arthur Ishiguro
Browse files

Makes minor modifications to Intent-based Service APIs

Bug: 117612105
Test: None
Change-Id: Ic6b623a78a1a807363de403050f027ad3f950817
parent a7c37975
Loading
Loading
Loading
Loading
+10 −8
Original line number Diff line number Diff line
@@ -130,18 +130,18 @@ 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) {
        Preconditions.checkNotNull(intent, "PendingIntent cannot be null");
    public boolean registerIntent(@NonNull PendingIntent pendingIntent, long nanoAppId) {
        Preconditions.checkNotNull(pendingIntent, "PendingIntent cannot be null");

        try {
            return mClientProxy.registerIntent(intent, nanoAppId);
            return mClientProxy.registerIntent(pendingIntent, nanoAppId);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
@@ -151,16 +151,18 @@ public class ContextHubClient implements Closeable {
     * 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) {
        Preconditions.checkNotNull(intent, "PendingIntent cannot be null");
    public boolean unregisterIntent(@NonNull PendingIntent pendingIntent) {
        Preconditions.checkNotNull(pendingIntent, "PendingIntent cannot be null");

        try {
            return mClientProxy.unregisterIntent(intent);
            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()));
    }

    /**