Esempio n. 1
0
        private void Load()
        {
            LoggingStation.Instance.Work();
            Updater.CheckAndNotice();
            Statistics.Do();
            ui.Progress = 0;
            //如果设置在启动时打开调试窗口
            if (Settings.Default.ShowDebuggingWindowNextLaunch)
            {
                //打开调试窗口
                App.Current.Dispatcher.Invoke(() =>
                {
                    new LogWindow().Show();
                });
            }
            logger.Info("");
            logger.Info("======================");
            logger.Info($"Run as " + (Self.HaveAdminPermission ? "Admin" : "Normal user"));
            logger.Info($"AutumnBox version: {Self.Version}");
            logger.Info($"SDK version: {BuildInfo.SDK_VERSION}");
            logger.Info($"Windows version {Environment.OSVersion.Version}");
            logger.Info("======================");
            logger.Info("===loading===");
#if DEBUG
            Basic.Util.Debugging.LoggingStation.Logging += (s, e) =>
            {
                LoggingStation.Instance.Log(e.Tag, e.Level.ToString(), e.Text);
            };
#endif
            ui.Progress   = 30;
            ui.LoadingTip = App.Current.Resources["ldmsgStartAdb"].ToString();

            try
            {
                logger.Info("trying starts adb server ");
                Adb.DefaultLoad();
                logger.Info("adb server starts successed");
            }
            catch (AdbCommandFailedException e)
            {
                logger.Info("adb server starts failed");
                logger.Warn(e);
                ui.Progress   = 60;
                ui.LoadingTip = App.Current.Resources["ldmsgAdbServerFailed"].ToString();
                Thread.Sleep(10000);
                App.Current.Shutdown(e.ExitCode);
            }
            ui.Progress   = 60;
            ui.LoadingTip = App.Current.Resources["ldmsgLoadingExtensions"].ToString();
            OpenFrameworkManager.Init();
            OpenFxObserver.Instance.OnLoaded();
            ConnectedDevicesListener.Instance.Work();
            ui.Progress   = 100;
            ui.LoadingTip = "Enjoy!";
            Thread.Sleep(1 * 1000);
            logger.Info("===loaded===");
            ui.Finish();
        }
Esempio n. 2
0
        private void Load()
        {
            LoggingStation.Instance.Work();
            ui.Progress = 0;
            //如果设置在启动时打开调试窗口
            if (Settings.Default.ShowDebuggingWindowNextLaunch)
            {
                //打开调试窗口
                App.Current.Dispatcher.Invoke(() =>
                {
                    new LogWindow().Show();
                });
            }
            logger.Info("");
            logger.Info("======================");
            logger.Info($"Run as " + (Self.HaveAdminPermission ? "Admin" : "Normal user"));
            logger.Info($"AutumnBox version: {Self.Version}");
            logger.Info($"SDK version: {BuildInfo.SDK_VERSION}");
            logger.Info($"Windows version {Environment.OSVersion.Version}");
            logger.Info("======================");
            Basic.Util.Debugging.LoggingStation.Logging += (s, e) =>
            {
#if !DEBUG
                if (e.Tag.ToLower() == "debug")
                {
                    return;
                }
#endif
                LoggingStation.Instance.Log(e.Tag, e.Level.ToString(), e.Text);
            };
            ui.Progress   = 30;
            ui.LoadingTip = App.Current.Resources["ldmsgStartAdb"].ToString();
            try
            {
                logger.Info("trying starts adb server ");
                DirectoryInfo adbRootDir  = new DirectoryInfo("Resources/AdbExecutable/");
                FileInfo      adbExe      = new FileInfo("Resources/AdbExecutable/adb.exe");
                FileInfo      fastbootExe = new FileInfo("Resources/AdbExecutable/fastboot.exe");
                IAdbServer    server      = LocalAdbServer.Instance;
                logger.Info($"lanunching adb server at {server.IP}:{server.Port}");
                Adb.Load(adbRootDir, adbExe, fastbootExe, server, true);
            }
            catch (Exception e)
            {
                LocalAdbServer.Instance.InvalidKill = true;
                logger.Warn("can not start adb server!", e);
                App.Current.Dispatcher.Invoke(() =>
                {
                    new AdbFailedWindow(e.Message)
                    {
                        Owner = App.Current.MainWindow
                    }.ShowDialog();
                });
            }

            ui.Progress   = 60;
            ui.LoadingTip = App.Current.Resources["ldmsgLoadingExtensions"].ToString();
            OpenFrameworkManager.Init();
            OpenFxObserver.Instance.OnLoaded();
            ConnectedDevicesListener.Instance.Work();

            ui.Progress   = 90;
            ui.LoadingTip = "How can a man die better?";
            Updater.CheckAndNotice();
            Statistics.Do();
            ToastMotd.Do();

            ui.Progress   = 100;
            ui.LoadingTip = "Enjoy!";
            Thread.Sleep(1 * 1000);
            ui.Finish();
        }