@@ -447,6 +447,16 @@ int get_size(const char *pkgname, int persona, const char *apkpath,
447447 }
448448 }
449449
450+ /* add in size of any libraries */
451+ if (!create_pkg_path_in_dir (path , & android_app_lib_dir , pkgname , PKG_DIR_POSTFIX )) {
452+ d = opendir (path );
453+ if (d != NULL ) {
454+ dfd = dirfd (d );
455+ codesize += calculate_dir_size (dfd );
456+ closedir (d );
457+ }
458+ }
459+
450460 /* compute asec size if it is given
451461 */
452462 if (asecpath != NULL && asecpath [0 ] != '!' ) {
@@ -474,21 +484,33 @@ int get_size(const char *pkgname, int persona, const char *apkpath,
474484
475485 if (de -> d_type == DT_DIR ) {
476486 int subfd ;
487+ int64_t statsize = 0 ;
488+ int64_t dirsize = 0 ;
477489 /* always skip "." and ".." */
478490 if (name [0 ] == '.' ) {
479491 if (name [1 ] == 0 ) continue ;
480492 if ((name [1 ] == '.' ) && (name [2 ] == 0 )) continue ;
481493 }
494+ if (fstatat (dfd , name , & s , AT_SYMLINK_NOFOLLOW ) == 0 ) {
495+ statsize = stat_size (& s );
496+ }
482497 subfd = openat (dfd , name , O_RDONLY | O_DIRECTORY );
483498 if (subfd >= 0 ) {
484- int64_t size = calculate_dir_size (subfd );
485- if (!strcmp (name ,"lib" )) {
486- codesize += size ;
487- } else if (!strcmp (name ,"cache" )) {
488- cachesize += size ;
489- } else {
490- datasize += size ;
491- }
499+ dirsize = calculate_dir_size (subfd );
500+ }
501+ if (!strcmp (name ,"lib" )) {
502+ codesize += dirsize + statsize ;
503+ } else if (!strcmp (name ,"cache" )) {
504+ cachesize += dirsize + statsize ;
505+ } else {
506+ datasize += dirsize + statsize ;
507+ }
508+ } else if (de -> d_type == DT_LNK && !strcmp (name ,"lib" )) {
509+ // This is the symbolic link to the application's library
510+ // code. We'll count this as code instead of data, since
511+ // it is not something that the app creates.
512+ if (fstatat (dfd , name , & s , AT_SYMLINK_NOFOLLOW ) == 0 ) {
513+ codesize += stat_size (& s );
492514 }
493515 } else {
494516 if (fstatat (dfd , name , & s , AT_SYMLINK_NOFOLLOW ) == 0 ) {
0 commit comments