コード例 #1
0
 protected CompositFile(string fileSystemPath, bool included, CrcsProject project)
     : base(fileSystemPath, included, project)
 {
     WorkingFolder = Path.Combine(ParentFolder, ".rsproj", Name);
     ClassesFolder = Path.Combine(WorkingFolder, ClassesFolderName);
     FileBackup = Path.Combine(WorkingFolder, "backup" + Extension);
     OdexFile = Path.Combine(ParentFolder, FileNameWithoutExtension + ".odex");
 }
コード例 #2
0
        protected void Decompile(string name, string classesFile, string outputFolder, bool ignoreDecompileErrors, CrcsProject project)
        {
            var ep = new ExecuteProgram();

            string locationOfDependencies = GetLocationOfDependencies(project);
            var apiLevel = project.Properties.ApiLevel;

            bool decompiled = false;
            bool useIgnoreDecompileErrorsFlag = false;
            while (!decompiled)
            {
                string additionalDependencies = project.GetAdditionalDependencies(name).Aggregate("",
                                                                                                  (current, dependency)
                                                                                                  =>
                                                                                                  current +
                                                                                                  (":" + dependency));
                if (additionalDependencies.Length > 0) additionalDependencies = " -c " + additionalDependencies;

                var arguments = new StringBuilder();
                arguments.Append("-Xmx512m -jar \"").Append(_baksmaliFile).Append("\"");
                arguments.Append(locationOfDependencies);
                arguments.Append(" -o \"").Append(outputFolder).Append("\"");
                if (useIgnoreDecompileErrorsFlag) arguments.Append(" -I");
                arguments.Append(" -l -s");
                arguments.Append(additionalDependencies);
                if ((Path.GetExtension(classesFile) ?? "").ToUpperInvariant() == ".ODEX") arguments.Append(" -x");
                arguments.Append(" \"").Append(classesFile).Append("\"");
                if (_useBaksmaliApiLevel)
                {
                    arguments.Append(" -a ").Append(apiLevel);
                }
                if (ep.Execute(_javaFile, arguments.ToString(), Path.GetDirectoryName(classesFile)) == 0)
                {
                    if (useIgnoreDecompileErrorsFlag)
                    {
                        MessageEngine.AddInformation(this, ep.Output);
                    }
                    decompiled = true;
                }
                else
                {
                    if (!FindMissingDependency(name, project, ep.Output))
                    {
                        if (ignoreDecompileErrors)
                        {
                            useIgnoreDecompileErrorsFlag = true;
                        }
                        else
                        {
                            throw ep.CreateException(Path.GetFileName(_baksmaliFile));
                        }
                    }
                }
            }
        }
コード例 #3
0
 public ProjectPropertiesEditor(CrcsProject project)
 {
     _project = project;
     _buildDisplayId = project.Properties.BuildDisplayId;
     _apiLevel = project.Properties.ApiLevel;
     InitializeComponent();
     labelTitle.Text = "Project '" + _project.Name + "' properties";
     TabTitle = _project.Name;
     TabToolTip = _project.FileSystemPath;
     RefreshControls(project);
 }
コード例 #4
0
 public TextFile(string fileSystemPath, bool included, CrcsProject project)
     : base(fileSystemPath, included, project)
 {
 }
コード例 #5
0
 protected ProjectItemBase(string fileSystemPath, CrcsProject project)
 {
     Project = project;
     SetValuesFromFileSystemPath(fileSystemPath);
 }
コード例 #6
0
 private bool FindBootClassPathFile(string name, CrcsProject project, string missingClassName)
 {
     foreach (string location in project.LocationsOfDependencies)
     {
         string[] files = Directory.GetFiles(location, missingClassName + ".smali", SearchOption.AllDirectories);
         if (files.Length > 0)
         {
             string folder = files[0].Substring(location.Length).TrimStart(Path.DirectorySeparatorChar).Substring(7).TrimStart(Path.DirectorySeparatorChar);
             folder = folder.Split(Path.DirectorySeparatorChar)[0];
             return project.AddDependency(name, folder);
         }
     }
     return false;
 }
コード例 #7
0
        protected void Recompile(string compositFilePath, string inputFolder, CrcsProject project)
        {
            var ep = new ExecuteProgram();
            var apiLevel = project.Properties.ApiLevel;

            var arguments = new StringBuilder();
            arguments.Append("-jar \"").Append(_smaliFile).Append("\"");
            arguments.Append(" \"").Append(inputFolder).Append("\"");
            string classesDexFile = Path.Combine(FolderUtility.CreateTempFolder(), "classes.dex");
            arguments.Append(" -o \"").Append(classesDexFile).Append("\"");
            if (_useSmaliApiLevel)
            {
                arguments.Append(" -a ").Append(apiLevel);
            }
            if (ep.Execute(_javaFile, arguments.ToString(), Path.GetDirectoryName(classesDexFile)) != 0)
            {
                throw ep.CreateException(Path.GetFileName(_smaliFile));
            }

            // add to program file apk/jar...
            using (var zf = new AndroidArchive(compositFilePath))
            {
                zf.Add(classesDexFile, Path.GetFileName(classesDexFile));
            }
        }
コード例 #8
0
 protected string GetLocationOfDependencies(CrcsProject project)
 {
     if (!_pathToDependencies.ContainsKey(project))
     {
         string pathToDependencies = "";
         foreach (string path in project.LocationsOfDependencies)
         {
             pathToDependencies += " -d \"" + path + "\"";
         }
         _pathToDependencies.Add(project, pathToDependencies);
     }
     return _pathToDependencies[project];
 }
コード例 #9
0
        protected bool FindMissingDependency(string name, CrcsProject project, string baksmaliOutput)
        {
            string[] bootClassPathArray = GetBootClassPath(baksmaliOutput);
            if (bootClassPathArray.Length == 0) return false;
            if (bootClassPathArray[0].Equals("junit", StringComparison.OrdinalIgnoreCase) &&
                project.LocationsOfDependencies.FirstOrDefault(x => File.Exists(Path.Combine(x, "core-junit.jar"))) !=
                null)
            {
                return project.AddDependency(name, "core-junit.jar");
            }

            string missingClassName = bootClassPathArray[bootClassPathArray.Length - 1];
            if (FindBootClassPathFile(name, project, missingClassName)) return true;

            int start = 0;
            int count = bootClassPathArray.Length - 1;
            while (count > 0)
            {
                string bootClassPath = string.Join(".", bootClassPathArray, start, count) + ".jar";
                if (project.LocationsOfDependencies.FirstOrDefault(x => File.Exists(Path.Combine(x, bootClassPath))) !=
                    null)
                {
                    return project.AddDependency(name, bootClassPath);
                }
                start++;
                count--;
            }
            return false;
        }
コード例 #10
0
 public void SetProjectBuildOrder(CrcsProject project, int buildOrder)
 {
     if (_projects.Contains(project))
     {
         _projects.Remove(project);
         _projects.Insert(buildOrder, project);
         _isDirty = true;
     }
 }
コード例 #11
0
 public bool RemoveProject(CrcsProject proj)
 {
     if (proj == null) throw new ArgumentNullException("proj");
     if (!_projects.Contains(proj)) return false;
     _projects.Remove(proj);
     if (_initialized) _isDirty = true;
     return true;
 }
コード例 #12
0
 public void AddProject(CrcsProject project)
 {
     _projects.Add(project);
     _isDirty = true;
 }
コード例 #13
0
 public static CrcsProject OpenProject(string fileSystemPath, CrcsSolution solution)
 {
     var rsproj = new CrcsProject(fileSystemPath, solution);
     rsproj.LoadProjectFile();
     if (rsproj.Properties.FrameWorkFiles.Count() == 0)
     {
         rsproj.SetFrameWorkFiles();
     }
     rsproj._initialized = true;
     rsproj.AttachToSystem();
     return rsproj;
 }
コード例 #14
0
 public static CrcsProject CreateProject(string fileSystemPath, CrcsSolution solution)
 {
     string projectPath = Path.GetDirectoryName(fileSystemPath);
     if (projectPath == null) return null;
     if (!Directory.Exists(projectPath)) Directory.CreateDirectory(projectPath);
     var rsproj = new CrcsProject(fileSystemPath, solution);
     rsproj.AddFolder(rsproj.ProjectPath);
     string buildPropFile = FileUtility.FindFile(rsproj.ProjectPath, "build.prop");
     if (File.Exists(buildPropFile))
     {
         rsproj.Properties.ApkToolFrameWorkTag = PropFileUtility.GetProp(buildPropFile, "ro.build.version.incremental");
         rsproj.Properties.ApiLevel = PropFileUtility.GetProp(buildPropFile, "ro.build.version.sdk");
     }
     else
     {
         rsproj.Properties.ApkToolFrameWorkTag = rsproj.Name;
     }
     rsproj.SetFrameWorkFiles();
     rsproj._initialized = true;
     rsproj.AttachToSystem();
     return rsproj;
 }
コード例 #15
0
 private void RefreshControls(CrcsProject project)
 {
     try
     {
         _refreshingControls = true;
         textBoxBuildDisplayId.Text = _buildDisplayId;
         textBoxApiLevel.Text = _apiLevel;
         checkBoxReSignApkFiles.Checked = project.Properties.ReSignApkFiles;
         checkBoxIncludeInBuild.Checked = project.IncludeInBuild;
         foreach (string file in _project.Properties.FrameWorkFiles)
         {
             listBoxFrameWorkFiles.Items.Add(Path.GetFileName(file) ?? "");
         }
         textBoxFrameWorkFile.Text = "";
     }
     finally
     {
         _refreshingControls = false;
     }
 }
コード例 #16
0
 public IEnumerable<string> GetExpandedTreeNodes(CrcsProject project)
 {
     return
         _nodes.Where(x => x.IsExpanded && (x.IsFolder || x.IsProject) && ReferenceEquals(x.ProjectItem.Project, project)).Select(
             x => x.FileSystemPath).ToArray();
 }