Ejemplo n.º 1
0
        void UpdateList(IEnumerable <AndroidVirtualDevice> toAdd, IEnumerable <string> toRemoveIniFiles)
        {
            lock (lockObj) {
                var dict = new Dictionary <string, AndroidVirtualDevice> ();
                foreach (var avd in VirtualDevices)
                {
                    dict[avd.Name] = avd;
                }

                if (toRemoveIniFiles != null)
                {
                    foreach (var r in toRemoveIniFiles)
                    {
                        dict.Remove(Path.GetFileNameWithoutExtension(r));
                    }
                }

                if (toAdd != null)
                {
                    foreach (var a in toAdd)
                    {
                        dict[a.Name] = a;
                    }
                }

                var l = new AndroidVirtualDevice[dict.Count];
                int i = 0;
                foreach (var kvp in dict)
                {
                    l[i++] = kvp.Value;
                }
                VirtualDevices = l;
            }
            OnChanged();
        }
Ejemplo n.º 2
0
        //TODO: handle errors
        public AvdWatcher()
        {
            VirtualDevices = new AndroidVirtualDevice[0];

            FilePath home = Environment.GetFolderPath(Environment.SpecialFolder.Personal);

            if (PropertyService.IsWindows)
            {
                home = home.ParentDirectory;
            }
            avdDir = home.Combine(".android", "avd");
            if (!Directory.Exists(avdDir))
            {
                Directory.CreateDirectory(avdDir);
            }

            var avds = Directory.GetFiles(avdDir, "*.ini");

            UpdateAvds(avds, null);

            //FSW on mac is unreliable
            if (PropertyService.IsMac)
            {
                modTimes = new Dictionary <string, DateTime> ();
                foreach (var f in avds)
                {
                    modTimes[f] = File.GetLastWriteTimeUtc(f);
                }
                timeoutId = GLib.Timeout.Add(750, HandleTimeout);
            }
            else
            {
                CreateFsw();
            }
        }
Ejemplo n.º 3
0
		//TODO: handle errors
		public AvdWatcher ()
		{
			VirtualDevices = new AndroidVirtualDevice[0];
			
			FilePath home = Environment.GetFolderPath (Environment.SpecialFolder.Personal);
			if (PropertyService.IsWindows) {
				home = home.ParentDirectory;
			}
			avdDir = home.Combine (".android", "avd");
			if (!Directory.Exists (avdDir))
				Directory.CreateDirectory (avdDir);
			
			var avds = Directory.GetFiles (avdDir, "*.ini");
			UpdateAvds (avds, null);
			
			//FSW on mac is unreliable
			if (PropertyService.IsMac) {
				modTimes = new Dictionary<string, DateTime> ();
				foreach (var f in avds)
					modTimes[f] = File.GetLastWriteTimeUtc (f);
				timeoutId = GLib.Timeout.Add (750, HandleTimeout);
			} else {
				CreateFsw ();
			}
		}
Ejemplo n.º 4
0
        public void StartEmulator(AndroidVirtualDevice avd)
        {
            //FIXME: actually log the output and status
            var op = MonoDroidFramework.Toolbox.StartAvd(avd);

            emulatorHandles.Add(op);
            op.Completed += HandleEmulatorStarted;
        }
Ejemplo n.º 5
0
        public StartAvdOperation StartAvd(AndroidVirtualDevice avd)
        {
            var args = new ProcessArgumentBuilder();

            args.Add("-partition-size", "512", "-avd");
            args.AddQuoted(avd.Name);
            args.Add("-prop");
            args.AddQuoted("monodroid.avdname=" + avd.Name);

            var error   = new StringWriter();
            var process = StartProcess(EmulatorExe, args.ToString(), null, error);

            return(new StartAvdOperation(process, error));
        }
Ejemplo n.º 6
0
        void UpdateAvds(IEnumerable <string> addedOrChangedInis, IEnumerable <string> removedInis)
        {
            List <AndroidVirtualDevice> toAdd = null;

            if (addedOrChangedInis != null)
            {
                toAdd = new List <AndroidVirtualDevice> ();
                foreach (var ini in addedOrChangedInis)
                {
                    try {
                        var avd = AndroidVirtualDevice.Load(ini);
                        toAdd.Add(avd);
                    } catch (Exception ex) {
                        LoggingService.LogError("Error loading avd " + ini, ex);
                    }
                }
            }

            if ((toAdd != null && toAdd.Count > 0) || (removedInis != null))
            {
                UpdateList(toAdd, removedInis);
            }
        }
Ejemplo n.º 7
0
		public void StartEmulator (AndroidVirtualDevice avd)
		{
			//FIXME: actually log the output and status
			var op = MonoDroidFramework.Toolbox.StartAvd (avd);
			op.Completed += HandleEmulatorStarted;
		}
Ejemplo n.º 8
0
		void UpdateList (IEnumerable<AndroidVirtualDevice> toAdd, IEnumerable<string> toRemoveIniFiles)
		{
			lock (lockObj) {
				var dict = new Dictionary<string,AndroidVirtualDevice> ();
				foreach (var avd in VirtualDevices)
					dict[avd.Name] = avd;
				
				if (toRemoveIniFiles != null)
					foreach (var r in toRemoveIniFiles)
						dict.Remove (Path.GetFileNameWithoutExtension (r));
				
				if (toAdd != null)
					foreach (var a in toAdd)
						dict[a.Name] = a;
				
				var l = new AndroidVirtualDevice[dict.Count];
				int i = 0;
				foreach (var kvp in dict)
					l[i++] = kvp.Value;
				VirtualDevices = l;
			}
			OnChanged ();
		}
Ejemplo n.º 9
0
		public StartAvdOperation StartAvd (AndroidVirtualDevice avd)
		{
			var args = new ProcessArgumentBuilder ();
			args.Add ("-partition-size", "512", "-avd");
			args.AddQuoted (avd.Name);
			args.Add ("-prop");
			args.AddQuoted ("monodroid.avdname=" + avd.Name);

			var error = new StringWriter ();
			var process = StartProcess (EmulatorExe, args.ToString (), null, error);
			return new StartAvdOperation (process, error);
		}