diff options
| -rw-r--r-- | cmds/installd/InstalldNativeService.cpp | 158 | ||||
| -rw-r--r-- | cmds/installd/InstalldNativeService.h | 3 | ||||
| -rw-r--r-- | cmds/installd/binder/android/os/IInstalld.aidl | 2 | ||||
| -rw-r--r-- | cmds/installd/utils.h | 1 | ||||
| -rw-r--r-- | libs/nativewindow/AHardwareBuffer.cpp | 8 | ||||
| -rw-r--r-- | libs/nativewindow/include/android/hardware_buffer.h | 6 | ||||
| -rw-r--r-- | services/surfaceflinger/SurfaceFlinger.cpp | 6 |
7 files changed, 105 insertions, 79 deletions
diff --git a/cmds/installd/InstalldNativeService.cpp b/cmds/installd/InstalldNativeService.cpp index 989fcdaea6..70acb073a2 100644 --- a/cmds/installd/InstalldNativeService.cpp +++ b/cmds/installd/InstalldNativeService.cpp @@ -1122,65 +1122,81 @@ static void collectQuotaStats(const std::string& device, int32_t userId, struct dqblk dq; - uid_t uid = multiuser_get_uid(userId, appId); - if (quotactl(QCMD(Q_GETQUOTA, USRQUOTA), device.c_str(), uid, - reinterpret_cast<char*>(&dq)) != 0) { - if (errno != ESRCH) { - PLOG(ERROR) << "Failed to quotactl " << device << " for UID " << uid; - } - } else { -#if MEASURE_DEBUG - LOG(DEBUG) << "quotactl() for UID " << uid << " " << dq.dqb_curspace; -#endif - stats->dataSize += dq.dqb_curspace; - } - - int cacheGid = multiuser_get_cache_gid(userId, appId); - if (cacheGid != -1) { - if (quotactl(QCMD(Q_GETQUOTA, GRPQUOTA), device.c_str(), cacheGid, + if (stats != nullptr) { + uid_t uid = multiuser_get_uid(userId, appId); + if (quotactl(QCMD(Q_GETQUOTA, USRQUOTA), device.c_str(), uid, reinterpret_cast<char*>(&dq)) != 0) { if (errno != ESRCH) { - PLOG(ERROR) << "Failed to quotactl " << device << " for GID " << cacheGid; + PLOG(ERROR) << "Failed to quotactl " << device << " for UID " << uid; } } else { #if MEASURE_DEBUG - LOG(DEBUG) << "quotactl() for GID " << cacheGid << " " << dq.dqb_curspace; + LOG(DEBUG) << "quotactl() for UID " << uid << " " << dq.dqb_curspace; #endif - stats->cacheSize += dq.dqb_curspace; + stats->dataSize += dq.dqb_curspace; } - } -#if HACK_FOR_37193650 - extStats->dataSize = extStats->dataSize; -#else - int extGid = multiuser_get_ext_gid(userId, appId); - if (extGid != -1) { - if (quotactl(QCMD(Q_GETQUOTA, GRPQUOTA), device.c_str(), extGid, - reinterpret_cast<char*>(&dq)) != 0) { - if (errno != ESRCH) { - PLOG(ERROR) << "Failed to quotactl " << device << " for GID " << extGid; + int cacheGid = multiuser_get_cache_gid(userId, appId); + if (cacheGid != -1) { + if (quotactl(QCMD(Q_GETQUOTA, GRPQUOTA), device.c_str(), cacheGid, + reinterpret_cast<char*>(&dq)) != 0) { + if (errno != ESRCH) { + PLOG(ERROR) << "Failed to quotactl " << device << " for GID " << cacheGid; + } + } else { +#if MEASURE_DEBUG + LOG(DEBUG) << "quotactl() for GID " << cacheGid << " " << dq.dqb_curspace; +#endif + stats->cacheSize += dq.dqb_curspace; } - } else { + } + + int sharedGid = multiuser_get_shared_gid(0, appId); + if (sharedGid != -1) { + if (quotactl(QCMD(Q_GETQUOTA, GRPQUOTA), device.c_str(), sharedGid, + reinterpret_cast<char*>(&dq)) != 0) { + if (errno != ESRCH) { + PLOG(ERROR) << "Failed to quotactl " << device << " for GID " << sharedGid; + } + } else { #if MEASURE_DEBUG - LOG(DEBUG) << "quotactl() for GID " << extGid << " " << dq.dqb_curspace; + LOG(DEBUG) << "quotactl() for GID " << sharedGid << " " << dq.dqb_curspace; #endif - extStats->dataSize += dq.dqb_curspace; + stats->codeSize += dq.dqb_curspace; + } } } -#endif - int sharedGid = multiuser_get_shared_gid(userId, appId); - if (sharedGid != -1) { - if (quotactl(QCMD(Q_GETQUOTA, GRPQUOTA), device.c_str(), sharedGid, - reinterpret_cast<char*>(&dq)) != 0) { - if (errno != ESRCH) { - PLOG(ERROR) << "Failed to quotactl " << device << " for GID " << sharedGid; + if (extStats != nullptr) { + int extGid = multiuser_get_ext_gid(userId, appId); + if (extGid != -1) { + if (quotactl(QCMD(Q_GETQUOTA, GRPQUOTA), device.c_str(), extGid, + reinterpret_cast<char*>(&dq)) != 0) { + if (errno != ESRCH) { + PLOG(ERROR) << "Failed to quotactl " << device << " for GID " << extGid; + } + } else { +#if MEASURE_DEBUG + LOG(DEBUG) << "quotactl() for GID " << extGid << " " << dq.dqb_curspace; +#endif + extStats->dataSize += dq.dqb_curspace; } - } else { + } + + int extCacheGid = multiuser_get_ext_cache_gid(userId, appId); + if (extCacheGid != -1) { + if (quotactl(QCMD(Q_GETQUOTA, GRPQUOTA), device.c_str(), extCacheGid, + reinterpret_cast<char*>(&dq)) != 0) { + if (errno != ESRCH) { + PLOG(ERROR) << "Failed to quotactl " << device << " for GID " << extCacheGid; + } + } else { #if MEASURE_DEBUG - LOG(DEBUG) << "quotactl() for GID " << sharedGid << " " << dq.dqb_curspace; + LOG(DEBUG) << "quotactl() for GID " << extCacheGid << " " << dq.dqb_curspace; #endif - stats->codeSize += dq.dqb_curspace; + extStats->dataSize += dq.dqb_curspace; + extStats->cacheSize += dq.dqb_curspace; + } } } } @@ -1256,9 +1272,10 @@ static void collectManualStatsForUser(const std::string& path, struct stats* sta if (fstatat(dfd, name, &s, AT_SYMLINK_NOFOLLOW) != 0) { continue; } + int32_t user_uid = multiuser_get_app_id(s.st_uid); if (!strcmp(name, ".") || !strcmp(name, "..")) { continue; - } else if (exclude_apps && (s.st_uid >= AID_APP_START && s.st_uid <= AID_APP_END)) { + } else if (exclude_apps && (user_uid >= AID_APP_START && user_uid <= AID_APP_END)) { continue; } else { collectManualStats(StringPrintf("%s/%s", path.c_str(), name), stats); @@ -1357,25 +1374,13 @@ binder::Status InstalldNativeService::getAppSize(const std::unique_ptr<std::stri ATRACE_BEGIN("code"); for (auto codePath : codePaths) { calculate_tree_size(codePath, &stats.codeSize, -1, - multiuser_get_shared_gid(userId, appId)); + multiuser_get_shared_gid(0, appId)); } ATRACE_END(); ATRACE_BEGIN("quota"); collectQuotaStats(device, userId, appId, &stats, &extStats); ATRACE_END(); - -#if HACK_FOR_37193650 - ATRACE_BEGIN("external"); - for (size_t i = 0; i < packageNames.size(); i++) { - const char* pkgname = packageNames[i].c_str(); - auto extPath = create_data_media_package_path(uuid_, userId, "data", pkgname); - calculate_tree_size(extPath, &extStats.dataSize); - auto mediaPath = create_data_media_package_path(uuid_, userId, "media", pkgname); - calculate_tree_size(mediaPath, &extStats.dataSize); - } - ATRACE_END(); -#endif } else { ATRACE_BEGIN("code"); for (auto codePath : codePaths) { @@ -1414,7 +1419,7 @@ binder::Status InstalldNativeService::getAppSize(const std::unique_ptr<std::stri if (!uuid) { ATRACE_BEGIN("dalvik"); - int32_t sharedGid = multiuser_get_shared_gid(userId, appId); + int32_t sharedGid = multiuser_get_shared_gid(0, appId); if (sharedGid != -1) { calculate_tree_size(create_data_dalvik_cache_path(), &stats.codeSize, sharedGid, -1); @@ -1464,12 +1469,6 @@ binder::Status InstalldNativeService::getUserSize(const std::unique_ptr<std::str flags &= ~FLAG_USE_QUOTA; } -#if HACK_FOR_37193650 - if (userId != 0) { - flags &= ~FLAG_USE_QUOTA; - } -#endif - if (flags & FLAG_USE_QUOTA) { struct dqblk dq; @@ -1532,6 +1531,7 @@ binder::Status InstalldNativeService::getUserSize(const std::unique_ptr<std::str } ATRACE_BEGIN("quota"); + int64_t dataSize = extStats.dataSize; for (auto appId : appIds) { if (appId >= AID_APP_START) { collectQuotaStats(device, userId, appId, &stats, &extStats); @@ -1542,6 +1542,7 @@ binder::Status InstalldNativeService::getUserSize(const std::unique_ptr<std::str #endif } } + extStats.dataSize = dataSize; ATRACE_END(); } else { ATRACE_BEGIN("obb"); @@ -1601,7 +1602,8 @@ binder::Status InstalldNativeService::getUserSize(const std::unique_ptr<std::str } binder::Status InstalldNativeService::getExternalSize(const std::unique_ptr<std::string>& uuid, - int32_t userId, int32_t flags, std::vector<int64_t>* _aidl_return) { + int32_t userId, int32_t flags, const std::vector<int32_t>& appIds, + std::vector<int64_t>* _aidl_return) { ENFORCE_UID(AID_SYSTEM); CHECK_ARGUMENT_UUID(uuid); // NOTE: Locking is relaxed on this method, since it's limited to @@ -1620,6 +1622,7 @@ binder::Status InstalldNativeService::getExternalSize(const std::unique_ptr<std: int64_t audioSize = 0; int64_t videoSize = 0; int64_t imageSize = 0; + int64_t appSize = 0; auto device = findQuotaDeviceForUuid(uuid); if (device.empty()) { @@ -1629,6 +1632,7 @@ binder::Status InstalldNativeService::getExternalSize(const std::unique_ptr<std: if (flags & FLAG_USE_QUOTA) { struct dqblk dq; + ATRACE_BEGIN("quota"); uid_t uid = multiuser_get_uid(userId, AID_MEDIA_RW); if (quotactl(QCMD(Q_GETQUOTA, USRQUOTA), device.c_str(), uid, reinterpret_cast<char*>(&dq)) != 0) { @@ -1637,7 +1641,7 @@ binder::Status InstalldNativeService::getExternalSize(const std::unique_ptr<std: } } else { #if MEASURE_DEBUG - LOG(DEBUG) << "quotactl() for UID " << uid << " " << dq.dqb_curspace; + LOG(DEBUG) << "quotactl() for UID " << uid << " " << dq.dqb_curspace; #endif totalSize = dq.dqb_curspace; } @@ -1646,7 +1650,7 @@ binder::Status InstalldNativeService::getExternalSize(const std::unique_ptr<std: if (quotactl(QCMD(Q_GETQUOTA, GRPQUOTA), device.c_str(), audioGid, reinterpret_cast<char*>(&dq)) == 0) { #if MEASURE_DEBUG - LOG(DEBUG) << "quotactl() for GID " << audioGid << " " << dq.dqb_curspace; + LOG(DEBUG) << "quotactl() for GID " << audioGid << " " << dq.dqb_curspace; #endif audioSize = dq.dqb_curspace; } @@ -1654,7 +1658,7 @@ binder::Status InstalldNativeService::getExternalSize(const std::unique_ptr<std: if (quotactl(QCMD(Q_GETQUOTA, GRPQUOTA), device.c_str(), videoGid, reinterpret_cast<char*>(&dq)) == 0) { #if MEASURE_DEBUG - LOG(DEBUG) << "quotactl() for GID " << videoGid << " " << dq.dqb_curspace; + LOG(DEBUG) << "quotactl() for GID " << videoGid << " " << dq.dqb_curspace; #endif videoSize = dq.dqb_curspace; } @@ -1662,11 +1666,24 @@ binder::Status InstalldNativeService::getExternalSize(const std::unique_ptr<std: if (quotactl(QCMD(Q_GETQUOTA, GRPQUOTA), device.c_str(), imageGid, reinterpret_cast<char*>(&dq)) == 0) { #if MEASURE_DEBUG - LOG(DEBUG) << "quotactl() for GID " << imageGid << " " << dq.dqb_curspace; + LOG(DEBUG) << "quotactl() for GID " << imageGid << " " << dq.dqb_curspace; #endif imageSize = dq.dqb_curspace; } + ATRACE_END(); + + ATRACE_BEGIN("apps"); + struct stats extStats; + memset(&extStats, 0, sizeof(extStats)); + for (auto appId : appIds) { + if (appId >= AID_APP_START) { + collectQuotaStats(device, userId, appId, nullptr, &extStats); + } + } + appSize = extStats.dataSize + extStats.cacheSize; + ATRACE_END(); } else { + ATRACE_BEGIN("manual"); FTS *fts; FTSENT *p; auto path = create_data_media_path(uuid_, userId); @@ -1700,11 +1717,15 @@ binder::Status InstalldNativeService::getExternalSize(const std::unique_ptr<std: case FTS_DEFAULT: case FTS_SL: case FTS_SLNONE: + if (p->fts_parent->fts_number == 1) { + appSize += size; + } totalSize += size; break; } } fts_close(fts); + ATRACE_END(); } std::vector<int64_t> ret; @@ -1712,6 +1733,7 @@ binder::Status InstalldNativeService::getExternalSize(const std::unique_ptr<std: ret.push_back(audioSize); ret.push_back(videoSize); ret.push_back(imageSize); + ret.push_back(appSize); #if MEASURE_DEBUG LOG(DEBUG) << "Final result " << toString(ret); #endif diff --git a/cmds/installd/InstalldNativeService.h b/cmds/installd/InstalldNativeService.h index fe8aa14703..7f73c2ae15 100644 --- a/cmds/installd/InstalldNativeService.h +++ b/cmds/installd/InstalldNativeService.h @@ -68,7 +68,8 @@ public: int32_t userId, int32_t flags, const std::vector<int32_t>& appIds, std::vector<int64_t>* _aidl_return); binder::Status getExternalSize(const std::unique_ptr<std::string>& uuid, - int32_t userId, int32_t flags, std::vector<int64_t>* _aidl_return); + int32_t userId, int32_t flags, const std::vector<int32_t>& appIds, + std::vector<int64_t>* _aidl_return); binder::Status setAppQuota(const std::unique_ptr<std::string>& uuid, int32_t userId, int32_t appId, int64_t cacheQuota); diff --git a/cmds/installd/binder/android/os/IInstalld.aidl b/cmds/installd/binder/android/os/IInstalld.aidl index e738b810d8..6b99c1dbf9 100644 --- a/cmds/installd/binder/android/os/IInstalld.aidl +++ b/cmds/installd/binder/android/os/IInstalld.aidl @@ -38,7 +38,7 @@ interface IInstalld { int userId, int flags, int appId, in long[] ceDataInodes, in @utf8InCpp String[] codePaths); long[] getUserSize(@nullable @utf8InCpp String uuid, int userId, int flags, in int[] appIds); - long[] getExternalSize(@nullable @utf8InCpp String uuid, int userId, int flags); + long[] getExternalSize(@nullable @utf8InCpp String uuid, int userId, int flags, in int[] appIds); void setAppQuota(@nullable @utf8InCpp String uuid, int userId, int appId, long cacheQuota); diff --git a/cmds/installd/utils.h b/cmds/installd/utils.h index 5db547e441..dd94da9e31 100644 --- a/cmds/installd/utils.h +++ b/cmds/installd/utils.h @@ -32,7 +32,6 @@ #define MEASURE_DEBUG 0 #define FIXUP_DEBUG 0 -#define HACK_FOR_37193650 1 namespace android { namespace installd { diff --git a/libs/nativewindow/AHardwareBuffer.cpp b/libs/nativewindow/AHardwareBuffer.cpp index 35b76c7095..cf028dd568 100644 --- a/libs/nativewindow/AHardwareBuffer.cpp +++ b/libs/nativewindow/AHardwareBuffer.cpp @@ -358,8 +358,8 @@ uint32_t AHardwareBuffer_convertFromPixelFormat(uint32_t format) { case HAL_PIXEL_FORMAT_RGBX_8888: return AHARDWAREBUFFER_FORMAT_R8G8B8X8_UNORM; case HAL_PIXEL_FORMAT_RGB_565: return AHARDWAREBUFFER_FORMAT_R5G6B5_UNORM; case HAL_PIXEL_FORMAT_RGB_888: return AHARDWAREBUFFER_FORMAT_R8G8B8_UNORM; - case HAL_PIXEL_FORMAT_RGBA_FP16: return AHARDWAREBUFFER_FORMAT_R16G16B16A16_SFLOAT; - case HAL_PIXEL_FORMAT_RGBA_1010102: return AHARDWAREBUFFER_FORMAT_A2R10G10B10_UNORM_PACK32; + case HAL_PIXEL_FORMAT_RGBA_FP16: return AHARDWAREBUFFER_FORMAT_R16G16B16A16_FLOAT; + case HAL_PIXEL_FORMAT_RGBA_1010102: return AHARDWAREBUFFER_FORMAT_R10G10B10A2_UNORM; case HAL_PIXEL_FORMAT_BLOB: return AHARDWAREBUFFER_FORMAT_BLOB; default:ALOGE("Unknown pixel format %u", format); return 0; @@ -372,8 +372,8 @@ uint32_t AHardwareBuffer_convertToPixelFormat(uint32_t format) { case AHARDWAREBUFFER_FORMAT_R8G8B8X8_UNORM: return HAL_PIXEL_FORMAT_RGBX_8888; case AHARDWAREBUFFER_FORMAT_R5G6B5_UNORM: return HAL_PIXEL_FORMAT_RGB_565; case AHARDWAREBUFFER_FORMAT_R8G8B8_UNORM: return HAL_PIXEL_FORMAT_RGB_888; - case AHARDWAREBUFFER_FORMAT_R16G16B16A16_SFLOAT: return HAL_PIXEL_FORMAT_RGBA_FP16; - case AHARDWAREBUFFER_FORMAT_A2R10G10B10_UNORM_PACK32: return HAL_PIXEL_FORMAT_RGBA_1010102; + case AHARDWAREBUFFER_FORMAT_R16G16B16A16_FLOAT: return HAL_PIXEL_FORMAT_RGBA_FP16; + case AHARDWAREBUFFER_FORMAT_R10G10B10A2_UNORM: return HAL_PIXEL_FORMAT_RGBA_1010102; case AHARDWAREBUFFER_FORMAT_BLOB: return HAL_PIXEL_FORMAT_BLOB; default:ALOGE("Unknown AHardwareBuffer format %u", format); return 0; diff --git a/libs/nativewindow/include/android/hardware_buffer.h b/libs/nativewindow/include/android/hardware_buffer.h index 02838d4102..f5657ffe29 100644 --- a/libs/nativewindow/include/android/hardware_buffer.h +++ b/libs/nativewindow/include/android/hardware_buffer.h @@ -66,14 +66,14 @@ enum { * Vulkan: VK_FORMAT_R16G16B16A16_SFLOAT * OpenGL ES: GL_RGBA16F */ - AHARDWAREBUFFER_FORMAT_R16G16B16A16_SFLOAT = 0x16, + AHARDWAREBUFFER_FORMAT_R16G16B16A16_FLOAT = 0x16, /** * Corresponding formats: - * Vulkan: VK_FORMAT_A2R10G10B10_UNORM_PACK32 + * Vulkan: VK_FORMAT_A2B10G10R10_UNORM_PACK32 * OpenGL ES: GL_RGB10_A2 */ - AHARDWAREBUFFER_FORMAT_A2R10G10B10_UNORM_PACK32 = 0x2b, + AHARDWAREBUFFER_FORMAT_R10G10B10A2_UNORM = 0x2b, /** * An opaque binary blob format that must have height 1, with width equal to diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index 746d3d9913..9cd1214be6 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -2371,6 +2371,7 @@ bool SurfaceFlinger::handlePageFlip() bool visibleRegions = false; bool frameQueued = false; + bool newDataLatched = false; // Store the set of layers that need updates. This set must not change as // buffers are being latched, as this could result in a deadlock. @@ -2398,6 +2399,9 @@ bool SurfaceFlinger::handlePageFlip() const Region dirty(layer->latchBuffer(visibleRegions, latchTime)); layer->useSurfaceDamage(); invalidateLayerStack(layer->getLayerStack(), dirty); + if (!dirty.isEmpty()) { + newDataLatched = true; + } } mVisibleRegionsDirty |= visibleRegions; @@ -2410,7 +2414,7 @@ bool SurfaceFlinger::handlePageFlip() } // Only continue with the refresh if there is actually new work to do - return !mLayersWithQueuedFrames.empty(); + return !mLayersWithQueuedFrames.empty() && newDataLatched; } void SurfaceFlinger::invalidateHwcGeometry() |