예제 #1
0
 private static void ConnectToAdb(AdbCommandRunner runner)
 {
     if (runner.Connect(BlueStacks.ConfigHttpProxy.ConfigHttpProxy.sVMName))
     {
         return;
     }
     Console.Error.WriteLine("Cannot connect to guest.  Please make sure BlueStacks is running.");
     Environment.Exit(1);
 }
        private bool FreeDiskSpace(string vm)
        {
            Logger.Info("In FreeDiskSpace");
            AdbCommandRunner runner = new AdbCommandRunner(vm);

            try
            {
                if (!runner.Connect(vm))
                {
                    Logger.Warning("Cannot connect to guest");
                    return(false);
                }
                if (!runner.RunShellPrivileged("stop"))
                {
                    return(false);
                }
                runner.RunShellPrivileged("swapoff /data/swap_space");
                Thread.Sleep(2000);
                if (!runner.RunShellPrivileged("mount -o remount,ro /data"))
                {
                    return(false);
                }
                this.ParentWindow.UpdateProgress(30.0);
                this.ParentWindow.Dispatcher.Invoke((Delegate)(() =>
                {
                    this.progressTimer = new System.Windows.Forms.Timer();
                    this.progressTimer.Tick += new EventHandler(this.ProgressTimer_Tick);
                    this.progressTimer.Interval = 6000;
                    this.progressTimer.Start();
                }));
                if (!this.RunZeroFreeAndroid(runner))
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                Logger.Error("Error in freeing disk space err:" + ex.ToString());
                return(false);
            }
            finally
            {
                runner.Dispose();
            }
            return(true);
        }