Esempio n. 1
0
        //uninstalls an app
        public static ProcessOutput UninstallGame(string GameName)
        {
            ADB.WakeDevice();
            ProcessOutput output = new ProcessOutput("", "");

            string packageName = Sideloader.gameNameToPackageName(GameName);

            DialogResult dialogResult = FlexibleMessageBox.Show($"Are you sure you want to uninstall {packageName}? this CANNOT be undone!", "WARNING!", MessageBoxButtons.YesNo);

            if (dialogResult != DialogResult.Yes)
            {
                return(output);
            }

            output = ADB.UninstallPackage(packageName);

            //remove both data and obb if there is any
            Sideloader.RemoveFolder("/sdcard/Android/obb/" + packageName);
            Sideloader.RemoveFolder("/sdcard/Android/data/" + packageName);

            return(output);
        }
Esempio n. 2
0
        //For games that require manual install, like having another folder that isnt an obb
        public static ProcessOutput RunADBCommandsFromFile(string path, string RunFromPath)
        {
            ADB.WakeDevice();
            ProcessOutput output   = new ProcessOutput();
            var           commands = File.ReadAllLines(path);

            foreach (string cmd in commands)
            {
                if (cmd.StartsWith("adb"))
                {
                    var regex   = new Regex(Regex.Escape("adb"));
                    var command = regex.Replace(cmd, $"\"{ADB.adbFilePath}\"", 1);

                    Logger.Log($"Logging command: {command} from file: {path}");

                    if (ADB.DeviceID.Length > 1)
                    {
                        command = $" -s {ADB.DeviceID} {command}";
                    }
                    output += Utilities.GeneralUtilities.startProcess("cmd.exe", RunFromPath, command);
                }
            }
            return(output);
        }
Esempio n. 3
0
        //Run rclone command
        public static ProcessOutput runRcloneCommand(string command, string bandwithLimit = "")
        {
            if (!MainForm.HasInternet)
            {
                return(new ProcessOutput("", "No internet"));
            }

            //Set the password for rclone configs
            Environment.SetEnvironmentVariable("RCLONE_CRYPT_REMOTE", rclonepw);
            Environment.SetEnvironmentVariable("RCLONE_CONFIG_PASS", rclonepw);
            ProcessOutput prcoutput = new ProcessOutput();

            //Rclone output is unicode, else it will show garbage instead of unicode characters
            rclone.StartInfo.StandardOutputEncoding = Encoding.UTF8;
            string originalCommand = command;

            //set bandwidth limit
            if (bandwithLimit.Length > 0)
            {
                command += $" --bwlimit={bandwithLimit}";
            }

            //set configpath if there is any
            if (configPath.Length > 0)
            {
                command += $" --config {configPath}";
            }

            //set rclonepw
            if (rclonepw.Length > 0)
            {
                command += " --ask-password=false";
            }

            Logger.Log($"Running Rclone command: {command}");

            rclone.StartInfo.FileName               = Environment.CurrentDirectory + "\\rclone\\rclone.exe";
            rclone.StartInfo.Arguments              = command;
            rclone.StartInfo.RedirectStandardInput  = true;
            rclone.StartInfo.RedirectStandardError  = true;
            rclone.StartInfo.RedirectStandardOutput = true;
            rclone.StartInfo.WorkingDirectory       = Environment.CurrentDirectory + "\\rclone";
            rclone.StartInfo.CreateNoWindow         = true;
            //On debug we want to see when rclone is open
            if (MainForm.debugMode == true)
            {
                rclone.StartInfo.CreateNoWindow = false;
            }
            rclone.StartInfo.UseShellExecute = false;
            rclone.Start();

            rclone.StandardInput.WriteLine(command);
            rclone.StandardInput.Flush();
            rclone.StandardInput.Close();

            string output = rclone.StandardOutput.ReadToEnd();
            string error  = rclone.StandardError.ReadToEnd();

            rclone.WaitForExit();

            //if there is one of these errors, we switch the mirrors
            if (error.Contains("cannot fetch token") || error.Contains("authError") || (error.Contains("quota") && error.Contains("exceeded")))
            {
                string oldRemote = MainForm.currentRemote;
                try
                {
                    Program.form.SwitchMirrors();
                }
                catch
                {
                    return(new ProcessOutput("All mirrors are on quota or down...", "All mirrors are on quota or down..."));
                }
                prcoutput = runRcloneCommand(originalCommand.Replace(oldRemote, MainForm.currentRemote), bandwithLimit);
            }
            else
            {
                prcoutput.Output = output;
                prcoutput.Error  = error;
            }
            Logger.Log($"Rclone error: {error}\nRclone Output: {output}");
            return(prcoutput);
        }