از 27 مارس 2025، توصیه می کنیم از android-latest-release
به جای aosp-main
برای ساختن و کمک به AOSP استفاده کنید. برای اطلاعات بیشتر، به تغییرات AOSP مراجعه کنید.
Automotive Location Bypass API,Automotive Location Bypass API
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
این ویژگی اجازه میدهد تا دسترسی به مکان برنامههای کمک راننده فهرست مجاز، همراه با Android، به طور جداگانه توسط سوئیچ «استفاده از موقعیت مکانی برای کمک راننده» کنترل شود. این برنامهها را قادر میسازد حتی زمانی که سوئیچ «استفاده از مکان» خاموش است، به مکان دسترسی داشته باشند.
- اندروید 12 یک API عمومی برای این ویژگی ارائه نمی کند. برنامههای کمک راننده باید طبق معمول درخواست بهروزرسانی مکان کنند.
- Android نسخه 13 و بالاتر باید برای استفاده از
LocationManager.requestLocationUpdates()
درخواست مکان ارائه کند و در یک شی LocationRequest
که با LocationRequest.setAdasGnssBypass(true)
پیکربندی شده است عبور دهد.
از API دور زدن مکان کمک راننده استفاده کنید
بخشهای زیر نحوه استفاده از API بای پس موقعیت مکانی کمک راننده را شرح میدهند. برای کسب اطلاعات بیشتر در مورد خطمشی استفاده، به خطمشی فهرست مجاز دور زدن موقعیت مکانی مراجعه کنید.
وضعیت سوئیچ کمک راننده را بررسی کنید
در Android 13 و بالاتر، میتوانید وضعیت سوئیچ کمک راننده را قبل از درخواست بهروزرسانی مکان بررسی کنید.
// Returns the current status of "Use location for driver assistance".
locationManager.isAdasGnssLocationEnabled();
دستورات Android Debug Bridge (ADB) را اجرا کنید
برای توسعه و آزمایش، میتوانید بدون استفاده از تنظیمات مکان، وضعیت کلید کمک راننده را به سرعت بررسی یا تغییر دهید.
- برای استفاده از دستورات ADB برای بررسی یا تغییر وضعیت:
// Gets the status of ADAS location.
adb shell cmd location is-adas-gnss-location-enabled
// Enables ADAS location.
adb shell cmd location set-adas-gnss-location-enabled true
// Disables ADAS location.
adb shell cmd location set-adas-gnss-location-enabled false
مجوز را تنظیم کنید
برای نسخههای اندرویدی خاص به موارد زیر مراجعه کنید:
- در Android 12، برنامههای کمک راننده باید مجوز WRITE_SECURE_SETTINGS را داشته باشند.
- در Android نسخه 13 و بالاتر، مجوز
LOCATION_BYPASS
مورد نیاز است.
یک برنامه را به لیست مجاز دستگاه خود اضافه کنید
در دایرکتوری etc/sysconfig
:
- نام بسته برنامه را در یک فایل XML پیکربندی سیستم اضافه کنید:
<!-- In a xml file under etc/sysconfig–>
<config>
…
<allow-adas-location-settings package="PACKAGE-NAME" />
…
</config>
برای اطمینان از نمایش بسته شما در رابط کاربری تنظیمات مکان، نام بسته خود را به config_locationDriverAssistancePackageNames
اضافه کنید.
نشانی اینترنتی افشای خط مشی رازداری برنامه را به AndroidManifest.xml
اضافه کنید. نام متا داده باید privacy_policy
باشد.
<meta-data android:name="privacy_policy" android:value= privacy policy URL/>
"استفاده از موقعیت مکانی برای سوئیچ کمک راننده" را بردارید
اگر برنامه کمک راننده مبتنی بر مکان ندارید که موقعیت مکانی را از Android درخواست میکند، میتوانید برای حذف سوئیچ تنظیمات مکان، بلوک کد را نظر دهید.
-
packages/apps/Car/Settings/res/xml/location_settings_fragment.xml
را باز کرده و کد زیر را نظر دهید. <com.android.car.ui.preference.CarUiTwoActionSwitchPreference
android:fragment="com.android.car.settings.location.AdasLocationFragment"
android:key="@string/pk_location_driver_assistance_state_switch"
android:title="@string/location_driver_assistance_toggle_title"
android:summary="@string/location_driver_assistance_toggle_summary"
settings:controller="com.android.car.settings.location.AdasLocationSwitchPreferenceController"
settings:searchable="true"/>
<com.android.car.settings.common.DividerPreference/>
- پس از حذف سوئیچ،
config_defaultAdasGnssLocationEnabled
را روی false
قرار دهید.
مجموعه تست Automotive را اجرا کنید
Google یک تست مجموعه تست خودرو (ATS) ارائه میکند، که تضمین میکند همه بستههای کمک راننده در یک دستگاه در فهرست مجاز Google قرار گرفتهاند. تست از راه دور پیکربندی شده است. برای افزودن یک بسته جدید نیازی نیست تا نسخه بعدی ATS منتظر بمانید. میتوانید در بخش Complete Automotive Tests in a Box اطلاعات بیشتری کسب کنید.
محتوا و نمونه کدها در این صفحه مشمول پروانههای توصیفشده در پروانه محتوا هستند. جاوا و OpenJDK علامتهای تجاری یا علامتهای تجاری ثبتشده Oracle و/یا وابستههای آن هستند.
تاریخ آخرین بهروزرسانی 2025-08-08 بهوقت ساعت هماهنگ جهانی.
[[["درک آسان","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-08-08 بهوقت ساعت هماهنگ جهانی."],[],[],null,["# Automotive Location Bypass API\n\nThis feature allows location access of allowlisted, Android-bundled, driver\nassistance apps to be controlled separately by the \"Use location for driver\nassistance\" switch. This enables these apps to access location even when the \"Use location\"\nswitch is off.\n\n- Android 12 doesn't provide a public API for this feature. Driver assistance apps should request location updates as usual.\n- Android 13 and higher must make a location request to use `LocationManager.requestLocationUpdates()` and pass in a `LocationRequest` object configured with `LocationRequest.setAdasGnssBypass(true)`.\n\nUse the driver assistance location bypass API\n---------------------------------------------\n\nThe following sections describe how to use the driver assistance location bypass API. To learn\nmore about the usage policy, see\n[Location Bypass Allowlist Policy](/docs/automotive/location_bypass/location_bypass_policy).\n\n### Check the driver assistance switch status\n\nIn Android 13 and higher, you can check driver assistance switch status\nbefore requesting location updates.\n\n```scilab\n// Returns the current status of \"Use location for driver assistance\".\nlocationManager.isAdasGnssLocationEnabled();\n```\n\n### Run Android Debug Bridge (ADB) commands\n\nFor development and testing, you can quickly check or change the status of the driver assistance\ntoggle without using Location Settings.\n\n1. To use ADB commands to check or change status: \n\n ```scilab\n // Gets the status of ADAS location.\n adb shell cmd location is-adas-gnss-location-enabled\n\n // Enables ADAS location.\n adb shell cmd location set-adas-gnss-location-enabled true\n\n // Disables ADAS location.\n adb shell cmd location set-adas-gnss-location-enabled false\n ```\n\n### Set permission\n\nSee the following for version-specific Android releases:\n\n1. In Android 12, driver assistance apps must have the [WRITE_SECURE_SETTINGS](https://developer.android.com/reference/android/Manifest.permission#WRITE_SECURE_SETTINGS) permission.\n2. In Android 13 and higher, the `LOCATION_BYPASS` permission is required.\n\n### Add an app to the allowlist on your device\n\nIn the `etc/sysconfig` directory:\n\n1. Add the app's package name in a system configuration XML file: \n\n```carbon\n\u003c!-- In a xml file under etc/sysconfig--\u003e\n\u003cconfig\u003e\n...\n\u003callow-adas-location-settings package=\"PACKAGE-NAME\" /\u003e\n...\n\u003c/config\u003e\n```\n\nTo ensure your package appears in the Location Settings UI, add your package name to\n`config_locationDriverAssistancePackageNames`.\n\nAdd the app's URL of privacy policy disclosure to `AndroidManifest.xml`. The name\nof the meta-data should be `privacy_policy`. \n\n```scdoc\n\u003cmeta-data android:name=\"privacy_policy\" android:value= privacy policy URL/\u003e\n```\n\n### Remove the \"Use location for driver assistance switch\"\n\nIf you don't have a location-powered driver assistance app that requests location from Android,\nyou can comment out the code block to remove the switch for Location Settings.\n\n1. Open `packages/apps/Car/Settings/res/xml/location_settings_fragment.xml` and then comment out the following code. \n\n ```transact-sql\n \u003ccom.android.car.ui.preference.CarUiTwoActionSwitchPreference\n\n android:fragment=\"com.android.car.settings.location.AdasLocationFragment\"\n\n android:key=\"@string/pk_location_driver_assistance_state_switch\"\n\n android:title=\"@string/location_driver_assistance_toggle_title\"\n\n android:summary=\"@string/location_driver_assistance_toggle_summary\"\n\n\n settings:controller=\"com.android.car.settings.location.AdasLocationSwitchPreferenceController\"\n\n settings:searchable=\"true\"/\u003e\n\n \u003ccom.android.car.settings.common.DividerPreference/\u003e\n ```\n2. After removing the switch, set `config_defaultAdasGnssLocationEnabled` to `false`.\n\nRun the Automotive test suite\n-----------------------------\n\nGoogle provides an Automotive test suite (ATS) test, which ensures that all driver assistance\npackages on a device have been allowlisted with Google. The test is remotely configured. You\nneedn't wait until the next ATS release to add a new package. You can learn more at\n[Complete Automotive Tests in a Box.](/docs/automotive/tools/catbox)\n[](/docs/automotive/tools/catbox)"]]