Java Code Examples for de.robv.android.xposed.XposedBridge#log()

The following examples show how to use de.robv.android.xposed.XposedBridge#log() . 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: ModSettings.java    From GravityBox with Apache License 2.0 6 votes vote down vote up
public static void initPackageResources(final XSharedPreferences prefs, final InitPackageResourcesParam resparam) {
    try {
        XModuleResources modRes = XModuleResources.createInstance(GravityBox.MODULE_PATH, resparam.res);
        resparam.res.setReplacement(PACKAGE_NAME, "array", "window_animation_scale_entries",
                modRes.fwd(R.array.window_animation_scale_entries));
        resparam.res.setReplacement(PACKAGE_NAME, "array", "window_animation_scale_values",
                modRes.fwd(R.array.window_animation_scale_values));
        resparam.res.setReplacement(PACKAGE_NAME, "array", "transition_animation_scale_entries",
                modRes.fwd(R.array.transition_animation_scale_entries));
        resparam.res.setReplacement(PACKAGE_NAME, "array", "transition_animation_scale_values",
                modRes.fwd(R.array.transition_animation_scale_values));
        resparam.res.setReplacement(PACKAGE_NAME, "array", "animator_duration_scale_entries",
                modRes.fwd(R.array.animator_duration_scale_entries));
        resparam.res.setReplacement(PACKAGE_NAME, "array", "animator_duration_scale_values",
                modRes.fwd(R.array.animator_duration_scale_values));
    } catch (Throwable t) {
        XposedBridge.log(t);
    }
}
 
Example 2
Source File: ModStatusbarColor.java    From GravityBox with Apache License 2.0 6 votes vote down vote up
private static void updateStatusIcons(String statusIcons) {
    if (mPhoneStatusBar == null) return;
    try {
        Object icCtrl = XposedHelpers.getObjectField(mPhoneStatusBar, "mIconController");
        ViewGroup vg = (ViewGroup) XposedHelpers.getObjectField(icCtrl, statusIcons);
        final int childCount = vg.getChildCount();
        for (int i = 0; i < childCount; i++) {
            if (!vg.getChildAt(i).getClass().getName().equals(CLASS_STATUSBAR_ICON_VIEW)) {
                continue;
            }
            ImageView v = (ImageView) vg.getChildAt(i);
            final Object sbIcon = XposedHelpers.getObjectField(v, "mIcon");
            if (sbIcon != null) {
                final String iconPackage =
                        (String) XposedHelpers.getObjectField(sbIcon, "pkg");
                Drawable d = getColoredDrawable(v.getContext(), iconPackage,
                        (Icon) XposedHelpers.getObjectField(sbIcon, "icon"));
                if (d != null) {
                    v.setImageDrawable(d);
                }
            }
        }
    } catch (Throwable t) {
        XposedBridge.log(t);
    }
}
 
Example 3
Source File: CallFeatures.java    From GravityBox with Apache License 2.0 6 votes vote down vote up
@Override
public void onFaceDown() {
    if (DEBUG) log("PhoneSensorEventListener.onFaceDown");

    try {
        switch (mFlipAction) {
            case GravityBoxSettings.PHONE_FLIP_ACTION_MUTE:
                if (DEBUG) log("Muting call");
                silenceRinger();
                break;
            case GravityBoxSettings.PHONE_FLIP_ACTION_DISMISS:
                if (DEBUG) log("Rejecting call");
                rejectCall(mIncomingCall);
                break;
            case GravityBoxSettings.PHONE_FLIP_ACTION_NONE:
            default:
                // do nothing
        }
    } catch (Throwable t) {
        XposedBridge.log(t);
    }
}
 
Example 4
Source File: ModPower.java    From GravityBox with Apache License 2.0 6 votes vote down vote up
private static void toggleWakeUpWithProximityFeature(boolean enabled) {
    try {
        if (enabled) {
            mSensorManager = (SensorManager) mContext.getSystemService(Context.SENSOR_SERVICE);
            mProxSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY);
            mWakeLock = ((PowerManager) mContext.getSystemService(Context.POWER_SERVICE))
                    .newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, TAG);
        } else {
            unregisterProxSensorListener();
            mProxSensor = null;
            mSensorManager = null;
            mWakeLock = null;
        }
        if (DEBUG) log("toggleWakeUpWithProximityFeature: " + enabled);
    } catch (Throwable t) {
        XposedBridge.log(t);
    }
}
 
Example 5
Source File: GpsStatusMonitor.java    From GravityBox with Apache License 2.0 5 votes vote down vote up
public void setLocationMode(int mode) {
    final int currentUserId = Utils.getCurrentUser();
    if (!isUserLocationRestricted(currentUserId)) {
        try {
            final ContentResolver cr = mContext.getContentResolver();
            XposedHelpers.callStaticMethod(Settings.Secure.class, "putIntForUser",
                    cr, Settings.Secure.LOCATION_MODE, mode, currentUserId);
        } catch (Throwable t) {
            XposedBridge.log(t);
        }
    }
}
 
Example 6
Source File: MtkFixTtsSettings.java    From GravityBox with Apache License 2.0 5 votes vote down vote up
public static void init(final XSharedPreferences prefs, final ClassLoader classLoader) {
    try {
        final Class<?> classVoiceIoSettings = XposedHelpers.findClass(CLASS_VOICEIO_SETTINGS, classLoader);

        if (DEBUG) log("replacing populateOrRemovePreferences method");
        XposedHelpers.findAndHookMethod(classVoiceIoSettings, "populateOrRemovePreferences", 
                new XC_MethodReplacement() {

                    @Override
                    protected Object replaceHookedMethod(MethodHookParam param) throws Throwable {
                        boolean hasRecognizer = (Boolean) XposedHelpers.callMethod(param.thisObject, 
                                        "populateOrRemoveRecognizerPrefs");
                        boolean hasTts = (Boolean) XposedHelpers.callMethod(param.thisObject,
                                        "populateOrRemoveTtsPrefs");
                        if (DEBUG) log("populateOrRemovePreferences: hasRecognizer=" + hasRecognizer + "; hasTts=" + hasTts);

                        if (hasRecognizer || hasTts) {
                            return null;
                        }

                        PreferenceFragment fragment = (PreferenceFragment) XposedHelpers.getObjectField(
                                param.thisObject, "mFragment");
                        PreferenceCategory prefCat = (PreferenceCategory) XposedHelpers.getObjectField(
                                param.thisObject, "mVoiceCategory");
                        if (fragment != null && prefCat != null) {
                            fragment.getPreferenceScreen().removePreference(prefCat);
                        }

                        return null;
                    }
            
        });
    }
    catch (Throwable t) {
        XposedBridge.log(t);
    }
}
 
Example 7
Source File: GpsStatusMonitor.java    From GravityBox with Apache License 2.0 5 votes vote down vote up
private int getLocationModeFromSettings() {
    try {
        final int currentUserId = Utils.getCurrentUser();
        final ContentResolver cr = mContext.getContentResolver();
        final int mode = (int) XposedHelpers.callStaticMethod(Settings.Secure.class, "getIntForUser",
                cr, Settings.Secure.LOCATION_MODE, Settings.Secure.LOCATION_MODE_OFF, currentUserId);
        if (DEBUG) log("getLocationMode: mode=" + mode);
        return mode;
    } catch (Throwable t) {
        XposedBridge.log(t);
        return Settings.Secure.LOCATION_MODE_OFF;
    }
}
 
Example 8
Source File: SubscriptionManager.java    From GravityBox with Apache License 2.0 5 votes vote down vote up
private int getSubIdForPhoneAccount(final TelephonyManager tm, final PhoneAccount account) {
    try {
        return (int) XposedHelpers.callMethod(tm, "getSubIdForPhoneAccount", account);
    } catch (Throwable t) {
        XposedBridge.log(t);
        return -1;
    }
}
 
Example 9
Source File: BluetoothTetheringTile.java    From GravityBox with 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 10
Source File: ModLockscreen.java    From GravityBox with Apache License 2.0 5 votes vote down vote up
private static void prepareGestureDetector() {
    try {
        mGestureDetector = new GestureDetector(mContext,
                new GestureDetector.SimpleOnGestureListener() {
                    @Override
                    public boolean onDoubleTap(MotionEvent e) {
                        Intent intent = new Intent(ModHwKeys.ACTION_SLEEP);
                        mContext.sendBroadcast(intent);
                        return true;
                    }
                });
    } catch (Throwable t) {
        XposedBridge.log(t);
    }
}
 
Example 11
Source File: ModPieControls.java    From GravityBox with Apache License 2.0 5 votes vote down vote up
private static int getTriggerSlotsFromArray(String[] triggers) {
    int tslots = 0;
    for (String s : triggers) {
        try {
            tslots |= Integer.valueOf(s);
        } catch (NumberFormatException e) {
            XposedBridge.log(e);
        }
    }
    return tslots;
}
 
Example 12
Source File: ModNavigationBar.java    From GravityBox with Apache License 2.0 5 votes vote down vote up
private static void updateRecentsKeyCode() {
    if (mRecentsKeys == null) return;

    try {
        final boolean hasAction = recentsKeyHasAction();
        for (Object o : mRecentsKeys) {
            if (o != null) {
                XposedHelpers.setIntField(o, "mCode", hasAction ? KeyEvent.KEYCODE_APP_SWITCH : 0);
            }
        }
    } catch (Throwable t) {
        XposedBridge.log(t);
    }
}
 
Example 13
Source File: BaseTile.java    From GravityBox with Apache License 2.0 4 votes vote down vote up
protected static void log(String message) {
    XposedBridge.log(TAG + ": " + message);
}
 
Example 14
Source File: ModVolumePanel.java    From GravityBox with Apache License 2.0 4 votes vote down vote up
private static void log(String message) {
    XposedBridge.log(TAG + ": " + message);
}
 
Example 15
Source File: StatusbarClock.java    From GravityBox with Apache License 2.0 4 votes vote down vote up
private static void log(String message) {
    XposedBridge.log(TAG + ": " + message);
}
 
Example 16
Source File: ModDialer.java    From GravityBox with Apache License 2.0 4 votes vote down vote up
private static void log(String message) {
    XposedBridge.log(TAG + ": " + message);
}
 
Example 17
Source File: XpLog.java    From XposedNavigationBar with GNU General Public License v3.0 4 votes vote down vote up
public static void w(String logContent) {
    if (DEBUG)
    XposedBridge.log("[W/" + TAG + "] " + logContent);
}
 
Example 18
Source File: BatteryStyleController.java    From GravityBox with Apache License 2.0 4 votes vote down vote up
private void updateBatteryStyle() {
    try {
        if (mStockBattery != null) {
            if (mBatteryStyle == GravityBoxSettings.BATTERY_STYLE_STOCK ||
                    mBatteryStyle == GravityBoxSettings.BATTERY_STYLE_STOCK_PERCENT) {
                mStockBattery.getView().setVisibility(View.VISIBLE);
                mStockBattery.setShowPercentage(mBatteryStyle ==
                        GravityBoxSettings.BATTERY_STYLE_STOCK_PERCENT);
            } else {
                mStockBattery.getView().setVisibility(View.GONE);
            }
        }

        if (mCircleBattery != null) {
            mCircleBattery.setVisibility((mBatteryStyle == GravityBoxSettings.BATTERY_STYLE_CIRCLE ||
                    mBatteryStyle == GravityBoxSettings.BATTERY_STYLE_CIRCLE_PERCENT ||
                    mBatteryStyle == GravityBoxSettings.BATTERY_STYLE_CIRCLE_DASHED ||
                    mBatteryStyle == GravityBoxSettings.BATTERY_STYLE_CIRCLE_DASHED_PERCENT) ?
                    View.VISIBLE : View.GONE);
            mCircleBattery.setPercentage(
                    mBatteryStyle == GravityBoxSettings.BATTERY_STYLE_CIRCLE_PERCENT ||
                            mBatteryStyle == GravityBoxSettings.BATTERY_STYLE_CIRCLE_DASHED_PERCENT);
            mCircleBattery.setStyle(
                    mBatteryStyle == GravityBoxSettings.BATTERY_STYLE_CIRCLE_DASHED ||
                            mBatteryStyle == GravityBoxSettings.BATTERY_STYLE_CIRCLE_DASHED_PERCENT ?
                            CmCircleBattery.Style.DASHED : CmCircleBattery.Style.SOLID);
        }

        if (mPercentText != null) {
            switch (mContainerType) {
                case STATUSBAR:
                    if (mBatteryPercentTextEnabledSb || mMtkPercentTextEnabled) {
                        mPercentText.setVisibility(View.VISIBLE);
                        mPercentText.updateText();
                    } else {
                        mPercentText.setVisibility(View.GONE);
                    }
                    break;
                case KEYGUARD:
                case HEADER:
                    XposedHelpers.callMethod(mContainer, "updateVisibilities");
                    break;
            }
        }
    } catch (Throwable t) {
        XposedBridge.log(t);
    }
}
 
Example 19
Source File: XposedMain.java    From rebootmenu with GNU General Public License v3.0 4 votes vote down vote up
private static void xLog(String text) {
    XposedBridge.log("rebootmenu:" + text);
}
 
Example 20
Source File: XposedMod.java    From ActivityForceNewTask with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Throwable {
    if (!lpparam.packageName.equals("android"))
        return;

    XC_MethodHook hook = new XC_MethodHook() {
        @Override
        protected void afterHookedMethod(MethodHookParam param) throws Throwable {
            settingsHelper.reload();
            if (settingsHelper.isModDisabled())
                return;
            Intent intent = (Intent) XposedHelpers.getObjectField(param.thisObject, "intent");

            // The launching app does not expect data back. It's safe to run the activity in a
            // new task.
            int requestCode = getIntField(param.thisObject, "requestCode");
            if (requestCode != -1)
                return;

            // The intent already has FLAG_ACTIVITY_NEW_TASK set, no need to do anything.
            if ((intent.getFlags() & Intent.FLAG_ACTIVITY_NEW_TASK) == Intent.FLAG_ACTIVITY_NEW_TASK)
                return;

            String intentAction = intent.getAction();
            // If the intent is not a known safe intent (as in, the launching app does not expect
            // data back, so it's safe to run in a new task,) ignore it straight away.
            if (intentAction == null)
                return;

            // If the app is launching one of its own activities, we shouldn't open it in a new task.
            int uid = ((ActivityInfo) getObjectField(param.thisObject, "info")).applicationInfo.uid;
            if (getIntField(param.thisObject, "launchedFromUid") == uid)
                return;

            ComponentName componentName = (ComponentName) getObjectField(param.thisObject, "realActivity");
            String componentNameString = componentName.flattenToString();
            // Log if necessary.
            if (settingsHelper.isLogEnabled()) {
                // Get context
                Context context = AndroidAppHelper.currentApplication();

                if (context != null)
                    context.sendBroadcast(new Intent(Common.INTENT_LOG).putExtra(Common.INTENT_COMPONENT_EXTRA, componentNameString));
                else
                    XposedBridge.log("activityforcenewtask: couldn't get context.");
                XposedBridge.log("activityforcenewtask: componentString: " + componentNameString);
            }

            // If the blacklist is used and the component is in the blacklist, or if the
            // whitelist is used and the component isn't whitelisted, we shouldn't modify
            // the intent's flags.
            boolean isListed = settingsHelper.isListed(componentNameString);
            String listType = settingsHelper.getListType();
            if ((listType.equals(Common.PREF_BLACKLIST) && isListed) ||
                    (listType.equals(Common.PREF_WHITELIST) && !isListed))
                return;

            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        }
    };

    Class ActivityRecord = findClass("com.android.server.am.ActivityRecord", lpparam.classLoader);
    XposedBridge.hookAllConstructors(ActivityRecord, hook);
}