自 2025 年 3 月 27 日起,我們建議您使用 android-latest-release
而非 aosp-main
建構及貢獻 AOSP。詳情請參閱「Android 開放原始碼計畫變更」。
Android 權限
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
Android 權限提供控管機制,可提高使用者意識,並限制應用程式存取機密資料的權限。在 Android 8.0 以下版本設定權限時,必須加入許可清單,否則即使具有特殊權限的應用程式位於 priv-app
路徑,也會遭到停用。在 Android 9 以上版本中,如果裝置嘗試使用未列入正確許可清單的應用程式,就無法啟動。
Android 10 引進了「角色」概念,這是系統中與特定需求和權限相關聯的專屬名稱。為應用程式指派角色,授予特定用途的權限,並使用平台設定資源設定預設角色。
強化防範可能有害的應用程式 (PHA) 的功能可改善以下項目:
- 公開可能有害的應用程式行為。
- 使用者可控管應用程式行為。
- 應用程式開發人員在使用受權限保護的私人資料時,可自行決定是否使用。
套件安裝和權限
在 Android 9 以下版本中,套件安裝和權限控制功能包含在 PackageInstaller
套件 (//packages/apps/PackageInstaller
) 中。在 Android 10 以上版本中,權限控制功能則位於獨立的 PermissionController
套件 (//packages/apps/PermissionController
) 中。圖 1 說明這兩個套件在 Android 10 中的所在位置。
圖 1. Android 10 中的套件安裝和權限控管功能
許可清單和存取權
在 Android 6.0 以上版本中,應用程式會在執行階段要求危險權限的存取權。Android 10 新增活動辨識 (AR) 執行階段權限,可提示使用者修改或允許危險權限。
Android 8.0 要求您在 /etc/permissions
目錄的系統設定 XML 檔案中,明確列出特權應用程式。在 Android 9 以上版本中,必須將特權權限加入許可清單,否則裝置無法啟動。
為了限制內部 API 的顯示範圍,並防止應用程式誤用平台程式庫,Android 7.0 推出了原生程式庫的命名空間。這可將系統程式庫與應用程式程式庫分開,讓裝置製造商能夠新增自己的原生程式庫。
從 Android 10 開始,應用程式必須同時具備簽章權限和使用者同意聲明,才能
存取裝置的螢幕內容。依賴靜默擷取功能 (例如擷取螢幕截圖) 的特權應用程式,應改用 MediaProjection 類別。
Android 15 要求您在 /etc/permissions
目錄的系統設定 XML 檔案中,明確許可清單非系統應用程式要求的平台簽章權限,或系統應用程式更新後要求的權限。
資訊公開與隱私權
在 Android 6.0 以上版本中,裝置原廠 MAC 位址會受到保護,以免遭到 Wi-Fi 服務供應商和封包分析工具存取。在 Android 10 中,除非應用程式
已加入特權權限的許可清單,否則會受到額外限制,無法存取不可變動的裝置 ID。(「連線」
一節提供有關裝置 ID的相關討論,因為這會影響電信業者。)
在 Android 9 以下版本中,使用者在授予應用程式位置存取權時,會做出永久性的選擇。自 Android 10 起,三態位置權限功能可讓使用者選擇三種選項,允許應用程式存取裝置位置資訊。無論目標 SDK 為何,這些權限規定都會套用至 Android 10 中的應用程式。
自 Android 10 起,設定其他資訊公開和隱私權功能的權限
簡化設定
我們已簡化 Android 6.0 以上版本的權限設定。
init
啟動的服務的背景功能會將服務設定的所有層面保留在單一 .rc
檔案中。如果要為未由 init
啟動的服務設定功能,請改用 fs_config.c
設定檔案系統功能。
- Android 7.x 以下版本會擴充 Android ID (AID) 機制,使用裝置專屬的
android_filesystem_config.h
檔案指定檔案系統功能和/或自訂裝置製造商 AID。Android 8.0 以上版本支援擴充檔案系統功能的新方法。
- 在 Android 8.0 中,處理 USB 指令已從裝置專屬的
init
指令碼 (HAL 層的替代方案) 移至原生 USB 守護程序。在 Android 8.0 以上版本推出的每部裝置上,都必須實作 USB HAL 介面。
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。Java 與 OpenJDK 是 Oracle 和/或其關係企業的商標或註冊商標。
上次更新時間:2025-07-27 (世界標準時間)。
[[["容易理解","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-27 (世界標準時間)。"],[],[],null,["# Android permissions provide controls that increase user awareness and limit\nan app's access to sensitive data. Configuring permissions on Android 8.0 and\nlower includes allowlisting, without which privileged apps are disabled, even\nif they're in the `priv-app` path. On Android 9 and higher, a device\nthat tries to use apps that aren't properly allowlisted won't boot.\n\nAndroid 10 introduced the concept of a\n[role](https://developer.android.com/reference/android/app/role/RoleManager), a unique\nname within the system associated with\ncertain requirements and privileges. Assign roles to apps to grant them permissions for\na specific purpose, and configure default roles using platform config resources.\n\nThe increased protections against\n[Potentially\nHarmful Apps](https://developers.google.com/android/play-protect/potentially-harmful-applications) (PHAs) improve:\n\n- Transparency into potentially harmful app behavior.\n- User control over app behavior.\n- App developers' discretion when using private data, protected by permissions.\n\n### Package install and permission\n\nIn Android 9 and lower, the package install and permission control\nfunctionalities were contained in the `PackageInstaller` package\n(`//packages/apps/PackageInstaller`). In Android 10 and higher, the permission control functionality\nresides in a separate package, `PermissionController`\n(`//packages/apps/PermissionController`). [Figure 1](#package-install)\nillustrates where the two packages reside in Android 10.\n\n**Figure 1.** Package install and\npermission-control functionalities in Android 10\n\n### Allowlists and access\n\nIn Android 6.0 and higher, apps request access to dangerous permissions at\n[runtime](/docs/core/permissions/runtime_perms).\nAndroid 10 adds activity recognition (AR) runtime\npermissions, which prompt the user to modify or allow dangerous\npermissions.\n\nAndroid 8.0 required you to explicitly allowlist privileged apps in the\nsystem configuration XML files in the `/etc/permissions` directory.\nIn Android 9 and higher, privileged permissions must be\n[allowlisted](/docs/core/permissions/perms-allowlist)\nor the device can't boot.\n\nTo limit internal API visibility and prevent apps from accidentally\naccessing platform libraries, Android 7.0 introduced\n[Namespaces\nfor Native Libraries](/docs/core/permissions/namespaces_libraries). This separates system libraries from app\nlibraries, and device manufacturers can add their own native libraries.\n\nStarting in Android 10 apps must have both\nsignature permissions and user consent to [access a device's screen content](/docs/core/permissions/restricted-screen-reading). Privileged apps that rely on the silent\ncapture functionality, such as taking a screenshot, should use the\n[MediaProjection](https://developer.android.com/reference/android/media/projection/MediaProjection)\nclass instead.\n\nAndroid 15 requires you to explicitly\n[allowlist](/docs/core/permissions/signature-permission-allowlist)\nplatform signature permissions that are requested by nonsystem apps or newly requested by updates\nto system apps, in the system configuration XML files in the `/etc/permissions`\ndirectory.\n\n### Transparency and privacy\n\nIn Android 6.0 and higher, a device factory MAC address is protected from\naccess by Wi-Fi service providers and packet analyzers. Additional restrictions as\nof Android 10 limit apps from accessing the\n[immutable\ndevice identifiers (IDs)](/docs/core/permissions/immutable-device-ids) unless they're [allowlisted for privileged permissions](/docs/core/permissions/perms-allowlist). (The [**Connectivity**](/docs/core/connect) section provides a related discussion about\n[Device\nIdentifiers](/docs/core/connect/device-identifiers), as this impacts carriers.)\n\nOn Android 9 and lower, users make persistent choices when granting location\naccess to apps. Starting in Android 10, a\n[tristate\nlocation permissions](/docs/core/permissions/tristate-perms) feature gives users three options to allow app access\nto a device's location. These permission requirements are applied to apps in\nAndroid 10 regardless of target SDK.\n\nConfigure permissions for other transparency and privacy features starting\nin Android 10\n\n- The [background access location](/docs/core/permissions/background-location-access) reminder shows users when an app accesses their device location using [ACCESS_FINE_LOCATION](https://developer.android.com/reference/android/Manifest.permission#ACCESS_FINE_LOCATION) permission in the background.\n- Contacts-affinity related data, managed by the Contacts Provider component, is accessed differently: Apps can't write to or read from the [contact\n affinities](/docs/core/permissions/contacts-affinities) data in the database. This impacts [caller-related APIs](/docs/core/permissions/contacts-affinities#APIchanges).\n\n### Streamlined configurations\n\nPermissions configurations have been streamlined for Android 6.0 and\nhigher.\n\n- [Ambient\n capabilities](/docs/core/permissions/ambient) for services launched by `init` keeps all aspects of the service configuration in a single `.rc` file. When setting capabilities for services not launched by `init`, configure file system capabilities using `fs_config.c` instead.\n- Android 7.x and lower extend the Android IDs (AIDs) mechanism, using a device-specific `android_filesystem_config.h` file to specify filesystem capabilities and/or custom device-manufacturer AIDs. Android 8.0 and higher supports a [new method\n to extend filesystem capabilities](/docs/core/permissions/filesystem).\n- In Android 8.0, handling USB commands moved out of device-specific `init` scripts (a substitution for HAL layers) and into a native USB daemon. The [USB HAL](/docs/core/permissions/usb-hal) interface must be implemented on every device launching on Android 8.0 and higher."]]