Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ca4afd8c authored by Ahaan Ugale's avatar Ahaan Ugale Committed by Automerger Merge Worker
Browse files

Merge changes from topic "Data Share Sender Crash" into rvc-dev am: 4d8efece am: afeebb7f

Change-Id: I1820feaea0b698b53e6d45ccfb9c369aa3f502f9
parents 5d90f30b afeebb7f
Loading
Loading
Loading
Loading
+20 −1
Original line number Diff line number Diff line
@@ -930,7 +930,7 @@ public final class ContentCaptureManagerService extends
        }

        @Override
        public void accept(IDataShareReadAdapter serviceAdapter) throws RemoteException {
        public void accept(@NonNull IDataShareReadAdapter serviceAdapter) throws RemoteException {
            Slog.i(TAG, "Data share request accepted by Content Capture service");

            Pair<ParcelFileDescriptor, ParcelFileDescriptor> clientPipe = createPipe();
@@ -967,6 +967,7 @@ public final class ContentCaptureManagerService extends
            bestEffortCloseFileDescriptors(sourceIn, sinkOut);

            mParentService.mDataShareExecutor.execute(() -> {
                boolean receivedData = false;
                try (InputStream fis =
                             new ParcelFileDescriptor.AutoCloseInputStream(sinkIn);
                     OutputStream fos =
@@ -981,6 +982,8 @@ public final class ContentCaptureManagerService extends
                        }

                        fos.write(byteBuffer, 0 /* offset */, readBytes);

                        receivedData = true;
                    }
                } catch (IOException e) {
                    Slog.e(TAG, "Failed to pipe client and service streams", e);
@@ -992,6 +995,22 @@ public final class ContentCaptureManagerService extends
                        mParentService.mPackagesWithShareRequests
                                .remove(mDataShareRequest.getPackageName());
                    }
                    if (receivedData) {
                        try {
                            mClientAdapter.finish();
                        } catch (RemoteException e) {
                            Slog.e(TAG, "Failed to call finish() the client operation", e);
                        }
                        try {
                            serviceAdapter.finish();
                        } catch (RemoteException e) {
                            Slog.e(TAG, "Failed to call finish() the service operation", e);
                        }
                    } else {
                        // Client or service may have crashed before sending.
                        sendErrorSignal(mClientAdapter, serviceAdapter,
                                ContentCaptureManager.DATA_SHARE_ERROR_UNKNOWN);
                    }
                }
            });