Esempio n. 1
0
    @Override
    protected List<SourceInfo> doInBackground(String... params) {

      List<SourceInfo> historyItems = new ArrayList<>();
      File showJavaDir = new File(Environment.getExternalStorageDirectory() + "/ShowJava/");
      showJavaDir.mkdirs();

      File nomedia = new File(showJavaDir, ".nomedia");

      if (!nomedia.exists() || !nomedia.isFile()) {
        try {
          nomedia.createNewFile();
        } catch (IOException e) {
          Ln.d(e);
        }
      }

      File dir = new File(Environment.getExternalStorageDirectory() + "/ShowJava/sources");

      if (dir.exists()) {
        File[] files = dir.listFiles();
        for (File file : files) {
          if (Utils.sourceExists(file)) {
            historyItems.add(Utils.getSourceInfoFromSourcePath(file));
          } else {
            if (!Utils.isProcessorServiceRunning(baseContext)) {
              try {
                if (file.exists()) {
                  if (file.isDirectory()) {
                    FileUtils.deleteDirectory(file);
                  } else {
                    file.delete();
                  }
                }

              } catch (Exception e) {
                Ln.d(e);
              }
            }
            if (file.exists() && !file.isDirectory()) {
              file.delete();
            }
          }
        }
      }

      return historyItems;
    }
Esempio n. 2
0
 private void cleanOldSources() {
   File dir = new File(Environment.getExternalStorageDirectory() + "/ShowJava");
   if (dir.exists()) {
     File[] files = dir.listFiles();
     for (File file : files) {
       if (!file.getName().equalsIgnoreCase("sources")) {
         try {
           if (file.exists()) {
             if (file.isDirectory()) {
               FileUtils.deleteDirectory(file);
             } else {
               file.delete();
             }
           }
         } catch (Exception e) {
           Ln.d(e);
         }
       }
     }
   } else {
     dir.mkdirs();
   }
 }
Esempio n. 3
0
  @Override
  public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == FILE_PICKER) {
      if (data != null) {

        Uri uri = data.getData();
        File apkFile = new File(uri.getPath());
        final String PackageDir = apkFile.getAbsolutePath();

        Ln.d(PackageDir);

        final String PackageName;
        final String PackageId;

        if (FilenameUtils.isExtension(PackageDir, "apk")) {
          PackageManager pm = getPackageManager();
          PackageInfo info = pm.getPackageArchiveInfo(PackageDir, PackageManager.GET_ACTIVITIES);
          if (info != null) {
            ApplicationInfo appInfo = info.applicationInfo;

            if (Build.VERSION.SDK_INT >= 8) {
              appInfo.sourceDir = PackageDir;
              appInfo.publicSourceDir = PackageDir;
            }
            PackageName = info.applicationInfo.loadLabel(getPackageManager()).toString();
            PackageId = info.packageName;

          } else {
            PackageName = "";
            PackageId = "";
          }

          if (!prefs.getBoolean("hide_decompiler_select", false)) {
            final CharSequence[] items = {"CFR 0.102", "JaDX 0.6.1"};
            AlertDialog.Builder builder = new AlertDialog.Builder(this);
            builder.setTitle("Pick a decompiler");
            builder.setItems(
                items,
                new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface dialog, int item) {
                    Intent i = new Intent(getApplicationContext(), AppProcessActivity.class);
                    i.putExtra("package_id", PackageId);
                    i.putExtra("package_label", PackageName);
                    i.putExtra("package_file_path", PackageDir);
                    i.putExtra("decompiler", (item == 1 ? "jadx" : "cfr"));
                    startActivity(i);
                    overridePendingTransition(R.anim.fadein, R.anim.fadeout);
                  }
                });
            AlertDialog alert = builder.create();
            alert.show();
          } else {
            Intent i = new Intent(getApplicationContext(), AppProcessActivity.class);
            i.putExtra("package_id", PackageId);
            i.putExtra("package_label", PackageName);
            i.putExtra("package_file_path", PackageDir);
            i.putExtra("decompiler", prefs.getString("decompiler", "cfr"));
            startActivity(i);
            overridePendingTransition(R.anim.fadein, R.anim.fadeout);
          }
        }
      }
    }
  }