From 5b244cd71989b504d70936ce5575dc947cb5ab6b Mon Sep 17 00:00:00 2001 From: cyBerta Date: Tue, 19 Jul 2022 14:39:11 +0200 Subject: hide tethering option on CalyxOS 11 (SDK 30) --- .../base/utils/SystemPropertiesHelper.java | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 app/src/main/java/se/leap/bitmaskclient/base/utils/SystemPropertiesHelper.java (limited to 'app/src/main/java/se/leap/bitmaskclient/base/utils/SystemPropertiesHelper.java') diff --git a/app/src/main/java/se/leap/bitmaskclient/base/utils/SystemPropertiesHelper.java b/app/src/main/java/se/leap/bitmaskclient/base/utils/SystemPropertiesHelper.java new file mode 100644 index 00000000..b148f685 --- /dev/null +++ b/app/src/main/java/se/leap/bitmaskclient/base/utils/SystemPropertiesHelper.java @@ -0,0 +1,36 @@ +package se.leap.bitmaskclient.base.utils; + +import android.content.Context; + +import java.lang.reflect.Method; + + +public class SystemPropertiesHelper { + + /** + * Checks if SystemProperties contains a given key using reflection + * @return true if reflection was successful and the key was found + */ + public static boolean contains(String key, Context context) { + String result = null; + try { + ClassLoader cl = context.getClassLoader(); + @SuppressWarnings("rawtypes") + Class SystemProperties = cl.loadClass("android.os.SystemProperties"); + @SuppressWarnings("rawtypes") + Class[] paramTypes= new Class[1]; + paramTypes[0]= String.class; + + Method get = SystemProperties.getMethod("get", paramTypes); + Object[] params= new Object[1]; + params[0]= key; + + result = (String) get.invoke(SystemProperties, params); + } catch (Exception e) { + e.printStackTrace(); + } + + return result != null; + } +} + -- cgit v1.2.3