package com.ifpdos.daemonserver.h;

import android.os.SystemProperties;
import android.util.Log;
import com.ifpdos.daemonserver.App;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

/* JADX INFO: compiled from: LogChecker.java */
/* JADX INFO: loaded from: classes.dex */
public class d implements c {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    private Set<String> f1511a;

    public d() {
        HashSet hashSet = new HashSet();
        this.f1511a = hashSet;
        hashSet.add("/data/mosquitto.log");
        this.f1511a.add("/data/misc/last_logd/mosquitto.log");
        this.f1511a.add(com.ifpdos.daemonserver.j.f.f(App.f1492b));
    }

    @Override // com.ifpdos.daemonserver.h.c
    public boolean a() {
        if (SystemProperties.getBoolean("persist.sys.clear_mqtt_log", false)) {
            return false;
        }
        Log.d("LogChecker", "check");
        Iterator<String> it = this.f1511a.iterator();
        while (it.hasNext()) {
            File file = new File(it.next());
            if (file.exists()) {
                long length = file.length();
                Log.d("LogChecker", "log file size " + length);
                if (length > 52428800) {
                    try {
                        FileOutputStream fileOutputStream = new FileOutputStream(file);
                        try {
                            fileOutputStream.write(1);
                            fileOutputStream.flush();
                            fileOutputStream.close();
                        } catch (Throwable th) {
                            try {
                                fileOutputStream.close();
                            } catch (Throwable th2) {
                                th.addSuppressed(th2);
                            }
                            throw th;
                        }
                    } catch (IOException e2) {
                        e2.printStackTrace();
                    }
                } else {
                    continue;
                }
            }
        }
        return true;
    }

    @Override // com.ifpdos.daemonserver.h.c
    public int b() {
        return 30;
    }

    @Override // com.ifpdos.daemonserver.h.c
    public int c() {
        return 3600;
    }
}
