在驾驶会话之间保持热点

本页面介绍了如何设置用户以在 Google Cloud 之间 驾驶会话,类似于 AAOS 中的 Wi-Fi 驾驶体验。

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";
  }
}

要保持网络共享,请通过以下方式使用 ENABLE_PERSISTENT_TETHERINGSettings API 也可用于查询

权限

对 CarWifiManager API 的使用受到限制。这项新权限旨在 保障访问。

public boolean canControlPersistApSettings() { ... }

此权限的保护级别为:

新权限 权限 保护级别
READ_PERSIST_TETHERING_SETTINGS 签名 |特权

保留行为默认为 not supported。资源叠加层 (config_enablePersistTetheringCapabilities) 已配置为屏蔽 以及持续网络共享的功能要有意保留网络共享,请将 值设为 true,以在用户偏好设置的基础上启用该功能 选择启用,因为具有 WRITE_SECURE_SETTINGS 权限的其他系统应用可以 也可以控制此设置

以下 API 可确定是否已启用该行为。先调用此 API 您更改 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() { ... }
}