# CarRemoteAccessManager

Summary:[Nested Classes](https://developer.android.com/reference/android/car/remoteaccess/CarRemoteAccessManager#nestedclasses)\|[Methods](https://developer.android.com/reference/android/car/remoteaccess/CarRemoteAccessManager#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/car/remoteaccess/CarRemoteAccessManager#inhmethods)  

# CarRemoteAccessManager

`
public

final

class
CarRemoteAccessManager
`  
`

extends Object


``


`

|---|-------------------------------------------------|
| java.lang.Object                                   ||
| ↳ | android.car.remoteaccess.CarRemoteAccessManager |

<br />

*** ** * ** ***

CarRemoteAccessManager allows applications to listen to remote task requests even while Android System is not running.

The remote task client registers to[CarRemoteAccessManager](https://developer.android.com/reference/android/car/remoteaccess/CarRemoteAccessManager)to listen to remote access events. At[RemoteTaskClientCallback.onRegistrationUpdated](https://developer.android.com/reference/android/car/remoteaccess/CarRemoteAccessManager.RemoteTaskClientCallback#onRegistrationUpdated(android.car.remoteaccess.RemoteTaskClientRegistrationInfo))it is required to share`serviceId`,`deviceId`and`clientId`with the cloud service which will use the IDs to wake the vehicle. At[RemoteTaskClientCallback.onRemoteTaskRequested](https://developer.android.com/reference/android/car/remoteaccess/CarRemoteAccessManager.RemoteTaskClientCallback#onRemoteTaskRequested(java.lang.String,%20byte[],%20int)), it starts executing the given task. It is supposed to call[reportRemoteTaskDone(java.lang.String)](https://developer.android.com/reference/android/car/remoteaccess/CarRemoteAccessManager#reportRemoteTaskDone(java.lang.String))when it finishes the given task. Once the task completion is reported or the timeout expires, Android System goes back to either the previous power state or the specified power state.

Note that the remote task will be executed even when the vehicle is actively in use, not nessarily when the vehicle is off. Remote task client must make sure the task to be executed will not affect the system performance or affect driving safety. If certain task must be executed while the vehicle is off, the remote task client must check VHAL property`VEHICLE_IN_USE`and/or check igntition state via`VehicleIgnitionState`.

Note: all remote task clients must run as system user.

A serverless setup might also be supported if the RRO overlay for remote_access_serverless_client_map exists which provides a map from serverless client ID to their package names.

Here the term 'remote' refers to the source of task coming from outside of the Android system, it does not necessarily means the task comes from Internet. In the serverless setup, no cloud service is required. Another device within the same vehicle, but outside the Android system is the issuer for the remote task.

For serverless setup, there is a pre-configured set of serverless remote task clients. They register to[CarRemoteAccessManager](https://developer.android.com/reference/android/car/remoteaccess/CarRemoteAccessManager)to listen to remote access events.[RemoteTaskClientCallback.onServerlessClientRegistered](https://developer.android.com/reference/android/car/remoteaccess/CarRemoteAccessManager.RemoteTaskClientCallback#onServerlessClientRegistered())will be called instead of[RemoteTaskClientCallback.onRegistrationUpdated](https://developer.android.com/reference/android/car/remoteaccess/CarRemoteAccessManager.RemoteTaskClientCallback#onRegistrationUpdated(android.car.remoteaccess.RemoteTaskClientRegistrationInfo))and there is no cloud service involved.[RemoteTaskClientCallback.onRemoteTaskRequested](https://developer.android.com/reference/android/car/remoteaccess/CarRemoteAccessManager.RemoteTaskClientCallback#onRemoteTaskRequested(java.lang.String,%20byte[],%20int))will be invoked when the task is to be executed. It is supposed to call[reportRemoteTaskDone(java.lang.String)](https://developer.android.com/reference/android/car/remoteaccess/CarRemoteAccessManager#reportRemoteTaskDone(java.lang.String))when it finishes the given task. Once the task completion is reported or the timeout expires, Android system goes back to either the previous power state or the specified power state.

For serverless setup, if[ERROR(/isTaskScheduleSupported)](https://developer.android.com/)returns`true`, client may use[ERROR(InVehicleTaskScheduler.scheduleTask/android.car.remoteaccess.CarRemoteAccessManager.InVehicleTaskScheduler#scheduleTask InVehicleTaskScheduler.scheduleTask)](https://developer.android.com/)to schedule a remote task to be executed later. If[ERROR(/isTaskScheduleSupported)](https://developer.android.com/)returns`false`, it is assumed there exists some other channel outside of the Android system for task scheduling.

## Summary

|                                                                                                                                                                      ### Nested classes                                                                                                                                                                       ||
|--------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` interface` | [CarRemoteAccessManager.CompletableRemoteTaskFuture](https://developer.android.com/reference/android/car/remoteaccess/CarRemoteAccessManager.CompletableRemoteTaskFuture) An interface passed from[RemoteTaskClientCallback](https://developer.android.com/reference/android/car/remoteaccess/CarRemoteAccessManager.RemoteTaskClientCallback). |
| ` interface` | [CarRemoteAccessManager.RemoteTaskClientCallback](https://developer.android.com/reference/android/car/remoteaccess/CarRemoteAccessManager.RemoteTaskClientCallback) Listener for remote task events.                                                                                                                                            |

|                                                                                                                                                                                                                                                                                                                   ### Public methods                                                                                                                                                                                                                                                                                                                    ||
|---------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` void` | ` `[clearRemoteTaskClient](https://developer.android.com/reference/android/car/remoteaccess/CarRemoteAccessManager#clearRemoteTaskClient())`() ` Clears the remote task client previously set via[setRemoteTaskClient(java.util.concurrent.Executor, android.car.remoteaccess.CarRemoteAccessManager.RemoteTaskClientCallback)](https://developer.android.com/reference/android/car/remoteaccess/CarRemoteAccessManager#setRemoteTaskClient(java.util.concurrent.Executor,%20android.car.remoteaccess.CarRemoteAccessManager.RemoteTaskClientCallback)).                                                                                       |
| ` void` | ` `[reportRemoteTaskDone](https://developer.android.com/reference/android/car/remoteaccess/CarRemoteAccessManager#reportRemoteTaskDone(java.lang.String))`(String taskId) ` Reports that remote task execution is completed, so that the vehicle will go back to the power state before the wake-up.                                                                                                                                                                                                                                                                                                                                           |
| ` void` | ` `[setRemoteTaskClient](https://developer.android.com/reference/android/car/remoteaccess/CarRemoteAccessManager#setRemoteTaskClient(java.util.concurrent.Executor,%20android.car.remoteaccess.CarRemoteAccessManager.RemoteTaskClientCallback))`(Executor executor, `[CarRemoteAccessManager.RemoteTaskClientCallback](https://developer.android.com/reference/android/car/remoteaccess/CarRemoteAccessManager.RemoteTaskClientCallback)` callback) ` Sets the remote task client represented as[RemoteTaskClientCallback](https://developer.android.com/reference/android/car/remoteaccess/CarRemoteAccessManager.RemoteTaskClientCallback). |

| ### Inherited methods |
|-----------------------|---|
| From class` java.lang.Object ` |-------------------|-------------------------------| | ` Object`         | ` clone() `                   | | ` boolean`        | ` equals(Object arg0) `       | | ` void`           | ` finalize() `                | | ` final Class<?>` | ` getClass() `                | | ` int`            | ` hashCode() `                | | ` final void`     | ` notify() `                  | | ` final void`     | ` notifyAll() `               | | ` String`         | ` toString() `                | | ` final void`     | ` wait(long arg0, int arg1) ` | | ` final void`     | ` wait(long arg0) `           | | ` final void`     | ` wait() `                    | ||

## Public methods

### clearRemoteTaskClient

```
public void clearRemoteTaskClient ()
```

Clears the remote task client previously set via[setRemoteTaskClient(java.util.concurrent.Executor, android.car.remoteaccess.CarRemoteAccessManager.RemoteTaskClientCallback)](https://developer.android.com/reference/android/car/remoteaccess/CarRemoteAccessManager#setRemoteTaskClient(java.util.concurrent.Executor,%20android.car.remoteaccess.CarRemoteAccessManager.RemoteTaskClientCallback)).

After the remote task client is cleared, all tasks associated with the previous client will not be delivered and the client must not call`reportRemoteTaskDone`with the task ID associated with the previous client ID.  
Requires[Car.PERMISSION_USE_REMOTE_ACCESS](https://developer.android.com/reference/android/car/Car#PERMISSION_USE_REMOTE_ACCESS)

<br />

|                         Throws                          ||
|-------------------------|--------------------------------|
| `IllegalStateException` | if`callback`is not registered. |

### reportRemoteTaskDone

```
public void reportRemoteTaskDone (String taskId)
```

Reports that remote task execution is completed, so that the vehicle will go back to the power state before the wake-up.  
Requires[Car.PERMISSION_USE_REMOTE_ACCESS](https://developer.android.com/reference/android/car/Car#PERMISSION_USE_REMOTE_ACCESS)

<br />

|                                 Parameters                                 ||
|----------|------------------------------------------------------------------|
| `taskId` | `String`: ID of the remote task which has been completed. <br /> |

|                                          Throws                                          ||
|----------------------------|--------------------------------------------------------------|
| `IllegalArgumentException` | If`taskId`is null.                                           |
| `IllegalStateException`    | If the remote task client is not registered or not woken up. |

### setRemoteTaskClient

```
public void setRemoteTaskClient (Executor executor, 
                CarRemoteAccessManager.RemoteTaskClientCallback callback)
```

Sets the remote task client represented as[RemoteTaskClientCallback](https://developer.android.com/reference/android/car/remoteaccess/CarRemoteAccessManager.RemoteTaskClientCallback).  
Requires[Car.PERMISSION_USE_REMOTE_ACCESS](https://developer.android.com/reference/android/car/Car#PERMISSION_USE_REMOTE_ACCESS)

<br />

|                                                                                                                      Parameters                                                                                                                      ||
|------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `executor` | `Executor`: Executor on which`callback`is executed. <br />                                                                                                                                                                               |
| `callback` | `CarRemoteAccessManager.RemoteTaskClientCallback`:[RemoteTaskClientCallback](https://developer.android.com/reference/android/car/remoteaccess/CarRemoteAccessManager.RemoteTaskClientCallback)that listens to remote task events. <br /> |

|                                    Throws                                     ||
|----------------------------|---------------------------------------------------|
| `IllegalStateException`    | When a remote task client is already set.         |
| `IllegalArgumentException` | When the given callback or the executor is`null`. |