Kick movement preconditions onto handler thread.
The bulk of package moving already occurs on the handler thread, but one of the precondition steps requires that we make an installd call to calculate disk space of the app. If there was already another long-running installd call going on, we could end up ANR'ing the caller. Since movePackage() is already designed to return a moveId and go async, we can push all the precondition steps onto the handler thread to prevent the ANR. Bug: 25490003 Change-Id: I62d555c23bbf81b791f6f4cabc40c3d64c580cf8
This commit is contained in:
@@ -15986,13 +15986,18 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
mContext.enforceCallingOrSelfPermission(android.Manifest.permission.MOVE_PACKAGE, null);
|
||||
|
||||
final int moveId = mNextMoveId.getAndIncrement();
|
||||
try {
|
||||
movePackageInternal(packageName, volumeUuid, moveId);
|
||||
} catch (PackageManagerException e) {
|
||||
Slog.w(TAG, "Failed to move " + packageName, e);
|
||||
mMoveCallbacks.notifyStatusChanged(moveId,
|
||||
PackageManager.MOVE_FAILED_INTERNAL_ERROR);
|
||||
}
|
||||
mHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
movePackageInternal(packageName, volumeUuid, moveId);
|
||||
} catch (PackageManagerException e) {
|
||||
Slog.w(TAG, "Failed to move " + packageName, e);
|
||||
mMoveCallbacks.notifyStatusChanged(moveId,
|
||||
PackageManager.MOVE_FAILED_INTERNAL_ERROR);
|
||||
}
|
||||
}
|
||||
});
|
||||
return moveId;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user