Merge "Removing race condition accessing shared binder object." into rvc-dev am: 1d6e6bfe96 am: 92a23de26f am: 592fe5d0ef

Change-Id: I7676b2fe1159427d8d5a7f39aded0a8e18a6b2b6
This commit is contained in:
Yurii Zubrytskyi
2020-03-18 20:18:01 +00:00
committed by Automerger Merge Worker
6 changed files with 31 additions and 31 deletions

View File

@@ -29,9 +29,9 @@ oneway interface IDataLoader {
void create(int id, in DataLoaderParamsParcel params, void create(int id, in DataLoaderParamsParcel params,
in FileSystemControlParcel control, in FileSystemControlParcel control,
IDataLoaderStatusListener listener); IDataLoaderStatusListener listener);
void start(); void start(int id);
void stop(); void stop(int id);
void destroy(); void destroy(int id);
void prepareImage(in InstallationFileParcel[] addedFiles, in @utf8InCpp String[] removedFiles); void prepareImage(int id, in InstallationFileParcel[] addedFiles, in @utf8InCpp String[] removedFiles);
} }

View File

@@ -102,21 +102,18 @@ public abstract class DataLoaderService extends Service {
} }
private class DataLoaderBinderService extends IDataLoader.Stub { private class DataLoaderBinderService extends IDataLoader.Stub {
private int mId;
@Override @Override
public void create(int id, @NonNull DataLoaderParamsParcel params, public void create(int id, @NonNull DataLoaderParamsParcel params,
@NonNull FileSystemControlParcel control, @NonNull FileSystemControlParcel control,
@NonNull IDataLoaderStatusListener listener) @NonNull IDataLoaderStatusListener listener)
throws RuntimeException { throws RuntimeException {
mId = id;
try { try {
if (!nativeCreateDataLoader(id, control, params, listener)) { if (!nativeCreateDataLoader(id, control, params, listener)) {
Slog.e(TAG, "Failed to create native loader for " + mId); Slog.e(TAG, "Failed to create native loader for " + id);
} }
} catch (Exception ex) { } catch (Exception ex) {
Slog.e(TAG, "Failed to create native loader for " + mId, ex); Slog.e(TAG, "Failed to create native loader for " + id, ex);
destroy(); destroy(id);
throw new RuntimeException(ex); throw new RuntimeException(ex);
} finally { } finally {
// Closing FDs. // Closing FDs.
@@ -150,30 +147,31 @@ public abstract class DataLoaderService extends Service {
} }
@Override @Override
public void start() { public void start(int id) {
if (!nativeStartDataLoader(mId)) { if (!nativeStartDataLoader(id)) {
Slog.e(TAG, "Failed to start loader: " + mId); Slog.e(TAG, "Failed to start loader: " + id);
} }
} }
@Override @Override
public void stop() { public void stop(int id) {
if (!nativeStopDataLoader(mId)) { if (!nativeStopDataLoader(id)) {
Slog.w(TAG, "Failed to stop loader: " + mId); Slog.w(TAG, "Failed to stop loader: " + id);
} }
} }
@Override @Override
public void destroy() { public void destroy(int id) {
if (!nativeDestroyDataLoader(mId)) { if (!nativeDestroyDataLoader(id)) {
Slog.w(TAG, "Failed to destroy loader: " + mId); Slog.w(TAG, "Failed to destroy loader: " + id);
} }
} }
@Override @Override
public void prepareImage(InstallationFileParcel[] addedFiles, String[] removedFiles) { public void prepareImage(int id, InstallationFileParcel[] addedFiles,
if (!nativePrepareImage(mId, addedFiles, removedFiles)) { String[] removedFiles) {
Slog.w(TAG, "Failed to prepare image for data loader: " + mId); if (!nativePrepareImage(id, addedFiles, removedFiles)) {
Slog.w(TAG, "Failed to prepare image for data loader: " + id);
} }
} }
} }

View File

@@ -213,7 +213,7 @@ public class DataLoaderManagerService extends SystemService {
void destroy() { void destroy() {
try { try {
mDataLoader.destroy(); mDataLoader.destroy(mId);
} catch (RemoteException ignored) { } catch (RemoteException ignored) {
} }
mContext.unbindService(this); mContext.unbindService(this);

View File

@@ -2583,12 +2583,13 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
if (manualStartAndDestroy) { if (manualStartAndDestroy) {
// IncrementalFileStorages will call start after all files are // IncrementalFileStorages will call start after all files are
// created in IncFS. // created in IncFS.
dataLoader.start(); dataLoader.start(dataLoaderId);
} }
break; break;
} }
case IDataLoaderStatusListener.DATA_LOADER_STARTED: { case IDataLoaderStatusListener.DATA_LOADER_STARTED: {
dataLoader.prepareImage( dataLoader.prepareImage(
dataLoaderId,
addedFiles.toArray( addedFiles.toArray(
new InstallationFileParcel[addedFiles.size()]), new InstallationFileParcel[addedFiles.size()]),
removedFiles.toArray(new String[removedFiles.size()])); removedFiles.toArray(new String[removedFiles.size()]));
@@ -2603,7 +2604,7 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
dispatchStreamValidateAndCommit(); dispatchStreamValidateAndCommit();
} }
if (manualStartAndDestroy) { if (manualStartAndDestroy) {
dataLoader.destroy(); dataLoader.destroy(dataLoaderId);
} }
break; break;
} }
@@ -2613,7 +2614,7 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
new PackageManagerException(INSTALL_FAILED_MEDIA_UNAVAILABLE, new PackageManagerException(INSTALL_FAILED_MEDIA_UNAVAILABLE,
"Failed to prepare image.")); "Failed to prepare image."));
if (manualStartAndDestroy) { if (manualStartAndDestroy) {
dataLoader.destroy(); dataLoader.destroy(dataLoaderId);
} }
break; break;
} }

View File

@@ -940,7 +940,7 @@ bool IncrementalService::startDataLoader(MountId mountId) const {
if (!dataloader) { if (!dataloader) {
return false; return false;
} }
status = dataloader->start(); status = dataloader->start(mountId);
if (!status.isOk()) { if (!status.isOk()) {
return false; return false;
} }

View File

@@ -100,10 +100,11 @@ public:
const sp<IDataLoaderStatusListener>&) override { const sp<IDataLoaderStatusListener>&) override {
return binder::Status::ok(); return binder::Status::ok();
} }
binder::Status start() override { return binder::Status::ok(); } binder::Status start(int32_t) override { return binder::Status::ok(); }
binder::Status stop() override { return binder::Status::ok(); } binder::Status stop(int32_t) override { return binder::Status::ok(); }
binder::Status destroy() override { return binder::Status::ok(); } binder::Status destroy(int32_t) override { return binder::Status::ok(); }
binder::Status prepareImage(const std::vector<InstallationFileParcel>&, binder::Status prepareImage(int32_t,
const std::vector<InstallationFileParcel>&,
const std::vector<std::string>&) override { const std::vector<std::string>&) override {
return binder::Status::ok(); return binder::Status::ok();
} }