Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c5183aca authored by Kenny Root's avatar Kenny Root Committed by Android Git Automerger
Browse files

am c68bcc32: Merge "Only allow one movePackage operation in-flight" into gingerbread

Merge commit 'c68bcc32' into gingerbread-plus-aosp

* commit 'c68bcc32':
  Only allow one movePackage operation in-flight
parents acc4e683 c68bcc32
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -609,6 +609,16 @@ public abstract class PackageManager {
     */
    public static final int MOVE_FAILED_INTERNAL_ERROR = -6;

    /**
     * Error code that is passed to the {@link IPackageMoveObserver} by
     * {@link #movePackage(android.net.Uri, IPackageMoveObserver)} if the
     * specified package already has an operation pending in the
     * {@link PackageHandler} queue.
     * 
     * @hide
     */
    public static final int MOVE_FAILED_OPERATION_PENDING = -7;

    /**
     * Flag parameter for {@link #movePackage} to indicate that
     * the package should be moved to internal storage if its
+4 −1
Original line number Diff line number Diff line
@@ -2792,6 +2792,9 @@ public class PackageParser {
        // Additional data supplied by callers.
        public Object mExtras;

        // Whether an operation is currently pending on this package
        public boolean mOperationPending;

        /*
         *  Applications hardware preferences
         */
+21 −0
Original line number Diff line number Diff line
@@ -7202,6 +7202,9 @@ class PackageManagerService extends IPackageManager.Stub {
                    pw.print("    pkgFlags=0x"); pw.print(Integer.toHexString(ps.pkgFlags));
                            pw.print(" installStatus="); pw.print(ps.installStatus);
                            pw.print(" enabled="); pw.println(ps.enabled);
                    if (ps.pkg.mOperationPending) {
                        pw.println("    mOperationPending=true");
                    }
                    if (ps.disabledComponents.size() > 0) {
                        pw.println("    disabledComponents:");
                        for (String s : ps.disabledComponents) {
@@ -9889,6 +9892,9 @@ class PackageManagerService extends IPackageManager.Stub {
                       (pkg.applicationInfo.flags & ApplicationInfo.FLAG_FORWARD_LOCK) != 0) {
                   Slog.w(TAG, "Cannot move forward locked app.");
                   returnCode = PackageManager.MOVE_FAILED_FORWARD_LOCKED;
               } else if (pkg.mOperationPending) {
                   Slog.w(TAG, "Attempt to move package which has pending operations");
                   returnCode = PackageManager.MOVE_FAILED_OPERATION_PENDING;
               } else {
                   // Find install location first
                   if ((flags & PackageManager.MOVE_EXTERNAL_MEDIA) != 0 &&
@@ -9905,6 +9911,9 @@ class PackageManagerService extends IPackageManager.Stub {
                           returnCode = PackageManager.MOVE_FAILED_INVALID_LOCATION;
                       }
                   }
                   if (returnCode == PackageManager.MOVE_SUCCEEDED) {
                       pkg.mOperationPending = true;
                   }
               }
           }
           if (returnCode != PackageManager.MOVE_SUCCEEDED) {
@@ -10017,6 +10026,18 @@ class PackageManagerService extends IPackageManager.Stub {
                       mp.srcArgs.doPostDeleteLI(true);
                   }
               }

               // Allow more operations on this file if we didn't fail because
               // an operation was already pending for this package.
               if (returnCode != PackageManager.MOVE_FAILED_OPERATION_PENDING) {
                   synchronized (mPackages) {
                       PackageParser.Package pkg = mPackages.get(mp.packageName);
                       if (pkg != null) {
                           pkg.mOperationPending = false;
                       }
                   }
               }

               IPackageMoveObserver observer = mp.observer;
               if (observer != null) {
                   try {