示例#1
0
        public bool InstallFramework(InstallFrameworkOptions options)
        {
            lastActionType = ApktoolActionType.InstallFramework;
            lastFilePath   = options.InputFramePath;
            lastProjectDir = null;

            string keyFrameDir = null, keyTag = null;

            if (!String.IsNullOrWhiteSpace(options.FrameDir))
            {
                keyFrameDir = String.Format("{0} \"{1}\"", InstallFrameworkKeys.FrameDir, options.FrameDir);
            }
            if (!String.IsNullOrWhiteSpace(options.Tag))
            {
                keyTag = String.Format("{0} \"{1}\"", InstallFrameworkKeys.Tag, options.Tag);
            }

            string args = String.Format("if{0}{1} \"{2}\"", keyFrameDir, keyTag, options.InputFramePath);

            bool started = this.Start(args);

            this.BeginOutputReadLine();
            this.BeginErrorReadLine();
            return(started);
        }
示例#2
0
        public bool Decompile(DecompileOptions options)
        {
            lastActionType = ApktoolActionType.Decompile;
            lastFilePath   = options.AppPath;
            lastProjectDir = options.OutputDirectory;

            string keyNoSrc = null, keyNoRes = null, keyForce = null, keyFramePath = null, keyKeepBrokenRes = null, keyMatchOriginal = null, keyOutputDir = null;

            if (options.NoSource)
            {
                keyNoSrc = DecompileKeys.NoSource;
            }
            if (options.NoResource)
            {
                keyNoRes = DecompileKeys.NoResource;
            }
            if (options.Force)
            {
                keyForce = DecompileKeys.Force;
            }
            if (options.KeepBrokenResource)
            {
                keyKeepBrokenRes = DecompileKeys.KeepBrokenResource;
            }
            if (options.MatchOriginal)
            {
                keyMatchOriginal = DecompileKeys.MatchOriginal;
            }
            if (!String.IsNullOrWhiteSpace(options.FrameworkPath))
            {
                keyFramePath = String.Format("{0} \"{1}\"", DecompileKeys.FrameworkPath, options.FrameworkPath);
            }
            if (!String.IsNullOrWhiteSpace(options.OutputDirectory))
            {
                keyOutputDir = String.Format("{0} \"{1}\"", DecompileKeys.OutputDir, options.OutputDirectory);
            }

            //string args = String.Format("d{0}{1}{2}{3}{4}{5} -o \"{6}\" \"{7}\"", keyNoSrc, keyNoRes, keyForce, keyKeepBrokenRes, keyMatchOriginal, keyFramePath, options.ProjectDirectory, options.AppPath);
            string args = String.Format("d{0}{1}{2}{3}{4}{5}{6} \"{7}\"", keyNoSrc, keyNoRes, keyForce, keyKeepBrokenRes, keyMatchOriginal, keyFramePath, keyOutputDir, options.AppPath);

            bool started = this.Start(args);

            this.BeginOutputReadLine();
            this.BeginErrorReadLine();
            return(started);
        }
示例#3
0
        public bool Build(BuildOptions options)
        {
            lastActionType = ApktoolActionType.Build;
            lastFilePath   = options.AppPath;
            lastProjectDir = options.ProjectDirectory;

            string keyForceAll = null, keyAapt = null, keyCopyOriginal = null, keyFramePath = null, keyOutputAppPath = null;

            if (options.ForceAll)
            {
                keyForceAll = BuildKeys.ForceAll;
            }
            if (options.CopyOriginal)
            {
                keyCopyOriginal = BuildKeys.CopyOriginal;
            }
            if (!String.IsNullOrEmpty(options.AaptPath))
            {
                keyAapt = String.Format("{0} \"{1}\"", BuildKeys.Aapt, options.AaptPath);
            }
            if (!String.IsNullOrEmpty(options.FrameworkPath))
            {
                keyFramePath = String.Format("{0} \"{1}\"", BuildKeys.FrameworkPath, options.FrameworkPath);
            }
            if (!String.IsNullOrWhiteSpace(options.AppPath))
            {
                keyOutputAppPath = String.Format("{0} \"{1}\"", BuildKeys.OutputAppPath, options.AppPath);
            }

            string args = String.Format("b{0}{1}{2}{3}{4} \"{5}\"", keyForceAll, keyAapt, keyCopyOriginal, keyFramePath, keyOutputAppPath, options.ProjectDirectory);

            bool started = this.Start(args);

            this.BeginOutputReadLine();
            this.BeginErrorReadLine();
            return(started);
        }
示例#4
0
        private void Apktool_Exited(object sender, EventArgs e)
        {
            this.CancelOutputRead();
            this.CancelErrorRead();
            switch (lastActionType)
            {
            case ApktoolActionType.Build:
                if (onBuildCompleted != null)
                {
                    onBuildCompleted(this, new ApktoolEventCompletedEventArgs(this.ExitCode, lastFilePath, lastProjectDir));
                }
                lastActionType = ApktoolActionType.Null;
                break;

            case ApktoolActionType.Decompile:
                if (onDecompilingCompleted != null)
                {
                    onDecompilingCompleted(this, new ApktoolEventCompletedEventArgs(this.ExitCode, lastFilePath, lastProjectDir));
                }
                lastActionType = ApktoolActionType.Null;
                break;

            case ApktoolActionType.InstallFramework:
                if (onInstallFrameworkCompleted != null)
                {
                    onInstallFrameworkCompleted(this, new ApktoolEventCompletedEventArgs(this.ExitCode, lastFilePath, lastProjectDir));
                }
                lastActionType = ApktoolActionType.Null;
                break;

            case ApktoolActionType.Null:
                break;

            default:
                break;
            }
        }
示例#5
0
 private void Apktool_Exited(object sender, EventArgs e)
 {
     this.CancelOutputRead();
     this.CancelErrorRead();
     switch (lastActionType)
     {
         case ApktoolActionType.Build:
             if (onBuildCompleted != null)
                 onBuildCompleted(this, new ApktoolEventCompletedEventArgs(this.ExitCode, lastFilePath, lastProjectDir));
             lastActionType = ApktoolActionType.Null;
             break;
         case ApktoolActionType.Decompile:
             if (onDecompilingCompleted != null)
                 onDecompilingCompleted(this, new ApktoolEventCompletedEventArgs(this.ExitCode, lastFilePath, lastProjectDir));
             lastActionType = ApktoolActionType.Null;
             break;
         case ApktoolActionType.InstallFramework:
             if (onInstallFrameworkCompleted != null)
                 onInstallFrameworkCompleted(this, new ApktoolEventCompletedEventArgs(this.ExitCode, lastFilePath, lastProjectDir));
             lastActionType = ApktoolActionType.Null;
             break;
         case ApktoolActionType.Null:
             break;
         default:
             break;
     }
 }
示例#6
0
        public bool InstallFramework(InstallFrameworkOptions options)
        {
            lastActionType = ApktoolActionType.InstallFramework;
            lastFilePath = options.InputFramePath;
            lastProjectDir = null;

            string keyFrameDir = null, keyTag = null;

            if (!String.IsNullOrWhiteSpace(options.FrameDir))
                keyFrameDir = String.Format("{0} \"{1}\"", InstallFrameworkKeys.FrameDir, options.FrameDir);
            if (!String.IsNullOrWhiteSpace(options.Tag))
                keyTag = String.Format("{0} \"{1}\"", InstallFrameworkKeys.Tag, options.Tag);

            string args = String.Format("if{0}{1} \"{2}\"", keyFrameDir, keyTag, options.InputFramePath);

            bool started = this.Start(args);
            this.BeginOutputReadLine();
            this.BeginErrorReadLine();
            return started;
        }
示例#7
0
        public bool Decompile(DecompileOptions options)
        {
            lastActionType = ApktoolActionType.Decompile;
            lastFilePath = options.AppPath;
            lastProjectDir = options.OutputDirectory;

            string keyNoSrc = null, keyNoRes = null, keyForce = null, keyFramePath = null, keyKeepBrokenRes = null, keyMatchOriginal = null, keyOutputDir = null;

            if (options.NoSource)
                keyNoSrc = DecompileKeys.NoSource;
            if (options.NoResource)
                keyNoRes = DecompileKeys.NoResource;
            if (options.Force)
                keyForce = DecompileKeys.Force;
            if (options.KeepBrokenResource)
                keyKeepBrokenRes = DecompileKeys.KeepBrokenResource;
            if (options.MatchOriginal)
                keyMatchOriginal = DecompileKeys.MatchOriginal;
            if (!String.IsNullOrWhiteSpace(options.FrameworkPath))
                keyFramePath = String.Format("{0} \"{1}\"", DecompileKeys.FrameworkPath, options.FrameworkPath);
            if (!String.IsNullOrWhiteSpace(options.OutputDirectory))
                keyOutputDir = String.Format("{0} \"{1}\"", DecompileKeys.OutputDir, options.OutputDirectory);

            //string args = String.Format("d{0}{1}{2}{3}{4}{5} -o \"{6}\" \"{7}\"", keyNoSrc, keyNoRes, keyForce, keyKeepBrokenRes, keyMatchOriginal, keyFramePath, options.ProjectDirectory, options.AppPath);
            string args = String.Format("d{0}{1}{2}{3}{4}{5}{6} \"{7}\"", keyNoSrc, keyNoRes, keyForce, keyKeepBrokenRes, keyMatchOriginal, keyFramePath, keyOutputDir, options.AppPath);

            bool started = this.Start(args);
            this.BeginOutputReadLine();
            this.BeginErrorReadLine();
            return started;
        }
示例#8
0
        public bool Build(BuildOptions options)
        {
            lastActionType = ApktoolActionType.Build;
            lastFilePath = options.AppPath;
            lastProjectDir = options.ProjectDirectory;

            string keyForceAll = null, keyAapt = null, keyCopyOriginal = null, keyFramePath = null, keyOutputAppPath = null;
            if (options.ForceAll)
                keyForceAll = BuildKeys.ForceAll;
            if (options.CopyOriginal)
                keyCopyOriginal = BuildKeys.CopyOriginal;
            if (!String.IsNullOrEmpty(options.AaptPath))
                keyAapt = String.Format("{0} \"{1}\"", BuildKeys.Aapt, options.AaptPath);
            if (!String.IsNullOrEmpty(options.FrameworkPath))
                keyFramePath = String.Format("{0} \"{1}\"", BuildKeys.FrameworkPath, options.FrameworkPath);
            if (!String.IsNullOrWhiteSpace(options.AppPath))
                keyOutputAppPath = String.Format("{0} \"{1}\"", BuildKeys.OutputAppPath, options.AppPath);

            string args = String.Format("b{0}{1}{2}{3}{4} \"{5}\"", keyForceAll, keyAapt, keyCopyOriginal, keyFramePath, keyOutputAppPath, options.ProjectDirectory);

            bool started = this.Start(args);
            this.BeginOutputReadLine();
            this.BeginErrorReadLine();
            return started;
        }