Java Code Examples for de.robv.android.xposed.XposedHelpers#callStaticMethod()

The following examples show how to use de.robv.android.xposed.XposedHelpers#callStaticMethod() . 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: DingDingHandler.java    From xposed-rimet with Apache License 2.0 6 votes vote down vote up
/**
 * 接收红包
 * @param sid
 * @param clusterId
 */
public void pickRedEnvelop(long sid, String clusterId) throws Exception {

    Class classRedEnvelopPickIService = findClass(M.classz.class_android_dingtalk_redpackets_idl_service_RedEnvelopPickIService);
    Class classRedPacketsRpc = findClass(M.classz.class_defpackage_RedPacketsRpc);
    Class classSubRedPacketsRpc = findClass(M.classz.class_defpackage_RedPacketsRpc_9);

    Object redPacketsRpc = XposedHelpers.callStaticMethod(
            classRedPacketsRpc, getXString(M.method.method_defpackage_RedPacketsRpc_newInstance));
    Object handler = XposedHelpers.newInstance(classSubRedPacketsRpc, redPacketsRpc, null);

    Method methodGetService = findMatcherMethod(
            M.classz.class_defpackage_ServiceFactory,
            M.method.method_defpackage_ServiceFactory_getService,
            Class.class);

    // 获取红包服务
    Object redEnvelopPickIService = methodGetService.invoke(null, classRedEnvelopPickIService);

    // 自动接收红包
    XposedHelpers.callMethod(redEnvelopPickIService,
            getXString(M.method.method_android_dingtalk_redpackets_idl_service_RedEnvelopPickIService_pickRedEnvelopCluster),
            sid, clusterId, handler);
}
 
Example 2
Source File: DoNotDisturbTile.java    From GravityBox with Apache License 2.0 6 votes vote down vote up
private Uri getTimeUntilNextAlarmCondition() {
    try {
        GregorianCalendar weekRange = new GregorianCalendar();
        final long now = weekRange.getTimeInMillis();
        setToMidnight(weekRange);
        weekRange.roll(Calendar.DATE, 6);
        final long nextAlarmMs = (long) XposedHelpers.callMethod(mZenCtrl, "getNextAlarm");
        if (nextAlarmMs > 0) {
            GregorianCalendar nextAlarm = new GregorianCalendar();
            nextAlarm.setTimeInMillis(nextAlarmMs);
            setToMidnight(nextAlarm);
            if (weekRange.compareTo(nextAlarm) >= 0) {
                Object condition = XposedHelpers.callStaticMethod(getZenModeConfigClass(), "toNextAlarmCondition",
                        mContext, now, nextAlarmMs, SysUiManagers.KeyguardMonitor.getCurrentUserId());
                return (Uri) XposedHelpers.getObjectField(condition, "id");
            }
        }
        return null;
    } catch (Throwable t) {
        XposedBridge.log(t);
        return null;
    }
}
 
Example 3
Source File: PhoneWrapper.java    From GravityBox with Apache License 2.0 6 votes vote down vote up
private static int getCurrentNetworkType(int phoneId) {
    try {
        int networkType = getDefaultNetworkType();
        Object[] phones = (Object[]) XposedHelpers.callStaticMethod(mClsPhoneFactory, "getPhones");
        if (phoneId < phones.length) {
            int subId = (int) XposedHelpers.callMethod(phones[phoneId], "getSubId");
            if (DEBUG)
                log("getCurrentNetworkType: calculating network type for subId=" + subId);
            networkType = (int) XposedHelpers.callStaticMethod(mClsPhoneFactory,
                    "calculatePreferredNetworkType", mContext, subId);
        }
        if (DEBUG) log("getCurrentNetworkType: phoneId=" + phoneId +
                "; networkType=" + getNetworkModeNameFromValue(networkType));
        return networkType;
    } catch (Throwable t) {
        XposedBridge.log(t);
        return NT_WCDMA_PREFERRED;
    }
}
 
Example 4
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 5
Source File: PieController.java    From GravityBox with Apache License 2.0 6 votes vote down vote up
public void handleMessage(Message m) {
    switch (m.what) {
        case MSG_INJECT_KEY:
            final long eventTime = SystemClock.uptimeMillis();
            final InputManager inputManager = (InputManager)
                    XposedHelpers.callStaticMethod(InputManager.class, "getInstance");

            int flags = KeyEvent.FLAG_FROM_SYSTEM;
            XposedHelpers.callMethod(inputManager, "injectInputEvent",
                    new KeyEvent(eventTime - 50, eventTime - 50, KeyEvent.ACTION_DOWN, m.arg1, 0,
                            0, KeyCharacterMap.VIRTUAL_KEYBOARD, 0, flags, InputDevice.SOURCE_UNKNOWN), 0);
            XposedHelpers.callMethod(inputManager, "injectInputEvent",
                    new KeyEvent(eventTime - 50, eventTime - 25, KeyEvent.ACTION_UP, m.arg1, 0,
                            0, KeyCharacterMap.VIRTUAL_KEYBOARD, 0, flags, InputDevice.SOURCE_UNKNOWN), 0);

            break;
    }
}
 
Example 6
Source File: QsTile.java    From GravityBox with Apache License 2.0 5 votes vote down vote up
private Object createTileObject() throws Throwable {
    String hostTileClassName = getHostTileClassInfo(mContext.getClassLoader()).className;
    if (hostTileClassName.endsWith("AirplaneModeTile")) {
        Constructor<?> c = XposedHelpers.findConstructorExact(hostTileClassName,
                mContext.getClassLoader(), XposedHelpers.findClass(
                        "com.android.systemui.qs.QSTile.Host",
                            mContext.getClassLoader()));
        return c.newInstance(mHost);
    } else {
        return XposedHelpers.callStaticMethod(XposedHelpers.findClass(
                hostTileClassName, mContext.getClassLoader()),
                "create", mHost, "intent(dummy)");
    }
}
 
Example 7
Source File: PhoneWrapper.java    From GravityBox with Apache License 2.0 5 votes vote down vote up
public static int getDefaultNetworkType() {
    try {
        int mode = (Integer) XposedHelpers.callStaticMethod(mSystemProperties,
                "getInt", "ro.telephony.default_network", NT_WCDMA_PREFERRED);
        if (DEBUG) log("getDefaultNetworkMode: mode=" + mode);
        return mode;
    } catch (Throwable t) {
        XposedBridge.log(t);
        return NT_WCDMA_PREFERRED;
    }
}
 
Example 8
Source File: PhoneWrapper.java    From GravityBox with Apache License 2.0 5 votes vote down vote up
private static Object getPhone() {
    if (mClsPhoneFactory == null) {
        return null;
    } else if (hasMsimSupport()) {
        return XposedHelpers.callStaticMethod(mClsPhoneFactory, "getPhone", mSimSlot);
    } else {
        return XposedHelpers.callStaticMethod(mClsPhoneFactory, "getDefaultPhone");
    }
}
 
Example 9
Source File: KeyButtonView.java    From GravityBox with Apache License 2.0 5 votes vote down vote up
void sendEvent(int action, int flags, long when, boolean applyDefaultFlags) {
    try {
        final int repeatCount = (flags & KeyEvent.FLAG_LONG_PRESS) != 0 ? 1 : 0;
        if (applyDefaultFlags) {
            flags |= KeyEvent.FLAG_FROM_SYSTEM | KeyEvent.FLAG_VIRTUAL_HARD_KEY;
        }
        final KeyEvent ev = new KeyEvent(mDownTime, when, action, mCode, repeatCount,
                0, KeyCharacterMap.VIRTUAL_KEYBOARD, 0, flags,
                InputDevice.SOURCE_KEYBOARD);
        final Object inputManager = XposedHelpers.callStaticMethod(InputManager.class, "getInstance");
        XposedHelpers.callMethod(inputManager, "injectInputEvent", ev, 0);
    } catch (Throwable t) {
        XposedBridge.log(t);
    }
}
 
Example 10
Source File: KeyButtonView.java    From GravityBox with Apache License 2.0 5 votes vote down vote up
public void playSoundEffect(int soundConstant) {
    try {
        int currentUser = (Integer) XposedHelpers.callStaticMethod(
                ActivityManager.class, "getCurrentUser");
        XposedHelpers.callMethod(mAudioManager, "playSoundEffect",
                soundConstant, currentUser);
    } catch (Throwable t) {
        XposedBridge.log(t);
    }
}
 
Example 11
Source File: ModStatusBar.java    From GravityBox with Apache License 2.0 5 votes vote down vote up
public void update() {
    try {
        ContentResolver resolver = mContext.getContentResolver();
        int brightnessMode = (Integer) XposedHelpers.callStaticMethod(Settings.System.class,
                "getIntForUser", resolver,
                Settings.System.SCREEN_BRIGHTNESS_MODE, 0, -2);
        mAutomaticBrightness = brightnessMode == Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC;
    } catch (Throwable t) {
        XposedBridge.log(t);
    }
}
 
Example 12
Source File: PayHelperUtils.java    From Hook with Apache License 2.0 5 votes vote down vote up
public static String getCookieStr(ClassLoader paramClassLoader) {
    XposedHelpers.callStaticMethod(XposedHelpers.findClass("com.alipay.mobile.common.transportext.biz.appevent.AmnetUserInfo", paramClassLoader), "getSessionid", new Object[0]);
    Context localContext = (Context) XposedHelpers.callStaticMethod(XposedHelpers.findClass("com.alipay.mobile.common.transportext.biz.shared.ExtTransportEnv", paramClassLoader), "getAppContext", new Object[0]);
    if (localContext != null) {
        if (XposedHelpers.callStaticMethod(XposedHelpers.findClass("com.alipay.mobile.common.helper.ReadSettingServerUrl", paramClassLoader), "getInstance", new Object[0]) != null) {
            return (String) XposedHelpers.callStaticMethod(XposedHelpers.findClass("com.alipay.mobile.common.transport.http.GwCookieCacheHelper", paramClassLoader), "getCookie", new Object[]{".alipay.com"});
        }
        Log.i("tag", "异常readSettingServerUrl为空");
        return "";
    }
    Log.i("tag", "异常context为空");
    return "";
}
 
Example 13
Source File: SmsHandlerHook.java    From NekoSMS with GNU General Public License v3.0 5 votes vote down vote up
private void putPhoneIdAndSubIdExtra(Object inboundSmsHandler, Intent intent) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
        try {
            Object phone = XposedHelpers.getObjectField(inboundSmsHandler, "mPhone");
            int phoneId = (Integer)XposedHelpers.callMethod(phone, "getPhoneId");
            XposedHelpers.callStaticMethod(SubscriptionManager.class, "putPhoneIdAndSubIdExtra", intent, phoneId);
        } catch (Exception e) {
            Xlog.e("Could not update intent with subscription id", e);
        }
    }
}
 
Example 14
Source File: GpsStatusMonitor.java    From GravityBox with Apache License 2.0 5 votes vote down vote up
public void setLocationMode(int mode) {
    final int currentUserId = Utils.getCurrentUser();
    if (!isUserLocationRestricted(currentUserId)) {
        try {
            final ContentResolver cr = mContext.getContentResolver();
            XposedHelpers.callStaticMethod(Settings.Secure.class, "putIntForUser",
                    cr, Settings.Secure.LOCATION_MODE, mode, currentUserId);
        } catch (Throwable t) {
            XposedBridge.log(t);
        }
    }
}
 
Example 15
Source File: XposedHelpersWraper.java    From MIUIAnesthetist with MIT License 5 votes vote down vote up
public static Object callStaticMethod(Class<?> clazz, String methodName, Class<?>[] parameterTypes, Object... args) {
    try {
        return XposedHelpers.callStaticMethod(clazz, methodName, parameterTypes, args);
    } catch (Throwable t) {
        log(t);
    }
    return null;
}
 
Example 16
Source File: DoNotDisturbTile.java    From GravityBox with Apache License 2.0 5 votes vote down vote up
private Uri getTimeCondition() {
    try {
        Object condition = XposedHelpers.callStaticMethod(getZenModeConfigClass(), "toTimeCondition",
                mContext, mDuration, SysUiManagers.KeyguardMonitor.getCurrentUserId());
        return (Uri) XposedHelpers.getObjectField(condition, "id");
    } catch (Throwable t) {
        XposedBridge.log(t);
        return null;
    }
}
 
Example 17
Source File: HookHelper.java    From ConfessTalkKiller with GNU General Public License v3.0 4 votes vote down vote up
public static Object callStaticMethod(Class clazz, String methodName, Class<?>[] parameterTypes, Object... args) {
    return XposedHelpers.callStaticMethod((Class<?>) clazz, methodName, parameterTypes, args);
}
 
Example 18
Source File: ModStatusBar.java    From GravityBox with Apache License 2.0 4 votes vote down vote up
@Override
public void run() {
    XposedHelpers.callStaticMethod(Settings.System.class, "putIntForUser",
            mContext.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS, val, -2);
}
 
Example 19
Source File: Global.java    From OneTapVideoDownload with GNU General Public License v3.0 4 votes vote down vote up
public static Context getContext() {
    Class activityThreadClass = XposedHelpers.findClass("android.app.ActivityThread", null);
    Object activityThread = XposedHelpers.callStaticMethod(activityThreadClass, "currentActivityThread");
    return (Context) XposedHelpers.callMethod(activityThread, "getSystemContext");
}
 
Example 20
Source File: XHelper.java    From AideHelper with MIT License 2 votes vote down vote up
/**
 * 调用静态方法
 *
 * @param className 类名
 * @param methodName 方法名
 * @param args 参数
 * @return Object
 */
public static Object callStaticMethod(String className, String methodName, Object... args) {
  return XposedHelpers.callStaticMethod(findClass(className), methodName, args);
}