import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;
import java.util.regex.Pattern;

import quant.rich.emoney.entity.config.DeviceInfoConfig.DeviceInfo;

public class FingerprintsSpliter {
    
 
    public static void main(String[] args) throws IOException {
        
        Pattern p = Pattern.compile("^(?<brand>.*?)/(?<product>.*?)/(?<device>.*?):(?<versionRelease>.*?)/(?<buildId>.*?)/(?<buildNumber>.*?):(?<buildType>.*?)/(?<buildTags>.*?)$");
        
        List<String> lines = Files.readAllLines(Path.of("C:\\Users\\Administrator\\Downloads\\MagiskHidePropsConf-v6.1.2\\common\\prints.sh"));
        int count = 0;
        for(String line :lines) {
            if (!line.contains(":") || line.startsWith("#")) continue;
            String[] split = line.split(":", 3);
            String info = split[0];
            String manufacturer = split[1];
            String[] modelAndFingers = split[2].split("=");
            String model = modelAndFingers[0];
            String[] fingerprints = modelAndFingers[1].split(";");
            for(String fingerprint : fingerprints) {
                String realFinger = fingerprint.split("__")[0];
                // [brand]/[product]/[device]:[version.release]/[build.id]/[build.number]:[build.type]/[build.tags]
                
                /*
                System.out.printf("Manufacturer: %s, deviceName: %s, fingerprint: %s\r\n",
                        manufacturer,
                        deviceName,
                        realFinger);
                */
                DeviceInfo deviceInfo = DeviceInfo.from(model, realFinger);
                // System.out.printf("deviceInfos.add(DeviceInfo.from(\"%s\", \"%s\", \"%s\"));\r\n", manufacturer, model, realFinger);
                System.out.println(deviceInfo.toString());
                // System.out.println(EmoneyHeaderConfig.getSdkLevel(deviceInfo.getVersionRelease()));
                count++;
            }
        };
        System.out.printf("Total fingers: %d\r\n", count);
    }
   
}
