Skip to content
Commit 6caa2d15 authored by Martijn Coenen's avatar Martijn Coenen
Browse files

Add API for updating quota type of files on external storage.

In recent releases, Android has used the GID of files on external
storage to compute quota for various media types. This was implemented
by the kernel sdcard filesystem, which kept a mapping of file
extension->GID, and automatically set the correct GID on the lower
filesystem. We then simply asked the kernel "how much space is used by
the GID corresponding to image files" to determine how much space image
files took up on external storage.

sdcardfs will be removed starting with devices launching with R; this
means that the quota tracking implementation can no longer live in the
kernel on these devices. MediaProvider is a logical place to initiate
the quote handling in userspace, since it is responsible for all files
on external storage.

But since MediaProvider is now a mainline module, we don't want the
quota tracking implementation to live in MediaProvider itself. Instead,
provide a new @SystemAPI on StorageManager that can be called whenever
we need to set the quota type for a file on external storage. This
allows MediaProvider to call this API whenever a file is created on
external storage, or whenever its type is changed such that it requires
using a different quota type (eg going from an image file to an audio
file, which is presumably a rare case).

The API doesn't require a special permission, because the current
implementation is not a binder call, but an in-process call to modify
filesystem attributes. That means that the caller must already be in an
SELinux domain that allows these attribute modifications. Currently,
only MediaProvider and vold are allowed to modify these attributes.
Therefore, this API is effectively protected by SELinux.

Bug: 146419093
Test: builds. Functionality will be tested with existing
      StorageHostTest CTS test, but running that tests depends on other
      changes (eg a device without sdcardfs). This is tracked in the
      test plan for removing sdcardfs.
Change-Id: I9ffb11a89b17e5596fce70e96c06a8af2142e41f
parent f7258237
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment