Merge "Only allow one movePackage operation in-flight" into gingerbread
This commit is contained in:
@ -609,6 +609,16 @@ public abstract class PackageManager {
|
|||||||
*/
|
*/
|
||||||
public static final int MOVE_FAILED_INTERNAL_ERROR = -6;
|
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
|
* Flag parameter for {@link #movePackage} to indicate that
|
||||||
* the package should be moved to internal storage if its
|
* the package should be moved to internal storage if its
|
||||||
|
@ -2791,7 +2791,10 @@ public class PackageParser {
|
|||||||
|
|
||||||
// Additional data supplied by callers.
|
// Additional data supplied by callers.
|
||||||
public Object mExtras;
|
public Object mExtras;
|
||||||
|
|
||||||
|
// Whether an operation is currently pending on this package
|
||||||
|
public boolean mOperationPending;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Applications hardware preferences
|
* Applications hardware preferences
|
||||||
*/
|
*/
|
||||||
|
@ -7202,6 +7202,9 @@ class PackageManagerService extends IPackageManager.Stub {
|
|||||||
pw.print(" pkgFlags=0x"); pw.print(Integer.toHexString(ps.pkgFlags));
|
pw.print(" pkgFlags=0x"); pw.print(Integer.toHexString(ps.pkgFlags));
|
||||||
pw.print(" installStatus="); pw.print(ps.installStatus);
|
pw.print(" installStatus="); pw.print(ps.installStatus);
|
||||||
pw.print(" enabled="); pw.println(ps.enabled);
|
pw.print(" enabled="); pw.println(ps.enabled);
|
||||||
|
if (ps.pkg.mOperationPending) {
|
||||||
|
pw.println(" mOperationPending=true");
|
||||||
|
}
|
||||||
if (ps.disabledComponents.size() > 0) {
|
if (ps.disabledComponents.size() > 0) {
|
||||||
pw.println(" disabledComponents:");
|
pw.println(" disabledComponents:");
|
||||||
for (String s : ps.disabledComponents) {
|
for (String s : ps.disabledComponents) {
|
||||||
@ -9889,6 +9892,9 @@ class PackageManagerService extends IPackageManager.Stub {
|
|||||||
(pkg.applicationInfo.flags & ApplicationInfo.FLAG_FORWARD_LOCK) != 0) {
|
(pkg.applicationInfo.flags & ApplicationInfo.FLAG_FORWARD_LOCK) != 0) {
|
||||||
Slog.w(TAG, "Cannot move forward locked app.");
|
Slog.w(TAG, "Cannot move forward locked app.");
|
||||||
returnCode = PackageManager.MOVE_FAILED_FORWARD_LOCKED;
|
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 {
|
} else {
|
||||||
// Find install location first
|
// Find install location first
|
||||||
if ((flags & PackageManager.MOVE_EXTERNAL_MEDIA) != 0 &&
|
if ((flags & PackageManager.MOVE_EXTERNAL_MEDIA) != 0 &&
|
||||||
@ -9905,6 +9911,9 @@ class PackageManagerService extends IPackageManager.Stub {
|
|||||||
returnCode = PackageManager.MOVE_FAILED_INVALID_LOCATION;
|
returnCode = PackageManager.MOVE_FAILED_INVALID_LOCATION;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (returnCode == PackageManager.MOVE_SUCCEEDED) {
|
||||||
|
pkg.mOperationPending = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (returnCode != PackageManager.MOVE_SUCCEEDED) {
|
if (returnCode != PackageManager.MOVE_SUCCEEDED) {
|
||||||
@ -10017,6 +10026,18 @@ class PackageManagerService extends IPackageManager.Stub {
|
|||||||
mp.srcArgs.doPostDeleteLI(true);
|
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;
|
IPackageMoveObserver observer = mp.observer;
|
||||||
if (observer != null) {
|
if (observer != null) {
|
||||||
try {
|
try {
|
||||||
|
Reference in New Issue
Block a user