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

The following examples show how to use de.robv.android.xposed.XposedHelpers#newInstance() . 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: kikUtil.java    From XKik with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Generate a kik smiley type, currently beta
 *
 * @param smiley_class smiley manager class
 * @param title        smiley title
 * @param text         smiley text used to generate it, i.e <3
 * @param id           smiley id
 * @param installdate  smiley install ID
 * @return a smiley object
 */
static Object gen_smiley(Class smiley_class, String title, String text, String id, long installdate) {
    /*
    a = name
    b = id
    c and d = category/text
    e = is active
    f = ? (seems to always be true)
    g = bought time

    so constructor for it should be

    name,category,id,category,time
     */

    return XposedHelpers.newInstance(smiley_class, title, text, id, text, installdate);

}
 
Example 3
Source File: API16.java    From VirtualSensor with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
protected void afterHookedMethod(XC_MethodHook.MethodHookParam param) throws Throwable {
    super.afterHookedMethod(param);
    ArrayList sListeners = (ArrayList) XposedHelpers.getStaticObjectField(param.thisObject.getClass(), "sListeners");

    synchronized (sListeners) {
        ArrayList<Sensor> sFullSensorsList = (ArrayList<Sensor>) XposedHelpers.getStaticObjectField(param.thisObject.getClass(), "sFullSensorsList");
        SparseArray<Sensor> sHandleToSensor = (SparseArray<Sensor>) XposedHelpers.getStaticObjectField(param.thisObject.getClass(), "sHandleToSensor");

        XposedHelpers.findField(SystemSensorManagerHook.SYSTEM_SENSOR_MANAGER, "sFullSensorsList").setAccessible(true);
        XposedHelpers.findField(SystemSensorManagerHook.SYSTEM_SENSOR_MANAGER, "sHandleToSensor").setAccessible(true);

        this.mSystemSensorManagerHook.fillSensorLists(sFullSensorsList, sHandleToSensor);
        XposedHelpers.setStaticObjectField(param.thisObject.getClass(), "sHandleToSensor", sHandleToSensor.clone());
        XposedHelpers.setStaticObjectField(param.thisObject.getClass(), "sFullSensorsList", sFullSensorsList.clone());

        Object sPool = XposedHelpers.newInstance(this.SENSOR_EVENT_POOL, int.class, sHandleToSensor.size() * 2);
        XposedHelpers.setStaticObjectField(param.thisObject.getClass(), "sPool", sPool);
    }
}
 
Example 4
Source File: HookLocationFaker.java    From PokeFaker with MIT License 6 votes vote down vote up
public static List<GpsSatellite> fetchGpsSatellites() {
    if (cacheGpsSatelliteList == null) {
        cacheGpsSatelliteList = new ArrayList<>();
        for (FakeGpsSatellite fake: staticList) {
            GpsSatellite real = ((GpsSatellite) XposedHelpers.newInstance(GpsSatellite.class, fake.mPrn));
            XposedHelpers.setBooleanField(real, "mValid", fake.mValid);
            XposedHelpers.setBooleanField(real, "mUsedInFix", fake.mUsedInFix);
            XposedHelpers.setBooleanField(real, "mHasAlmanac", fake.mHasAlmanac);
            XposedHelpers.setBooleanField(real, "mHasEphemeris", fake.mHasEphemeris);
            XposedHelpers.setFloatField(real, "mSnr", fake.mSnr);
            XposedHelpers.setFloatField(real, "mElevation", fake.mElevation);
            XposedHelpers.setFloatField(real, "mAzimuth", fake.mAzimuth);
            cacheGpsSatelliteList.add(real);
        }
    }
    return cacheGpsSatelliteList;

}
 
Example 5
Source File: XposedHelpersWraper.java    From MIUIAnesthetist with MIT License 5 votes vote down vote up
public static Object newInstance(Class<?> clazz, Object... args) {
    try {
        return XposedHelpers.newInstance(clazz, args);
    } catch (Throwable t) {
        log(t);
    }
    return null;
}
 
Example 6
Source File: XposedHelpersWraper.java    From MIUIAnesthetist with MIT License 5 votes vote down vote up
public static Object newInstance(Class<?> clazz, Class<?>[] parameterTypes, Object... args) {
    try {
        return XposedHelpers.newInstance(clazz, parameterTypes, args);
    } catch (Throwable t) {
        log(t);
    }
    return null;
}
 
Example 7
Source File: AutoCommentHandler.java    From xposed-aweme with Apache License 2.0 3 votes vote down vote up
private void initAutoCommentHandler(HookManager hookManager) {

        ClassLoader classLoader = hookManager.getLoadPackageParam().classLoader;

        Class hClass = XposedHelpers.findClass(mVersionConfig.classCommentPublishPresenter, classLoader);
        Class gClass = XposedHelpers.findClass(mVersionConfig.classCommentPublishModel, classLoader);

        Object gObject = XposedHelpers.newInstance(gClass);

        mCommentPublishPresenter = XposedHelpers.newInstance(hClass);
        XposedHelpers.callMethod(mCommentPublishPresenter, mVersionConfig.methodSetCommentListener, gObject);
    }
 
Example 8
Source File: XHelper.java    From AideHelper with MIT License 2 votes vote down vote up
/**
 * 创建一个实例
 *
 * @param className 类名
 * @param args 类参数
 * @return Object
 */
public static Object newInstance(String className, Object... args) {
  return XposedHelpers.newInstance(findClass(className), args);
}