รักษาฮอตสปอตไว้ระหว่างเซสชันการขับรถ

หน้านี้อธิบายวิธีตั้งค่าผู้ใช้เพื่อรักษาฮอตสปอตระหว่างเซสชันการขับขี่ ซึ่งคล้ายกับประสบการณ์การขับขี่ด้วย Wi-Fi ใน 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";
  }
}

หากต้องการคงการเชื่อมต่ออินเทอร์เน็ต ให้ใช้ ENABLE_PERSISTENT_TETHERING ผ่าน Settings API ซึ่งใช้ในการค้นหาได้ด้วย

สิทธิ์

การใช้ CarWifiManager API ถูกจำกัด เราสร้างสิทธิ์ใหม่นี้ขึ้นมาเพื่อ ป้องกันการเข้าถึง

public boolean canControlPersistApSettings() { ... }

ระดับการป้องกันสำหรับสิทธิ์นี้มีดังนี้

สิทธิ์ใหม่ สิทธิ์ ระดับการปกป้อง
ใช่ READ_PERSIST_TETHERING_SETTINGS ลายเซ็น | สิทธิ์พิเศษ

ลักษณะการทำงานของฟีเจอร์คงอยู่จะตั้งค่าเริ่มต้นเป็นไม่รองรับ ระบบจะกำหนดค่าการซ้อนทับทรัพยากร (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() { ... }
}