| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- package com.example.modifiermodule;
- import android.annotation.SuppressLint;
- import android.app.Application;
- import android.content.ContentResolver;
- import android.content.Context;
- import android.database.Cursor;
- import android.net.Uri;
- import android.text.TextUtils;
- import android.util.Base64;
- import android.util.Log;
- import org.apache.commons.io.FileUtils;
- import org.json.JSONObject;
- import java.io.File;
- import java.lang.reflect.Method;
- import java.nio.charset.StandardCharsets;
- import de.robv.android.xposed.XposedBridge;
- import de.robv.android.xposed.XposedHelpers;
- public class BaseHook {
- // static final String PROP_MCC = "persist.spoof.mcc";
- // static final String PROP_MNC = "persist.spoof.mnc";
- // static final String PROP_ICCID = "persist.spoof.iccid";
- // static final String PROP_IMSI = "persist.spoof.imsi";
- // static final String PROP_IMEI = "persist.spoof.imei";
- // static final String PROP_NUMBER = "persist.spoof.number";
- // static final String PROP_COUNTRY = "persist.spoof.country";
- // static final String PROP_CARRIER_ID = "persist.spoof.carrier.id";
- // static final String PROP_CARRIER_NAME = "persist.spoof.carrier.name";
- // static final String PROP_UPI_POLICY = "persist.spoof.upi.policy";
- static final String PROP_MCC = "mcc";
- static final String PROP_MNC = "mnc";
- static final String PROP_ICCID = "iccid";
- static final String PROP_IMSI = "imsi";
- static final String PROP_IMEI = "imei";
- static final String PROP_NUMBER = "number";
- static final String PROP_COUNTRY = "country";
- static final String PROP_CARRIER_ID = "carrierId";
- static final String PROP_CARRIER_NAME = "carrierName";
- static final String PROP_UPI_POLICY = "upi_policy";
- static final String PROP_MAC = "mac";
- static final String PROP_BSSID = "bssid";
- static final String PROP_SERIAL = "serialNo";
- static final String PROP_ANDROID_ID = "androidId";
- static final String TAG = "Modifier";
- public BaseHook(ClassLoader classLoader) {
- this.classLoader = classLoader;
- }
- static void log(String message) {
- Log.i(TAG, message);
- XposedBridge.log(TAG + ": " + message);
- }
- private ClassLoader classLoader;
- // @SuppressLint("PrivateApi")
- // public String getProperty(String key, String defaultValue) {
- // String value = defaultValue;
- // try {
- // Class<?> c = Class.forName("android.os.SystemProperties");
- // Method get = c.getMethod("get", String.class, String.class);
- // value = (String) (get.invoke(c, key, defaultValue));
- // if (TextUtils.isEmpty(value)) {
- // value = defaultValue;
- // }
- // } catch (Exception e) {
- // e.printStackTrace();
- // }
- // return value;
- // }
- //
- // public int getIntProperty(String key, int defaultValue) {
- // int value = defaultValue;
- // try {
- // String prop = getProperty(key, String.valueOf(defaultValue));
- // if (TextUtils.isEmpty(prop)) {
- // return defaultValue;
- // }
- // value = Integer.parseInt(prop);
- // } catch (NumberFormatException e) {
- // e.printStackTrace();
- // }
- // return value;
- // }
- @SuppressLint("PrivateApi")
- public String getProperty(String key, String defaultValue) {
- log("getProperty: " + key);
- String value = defaultValue;
- try {
- Context context = getContext();
- String packageName = context.getPackageName();
- File configFile;
- if (packageName.equals("android")) {
- configFile = new File("/data/system/config.json");
- } else if (packageName.equals("com.android.phone")) {
- configFile = new File(context.getExternalFilesDir("config"), "config.json");
- } else {
- return defaultValue;
- }
- if (configFile.exists()) {
- String json = FileUtils.readFileToString(configFile, StandardCharsets.UTF_8);
- if (!TextUtils.isEmpty(json)) {
- JSONObject jsonObject = new JSONObject(json);
- if (jsonObject.has(key)) {
- value = jsonObject.getString(key);
- }
- }
- }
- } catch (Exception e) {
- log("getProperty: " + e.getMessage());
- e.printStackTrace();
- }
- return value;
- }
- public int getIntProperty(String key, int defaultValue) {
- int value = defaultValue;
- try {
- String prop = getProperty(key, String.valueOf(defaultValue));
- if (TextUtils.isEmpty(prop)) {
- return defaultValue;
- }
- value = Integer.parseInt(prop);
- } catch (NumberFormatException e) {
- e.printStackTrace();
- }
- return value;
- }
- public Context getContext() {
- Class<?> ActivityThread = XposedHelpers.findClass("android.app.ActivityThread", classLoader);
- Object currentActivityThread = XposedHelpers.callStaticMethod(ActivityThread, "currentActivityThread");
- Application application = (Application) XposedHelpers.callMethod(currentActivityThread, "getApplication");
- return application.getApplicationContext();
- }
- }
|