自 2025 年 3 月 27 日起,我們建議您使用 android-latest-release
而非 aosp-main
建構及貢獻 AOSP。詳情請參閱「Android 開放原始碼計畫變更」。
淘汰 SDCardFS
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
在搭載 Android 11 以上版本且執行核心版本 5.4 以上版本的裝置上,已淘汰 SDCardFS。在這種裝置上,VTS 測試不允許掛載的檔案系統列為 SDCardFS。搭載 Android 11 以上版本,但執行 4.19 以下核心版本的裝置可以繼續使用 SDCardFS,但 Google 不會提供額外支援。
在停用前,SDCardFS 提供一種方法,可控制對模擬內部儲存空間和外部 SD 卡的存取權,讓應用程式只存取與其相關的資料。此外,它還提供一個不區分大小寫的層級,以及一些額外的儲存空間追蹤功能。
SDCardFS 替代功能
SDCardFS 的替代方案會使用多個 Linux kernel 檔案系統功能來達成類似的結果。系統會直接處理大小寫不敏感的情況,因此大小寫不敏感的資料夾與大小寫敏感的資料夾的查詢時間幾乎相同,可消除 SDCardFS 中大型資料夾的速度變慢問題。SDCardFS 為了快速收集設定的儲存空間資料,所進行配額追蹤作業,現在已從使用者空間使用專案配額進行設定。在某些效能敏感的情況下,目錄會綁定並掛載到適當位置。新的 FUSE 實作會提供限定範圍儲存空間,以便直接存取檔案系統,主要用於支援位置資訊的遮蓋。
設定 SD 卡替換功能
如要在搭載 Android 11 以上版本的裝置上,為模擬儲存空間啟用專案配額和大小寫折衷,請從 device.mk
檔案的 emulated_storage.mk
繼承:
$(call inherit-product, $(SRC_TARGET_DIR)/product/emulated_storage.mk)
警告: 請勿在搭載 Android 10 以下版本的裝置上執行這項操作,因為檔案系統原生大小寫不敏感性與這些裝置上使用的檔案型加密設定不相容。因此,您必須在這些裝置上繼續使用 SDCardFS。
棄用 SDCardFS 的原因
我們有各種原因淘汰 SDCardFS。
穩定性
SDCardFS 會發生幾個與大小寫敏感度相關的競爭狀況,以及一些與記憶體不足情況相關的問題。在大型目錄中,不區分大小寫的查詢可能會相當緩慢,因為查詢必須逐一檢查較低層目錄,才能找到其他大小寫。同時存取上層和下層檔案系統也會導致問題。
上游對等性
SDCardFS 需要額外的 VFS 修補程式,才能支援綁定掛載點的變更選項。這些修補程式會導致額外工作,以便接受這些領域的上游變更。SDCardFS 的功能可由上游元件複製,因此可解決這個問題。
與 API 的功能對等性
在先前的 Android 版本中,範圍限定儲存空間會限制存取特定類型的中繼資料。透過 SDCardFS 進行直接儲存空間存取作業,不支援這些受控範圍的儲存空間功能。
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。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,["# SDCardFS deprecation\n\nSDCardFS is deprecated on devices that launch with Android 11 or higher and run kernel version 5.4 or higher. On such\ndevices, [VTS\ntesting](https://android.googlesource.com/platform/test/vts-testcase/kernel/+/refs/heads/android11-dev/sdcardfs/)\ndoesn't allow mounted file systems listed as SDCardFS. Devices that launch with\nAndroid 11 or higher but run kernel version 4.19 or\nlower can continue to use SDCardFS, but Google doesn't provide additional\nsupport.\n\nBefore its deprecation, SDCardFS provided a way to control access to emulated\ninternal storage and external SD cards, allowing apps to access only the data\nrelevant to them. Additionally, it provided a layer of case insensitivity, as\nwell as some additional storage tracking.\n\nSDCardFS replacement functionality\n----------------------------------\n\nThe replacement for SDCardFS uses several Linux kernel filesystem features to\nachieve similar results. Case insensitivity is handled directly by the\nfilesystem; this results in lookup times nearly identical in case-sensitive and\ncase-insensitive folders, removing the large folder slowdown from SDCardFS. The\nquota tracking that SDCardFS was doing to quickly gather storage data for\nsettings is now configured from userspace using project quotas. In some\nperformance-sensitive contexts, directories are bind mounted in place. A new\nFUSE implementation provides scoped storage for direct filesystem access,\nprimarily to support redaction of location information.\n\nConfigure SDCard replacement functionality\n------------------------------------------\n\nTo enable project quotas and case folding for emulated storage without SDCardFS\non a device that launched with Android 11 or higher,\ninherit from `emulated_storage.mk` in the `device.mk` file: \n\n $(call inherit-product, $(SRC_TARGET_DIR)/product/emulated_storage.mk)\n\n**Warning:** Do *not* do this on devices\nthat launched with Android 10 or lower, since\nfilesystem native case-insensitivity is incompatible with the file-based\nencryption settings used on such devices. It is necessary to keep using SDCardFS\non such devices.\n\nReasons to deprecate SDCardFS\n-----------------------------\n\nThere are various reasons to deprecate SDCardFS.\n\n### Stability\n\nSDCardFS suffers from several race conditions concerning case sensitivity, as\nwell as some issues concerning low memory circumstances. Case-insensitive\nlookups can be rather slow in large directories because lookups have to walk the\nlower directory to find alternate cases. Accessing the upper and lower\nfilesystems at the same time can lead to issues as well.\n\n### Upstream parity\n\nSDCardFS requires additional patches to the VFS to support changing options on\nbind mounts. These patches cause additional work to accept upstream changes to\nthese areas. SDCardFS's features can be replicated by upstream components,\nremoving this pain point.\n\n### Feature parity with API\n\nIn the previous release of Android, scoped storage limited access to particular\ntypes of metadata. Direct storage access through SDCardFS doesn't support these\nscoped storage features."]]