Add finish() method to DataShare Read and Write Adapters am: dc699fb8ce

Change-Id: I747217a8f7808a9dec4d5fb03daeeaec0bc107a8
This commit is contained in:
Yara Hassan
2020-05-29 23:50:57 +00:00
committed by Automerger Merge Worker
4 changed files with 14 additions and 8 deletions

View File

@@ -677,10 +677,6 @@ public abstract class ContentCaptureService extends Service {
throws RemoteException {
synchronized (mLock) {
executeAdapterMethodLocked(adapter -> adapter.onStart(fd), "onStart");
// Client app and Service successfully connected, so this object would be kept alive
// until the session has finished.
clearHardReferences();
}
}
@@ -693,6 +689,13 @@ public abstract class ContentCaptureService extends Service {
}
}
@Override
public void finish() throws RemoteException {
synchronized (mLock) {
clearHardReferences();
}
}
private void executeAdapterMethodLocked(Consumer<DataShareReadAdapter> adapterFn,
String methodName) {
LocalDataShareAdapterResourceManager resourceManager = mResourceManagerReference.get();

View File

@@ -22,4 +22,5 @@ import android.os.ICancellationSignal;
oneway interface IDataShareReadAdapter {
void start(in ParcelFileDescriptor fd);
void error(int errorCode);
void finish();
}

View File

@@ -761,10 +761,6 @@ public final class ContentCaptureManager {
public void write(ParcelFileDescriptor destination)
throws RemoteException {
executeAdapterMethodLocked(adapter -> adapter.onWrite(destination), "onWrite");
// Client app and Service successfully connected, so this object would be kept alive
// until the session has finished.
clearHardReferences();
}
@Override
@@ -779,6 +775,11 @@ public final class ContentCaptureManager {
clearHardReferences();
}
@Override
public void finish() throws RemoteException {
clearHardReferences();
}
private void executeAdapterMethodLocked(Consumer<DataShareWriteAdapter> adapterFn,
String methodName) {
LocalDataShareAdapterResourceManager resourceManager = mResourceManagerReference.get();

View File

@@ -25,4 +25,5 @@ oneway interface IDataShareWriteAdapter {
void write(in ParcelFileDescriptor destination);
void error(int errorCode);
void rejected();
void finish();
}