History log of /frameworks/native/cmds/installd/utils.h
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
d712f0ccc120357e1267a04ac6de9dd732b27e76 03-May-2017 Jeff Sharkey <jsharkey@android.com> Clear cached files on external storage.

When clearing cached files belonging to an app, include any cached
files on external storage. Since we need to keep sdcardfs in the
loop about any file deletions, we always mutate by going through the
sdcardfs layer instead of behind its back.

Test: cts-tradefed run commandAndExit cts-dev -m CtsAppSecurityHostTestCases -t android.appsecurity.cts.StorageHostTest
Bug: 37486230, 37566983, 37913442, 37914374
Change-Id: If174bf7eaf682da83cf0ab1b4938fe9a5956d464
/frameworks/native/cmds/installd/utils.h
a084fcdcd052d71e8205a2eea0955911b99160b9 18-Apr-2017 Jeff Sharkey <jsharkey@android.com> Fix external cache and secondary user bugs.

External cache files now have their own GID range, so measure using
those quotas. Fix secondary user code measurement, since it always
lives under user 0. Fix secondary user data measurement in manual
mode; we need to match based on appId instead of pure UID.

Test: cts-tradefed run commandAndExit cts-dev -m CtsAppSecurityHostTestCases -t android.appsecurity.cts.StorageHostTest
Bug: 35812899, 35844919, 37193650
Change-Id: Ic3b153798164c33ea10e8a4dabc65edff26c56ca
/frameworks/native/cmds/installd/utils.h
ec1be62c18b216901d738be0ccc8a05aab8edef0 10-Apr-2017 Jeff Sharkey <jsharkey@android.com> Get a hack in place for broken quotas.

Sadly we mixed together both UID and GID quotas in such a way that
we couldn't detangle the actual data-vs-cache usage in all cases.

Temporarily patch over this to get CTS passing until we can circle
back and try again.

Test: cts-tradefed run commandAndExit cts-dev -m CtsAppSecurityHostTestCases -t android.appsecurity.cts.StorageHostTest
Bug: 36731175, 37193650
Change-Id: I5870b4e9c22398762fc47672e4d5d78c06bef79f
/frameworks/native/cmds/installd/utils.h
e12d5964a8d14abe7f2eb6e57469cbe7f7391a19 04-Apr-2017 Jeff Sharkey <jsharkey@android.com> Offer to "fixup" GIDs used for app data.

We recently started tracking cached app data using a per-app GID for
the "cache" and "code_cache" directories and their contents. For
upgraded devices, we ideally want to "fixup" the GIDs of any existing
data while the device is still showing the boot animation, instead of
blocking the user when they unlock the device.

Since all the information we need is available in metadata, we can
update GIDs before the user has unlocked data. We're pretty paranoid
and we only pivot between the normal app GID and the cache GID; any
other GID values are ignored.

This "fixup" method can also be used in the future to ensure
consistency of the files on disk. Also fix bug by always using
"fts_path" instead of "fts_accpath" which is based on racy chdir().

Test: /data/nativetest/installd_service_test/installd_service_test
Bug: 34201111, 35084485
Change-Id: Ia52694f3763cba09926082c08f0766477e03e39c
/frameworks/native/cmds/installd/utils.h
1cb4aafc17daae520a5c3a991f59605ea3ee4ee5 28-Mar-2017 Jeff Sharkey <jsharkey@android.com> Remove legacy cache clearing logic.

It was riddled with funky memory access, and it's been fully replaced
by the new V2 logic.

Test: builds, boots
Bug: 27948817, 36655947
Change-Id: Ic5f0636c414ccf5ccf56eb50fea321b6688a83a0
/frameworks/native/cmds/installd/utils.h
ed909ae8db2f44ce7fe7003c6fee457f13669702 23-Mar-2017 Jeff Sharkey <jsharkey@android.com> Follow "atomic" to "group" refactoring.

Remove noisy logging about UIDs that are relying on default cache
quota of 64MiB.

Move away from yucky old statfs() and use statvfs() instead.

Test: /data/nativetest/installd_cache_test/installd_cache_test
Bug: 35812899, 35684969, 36482620
Change-Id: I3d68da97eac2ebcda489bdf9d27061cac5b3f7cc
/frameworks/native/cmds/installd/utils.h
8348fa3545e0ad4e178b5f3faf37a3b68da727d6 17-Mar-2017 Calin Juravle <calin@google.com> Merge "Support profile guided compilation for secondary dex files" am: cb2e477f14 am: f01cd5f89f
am: 95c5f4b85d

Change-Id: I432fd0a8e7056b5d41e6beb9a71d8fd74c3a34b8
114f08107be384a3f9cc954bdec2b6b7619354ae 09-Mar-2017 Calin Juravle <calin@google.com> Support profile guided compilation for secondary dex files

Test: adb shell cmd package bg-dexopt-job works for sercondary dex files
Bug: 26719109
Change-Id: I4011a780f65378c23a4631c07c37cdb4f5fee41e
/frameworks/native/cmds/installd/utils.h
47ec28647af5ce9d7079ee2ab782cf42e6299cad 11-Mar-2017 Calin Juravle <calin@google.com> Merge "Use std::string for profile operations instead of const char" am: 7c7d888d94 am: ccaa1f3f78
am: 0045d606d1

Change-Id: I6ad63a777811dbc5e5d74870441d8c76dc3273af
76268c56febde9a77183387fbd4baabe6694e6b5 09-Mar-2017 Calin Juravle <calin@google.com> Use std::string for profile operations instead of const char

Will make things cleaner when adding secondary dex profile support.

Also, add tests to verify profile path creation.

Bug: 26719109
Test: /data/nativetest64/installd_utils_test/installd_utils_test
Change-Id: I8cb1a11cefee21f5001d2b729110696d52fc8323
/frameworks/native/cmds/installd/utils.h
c9e55782b05366bfcda975c2f5e4b80632b8c884 07-Mar-2017 Calin Juravle <calin@google.com> Merge "Installd: Clean up code related to foreign dex use" am: 62b34b57c4 am: 9d4819ff2e
am: 9181bdb57f

Change-Id: I2257654b3b73e74a92a179e1068f771e2b6af186
35c8465e31381dcc9a59655f63a91849a50294a6 04-Mar-2017 Calin Juravle <calin@google.com> Installd: Clean up code related to foreign dex use

We simplified the way we track whether or not a dex file is used by
other apps. DexManager in the framework keeps track of the data and we
no longer need file markers on disk.

Also, fix the getUserSize by considering the size of the actual profiles
not of the set of empty markers.

Test: device boots, foreign dex markers are not created anymore

Bug: 32871170
Change-Id: I9250e816a1bfa95cb10155e513ae28ebfda7ce4b
/frameworks/native/cmds/installd/utils.h
80a2125b85eaa0916daea7e90b016fe4f1b59924 17-Jan-2017 Calin Juravle <calin@google.com> Add installd logic for compiling secondary dex files

Secondary dex compilation takes almost the same path as primary apk
compilation.

The main difference is in the fact that for secondary dex files we
create the oat dir on the fly and execute dexoptanalyzer (the equivalent
of GetDexOptNeeded) to check if we really need to perform the
compilation.

Test: adb shell cmd package compile -f -m speed --secondary-dex com.google.android.gms
Bug: 32871170

(cherry picked from commit 42451c029b0e87990e5833daea2286bb12c21df5)

Change-Id: Ie5efe6eccc6b8c91ca7bd7c9e680aa7288d79ae8

Merged-In: I2c56d57322899968a338ccabffca575d66f8ee08
/frameworks/native/cmds/installd/utils.h
871a8f236ef2a055b9955b47a342b2c44c020ef7 22-Feb-2017 Jeff Sharkey <jsharkey@android.com> Logic for atmoic/tombstone behavior; split mode.

Flesh out logic for cache directories that request new atomic and/or
tombstone clearing behaviors. Atomic directories are considered for
deletion as a single all-or-nothing unit, and tombstone directories
truncate any removed files instead of unlinking them.

Since these behaviors can be mixed together, add local tests that
quickly verify several different permutations.

Reduce memory footprint of CacheItem objects by only storing name
and pointer to parent (instead of full path). Fix ordering bug by
switching to std::stable_sort.

Add "V2_DEFY_QUOTA" flag so we can split clearing into two distinct
phases: clearing data for apps above their quotas, and then pushing
deeper by clearing data for apps below their quotas.

Test: adb shell /data/nativetest64/installd_cache_test/installd_cache_test
Bug: 34692014, 33811826
Change-Id: I156897de1d1d1c371b2b837128b2e286bf33d40d
/frameworks/native/cmds/installd/utils.h
20e0fd800ffa9eaa9e95f3c9b84e1610068827ee 30-Jan-2017 Calin Juravle <calin@google.com> Merge "Add installd logic for compiling secondary dex files"
42451c029b0e87990e5833daea2286bb12c21df5 17-Jan-2017 Calin Juravle <calin@google.com> Add installd logic for compiling secondary dex files

Secondary dex compilation takes almost the same path as primary apk
compilation.

The main difference is in the fact that for secondary dex files we
create the oat dir on the fly and execute dexoptanalyzer (the equivalent
of GetDexOptNeeded) to check if we really need to perform the
compilation.

Test: adb shell cmd package compile -f -m speed --secondary-dex com.google.android.gms
Bug: 32871170

Change-Id: I2c56d57322899968a338ccabffca575d66f8ee08
/frameworks/native/cmds/installd/utils.h
f3124d8fab2377d6b5ec2c7cbc775e2ab20df3ef 07-Sep-2016 Fyodor Kupolov <fkupolov@google.com> Remove from preloads/file_cache when clearing the cache

Test: pm trim-caches 50G internal
Bug: 31008665
Change-Id: If74f4d3c2d838ecb924aba84ad76293af34089bc
/frameworks/native/cmds/installd/utils.h
7bf5b9532e192e846be3a31f28171cdba0f3c830 19-Jan-2017 Jeff Sharkey <jsharkey@android.com> Measure external storage using new GIDs.

We just defined a new range of GIDs that will be used to mark per-app
data files stored on external storage, so start measuring them.

Also measure all OBB files using another new GID that was defined.

Note that we're relying on the per-app cache GIDs to track cache
usage on *both* internal and external storage, which means that stats
and extStats won't always add up. (The framework already combines
these values together, and we didn't want to waste precious GID
space on explicitly tracking cache files on external storage.)

Test: builds, boots
Bug: 27948817, 34263266
Change-Id: Ife087df299ff8ee1a75fce1e39b4b737cf9375d5
/frameworks/native/cmds/installd/utils.h
df2d754b38796e0c49c70e0a67f7d383e3079ff2 07-Jan-2017 Jeff Sharkey <jsharkey@android.com> Methods to calculate user and external disk usage.

Add method to calculate user disk usage, which will be faster than
making a Binder call for every single appId under a user. Add method
to calculate external disk usage, which uses file extensions to track
usage with "audio", "video", and "images" categories.

Add script to generate optimized file extension matcher logic.

Start measuring internal and external storage space separately; new
GIDs are coming in a future CL. Pass down all package names, inodes,
and code paths, since shared UIDs host more than one.

Test: builds, boots, stats are consistent
Bug: 27948817, 32206268
Change-Id: Icb9843ac5159e0e5f1503d9b64e0bcae407e1a5d
/frameworks/native/cmds/installd/utils.h
3dfae0c008576c873c4039bb4c2e54a6adf3720a 13-Dec-2016 Jeff Sharkey <jsharkey@android.com> Offer to measure disk stats using quotas.

Now we're getting somewhere! This CL starts using quotactl() to read
UID/GID quota statistics when called with FLAG_USE_QUOTA, otherwise
it continues using the old heavy-weight traversal for calculation.

We now set the recently defined per-app GID used for identifying
cached data, and we use the sticky GID bit on cache directories to
ensure that newly created data inherits the GID for tracking
purposes. For any existing apps during an upgrade, an initial
bootstrapping case will recursively set this new GID.

This change also shuffles around a bunch of the tedious manual
accounting logic so that we exactly match the new quota statistics.

Test: builds, boots, quota stats match manual stats
Bug: 27948817
Change-Id: I8512c3193ce698f197a3f446e625d6a1c74e7649
/frameworks/native/cmds/installd/utils.h
90aff26f0135379db19432ae90c40c0831ba5954 12-Dec-2016 Jeff Sharkey <jsharkey@android.com> Split all dexopt-related code into dexopt.cpp.

Only a few minor changes to return bool instead of binder::Status.

Test: builds, boots, apps install/uninstall fine
Change-Id: I538024c0e9da8ca2c0983a6e779c34bd40752053
/frameworks/native/cmds/installd/utils.h
423e746ac7d4b3a3d772dd0e01bdb9fd6029d439 10-Dec-2016 Jeff Sharkey <jsharkey@android.com> Return real error strings from installd.

Now that we've moved installd to Binder, we can return nice detailed
error strings explaining why a call failed. This is particularly
valuable when we record the error message into the PackageManager
persistent log, because up until now those errors were limited to
an unhelpful "installd returned -1" message.

Also perform uniform enforcement of all incoming package name and
UUID arguments.

Test: builds, boots, apps install/uninstall fine
Bug: 13758960, 30944031
Change-Id: Ic1f65ce8c10b1329e01d6a49d72cafa879c4d8bc
/frameworks/native/cmds/installd/utils.h
0274c977e3b10b52936fd5b2eb464857f0ca6358 06-Dec-2016 Jeff Sharkey <jsharkey@android.com> Shuffle installd Binder implementation around.

Instead of writing wrapper methods in InstalldNativeService.cpp,
this change shifts the Binder implementation over into the existing
commands.cpp file. This will let us migrate all methods over, and
then perform one final file rename to InstalldNativeService.cpp.

The downside of this approach is that we no longer have a giant kill
switch to quickly switch back.

Moves the moveCompleteApp() method over to Binder.

Test: builds, boots, apps install fine
Bug: 13758960, 30944031
Change-Id: I53550e05bc2b65155c3de18424f67b1a95450a6f
/frameworks/native/cmds/installd/utils.h
9a998f4762cb5ad71c786229be748ea0ab9eb7a0 15-Jul-2016 Jeff Sharkey <jsharkey@android.com> DO NOT MERGE. Record "cache" inodes to clear while CE is locked.

There are two situations where we need to clear cached data from
all users, including those whose CE storage might still be locked:

1. When PackageManager is clearing caches to try making room for
package updates.
2. When the device fingerprint changes, we need to clear code caches
for all apps.

To enable this, we now record the inode number of the "cache" and
"code_cache" directories in xattrs of the parent directory. This is
just enough information to find the cache directories to enable
deleting files inside. When preparing CE storage for an app, we now
create these two directories and immediately write the inode numbers.

Bug: 26056125
Change-Id: I7e442b0676a695acf962593469793a93b03c8aee
/frameworks/native/cmds/installd/utils.h
54e292e1ea87b504b552393d2e9bc800458bd0c1 11-May-2016 Jeff Sharkey <jsharkey@android.com> Search both CE/DE storage when clearing caches.

Now that we have two data storage locations, we need to scan them
both when freeing up disk space. Clean up logic to use new
get_known_users() API.

Bug: 26056125
Change-Id: Ic05c0022d6f5eb438967b69402b1900678f3858b
/frameworks/native/cmds/installd/utils.h
379a12b0072b322c7f86e690a8e8a220e500861c 15-Apr-2016 Jeff Sharkey <jsharkey@android.com> Consistent creation/destruction of user data.

Preparing and destroying users currently needs to be split across
installd, system_server, and vold, since no single party has all the
required SELinux permissions.

Start passing down flags so we only prepare/destroy storage areas
that have keys currently installed.

Add delete_dir_contents_and_dir() argument to ignore ENOENT, since
all we care about is the directory being gone.

Bug: 27896918
Change-Id: Ia1cccc9b35e6ff09e3ca50effeab676157b856e8
/frameworks/native/cmds/installd/utils.h
2f720f7ec5c9d0b91defc85878e7330b10f8e89a 11-Apr-2016 Jeff Sharkey <jsharkey@android.com> Use inode numbers for CE storage, fix sizes.

Certain operations, such as clearing/destroying app data, or just
counting on-disk size, require us to know the CE storage directory
of a particular app. To facilitate these operations, offer a method
to get the inode of a CE directory, and accept that inode number
for later operations.

In previous releases, we started installing apps using a new
directory-based layout, where all app code, unpacked native libraries,
and optimized code is bundled together. So now we only have a single
path to measure for code size.

Start measuring both CE and DE storage data usage for apps, and tweak
the reporting so that empty cache/data directories actually show up
as "0 bytes".

Fix bugs in disk usage counting, since st_blksize has no bearing on
the allocated disk space. Also don't double-count "." and ".."
directories when measuring storage.

Bug: 27828915, 27197819
Change-Id: I350b951f5c24165edb253ac663c9aae020c24dc9
/frameworks/native/cmds/installd/utils.h
b06f98aabc5381fd6366526d9b31b5d0345481b6 28-Mar-2016 Calin Juravle <calin@google.com> Don't report errors when trying to delete a non-existing profile dir

Also, put destroy_app_current_profiles behind FLAG_STORAGE_DE flag.

Bug: 27081617
Change-Id: Ib8b9ff292784c659259ceb4339b803e3580da7ed
/frameworks/native/cmds/installd/utils.h
6a1648e2f161cb1d7c46aa9d27e8062521a9f314 01-Feb-2016 Calin Juravle <calin@google.com> Extract profile files in their dedicated folder

Current profiles (the ones which have not been used for
compilation) are stored in /data/misc/profiles/cur/0/pkgname/.

Reference profiles (the merged of all user profiles, used for
compilation) are stored in /data/misc/profiles/ref/pkgname.

The profile analysis flow has been changed to use profman
before calling dex2oat. profman decides if there is a need
for compilation and does the merging.

Bug: 26719109
Bug: 26563023
Bug: 26881016

Change-Id: I5a86ed5fd07a28e2e580f9c108428527ba7993b6
/frameworks/native/cmds/installd/utils.h
e02657d627a85628ec6f0f398fb85283b8d91bfa 13-Jan-2016 Jeff Sharkey <jsharkey@android.com> Remove older migration code.

We used to offer to migrate pre-multi-user devices to the new
multi-user layout around JB, but the new layout has been the default
for many years now, so it's safe to remove this logic.

All core directory creation is now handled by init.rc where FBE
policies can be setup correctly, so we shouldn't be in the business
of doing system bootstrapping here.

Remove some lingering FBE debugging code.

Bug: 26466827
Change-Id: I1dfe9c8fc02b64013a5c45cea99bf8f61f7d1d5b
/frameworks/native/cmds/installd/utils.h
02d0de56c75347a0cb8d5a8565dc8c4ee7616057 12-Nov-2015 Andreas Gampe <agampe@google.com> Installd: Refactor in preparation for OTA

Refactor installd code so reuse with a few key plugin functions is
possible. Do a bit of code cleanup.

Bug: 25612095
Change-Id: I544604f0a391583a4c07887a8234343a3a255942
/frameworks/native/cmds/installd/utils.h