コード例 #1
0
        private static void ResetProxy()
        {
            Console.WriteLine("Resetting proxy configuration.");
            BlueStacks.ConfigHttpProxy.ConfigHttpProxy.CheckIfGuestReady();
            AdbCommandRunner runner = new AdbCommandRunner("Android");

            BlueStacks.ConfigHttpProxy.ConfigHttpProxy.ConnectToAdb(runner);
            BlueStacks.ConfigHttpProxy.ConfigHttpProxy.CopyXMLToSDCard(runner);
            runner.Pull(BlueStacks.ConfigHttpProxy.ConfigHttpProxy.SDCARD_FILE_PATH, BlueStacks.ConfigHttpProxy.ConfigHttpProxy.TEMP_XML_FILE_PATH);
            XMLManipulation.DeleteFromXMLFile("global_http_proxy_host");
            XMLManipulation.DeleteFromXMLFile("global_http_proxy_port");
            XMLManipulation.DeleteFromXMLFile("global_http_proxy_exclusion_list");
            runner.Push(BlueStacks.ConfigHttpProxy.ConfigHttpProxy.TEMP_XML_FILE_PATH, BlueStacks.ConfigHttpProxy.ConfigHttpProxy.SDCARD_FILE_PATH);
            BlueStacks.ConfigHttpProxy.ConfigHttpProxy.MoveXMLToOrigLocationAndFixPermissions(runner);
            Console.WriteLine("Please wait while BlueStacks restarts.");
            runner.Dispose();
            BlueStacks.ConfigHttpProxy.ConfigHttpProxy.RestartBlueStacks();
            Console.WriteLine("HTTP proxy server was successfully removed.");
            Environment.Exit(0);
        }
コード例 #2
0
        private static void SetProxy(string host, string port)
        {
            Console.WriteLine("Setting proxy configuration: host = {0}, port = {1}", (object)host, (object)port);
            BlueStacks.ConfigHttpProxy.ConfigHttpProxy.CheckIfGuestReady();
            AdbCommandRunner runner = new AdbCommandRunner("Android");

            BlueStacks.ConfigHttpProxy.ConfigHttpProxy.ConnectToAdb(runner);
            BlueStacks.ConfigHttpProxy.ConfigHttpProxy.CopyXMLToSDCard(runner);
            runner.Pull(BlueStacks.ConfigHttpProxy.ConfigHttpProxy.SDCARD_FILE_PATH, BlueStacks.ConfigHttpProxy.ConfigHttpProxy.TEMP_XML_FILE_PATH);
            XMLManipulation.AppendToXMLFile("global_http_proxy_host", "91", host);
            XMLManipulation.AppendToXMLFile("global_http_proxy_port", "92", port);
            XMLManipulation.AppendToXMLFile("global_http_proxy_exclusion_list", "93", "127.0.0.1,10.0.2.2,10.0.2.15");
            runner.Push(BlueStacks.ConfigHttpProxy.ConfigHttpProxy.TEMP_XML_FILE_PATH, BlueStacks.ConfigHttpProxy.ConfigHttpProxy.SDCARD_FILE_PATH);
            BlueStacks.ConfigHttpProxy.ConfigHttpProxy.MoveXMLToOrigLocationAndFixPermissions(runner);
            Console.WriteLine("Process completed, please wait while BlueStacks restarts.");
            runner.Dispose();
            BlueStacks.ConfigHttpProxy.ConfigHttpProxy.RestartBlueStacks();
            Console.WriteLine("New HTTP proxy server was successfully configured.");
            Environment.Exit(0);
        }