コード例 #1
0
ファイル: JsonParser.cs プロジェクト: eladtamari/installer_
        public FirsrHirc Parse()
        {
            string    fileName = @"Config.JSON";
            string    js       = File.ReadAllText(fileName);
            FirsrHirc fJson    = JsonConvert.DeserializeObject <FirsrHirc>(js);

            return(fJson);
        }
コード例 #2
0
        public void Enter_Boot_Loader(string[] images)
        {
            Utilities  util       = new Utilities();
            Constants  con        = new Constants();
            JsonParser J_S        = new JsonParser();
            FirsrHirc  jsonObject = J_S.Parse();

            int l = 0;

            try
            {
                util.Check_devices();
            }
            catch
            {
                throw new AccessViolationException("The Device not responding  may be disconnected");
            }

            string boot = "adb reboot bootloader";

            if (!string.Equals(Utilities.ConnectionVal, "Fastboot"))
            {
                util.proc(boot, true);
                string out_ = util.Output;

                try
                {
                    Thread.Sleep(1000);
                    util.Check_devices();
                }
                catch
                {
                    throw new AccessViolationException("The Device not responding  may be disconnected");
                    //// need to add write to console the debug went down to boot
                }
            }


            //check id there are images as input if not take it from the file
            string[] results;
            if (images.Length < 1)
            {
                results = System.IO.File.ReadAllLines(con.Get_ToInstall());
                if (results.Length < 1)
                {
                    return;
                }
            }
            else
            {
                results = images;
            }


            l = jsonObject.install.list.Count;
            int count = 100 / l;

            Utilities.Progress = 10;
            bool flag;

            foreach (var obj in jsonObject.install.list)
            {
                flag = false;
                foreach (var j in results)
                {
                    if (j.Contains(obj.image))
                    {
                        flag = true;
                        break;
                    }
                }
                if (!flag)
                {
                    continue;
                }

                boot = string.Format(@"fastboot flash {0} {1}\{2}", obj.partition, Path.GetDirectoryName(results[0]), obj.image);

                //pause update GUI while in fastboot
                Utilities.Pause = true;

                util.proc(boot, true);


                int i = 0;
                while (!String.Equals(Utilities.ConnectionVal, "Fastboot") && i < 20)
                {
                    Thread.Sleep(5000);
                    i++;
                }

                Utilities.Progress = l + count;
            }
            Utilities.Pause    = false;
            Utilities.Progress = 90;
        }
コード例 #3
0
        public bool One_shot_Install()
        {
            //form to summerize the preinstall
            //in the form img, apk, cal, hexagon, config

            //install img
            //install apks
            //copy cal to /sdcard/iar
            //copy hexagon to "/system/lib/rfsa/adsp"

            //Dialog
            string[] dirs   = { };
            var      dialog = new CommonOpenFileDialog();

            dialog.IsFolderPicker = true;
            if (dialog.ShowDialog() == CommonFileDialogResult.Ok)
            {
                dirs = dialog.FileNames.ToArray();
            }
            else
            {
                return(false);
            }


            if (dirs.Length < 1)
            {
                return(false);
            }


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

            imgFilePaths = Directory.GetFiles(dirs[0], "*.img",
                                              SearchOption.AllDirectories).ToList();

            hexFilePaths = Directory.GetFiles(dirs[0], "test*.so",
                                              SearchOption.AllDirectories).ToList();

            iniFilePaths = Directory.GetFiles(dirs[0], "*.ini",
                                              SearchOption.AllDirectories).ToList();

            calFilePaths = Directory.GetFiles(dirs[0], "*.cal",
                                              SearchOption.AllDirectories).ToList();



            //filter out the images not for burn

            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 imgFilePaths)
            {
                string g = System.IO.Path.GetFileName(file);
                if (inGame.Contains(g))
                {
                    files_.Add(file);
                }
            }

            imgFilePaths = files_;
            return(true);
        }
コード例 #4
0
        public MainWindow()
        {
            InitializeComponent();

            JsonParser J_S        = new JsonParser();
            FirsrHirc  jsonObject = J_S.Parse();

            installer_.Title += jsonObject.install.version;


            //new log collection
            logItems = new ObservableCollection <Item>()
            {
                new Item()
                {
                    Text = "Logger"
                }
            };


            var bc = new BrushConverter();

            Utilities.LogTextColor = (System.Windows.Media.Brush)bc.ConvertFromString(Constants.White);
            Utilities.Hexagon      = "";
            Utilities.EnableDebug  = false;

            //bind the log collection to its UI asset
            log.ItemsSource = logItems;


            //set the infinity icon
            string iconsPath;

            iconsPath = System.IO.Path.Combine(Directory.GetCurrentDirectory(), "INFINITY_logo.png");
            if (File.Exists(iconsPath))
            {
                logo.Source = new BitmapImage(new Uri(iconsPath, UriKind.RelativeOrAbsolute));
            }


            //Start the backgroung workers
            BackgroundWorker worker = new BackgroundWorker();

            worker.DoWork += worker_DoWork;
            worker.RunWorkerAsync();

            BackgroundWorker worker_check_connection = new BackgroundWorker();

            worker_check_connection.DoWork += worker_CheckConnection;
            worker_check_connection.RunWorkerAsync();

            BackgroundWorker worker_check_battery = new BackgroundWorker();

            worker_check_battery.DoWork += worker_CheckBattary;
            worker_check_battery.RunWorkerAsync();


            //read the serial number
            var t = Task.Run(() =>
            {
                try
                {
                    util.Check_devices();
                    Thread.Sleep(1000);
                    l_serial_val.Content = Utilities.SerialNum;
                }
                catch (Exception ex)
                {
                    //util.change_color = true;
                    Console.WriteLine(ex);
                }
            });
        }
コード例 #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);
            });
        }