package com.facebook.internal;

import android.graphics.Bitmap;
import android.net.Uri;
import com.facebook.FacebookContentProvider;
import com.facebook.FacebookException;
import com.facebook.FacebookSdk;
import com.google.firebase.analytics.FirebaseAnalytics$b;
import com.tencent.matrix.trace.core.AppMethodBeat;
import java.util.UUID;

public final class NativeAppCallAttachmentStore$Attachment {
    private final String attachmentName;
    private final String attachmentUrl;
    private Bitmap bitmap;
    private final UUID callId;
    private boolean isContentUri;
    private Uri originalUri;
    private boolean shouldCreateFile;

    private NativeAppCallAttachmentStore$Attachment(UUID uuid, Bitmap bitmap, Uri uri) {
        String attachmentUrl;
        boolean z = true;
        AppMethodBeat.i(72423);
        this.callId = uuid;
        this.bitmap = bitmap;
        this.originalUri = uri;
        FacebookException facebookException;
        if (uri != null) {
            String scheme = uri.getScheme();
            if (FirebaseAnalytics$b.CONTENT.equalsIgnoreCase(scheme)) {
                this.isContentUri = true;
                if (uri.getAuthority() == null || uri.getAuthority().startsWith("media")) {
                    z = false;
                }
                this.shouldCreateFile = z;
            } else if ("file".equalsIgnoreCase(uri.getScheme())) {
                this.shouldCreateFile = true;
            } else if (!Utility.isWebUri(uri)) {
                facebookException = new FacebookException("Unsupported scheme for media Uri : ".concat(String.valueOf(scheme)));
                AppMethodBeat.o(72423);
                throw facebookException;
            }
        } else if (bitmap != null) {
            this.shouldCreateFile = true;
        } else {
            facebookException = new FacebookException("Cannot share media without a bitmap or Uri set");
            AppMethodBeat.o(72423);
            throw facebookException;
        }
        this.attachmentName = !this.shouldCreateFile ? null : UUID.randomUUID().toString();
        if (this.shouldCreateFile) {
            attachmentUrl = FacebookContentProvider.getAttachmentUrl(FacebookSdk.getApplicationId(), uuid, this.attachmentName);
        } else {
            attachmentUrl = this.originalUri.toString();
        }
        this.attachmentUrl = attachmentUrl;
        AppMethodBeat.o(72423);
    }

    public final String getAttachmentUrl() {
        return this.attachmentUrl;
    }

    public final Uri getOriginalUri() {
        return this.originalUri;
    }
}
