コード例 #1
0
    @Override
    protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
      try {
        String uuid =
            Common.byteArrayToHexString((byte[]) XposedHelpers.callMethod(param.args[0], "getUid"));

        Set<String> authorizedNfcTags =
            prefs.getStringSet(Common.PREF_NFC_KEYS, new HashSet<String>());
        Context context = (Context) XposedHelpers.getObjectField(param.thisObject, "mContext");
        if (mDebugMode) XposedBridge.log(uuid.trim());

        if (context != null) {
          if (authorizedNfcTags != null && authorizedNfcTags.contains(uuid.trim())) {
            if (mDebugMode) XposedBridge.log("Got matching NFC tag, unlocking device...");
            context.sendBroadcast(new Intent(Common.INTENT_UNLOCK_DEVICE));
          }

          if (!prefs.getBoolean(Common.PREF_TAGLOST, true)) return;

          XposedHelpers.setAdditionalInstanceField(param.args[0], "mContext", context);
        }
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
コード例 #2
0
ファイル: Main.java プロジェクト: mvg-v70/xposed-mtc-manager
 // изменение текста на кнопках
 private void showStationButtons() {
   Object button;
   Log.d(TAG, "showStationButtons");
   // если находимся в режиме поиска, то кнопки не переименовываем
   boolean mSearching = XposedHelpers.getBooleanField(radioService, "mSearching");
   if (mSearching) return;
   int mBand = XposedHelpers.getIntField(radioService, "mBand");
   int[][] freq = (int[][]) XposedHelpers.getObjectField(radioService, "freq");
   // цикл по кнопкам
   for (int i = 0; i < 6; i++) {
     // поиск кнопки
     button = XposedHelpers.callMethod(mUi, "getChannelButton", i);
     if (button == null) return;
     // выходим, если это не кнопка, а layout
     if (!(button instanceof Button)) return;
     // частота кнопки
     int buttonFreq = freq[mBand][i];
     // форматируем частоту
     String freqStr = getFrequencyString(buttonFreq);
     // короткое наименование
     String text = getShortStationName(freqStr);
     Log.d(TAG, "freq=" + freqStr + ", text=" + text);
     if (!text.isEmpty())
       // изменим текст на кнопке, если он задан
       ((Button) button).setText(text);
   }
 }
コード例 #3
0
ファイル: XposedHook.java プロジェクト: xpduyson/AndroidN-ify
  @Override
  public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Throwable {

    switch (lpparam.packageName) {
      case PACKAGE_SETTINGS:
        SettingsHooks.hook(lpparam.classLoader);
        break;
      case PACKAGE_SYSTEMUI:
        SystemUIHooks.hookSystemUI(lpparam.classLoader);
        StatusBarHeaderHooks.hook(lpparam.classLoader);
        NotificationPanelHooks.hook(lpparam.classLoader);
        StackScrollAlgorithmHooks.hook(lpparam.classLoader);
        NotificationHooks.hookSystemUI(lpparam.classLoader);
        RecentsStackHooks.hookSystemUI(lpparam.classLoader);
        RecentsNavigation.hookSystemUI(lpparam.classLoader);
        DoubleTapSwKeys.hook(lpparam.classLoader);
        break;
      case PACKAGE_ANDROID:
        DoubleTapHwKeys.hook(lpparam.classLoader);
        LiveDisplayObserver.hook(lpparam.classLoader);
        PermissionGranter.initAndroid(lpparam.classLoader);
        break;
      case PACKAGE_PHONE:
        EmergencyHooks.hook(lpparam.classLoader);
        break;
      case PACKAGE_OWN:
        XposedHelpers.findAndHookMethod(
            SETTINGS_OWN,
            lpparam.classLoader,
            "isActivated",
            XC_MethodReplacement.returnConstant(true));
        if (!sPrefs.getBoolean("can_read_prefs", false))
          XposedHelpers.findAndHookMethod(
              SETTINGS_OWN,
              lpparam.classLoader,
              "isPrefsFileReadable",
              XC_MethodReplacement.returnConstant(false));
        break;
    }

    // Has to be hooked in every app as every app creates own instances of the Notification.Builder
    NotificationHooks.hook(lpparam.classLoader);

    // This actually is only used in the system process, but every app has access, so just to be
    // sure hook everything
    if (ConfigUtils.qs().enable_qs_editor) {
      try {
        Class<?> classCMStatusBarManager =
            XposedHelpers.findClass("cyanogenmod.app.CMStatusBarManager", lpparam.classLoader);
        XposedBridge.hookAllMethods(
            classCMStatusBarManager, "publishTile", XC_MethodReplacement.DO_NOTHING);
        XposedBridge.hookAllMethods(
            classCMStatusBarManager, "publishTileAsUser", XC_MethodReplacement.DO_NOTHING);
      } catch (Throwable ignore) {
      }
    }
  }
コード例 #4
0
  @Override
  protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
    super.onLayout(changed, left, top, right, bottom);
    // Find the view we wish to grab events from in order to detect search gesture.
    // Depending on the device, this will be one of the id's listed below.
    // If we don't find one, we'll use the view provided in the constructor above (this view).

    View view = findViewById(SystemR.id.nav_buttons);

    XposedHelpers.callMethod(mDelegateHelper, "setSourceView", view);
    XposedHelpers.callMethod(
        mDelegateHelper, "setInitialTouchRegion", new Object[] {new View[] {view}});
  }
コード例 #5
0
ファイル: _2chMate.java プロジェクト: subtek/MinMinGuard-X
  public static boolean handleLoadPackage(
      final String packageName, LoadPackageParam lpparam, final boolean test) {

    if (!packageName.equals("jp.co.airfront.android.a2chMate")) {
      return false;
    }

    try {

      Class<?> adview = findClass("jp.syoboi.a2chMate.view.MyAdView", lpparam.classLoader);

      XposedHelpers.findAndHookMethod(
          adview,
          "a",
          int.class,
          String.class,
          new XC_MethodHook() {
            @Override
            protected void beforeHookedMethod(MethodHookParam param) throws Throwable {

              Util.log(packageName, "Detect 2chmate MyAdView in " + packageName);

              if (!test) {
                param.setResult(new Object());
                Main.removeAdView((View) param.thisObject, packageName, true);
              }
            }
          });
      Util.log(packageName, packageName + " is 2chmate");
    } catch (ClassNotFoundError e) {
      return false;
    }
    return true;
  }
コード例 #6
0
 @Override
 public boolean onTouchEvent(MotionEvent event) {
   if (mDelegateHelper != null) {
     XposedHelpers.callMethod(mDelegateHelper, "onInterceptTouchEvent", event);
   }
   return true;
 }
コード例 #7
0
    //重置日期记录信息
    private void resetLast(){
        synchronized (Main.class) {
            for (TextView dateView : mDateViews) {
                XposedHelpers.setAdditionalInstanceField(dateView, "lunarText", "RESET");
                XposedHelpers.setAdditionalInstanceField(dateView, "finalText", "RESET");
                XposedHelpers.setAdditionalInstanceField(dateView, "lDate", "RESET");

                //4.4以上有个mLastText储存上次的日期字符串,在此尝试清空它,避免导致文字出现重复等现象
                if(Build.VERSION.SDK_INT >= 19){
                    try{
                        XposedHelpers.setObjectField(dateView, "mLastText", ""); //重置DateView内部日期记录
                    }catch(Throwable t){}
                }
            }
        }
    }
コード例 #8
0
 public TabletStatusBarView(Context context, AttributeSet attrs, Object barService) {
   super(context, attrs);
   mDelegateHelper = XposedHelpers.newInstance(TabletKatModule.mDelegateViewHelperClass, this);
   setBackgroundResource(SystemR.drawable.system_bar_background);
   mBarTransitions = new TabletStatusBarTransitions(this, barService);
   mBlocksEvents = false;
 }
コード例 #9
0
 /* Helper method, on API 17+ this method uses sendBroadcastAsUser to prevent
  * system warnings in logcat.
  */
 public static void sendBroadcast(Context context, Intent intent) {
   int currentapiVersion = android.os.Build.VERSION.SDK_INT;
   if (currentapiVersion >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR1) {
     context.sendBroadcastAsUser(
         intent, (UserHandle) XposedHelpers.getStaticObjectField(UserHandle.class, "CURRENT"));
   } else {
     context.sendBroadcast(intent);
   }
 }
コード例 #10
0
    @Override
    protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
      if (!prefs.getBoolean(Common.PREF_TAGLOST, true)) return;

      XposedHelpers.callMethod(
          param.thisObject,
          "setTimeout",
          Integer.parseInt(prefs.getString(Common.PREF_PRESENCE_CHECK_TIMEOUT, "2000")));
    }
コード例 #11
0
 private static float maxVisibleQuiescentAlpha(float max, View v) {
   if (v.isShown()) {
     try {
       return Math.max(max, (Float) XposedHelpers.callMethod(v, "getQuiescentAlpha"));
     } catch (ClassCastException e) {
     }
   }
   return max;
 }
コード例 #12
0
  public static void doHook(ClassLoader loader) {
    Class<?> clazz = XposedHelpers.findClass(sClassName, loader);
    XposedBridge.hookAllConstructors(
        clazz,
        new XC_MethodHook() {
          @Override
          protected void afterHookedMethod(MethodHookParam param) throws Throwable {
            ReflectionHelper.setAdditionalInstanceField(
                param.thisObject,
                "mSimpleStatusbarHook",
                new SimpleStatusbarInjector(param.thisObject));
          }
        });

    XposedHelpers.findAndHookMethod(
        clazz,
        "updateNotificationIcons",
        boolean.class,
        ArrayList.class,
        LinearLayout.LayoutParams.class,
        new XC_MethodHook() {
          @Override
          protected void afterHookedMethod(MethodHookParam param) throws Throwable {
            ((SimpleStatusbarInjector)
                    ReflectionHelper.getAdditionalInstanceField(
                        param.thisObject, "mSimpleStatusbarHook"))
                .hookAfterUpdateNotificationIcons();
          }
        });

    XposedHelpers.findAndHookMethod(
        clazz,
        "updateDarkMode",
        new XC_MethodHook() {
          @Override
          protected void afterHookedMethod(MethodHookParam param) throws Throwable {
            ((SimpleStatusbarInjector)
                    ReflectionHelper.getAdditionalInstanceField(
                        param.thisObject, "mSimpleStatusbarHook"))
                .hookAfterUpdateDarkMode();
          }
        });
  }
コード例 #13
0
  public BatteryHooks(ColourChangerMod instance, ClassLoader classLoader) {
    mInstance = instance;
    String className = "com.android.systemui.statusbar.policy.BatteryController";
    String addIconMethodName = "addIconView";
    String addLabelMethodName = "addLabelView";
    try {
      Class<?> BatteryController = XposedHelpers.findClass(className, classLoader);

      try {
        XposedHelpers.findAndHookMethod(
            BatteryController,
            addIconMethodName,
            ImageView.class,
            new XC_MethodHook() {
              @Override
              protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
                mInstance.addSystemIconView((ImageView) param.args[0]);
              }
            });
      } catch (NoSuchMethodError e) {
        XposedBridge.log("Not hooking method " + className + "." + addIconMethodName);
      }

      try {
        XposedHelpers.findAndHookMethod(
            BatteryController,
            addLabelMethodName,
            TextView.class,
            new XC_MethodHook() {
              @Override
              protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
                mInstance.addTextLabel((TextView) param.args[0]);
              }
            });
      } catch (NoSuchMethodError e) {
        XposedBridge.log("Not hooking method " + className + "." + addLabelMethodName);
      }

    } catch (ClassNotFoundError e) {
      // Really shouldn't happen, but we can't afford a crash here.
      XposedBridge.log("Not hooking class: " + className);
    }
  }
コード例 #14
0
  @Override
  public void initCmdApp(de.robv.android.xposed.IXposedHookCmdInit.StartupParam startupParam)
      throws Throwable {
    if (!startupParam.startClassName.equals("com.android.commands.am.Am")) return;

    Class<?> Am = findClass("com.android.commands.am.Am", null);
    Method sendBroadcastMethod = null;
    try {
      sendBroadcastMethod = XposedHelpers.findMethodBestMatch(Am, "makeIntent", int.class);
    } catch (NoSuchMethodError e) {
      try {
        sendBroadcastMethod = XposedHelpers.findMethodBestMatch(Am, "makeIntent");
      } catch (NoSuchMethodError e1) {
      }
    }

    if (sendBroadcastMethod != null) {
      XposedBridge.hookMethod(sendBroadcastMethod, new AmInterceptHook());
    }
  }
コード例 #15
0
ファイル: MaxLock.java プロジェクト: axe-why/MaxLock
 public static void init(XC_LoadPackage.LoadPackageParam lPParam) {
   try {
     findAndHookMethod(
         PACKAGE_NAME + ".ui.LockActivity",
         lPParam.classLoader,
         "openApp",
         new XC_MethodHook() {
           @Override
           protected void beforeHookedMethod(final MethodHookParam param) throws Throwable {
             put(getObjectField(param.thisObject, "packageName") + Apps.FLAG_TMP);
           }
         });
     findAndHookMethod(
         PACKAGE_NAME + ".ui.LockActivity",
         lPParam.classLoader,
         "onAuthenticationSucceeded",
         new XC_MethodHook() {
           @Override
           protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
             put(
                 getObjectField(param.thisObject, "packageName") + Apps.FLAG_IMOD,
                 Apps.IMOD_LAST_UNLOCK_GLOBAL);
           }
         });
     findAndHookMethod(
         PACKAGE_NAME + ".ui.LockActivity",
         lPParam.classLoader,
         "onBackPressed",
         new XC_MethodHook() {
           @Override
           protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
             put(getObjectField(param.thisObject, "packageName") + Apps.FLAG_CLOSE_APP);
           }
         });
     findAndHookMethod(
         PACKAGE_NAME + ".tasker.TaskActionReceiver",
         lPParam.classLoader,
         "clearImod",
         new XC_MethodHook() {
           @Override
           protected void afterHookedMethod(MethodHookParam param) throws Throwable {
             ScreenOff.clear();
           }
         });
     XposedHelpers.setStaticBooleanField(
         findClass(PACKAGE_NAME + ".ui.SettingsActivity", lPParam.classLoader), "IS_ACTIVE", true);
   } catch (Throwable t) {
     log(t);
   }
 }
コード例 #16
0
        @Override
        public boolean onTouch(View v, MotionEvent ev) {
          if (ev.getAction() == MotionEvent.ACTION_DOWN) {
            // even though setting the systemUI visibility below will turn these views
            // on, we need them to come up faster so that they can catch this motion
            // event
            applyLightsOut(false, false, false);

            try {
              XposedHelpers.callMethod(
                  mBarService, "setSystemUiVisibility", 0, View.SYSTEM_UI_FLAG_LOW_PROFILE);
            } catch (Exception ex) {
            }
          }
          return false;
        }
コード例 #17
0
ファイル: Utils.java プロジェクト: bucketzxm/droid_controller
 /**
  * modify SERIAL
  *
  * @param lpparam
  */
 public static void handleSERIAL(XC_LoadPackage.LoadPackageParam lpparam) {
   try {
     Log.d(TAG + "-" + "handleSERIAL", new Exception().getStackTrace()[0].getMethodName());
     String SERIAL_VAL = "";
     try {
       FileLoaderBaseVersion imeiLoader =
           new FileLoaderBaseVersion(AppsParameters.PARAM_FILE_PATH);
       SERIAL_VAL = imeiLoader.loadKeyValue("SERIAL");
     } catch (Exception e) {
       SERIAL_VAL = getRandomSERIAL();
     } finally {
       XposedHelpers.setStaticObjectField(Build.class, "SERIAL", SERIAL_VAL);
     }
   } catch (Exception e) {
     Log.e(TAG, lpparam.packageName + " has error:" + e.toString());
   }
 }
コード例 #18
0
ファイル: Amazon.java プロジェクト: david082321/MinMinGuard
  public static boolean handleLoadPackage(
      final String packageName, LoadPackageParam lpparam, final boolean test) {
    try {
      Class<?> adView =
          XposedHelpers.findClass("com.amazon.device.ads.AdLayout", lpparam.classLoader);

      XposedBridge.hookAllMethods(
          adView,
          "setListener",
          new XC_MethodHook() {

            @Override
            protected void beforeHookedMethod(MethodHookParam param) throws Throwable {

              Util.log(packageName, "Prevent amazon setlistener");

              if (!test) {
                param.setResult(new Object());
                Main.removeAdView((View) param.thisObject, packageName, true);
              }
            }
          });

      XposedBridge.hookAllMethods(
          adView,
          "loadAd",
          new XC_MethodHook() {

            @Override
            protected void beforeHookedMethod(MethodHookParam param) throws Throwable {

              Util.log(packageName, "Detect Amazon loadAd in " + packageName);

              if (!test) {
                param.setResult(Boolean.valueOf(true));
                Main.removeAdView((View) param.thisObject, packageName, true);
              }
            }
          });

      Util.log(packageName, packageName + " uses Amazon");
    } catch (ClassNotFoundError e) {
      return false;
    }
    return true;
  }
コード例 #19
0
ファイル: ApkVariant.java プロジェクト: jclehner/AppOpsXposed
  private boolean isMatching(ApplicationInfo appInfo, ClassChecker classChecker) {
    boolean havePackageMatch = false;

    for (String packageName : targetPackages()) {
      if (appInfo.packageName.equals(packageName)) havePackageMatch = true;
    }

    if (!havePackageMatch) return false;

    if (manufacturer() != ANY && !Util.containsManufacturer(manufacturer())) return false;

    if (release() != ANY && !Build.VERSION.RELEASE.equals(release())) return false;

    if (buildId() != ANY && !Build.ID.equals(buildId())) return false;

    try {
      if (md5Sum() != ANY && !XposedHelpers.getMD5Sum(appInfo.sourceDir).equals(md5Sum()))
        return false;
    } catch (IOException e) {
      log("Failed to get MD5 hash of " + appInfo.sourceDir);
      debug(e);
      return false;
    }

    if (apiLevel() != 0 && Build.VERSION.SDK_INT != apiLevel()) return false;

    if (!onMatch(appInfo, classChecker)) return false;

    final String[] classes = indicatorClasses();
    if (classes == null || classes.length == 0) return true;

    debug("Checking " + classes.length + " indicator classes");

    for (String className : classes) {
      if (classChecker.exists(className)) {
        debug("  OK: " + className);
        return true;
      } else {
        debug("  N/A: " + className);
        // continue
      }
    }

    return false;
  }
コード例 #20
0
ファイル: Main.java プロジェクト: mvg-v70/xposed-mtc-manager
 // переход на радиостанцию
 private void gotoStation(Intent data) {
   String freq = data.getStringExtra("frequency");
   Log.d(TAG, "freq=" + freq);
   boolean mSearching = XposedHelpers.getBooleanField(radioService, "mSearching");
   if (mSearching) return;
   int freqInt = (int) (Float.valueOf(freq) * 1000000);
   Log.d(TAG, "(int)freq=" + freqInt);
   XposedHelpers.callMethod(radioService, "setFreq", freqInt);
   // XposedHelpers.callMethod(radioService, "setMute", false);
   XposedHelpers.callMethod(radioService, "showBandChannel");
   XposedHelpers.callMethod(radioService, "showFreq");
   XposedHelpers.callMethod(radioService, "showRds");
   XposedHelpers.callMethod(radioService, "showSt");
   XposedHelpers.setIntField(radioService, "mChannel", -1);
   Log.d(TAG, "frequency set OK");
 }
コード例 #21
0
 private static void hideAlarmIcon() {
   XposedHelpers.findAndHookMethod(
       Packages.SYSTEM_UI + ".statusbar.phone.PhoneStatusBarPolicy",
       classLoader,
       "updateAlarm",
       Intent.class,
       new XC_MethodHook() {
         @Override
         protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
           int timeout = prefs.getInt("smartAlarmIconTime", 0);
           if (timeout == 0) {
             ((Intent) param.args[0]).putExtra("alarmSet", false);
           } else {
             setupSmartAlarm(param, timeout);
           }
         }
       });
 }
コード例 #22
0
ファイル: XposedUtils.java プロジェクト: noverguo/FRE
 public static void findAndHookMethod(
     Class<?> clazz, String methodName, Object... parameterTypesAndCallback) {
   int size = parameterTypesAndCallback.length - 1;
   Class[] argsClass = new Class[size];
   for (int i = 0; i < size; ++i) {
     argsClass[i] = (Class) parameterTypesAndCallback[i];
   }
   Class newClazz = ClassUtils.getDeclaredMethodClass(clazz, methodName, argsClass);
   if (newClazz == null) {
     if (BuildConfig.DEBUG) {
       XposedBridge.log(
           "XposedUtils.findAndHookMethod error: "
               + clazz.getName()
               + methodName
               + Arrays.toString(argsClass));
     }
   }
   XposedHelpers.findAndHookMethod(newClazz, methodName, parameterTypesAndCallback);
 }
コード例 #23
0
  @Override
  public void handleLoadPackage(LoadPackageParam lpparam) throws Throwable {

    if (lpparam.packageName != null) {
      switch (lpparam.packageName) {
        case KyoboLibrary.packageName:
          KyoboLibrary.modCode(lpparam);
          break;
        case EpyrusLibrary.packageName:
          EpyrusLibrary.modCode(lpparam);
          break;
        case Yes24Library.packageName:
        case Yes24Library.packagename2:
          Yes24Library.modCode(lpparam);
          break;
        case BookcubeLibrary.packageName:
        case BookcubeLibrary.packageName2:
          BookcubeLibrary.modCode(lpparam);
          break;

        case KyoboEbook.packageName:
          KyoboEbook.modCode(lpparam);
          break;
        case Yes24Ebook.packageName:
          Yes24Ebook.modCode(lpparam);
          break;
        case KakaoPage.packageName:
          KakaoPage.modCode(lpparam);
          break;
      }
    }

    if (lpparam.packageName.equals(PaperLogger.PACKAGE_NAME)) {
      String className = PaperLogger.PACKAGE_NAME + ".PrefFragment";
      XposedHelpers.findAndHookMethod(
          className,
          lpparam.classLoader,
          "isModuleActive",
          XC_MethodReplacement.returnConstant(true));
    }
  }
コード例 #24
0
  @Override
  public boolean onInterceptTouchEvent(MotionEvent ev) {
    if (ev.getAction() == MotionEvent.ACTION_DOWN) {

      if (TabletStatusBarMod.DEBUG) {
        Log.d(TabletStatusBarMod.TAG, "TabletStatusBarView intercepting touch event: " + ev);
      }

      mHandler.removeMessages(TabletStatusBarMod.MSG_CLOSE_RECENTS_PANEL);
      mHandler.sendEmptyMessage(TabletStatusBarMod.MSG_CLOSE_RECENTS_PANEL);
      mHandler.removeMessages(TabletStatusBarMod.MSG_CLOSE_NOTIFICATION_PANEL);
      mHandler.sendEmptyMessage(TabletStatusBarMod.MSG_CLOSE_NOTIFICATION_PANEL);
      mHandler.removeMessages(TabletStatusBarMod.MSG_CLOSE_INPUT_METHODS_PANEL);
      mHandler.sendEmptyMessage(TabletStatusBarMod.MSG_CLOSE_INPUT_METHODS_PANEL);
      mHandler.removeMessages(TabletStatusBarMod.MSG_STOP_TICKER);
      mHandler.sendEmptyMessage(TabletStatusBarMod.MSG_STOP_TICKER);

      for (int i = 0; i < mPanels.length; i++) {
        if (mPanels[i] != null && mPanels[i].getVisibility() == View.VISIBLE) {
          if (eventInside(mIgnoreChildren[i], ev)) {
            if (TabletStatusBarMod.DEBUG) {
              Log.d(
                  TabletStatusBarMod.TAG,
                  "TabletStatusBarView eating event for view: " + mIgnoreChildren[i]);
            }
            return true;
          }
        }
      }
    }
    if (TabletStatusBarMod.DEBUG) {
      Log.d(TabletStatusBarMod.TAG, "TabletStatusBarView not intercepting event");
    }
    boolean b = (Boolean) XposedHelpers.callMethod(mDelegateHelper, "onInterceptTouchEvent", ev);
    if ((mDelegateHelper != null && b) || mBlocksEvents) {
      return true;
    }
    return super.onInterceptTouchEvent(ev);
  }
コード例 #25
0
  private void setKitKatBatteryColor(int iconColor) {
    if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.KITKAT) return;

    if (mKitKatBatteryView == null) return;

    boolean debug = mSettingsHelper.isDebugMode();

    try {
      final int[] colors = (int[]) XposedHelpers.getObjectField(mKitKatBatteryView, "mColors");
      colors[colors.length - 1] = iconColor;
      XposedHelpers.setObjectField(mKitKatBatteryView, "mColors", colors);
    } catch (NoSuchFieldError e) {
      if (debug) e.printStackTrace();
    }

    try {
      final Paint framePaint =
          (Paint) XposedHelpers.getObjectField(mKitKatBatteryView, "mFramePaint");
      framePaint.setColor(iconColor);
      framePaint.setAlpha(100);
    } catch (NoSuchFieldError e) {
      if (debug) e.printStackTrace();
    }

    try {
      final Paint boltPaint =
          (Paint) XposedHelpers.getObjectField(mKitKatBatteryView, "mBoltPaint");
      boltPaint.setColor(Utils.getIconColorForColor(iconColor, Color.BLACK, Color.WHITE, 0.7f));
      boltPaint.setAlpha(100);
    } catch (NoSuchFieldError e) {
      if (debug) e.printStackTrace();
    }

    try {
      XposedHelpers.setIntField(mKitKatBatteryView, "mChargeColor", iconColor);
    } catch (NoSuchFieldError e) {
      /* Beanstalk, not sure why the ROM changed this */
      try {
        XposedHelpers.setIntField(mKitKatBatteryView, "mBatteryColor", iconColor);
      } catch (NoSuchFieldError e1) {
      }
      if (debug) e.printStackTrace();
    }

    mKitKatBatteryView.invalidate();
  }
コード例 #26
0
  private void doClockHooks(ClassLoader loader) {
    Class<?> Clock = XposedHelpers.findClass("com.android.systemui.statusbar.policy.Clock", loader);
    XposedBridge.hookAllConstructors(
        Clock,
        new XC_MethodHook() {
          @Override
          protected void afterHookedMethod(MethodHookParam param) throws Throwable {
            addTextLabel((TextView) param.thisObject);
            mFoundClock = true;
          }
        });

    findAndHookMethod(
        Clock,
        "updateClock",
        new XC_MethodHook() {
          @Override
          protected void afterHookedMethod(MethodHookParam param) throws Throwable {
            TextView textView = (TextView) param.thisObject;
            textView.setTextColor(mColorForStatusIcons);
          }
        });
  }
コード例 #27
0
  @SuppressLint("SimpleDateFormat")
  @SuppressWarnings("deprecation")
  private static void setupSmartAlarm(MethodHookParam param, int timeout) {
    if (((Intent) param.args[0]).getBooleanExtra("alarmSet", false)) {
      Context context = (Context) XposedHelpers.getObjectField(param.thisObject, "mContext");
      String nextAlarm =
          Settings.System.getString(
              context.getContentResolver(), android.provider.Settings.System.NEXT_ALARM_FORMATTED);
      DateFormat sdf = new SimpleDateFormat("EEE hh:mm aa");
      Date alarmDate = null;
      try {
        alarmDate = sdf.parse(nextAlarm);
      } catch (ParseException e) {
        e.printStackTrace();
      }
      int alarmDay = alarmDate.getDay();
      Calendar now = Calendar.getInstance();
      Date currentDate = now.getTime();
      int todayDay = currentDate.getDay();
      int daysDiff = 0;
      if (todayDay > alarmDay) {
        daysDiff = ((7 + (alarmDay - todayDay)) % 7) + 1;
      } else {
        daysDiff = ((7 + (alarmDay - todayDay)) % 7);
      }
      now.add(Calendar.DATE, daysDiff);
      Date alarmFulldate = now.getTime();
      alarmFulldate.setHours(alarmDate.getHours());
      alarmFulldate.setMinutes(alarmDate.getMinutes());
      alarmFulldate.setSeconds(0);
      long millis = alarmFulldate.getTime() - new Date().getTime();

      if (millis > (timeout * 60 * 1000)) {
        ((Intent) param.args[0]).putExtra("alarmSet", false);
      }
    }
  }
コード例 #28
0
  @Override
  public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Throwable {
    switch (lpparam.packageName) {
      case PACKAGE_SYSTEMUI:
        try {
          SystemUIHooks.doHook(lpparam.classLoader);
        } catch (Exception e) {
          log(TAG + e);
        }

        try {
          CmSystemUIHooks.doHook(lpparam.classLoader);
        } catch (Exception e) {
          log(TAG + e);
        }
        break;
      case "android":
        try {
          PointerEventDispatcherHooks.doHook(lpparam.classLoader);
        } catch (Exception e) {
          log(TAG + e);
        }
        break;

      case BuildConfig.APPLICATION_ID:
        try {
          XposedHelpers.findAndHookMethod(
              SettingsActivity.class.getName(),
              lpparam.classLoader,
              "activatedModuleVersion",
              XC_MethodReplacement.returnConstant(BuildConfig.VERSION_CODE));
        } catch (Exception e) {
          log(TAG + e);
        }
        break;
    }
  }
コード例 #29
0
  @Override
  public void handleLoadPackage(LoadPackageParam lpparam) throws Throwable {
    if (!lpparam.packageName.equals("com.android.vpndialogs")) return;

    XposedBridge.log("Got VPN Dialog");

    XposedHelpers.findAndHookMethod(
        "com.android.vpndialogs.ConfirmDialog",
        lpparam.classLoader,
        "onResume",
        new XC_MethodHook() {
          @Override
          protected void afterHookedMethod(MethodHookParam param) throws Throwable {

            // IConnectivityManager mService = IConnectivityManager.Stub.asInterface(
            //        ServiceManager.getService(Context.CONNECTIVITY_SERVICE));

            try {

              /*Class servicemanager = Class.forName("android.os.ServiceManager");
              Method getService = servicemanager.getMethod("getService",String.class);

              IConnectivityManager mService = IConnectivityManager.Stub.asInterface(
                      (IBinder) getService.invoke(servicemanager, Context.CONNECTIVITY_SERVICE));

              */
              Object mService = XposedHelpers.getObjectField(param.thisObject, "mService");

              String mPackage = ((Activity) param.thisObject).getCallingPackage();

              // App is already allowed do nothing
              /*if (mService.prepareVpn(mPackage, null)) {
                  return;
              }*/

              Class<?>[] prepareVPNsignature = {String.class, String.class};
              if ((Boolean)
                  XposedHelpers.callMethod(
                      mService, "prepareVpn", prepareVPNsignature, mPackage, (String) null)) return;

              HashSet<String> blinktapp = new HashSet<String>();
              blinktapp.add("de.blinkt.openvpn");
              //  blinktapp.add("de.blinkt.nothingset");

              pref.reload();
              Set<String> allowedApps = pref.getStringSet("allowedApps", blinktapp);

              // Toast.makeText((Context)param.thisObject, "Allowed apps: " + allowedApps,
              // Toast.LENGTH_LONG).show();

              if (allowedApps.contains(mPackage)) {
                // mService.prepareVpn(null, mPackage);
                XposedHelpers.callMethod(
                    mService, "prepareVpn", prepareVPNsignature, (String) null, mPackage);
                ((Activity) param.thisObject).setResult(Activity.RESULT_OK);
                Toast.makeText(
                        (Context) param.thisObject,
                        "Allowed VpnService app: " + mPackage,
                        Toast.LENGTH_LONG)
                    .show();
                ((Activity) param.thisObject).finish();
              }

            } catch (Exception e) {
              e.printStackTrace();
            }
          }
        });
  }
コード例 #30
0
  @Override
  public void afterHookedMethod(MethodHookParam param) {
    // Logging string
    String methodAndParams = "afterHookedMethod(MethodHookParam)";

    // Log
    WiFiKeyView.verboseLog(this, methodAndParams, "ModifyNetworkHook started");

    // The WifiConfigController class reference
    Class<?> wifiConfigControllerClass = param.thisObject.getClass();

    for (Field f : wifiConfigControllerClass.getFields()) {
      WiFiKeyView.verboseLog(this, methodAndParams, "" + f.getName());
    }

    // Get the password field
    Field mPasswordViewField = null;
    try {
      mPasswordViewField = XposedHelpers.findField(wifiConfigControllerClass, "mPasswordView");
      // mPasswordViewField = wifiConfigControllerClass.getField("mPasswordView");
    } catch (NoSuchFieldError e) {
      // Print stack trace
      e.printStackTrace();

      // Report message in Xposed log
      WiFiKeyView.verboseLog(
          this, methodAndParams, "mPasswordView is not found: " + e.getMessage());

      // Don't continue, this will produce more exceptions
      return;
    }

    try {
      mPasswordView = (TextView) mPasswordViewField.get(param.thisObject);
    } catch (IllegalAccessException e) {
      // Print stack trace
      e.printStackTrace();

      // Report message in Xposed log
      WiFiKeyView.verboseLog(
          this, methodAndParams, "Failed to get value from mPasswordView field: " + e.getMessage());

      // Don't continue, this will produce more exceptions
      return;

    } catch (IllegalArgumentException e) {
      // Print stack trace
      e.printStackTrace();

      // Report message in Xposed log
      WiFiKeyView.verboseLog(
          this, methodAndParams, "Failed to get value from mPasswordView field: " + e.getMessage());

      // Don't continue, this will produce more exceptions
      return;
    }

    Field fAccessPoint = null;
    try {
      fAccessPoint = XposedHelpers.findField(wifiConfigControllerClass, "mAccessPoint");
    } catch (NoSuchFieldError e) {
      // Print stack trace
      e.printStackTrace();

      // Report message in Xposed log
      WiFiKeyView.verboseLog(this, methodAndParams, "mAccessPoint is not found: " + e.getMessage());

      // Don't continue, this will produce more exceptions
      return;
    }

    Class<?> accessPointClass = null;
    try {
      accessPointClass = fAccessPoint.get(param.thisObject).getClass();
    } catch (IllegalAccessException e) {
      // Print stack trace
      e.printStackTrace();

      // Report message in Xposed log
      WiFiKeyView.verboseLog(
          this, methodAndParams, "Failed to get value from mAccessPoint field: " + e.getMessage());

      // Don't continue, this will produce more exceptions
      return;

    } catch (IllegalArgumentException e) {
      // Print stack trace
      e.printStackTrace();

      // Report message in Xposed log
      WiFiKeyView.verboseLog(
          this, methodAndParams, "Failed to get value from mAccessPoint field: " + e.getMessage());

      // Don't continue, this will produce more exceptions
      return;
    }

    Field fssid = null;
    try {
      fssid = XposedHelpers.findField(accessPointClass, "ssid");
    } catch (NoSuchFieldError e) {
      // Print stack trace
      e.printStackTrace();

      // Report message in Xposed log
      WiFiKeyView.verboseLog(
          this, methodAndParams, "Failed to get value from mPasswordView field: " + e.getMessage());

      // Don't continue, this will produce more exceptions
      return;
    }

    String ssid = null;
    try {
      ssid = (String) fssid.get(fAccessPoint.get(param.thisObject));
    } catch (IllegalAccessException e) {
      // Print stack trace
      e.printStackTrace();

      // Report message in Xposed log
      WiFiKeyView.verboseLog(
          this, methodAndParams, "Failed to get value from ssid field: " + e.getMessage());

      // Don't continue, this will produce more exceptions
      return;

    } catch (IllegalArgumentException e) {
      // Print stack trace
      e.printStackTrace();

      // Report message in Xposed log
      WiFiKeyView.verboseLog(
          this, methodAndParams, "Failed to get value from ssid field: " + e.getMessage());

      // Don't continue, this will produce more exceptions
      return;
    }

    WiFiKeyView.verboseLog(
        this,
        "afterHookedMethod(MethodHookParam);",
        "After hooked method finished with ssid: " + ssid);

    new NetworkParseTask(this).execute(ssid);
  }