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

* commit '0acee36bd8b5b5fdb36ef0b80ebe7e736041cecd':
  Fix race condition in PackageManager.
This commit is contained in:
oleksii stepanian
2015-06-22 20:41:21 +00:00
committed by Android Git Automerger

View File

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