از 27 مارس 2025، توصیه می کنیم از android-latest-release
به جای aosp-main
برای ساختن و کمک به AOSP استفاده کنید. برای اطلاعات بیشتر، به تغییرات AOSP مراجعه کنید.
سیگنال دهی از طریق USB را غیرفعال کنید
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
اندروید 12 این قابلیت را برای مدیران فناوری اطلاعات اضافه کرده است که سیگنال دهی از طریق USB را در دستگاه های متعلق به شرکت (به جز عملکرد شارژ) غیرفعال کنند. به منظور پشتیبانی از این عملکرد، OEM ها باید USB HAL خود را به روز کنند و از پشتیبانی اضافه شده برای Device Policy Manager API ها استفاده کنند.
مدیر سیاست دستگاه
برای پشتیبانی از غیرفعال کردن سیگنال دهی از طریق USB، سه API عمومی زیر در DevicePolicyManager
گنجانده شده است:
-
setUsbDataSignalingEnabled(boolean enabled)
یک API است که سیگنال دهی USB را با فراخوانی enableUsbDataSignal
API در UsbManager
فعال یا غیرفعال می کند. -
canUsbDataSignalingBeDisabled()
یک API است که بررسی می کند فعال یا غیرفعال کردن سیگنالینگ داده USB در دستگاه پشتیبانی می شود. -
isUsbDataSignalingEnabled()
یک API است که بررسی می کند سیگنالینگ داده USB فعال شده است یا خیر.- برای بررسی اینکه آیا پنجره گفتگوی شفافیت خط مشی نشان داده شده است یا خیر، لازم است. کاربران سیستم می توانند یک نوع مخفی را برای این API خاص فراخوانی کنند که می تواند توسط کاربر سیستم فراخوانی شود تا بررسی کند که آیا سیگنال دهی USB برای یک کاربر خاص فعال شده است یا خیر.
مثال اجرای Device Policy Manager
در زیر نمونه ای از نحوه پیاده سازی Device Policy Manager آورده شده است.
class android.app.admin.DevicePolicyManager {
/**
* Called by device owner or profile owner of an organization-owned managed profile to
* enable or disable USB data signaling for the device. When disabled, USB data connections
* (except from charging functions) are prohibited.
*
* <p> This API is not supported on all devices, the caller should call
* {@link #canUsbDataSignalingBeDisabled()} to check whether enabling or disabling USB data
* signaling is supported on the device.
*
* @param enabled whether USB data signaling should be enabled or not.
* @throws SecurityException if the caller is not a device owner or a profile owner on
* an organization-owned managed profile.
* @throws IllegalStateException if disabling USB data signaling is not supported or
* if USB data signaling fails to be enabled/disabled.
*/
public void setUsbDataSignalingEnabled(boolean enabled);
/**
* Called by device owner or profile owner of an organization-owned managed profile to return
* whether USB data signaling is currently enabled by the admin.
*
* @return {@code true} if USB data signaling is enabled, {@code false} otherwise.
*/
public boolean isUsbDataSignalingEnabled();
/**
* Called by the system to check whether USB data signaling is currently enabled for this user.
*
* @param userId which user to check for.
* @return {@code true} if USB data signaling is enabled, {@code false} otherwise.
* @hide
*/
public boolean isUsbDataSignalingEnabledForUser(@UserIdInt int userId);
/**
* Returns whether enabling or disabling USB data signaling is supported on the device.
*
* @return {@code true} if the device supports enabling and disabling USB data signaling.
*/
public boolean canUsbDataSignalingBeDisabled();
تنظیمات
به محض اتصال USB، کاربران می توانند تنظیمات برگزیده USB و اتصال به اینترنت را تغییر دهند. برای دسترسی به صفحه تنظیمات برگزیده USB، موارد زیر را انجام دهید:
- روی تنظیمات ضربه بزنید.
- روی دستگاههای متصل ضربه بزنید.
- روی USB ضربه بزنید.
توجه: اگر USB متصل نباشد، تنظیمات برگزیده USB قابل تغییر نیستند و در پنجره دستگاههای متصل ظاهر نمیشوند.
اگر یک سرپرست فناوری اطلاعات سیگنالینگ داده USB را در یک دستگاه متعلق به شرکت غیرفعال کند، کاربر نمیتواند تنظیمات برگزیده USB خود را تغییر دهد. در عوض، همه تنظیمات برگزیده USB در تنظیمات کاملاً غیرفعال هستند، که یک پنجره گفتگوی شفافیت خط مشی ایجاد می کند.
توجه: اگر سیگنال دهی USB غیرفعال باشد، اشکال زدایی USB، تنظیمات پیش فرض USB و تنظیمات برگزیده مسیریابی صوتی USB همگی در گزینه های توسعه دهنده غیرفعال می شوند.
محتوا و نمونه کدها در این صفحه مشمول پروانههای توصیفشده در پروانه محتوا هستند. جاوا و OpenJDK علامتهای تجاری یا علامتهای تجاری ثبتشده Oracle و/یا وابستههای آن هستند.
تاریخ آخرین بهروزرسانی 2025-07-29 بهوقت ساعت هماهنگ جهانی.
[[["درک آسان","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-07-29 بهوقت ساعت هماهنگ جهانی."],[],[],null,["# Disable data signaling over USB\n\nAndroid 12 has added the ability for IT admins to disable data signaling\nover USB on corporate-owned devices (except for the charging function). In order to support this\nfunctionality, OEMs must update their USB HAL and utilize the added support for Device Policy\nManager APIs.\n\nDevice Policy Manager\n---------------------\n\nTo support disabling signaling over USB, the following three public APIs are included in\n`DevicePolicyManager`:\n\n- `setUsbDataSignalingEnabled(boolean enabled)` is an API that enables or disables USB data signaling by calling the `enableUsbDataSignal` API in `UsbManager`.\n- `canUsbDataSignalingBeDisabled()` is an API that checks whether enabling or disabling USB data signaling is supported on the device.\n- `isUsbDataSignalingEnabled()` is an API that checks whether USB data signaling has been enabled.\n - This is required to check whether or not a policy transparency dialog window is shown. System users can call a hidden variant for this particular API that can be called by the system user to check if USB data signaling has been enabled for a particular user.\n\n### Device Policy Manager implementation example\n\nThe following is an example of how to implement the Device Policy Manager. \n\n```\nclass android.app.admin.DevicePolicyManager {\n /**\n * Called by device owner or profile owner of an organization-owned managed profile to\n * enable or disable USB data signaling for the device. When disabled, USB data connections\n * (except from charging functions) are prohibited.\n *\n * \u003cp\u003e This API is not supported on all devices, the caller should call\n * {@link #canUsbDataSignalingBeDisabled()} to check whether enabling or disabling USB data\n * signaling is supported on the device.\n *\n * @param enabled whether USB data signaling should be enabled or not.\n * @throws SecurityException if the caller is not a device owner or a profile owner on\n * an organization-owned managed profile.\n * @throws IllegalStateException if disabling USB data signaling is not supported or\n * if USB data signaling fails to be enabled/disabled.\n */\n public void setUsbDataSignalingEnabled(boolean enabled);\n\n\n /**\n * Called by device owner or profile owner of an organization-owned managed profile to return\n * whether USB data signaling is currently enabled by the admin.\n *\n * @return {@code true} if USB data signaling is enabled, {@code false} otherwise.\n */\n public boolean isUsbDataSignalingEnabled();\n\n\n /**\n * Called by the system to check whether USB data signaling is currently enabled for this user.\n *\n * @param userId which user to check for.\n * @return {@code true} if USB data signaling is enabled, {@code false} otherwise.\n * @hide\n */\n public boolean isUsbDataSignalingEnabledForUser(@UserIdInt int userId);\n\n\n /**\n * Returns whether enabling or disabling USB data signaling is supported on the device.\n *\n * @return {@code true} if the device supports enabling and disabling USB data signaling.\n */\n public boolean canUsbDataSignalingBeDisabled();\n```\n\nSettings\n--------\n\n- Users can modify USB preference and tethering settings as soon as USB is connected. To access the USB preferences screen, do the following:\n 1. Tap **Settings.**\n 2. Tap **Connected devices.**\n 3. Tap **USB.**\n- **Note:** If USB is not connected, USB preferences can't be modified and will not appear in the Connected devices window.\n- If an IT admin disables USB data signaling on a corporate-owned device, the user can't modify their USB preferences. Instead, all USB preferences in **Settings** are totally disabled, which will create a policy transparency dialog window.\n- **Note:** If USB data signaling is disabled, USB debugging, default USB configurations, and USB audio routing preferences will all be disabled in developer options."]]