예제 #1
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
        }
예제 #2
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);
            });
        }