mirror of https://github.com/FongMi/TV.git
parent
06006b79d3
commit
d61be8aa56
Binary file not shown.
@ -0,0 +1,44 @@ |
||||
package com.fongmi.android.tv.utils; |
||||
|
||||
import android.content.pm.PackageManager; |
||||
import android.webkit.CookieManager; |
||||
|
||||
import com.fongmi.android.tv.App; |
||||
|
||||
import java.util.Set; |
||||
|
||||
public class WebViewUtil { |
||||
|
||||
private static final String SYSTEM_SETTINGS_PACKAGE = "com.android.settings"; |
||||
|
||||
private static final Set<String> BROWSER_PACKAGES = Set.of( |
||||
"com.android.chrome", |
||||
"com.mi.globalbrowser", |
||||
"com.huawei.browser", |
||||
"com.heytap.browser", |
||||
"com.vivo.browser" |
||||
); |
||||
|
||||
private static boolean installed(PackageManager pm, String pkg) { |
||||
try { |
||||
pm.getPackageInfo(pkg, PackageManager.GET_META_DATA); |
||||
return true; |
||||
} catch (PackageManager.NameNotFoundException ignored) { |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
public static String spoof() { |
||||
PackageManager pm = App.get().getPackageManager(); |
||||
return BROWSER_PACKAGES.stream().filter(packageName -> installed(pm, packageName)).findFirst().orElse(SYSTEM_SETTINGS_PACKAGE); |
||||
} |
||||
|
||||
public static boolean support() { |
||||
try { |
||||
CookieManager.getInstance(); |
||||
} catch (Throwable e) { |
||||
return false; |
||||
} |
||||
return App.get().getPackageManager().hasSystemFeature(PackageManager.FEATURE_WEBVIEW); |
||||
} |
||||
} |
||||
@ -1,54 +1,19 @@ |
||||
package com.fongmi.hook; |
||||
|
||||
import android.content.Context; |
||||
import android.content.pm.PackageManager; |
||||
import android.os.Looper; |
||||
|
||||
import java.util.Arrays; |
||||
import java.util.Set; |
||||
|
||||
public class Chromium { |
||||
|
||||
private static final String SYSTEM_SETTINGS_PACKAGE = "com.android.settings"; |
||||
|
||||
private static final Set<String> CHROMIUM_CLASS_NAMES = Set.of( |
||||
"org.chromium.base.buildinfo", |
||||
"org.chromium.base.apkinfo" |
||||
); |
||||
|
||||
private static final Set<String> CHROMIUM_METHOD_NAMES = Set.of( |
||||
"getall", |
||||
"getpackagename", |
||||
"<init>" |
||||
); |
||||
|
||||
private static final Set<String> BROWSER_PACKAGES = Set.of( |
||||
"com.android.chrome", |
||||
"com.mi.globalbrowser", |
||||
"com.huawei.browser", |
||||
"com.heytap.browser", |
||||
"com.vivo.browser" |
||||
); |
||||
|
||||
private static boolean isInstalled(PackageManager pm, String pkg) { |
||||
try { |
||||
pm.getPackageInfo(pkg, PackageManager.GET_META_DATA); |
||||
return true; |
||||
} catch (PackageManager.NameNotFoundException ignored) { |
||||
return false; |
||||
} |
||||
} |
||||
private static final String CLASS_NAME = "org.chromium.base.buildinfo"; |
||||
private static final String METHOD_NAME = "getall"; |
||||
|
||||
public static boolean find() { |
||||
try { |
||||
return Arrays.stream(Looper.getMainLooper().getThread().getStackTrace()).anyMatch(trace -> CHROMIUM_CLASS_NAMES.contains(trace.getClassName().toLowerCase()) && CHROMIUM_METHOD_NAMES.contains(trace.getMethodName().toLowerCase())); |
||||
} catch (Exception e) { |
||||
return Arrays.stream(Looper.getMainLooper().getThread().getStackTrace()).anyMatch(trace -> CLASS_NAME.equalsIgnoreCase(trace.getClassName()) && METHOD_NAME.equalsIgnoreCase(trace.getMethodName())); |
||||
} catch (Throwable ignored) { |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
public static String spoofedPackageName(Context context) { |
||||
PackageManager pm = context.getPackageManager(); |
||||
return BROWSER_PACKAGES.stream().filter(packageName -> isInstalled(pm, packageName)).findFirst().orElse(SYSTEM_SETTINGS_PACKAGE); |
||||
} |
||||
} |
||||
|
||||
Loading…
Reference in new issue