@@ -3623,21 +3623,19 @@ private int cachePackageSharedLibsForAbiLI(PackageParser.Package pkg,
36233623
36243624 installedNativeLibraries = true ;
36253625
3626+ // Always extract the shared library
36263627 String sharedLibraryFilePath = sharedLibraryDir .getPath () +
36273628 File .separator + libFileName ;
36283629 File sharedLibraryFile = new File (sharedLibraryFilePath );
3629- if (! sharedLibraryFile .exists () ||
3630- sharedLibraryFile .length () != entry .getSize () ||
3631- sharedLibraryFile .lastModified () != entry .getTime ()) {
3632- if (Config .LOGD ) {
3633- Log .d (TAG , "Caching shared lib " + entry .getName ());
3634- }
3635- if (mInstaller == null ) {
3636- sharedLibraryDir .mkdir ();
3637- }
3638- cacheNativeBinaryLI (pkg , zipFile , entry , sharedLibraryDir ,
3639- sharedLibraryFile );
3630+
3631+ if (Config .LOGD ) {
3632+ Log .d (TAG , "Caching shared lib " + entry .getName ());
36403633 }
3634+ if (mInstaller == null ) {
3635+ sharedLibraryDir .mkdir ();
3636+ }
3637+ cacheNativeBinaryLI (pkg , zipFile , entry , sharedLibraryDir ,
3638+ sharedLibraryFile );
36413639 }
36423640 if (!hasNativeLibraries )
36433641 return PACKAGE_INSTALL_NATIVE_NO_LIBRARIES ;
@@ -3679,18 +3677,16 @@ private int cachePackageGdbServerLI(PackageParser.Package pkg,
36793677 String installGdbServerPath = installGdbServerDir .getPath () +
36803678 "/" + GDBSERVER ;
36813679 File installGdbServerFile = new File (installGdbServerPath );
3682- if (! installGdbServerFile .exists () ||
3683- installGdbServerFile .length () != entry .getSize () ||
3684- installGdbServerFile .lastModified () != entry .getTime ()) {
3685- if (Config .LOGD ) {
3686- Log .d (TAG , "Caching gdbserver " + entry .getName ());
3687- }
3688- if (mInstaller == null ) {
3689- installGdbServerDir .mkdir ();
3690- }
3691- cacheNativeBinaryLI (pkg , zipFile , entry , installGdbServerDir ,
3692- installGdbServerFile );
3680+
3681+ if (Config .LOGD ) {
3682+ Log .d (TAG , "Caching gdbserver " + entry .getName ());
3683+ }
3684+ if (mInstaller == null ) {
3685+ installGdbServerDir .mkdir ();
36933686 }
3687+ cacheNativeBinaryLI (pkg , zipFile , entry , installGdbServerDir ,
3688+ installGdbServerFile );
3689+
36943690 return PACKAGE_INSTALL_NATIVE_FOUND_LIBRARIES ;
36953691 }
36963692 return PACKAGE_INSTALL_NATIVE_NO_LIBRARIES ;
@@ -3704,6 +3700,16 @@ private int cachePackageGdbServerLI(PackageParser.Package pkg,
37043700 // one if ro.product.cpu.abi2 is defined.
37053701 //
37063702 private int cachePackageSharedLibsLI (PackageParser .Package pkg , File scanFile ) {
3703+ // Remove all native binaries from a directory. This is used when upgrading
3704+ // a package: in case the new .apk doesn't contain a native binary that was
3705+ // in the old one (and thus installed), we need to remove it from
3706+ // /data/data/<appname>/lib
3707+ //
3708+ // The simplest way to do that is to remove all files in this directory,
3709+ // since it is owned by "system", applications are not supposed to write
3710+ // anything there.
3711+ removeNativeBinariesLI (pkg );
3712+
37073713 String cpuAbi = Build .CPU_ABI ;
37083714 try {
37093715 int result = cachePackageSharedLibsForAbiLI (pkg , scanFile , cpuAbi );
0 commit comments