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

The following examples show how to use de.robv.android.xposed.XposedHelpers#setBooleanField() . 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: 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 2
Source File: XposedHelpersWraper.java    From MIUIAnesthetist with MIT License 5 votes vote down vote up
public static void setBooleanField(Object obj, String fieldName, boolean value) {
    try {
        XposedHelpers.setBooleanField(obj, fieldName, value);
    } catch (Throwable t) {
        log(t);
    }
}
 
Example 3
Source File: ModLedControl.java    From GravityBox with Apache License 2.0 5 votes vote down vote up
@Override
protected void beforeHookedMethod(final MethodHookParam param) throws Throwable {
    if (mScreenOnDueToActiveScreen) {
        try {
            XposedHelpers.setBooleanField(param.thisObject, "mScreenOn", false);
            if (DEBUG) log("updateLightsLocked: Screen on due to active screen - pretending it's off");
        } catch (Throwable t) {
            XposedBridge.log(t);
        }
    }
}
 
Example 4
Source File: KeyguardStateMonitor.java    From GravityBox with Apache License 2.0 5 votes vote down vote up
public void setKeyguardDisabled(boolean disabled) {
    try {
        mIsKeyguardDisabled = disabled;
        XposedHelpers.callMethod(mMediator, "setKeyguardEnabled", !disabled);
        if (mIsKeyguardDisabled) {
            XposedHelpers.setBooleanField(mMediator, "mNeedToReshowWhenReenabled", false);
        }
    } catch (Throwable t) {
        XposedBridge.log(t);
    }
}
 
Example 5
Source File: StatusbarBattery.java    From GravityBox with Apache License 2.0 5 votes vote down vote up
public void setShowPercentage(boolean showPercentage) {
    if (mBattery != null) {
        try {
            XposedHelpers.setBooleanField(getDrawable(), "mShowPercent", showPercentage);
            getDrawable().invalidateSelf();
            mBattery.invalidate();
        } catch (Throwable t) {
            log("Error setting percentage: " + t.getMessage());
        }
    }
}
 
Example 6
Source File: QsTile.java    From GravityBox with Apache License 2.0 5 votes vote down vote up
public void applyTo(Object state) {
    XposedHelpers.setBooleanField(state, "visible", visible);
    XposedHelpers.setObjectField(state, "icon", getResourceIcon());
    XposedHelpers.setObjectField(state, "label", label);
    XposedHelpers.setBooleanField(state, "autoMirrorDrawable", autoMirrorDrawable);
    XposedHelpers.setBooleanField(state, "value", booleanValue);
}
 
Example 7
Source File: AospTile.java    From GravityBox with Apache License 2.0 5 votes vote down vote up
@Override
public void handleUpdateState(Object state, Object arg) {
    final boolean visible = mEnabled &&
            (!mLocked || !mKgMonitor.isShowing()) &&
            (!mLockedOnly || mKgMonitor.isShowing()) &&
            (!mSecured || !(mKgMonitor.isShowing() && mKgMonitor.isLocked()));
    XposedHelpers.setBooleanField(state, "visible", visible);
}
 
Example 8
Source File: ModLockscreen.java    From GravityBox with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings({"unchecked", "rawtypes"})
private static void beforeLockPatternDraw(final Class<? extends Enum> displayModeEnum, final Object thisObject) {
    final Object patternDisplayMode = XposedHelpers.getObjectField(thisObject, "mPatternDisplayMode");
    final Boolean inStealthMode = XposedHelpers.getBooleanField(thisObject, "mInStealthMode");

    if (!mPrefs.getBoolean(GravityBoxSettings.PREF_KEY_LOCKSCREEN_SHOW_PATTERN_ERROR, true) &&
            mPatternDisplayMode == null && patternDisplayMode == Enum.valueOf(displayModeEnum, "Wrong")) {
        mInStealthMode = inStealthMode;
        mPatternDisplayMode = patternDisplayMode;
        XposedHelpers.setBooleanField(thisObject, "mInStealthMode", true);
        XposedHelpers.setObjectField(thisObject, "mPatternDisplayMode", Enum.valueOf(displayModeEnum, "Correct"));
    } else {
        mPatternDisplayMode = null;
    }
}
 
Example 9
Source File: ModLockscreen.java    From GravityBox with Apache License 2.0 5 votes vote down vote up
private static void afterLockPatternDraw(final Object thisObject) {
    if (null != mPatternDisplayMode) {
        XposedHelpers.setBooleanField(thisObject, "mInStealthMode", mInStealthMode);
        XposedHelpers.setObjectField(thisObject, "mPatternDisplayMode", mPatternDisplayMode);
        mInStealthMode = false;
        mPatternDisplayMode = null;
    }
}
 
Example 10
Source File: ModHwKeys.java    From GravityBox with Apache License 2.0 5 votes vote down vote up
private static void doubleHomeHook(XC_MethodHook.MethodHookParam param) {
    if (!isTaskLocked() && getActionFor(HwKeyTrigger.HOME_DOUBLETAP).actionId !=
            GravityBoxSettings.HWKEY_ACTION_DEFAULT) {
        XposedHelpers.setBooleanField(param.thisObject, "mHomeConsumed", true);
        performAction(HwKeyTrigger.HOME_DOUBLETAP);
        param.setResult(null);
    }
}
 
Example 11
Source File: ModHwKeys.java    From GravityBox with Apache License 2.0 5 votes vote down vote up
private static void adjustLongPressPowerWhenNonInteractive() {
    try {
        if (mSupportLongPressPowerWhenNonInteractiveOrig == null) {
            mSupportLongPressPowerWhenNonInteractiveOrig =
                    XposedHelpers.getBooleanField(mPhoneWindowManager,
                            "mSupportLongPressPowerWhenNonInteractive");
        }
        XposedHelpers.setBooleanField(mPhoneWindowManager,
                "mSupportLongPressPowerWhenNonInteractive",
                mLockscreenTorch == GravityBoxSettings.HWKEY_TORCH_POWER_LONGPRESS ?
                        true : mSupportLongPressPowerWhenNonInteractiveOrig);
    } catch (Throwable t) {
        XposedBridge.log(t);
    }
}
 
Example 12
Source File: ModDisplay.java    From GravityBox with Apache License 2.0 4 votes vote down vote up
private static void updateAutobrightnessConfig(int[] lux, int[] brightness) {
    if (mDisplayPowerController == null || mContext == null) return;

    if (DEBUG) log("updateAutobrightnessConfig called");
    Resources res = mContext.getResources();
    boolean mtkVirtualValuesSupport = false;
    boolean mtkVirtualValues = false;

    int screenBrightnessDim = res.getInteger(res.getIdentifier(
            "config_screenBrightnessDim", "integer", "android"));
    int screenBrightnessMinimum = res.getInteger(res.getIdentifier(
            "config_screenBrightnessSettingMinimum", "integer", "android"));
    screenBrightnessMinimum = Math.min(screenBrightnessDim, screenBrightnessMinimum);

    boolean useSwAutobrightness = XposedHelpers.getBooleanField(
            mDisplayPowerController, "mUseSoftwareAutoBrightnessConfig");

    if (useSwAutobrightness) {
        // brightness array must have one more element than lux array
        int[] brightnessAdj = new int[lux.length + 1];
        for (int i = 0; i < brightnessAdj.length; i++) {
            if (i < brightness.length) {
                brightnessAdj[i] = brightness[i];
            } else {
                brightnessAdj[i] = 255;
            }
        }
        if (DEBUG) log("updateAutobrightnessConfig: lux=" + Utils.intArrayToString(lux) +
                "; brightnessAdj=" + Utils.intArrayToString(brightnessAdj));

        if (Utils.isMtkDevice()) {
            try {
                mtkVirtualValues = (boolean) XposedHelpers.getStaticBooleanField(
                        mDisplayPowerController.getClass(), "MTK_ULTRA_DIMMING_SUPPORT");
                int resId = res.getIdentifier("config_screenBrightnessVirtualValues",
                        "bool", "android");
                if (resId != 0) {
                    mtkVirtualValues &= res.getBoolean(resId);
                }
                mtkVirtualValuesSupport = true;
                if (DEBUG) log("MTK brightness virtual values: " + mtkVirtualValues);
            } catch (Throwable t) {
                if (DEBUG) log("Couldn't detect MTK virtual values feature");
            }
        }

        Object autoBrightnessSpline = mtkVirtualValuesSupport ? XposedHelpers.callMethod(
                mDisplayPowerController, "createAutoBrightnessSpline",
                lux, brightnessAdj, mtkVirtualValues) :
                XposedHelpers.callMethod(mDisplayPowerController,
                        "createAutoBrightnessSpline", lux, brightnessAdj);
        if (autoBrightnessSpline != null) {
            Object abrCtrl = XposedHelpers.getObjectField(mDisplayPowerController,
                    "mAutomaticBrightnessController");
            XposedHelpers.setObjectField(abrCtrl,
                    "mScreenAutoBrightnessSpline", autoBrightnessSpline);
            if (brightnessAdj[0] < screenBrightnessMinimum) {
                screenBrightnessMinimum = brightnessAdj[0];
            }
        } else {
            XposedHelpers.setBooleanField(mDisplayPowerController, "mUseSoftwareAutoBrightnessConfig", false);
            log("Error computing auto-brightness spline: lux=" + Utils.intArrayToString(lux) +
                    "; brightnessAdj=" + Utils.intArrayToString(brightnessAdj));
        }
    }

    int screenBrightnessRangeMinimum = mtkVirtualValuesSupport ?
            (Integer) XposedHelpers.callMethod(mDisplayPowerController, "clampAbsoluteBrightness",
                    screenBrightnessMinimum, mtkVirtualValues) :
            (Integer) XposedHelpers.callMethod(
                    mDisplayPowerController, "clampAbsoluteBrightness", screenBrightnessMinimum);
    XposedHelpers.setIntField(mDisplayPowerController, "mScreenBrightnessRangeMinimum",
            screenBrightnessRangeMinimum);

    if (DEBUG) log("Autobrightness config updated");
}
 
Example 13
Source File: ModExpandedDesktop.java    From GravityBox with Apache License 2.0 4 votes vote down vote up
private static void setBool(String field, boolean value) {
    XposedHelpers.setBooleanField(mPhoneWindowManager, field, value);
}