Manter pontos de acesso entre sessões de condução

Esta página descreve como configurar os usuários para manter pontos de acesso entre sessões no carro, semelhante à experiência de condução com Wi-Fi no AAOS.

public class CarSettings {
 
...

 
@SystemApi
 
public static final class Global {
   
...

   
/**
     * Enables persistent tethering when set to {@code "true"}.
     *
     * <p>When enabled, tethering is started when the car is started given
     * that the hotspot was enabled at shutdown and all tethering sessions
     * will remain on even if no devices are connected to it.
     *
     * <p>When disabled, hotspot will turn off automatically if no devices
     * are connected and will no longer persist through drives.
     *
     * @hide
     */

   
@SystemApi
   
public static final String ENABLE_PERSISTENT_TETHERING =
           
"android.car.ENABLE_PERSISTENT_TETHERING";
 
}
}

Para manter o tethering, use ENABLE_PERSISTENT_TETHERING pelo API Settings, que também pode ser usado para fazer consultas.

Permissões

O uso da API CarWifiManager é restrito. Essa nova permissão é criada para proteger o acesso.

public boolean canControlPersistApSettings() { ... }

Os níveis de proteção para essa permissão são:

Nova permissão Permissão Nível de proteção
Sim READ_PERSIST_TETHERING_SETTINGS Assinatura | Privilegiado

O comportamento padrão é indisponível. Uma sobreposição de recursos (config_enablePersistTetheringCapabilities) está configurado para bloquear o a capacidade de manter o tethering. Para manter o tethering intencionalmente, defina o como true para ativar o recurso sobre a preferência do usuário porque outros apps do sistema com a permissão WRITE_SECURE_SETTINGS também podem também controlam essa configuração.

A API a seguir determina se o comportamento está ativado. Chame essa API antes você mudar ENABLE_PERSISTENT_TETHERING.

/**
 * CarWifiManager provides API to allow for applications to perform Wi-Fi specific
 * operations.
 *
 * @hide
 */

@SystemApi
public final class CarWifiManager extends CarManagerBase {
 
/**
  * Returns {@code true} if the persist tethering settings are able to be
  * changed.
  *
  * @hide
  */

 
@SystemApi
 
@RequiresPermission(Car.PERMISSION_READ_PERSIST_TETHERING_SETTINGS)
 
public boolean canControlPersistApSettings() { ... }
}