de.robv.android.xposed.XposedHelpers Java Examples

The following examples show how to use de.robv.android.xposed.XposedHelpers. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ADBlock.java    From WechatEnhancement with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void hook(XC_LoadPackage.LoadPackageParam lpparam) {
    XposedHelpers.findAndHookMethod(HookParams.getInstance().XMLParserClassName, lpparam.classLoader, HookParams.getInstance().XMLParserMethod, String.class, String.class, new XC_MethodHook() {
        @Override
        protected void beforeHookedMethod(MethodHookParam param) {
            try {
                if (!PreferencesUtils.isADBlock())
                    return;

                if (param.args[1].equals("ADInfo"))
                    param.setResult(null);
            } catch (Error | Exception e) {
            }

        }
    });
}
 
Example #2
Source File: AweMeHook.java    From xposed-aweme with Apache License 2.0 6 votes vote down vote up
/**
 * 移除推荐的广告
 * @param feedList
 * @return
 */
private Object removeFeedAd(Object feedList) {

    if (feedList == null) return null;

    try {
        List<Object> newItems = new ArrayList<>();
        List<Object> items = (List<Object>) XposedHelpers
                .getObjectField(feedList, mVersionConfig.fieldFeedListItems);

        for (Object item : items) {
            // 只添加非广告视频
            if (!isAd(item)) newItems.add(item);
        }

        // 重新设置列表数据
        XposedHelpers.setObjectField(feedList,
                mVersionConfig.fieldFeedListItems, newItems);
    } catch (Throwable tr) {
        Alog.e("移除广告异常", tr);
    }
    return feedList;
}
 
Example #3
Source File: AlipayBroadcast.java    From alipay-master with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onReceive(Context context, Intent intent) {
    if (intent.getAction().contentEquals(CONSULT_SET_AMOUNT_RES_STRING_INTENT_FILTER_ACTION)) {
        String qr_money = intent.getStringExtra("qr_money");
        String beiZhu = intent.getStringExtra("beiZhu");
        log("AlipayBroadcast onReceive " + qr_money + " " + beiZhu + "\n");
        if (!qr_money.contentEquals("")) {
            Intent launcherIntent = new Intent(context, XposedHelpers.findClass("com.alipay.mobile.payee.ui.PayeeQRSetMoneyActivity", Main.launcherActivity.getApplicationContext().getClassLoader()));
            launcherIntent.putExtra("qr_money", qr_money);
            launcherIntent.putExtra("beiZhu", beiZhu);
            Main.launcherActivity.startActivity(launcherIntent);
        }
    } else if (intent.getAction().contentEquals(COOKIE_STR_INTENT_FILTER_ACTION)) {
        String cookieStr = Main.getCookieStr();
        log("AlipayBroadcast onReceive getCookieStr " + cookieStr + "\n");
        Intent broadCastIntent = new Intent();
        broadCastIntent.putExtra("cookieStr", cookieStr);
        broadCastIntent.setAction(PluginBroadcast.COOKIE_STR_INTENT_FILTER_ACTION);
        context.sendBroadcast(broadCastIntent);
    }
}
 
Example #4
Source File: XposedMod.java    From VirtualSensor with GNU Lesser General Public License v3.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
private void addSensors(final LoadPackageParam lpparam) {
    if (Build.VERSION.SDK_INT >= 24)
        XposedHelpers.findAndHookConstructor("android.hardware.SystemSensorManager",
                lpparam.classLoader, android.content.Context.class, android.os.Looper.class,
                new fr.frazew.virtualgyroscope.hooks.constructor.API24(lpparam));
    else if (Build.VERSION.SDK_INT == 23)
        XposedHelpers.findAndHookConstructor("android.hardware.SystemSensorManager",
                lpparam.classLoader, android.content.Context.class, android.os.Looper.class,
                new fr.frazew.virtualgyroscope.hooks.constructor.API23(lpparam));
    else if (Build.VERSION.SDK_INT >= 18)
        XposedHelpers.findAndHookConstructor("android.hardware.SystemSensorManager",
                lpparam.classLoader, android.content.Context.class, android.os.Looper.class,
                new fr.frazew.virtualgyroscope.hooks.constructor.API18(lpparam));
    else if (Build.VERSION.SDK_INT >= 16)
        XposedHelpers.findAndHookConstructor("android.hardware.SystemSensorManager",
                lpparam.classLoader, android.os.Looper.class,
                new fr.frazew.virtualgyroscope.hooks.constructor.API16(lpparam));
    else XposedBridge.log("VirtualSensor: Using SDK version " + Build.VERSION.SDK_INT + ", this is not supported");
}
 
Example #5
Source File: XposedHook.java    From XQuickEnergy with Apache License 2.0 6 votes vote down vote up
@Override
public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Throwable
{
 if("pansong291.xposed.quickenergy".equals(lpparam.packageName))
 {
  XposedHelpers.findAndHookMethod(MainActivity.class.getName(), lpparam.classLoader, "setModuleActive", boolean.class, new XC_MethodHook()
   {
    @Override
    protected void beforeHookedMethod(MethodHookParam param) throws Throwable
    {
     param.args[0] = true;
    }
   });
 }

 if(ClassMember.com_eg_android_AlipayGphone.equals(lpparam.packageName))
 {
  Log.i(TAG, lpparam.packageName);
  hookLauncherService(lpparam.classLoader);
  hookRpcCall(lpparam.classLoader);
 }
}
 
Example #6
Source File: MtkFixDevOptions.java    From GravityBox with Apache License 2.0 6 votes vote down vote up
public static void init(final XSharedPreferences prefs, final ClassLoader classLoader) {
    try {
        final Class<?> classDevSettings = XposedHelpers.findClass(CLASS_DEV_SETTINGS, classLoader);

        if (DEBUG) log("hooking DeveloperSettings.onCreate method");
        XposedHelpers.findAndHookMethod(classDevSettings, "onCreate", Bundle.class, new XC_MethodHook() {
            @Override
            protected void beforeHookedMethod(final MethodHookParam param) throws Throwable {
                PreferenceFragment pf = (PreferenceFragment) param.thisObject;
                mResId = pf.getResources().getIdentifier("development_prefs", "xml", PACKAGE_NAME);
                if (DEBUG) log("mResId=" + mResId);
            }
        });
    }
    catch (Throwable t) {
        XposedBridge.log(t);
    }
}
 
Example #7
Source File: PieSysInfo.java    From GravityBox with Apache License 2.0 6 votes vote down vote up
private String getWifiSsid() {
    String ssid = null;
    final WifiManager wifiManager = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE);
    if (wifiManager != null) {
        final WifiInfo connectionInfo = wifiManager.getConnectionInfo();
        if (connectionInfo != null) {
            final Object wifiSsid = XposedHelpers.callMethod(connectionInfo, "getWifiSsid");
            if (wifiSsid != null) {
                ssid = wifiSsid.toString();
            }
        }
    }
    if (TextUtils.isEmpty(ssid)) {
        int resId = mContext.getResources().getIdentifier(
                "quick_settings_wifi_not_connected", "string", PieController.PACKAGE_NAME);
        // TODO: translate
        ssid = resId == 0 ? "Not connected" : mContext.getString(resId);
    }
    return ssid;
}
 
Example #8
Source File: ModDownloadProvider.java    From GravityBox with Apache License 2.0 6 votes vote down vote up
public static void init(final XSharedPreferences prefs, final ClassLoader classLoader) {
    try {
        final Class<?> classDownloadService = XposedHelpers.findClass(CLASS_DOWNLOAD_SERVICE, classLoader);

        XposedHelpers.findAndHookMethod(classDownloadService, "updateLocked", new XC_MethodHook() {
            @Override
            protected void afterHookedMethod(MethodHookParam param) throws Throwable {
                final boolean isActive = (Boolean) param.getResult();
                if (mIsActive != isActive) { 
                    mIsActive = isActive;
                    if (DEBUG) log("Download state changed; active=" + mIsActive);
                    final Context context = (Context) param.thisObject;
                    Intent intent = new Intent(ACTION_DOWNLOAD_STATE_CHANGED);
                    intent.putExtra(EXTRA_ACTIVE, mIsActive);
                    context.sendBroadcast(intent);
                }
            }
        });
    } catch (Throwable t) {
        XposedBridge.log(t);
    }
}
 
Example #9
Source File: DontGroupOpsHack.java    From AppOpsXposed with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void handleLoadAnyPackage(LoadPackageParam lpparam) throws Throwable
{
	try
	{
		XposedHelpers.findAndHookMethod("android.app.AppOpsManager",
				lpparam.classLoader, "opToSwitch", int.class, new XC_MethodHook() {

					@Override
					protected void beforeHookedMethod(MethodHookParam param) throws Throwable
					{
						param.setResult(param.args[0]);
					}
		});
	}
	catch(Throwable t)
	{
		debug(t);
	}
}
 
Example #10
Source File: Utils.java    From GravityBox with Apache License 2.0 6 votes vote down vote up
public static void performSoftReboot() {
    try {
        Class<?> classSm = XposedHelpers.findClass("android.os.ServiceManager", null);
        Class<?> classIpm = XposedHelpers.findClass("android.os.IPowerManager.Stub", null);
        IBinder b = (IBinder) XposedHelpers.callStaticMethod(
                classSm, "getService", Context.POWER_SERVICE);
        Object ipm = XposedHelpers.callStaticMethod(classIpm, "asInterface", b);
        XposedHelpers.callMethod(ipm, "crash", "Hot reboot");
    } catch (Throwable t) {
        try {
            SystemProp.set("ctl.restart", "surfaceflinger");
            SystemProp.set("ctl.restart", "zygote");
        } catch (Throwable t2) {
            XposedBridge.log(t);
            XposedBridge.log(t2);
        }
    }
}
 
Example #11
Source File: API24.java    From VirtualSensor with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
protected void beforeHookedMethod(XC_MethodHook.MethodHookParam param) throws Throwable {
    SensorEventListener listener = (SensorEventListener) XposedHelpers.getObjectField(param.thisObject, "mListener");
    int handle = (int) param.args[0];
    Object mgr = XposedHelpers.getObjectField(param.thisObject, "mManager");
    HashMap<Integer, Sensor> sensors = (HashMap<Integer, Sensor>) XposedHelpers.getObjectField(mgr, "mHandleToSensor");
    Sensor s = sensors.get(handle);

    if (listener instanceof VirtualSensorListener) {
        float[] values = this.mSensorChange.handleListener(s, (VirtualSensorListener) listener, ((float[]) param.args[1]).clone(), (int) param.args[2], (long) param.args[3], XposedMod.ACCELEROMETER_RESOLUTION, XposedMod.MAGNETIC_RESOLUTION);
        if (values != null) {
            System.arraycopy(values, 0, param.args[1], 0, values.length);
            param.args[0] = XposedMod.sensorTypetoHandle.get(((VirtualSensorListener) listener).getSensor().getType());
        }// else param.setResult(null);
    }
}
 
Example #12
Source File: AntiXposedHook.java    From AdBlocker_Reborn with GNU General Public License v3.0 6 votes vote down vote up
public void hook(final XC_LoadPackage.LoadPackageParam lpparam) {

        if (!PreferencesHelper.isDisableXposedEnabled()) {
            return;
        }

        XC_MethodHook disableXposedHook = new XC_MethodHook() {
            @Override
            protected void beforeHookedMethod(MethodHookParam param) {
                if (param.args[0].equals("disableHooks") || param.args[0].equals("sHookedMethodCallbacks")) {
                    param.setThrowable(new NoClassDefFoundError());
                    LogUtils.logRecord("AntiXposedHook Success: " + lpparam.packageName);
                }
            }
        };

        XposedHelpers.findAndHookMethod(Class.class, "getDeclaredField", String.class, disableXposedHook);
    }
 
Example #13
Source File: HookCommentUI.java    From douyin with Apache License 2.0 6 votes vote down vote up
public static void hookCommentUI(ClassLoader classLoader){
    XposedHelpers.findAndHookMethod(Version.VideoCommentDialogFragment2,
            classLoader,
            "onCreateView",
            LayoutInflater.class,
            ViewGroup.class,
            Bundle.class,
            new XC_MethodHook() {
                @Override
                protected void afterHookedMethod(MethodHookParam param) throws Throwable {
                    Object o = param.getResult();
                    Vlog.log("评论界面View>>"+o);
                    LinearLayout linearLayout = (LinearLayout) param.getResult();
                    if (linearLayout != null){
                        MyLinear myLinear = new MyLinear(HookAwemeUI.globalActivity);
                        linearLayout.addView(myLinear, 0);
                    }
                }
            }
    );
}
 
Example #14
Source File: XUtils.java    From AppOpsXposed with GNU General Public License v3.0 6 votes vote down vote up
public static ApplicationInfo getApplicationInfo(String packageName)
{
	final Class<?> atClazz = XposedHelpers.findClass("android.app.ActivityThread", null);
	final Object pm = XposedHelpers.callStaticMethod(atClazz, "getPackageManager");

	try
	{
		final ApplicationInfo ai = (ApplicationInfo) XposedHelpers.callMethod(pm,
				"getApplicationInfo", new Class<?>[] { String.class, int.class, int.class },
				packageName, 0, 0);

		if(ai != null)
			return ai;
	}
	catch(Exception e)
	{
		Util.debug(e);
	}

	Util.log("getApplicationInfo failed for " + packageName);

	return null;
}
 
Example #15
Source File: AlipayHook.java    From renrenpay-android with Apache License 2.0 6 votes vote down vote up
@Override
public void hookCreatQr() throws Error, Exception {
    XposedHelpers.findAndHookMethod("com.alipay.mobile.payee.ui.PayeeQRSetMoneyActivity", mAppClassLoader, "a",
            XposedHelpers.findClass("com.alipay.transferprod.rpc.result.ConsultSetAmountRes", mAppClassLoader), new XC_MethodHook() {
                @Override
                protected void afterHookedMethod(MethodHookParam param) throws Throwable {
                    try {
                        String money = (String) ReflecUtils.findField(param.thisObject.getClass(), String.class
                                , 0, false).get(param.thisObject);
                        String payurl = (String) XposedHelpers.findField(param.args[0].getClass(),
                                "qrCodeUrl").get(param.args[0]);
                        Class<?> auinputbox = XposedHelpers.findClass("com.alipay.mobile.antui.input.AUInputBox", mAppClassLoader);
                        Object markObject = ReflecUtils.findField(param.thisObject.getClass(), auinputbox
                                , 1, false).get(param.thisObject);
                        String mark = (String) XposedHelpers.callMethod(markObject, "getUbbStr");
                        Log.d(TAG, "支付宝生成二维码:" + money + "|" + mark + "|" + payurl);
                    } catch (Error | Exception ignore) {
                        Log.d(TAG, "hookCreatQr error -> " + ignore.getMessage());
                    }
                }
            });
}
 
Example #16
Source File: ModDialer24.java    From GravityBox with Apache License 2.0 6 votes vote down vote up
private static ClassInfo resolveCallCardFragment(ClassLoader cl) {
    ClassInfo info = null;
    String[] CLASS_NAMES = new String[] { "com.android.incallui.CallCardFragment", "ayv" };
    String[] METHOD_NAMES = new String[] { "setDrawableToImageView" };
    for (String className : CLASS_NAMES) {
        Class<?> clazz = XposedHelpers.findClassIfExists(className, cl);
        if (clazz == null || !Fragment.class.isAssignableFrom(clazz))
            continue;
        info = new ClassInfo(clazz);
        for (String methodName : METHOD_NAMES) {
            if (methodName.equals("setDrawableToImageView")) {
                for (String realMethodName : new String[] { methodName, "b" }) {
                    Method m = XposedHelpers.findMethodExactIfExists(clazz, realMethodName,
                        Drawable.class);
                    if (m != null) {
                        info.methods.put(methodName, realMethodName);
                        break;
                    }
                }
            }
        }
    }
    return info;
}
 
Example #17
Source File: ClearMainAdPlugin.java    From mhzs with MIT License 6 votes vote down vote up
@Override
    public void run(ClassLoader classLoader) throws Throwable {

        /**
         * 在com.mh.movie.core.mvp.ui.widget.MovieCardView中
         * 替换setShowBanner方法,去掉广告
         */
        // TODO: 2019/3/6 0006 VXP/EXP TOO SHORT METHOD
//        XposedHelpers.findAndHookMethod(movieCardViewClassName, classLoader, "setShowBanner", List.class, new XC_MethodReplacement() {
//            @Override
//            protected Object replaceHookedMethod(MethodHookParam methodHookParam) throws Throwable {
//                LogUtil.e("hook setShowBanner method!");
//                return null;
//            }
//        });

        XposedHelpers.findAndHookMethod(movieCardViewClassName, classLoader, "c", new XC_MethodReplacement() {
            @Override
            protected Object replaceHookedMethod(MethodHookParam methodHookParam) throws Throwable {
                LogUtil.e("hook setShowBanner2 method!");
                return null;
            }
        });

    }
 
Example #18
Source File: HookEntry.java    From QNotified with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void handleLoadPackage(final XC_LoadPackage.LoadPackageParam lpparam) throws Throwable {
    if (R.string.res_inject_success >>> 24 == 0x7f) {
        XposedBridge.log("package id must NOT be 0x7f, reject loading...");
        return;
    }
    //dumpProcessInfo(lpparam.isFirstApplication);
    switch (lpparam.packageName) {
        case PACKAGE_NAME_SELF:
            XposedHelpers.findAndHookMethod("nil.nadph.qnotified.util.Utils", lpparam.classLoader, "getActiveModuleVersion", XC_MethodReplacement.returnConstant(Utils.QN_VERSION_NAME));
            break;
        case PACKAGE_NAME_QQ:
        case PACKAGE_NAME_TIM:
            StartupHook.getInstance().doInit(lpparam.classLoader);
            break;
        case PACKAGE_NAME_QQ_INTERNATIONAL:
        case PACKAGE_NAME_QQ_LITE:
            //coming...
    }
}
 
Example #19
Source File: XposedHelpersWraper.java    From MIUIAnesthetist with MIT License 5 votes vote down vote up
public static void setByteField(Object obj, String fieldName, byte value) {
    try {
        XposedHelpers.setByteField(obj, fieldName, value);
    } catch (Throwable t) {
        log(t);
    }
}
 
Example #20
Source File: XposedHelpersWraper.java    From MIUIAnesthetist with MIT License 5 votes vote down vote up
public static void setCharField(Object obj, String fieldName, char value) {
    try {
        XposedHelpers.setCharField(obj, fieldName, value);
    } catch (Throwable t) {
        log(t);
    }
}
 
Example #21
Source File: ModLowBatteryWarning.java    From GravityBox with Apache License 2.0 5 votes vote down vote up
private static void updateLightsLocked() {
    if (mBatteryLed == null) return;

    try {
        XposedHelpers.callMethod(mBatteryLed, "updateLightsLocked");
    } catch (Throwable t) {
        XposedBridge.log(t);
    }
}
 
Example #22
Source File: XposedHelpersWraper.java    From MIUIAnesthetist with MIT License 5 votes vote down vote up
public static void setIntField(Object obj, String fieldName, int value) {
    try {
        XposedHelpers.setIntField(obj, fieldName, value);
    } catch (Throwable t) {
        log(t);
    }
}
 
Example #23
Source File: XposedHelpersWraper.java    From MIUIAnesthetist with MIT License 5 votes vote down vote up
public static byte[] assetAsByteArray(Resources res, String path) {
    try {
        return XposedHelpers.assetAsByteArray(res, path);
    } catch (Throwable t) {
        log(t);
    }
    return null;
}
 
Example #24
Source File: XposedHelpersWraper.java    From MIUIAnesthetist with MIT License 5 votes vote down vote up
public static Object callMethod(Object obj, String methodName, Class<?>[] parameterTypes, Object... args) {
    try {
        return XposedHelpers.callMethod(obj, methodName, parameterTypes, args);
    } catch (Throwable t) {
        log(t);
    }
    return null;
}
 
Example #25
Source File: XposedHelpersWraper.java    From MIUIAnesthetist with MIT License 5 votes vote down vote up
public static Object removeAdditionalStaticField(Object obj, String key) {
    try {
        return XposedHelpers.removeAdditionalStaticField(obj, key);
    } catch (Throwable t) {
        log(t);
    }
    return null;
}
 
Example #26
Source File: SmsHandlerHook.java    From XposedSmsCode with GNU General Public License v3.0 5 votes vote down vote up
private void hookConstructor19(ClassLoader classloader) {
    XLog.i("Hooking InboundSmsHandler constructor for Android v19+");
    XposedHelpers.findAndHookConstructor(SMS_HANDLER_CLASS, classloader,
            /*                 name */ String.class,
            /*              context */ Context.class,
            /*       storageMonitor */ TELEPHONY_PACKAGE + ".SmsStorageMonitor",
            /*                phone */ TELEPHONY_PACKAGE + ".PhoneBase",
            /* cellBroadcastHandler */ TELEPHONY_PACKAGE + ".CellBroadcastHandler",
            new ConstructorHook());
}
 
Example #27
Source File: ModTrustManager.java    From GravityBox with Apache License 2.0 5 votes vote down vote up
private static void updateTrustAll() {
    try {
        XposedHelpers.callMethod(mTrustManager, "updateTrustAll");
    } catch (Throwable t) {
        XposedBridge.log(t);
    }
}
 
Example #28
Source File: HookLocationFaker.java    From PokeFaker with MIT License 5 votes vote down vote up
private void hook_gpsStatusUpdate(XC_LoadPackage.LoadPackageParam lpparam) {
        if (!lpparam.packageName.equals("com.nianticlabs.pokemongo")) return;

        XposedHelpers.findAndHookMethod(
                    "com.nianticlabs.nia.location.NianticLocationManager",
                    lpparam.classLoader,
                    "gpsStatusUpdate",
                    int.class,
                    GpsSatellite[].class,
                    new XC_MethodReplacement() {
                        @Override
                        protected Object replaceHookedMethod(MethodHookParam param) throws Throwable {
//                            int timeToFix = ((int) param.args[0]);
//                            GpsSatellite[] satellites = ((GpsSatellite[]) param.args[1]);
//                            for (GpsSatellite s: satellites) {
//                                XposedBridge.log(satelliteToString(s));
//                            }
                            Location locationGps = mLocationHolder.pollLocation("gps");
                            Location locationNetwork = mLocationHolder.pollLocation("network");
                            call_updateLocation(locationGps);
                            call_updateLocation(locationNetwork);

//                            List<GpsSatellite> fakeSatelliteList = FakeGpsSatellite.fetchGpsSatellites();
//                            GpsSatellite[] fakeSatellites = new GpsSatellite[fakeSatelliteList.size()];
//                            for (int i = 0; i < fakeSatelliteList.size(); i++) {
//                                fakeSatellites[i] = fakeSatelliteList.get(i);
//                            }
//                            param.args[1] = fakeSatellites;
                            return null;
                        }
                    }
        );
    }
 
Example #29
Source File: InputHelper.java    From XposedSmsCode with GNU General Public License v3.0 5 votes vote down vote up
/**
 * refer com.android.commands.input.Input#injectKeyEvent()
 */
@SuppressLint("PrivateApi")
private static void injectKeyEvent(KeyEvent keyEvent) throws Throwable {
    InputManager inputManager = (InputManager) XposedHelpers.callStaticMethod(InputManager.class, "getInstance");

    int INJECT_INPUT_EVENT_MODE_WAIT_FOR_FINISH =
            XposedHelpers.getStaticIntField(InputManager.class, "INJECT_INPUT_EVENT_MODE_WAIT_FOR_FINISH");

    Class<?>[] paramTypes = {KeyEvent.class, int.class,};
    Object[] args = {keyEvent, INJECT_INPUT_EVENT_MODE_WAIT_FOR_FINISH,};

    XposedHelpers.callMethod(inputManager, "injectInputEvent", paramTypes, args);
}
 
Example #30
Source File: BaseTile.java    From GravityBox with Apache License 2.0 5 votes vote down vote up
public void collapsePanels() {
    try {
        XposedHelpers.callMethod(mHost, "collapsePanels");
    } catch (Throwable t) {
        log("Error in collapsePanels: ");
        XposedBridge.log(t);
    }
}