A partir de 27 de março de 2025, recomendamos usar android-latest-release
em vez de aosp-main
para criar e contribuir com o AOSP. Para mais informações, consulte Mudanças no AOSP.
Manter os pontos de acesso entre as sessões de direção
Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
Esta página descreve como configurar os usuários para manter os pontos de acesso entre
sessões de direção, semelhante à experiência de direçã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
pela
API Settings,
que também pode ser usada para 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 de persistência é não compatível por padrão. Uma sobreposição de recurso
(config_enablePersistTetheringCapabilities
) é configurada para bloquear a
capacidade de manter o tethering. Para manter o tethering intencionalmente, defina o
valor como true
para ativar o recurso acima da ativação de preferências do usuário,
já que outros apps do sistema com a permissão WRITE_SECURE_SETTINGS
também
podem controlar essa configuração.
A API a seguir determina se o comportamento está ativado. Chame essa API antes
de 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() { ... }
}
O conteúdo e os exemplos de código nesta página estão sujeitos às licenças descritas na Licença de conteúdo. Java e OpenJDK são marcas registradas da Oracle e/ou suas afiliadas.
Última atualização 2025-06-26 UTC.
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Não contém as informações de que eu preciso","missingTheInformationINeed","thumb-down"],["Muito complicado / etapas demais","tooComplicatedTooManySteps","thumb-down"],["Desatualizado","outOfDate","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Problema com as amostras / o código","samplesCodeIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 2025-06-26 UTC."],[],[],null,["# Maintain hotspots between driving sessions\n\nThis page describes how you can set up users to maintain hotspots between\ndriving sessions, similar to the Wi-Fi driving experience in AAOS. \n\n public class CarSettings {\n ...\n\n @SystemApi\n public static final class Global {\n ...\n\n /**\n * Enables persistent tethering when set to {@code \"true\"}.\n *\n * \u003cp\u003eWhen enabled, tethering is started when the car is started given\n * that the hotspot was enabled at shutdown and all tethering sessions\n * will remain on even if no devices are connected to it.\n *\n * \u003cp\u003eWhen disabled, hotspot will turn off automatically if no devices\n * are connected and will no longer persist through drives.\n *\n * @hide\n */\n @SystemApi\n public static final String ENABLE_PERSISTENT_TETHERING =\n \"android.car.ENABLE_PERSISTENT_TETHERING\";\n }\n }\n\nTo persist tethering, use `ENABLE_PERSISTENT_TETHERING` through the\n[Settings API](https://developer.android.com/reference/android/provider/Settings.Global#public-methods),\nwhich can also be used to query.\n\n### Permissions\n\nUse of the CarWifiManager API is restricted. This new permission is created to\nguard access. \n\n public boolean canControlPersistApSettings() { ... }\n\nProtection levels for this permission are:\n\n| New permission | Permission | Protection level |\n|----------------|-----------------------------------|-------------------------|\n| Yes | `READ_PERSIST_TETHERING_SETTINGS` | Signature \\| Privileged |\n\nThe persist behavior defaults to *not supported.* A resource overlay\n([`config_enablePersistTetheringCapabilities`](https://cs.android.com/android/platform/superproject/+/android-latest-release:packages/services/Car/service/res/values/config.xml;l=644)) is configured to block the\nability to persist tethering. To intentionally persist tethering, set the\nvalue to `true` to enable the feature on top of the user preference\nopt-in since other system apps with the `WRITE_SECURE_SETTINGS` permission can\nalso control this setting.\n\nThe following API determines if the behavior is enabled. Call this API before\nyou change `ENABLE_PERSISTENT_TETHERING`. \n\n /**\n * CarWifiManager provides API to allow for applications to perform Wi-Fi specific\n * operations.\n *\n * @hide\n */\n @SystemApi\n public final class CarWifiManager extends CarManagerBase {\n /**\n * Returns {@code true} if the persist tethering settings are able to be\n * changed.\n *\n * @hide\n */\n @SystemApi\n @RequiresPermission(Car.PERMISSION_READ_PERSIST_TETHERING_SETTINGS)\n public boolean canControlPersistApSettings() { ... }\n }"]]