package net.gotev.uploadservice;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import net.gotev.uploadservice.BroadcastData;
/* loaded from: classes.dex */
public class UploadServiceBroadcastReceiver extends BroadcastReceiver implements UploadStatusDelegate {
    @Override // net.gotev.uploadservice.UploadStatusDelegate
    public void onCancelled(Context context, UploadInfo uploadInfo) {
    }

    @Override // net.gotev.uploadservice.UploadStatusDelegate
    public void onCompleted(Context context, UploadInfo uploadInfo, ServerResponse serverResponse) {
    }

    @Override // net.gotev.uploadservice.UploadStatusDelegate
    public void onError(Context context, UploadInfo uploadInfo, Exception exc) {
    }

    @Override // net.gotev.uploadservice.UploadStatusDelegate
    public void onProgress(Context context, UploadInfo uploadInfo) {
    }

    @Override // android.content.BroadcastReceiver
    public void onReceive(Context context, Intent intent) {
        if (intent == null || !UploadService.getActionBroadcast().equals(intent.getAction())) {
            return;
        }
        BroadcastData broadcastData = (BroadcastData) intent.getParcelableExtra("broadcastData");
        if (broadcastData == null) {
            Logger.error(getClass().getSimpleName(), "Missing intent parameter: broadcastData");
            return;
        }
        int i = AnonymousClass1.$SwitchMap$net$gotev$uploadservice$BroadcastData$Status[broadcastData.getStatus().ordinal()];
        if (i == 1) {
            onError(context, broadcastData.getUploadInfo(), broadcastData.getException());
        } else if (i == 2) {
            onCompleted(context, broadcastData.getUploadInfo(), broadcastData.getServerResponse());
        } else if (i == 3) {
            onProgress(context, broadcastData.getUploadInfo());
        } else if (i != 4) {
        } else {
            onCancelled(context, broadcastData.getUploadInfo());
        }
    }

    /* renamed from: net.gotev.uploadservice.UploadServiceBroadcastReceiver$1  reason: invalid class name */
    /* loaded from: classes.dex */
    static /* synthetic */ class AnonymousClass1 {
        static final /* synthetic */ int[] $SwitchMap$net$gotev$uploadservice$BroadcastData$Status;

        static {
            int[] iArr = new int[BroadcastData.Status.values().length];
            $SwitchMap$net$gotev$uploadservice$BroadcastData$Status = iArr;
            try {
                iArr[BroadcastData.Status.ERROR.ordinal()] = 1;
            } catch (NoSuchFieldError unused) {
            }
            try {
                $SwitchMap$net$gotev$uploadservice$BroadcastData$Status[BroadcastData.Status.COMPLETED.ordinal()] = 2;
            } catch (NoSuchFieldError unused2) {
            }
            try {
                $SwitchMap$net$gotev$uploadservice$BroadcastData$Status[BroadcastData.Status.IN_PROGRESS.ordinal()] = 3;
            } catch (NoSuchFieldError unused3) {
            }
            try {
                $SwitchMap$net$gotev$uploadservice$BroadcastData$Status[BroadcastData.Status.CANCELLED.ordinal()] = 4;
            } catch (NoSuchFieldError unused4) {
            }
        }
    }

    public void register(Context context) {
        IntentFilter intentFilter = new IntentFilter();
        intentFilter.addAction(UploadService.getActionBroadcast());
        context.registerReceiver(this, intentFilter);
    }

    public void unregister(Context context) {
        context.unregisterReceiver(this);
    }
}
