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

The following examples show how to use de.robv.android.xposed.XposedHelpers#getSurroundingThis() . 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: ModDisplay.java    From GravityBox with Apache License 2.0 6 votes vote down vote up
private static void updateButtonBacklight(boolean isScreenOn) {
    if (mLight == null || (mButtonBacklightNotif && mPendingNotif)) return;

    try {
        Integer color = null;
        if (mButtonBacklightMode.equals(GravityBoxSettings.BB_MODE_ALWAYS_ON)) {
            color = isScreenOn ? 0xff6e6e6e : 0;
        } else if (mButtonBacklightMode.equals(GravityBoxSettings.BB_MODE_DISABLE)) {
            color = 0;
        } else if (!isScreenOn) {
            color = 0;
        }

        if (color != null) {
            Object ls = XposedHelpers.getSurroundingThis(mLight);
            long np = XposedHelpers.getLongField(ls, "mNativePointer");
            XposedHelpers.callMethod(ls, "setLight_native",
                    np, LIGHT_ID_BUTTONS, color, 0, 0, 0, 0);
        }
    } catch (Throwable t) {
        XposedBridge.log(t);
    }
}
 
Example 2
Source File: XposedHelpersWraper.java    From MIUIAnesthetist with MIT License 5 votes vote down vote up
public static Object getSurroundingThis(Object obj) {
    try {
        return XposedHelpers.getSurroundingThis(obj);
    } catch (Throwable t) {
        log(t);
    }
    return null;
}
 
Example 3
Source File: ModDisplay.java    From GravityBox with Apache License 2.0 5 votes vote down vote up
private static void resetLight(int lightId) {
    if (mLight == null) return;

    try {
        Object ls = XposedHelpers.getSurroundingThis(mLight);
        Object[] lights = (Object[]) XposedHelpers.getObjectField(ls, "mLights");
        XposedHelpers.callMethod(lights[lightId],
                "setLightLocked", 0, 0, 0, 0, 0);
    } catch (Throwable t) {
        XposedBridge.log(t);
    }
}
 
Example 4
Source File: ModDisplay.java    From GravityBox with Apache License 2.0 5 votes vote down vote up
@Override
public void run() {
    if (mLight == null) return;
    try {
        Object ls = XposedHelpers.getSurroundingThis(mLight);
        long np = XposedHelpers.getLongField(ls, "mNativePointer");
        if (!mPendingNotif) {
            mHandler.removeCallbacks(this);
            mPendingNotifColor =
                    mButtonBacklightMode.equals(GravityBoxSettings.BB_MODE_ALWAYS_ON)
                            && mPm.isInteractive() ? 0xff6e6e6e : 0;
            XposedHelpers.callMethod(ls, "setLight_native",
                    np, LIGHT_ID_BUTTONS, mPendingNotifColor, 0, 0, 0, 0);
        } else {
            if (mPendingNotifColor == 0) {
                mPendingNotifColor = 0xff6e6e6e;
                XposedHelpers.callMethod(ls, "setLight_native",
                        np, LIGHT_ID_BUTTONS, mPendingNotifColor, 0, 0, 0, 0);
                mHandler.postDelayed(mPendingNotifRunnable, 500);
            } else {
                mPendingNotifColor = 0;
                XposedHelpers.callMethod(ls, "setLight_native",
                        np, LIGHT_ID_BUTTONS, mPendingNotifColor, 0, 0, 0, 0);
                mHandler.postDelayed(mPendingNotifRunnable, mPulseNotifDelay);
            }
        }
    } catch (Exception e) {
        XposedBridge.log(e);
    }
}
 
Example 5
Source File: FixWakeLock.java    From AppOpsXposed with GNU General Public License v3.0 5 votes vote down vote up
private static Context getContextFromThis(Object object)
{
	final Object location = Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ?
			XposedHelpers.getSurroundingThis(object) : object;

	return (Context) XposedHelpers.getObjectField(location, "mContext");
}