ตั้งแต่วันที่ 27 มีนาคม 2025 เป็นต้นไป เราขอแนะนำให้ใช้ android-latest-release
แทน aosp-main
เพื่อสร้างและมีส่วนร่วมใน AOSP โปรดดูข้อมูลเพิ่มเติมที่หัวข้อการเปลี่ยนแปลงใน AOSP
รักษาฮอตสปอตไว้ระหว่างเซสชันการขับรถ
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
หน้านี้อธิบายวิธีตั้งค่าให้ผู้ใช้รักษาฮอตสปอตไว้ระหว่างเซสชันการขับรถ ซึ่งคล้ายกับประสบการณ์การขับรถผ่าน 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() { ... }
}
ตัวอย่างเนื้อหาและโค้ดในหน้าเว็บนี้ขึ้นอยู่กับใบอนุญาตที่อธิบายไว้ในใบอนุญาตการใช้เนื้อหา Java และ OpenJDK เป็นเครื่องหมายการค้าหรือเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-06-26 UTC
[[["เข้าใจง่าย","easyToUnderstand","thumb-up"],["แก้ปัญหาของฉันได้","solvedMyProblem","thumb-up"],["อื่นๆ","otherUp","thumb-up"]],[["ไม่มีข้อมูลที่ฉันต้องการ","missingTheInformationINeed","thumb-down"],["ซับซ้อนเกินไป/มีหลายขั้นตอนมากเกินไป","tooComplicatedTooManySteps","thumb-down"],["ล้าสมัย","outOfDate","thumb-down"],["ปัญหาเกี่ยวกับการแปล","translationIssue","thumb-down"],["ตัวอย่าง/ปัญหาเกี่ยวกับโค้ด","samplesCodeIssue","thumb-down"],["อื่นๆ","otherDown","thumb-down"]],["อัปเดตล่าสุด 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 }"]]