am 2bd8e97f: Merge "Fix race condition in PackageManager." into mnc-dev

* commit '2bd8e97f996bba0b52ed213f4feb4f367fe019c2':
  Fix race condition in PackageManager.
This commit is contained in:
oleksii stepanian
2015-06-22 20:28:07 +00:00
committed by Android Git Automerger

View File

@@ -871,7 +871,7 @@ public class PackageManagerService extends IPackageManager.Stub {
public void onServiceDisconnected(ComponentName name) {
if (DEBUG_SD_INSTALL) Log.i(TAG, "onServiceDisconnected");
}
};
}
// Recordkeeping of restore-after-install operations that are currently in flight
// between the Package Manager and the Backup Manager
@@ -883,7 +883,8 @@ public class PackageManagerService extends IPackageManager.Stub {
args = _a;
res = _r;
}
};
}
final SparseArray<PostInstallData> mRunningInstalls = new SparseArray<PostInstallData>();
int mNextInstallToken = 1; // nonzero; will be wrapped back to 1 when ++ overflows
@@ -1109,13 +1110,18 @@ public class PackageManagerService extends IPackageManager.Stub {
mContainerService = (IMediaContainerService) msg.obj;
}
if (mContainerService == null) {
// Something seriously wrong. Bail out
Slog.e(TAG, "Cannot bind to media container service");
for (HandlerParams params : mPendingInstalls) {
// Indicate service bind error
params.serviceError();
if (!mBound) {
// Something seriously wrong since we are not bound and we are not
// waiting for connection. Bail out.
Slog.e(TAG, "Cannot bind to media container service");
for (HandlerParams params : mPendingInstalls) {
// Indicate service bind error
params.serviceError();
}
mPendingInstalls.clear();
} else {
Slog.w(TAG, "Waiting to connect to media container service");
}
mPendingInstalls.clear();
} else if (mPendingInstalls.size() > 0) {
HandlerParams params = mPendingInstalls.get(0);
if (params != null) {