Launcher/libLauncher/src/main/java/ru/gravit/launcher/OshiHWID.java

52 lines
1.5 KiB
Java
Raw Normal View History

package ru.gravit.launcher;
import com.google.gson.Gson;
public class OshiHWID implements HWID {
public static Gson gson = new Gson();
2018-12-03 13:44:23 +03:00
@LauncherAPI
public long totalMemory = 0;
2018-12-03 13:44:23 +03:00
@LauncherAPI
public String serialNumber;
2018-12-03 13:44:23 +03:00
@LauncherAPI
public String HWDiskSerial;
2018-12-03 13:44:23 +03:00
@LauncherAPI
public String processorID;
@Override
public String getSerializeString() {
return gson.toJson(this);
}
2018-12-20 18:45:01 +03:00
2018-12-03 13:44:23 +03:00
@Override
public int getLevel() //Уровень доверия, насколько уникальные значения
{
int result = 0;
2018-12-20 18:45:01 +03:00
if (totalMemory != 0) result++;
if (serialNumber != null && !serialNumber.equals("unknown")) result += 4;
if (HWDiskSerial != null && !HWDiskSerial.equals("unknown")) result += 15;
if (processorID != null && !processorID.equals("unknown")) result += 6;
return result;
}
2018-12-20 18:45:01 +03:00
2019-03-08 14:02:54 +03:00
@Override
public int compare(HWID hwid) {
if(hwid instanceof OshiHWID)
{
int rate = 0;
OshiHWID oshi = (OshiHWID) hwid;
if(Math.abs(oshi.totalMemory - totalMemory) < 1024*1024) rate+=10;
if(oshi.HWDiskSerial.equals(HWDiskSerial)) rate+=50;
if(oshi.processorID.equals(processorID)) rate+=26;
if(oshi.serialNumber.equals(serialNumber)) rate+=15;
return rate;
}
return 0;
}
@Override
public boolean isNull() {
return getLevel() < 2;
}
}