From 306338992e3a414068e0f3bd55eea34013b546ba Mon Sep 17 00:00:00 2001 From: gdlbo <41114720+gdlbo@users.noreply.github.com> Date: Mon, 15 Aug 2022 20:44:22 +0300 Subject: [PATCH] New device id generator for webview auth --- .../vtosters/lite/hooks/DeviceInfoHook.java | 47 +++++++++++-------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/app/src/main/java/ru/vtosters/lite/hooks/DeviceInfoHook.java b/app/src/main/java/ru/vtosters/lite/hooks/DeviceInfoHook.java index 6505c7716..0e781bc94 100644 --- a/app/src/main/java/ru/vtosters/lite/hooks/DeviceInfoHook.java +++ b/app/src/main/java/ru/vtosters/lite/hooks/DeviceInfoHook.java @@ -1,6 +1,12 @@ package ru.vtosters.lite.hooks; +import static ru.vtosters.lite.utils.AndroidUtils.MD5; +import static ru.vtosters.lite.utils.AndroidUtils.getGlobalContext; import static ru.vtosters.lite.utils.Preferences.getBoolValue; +import android.annotation.SuppressLint; +import android.content.Context; +import android.os.Build; +import android.provider.Settings; import android.util.Log; import java.util.Random; @@ -13,27 +19,30 @@ public class DeviceInfoHook{ } public static String getDeviceId(String input) { - Log.d("DeviceInfoHook", "getDeviceId: " + input); - Log.d("DeviceInfoHook", "getDeviceId shuffled: " + shuffle(input)); - if (getBoolValue("hideDeviceInfo", true)) return shuffle(input); - return input; + return findDeviceId() + ":" + getDeviceId(); } - public static String shuffle(String string) { - StringBuilder sb = new StringBuilder(string.length()); - double rnd; - for (char c: string.toCharArray()) { - rnd = Math.random(); - if (rnd < 0.34) - sb.append(c); - else if (rnd < 0.67) - sb.insert(sb.length() / 2, c); - else - sb.insert(0, c); + public static String getDeviceId() { + String sb2 = Build.PRODUCT + + Build.BOARD + + Build.BOOTLOADER + + Build.BRAND + + Build.DEVICE + + Build.DISPLAY + + Build.FINGERPRINT + + Build.HARDWARE + + Build.HOST + + Build.ID + + Build.MANUFACTURER + + Build.MODEL + + Build.PRODUCT + + Build.TAGS; - sb.append(new Random().nextInt(10)); - sb.deleteCharAt(0); - } - return sb.toString(); + return MD5(sb2); + } + + @SuppressLint("HardwareIds") + private static String findDeviceId() { + return Settings.Secure.getString(getGlobalContext().getContentResolver(), "android_id"); } }