Ejemplo n.º 1
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);
   }
 }
Ejemplo n.º 2
0
  public void getSettingsFromDB(String process_name) {
    if (!process_name.equals("android")) {
      return;
    }
    ArrayList<ProcessSetting> ps =
        (ArrayList<ProcessSetting>)
            XposedHelpers.getStaticObjectField(ProcessSettingDBHelper.class, "psettings");
    if (ps == null) {
      XposedHelpers.setStaticObjectField(
          ProcessSettingDBHelper.class, "psettings", new ArrayList<ProcessSetting>());
    } else {
      return;
    }
    /* Read DB */

    try {
      Runtime.getRuntime()
          .exec(
              new String[] {
                "su", "-c", "chown root.root /data/data/sg.edu.nus.soc.cs5231/databases/cs5231.db"
              });
    } catch (IOException e) {
      XposedBridge.log(
          "chown root.root /data/data/sg.edu.nus.soc.cs5231/databases/cs5231.db failed.");
    }
    try {
      Runtime.getRuntime()
          .exec(
              new String[] {
                "su", "-c", "chmod 777 /data/data/sg.edu.nus.soc.cs5231/databases/cs5231.db"
              });
    } catch (IOException e) {
      XposedBridge.log("chmod 777 /data/data/sg.edu.nus.soc.cs5231/databases/cs5231.db failed.");
    }
    try {
      Runtime.getRuntime()
          .exec(
              new String[] {
                "su",
                "-c",
                "chown root.root /data/data/sg.edu.nus.soc.cs5231/databases/cs5231.db-journal"
              });
    } catch (IOException e) {
      XposedBridge.log(
          "chown root.root /data/data/sg.edu.nus.soc.cs5231/databases/cs5231.db-journal failed.");
    }
    try {
      Runtime.getRuntime()
          .exec(
              new String[] {
                "su", "-c", "chmod 777 /data/data/sg.edu.nus.soc.cs5231/databases/cs5231.db-journal"
              });
    } catch (IOException e) {
      XposedBridge.log(
          "chmod 777 /data/data/sg.edu.nus.soc.cs5231/databases/cs5231.db-journal failed.");
    }
    ProcessSettingDBHelper db = new ProcessSettingDBHelper(null);
    XposedHelpers.setStaticObjectField(
        ProcessSettingDBHelper.class, "psettings", db.getAllProcessSetting());
    ;
    XposedBridge.log(
        "JASON: DB LOADED WITH "
            + ((ArrayList<ProcessSetting>)
                    XposedHelpers.getStaticObjectField(ProcessSettingDBHelper.class, "psettings"))
                .size()
            + " PROCESS SETTINGS.");
    /* End Read DB */
  }