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

The following examples show how to use de.robv.android.xposed.XposedHelpers#getStaticObjectField() . 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: LockscreenPinScrambler.java    From GravityBox with Apache License 2.0 6 votes vote down vote up
private void changeDigit(Object key, int digit) {
    XposedHelpers.setIntField(key, "mDigit", digit);
    ((TextView)XposedHelpers.getObjectField(key, "mDigitText"))
        .setText(Integer.toString(digit));

    TextView kt = (TextView) XposedHelpers.getObjectField(
            key, "mKlondikeText");
    kt.setText("");
    kt.setVisibility(View.INVISIBLE);
    if (digit >= 0) {
        String[] sKlondike = (String[]) XposedHelpers.getStaticObjectField(
                key.getClass(), "sKlondike");
        if (sKlondike != null && sKlondike.length > digit) {
            String klondike = sKlondike[digit];
            if (klondike.length() > 0) {
                kt.setText(klondike);
                kt.setVisibility(View.VISIBLE);
            }
        }
    }

    ((View)key).setContentDescription(Integer.toString(digit));
}
 
Example 2
Source File: API18.java    From VirtualSensor with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
protected void beforeHookedMethod(XC_MethodHook.MethodHookParam param) throws Throwable {
    Object listener = XposedHelpers.getObjectField(param.thisObject, "mListener");
    int handle = (int) param.args[0];
    Object mgr = XposedHelpers.getObjectField(param.thisObject, "mManager");
    SparseArray<Sensor> sensors = (SparseArray<Sensor>) XposedHelpers.getStaticObjectField(mgr.getClass(), "sHandleToSensor");
    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 3
Source File: API18.java    From VirtualSensor with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
    super.afterHookedMethod(param);
    Object sSensorModuleLock = XposedHelpers.getStaticObjectField(param.thisObject.getClass(), "sSensorModuleLock");

    synchronized (sSensorModuleLock) {
        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());
    }
}
 
Example 4
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 5
Source File: XposedHelpersWraper.java    From MIUIAnesthetist with MIT License 5 votes vote down vote up
public static Object getStaticObjectField(Class<?> clazz, String fieldName) {
    try {
        return XposedHelpers.getStaticObjectField(clazz, fieldName);
    } catch (Throwable t) {
        log(t);
    }
    return null;
}
 
Example 6
Source File: RetalDriverApplication.java    From ratel with Apache License 2.0 4 votes vote down vote up
public static Object currentActivityThread() {
    return XposedHelpers.getStaticObjectField(XposedHelpers.findClass("android.app.ActivityThread", RetalDriverApplication.class.getClassLoader()), "sCurrentActivityThread");
}
 
Example 7
Source File: MockSensorValuesModificationMethodApi18.java    From Sensor-Disabler with MIT License 4 votes vote down vote up
@SuppressWarnings("unchecked")
protected SparseArray<Sensor> getSensors(Object systemSensorManager) {
    return (SparseArray<Sensor>) XposedHelpers.getStaticObjectField(systemSensorManager.getClass(), "sHandleToSensor");
}