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

Commit 9fe15c48 authored by Yingren Wang's avatar Yingren Wang Committed by Marcus Hagerott
Browse files

Contacts: Fix security exception when export to .vcf file

When export contacts to external .vcf file, it will display
"contacts keeps stopping". Temporary read and write permissions
must be revoked when activity destroy. At this scenario, it
still access this external .vcf file after ExportVcardActivity
destroy, then cause security exception.

Obtain external .vcf file name before activity destroy and
issue resolved.

Test: built the Contacts app installed and verified that it doesn't
crash when exporting.
Bug: 154946972

Change-Id: I855bde6d1147db7fc40a54be43e30a37da8e545b
parent 931bb544
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -209,7 +209,7 @@ public class ExportProcessor extends ProcessorBase {
            mService.updateMediaScanner(request.destUri.getPath());

            successful = true;
            final String filename = ExportVCardActivity.getOpenableUriDisplayName(mService, uri);
            final String filename = request.displayName;
            // If it is a local file (i.e. not a file from Drive), we need to allow user to share
            // the file by pressing the notification; otherwise, it would be a file in Drive, we
            // don't need to enable this action in notification since the file is already uploaded.
+7 −0
Original line number Diff line number Diff line
@@ -24,12 +24,19 @@ public class ExportRequest {
     */
    public final String exportType;

    public final String displayName;

    public ExportRequest(Uri destUri) {
        this(destUri, null);
    }

    public ExportRequest(Uri destUri, String exportType) {
        this(destUri, exportType, null);
    }

    public ExportRequest(Uri destUri, String exportType, String displayName) {
        this.destUri = destUri;
        this.exportType = exportType;
        this.displayName = displayName;
    }
}
+2 −1
Original line number Diff line number Diff line
@@ -136,7 +136,8 @@ public class ExportVCardActivity extends Activity implements ServiceConnection,
                    data != null && data.getData() != null) {
                final Uri targetFileName = data.getData();
                if (DEBUG) Log.d(LOG_TAG, "exporting to " + targetFileName);
                final ExportRequest request = new ExportRequest(targetFileName);
                final String displayName = getOpenableUriDisplayName(this, targetFileName);
                final ExportRequest request = new ExportRequest(targetFileName, null, displayName);
                // The connection object will call finish().
                mService.handleExportRequest(request, new NotificationImportExportListener(
                        ExportVCardActivity.this));
+1 −2
Original line number Diff line number Diff line
@@ -158,8 +158,7 @@ public class NotificationImportExportListener implements VCardImportExportListen

    @Override
    public Notification onExportProcessed(ExportRequest request, int jobId) {
        final String displayName = ExportVCardActivity.getOpenableUriDisplayName(mContext,
                request.destUri);
        final String displayName = request.displayName;
        final String message = mContext.getString(R.string.contacts_export_will_start_message);

        mHandler.obtainMessage(0, message).sendToTarget();
+1 −1
Original line number Diff line number Diff line
@@ -60,7 +60,7 @@ public class ShareVCardActivity extends ExportVCardActivity {
                getString(R.string.contacts_file_provider_authority), file);
        if (DEBUG) Log.d(LOG_TAG, "exporting to " + contentUri);

        final ExportRequest request = new ExportRequest(contentUri);
        final ExportRequest request = new ExportRequest(contentUri, null, file.getName());
        // The connection object will call finish().
        mService.handleExportRequest(request, new NotificationImportExportListener(
                ShareVCardActivity.this));