n.java 源代码


package k2;

import android.os.StatFs;
import android.text.TextUtils;
import android.util.Log;
import java.io.File;

public class n {

    public static long f23542b = 10485760;

    private long f23543a;

    private synchronized boolean a(File file, long j6) {
        long b6 = b(file);
        if (b6 == -1) {
            return true;
        }
        if (b6 >= j6) {
            return true;
        }
        Log.e("StorageManager", "Download#not enough free space in the filesystem rooted at: " + file);
        return false;
    }

    private static long b(File file) {
        try {
            StatFs statFs = new StatFs(file.getAbsolutePath());
            return statFs.getAvailableBlocksLong() * statFs.getBlockSizeLong();
        } catch (Exception e6) {
            Log.e("StorageManager", e6.getLocalizedMessage());
            return -1L;
        }
    }

    public boolean c(long j6) {
        long j7 = this.f23543a;
        if (j7 >= f23542b) {
            this.f23543a = 0L;
            return true;
        }
        this.f23543a = j7 + j6;
        return false;
    }

    public boolean d(String str, long j6) {
        if (TextUtils.isEmpty(str)) {
            return false;
        }
        if (j6 <= 0) {
            return true;
        }
        File file = new File(str);
        if (!file.isDirectory()) {
            file = file.getParentFile();
        }
        return a(file, j6);
    }
}