Fix two bugs in external storage accounting.
When doing a manual tree walk, we always want to inherit fts_number
from the parent fts node.
For create_data_media_package_path(), two of the arguments had been
swapped.
Test: cts-tradefed run commandAndExit cts-dev -m CtsAppSecurityHostTestCases -t android.appsecurity.cts.StorageHostTest
Bug: 27948817, 30927649
Change-Id: Ic3cbf387cf119aa82af6e380bde9d9b069f6bfb0
diff --git a/cmds/installd/InstalldNativeService.cpp b/cmds/installd/InstalldNativeService.cpp
index 914eaae..cdef7e1 100644
--- a/cmds/installd/InstalldNativeService.cpp
+++ b/cmds/installd/InstalldNativeService.cpp
@@ -1184,6 +1184,7 @@
return;
}
while ((p = fts_read(fts)) != NULL) {
+ p->fts_number = p->fts_parent->fts_number;
switch (p->fts_info) {
case FTS_D:
if (p->fts_level == 4
@@ -1192,7 +1193,6 @@
&& !strcmp(p->fts_parent->fts_parent->fts_parent->fts_name, "Android")) {
p->fts_number = 1;
}
- p->fts_number = p->fts_parent->fts_number;
// Fall through to count the directory
case FTS_DEFAULT:
case FTS_F:
@@ -1296,9 +1296,9 @@
ATRACE_END();
ATRACE_BEGIN("external");
- auto extPath = create_data_media_package_path(uuid_, userId, pkgname, "data");
+ auto extPath = create_data_media_package_path(uuid_, userId, "data", pkgname);
collectManualStats(extPath, &extStats);
- auto mediaPath = create_data_media_package_path(uuid_, userId, pkgname, "media");
+ auto mediaPath = create_data_media_package_path(uuid_, userId, "media", pkgname);
calculate_tree_size(mediaPath, &extStats.dataSize);
ATRACE_END();
}