Exemplo n.º 1
0
        private void b_install_apk_Click(object sender, RoutedEventArgs e)
        {
            string[] dirs   = { };
            var      dialog = new CommonOpenFileDialog();

            dialog.IsFolderPicker = true;
            if (dialog.ShowDialog() == CommonFileDialogResult.Ok)
            {
                dirs = dialog.FileNames.ToArray();
            }
            Install install = new Install();

            if (dirs.Length < 1)
            {
                util.dc.ConsoleInput = "Path wasn't specified, to complete APK install, give an exist path";
                return;
            }

            //show all apks in the folder
            string[] filePaths = Directory.GetFiles(dirs[0], "*.apk",
                                                    SearchOption.AllDirectories);


            string[] results = { };
            var      items   = new installedItems(filePaths.ToList());

            if ((bool)items.ShowDialog() == true)
            {
                results = System.IO.File.ReadAllLines(con.Get_ToInstall());
            }


            //wait till the list of items to be installed return


            var uiContext = SynchronizationContext.Current;

            if (results.Length > 0)
            {
                this.Dispatcher.Invoke((Action) delegate
                {
                    Task.Run(() => install.Install_APKs(results)).ContinueWith(task => uiContext.Send(x => logItems.Add(Utilities.TextToLog), null));
                });


                //var run = Task.Run(() => install.Install_APKs(results)).ContinueWith(failedTask => Console.WriteLine("APK is already installed"),
                //               TaskContinuationOptions.OnlyOnFaulted);
            }
            else
            {
            }
        }
Exemplo n.º 2
0
        private void b_push_cal_Click(object sender, RoutedEventArgs e)
        {
            string[] dirs   = { };
            var      dialog = new CommonOpenFileDialog();

            dialog.IsFolderPicker = true;
            if (dialog.ShowDialog() == CommonFileDialogResult.Ok)
            {
                dirs = dialog.FileNames.ToArray();
            }
            Install install = new Install();

            if (dirs.Length < 1)
            {
                util.dc.ConsoleInput = "Path wasn't specified, to complete APK install, give an exist path";
                return;
            }

            //show all apks in the folder
            string[] filePaths = Directory.GetFiles(dirs[0], "*.cal",
                                                    SearchOption.AllDirectories);


            string[] results = { };
            var      items   = new installedItems(filePaths.ToList());

            if ((bool)items.ShowDialog() == true)
            {
                results = System.IO.File.ReadAllLines(con.Get_ToInstall());
            }

            var uiContext = SynchronizationContext.Current;



            var t = Task.Run(() => pushCalib(results)).ContinueWith(task => uiContext.Send(x => logItems.Add(Utilities.TextToLog), null));

            if (Utilities.Progress == 100)
            {
                if (t.Status == TaskStatus.Faulted)
                {
                    foreach (var i in t.Exception.InnerExceptions)
                    {
                        Error.Text = i.Message;
                        logItems.Add(Error);
                    }
                }
            }
        }
Exemplo n.º 3
0
        static int Main(string[] args)
        {
            Install installer = new Install(args);

            return(installer.Up());
        }
Exemplo n.º 4
0
        private void One_Shot_Install_Click(object sender, RoutedEventArgs e)
        {
            PushPullFiles pushPull  = new PushPullFiles();
            var           uiContext = SynchronizationContext.Current;

            List <string> apkFilePathsFiltered = new List <string>();
            List <string> imgFilePathsFiltered = new List <string>();
            List <string> calFilePathsFiltered = new List <string>();
            List <string> hexFilePathsFiltered = new List <string>();
            List <string> iniFilePathsFiltered = new List <string>();


            Install install = new Install();

            if (!install.One_shot_Install())
            {
                return;
            }


            var items = new installedItemsOneShot();

            if ((bool)items.ShowDialog() == false)
            {
                return;
            }


            l_calib_files_val.Content  = "None";
            l_config_files_val.Content = "None";
            l_engine_val.Content       = "None";
            l_hexagon_val.Content      = "None";
            l_release_val.Content      = "None";
            l_config_files_val.Content = "None";
            Utilities.Hexagon          = "";

            if (!File.Exists(con.Get_ToInstall()))
            {
                return;
            }

            var files = File.ReadAllLines(con.Get_ToInstall());

            foreach (var item in files)
            {
                Console.WriteLine(System.IO.Path.GetExtension(item));
                if (System.IO.Path.GetExtension(item).Equals(".img"))
                {
                    imgFilePathsFiltered.Add(item);
                }

                if (System.IO.Path.GetExtension(item).Equals(".apk"))
                {
                    apkFilePathsFiltered.Add(item);
                }
                if (System.IO.Path.GetExtension(item).Equals(".cal"))
                {
                    calFilePathsFiltered.Add(item);
                }
                if (System.IO.Path.GetExtension(item).Equals(".so") && item.Contains("testsig-0x"))
                {
                    hexFilePathsFiltered.Add(item);
                }
                if (System.IO.Path.GetExtension(item).Equals(".ini"))
                {
                    iniFilePathsFiltered.Add(item);
                }
            }

            //install images
            Utilities.Progress = 20;
            //if (imgFilePathsFiltered.Count > 0)
            //{
            //    var t2 = new Task(() => install.Install_APKs(imgFilePathsFiltered.ToArray()));
            //    var t1 = Task.Run(() => install.Enter_Boot_Loader(imgFilePathsFiltered.ToArray()));
            //    Utilities.Progress += 10 ;
            //    await t1.ContinueWith(task => uiContext.Send(x => logItems.Add(Utilities.TextToLog), null));
            //    //await t1.ContinueWith(t2.Start());

            //}
            this.Dispatcher.Invoke((Action) delegate
            {
                Item i = new Item()
                {
                    Text = "Waiting 60 seconds after reboot before continue"
                };
                Item j = new Item()
                {
                    Text = "Installing APKs"
                };
                string pushHex = "";
                if (hexFilePathsFiltered.Count > 0)
                {
                    pushHex = string.Format("adb push {0} /system/lib/rfsa/adsp", hexFilePathsFiltered[0]);
                }
                //install images
                Utilities.Progress      = 25;
                var backgroundScheduler = TaskScheduler.Default;
                var uiScheduler         = TaskScheduler.FromCurrentSynchronizationContext();
                //install img

                //pause check device connectivity
                Utilities.Pause = true;
                Task.Factory.StartNew(delegate { install.Enter_Boot_Loader(imgFilePathsFiltered.ToArray()); },
                                      backgroundScheduler).
                ContinueWith(delegate { uiContext.Send(x => logItems.Add(Utilities.TextToLog), null); }, uiScheduler).

                ContinueWith(delegate { uiContext.Send(x => logItems.Add(i), null); }, uiScheduler).

                ContinueWith(delegate { Utilities.Pause = false; }, uiScheduler).

                ContinueWith(delegate { install.Fastboot_Reboot(); },
                             backgroundScheduler).

                ContinueWith(delegate { uiContext.Send(x => logItems.Add(Utilities.TextToLog), null); }, uiScheduler).



                //install apk
                ContinueWith(delegate { uiContext.Send(x => logItems.Add(j), null); }, uiScheduler).

                ContinueWith(delegate { install.Install_APKs(apkFilePathsFiltered.ToArray()); },
                             backgroundScheduler).

                ContinueWith(delegate { uiContext.Send(x => logItems.Add(Utilities.TextToLog), null); }, uiScheduler).



                //copy Calibrations files
                ContinueWith(delegate { pushPull.PushCalib(calFilePathsFiltered.ToArray(), true); },
                             backgroundScheduler).
                ContinueWith(delegate { uiContext.Send(x => logItems.Add(Utilities.TextToLog), null); }, uiScheduler).

                ContinueWith(delegate { util.proc("adb root", true); },
                             backgroundScheduler).
                ContinueWith(delegate { uiContext.Send(x => logItems.Add(Utilities.TextToLog), null); }, uiScheduler).

                ContinueWith(delegate { util.proc("adb remount", true); },
                             backgroundScheduler).
                ContinueWith(delegate { uiContext.Send(x => logItems.Add(Utilities.TextToLog), null); }, uiScheduler).

                //wait after remount
                ContinueWith(delegate { Thread.Sleep(5000); },
                             backgroundScheduler).
                ContinueWith(delegate { uiContext.Send(x => logItems.Add(Utilities.TextToLog), null); }, uiScheduler).

                //copy hexagon
                ContinueWith(delegate { util.proc(pushHex, true); },
                             backgroundScheduler).
                ContinueWith(delegate { uiContext.Send(x => logItems.Add(Utilities.TextToLog), null); }, uiScheduler).

                ContinueWith(delegate { util.proc("adb reboot", true); },
                             backgroundScheduler);



                Utilities.Progress = 0;

                //pause check device connectivity
                Utilities.Pause = true;
            });



            //install apk
        }
Exemplo n.º 5
0
        private void b_install_Click(object sender, RoutedEventArgs e)
        {
            string[] empty   = {};
            string[] dir     = { };
            string[] results = { };
            var      dialog  = new CommonOpenFileDialog();

            dialog.IsFolderPicker = true;

            //CommonFileDialogResult result = dialog.ShowDialog();
            if (dialog.ShowDialog() == CommonFileDialogResult.Ok)
            {
                dir = dialog.FileNames.ToArray();
            }
            Install install = new Install();

            if (dir.Length < 1)
            {
                return;
            }


            string[] files = Directory.GetFiles(dir[0], "*.img",
                                                SearchOption.AllDirectories);

            List <string> files_ = new List <string>();
            List <string> inGame = new List <string>();

            JsonParser J_S        = new JsonParser();
            FirsrHirc  jsonObject = J_S.Parse();
            var        t          = jsonObject.install.list;

            foreach (var im in t)
            {
                inGame.Add(im.image);
            }

            foreach (var file in files)
            {
                string g = System.IO.Path.GetFileName(file);
                if (inGame.Contains(g))
                {
                    files_.Add(file);
                }
            }


            //show all images in the folder

            var items = new installedItems(files_.ToList());

            if (!(bool)items.ShowDialog() == true)
            {
                return;
            }

            l_calib_files_val.Content  = "None";
            l_config_files_val.Content = "None";
            l_engine_val.Content       = "None";
            l_hexagon_val.Content      = "None";
            l_release_val.Content      = "None";
            l_config_files_val.Content = "None";
            Utilities.Hexagon          = "";

            Item k = new Item()
            {
                Text = "Start instllation, it may take few minutes."
            };

            logItems.Add(k);
            var backgroundScheduler = TaskScheduler.Default;
            var uiScheduler         = TaskScheduler.FromCurrentSynchronizationContext();
            var uiContext           = SynchronizationContext.Current;

            this.Dispatcher.Invoke((Action) delegate
            {
                Item i = new Item()
                {
                    Text = "wait while device is rebooting, the installation wait 60 sec after reboot"
                };
                Task.Factory.StartNew(delegate { install.Enter_Boot_Loader(empty); },
                                      backgroundScheduler).
                ContinueWith(delegate { uiContext.Send(x => logItems.Add(Utilities.TextToLog), null); }, uiScheduler).
                ContinueWith(delegate { uiContext.Send(x => logItems.Add(i), null); }, uiScheduler).
                ContinueWith(delegate { install.Fastboot_Reboot(); }, backgroundScheduler).
                ContinueWith(delegate { uiContext.Send(x => logItems.Add(i), null); }, uiScheduler);
            });
        }
Exemplo n.º 6
0
        static void Main(string[] args)
        {
            Program program = new Program();

            foreach (var arg in args)
            {
                if (arg == "/?" || arg == "--help" || arg == "-h")
                {
                    Console.WriteLine("Установщик");
                    Console.WriteLine(@"Синтаксис: installer [параметр]");
                    Console.WriteLine("Параметры:");
                    Console.WriteLine("-c Скопировать файлы в исходный каталог");
                    Console.WriteLine("-r Удалить файлы из исходного каталога");
                    Console.WriteLine("-i Установить службу");
                    Console.WriteLine("-u Удалить службу");
                    Console.WriteLine("-start Запустить службу");
                    Console.WriteLine("-stop Остановить службу");
                    Console.WriteLine("-ct Создать задание");
                }

                if (arg == "-c")
                {
                    Install copy = new Install();
                    copy.CopyFiles();
                }

                if (arg == "-r")
                {
                    Install remove = new Install();
                    remove.Remove();
                }

                if (arg == "-i")
                {
                    Install installService = new Install();
                    installService.InstallService();
                }

                if (arg == "-u")
                {
                    Install uninstallService = new Install();
                    uninstallService.UninstallService();
                }

                if (arg == "-start")
                {
                    Install startService = new Install();
                    startService.StartService();
                }

                if (arg == "-stop")
                {
                    Install startService = new Install();
                    startService.StopService();
                }

                if (arg == "-ct")
                {
                    Install creatTask = new Install();
                    creatTask.CreateTask();
                }
            }

            Console.ReadKey();
        }