@@ -6523,8 +6523,9 @@ class AsecInstallArgs extends InstallArgs {
65236523 setCachePath (subStr1 );
65246524 }
65256525
6526- AsecInstallArgs (String cid ) {
6527- super (null , null , isAsecExternal (cid ) ? PackageManager .INSTALL_EXTERNAL : 0 , null , null );
6526+ AsecInstallArgs (String cid , boolean isForwardLocked ) {
6527+ super (null , null , (isAsecExternal (cid ) ? PackageManager .INSTALL_EXTERNAL : 0 )
6528+ | (isForwardLocked ? PackageManager .INSTALL_FORWARD_LOCK : 0 ), null , null );
65286529 this .cid = cid ;
65296530 setCachePath (PackageHelper .getSdDir (cid ));
65306531 }
@@ -6730,11 +6731,7 @@ boolean matchContainer(String app) {
67306731 }
67316732
67326733 String getPackageName () {
6733- int idx = cid .lastIndexOf ("-" );
6734- if (idx == -1 ) {
6735- return cid ;
6736- }
6737- return cid .substring (0 , idx );
6734+ return getAsecPackageName (cid );
67386735 }
67396736
67406737 boolean doPostDeleteLI (boolean delete ) {
@@ -6765,7 +6762,6 @@ int doPreCopy() {
67656762 @ Override
67666763 int doPostCopy (int uid ) {
67676764 if (isFwdLocked ()) {
6768- PackageHelper .fixSdPermissions (cid , uid , RES_FILE_NAME );
67696765 if (uid < Process .FIRST_APPLICATION_UID
67706766 || !PackageHelper .fixSdPermissions (cid , uid , RES_FILE_NAME )) {
67716767 Slog .e (TAG , "Failed to finalize " + cid );
@@ -6778,6 +6774,14 @@ int doPostCopy(int uid) {
67786774 }
67796775 };
67806776
6777+ static String getAsecPackageName (String packageCid ) {
6778+ int idx = packageCid .lastIndexOf ("-" );
6779+ if (idx == -1 ) {
6780+ return packageCid ;
6781+ }
6782+ return packageCid .substring (0 , idx );
6783+ }
6784+
67816785 // Utility method used to create code paths based on package name and available index.
67826786 private static String getNextCodePath (String oldCodePath , String prefix , String suffix ) {
67836787 String idxStr = "" ;
@@ -8699,10 +8703,9 @@ private void updateExternalMediaStatusInner(boolean isMounted, boolean reportSta
86998703 // reader
87008704 synchronized (mPackages ) {
87018705 for (String cid : list ) {
8702- AsecInstallArgs args = new AsecInstallArgs (cid );
87038706 if (DEBUG_SD_INSTALL )
87048707 Log .i (TAG , "Processing container " + cid );
8705- String pkgName = args . getPackageName ( );
8708+ String pkgName = getAsecPackageName ( cid );
87068709 if (pkgName == null ) {
87078710 if (DEBUG_SD_INSTALL )
87088711 Log .i (TAG , "Container : " + cid + " stale" );
@@ -8711,24 +8714,31 @@ private void updateExternalMediaStatusInner(boolean isMounted, boolean reportSta
87118714 }
87128715 if (DEBUG_SD_INSTALL )
87138716 Log .i (TAG , "Looking for pkg : " + pkgName );
8714- PackageSetting ps = mSettings .mPackages .get (pkgName );
8717+
8718+ final PackageSetting ps = mSettings .mPackages .get (pkgName );
8719+ if (ps == null ) {
8720+ Log .i (TAG , "Deleting container with no matching settings " + cid );
8721+ removeCids .add (cid );
8722+ continue ;
8723+ }
8724+
8725+ final AsecInstallArgs args = new AsecInstallArgs (cid , isForwardLocked (ps ));
87158726 // The package status is changed only if the code path
87168727 // matches between settings and the container id.
8717- if (ps != null && ps .codePathString != null
8718- && ps .codePathString .equals (args .getCodePath ())) {
8719- if (DEBUG_SD_INSTALL )
8728+ if (ps .codePathString != null && ps .codePathString .equals (args .getCodePath ())) {
8729+ if (DEBUG_SD_INSTALL ) {
87208730 Log .i (TAG , "Container : " + cid + " corresponds to pkg : " + pkgName
87218731 + " at code path: " + ps .codePathString );
8732+ }
8733+
87228734 // We do have a valid package installed on sdcard
87238735 processCids .put (args , ps .codePathString );
8724- int uid = ps .appId ;
8736+ final int uid = ps .appId ;
87258737 if (uid != -1 ) {
87268738 uidList [num ++] = uid ;
87278739 }
87288740 } else {
8729- // Stale container on sdcard. Just delete
8730- if (DEBUG_SD_INSTALL )
8731- Log .i (TAG , "Container : " + cid + " stale" );
8741+ Log .i (TAG , "Deleting stale container for " + cid );
87328742 removeCids .add (cid );
87338743 }
87348744 }
@@ -8812,6 +8822,9 @@ private void loadMediaPackages(HashMap<AsecInstallArgs, String> processCids, int
88128822 if (args .isExternal ()) {
88138823 parseFlags |= PackageParser .PARSE_ON_SDCARD ;
88148824 }
8825+ if (args .isFwdLocked ()) {
8826+ parseFlags |= PackageParser .PARSE_FORWARD_LOCK ;
8827+ }
88158828
88168829 doGc = true ;
88178830 synchronized (mInstallLock ) {
0 commit comments