Merge "Fix for Binder one-way deadlock." into rvc-dev am: 24c1e39726 am: ab5beb2a17

Change-Id: Iac8fad10017a6adb4a96d041b8a8f3ce267479df
This commit is contained in:
TreeHugger Robot
2020-04-27 23:08:29 +00:00
committed by Automerger Merge Worker
2 changed files with 24 additions and 16 deletions

View File

@@ -163,6 +163,7 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
private static final int MSG_STREAM_VALIDATE_AND_COMMIT = 1; private static final int MSG_STREAM_VALIDATE_AND_COMMIT = 1;
private static final int MSG_INSTALL = 2; private static final int MSG_INSTALL = 2;
private static final int MSG_ON_PACKAGE_INSTALLED = 3; private static final int MSG_ON_PACKAGE_INSTALLED = 3;
private static final int MSG_SESSION_VERIFICATION_FAILURE = 4;
/** XML constants used for persisting a session */ /** XML constants used for persisting a session */
static final String TAG_SESSION = "session"; static final String TAG_SESSION = "session";
@@ -449,6 +450,11 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
packageName, returnCode, message, extras); packageName, returnCode, message, extras);
break; break;
case MSG_SESSION_VERIFICATION_FAILURE:
final int error = msg.arg1;
final String detailMessage = (String) msg.obj;
onSessionVerificationFailure(error, detailMessage);
break;
} }
return true; return true;
@@ -1479,12 +1485,15 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
} }
private PackageManagerException onSessionVerificationFailure(PackageManagerException e) { private PackageManagerException onSessionVerificationFailure(PackageManagerException e) {
onSessionVerificationFailure(e.error, ExceptionUtils.getCompleteMessage(e));
return e;
}
private void onSessionVerificationFailure(int error, String detailMessage) {
// Session is sealed but could not be verified, we need to destroy it. // Session is sealed but could not be verified, we need to destroy it.
destroyInternal(); destroyInternal();
// Dispatch message to remove session from PackageInstallerService. // Dispatch message to remove session from PackageInstallerService.
dispatchSessionFinished(e.error, ExceptionUtils.getCompleteMessage(e), null); dispatchSessionFinished(error, detailMessage, null);
return e;
} }
private void onDataLoaderUnrecoverable() { private void onDataLoaderUnrecoverable() {
@@ -2629,9 +2638,8 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
IDataLoader dataLoader = dataLoaderManager.getDataLoader(dataLoaderId); IDataLoader dataLoader = dataLoaderManager.getDataLoader(dataLoaderId);
if (dataLoader == null) { if (dataLoader == null) {
mDataLoaderFinished = true; mDataLoaderFinished = true;
onSessionVerificationFailure( dispatchSessionVerificationFailure(INSTALL_FAILED_MEDIA_UNAVAILABLE,
new PackageManagerException(INSTALL_FAILED_MEDIA_UNAVAILABLE, "Failure to obtain data loader");
"Failure to obtain data loader"));
return; return;
} }
@@ -2676,9 +2684,8 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
} }
case IDataLoaderStatusListener.DATA_LOADER_IMAGE_NOT_READY: { case IDataLoaderStatusListener.DATA_LOADER_IMAGE_NOT_READY: {
mDataLoaderFinished = true; mDataLoaderFinished = true;
onSessionVerificationFailure( dispatchSessionVerificationFailure(INSTALL_FAILED_MEDIA_UNAVAILABLE,
new PackageManagerException(INSTALL_FAILED_MEDIA_UNAVAILABLE, "Failed to prepare image.");
"Failed to prepare image."));
if (manualStartAndDestroy) { if (manualStartAndDestroy) {
dataLoader.destroy(dataLoaderId); dataLoader.destroy(dataLoaderId);
} }
@@ -2686,9 +2693,8 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
} }
case IDataLoaderStatusListener.DATA_LOADER_UNRECOVERABLE: case IDataLoaderStatusListener.DATA_LOADER_UNRECOVERABLE:
mDataLoaderFinished = true; mDataLoaderFinished = true;
onSessionVerificationFailure( dispatchSessionVerificationFailure(INSTALL_FAILED_MEDIA_UNAVAILABLE,
new PackageManagerException(INSTALL_FAILED_MEDIA_UNAVAILABLE, "DataLoader reported unrecoverable failure.");
"DataLoader reported unrecoverable failure."));
return; return;
} }
} catch (RemoteException e) { } catch (RemoteException e) {
@@ -2720,6 +2726,11 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
return false; return false;
} }
private void dispatchSessionVerificationFailure(int error, String detailMessage) {
mHandler.obtainMessage(MSG_SESSION_VERIFICATION_FAILURE, error, -1,
detailMessage).sendToTarget();
}
@Override @Override
public int[] getChildSessionIds() { public int[] getChildSessionIds() {
final int[] childSessionIds = mChildSessionIds.copyKeys(); final int[] childSessionIds = mChildSessionIds.copyKeys();

View File

@@ -761,10 +761,7 @@ int IncrementalService::unbind(StorageId storage, std::string_view target) {
std::unique_lock l2(ifs->lock); std::unique_lock l2(ifs->lock);
if (ifs->bindPoints.size() <= 1) { if (ifs->bindPoints.size() <= 1) {
ifs->bindPoints.clear(); ifs->bindPoints.clear();
std::thread([this, ifs, l2 = std::move(l2)]() mutable { deleteStorageLocked(*ifs, std::move(l2));
mJni->initializeForCurrentThread();
deleteStorageLocked(*ifs, std::move(l2));
}).detach();
} else { } else {
const std::string savedFile = std::move(bindIt->second.savedFilename); const std::string savedFile = std::move(bindIt->second.savedFilename);
ifs->bindPoints.erase(bindIt); ifs->bindPoints.erase(bindIt);