Пример #1
0
 private void MainForm_Bugreport(object sender, MouseEventArgs e)
 {
     btn_bugreport.Enabled = false;
     ShowInfo("抓取bugreport中,成功后将保存在桌面...");
     AdbHelper.CatchBugreport(GetSelectedDeviceNo());
     ShowInfo("");
 }
Пример #2
0
        private void MainForm_refresh(object sender, MouseEventArgs e)
        {
            ShowInfo("获取设备中...");
            btnRefresh.Enabled = false;
            btnFill.Enabled    = false;
            cbbDevices.Items.Clear();
            cbbDevices.Text    = "";
            txbDeviceInfo.Text = "";
            //启动服务
            if (!AdbHelper.StartServer())
            {
                ShowInfo("服务启动失败!");
                btnRefresh.Enabled = true;
                return;
            }
            string[] mDevices = AdbHelper.GetDevices();
            if (mDevices.Length == 0)
            {
                ShowInfo("未查找到可用设备!");
                btnRefresh.Enabled = true;
                return;
            }
            cbbDevices.Items.AddRange(mDevices);
            cbbDevices.SelectedIndex = 0;

            btnRefresh.Enabled    = true;
            btn_bugreport.Enabled = true;
            btnFill.Enabled       = true;
        }
Пример #3
0
        private void UpdatePartitionInfo()
        {
            Console.WriteLine("GetPartitionInfo begin");
            var partitionInfo = AdbHelper.GetPartitionInfo(GetSelectedDeviceNo(), rb_internal.Checked);

            Console.WriteLine(partitionInfo.Length);
            if (partitionInfo.Length <= 0)
            {
                ShowInfo("获取分区信息失败!");
                Console.WriteLine("获取分区信息失败");
                mAvaliableSize = 0;
                return;
            }
            ShowInfo("");

            try
            {
                mAvaliableSize = long.Parse(partitionInfo[3]) /* - (long.Parse(partitionInfo[3]) % 1024)*/;
                Console.WriteLine(mAvaliableSize);
                txb_avail_size.Text = " " + mAvaliableSize / 1024 + " MB";
            }
            catch (Exception)
            {
            }
            if (mAvaliableSize <= (5 * 1024))
            {
                btn_bugreport.Enabled = false;
            }
        }
Пример #4
0
 /// <summary>
 /// 使用中のリソースをすべてクリーンアップします。
 /// </summary>
 /// <param name="disposing">マネージ リソースを破棄する場合は true を指定し、その他の場合は false を指定します。</param>
 protected override void Dispose(bool disposing)
 {
     if (disposing && (components != null))
     {
         AdbHelper.KillServer();
         components.Dispose();
     }
     base.Dispose(disposing);
 }
Пример #5
0
        private void CbbDevices_SelectedIndexChanged(object sender, EventArgs e)
        {
            Console.WriteLine("cbbDevices_SelectedIndexChanged");
            var deviceNo = GetSelectedDeviceNo();

            txbDeviceInfo.Text = string.Format("{0} {1}",
                                               AdbHelper.GetDeviceBrand(deviceNo),
                                               AdbHelper.GetDeviceModel(deviceNo));
            UpdatePartitionInfo();
        }
Пример #6
0
 protected override void OnExit(ExitEventArgs e)
 {
     base.OnExit(e);
     Logger.Info(this, "Exit code : " + e.ApplicationExitCode);
     if (e.ApplicationExitCode != HAVE_OTHER_PROCESS)
     {
         AdbHelper.KillAllAdbProcess();
     }
     if (Settings.Default.IsFirstLaunch)
     {
         Settings.Default.IsFirstLaunch = false;
         Settings.Default.Save();
     }
     Settings.Default.Save();
 }
Пример #7
0
 /// <summary>
 /// 获取已连接的设备
 /// </summary>
 /// <returns></returns>
 public DevicesList GetDevices()
 {
     lock (executer)
     {
         DevicesList devList          = new DevicesList();
         var         adbDevicesOutput = executer.Execute(adbDevicesCmd);
         if (!adbDevicesOutput.IsSuccessful)
         {
             AdbHelper.RisesAdbServerStartsFailedEvent();
             return(devList);
         }
         var fastbootDevicesOutput = executer.Execute(fbDevicesCmd);
         AdbParse(adbDevicesOutput, ref devList);
         FastbootParse(fastbootDevicesOutput, ref devList);
         return(devList);
     }
 }
Пример #8
0
        /// <summary>
        /// 初始化
        /// </summary>
        private void Init()
        {
            if (adb == null)
            {
                adb = new AdbHelper(this.adbDir);
            }

            //设置进程选择框可搜索
            cmbProcess.AutoCompleteSource = AutoCompleteSource.ListItems;
            cmbProcess.AutoCompleteMode   = AutoCompleteMode.SuggestAppend;
            cmbProcess.DisplayMember      = "Value";
            cmbProcess.ValueMember        = "Key";
            cmbLevel.DropDownStyle        = ComboBoxStyle.DropDownList;
            //防止DropDownList 显示为灰色像禁用状态
            cmbLevel.FlatStyle = FlatStyle.Popup;
            cmbLevel.Items.AddRange(new string[] { "V--verbose", "D--debug", "I--info", "W--warn", "E--error", "F--fatal", "S--silent" });
            txtLogs.ReadOnly = true;
        }
Пример #9
0
 /// <summary>
 /// 链接
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnConnect_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(txtIp.Text.Trim()))
     {
         new Task(() =>
         {
             try
             {
                 if (txtAdbDir.Text != "默认使用系统环境变量")
                 {
                     adbDir = txtAdbDir.Text + "\\";
                 }
                 if (adb == null)
                 {
                     adb = new AdbHelper(adbDir);
                 }
                 logger.Info("正在检查adb..");
                 var flag = adb.CheckAdb();
                 logger.Info("adb:" + flag);
                 if (!flag)
                 {
                     UiShowMsg("没有找到adb软件");
                     return;
                 }
                 //判断是否已经连接
                 if (connect)
                 {
                     DisConnect();
                 }
                 else
                 {
                     Connect();
                 }
             }
             catch (Exception ex)
             {
                 logger.Error(ex.Message + "\r\n" + ex.StackTrace);
             }
         }).Start();
     }
 }
Пример #10
0
        private void MainForm_fill(object sender, MouseEventArgs e)
        {
            if (mAvaliableSize <= 1024)
            {
                return;
            }
            btnFill.Enabled        = false;
            mPushProgressBar.Value = 0;
            mPushProgressText.Text = "0%";
            ShowInfo("生成缓存文件...");
            int reppeat = FileHelper.CreateNewTempFile(mAvaliableSize * 1024);

            mPushProgressBar.Maximum = reppeat;
            mPushProgressBar.Value   = 0;
            mPushProgressText.Text   = "0%";
            ShowInfo("正在拷贝文件...");
            AdbHelper.CopyToDevice(GetSelectedDeviceNo(), FileHelper.FilePath, AdbHelper.CopyPath, reppeat, mPushProgressBar, mPushProgressText);
            ShowInfo("删除缓存文件");
            FileHelper.DeleteTempFile();
            UpdatePartitionInfo();
            ShowInfo("填充完成!");
            btnFill.Enabled = true;
        }
Пример #11
0
        public void Load()
        {
#if PAID_VERSION
            App.Current.Dispatcher.Invoke(() =>
            {
                loadingWindowApi.SetProgress(10);
                loadingWindowApi.SetTip(App.Current.Resources["ldmsgLoginAccount"].ToString());
            });
            if (Login() == false)
            {
                App.Current.Dispatcher.Invoke(() => App.Current.Shutdown(1));
            }
#endif
            //如果设置在启动时打开调试窗口
            if (Settings.Default.ShowDebuggingWindowNextLaunch)
            {
                //打开调试窗口
                App.Current.Dispatcher.Invoke(() =>
                {
                    new DebugWindow().Show();
                });
            }
            PrintInfo();
            //启动ADB服务
            App.Current.Dispatcher.Invoke(() =>
            {
                loadingWindowApi.SetProgress(30);
                loadingWindowApi.SetTip(App.Current.Resources["ldmsgStartAdb"].ToString());
            });

            bool success  = false;
            bool tryAgain = true;
            while (!success)
            {
                Logger.Info(this, "Try to start adb server ");
                success = AdbHelper.StartServer();
                Logger.Info(this, success ? "adb server starts success" : "adb server starts failed...");
                if (!success)
                {
                    App.Current.Dispatcher.Invoke(() =>
                    {
                        tryAgain = BoxHelper.ShowChoiceDialog(
                            "msgWarning",
                            "msgStartAdbServerFail",
                            "btnExit", "btnIHaveCloseOtherPhoneHelper").ToBool();
                    });
                }
                if (tryAgain)
                {
                    Thread.Sleep(2000);
                }
                else
                {
                    App.Current.Dispatcher.Invoke(() =>
                    {
                        App.Current.Shutdown(App.HAVE_OTHER_PROCESS);
                    });
                }
            }
            App.Current.Dispatcher.Invoke(() =>
            {
                //初始化主窗口
                App.Current.MainWindow = new MainWindow();
                //初始化拓展模块及其API框架
                loadingWindowApi.SetProgress(60);
                loadingWindowApi.SetTip(App.Current.Resources["ldmsgLoadingExtensions"].ToString());
            });
            OpenFrameworkManager.LoadApi();
            App.Current.OpenFrameworkManager.ReloadAllScript();
            App.Current.OpenFrameworkManager.LoadAllExtension();

            //启动设备拔插监听器
            App.Current.Dispatcher.Invoke(() =>
            {
                loadingWindowApi.SetProgress(80);
                loadingWindowApi.SetTip(App.Current.Resources["ldmsgStartDeviceMonitor"].ToString());
            });
            DevicesMonitor.Begin();

            //加载完成,启动主界面
            App.Current.Dispatcher.Invoke(() =>
            {
                loadingWindowApi.SetProgress(100);
                loadingWindowApi.Finish();
                App.Current.MainWindow.Show();
            });
        }
Пример #12
0
 private void MainForm_Load(object sender, EventArgs e)
 {
     AdbHelper.StopServer();
     btnFill.Enabled = false;
 }
Пример #13
0
 private void MainForm_Closing(object sender, FormClosingEventArgs e)
 {
     AdbHelper.StopServer();
 }