History log of /frameworks/native/cmds/installd/utils.cpp
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
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.cpp
623912183d8314595b37cdedc7c193a21c345bdb 03-Apr-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "We really want f_frsize." into oc-dev
a836c472f017f09cf16fa68176df461a4958d22a 03-Apr-2017 Jeff Sharkey <jsharkey@android.com> We really want f_frsize.

It's confusing, but f_bsize is not the value you're looking for; the
real block size is f_frsize. Fix all those bugs.

Test: builds, boots
Bug: 36840579
Change-Id: I2846b8998c27f3e9a71dbf573a0a22158215a3bd
/frameworks/native/cmds/installd/utils.cpp
e59c85cc0e78bfcc8fec6acc8e37e6a472ffc07f 03-Apr-2017 Jeff Sharkey <jsharkey@android.com> Define upper-bound disk quotas for all apps.

Abusive or broken apps can go crazy and try allocating all of the
disk space on the device. To mitigate the impact on system health,
set hard limits to block any given app from using more than 90% of
disk blocks, or 50% of disk inodes.

Also define the hard limit for AID_MEDIA_RW to avoid filling up the
device via the SD card.

Kick QUOTAON when scanning devices, since ext4 doesn't toggle
DQUOT_LIMITS_ENABLED during initial mount.

Test: cts-tradefed run commandAndExit cts-dev -m CtsAppSecurityHostTestCases -t android.appsecurity.cts.StorageHostTest
Test: cts-tradefed run commandAndExit cts-dev -m CtsOsTestCases -t android.os.cts.EnvironmentTest#testSaneInodes
Bug: 36450358
Change-Id: Iaa2bc6a2f0bc9047ee54c1d1a49bbda92142457a
/frameworks/native/cmds/installd/utils.cpp
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.cpp
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.cpp
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.cpp
2c5d1a85898f9178b0a1130b7f36ea3031361133 12-Mar-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Finer-grained locking for size operations."
b26786d647b624498c11405075e5223d1853f30a 12-Mar-2017 Jeff Sharkey <jsharkey@android.com> Finer-grained locking for size operations.

Disk space measurements are read-only and don't perform mutations,
so other installd operations shouldn't block them.

If there's an ongoing parallel operation (such as a dexopt) that
could race and skew the results, that's no different than an actively
running app changing it's disk usage during the measurement.

This change also allows measurements to happen in parallel, so we can
no longer rely on getcwd() being stable, which means all fts(3) users
now need to use FTS_NOCHDIR.

Bug: 36032444, 35706513
Test: runtest -x frameworks/base/services/tests/servicestests/src/com/android/server/pm/InstallerTest.java
Change-Id: I67d303d3ecce148052d41444cef67381b1d34ab0
/frameworks/native/cmds/installd/utils.cpp
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.cpp
2ee8cc08caf6c45c8550896b54387c7a42339d0f 08-Mar-2017 Jeff Sharkey <jsharkey@android.com> Allow "android" package name.

Test: /data/nativetest64/installd_utils_test/installd_utils_test
Bug: 36062649

(cherry picked from commit ab7ac8d5a04bd3f38b85ce20ae5bb382f2a26585)

Change-Id: I20d546fdd20813e96bcb5f061ca5b352dff44450
/frameworks/native/cmds/installd/utils.cpp
068ef2229e5493b2678b00ff875df486b561e00d 08-Mar-2017 Jeff Sharkey <jsharkey@android.com> Update is_valid_package_name() to match framework.

The framework has a new format for /data/app directory names in OC
to protect user privacy. This change updates the validation logic
in installd to support the new format.

For consistency the logic now mirrors the package name validation
logic used by PackageParser.

Test: /data/nativetest64/installd_utils_test/installd_utils_test
Bug: 33705143

(cherry picked from commit 367ace2f77105f7a09b34a50bc875fd4fa591177)

Merged-In: I41d270942479c52e063c29a2cb9552d7b238b86e
Change-Id: I15363803fb45310697e29be810e800dc1b1902d0
/frameworks/native/cmds/installd/utils.cpp
ab7ac8d5a04bd3f38b85ce20ae5bb382f2a26585 08-Mar-2017 Jeff Sharkey <jsharkey@android.com> Allow "android" package name.

Test: /data/nativetest64/installd_utils_test/installd_utils_test
Bug: 36062649
Change-Id: I9b41a34822a1a194d256f5b99d5955e51716029c
/frameworks/native/cmds/installd/utils.cpp
110c3baf58aeef284f08a85d730898aaeb65c8ba 08-Mar-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Update is_valid_package_name() to match framework."
367ace2f77105f7a09b34a50bc875fd4fa591177 08-Mar-2017 Jeff Sharkey <jsharkey@android.com> Update is_valid_package_name() to match framework.

The framework has a new format for /data/app directory names in OC
to protect user privacy. This change updates the validation logic
in installd to support the new format.

For consistency the logic now mirrors the package name validation
logic used by PackageParser.

Test: /data/nativetest64/installd_utils_test/installd_utils_test
Bug: 33705143
Change-Id: I41d270942479c52e063c29a2cb9552d7b238b86e
/frameworks/native/cmds/installd/utils.cpp
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.cpp
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.cpp
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.cpp
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.cpp
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.cpp
7823e124e00576e20e47ec717cbe8bc89f0f2bf2 29-Sep-2016 Mark Salyzyn <salyzyn@google.com> Replace cutils/log.h and rationalize log/log.h and android/log.h

- cutils/log.h treat as deprecated and lead by example
- android/log.h to be used instead of log/log.h if possible
- add system includes that are assumed as side effects
- define LOG_TAG first

Test: compile
Bug: 31289077
Bug: 30465923
Change-Id: I8d99b24c333578c9b5aa9f2a01324bd0bba268dd
/frameworks/native/cmds/installd/utils.cpp
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.cpp
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.cpp
a5e161b1207ef447a51e99856097d69d4a6111e1 29-Sep-2016 Mark Salyzyn <salyzyn@google.com> Replace cutils/log.h and rationalize log/log.h and android/log.h

- cutils/log.h treat as deprecated and lead by example
- android/log.h to be used instead of log/log.h if required
- add system includes that are assumed as side effects of log.h
- modules that use SLOG should use SLOG for all logging (installd)
- define LOG_TAG first
- remove logging infrastructure if not used

Test: build
Bug: 31289077
Change-Id: Iea147a0104c7ab7f12451304131d6500f42141e7
/frameworks/native/cmds/installd/utils.cpp
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.cpp
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.cpp
4ed6507cfb4f0fae8567b42037e74a07f7dd28ba 22-Jul-2016 Jeff Sharkey <jsharkey@android.com> DO NOT MERGE. Ignore setxattr() failures on tmpfs.

Bug: 30210614
Change-Id: Ic9dfb2439b4b1056e1a58552be2e84f4e524321e
/frameworks/native/cmds/installd/utils.cpp
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.cpp
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.cpp
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.cpp
1d992f9f7886f98e46f98430d6c1d061cc31fdb3 13-Apr-2016 Jeff Sharkey <jsharkey@android.com> Build target path before closedir().

Otherwise ent->d_name could be cleared out, and we'd aim at the
top-level data directory, which has disastrous results when clearing
app data.

Bug: 28155330
Change-Id: Icf7df835d76816dfbe2894fdae708033df983825
/frameworks/native/cmds/installd/utils.cpp
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.cpp
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.cpp
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.cpp
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.cpp
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.cpp
32717f851ec39e44b43dcd2053b091daff5e1753 07-Dec-2015 Todd Kennedy <toddke@google.com> Merge "Create new ephemeral app directory"
c7b8a11974f0bf0b13f47b9fb40059b1c50ec9b6 05-Dec-2015 Elliott Hughes <enh@google.com> Merge "Track rename from base/ to android-base/." am: f31cf3ab0f am: c21980bc12
am: 803823f8b6

* commit '803823f8b6663578922be595755351a9e710d93c':
Track rename from base/ to android-base/.
e4ec9eb7b4c452493589983970ba5ccc501728d1 05-Dec-2015 Elliott Hughes <enh@google.com> Track rename from base/ to android-base/.

Change-Id: I62c18891ffe319d20ff084f5ca2aa0c038c23cd3
/frameworks/native/cmds/installd/utils.cpp
5c1a910e6a2d2c42002dc6ed88ff770336afcb3f 24-Nov-2015 Todd Kennedy <toddke@google.com> Create new ephemeral app directory

Bug: 25119046
Change-Id: I829f7ae1df09f2b7af1cd64fbbad6c1f5a2d716d
/frameworks/native/cmds/installd/utils.cpp
ebf728fd43ab5c7d11a1f9e5fdc775d6740fae0a 18-Nov-2015 Jeff Sharkey <jsharkey@android.com> More device-encrypted directory work.

Unify package directory creation logic, and always create user_de
directories to be ready for emulation mode. Also clean up the new
user_de directories on user deletion, package uninstallation, and
data clearing. Also run restorecon over the new user_de paths.

Bug: 22358539
Change-Id: I65ab1562db8455dae6e99dbd8965409b1bf3c6b0
/frameworks/native/cmds/installd/utils.cpp
f24aae872d79982899fed4911141b05c874b0c50 18-Nov-2015 Calin Juravle <calin@google.com> Merge "Remove obsolete profile handling from installd." am: 8161da7a0e am: a51f45a601
am: 357cb908fa

* commit '357cb908faa88b915c1d2c977f16e533e855f19f':
Remove obsolete profile handling from installd.
63ec2d64196144b2d15d2baffedccfa011d6494f 09-Nov-2015 Jeff Sharkey <jsharkey@android.com> Create device-encrypted directories for apps.

When device has FBE, create device-encrypted storage location when
installing apps.

Also remove "renamepkg" unused command.

Bug: 22358539
Change-Id: Ic56eeecdc64bdaa7429b93426727a243a4e45f47
/frameworks/native/cmds/installd/utils.cpp
df9dadd5e5c287110d837c38aaec12bcf5e5d151 04-Nov-2015 Calin Juravle <calin@google.com> Remove obsolete profile handling from installd.

Bug: 24698874
Bug: 17173268
Change-Id: I140d70262f8f8fa7afd52c3cf63b4abaf401a479
/frameworks/native/cmds/installd/utils.cpp
592e6282cd722ba8075239db85a2707e53f3d3f7 10-Aug-2015 Nick Kralevich <nnk@google.com> am 0e3234b7: am 1efe1bdd: Merge "More O_DIRECTORY | O_NOFOLLOW changes"

* commit '0e3234b7f11048d8291d5427cc0acfb77ba6b843':
More O_DIRECTORY | O_NOFOLLOW changes
2379e15da458aa9aac09c1834eb893540d522ac2 10-Aug-2015 Nick Kralevich <nnk@google.com> am 0e3234b7: am 1efe1bdd: Merge "More O_DIRECTORY | O_NOFOLLOW changes"

* commit '0e3234b7f11048d8291d5427cc0acfb77ba6b843':
More O_DIRECTORY | O_NOFOLLOW changes
8b7acacc93930df9fa9e1ebea4a4394195b2332e 10-Aug-2015 Nick Kralevich <nnk@google.com> More O_DIRECTORY | O_NOFOLLOW changes

Fix a few other spots where we're not using O_NOFOLLOW
with O_DIRECTORY.

Add O_CLOEXEC for good measure.

https://code.google.com/p/android/issues/detail?id=181945

Bug: 23044050
Change-Id: Ib535cbba29cdd587443ea9e1e75831f57fd7a93c
/frameworks/native/cmds/installd/utils.cpp
e34de3a77b5f4d408af3f812b304475e858246ec 10-Aug-2015 Nick Kralevich <nnk@google.com> am c45bad1d: am a1b2eaa2: Merge "installd _delete_dir_contents: add O_NOFOLLOW"

* commit 'c45bad1dc14a7af1e72ad3585b3b057c38fcec3f':
installd _delete_dir_contents: add O_NOFOLLOW
6611bd6489b9efd3bc41c13aea71387891cef300 10-Aug-2015 Nick Kralevich <nnk@google.com> am c45bad1d: am a1b2eaa2: Merge "installd _delete_dir_contents: add O_NOFOLLOW"

* commit 'c45bad1dc14a7af1e72ad3585b3b057c38fcec3f':
installd _delete_dir_contents: add O_NOFOLLOW
7fd646708c4248b0ee2bb35176b58b298a7b8ae0 10-Aug-2015 Nick Kralevich <nnk@google.com> installd _delete_dir_contents: add O_NOFOLLOW

Add O_NOFOLLOW to make sure we're not following symlinks.

https://code.google.com/p/android/issues/detail?id=181945

Bug: 23044050
Change-Id: I3408309fd401aefb6ebecb2a052bba198eed7633
/frameworks/native/cmds/installd/utils.cpp
d845c96128a40ca5802c0840ae190fa0af7d4735 04-Jun-2015 Narayan Kamath <narayan@google.com> Add an installd command to link files

Given a pair of absolute paths {from_path, to_path} , check that
they are both valid apk subpaths (eg. /data/app/package/foo) and
link(2) to_path to from_path. This is required by staged installs,
where we link existing apks and oat files to their staging location.

bug: 20889739
Change-Id: I3b5e3b43677af68be59308121a4409caaa6a72f0
/frameworks/native/cmds/installd/utils.cpp
d792118c493806eeb24a8203f508e6e18fe93bd7 01-May-2015 Jeff Sharkey <jsharkey@android.com> Offer to move both code and data together.

We now move code under /data/app/com.example when a complete move
is requested. This really only works for new cluster-style installs
that also have native libraries and OAT contained inside.

Teach measuring code about cluster-style installs when measuring
app footprint. Also offer to measure private data space for all
users.

Bug: 19993667, 20275578
Change-Id: I6df7b947cb5cc8a4552f56f4b64a661e8512389f
/frameworks/native/cmds/installd/utils.cpp
e36372423000a906bafae68844ebc6c42d09335a 09-Apr-2015 Jeff Sharkey <jsharkey@android.com> Command to move private app data between volumes.

New "mvuserdata" command will move all private app data from one
volume UUID to another. It leverages the existing "cp" toybox
command to do the heavy lifting for all known users, preserving
details like timestamps and permissions. It invokes restorecon()
to correctly label the new location when the copy is finished.

Changes installd to no longer drop capabilities, so we run as root
again. This also allows us to exec "cp" with CAP_DAC_OVERRIDE and
CAP_FOWNER still in effect.

Bug: 19993667
Change-Id: I1f407a7c4a1af97ca5afc27b04eb16b4936cbdef
/frameworks/native/cmds/installd/utils.cpp
41ea424413c0381ef2aa15fc5bd5d4b88abd23c4 09-Apr-2015 Jeff Sharkey <jsharkey@android.com> More volume UUID awareness.

Teach free_cache() and restorecon_data() about building per-volume
paths. Also clean up restorecon_data() by using std::string when
building paths.

Clearer names for path building utility methods, and tests to verify.

Bug: 19993667
Change-Id: Iacfbcdaa5b901cc2490bc8eba366dfdeb44f1d93
/frameworks/native/cmds/installd/utils.cpp
c03de09173f98506e73e7cf7df21fe11795d4b24 08-Apr-2015 Jeff Sharkey <jsharkey@android.com> Plumb through volume UUID when building paths.

Since app data paths can live on expanded storage devices, accept the
target volume UUID when building paths. The null UUID indicates the
default internal storage.

To improve readability, start using std::string in several places,
which throws when allocations fail. For now, perform last-second
sanity checks on incoming path arguments, but we'll eventually want
to check arguments as they come through installd.cpp, instead of
crashing the entire daemon.

Also remove "lib" symlink code from install() and make_user_data(),
since we're no longer supporting /data/app-lib. The framework
already uses linklib() to create the right symlink for the selected
ISA-specific library dir.

Bug: 19993667
Change-Id: Ib9343575ffb62bf3981e19375de8f3822fc31e28
/frameworks/native/cmds/installd/utils.cpp
19803807cd7ae01868fcfa50305f4a7dd13765e2 07-Apr-2015 Jeff Sharkey <jsharkey@android.com> Switch installd to compile as C++.

This is the minimal change needed to switch it over to C++, which
paves the way for using more robust utilities like std::string.

Change-Id: I80ed6280146875eb6ddbbb340c05450388ca13f0
/frameworks/native/cmds/installd/utils.cpp