@@ -196,7 +196,7 @@ PackageSetting getPackageLPw(PackageParser.Package pkg, PackageSetting origPacka
196196 final String name = pkg .packageName ;
197197 PackageSetting p = getPackageLPw (name , origPackage , realName , sharedUser , codePath ,
198198 resourcePath , nativeLibraryPathString , pkg .mVersionCode , pkgFlags ,
199- user , add );
199+ user , add , true /* allowInstall */ );
200200 return p ;
201201 }
202202
@@ -358,7 +358,7 @@ void transferPermissionsLPw(String origPkg, String newPkg) {
358358 private PackageSetting getPackageLPw (String name , PackageSetting origPackage ,
359359 String realName , SharedUserSetting sharedUser , File codePath , File resourcePath ,
360360 String nativeLibraryPathString , int vc , int pkgFlags ,
361- UserHandle installUser , boolean add ) {
361+ UserHandle installUser , boolean add , boolean allowInstall ) {
362362 PackageSetting p = mPackages .get (name );
363363 if (p != null ) {
364364 if (!p .codePath .equals (codePath )) {
@@ -432,7 +432,7 @@ private PackageSetting getPackageLPw(String name, PackageSetting origPackage,
432432 Slog .i (PackageManagerService .TAG , "Stopping package " + name , e );
433433 }
434434 List <UserInfo > users = getAllUsers ();
435- if (users != null ) {
435+ if (users != null && allowInstall ) {
436436 for (UserInfo user : users ) {
437437 // By default we consider this app to be installed
438438 // for the user if no user has been specified (which
@@ -498,7 +498,7 @@ private PackageSetting getPackageLPw(String name, PackageSetting origPackage,
498498 addPackageSettingLPw (p , name , sharedUser );
499499 }
500500 } else {
501- if (installUser != null ) {
501+ if (installUser != null && allowInstall ) {
502502 // The caller has explicitly specified the user they want this
503503 // package installed for, and the package already exists.
504504 // Make sure it conforms to the new request.
@@ -1701,24 +1701,6 @@ boolean readLPw(List<UserInfo> users) {
17011701 Log .wtf (PackageManagerService .TAG , "Error reading package manager settings" , e );
17021702 }
17031703
1704- if (mBackupStoppedPackagesFilename .exists ()
1705- || mStoppedPackagesFilename .exists ()) {
1706- // Read old file
1707- readStoppedLPw ();
1708- mBackupStoppedPackagesFilename .delete ();
1709- mStoppedPackagesFilename .delete ();
1710- // Migrate to new file format
1711- writePackageRestrictionsLPr (0 );
1712- } else {
1713- if (users == null ) {
1714- readPackageRestrictionsLPr (0 );
1715- } else {
1716- for (UserInfo user : users ) {
1717- readPackageRestrictionsLPr (user .id );
1718- }
1719- }
1720- }
1721-
17221704 final int N = mPendingPackages .size ();
17231705 for (int i = 0 ; i < N ; i ++) {
17241706 final PendingPackage pp = mPendingPackages .get (i );
@@ -1727,7 +1709,7 @@ boolean readLPw(List<UserInfo> users) {
17271709 PackageSetting p = getPackageLPw (pp .name , null , pp .realName ,
17281710 (SharedUserSetting ) idObj , pp .codePath , pp .resourcePath ,
17291711 pp .nativeLibraryPathString , pp .versionCode , pp .pkgFlags ,
1730- UserHandle . ALL , true );
1712+ null , true /* add */ , false /* allowInstall */ );
17311713 if (p == null ) {
17321714 PackageManagerService .reportSettingsProblem (Log .WARN ,
17331715 "Unable to create application package for " + pp .name );
@@ -1748,6 +1730,24 @@ boolean readLPw(List<UserInfo> users) {
17481730 }
17491731 mPendingPackages .clear ();
17501732
1733+ if (mBackupStoppedPackagesFilename .exists ()
1734+ || mStoppedPackagesFilename .exists ()) {
1735+ // Read old file
1736+ readStoppedLPw ();
1737+ mBackupStoppedPackagesFilename .delete ();
1738+ mStoppedPackagesFilename .delete ();
1739+ // Migrate to new file format
1740+ writePackageRestrictionsLPr (0 );
1741+ } else {
1742+ if (users == null ) {
1743+ readPackageRestrictionsLPr (0 );
1744+ } else {
1745+ for (UserInfo user : users ) {
1746+ readPackageRestrictionsLPr (user .id );
1747+ }
1748+ }
1749+ }
1750+
17511751 /*
17521752 * Make sure all the updated system packages have their shared users
17531753 * associated with them.
0 commit comments