package io.flutter.plugins.pathprovider;

import android.content.Context;
import androidx.annotation.Nullable;
import java.io.File;
import java.util.ArrayList;

/* JADX INFO: loaded from: classes.dex */
public class d implements ad.c, b {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public Context f28273a;

    public final ArrayList a(Messages$StorageDirectory messages$StorageDirectory) {
        String str;
        ArrayList arrayList = new ArrayList();
        Context context = this.f28273a;
        switch (messages$StorageDirectory) {
            case ROOT:
                str = null;
                break;
            case MUSIC:
                str = "music";
                break;
            case PODCASTS:
                str = "podcasts";
                break;
            case RINGTONES:
                str = "ringtones";
                break;
            case ALARMS:
                str = "alarms";
                break;
            case NOTIFICATIONS:
                str = "notifications";
                break;
            case PICTURES:
                str = "pictures";
                break;
            case MOVIES:
                str = "movies";
                break;
            case DOWNLOADS:
                str = "downloads";
                break;
            case DCIM:
                str = "dcim";
                break;
            case DOCUMENTS:
                str = "documents";
                break;
            default:
                throw new RuntimeException("Unrecognized directory: " + messages$StorageDirectory);
        }
        for (File file : context.getExternalFilesDirs(str)) {
            if (file != null) {
                arrayList.add(file.getAbsolutePath());
            }
        }
        return arrayList;
    }

    @Override // io.flutter.plugins.pathprovider.b
    @Nullable
    public String getApplicationCachePath() {
        return this.f28273a.getCacheDir().getPath();
    }

    @Override // io.flutter.plugins.pathprovider.b
    @Nullable
    public String getApplicationDocumentsPath() {
        Context context = this.f28273a;
        File dir = context.getDir("flutter", 0);
        if (dir == null) {
            dir = new File(context.getDataDir().getPath(), "app_flutter");
        }
        return dir.getPath();
    }

    @Override // io.flutter.plugins.pathprovider.b
    @Nullable
    public String getApplicationSupportPath() {
        Context context = this.f28273a;
        File filesDir = context.getFilesDir();
        if (filesDir == null) {
            filesDir = new File(context.getDataDir().getPath(), "files");
        }
        return filesDir.getPath();
    }

    @Override // io.flutter.plugins.pathprovider.b
    @Nullable
    public String getExternalStoragePath() {
        File externalFilesDir = this.f28273a.getExternalFilesDir(null);
        if (externalFilesDir == null) {
            return null;
        }
        return externalFilesDir.getAbsolutePath();
    }

    @Override // io.flutter.plugins.pathprovider.b
    @Nullable
    public String getTemporaryPath() {
        return this.f28273a.getCacheDir().getPath();
    }

    @Override // ad.c
    public final void onAttachedToEngine(ad.b bVar) {
        try {
            b.setUp(bVar.f443b, this);
        } catch (Exception unused) {
        }
        this.f28273a = bVar.f442a;
    }

    @Override // ad.c
    public final void onDetachedFromEngine(ad.b bVar) {
        b.setUp(bVar.f443b, null);
    }
}
