Java Code Examples for de.robv.android.xposed.XposedHelpers

The following examples show how to use de.robv.android.xposed.XposedHelpers. These examples are extracted from open source projects. 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 Project: WechatEnhancement   Source File: ADBlock.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
public void hook(XC_LoadPackage.LoadPackageParam lpparam) {
    XposedHelpers.findAndHookMethod(HookParams.getInstance().XMLParserClassName, lpparam.classLoader, HookParams.getInstance().XMLParserMethod, String.class, String.class, new XC_MethodHook() {
        @Override
        protected void beforeHookedMethod(MethodHookParam param) {
            try {
                if (!PreferencesUtils.isADBlock())
                    return;

                if (param.args[1].equals("ADInfo"))
                    param.setResult(null);
            } catch (Error | Exception e) {
            }

        }
    });
}
 
Example 2
Source Project: GravityBox   Source File: Utils.java    License: Apache License 2.0 6 votes vote down vote up
public static void performSoftReboot() {
    try {
        Class<?> classSm = XposedHelpers.findClass("android.os.ServiceManager", null);
        Class<?> classIpm = XposedHelpers.findClass("android.os.IPowerManager.Stub", null);
        IBinder b = (IBinder) XposedHelpers.callStaticMethod(
                classSm, "getService", Context.POWER_SERVICE);
        Object ipm = XposedHelpers.callStaticMethod(classIpm, "asInterface", b);
        XposedHelpers.callMethod(ipm, "crash", "Hot reboot");
    } catch (Throwable t) {
        try {
            SystemProp.set("ctl.restart", "surfaceflinger");
            SystemProp.set("ctl.restart", "zygote");
        } catch (Throwable t2) {
            XposedBridge.log(t);
            XposedBridge.log(t2);
        }
    }
}
 
Example 3
Source Project: GravityBox   Source File: ModDownloadProvider.java    License: Apache License 2.0 6 votes vote down vote up
public static void init(final XSharedPreferences prefs, final ClassLoader classLoader) {
    try {
        final Class<?> classDownloadService = XposedHelpers.findClass(CLASS_DOWNLOAD_SERVICE, classLoader);

        XposedHelpers.findAndHookMethod(classDownloadService, "updateLocked", new XC_MethodHook() {
            @Override
            protected void afterHookedMethod(MethodHookParam param) throws Throwable {
                final boolean isActive = (Boolean) param.getResult();
                if (mIsActive != isActive) { 
                    mIsActive = isActive;
                    if (DEBUG) log("Download state changed; active=" + mIsActive);
                    final Context context = (Context) param.thisObject;
                    Intent intent = new Intent(ACTION_DOWNLOAD_STATE_CHANGED);
                    intent.putExtra(EXTRA_ACTIVE, mIsActive);
                    context.sendBroadcast(intent);
                }
            }
        });
    } catch (Throwable t) {
        XposedBridge.log(t);
    }
}
 
Example 4
Source Project: GravityBox   Source File: MtkFixDevOptions.java    License: Apache License 2.0 6 votes vote down vote up
public static void init(final XSharedPreferences prefs, final ClassLoader classLoader) {
    try {
        final Class<?> classDevSettings = XposedHelpers.findClass(CLASS_DEV_SETTINGS, classLoader);

        if (DEBUG) log("hooking DeveloperSettings.onCreate method");
        XposedHelpers.findAndHookMethod(classDevSettings, "onCreate", Bundle.class, new XC_MethodHook() {
            @Override
            protected void beforeHookedMethod(final MethodHookParam param) throws Throwable {
                PreferenceFragment pf = (PreferenceFragment) param.thisObject;
                mResId = pf.getResources().getIdentifier("development_prefs", "xml", PACKAGE_NAME);
                if (DEBUG) log("mResId=" + mResId);
            }
        });
    }
    catch (Throwable t) {
        XposedBridge.log(t);
    }
}
 
Example 5
@SuppressWarnings("unchecked")
private void addSensors(final LoadPackageParam lpparam) {
    if (Build.VERSION.SDK_INT >= 24)
        XposedHelpers.findAndHookConstructor("android.hardware.SystemSensorManager",
                lpparam.classLoader, android.content.Context.class, android.os.Looper.class,
                new fr.frazew.virtualgyroscope.hooks.constructor.API24(lpparam));
    else if (Build.VERSION.SDK_INT == 23)
        XposedHelpers.findAndHookConstructor("android.hardware.SystemSensorManager",
                lpparam.classLoader, android.content.Context.class, android.os.Looper.class,
                new fr.frazew.virtualgyroscope.hooks.constructor.API23(lpparam));
    else if (Build.VERSION.SDK_INT >= 18)
        XposedHelpers.findAndHookConstructor("android.hardware.SystemSensorManager",
                lpparam.classLoader, android.content.Context.class, android.os.Looper.class,
                new fr.frazew.virtualgyroscope.hooks.constructor.API18(lpparam));
    else if (Build.VERSION.SDK_INT >= 16)
        XposedHelpers.findAndHookConstructor("android.hardware.SystemSensorManager",
                lpparam.classLoader, android.os.Looper.class,
                new fr.frazew.virtualgyroscope.hooks.constructor.API16(lpparam));
    else XposedBridge.log("VirtualSensor: Using SDK version " + Build.VERSION.SDK_INT + ", this is not supported");
}
 
Example 6
Source Project: GravityBox   Source File: PieSysInfo.java    License: Apache License 2.0 6 votes vote down vote up
private String getWifiSsid() {
    String ssid = null;
    final WifiManager wifiManager = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE);
    if (wifiManager != null) {
        final WifiInfo connectionInfo = wifiManager.getConnectionInfo();
        if (connectionInfo != null) {
            final Object wifiSsid = XposedHelpers.callMethod(connectionInfo, "getWifiSsid");
            if (wifiSsid != null) {
                ssid = wifiSsid.toString();
            }
        }
    }
    if (TextUtils.isEmpty(ssid)) {
        int resId = mContext.getResources().getIdentifier(
                "quick_settings_wifi_not_connected", "string", PieController.PACKAGE_NAME);
        // TODO: translate
        ssid = resId == 0 ? "Not connected" : mContext.getString(resId);
    }
    return ssid;
}
 
Example 7
@Override
protected void handleLoadAnyPackage(LoadPackageParam lpparam) throws Throwable
{
	try
	{
		XposedHelpers.findAndHookMethod("android.app.AppOpsManager",
				lpparam.classLoader, "opToSwitch", int.class, new XC_MethodHook() {

					@Override
					protected void beforeHookedMethod(MethodHookParam param) throws Throwable
					{
						param.setResult(param.args[0]);
					}
		});
	}
	catch(Throwable t)
	{
		debug(t);
	}
}
 
Example 8
Source Project: AppOpsXposed   Source File: XUtils.java    License: 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 9
Source Project: renrenpay-android   Source File: AlipayHook.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void hookCreatQr() throws Error, Exception {
    XposedHelpers.findAndHookMethod("com.alipay.mobile.payee.ui.PayeeQRSetMoneyActivity", mAppClassLoader, "a",
            XposedHelpers.findClass("com.alipay.transferprod.rpc.result.ConsultSetAmountRes", mAppClassLoader), new XC_MethodHook() {
                @Override
                protected void afterHookedMethod(MethodHookParam param) throws Throwable {
                    try {
                        String money = (String) ReflecUtils.findField(param.thisObject.getClass(), String.class
                                , 0, false).get(param.thisObject);
                        String payurl = (String) XposedHelpers.findField(param.args[0].getClass(),
                                "qrCodeUrl").get(param.args[0]);
                        Class<?> auinputbox = XposedHelpers.findClass("com.alipay.mobile.antui.input.AUInputBox", mAppClassLoader);
                        Object markObject = ReflecUtils.findField(param.thisObject.getClass(), auinputbox
                                , 1, false).get(param.thisObject);
                        String mark = (String) XposedHelpers.callMethod(markObject, "getUbbStr");
                        Log.d(TAG, "支付宝生成二维码:" + money + "|" + mark + "|" + payurl);
                    } catch (Error | Exception ignore) {
                        Log.d(TAG, "hookCreatQr error -> " + ignore.getMessage());
                    }
                }
            });
}
 
Example 10
Source Project: mhzs   Source File: ClearMainAdPlugin.java    License: MIT License 6 votes vote down vote up
@Override
    public void run(ClassLoader classLoader) throws Throwable {

        /**
         * 在com.mh.movie.core.mvp.ui.widget.MovieCardView中
         * 替换setShowBanner方法,去掉广告
         */
        // TODO: 2019/3/6 0006 VXP/EXP TOO SHORT METHOD
//        XposedHelpers.findAndHookMethod(movieCardViewClassName, classLoader, "setShowBanner", List.class, new XC_MethodReplacement() {
//            @Override
//            protected Object replaceHookedMethod(MethodHookParam methodHookParam) throws Throwable {
//                LogUtil.e("hook setShowBanner method!");
//                return null;
//            }
//        });

        XposedHelpers.findAndHookMethod(movieCardViewClassName, classLoader, "c", new XC_MethodReplacement() {
            @Override
            protected Object replaceHookedMethod(MethodHookParam methodHookParam) throws Throwable {
                LogUtil.e("hook setShowBanner2 method!");
                return null;
            }
        });

    }
 
Example 11
Source Project: GravityBox   Source File: ModDialer24.java    License: Apache License 2.0 6 votes vote down vote up
private static ClassInfo resolveCallCardFragment(ClassLoader cl) {
    ClassInfo info = null;
    String[] CLASS_NAMES = new String[] { "com.android.incallui.CallCardFragment", "ayv" };
    String[] METHOD_NAMES = new String[] { "setDrawableToImageView" };
    for (String className : CLASS_NAMES) {
        Class<?> clazz = XposedHelpers.findClassIfExists(className, cl);
        if (clazz == null || !Fragment.class.isAssignableFrom(clazz))
            continue;
        info = new ClassInfo(clazz);
        for (String methodName : METHOD_NAMES) {
            if (methodName.equals("setDrawableToImageView")) {
                for (String realMethodName : new String[] { methodName, "b" }) {
                    Method m = XposedHelpers.findMethodExactIfExists(clazz, realMethodName,
                        Drawable.class);
                    if (m != null) {
                        info.methods.put(methodName, realMethodName);
                        break;
                    }
                }
            }
        }
    }
    return info;
}
 
Example 12
Source Project: douyin   Source File: HookCommentUI.java    License: Apache License 2.0 6 votes vote down vote up
public static void hookCommentUI(ClassLoader classLoader){
    XposedHelpers.findAndHookMethod(Version.VideoCommentDialogFragment2,
            classLoader,
            "onCreateView",
            LayoutInflater.class,
            ViewGroup.class,
            Bundle.class,
            new XC_MethodHook() {
                @Override
                protected void afterHookedMethod(MethodHookParam param) throws Throwable {
                    Object o = param.getResult();
                    Vlog.log("评论界面View>>"+o);
                    LinearLayout linearLayout = (LinearLayout) param.getResult();
                    if (linearLayout != null){
                        MyLinear myLinear = new MyLinear(HookAwemeUI.globalActivity);
                        linearLayout.addView(myLinear, 0);
                    }
                }
            }
    );
}
 
Example 13
public void hook(final XC_LoadPackage.LoadPackageParam lpparam) {

        if (!PreferencesHelper.isDisableXposedEnabled()) {
            return;
        }

        XC_MethodHook disableXposedHook = new XC_MethodHook() {
            @Override
            protected void beforeHookedMethod(MethodHookParam param) {
                if (param.args[0].equals("disableHooks") || param.args[0].equals("sHookedMethodCallbacks")) {
                    param.setThrowable(new NoClassDefFoundError());
                    LogUtils.logRecord("AntiXposedHook Success: " + lpparam.packageName);
                }
            }
        };

        XposedHelpers.findAndHookMethod(Class.class, "getDeclaredField", String.class, disableXposedHook);
    }
 
Example 14
Source Project: VirtualSensor   Source File: API24.java    License: GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
protected void beforeHookedMethod(XC_MethodHook.MethodHookParam param) throws Throwable {
    SensorEventListener listener = (SensorEventListener) XposedHelpers.getObjectField(param.thisObject, "mListener");
    int handle = (int) param.args[0];
    Object mgr = XposedHelpers.getObjectField(param.thisObject, "mManager");
    HashMap<Integer, Sensor> sensors = (HashMap<Integer, Sensor>) XposedHelpers.getObjectField(mgr, "mHandleToSensor");
    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 15
Source Project: xposed-aweme   Source File: AweMeHook.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 移除推荐的广告
 * @param feedList
 * @return
 */
private Object removeFeedAd(Object feedList) {

    if (feedList == null) return null;

    try {
        List<Object> newItems = new ArrayList<>();
        List<Object> items = (List<Object>) XposedHelpers
                .getObjectField(feedList, mVersionConfig.fieldFeedListItems);

        for (Object item : items) {
            // 只添加非广告视频
            if (!isAd(item)) newItems.add(item);
        }

        // 重新设置列表数据
        XposedHelpers.setObjectField(feedList,
                mVersionConfig.fieldFeedListItems, newItems);
    } catch (Throwable tr) {
        Alog.e("移除广告异常", tr);
    }
    return feedList;
}
 
Example 16
@Override
public void onReceive(Context context, Intent intent) {
    if (intent.getAction().contentEquals(CONSULT_SET_AMOUNT_RES_STRING_INTENT_FILTER_ACTION)) {
        String qr_money = intent.getStringExtra("qr_money");
        String beiZhu = intent.getStringExtra("beiZhu");
        log("AlipayBroadcast onReceive " + qr_money + " " + beiZhu + "\n");
        if (!qr_money.contentEquals("")) {
            Intent launcherIntent = new Intent(context, XposedHelpers.findClass("com.alipay.mobile.payee.ui.PayeeQRSetMoneyActivity", Main.launcherActivity.getApplicationContext().getClassLoader()));
            launcherIntent.putExtra("qr_money", qr_money);
            launcherIntent.putExtra("beiZhu", beiZhu);
            Main.launcherActivity.startActivity(launcherIntent);
        }
    } else if (intent.getAction().contentEquals(COOKIE_STR_INTENT_FILTER_ACTION)) {
        String cookieStr = Main.getCookieStr();
        log("AlipayBroadcast onReceive getCookieStr " + cookieStr + "\n");
        Intent broadCastIntent = new Intent();
        broadCastIntent.putExtra("cookieStr", cookieStr);
        broadCastIntent.setAction(PluginBroadcast.COOKIE_STR_INTENT_FILTER_ACTION);
        context.sendBroadcast(broadCastIntent);
    }
}
 
Example 17
Source Project: XQuickEnergy   Source File: XposedHook.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Throwable
{
 if("pansong291.xposed.quickenergy".equals(lpparam.packageName))
 {
  XposedHelpers.findAndHookMethod(MainActivity.class.getName(), lpparam.classLoader, "setModuleActive", boolean.class, new XC_MethodHook()
   {
    @Override
    protected void beforeHookedMethod(MethodHookParam param) throws Throwable
    {
     param.args[0] = true;
    }
   });
 }

 if(ClassMember.com_eg_android_AlipayGphone.equals(lpparam.packageName))
 {
  Log.i(TAG, lpparam.packageName);
  hookLauncherService(lpparam.classLoader);
  hookRpcCall(lpparam.classLoader);
 }
}
 
Example 18
Source Project: QNotified   Source File: HookEntry.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
public void handleLoadPackage(final XC_LoadPackage.LoadPackageParam lpparam) throws Throwable {
    if (R.string.res_inject_success >>> 24 == 0x7f) {
        XposedBridge.log("package id must NOT be 0x7f, reject loading...");
        return;
    }
    //dumpProcessInfo(lpparam.isFirstApplication);
    switch (lpparam.packageName) {
        case PACKAGE_NAME_SELF:
            XposedHelpers.findAndHookMethod("nil.nadph.qnotified.util.Utils", lpparam.classLoader, "getActiveModuleVersion", XC_MethodReplacement.returnConstant(Utils.QN_VERSION_NAME));
            break;
        case PACKAGE_NAME_QQ:
        case PACKAGE_NAME_TIM:
            StartupHook.getInstance().doInit(lpparam.classLoader);
            break;
        case PACKAGE_NAME_QQ_INTERNATIONAL:
        case PACKAGE_NAME_QQ_LITE:
            //coming...
    }
}
 
Example 19
private Object fakeAMapLocationObject(Object object) {
    reload();
    if (fakeLocation) {
        if (!fakeLocationTime || isAfterSetTime(startTime)) {
            XposedHelpers.callMethod(object, "setLatitude", Double.valueOf(latitude));
            XposedHelpers.callMethod(object, "setLongitude", Double.valueOf(longitude));
        }
    }
    return object;
}
 
Example 20
Source Project: GravityBox   Source File: ModTrustManager.java    License: Apache License 2.0 5 votes vote down vote up
private static boolean isTrustAllowedForUser(int userId) {
    if (hasStrongAuthTracker()) {
        Object authTracker = XposedHelpers.getObjectField(
                mTrustManager, "mStrongAuthTracker");
        return (boolean) XposedHelpers.callMethod(authTracker,
                "isTrustAllowedForUser", userId);
    } else {
        return (boolean) XposedHelpers.callMethod(mTrustManager,
                "getUserHasAuthenticated", userId);
    }
}
 
Example 21
Source Project: NekoSMS   Source File: SmsHandlerHook.java    License: GNU General Public License v3.0 5 votes vote down vote up
private void deleteFromRawTable24(Object smsHandler, Object smsReceiver) {
    Xlog.i("Removing raw SMS data from database for Android v24+");
    callDeclaredMethod(SMS_HANDLER_CLASS, smsHandler, "deleteFromRawTable",
        /*     deleteWhere */ XposedHelpers.getObjectField(smsReceiver, "mDeleteWhere"),
        /* deleteWhereArgs */ XposedHelpers.getObjectField(smsReceiver, "mDeleteWhereArgs"),
        /*      deleteType */ MARK_DELETED);
}
 
Example 22
Source Project: wifi-password-android   Source File: Patch.java    License: Apache License 2.0 5 votes vote down vote up
private static boolean tryHookConstructor(Class<?> clazz, String msg,
        Object... parameterTypesAndCallback) {
    try {
        XposedHelpers.findAndHookConstructor(clazz, parameterTypesAndCallback);
    } catch (Error e) {
        return false;
    }

    XposedBridge.log(msg + " success");
    return true;
}
 
Example 23
public BaseDTOEntity(ClassLoader classLoader, ContextWrapper contextWrapper) {
    try {
        Class<?> TicketNetRequest = XposedHelpers.findClass("com.MobileTicket.common.rpc.TicketNetRequest",
                classLoader);
        BaseDTO = XposedHelpers.findClass("com.MobileTicket.common.rpc.model.BaseDTO", classLoader);
        targetObject = XposedHelpers.callStaticMethod(TicketNetRequest, "getBaseDTO",
                new Class<?>[]{ContextWrapper.class}, contextWrapper);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example 24
Source Project: GravityBox   Source File: CellularTile.java    License: Apache License 2.0 5 votes vote down vote up
private boolean hasField(Object o, String fieldName) {
    try {
        XposedHelpers.findField(o.getClass(), fieldName);
        return true;
    } catch (NoSuchFieldError e) {
        return false;
    }
}
 
Example 25
Source Project: GravityBox   Source File: StatusbarSignalCluster.java    License: Apache License 2.0 5 votes vote down vote up
protected void setNetworkController(Object networkController) {
    final ClassLoader classLoader = mView.getClass().getClassLoader();
    final Class<?> networkCtrlCbClass = XposedHelpers.findClass("com.android.systemui.statusbar.policy.NetworkController.SignalCallback", classLoader);
    mNetworkControllerCallback = Proxy.newProxyInstance(classLoader,
            new Class<?>[]{networkCtrlCbClass}, new NetworkControllerCallback());
    XposedHelpers.callMethod(networkController, "addSignalCallback",
            mNetworkControllerCallback);
    if (DEBUG) log("setNetworkController: callback registered");
}
 
Example 26
Source Project: GravityBox   Source File: ModDisplay.java    License: 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 27
Source Project: GravityBox   Source File: BluetoothTetheringTile.java    License: Apache License 2.0 5 votes vote down vote up
private boolean isTetheringOn() {
    try {
        Object pan = mBluetoothPan.get();
        return (pan != null &&
                (boolean) XposedHelpers.callMethod(pan, "isTetheringOn"));
    } catch (Throwable t) {
        XposedBridge.log(t);
        return false;
    }
}
 
Example 28
Source Project: Cracker   Source File: Hook.java    License: Apache License 2.0 5 votes vote down vote up
private void hookUncaughtException(final Application application) {
    Class<?> c = Thread.getDefaultUncaughtExceptionHandler().getClass();
    XposedHelpers.findAndHookMethod(c, "uncaughtException", Thread.class, Throwable.class, new XC_MethodHook() {
        @Override
        protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
            super.beforeHookedMethod(param);

            Intent intent = new Intent(INTENT_ACTION);
            intent.putExtra(INTENT_PACKAGE_NAME, application.getPackageName());
            intent.putExtra(INTENT_TIME, System.currentTimeMillis());
            intent.putExtra(INTENT_THROWABLE, (Throwable) param.args[1]);
            application.sendBroadcast(intent);
        }
    });
}
 
Example 29
Source Project: GravityBox   Source File: AospTile.java    License: 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 30
Source Project: GravityBox   Source File: ModDisplay.java    License: 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);
    }
}