Ejemplo n.º 1
1
    @Override
    public void onReceive(Context context, Intent intent) {
      /*
       * Close the notification bar in order to see the toast that module
       * was enabled successfully. Furthermore, if SU permissions haven't
       * been granted yet, the SU dialog will be prompted behind the
       * expanded notification panel and is therefore not visible to the
       * user.
       */
      sContext.sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS));
      cancelAll();

      if (intent.hasExtra(EXTRA_ACTIVATE_MODULE)) {
        String packageName = intent.getStringExtra(EXTRA_ACTIVATE_MODULE);
        ModuleUtil moduleUtil = ModuleUtil.getInstance();
        moduleUtil.setModuleEnabled(packageName, true);
        moduleUtil.updateModulesList(false);
        Toast.makeText(sContext, R.string.module_activated, Toast.LENGTH_SHORT).show();

        if (intent.hasExtra(EXTRA_ACTIVATE_MODULE_AND_RETURN)) return;
      }

      RootUtil rootUtil = new RootUtil();
      if (!rootUtil.startShell()) {
        Log.e(XposedApp.TAG, "Could not start root shell");
        return;
      }

      boolean isSoftReboot = intent.getBooleanExtra(EXTRA_SOFT_REBOOT, false);
      rootUtil.reboot(
          isSoftReboot ? RootUtil.RebootMode.SOFT : RootUtil.RebootMode.NORMAL,
          new RootUtil.LogLineCallback());

      AssetUtil.removeBusybox();
    }