コード例 #1
0
        public IProcessAsyncOperation ForwardPort(AndroidDevice device, int devicePort, int localPort,
                                                  ProcessEventHandler outputLog, ProcessEventHandler errorLog)
        {
            var args = string.Format("-s {0} forward tcp:{1} tcp:{2}", device.ID, localPort, devicePort);

            return(StartProcess(AdbExe, args, outputLog, errorLog));
        }
コード例 #2
0
        public ProcessWrapper LogCat(AndroidDevice device, ProcessEventHandler outputLog,
                                     ProcessEventHandler errorLog)
        {
            var args = string.Format("-s {0} logcat", device.ID);

            return(StartProcess(AdbExe, args, outputLog, errorLog));
        }
コード例 #3
0
        public MonoDroidProcess(AndroidDevice device, string activity, string packageName,
                                Action <string> stdout, Action <string> stderr, IAsyncOperation startOp)
        {
            this.device      = device;
            this.packageName = packageName;
            this.stdout      = stdout;
            this.stderr      = stderr;

            //startTime = DateTime.Now;

            if (startOp == null)
            {
                StartTracking();
                return;
            }

            // Our launch intent.
            startOp.Completed += delegate(IAsyncOperation op) {
                if (!op.Success)
                {
                    SetCompleted(false);
                }
                else
                {
                    StartTracking();
                }
            };
        }
コード例 #4
0
ファイル: DeviceManager.cs プロジェクト: thild/monodevelop
        void AsyncGetProperties(AndroidDevice device)
        {
            var gpop = new AdbGetPropertiesOperation(device);

            lock (outstandingQueries) {
                outstandingQueries.Add(gpop);
            }
            gpop.Completed += delegate(IAsyncOperation op) {
                lock (outstandingQueries) {
                    if (disposed)
                    {
                        return;
                    }
                    outstandingQueries.Remove(gpop);
                    gpop.Dispose();
                }
                if (!op.Success)
                {
                    LoggingService.LogError(string.Format("Error getting properties from device '{0}'", device.ID), gpop.Error);
                    //fall through, to cache the null result for failed queries
                }
                lock (props) {
                    props [device.ID] = gpop.Properties;
                }
                if (Changed != null)
                {
                    Changed();
                }
            };
        }
コード例 #5
0
 public AdbTransportOperation(AndroidDevice device)
 {
     if (device == null)
     {
         throw new ArgumentNullException("device");
     }
     this.device = device;
 }
コード例 #6
0
        public IProcessAsyncOperation Uninstall(AndroidDevice device, string package, TextWriter outputLog, TextWriter errorLog)
        {
            var args = new ProcessArgumentBuilder();

            args.Add("-s", device.ID, "uninstall");
            args.AddQuoted(package);

            return(StartProcess(AdbExe, args.ToString(), outputLog, errorLog));
        }
コード例 #7
0
        public IProcessAsyncOperation PullFile(AndroidDevice device, string source, string destination,
                                               TextWriter outputLog, TextWriter errorLog)
        {
            var args = new ProcessArgumentBuilder();

            args.Add("-s", device.ID, "pull");
            args.AddQuoted(source, destination);

            return(StartProcess(AdbExe, args.ToString(), outputLog, errorLog));
        }
コード例 #8
0
        public AdbGetProcessIdOperation(AndroidDevice device, string packageName) :
            base(device)
        {
            if (packageName == null)
            {
                throw new ArgumentNullException("packageName");
            }

            this.packageName = packageName;
            BeginConnect();
        }
コード例 #9
0
        public AdbTrackLogOperation(AndroidDevice device, Action <string> output, params string [] parameters) : base(device)
        {
            if (output == null)
            {
                throw new ArgumentNullException("output");
            }

            this.output     = output;
            this.parameters = parameters;

            BeginConnect();
        }
コード例 #10
0
        public InstallPackageOperation Install(AndroidDevice device, string package, TextWriter outputLog, TextWriter errorLog)
        {
            var args = new ProcessArgumentBuilder();

            args.Add("-s", device.ID, "install");
            args.AddQuoted(package);

            var errorCapture = new StringWriter();
            var errorWriter  = TeeTextWriter.ForNonNull(errorCapture, errorCapture);

            return(new InstallPackageOperation(StartProcess(AdbExe, args.ToString(), outputLog, errorWriter), errorCapture));
        }
コード例 #11
0
		public MonoDroidExecutionCommand (string packageName, AndroidDevice device, FilePath apkPath,
			TargetRuntime runtime, TargetFramework framework, bool debugMode)
		{
			this.Device = device;
			this.PackageName = packageName;
			this.ApkPath = apkPath;
			this.Runtime = runtime;
			this.Framework = framework;
			this.DebugMode = debugMode;
			
			DebugPort = MonoDroidSettings.DebuggerPort;
			OutputPort = MonoDroidSettings.DebuggerOutputPort;
		}
コード例 #12
0
        public AdbShellOperation SetProperty(AndroidDevice device, string property, string value)
        {
            if (property == null)
            {
                throw new ArgumentNullException("property");
            }
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }

            return(new AdbShellOperation(device, string.Format("setprop \"{0}\" \"{1}\"", property, value)));
        }
コード例 #13
0
        //may block while it's showing a GUI. project MUST be built before calling this
        public static MonoDroidUploadOperation SignAndUpload(IProgressMonitor monitor, MonoDroidProject project,
                                                             ConfigurationSelector configSel, bool forceReplace, ref AndroidDevice device)
        {
            var conf  = project.GetConfiguration(configSel);
            var opMon = new AggregatedOperationMonitor(monitor);

            InvokeSynch(() => MonoDroidFramework.EnsureSdksInstalled());

            IAsyncOperation signOp = null;

            if (project.PackageNeedsSigning(configSel))
            {
                ClearUploadFlags(conf);
                signOp = project.SignPackage(configSel);
                opMon.AddOperation(signOp);
            }

            if (device == null)
            {
                device = InvokeSynch(() => ChooseDevice(null));
            }

            if (device == null)
            {
                opMon.Dispose();
                return(null);
            }

            if (!device.IsEmulator && MonoDroidFramework.CheckTrial())
            {
                opMon.Dispose();
                return(null);
            }

            //copture the device for a later anonymous method
            AndroidDevice dev = device;

            bool replaceIfExists = forceReplace || !GetUploadFlag(conf, device);

            var uploadOp = Upload(device, conf.ApkSignedPath, conf.PackageName, signOp, replaceIfExists);

            opMon.AddOperation(uploadOp);
            uploadOp.Completed += delegate(IAsyncOperation op) {
                if (op.Success)
                {
                    SetUploadFlag(conf, dev);
                }
                opMon.Dispose();
            };
            return(uploadOp);
        }
コード例 #14
0
        static MonoDroidUploadOperation Upload(AndroidDevice device, FilePath packageFile, string packageName,
                                               IAsyncOperation signingOperation, bool replaceIfExists)
        {
            var monitor = IdeApp.Workbench.ProgressMonitors.GetOutputProgressMonitor(
                GettextCatalog.GetString("Deploy to Device"), MonoDevelop.Ide.Gui.Stock.RunProgramIcon, true, true);

            var op = new MonoDroidUploadOperation(monitor, device, packageFile, packageName, signingOperation, replaceIfExists);

            op.Completed += delegate {
                monitor.Dispose();
            };
            op.Start();
            return(op);
        }
コード例 #15
0
 //simple flag used to determine whether the current binary has been uploaded to the device
 //we clear it before signing, and set it for each device after successful upload
 static bool GetUploadFlag(MonoDroidProjectConfiguration conf, AndroidDevice device)
 {
     try {
         var file = GetUploadFlagFileName(conf);
         if (File.Exists(file))
         {
             var deviceIds = File.ReadAllLines(file);
             return(deviceIds.Contains(device.ID));
         }
     } catch (Exception ex) {
         LoggingService.LogError("Error reading upload flag", ex);
     }
     return(true);
 }
コード例 #16
0
 static void SetUploadFlag(MonoDroidProjectConfiguration conf, AndroidDevice device)
 {
     try {
         var file = GetUploadFlagFileName(conf);
         if (!File.Exists(file))
         {
             File.WriteAllText(file, device.ID);
         }
         else
         {
             File.AppendAllText(file, "\n" + device.ID);
         }
     } catch (Exception ex) {
         LoggingService.LogError("Error setting upload flag", ex);
     }
 }
コード例 #17
0
        protected override void Run()
        {
            if (!MonoDroidFramework.EnsureSdksInstalled())
            {
                return;
            }

            var configSel = IdeApp.Workspace.ActiveConfiguration;
            var proj      = GetActiveExecutableMonoDroidProject();

            OperationHandler upload = delegate {
                using (var monitor = new MonoDevelop.Ide.ProgressMonitoring.MessageDialogProgressMonitor()) {
                    AndroidDevice device = null;

                    var conf     = (MonoDroidProjectConfiguration)proj.GetConfiguration(configSel);
                    var deviceId = proj.GetDeviceTarget(conf);
                    if (deviceId != null)
                    {
                        device = MonoDroidFramework.DeviceManager.GetDevice(deviceId);
                    }
                    if (device == null)
                    {
                        proj.SetDeviceTarget(conf, null);
                    }

                    MonoDroidUtility.SignAndUpload(monitor, proj, configSel, true, ref device);
                }
            };

            if (proj.NeedsBuilding(configSel))
            {
                IdeApp.ProjectOperations.Build(proj).Completed += upload;
            }
            else
            {
                upload(null);
            }
        }
コード例 #18
0
ファイル: DeviceManager.cs プロジェクト: thild/monodevelop
 void ClearTracking()
 {
     lock (lockObj) {
         if (op != null)
         {
             ((IDisposable)op).Dispose();
         }
         op = null;
         if (propTracker != null)
         {
             propTracker.Dispose();
         }
         propTracker = null;
         if (pop != null)
         {
             pop.Dispose();
         }
         pop           = null;
         Devices       = new AndroidDevice[0];
         lastForwarded = null;
         OnChanged(null, null);
     }
 }
コード例 #19
0
ファイル: AdbOperations.cs プロジェクト: kmarecki/monodevelop
		public AdbGetPackagesOperation (AndroidDevice device, string packageFileName) : base (device)
		{
			this.packageFileName = packageFileName;
			BeginConnect ();
		}
コード例 #20
0
        public IProcessAsyncOperation WaitForDevice(AndroidDevice device, TextWriter outputLog, TextWriter errorLog)
        {
            var args = string.Format("-s {0} wait-for-device", device.ID);

            return(StartProcess(AdbExe, args, outputLog, errorLog));
        }
コード例 #21
0
ファイル: AdbOperations.cs プロジェクト: kmarecki/monodevelop
		public AdbTrackLogOperation (AndroidDevice device, Action<string> output, params string [] parameters) : base (device)
		{
			if (output == null)
				throw new ArgumentNullException ("output");
			
			this.output = output;
			this.parameters = parameters;
			
			BeginConnect ();
		}
コード例 #22
0
ファイル: AndroidToolbox.cs プロジェクト: poke/monodevelop
		public AdbGetDateOperation GetDeviceDate (AndroidDevice device)
		{
			return new AdbGetDateOperation (device);
		}
コード例 #23
0
 public AdbShellOperation StartActivity(AndroidDevice device, string activity)
 {
     return(new AdbShellOperation(device,
                                  string.Format("am start -a android.intent.action.MAIN -n '{0}'", activity)));
 }
コード例 #24
0
		public AdbTrackLogOperation (AndroidDevice device, Action<string> output, params string [] parameters) : base (device)
		{
			this.output = output;
			this.parameters = parameters;
		}
コード例 #25
0
ファイル: AndroidToolbox.cs プロジェクト: poke/monodevelop
		public InstallPackageOperation Install (AndroidDevice device, string package, TextWriter outputLog, TextWriter errorLog)
		{
			var args = new ProcessArgumentBuilder ();
			args.Add ("-s", device.ID, "install");
			args.AddQuoted (package);
			
			var errorCapture = new StringWriter ();
			var errorWriter = TeeTextWriter.ForNonNull (errorCapture, errorCapture);
			return new InstallPackageOperation (StartProcess (AdbExe, args.ToString (), outputLog, errorWriter), errorCapture);
		}
コード例 #26
0
ファイル: AndroidToolbox.cs プロジェクト: poke/monodevelop
		public IProcessAsyncOperation WaitForDevice (AndroidDevice device, TextWriter outputLog, TextWriter errorLog)
		{
			var args = string.Format ("-s {0} wait-for-device", device.ID);
			return StartProcess (AdbExe, args, outputLog, errorLog);
		}
コード例 #27
0
 public AdbGetPackagesOperation(AndroidDevice device) : this(device, DefaultPackagesFile)
 {
 }
コード例 #28
0
ファイル: AndroidToolbox.cs プロジェクト: poke/monodevelop
		public ProcessWrapper LogCat (AndroidDevice device, ProcessEventHandler outputLog,
			ProcessEventHandler errorLog)
		{
			var args = string.Format ("-s {0} logcat", device.ID);
			return StartProcess (AdbExe, args, outputLog, errorLog);
		}
コード例 #29
0
		public AdbTransportOperation (AndroidDevice device)
		{
			this.device = device;
		}
コード例 #30
0
ファイル: AndroidToolbox.cs プロジェクト: poke/monodevelop
		public IProcessAsyncOperation ForwardPort (AndroidDevice device, int devicePort, int localPort,
			ProcessEventHandler outputLog, ProcessEventHandler errorLog)
		{
			var args = string.Format ("-s {0} forward tcp:{1} tcp:{2}", device.ID, localPort, devicePort);
			return StartProcess (AdbExe, args, outputLog, errorLog);
		}
コード例 #31
0
ファイル: AndroidToolbox.cs プロジェクト: poke/monodevelop
		public AdbShellOperation StartActivity (AndroidDevice device, string activity)
		{
			return new AdbShellOperation (device,
				string.Format ("am start -a android.intent.action.MAIN -n '{0}'", activity));
		}
コード例 #32
0
ファイル: AndroidToolbox.cs プロジェクト: poke/monodevelop
		public IProcessAsyncOperation Uninstall (AndroidDevice device, string package, TextWriter outputLog, TextWriter errorLog)
		{
			var args = new ProcessArgumentBuilder ();
			args.Add ("-s", device.ID, "uninstall");
			args.AddQuoted (package);
			
			return StartProcess (AdbExe, args.ToString (), outputLog, errorLog);
		}
コード例 #33
0
ファイル: AdbOperations.cs プロジェクト: kmarecki/monodevelop
		public AdbKillProcessOperation (AndroidDevice device, string packageName) : 
			base (device, "am broadcast -a mono.android.intent.action.SEPPUKU " +
				"-c mono.android.intent.category.SEPPUKU." + packageName)
		{
			BeginConnect ();
		}
コード例 #34
0
 public AdbGetPackagesOperation(AndroidDevice device, string packageFileName) : base(device)
 {
     this.packageFileName = packageFileName;
     BeginConnect();
 }
コード例 #35
0
ファイル: AdbOperations.cs プロジェクト: kmarecki/monodevelop
		public AdbGetPartitionSizeOperation (AndroidDevice device, string partition) : base (device, "df " + partition)
		{
			this.partition = partition;
			BeginConnect ();
		}
コード例 #36
0
 public AdbGetPropertiesOperation(AndroidDevice device) : base(device)
 {
     BeginConnect();
 }
コード例 #37
0
		public AdbGetPropertiesOperation (AndroidDevice device) : base (device) {}
コード例 #38
0
		public AdbShellOperation (AndroidDevice device, string command) : base (device)
		{
			this.command = command;
		}
コード例 #39
0
		//this should be a singleton created from MonoDroidFramework
		internal DeviceManager ()
		{
			Devices = new AndroidDevice[0];
		}
コード例 #40
0
ファイル: AndroidToolbox.cs プロジェクト: poke/monodevelop
		public AdbShellOperation SetProperty (AndroidDevice device, string property, string value)
		{
			if (property == null)
				throw new ArgumentNullException ("property");
			if (value == null)
				throw new ArgumentNullException ("value");
			
			return new AdbShellOperation (device, string.Format ("setprop \"{0}\" \"{1}\"", property, value));
		}
コード例 #41
0
		public MonoDroidExecutionHandler (AndroidDevice target)
		{
			this.DeviceTarget = target;
		}		
コード例 #42
0
 public AdbGetDateOperation(AndroidDevice device) : base(device, "date +%s")
 {
     BeginConnect();
 }
コード例 #43
0
        public MonoDroidUploadOperation(IProgressMonitor monitor, AndroidDevice device, FilePath packageFile, string packageName,
                                        IAsyncOperation signingOperation, bool replaceIfExists)
        {
            var         toolbox              = MonoDroidFramework.Toolbox;
            var         project              = DefaultUploadToDeviceHandler.GetActiveExecutableMonoDroidProject();
            var         conf                 = (MonoDroidProjectConfiguration)project.GetConfiguration(IdeApp.Workspace.ActiveConfiguration);
            int         apiLevel             = MonoDroidFramework.FrameworkVersionToApiLevel(project.TargetFramework.Id.Version);
            int         runtimeVersion       = MonoDroidFramework.GetRuntimeVersion();
            string      packagesListLocation = null;
            PackageList list                 = null;

            replaceIfExists = replaceIfExists || signingOperation != null;

            chop = new ChainedAsyncOperationSequence(monitor,
                                                     new ChainedAsyncOperation()
            {
                Skip         = () => MonoDroidFramework.DeviceManager.GetDeviceIsOnline(device.ID) ? "" : null,
                TaskName     = GettextCatalog.GetString("Waiting for device"),
                Create       = () => toolbox.WaitForDevice(device, monitor.Log, monitor.Log),
                Completed    = op => { DeviceNotFound = !op.Success; },
                ErrorMessage = GettextCatalog.GetString("Failed to get device")
            },
                                                     new ChainedAsyncOperation <AdbShellOperation> ()
            {
                TaskName  = GettextCatalog.GetString("Getting the package list location from device"),
                Create    = () => new AdbShellOperation(device, "ls /data/system/packages.xml"),
                Completed = op => {
                    string output = op.Output.Trim(new char [] { '\n', '\r' });
                    if (output == "/data/system/packages.xml")
                    {
                        packagesListLocation = output;
                    }
                    else
                    {
                        packagesListLocation = "/dbdata/system/packages.xml";
                    }
                }
            },
                                                     new ChainedAsyncOperation <AdbGetPackagesOperation> ()
            {
                TaskName     = GettextCatalog.GetString("Getting package list from device"),
                Create       = () => new AdbGetPackagesOperation(device, packagesListLocation),
                Completed    = op => list = op.PackageList,
                ErrorMessage = GettextCatalog.GetString("Failed to get package list")
            },
                                                     new ChainedAsyncOperation()
            {
                TaskName = GettextCatalog.GetString("Uninstalling old version of shared runtime package"),
                Skip     = () => !conf.AndroidUseSharedRuntime || list.GetOldRuntimesAndPlatforms(apiLevel, runtimeVersion).Count() == 0 ?
                           "" : null,
                Create = () => {                         // Cleanup task, no need to wait for it
                    foreach (InstalledPackage oldPackage in list.GetOldRuntimesAndPlatforms(apiLevel, runtimeVersion))
                    {
                        toolbox.Uninstall(device, oldPackage.Name, monitor.Log, monitor.Log);
                    }
                    return(Core.Execution.NullProcessAsyncOperation.Success);
                },
                ErrorMessage = GettextCatalog.GetString("Failed to uninstall package")
            },
                                                     new ChainedAsyncOperation()
            {
                TaskName = GettextCatalog.GetString("Installing shared runtime package on device"),
                Skip     = () => !conf.AndroidUseSharedRuntime || list.IsCurrentRuntimeInstalled(runtimeVersion) ?
                           "" : null,
                Create = () => {
                    var pkg = MonoDroidFramework.SharedRuntimePackage;
                    if (!File.Exists(pkg))
                    {
                        var msg = GettextCatalog.GetString("Could not find shared runtime package file");
                        monitor.ReportError(msg, null);
                        LoggingService.LogError("{0} '{1}'", msg, pkg);
                        return(null);
                    }
                    return(toolbox.Install(device, pkg, monitor.Log, monitor.Log));
                },
                ErrorMessage = GettextCatalog.GetString("Failed to install shared runtime package")
            },
                                                     new ChainedAsyncOperation()
            {
                TaskName = GettextCatalog.GetString("Installing the platform framework"),
                Skip     = () => !conf.AndroidUseSharedRuntime || list.IsCurrentPlatformInstalled(apiLevel, runtimeVersion) ?
                           "" : null,
                Create = () => {
                    var platformApk = MonoDroidFramework.GetPlatformPackage(apiLevel);
                    if (!File.Exists(platformApk))
                    {
                        var msg = GettextCatalog.GetString("Could not find platform package file");
                        monitor.ReportError(msg, null);
                        LoggingService.LogError("{0} '{1}'", msg, platformApk);
                        return(null);
                    }
                    return(toolbox.Install(device, platformApk, monitor.Log, monitor.Log));
                },
                ErrorMessage = GettextCatalog.GetString("Failed to install the platform framework")
            },
                                                     new ChainedAsyncOperation()
            {
                TaskName     = GettextCatalog.GetString("Uninstalling old version of package"),
                Skip         = () => (!replaceIfExists || !list.ContainsPackage(packageName))? "" : null,
                Create       = () => toolbox.Uninstall(device, packageName, monitor.Log, monitor.Log),
                ErrorMessage = GettextCatalog.GetString("Failed to uninstall package")
            },
                                                     new ChainedAsyncOperation()
            {
                TaskName     = GettextCatalog.GetString("Waiting for packaging signing to complete"),
                Skip         = () => (signingOperation == null || signingOperation.IsCompleted) ? "" : null,
                Create       = () => signingOperation,
                ErrorMessage = GettextCatalog.GetString("Package signing failed"),
            },
                                                     new ChainedAsyncOperation()
            {
                Skip = () => (list.ContainsPackage(packageName) && !replaceIfExists)
                                                ? GettextCatalog.GetString("Package is already up to date") : null,
                TaskName     = GettextCatalog.GetString("Installing package"),
                Create       = () => toolbox.Install(device, packageFile, monitor.Log, monitor.Log),
                ErrorMessage = GettextCatalog.GetString("Failed to install package")
            }
                                                     );
        }
コード例 #44
0
 public AdbGetPartitionSizeOperation(AndroidDevice device, string partition) : base(device, "df " + partition)
 {
     this.partition = partition;
     BeginConnect();
 }
コード例 #45
0
 public AdbGetDateOperation GetDeviceDate(AndroidDevice device)
 {
     return(new AdbGetDateOperation(device));
 }
コード例 #46
0
 public AdbBaseShellOperation(AndroidDevice device, string command) : base(device)
 {
     this.command = command;
 }
コード例 #47
0
ファイル: AdbOperations.cs プロジェクト: kmarecki/monodevelop
		public AdbGetPackagesOperation (AndroidDevice device) : this (device, DefaultPackagesFile)
		{
		}
コード例 #48
0
 public AdbShellOperation(AndroidDevice device, string command) : base(device, command)
 {
     BeginConnect();
 }
コード例 #49
0
ファイル: AdbOperations.cs プロジェクト: kmarecki/monodevelop
		public AdbGetPropertiesOperation (AndroidDevice device) : base (device)
		{
			BeginConnect ();
		}
コード例 #50
0
ファイル: MonoDroidProject.cs プロジェクト: thild/monodevelop
        protected override void OnExecute(IProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configSel)
        {
            var conf = (MonoDroidProjectConfiguration)GetConfiguration(configSel);

            IConsole console = null;
            var      opMon   = new AggregatedOperationMonitor(monitor);

            try {
                var  handler          = context.ExecutionHandler as MonoDroidExecutionHandler;
                bool useHandlerDevice = handler != null && handler.DeviceTarget != null;

                AndroidDevice device = null;

                if (useHandlerDevice)
                {
                    device = handler.DeviceTarget;
                }
                else
                {
                    var deviceId = GetDeviceTarget(conf);
                    if (deviceId != null)
                    {
                        device = MonoDroidFramework.DeviceManager.GetDevice(deviceId);
                    }
                    if (device == null)
                    {
                        SetDeviceTarget(conf, null);
                    }
                }

                var uploadOp = MonoDroidUtility.SignAndUpload(monitor, this, configSel, false, ref device);

                //user cancelled device selection
                if (device == null)
                {
                    return;
                }

                if (!device.IsEmulator && MonoDroidFramework.CheckTrial())
                {
                    return;
                }

                opMon.AddOperation(uploadOp);
                uploadOp.WaitForCompleted();

                if (!uploadOp.Success || monitor.IsCancelRequested)
                {
                    return;
                }

                //get the activity name after signing produced the final manifest
                string activity;
                if (!GetActivityNameFromManifest(monitor, conf, out activity))
                {
                    return;
                }

                //successful, persist the device choice
                if (!useHandlerDevice)
                {
                    SetDeviceTarget(conf, device.ID);
                }

                var command = (MonoDroidExecutionCommand)CreateExecutionCommand(configSel, conf);
                command.Device   = device;
                command.Activity = activity;

                //FIXME: would be nice to skip this if it's a debug handler, which will set another value later
                var propOp = MonoDroidFramework.Toolbox.SetProperty(device, "debug.mono.extra", string.Empty);
                opMon.AddOperation(propOp);
                propOp.WaitForCompleted();
                if (!propOp.Success)
                {
                    monitor.ReportError(GettextCatalog.GetString("Could not clear debug settings on device"),
                                        propOp.Error);
                    return;
                }

                console = context.ConsoleFactory.CreateConsole(false);
                var executeOp = context.ExecutionHandler.Execute(command, console);
                opMon.AddOperation(executeOp);
                executeOp.WaitForCompleted();
            } finally {
                opMon.Dispose();
                if (console != null)
                {
                    console.Dispose();
                }
            }
        }
コード例 #51
0
ファイル: AdbOperations.cs プロジェクト: kmarecki/monodevelop
		public AdbGetDateOperation (AndroidDevice device) : base (device, "date +%s")
		{
			BeginConnect ();
		}
コード例 #52
0
		public void SetDeviceTarget (MonoDroidProjectConfiguration conf, AndroidDevice value)
		{
			UserProperties.SetValue<AndroidDevice> (GetDeviceTargetKey (conf), value);
		}
コード例 #53
0
ファイル: AdbOperations.cs プロジェクト: kmarecki/monodevelop
		public AdbShellOperation (AndroidDevice device, string command) : base (device, command)
		{
			BeginConnect ();
		}
コード例 #54
0
		void ClearTracking ()
		{
			lock (lockObj) {
				if (op != null)
					((IDisposable)op).Dispose ();
				op = null;
				if (propTracker != null)
					propTracker.Dispose ();
				propTracker = null;
				Devices = new AndroidDevice[0];
				lastForwarded = null;
				OnChanged (null, null);
			}
		}
コード例 #55
0
		public AdbGetPackagesOperation (AndroidDevice device) : base (device) {}
コード例 #56
0
		void AsyncGetProperties (AndroidDevice device)
		{
			var gpop = new AdbGetPropertiesOperation (device);
			lock (outstandingQueries) {
				outstandingQueries.Add (gpop);
			}
			gpop.Completed += delegate (IAsyncOperation op) {
				lock (outstandingQueries) {
					if (disposed)
						return;
					outstandingQueries.Remove (gpop);
					gpop.Dispose ();
				}
				if (!op.Success) {
					LoggingService.LogError (string.Format ("Error getting properties from device '{0}'", device.ID), gpop.Error);
					//fall through, to cache the null result for failed queries
				}
				lock (props) {
					props [device.ID] = gpop.Properties	;
				}
				if (Changed != null)
					Changed ();
			};
		}
コード例 #57
0
		public AdbGetProcessIdOperation (AndroidDevice device, string packageName) :
			base (device)
		{
			if (packageName == null)
				throw new ArgumentNullException ("packageName");

			this.packageName = packageName;
		}
コード例 #58
0
ファイル: AndroidToolbox.cs プロジェクト: poke/monodevelop
		public IProcessAsyncOperation PullFile (AndroidDevice device, string source, string destination,
			TextWriter outputLog, TextWriter errorLog)
		{
			var args = new ProcessArgumentBuilder ();
			args.Add ("-s", device.ID, "pull");
			args.AddQuoted (source, destination);
			
			return StartProcess (AdbExe, args.ToString (), outputLog, errorLog);
		}
コード例 #59
0
		protected override void OnRun (DebuggerStartInfo startInfo)
		{
			var dsi = (MonoDroidDebuggerStartInfo) startInfo;
			var cmd = dsi.ExecutionCommand;
			debugDevice = cmd.Device;
			
			bool alreadyForwarded = MonoDroidFramework.DeviceManager.GetDeviceIsForwarded (cmd.Device.ID);
			if (!alreadyForwarded)
				MonoDroidFramework.DeviceManager.SetDeviceLastForwarded (null);
			
			long date = 0;
			int runningProcessId = 0; // Already running activity
			DateTime setPropertyTime = DateTime.MinValue;
			launchOp = new ChainedAsyncOperationSequence (
				new ChainedAsyncOperation<AndroidToolbox.GetDateOperation> () {
					Create = () => MonoDroidFramework.Toolbox.GetDeviceDate (cmd.Device),
					Completed = (op) => {
						if (op.Success) {
							date = op.Date;
							setPropertyTime = DateTime.Now;
						} else {
							this.OnDebuggerOutput (true, GettextCatalog.GetString ("Failed to get date from device"));
							this.OnDebuggerOutput (true, op.GetOutput ());
						}
					},
				},
				new ChainedAsyncOperation<AndroidToolbox.AdbOutputOperation> () {
					Create = () => {
						this.OnDebuggerOutput (false, GettextCatalog.GetString ("Setting debug property") + "\n");
						long expireDate = date + (DEBUGGER_TIMEOUT_MS / 1000);
						string monoOptions = string.Format ("debug={0}:{1}:{2},timeout={3},server=y", dsi.Address, dsi.DebugPort, 0, expireDate);
						return MonoDroidFramework.Toolbox.SetProperty (cmd.Device, "debug.mono.extra", monoOptions);
					},
					Completed = (op) => {
						if (!op.Success) {
							this.OnDebuggerOutput (true, GettextCatalog.GetString ("Failed to set debug property on device"));
							this.OnDebuggerOutput (true, op.GetOutput ());
						} else {
							debugPropertySet = true;
						}
					}
				},
				new ChainedAsyncOperation () {
					Skip = () => alreadyForwarded? "" : null,
					Create = () => {
						this.OnDebuggerOutput (false, GettextCatalog.GetString ("Forwarding debugger port") + "\n");
						return MonoDroidFramework.Toolbox.ForwardPort (cmd.Device, dsi.DebugPort, dsi.DebugPort, DebuggerOutput, DebuggerError);
					},
					Completed = (op) => {
						if (!op.Success) {
							this.OnDebuggerOutput (true, GettextCatalog.GetString ("Failed to forward port on device"));
						}
					}
				},
				new ChainedAsyncOperation () {
					Skip = () => alreadyForwarded? "" : null,
					Create = () => {
						this.OnDebuggerOutput (false, GettextCatalog.GetString ("Forwarding console port") + "\n");
						return MonoDroidFramework.Toolbox.ForwardPort (cmd.Device, dsi.OutputPort, dsi.OutputPort, DebuggerOutput, DebuggerError);
					},
					Completed = (op) => {
						if (!op.Success) {
							this.OnDebuggerOutput (true, GettextCatalog.GetString ("Failed to forward port on device"));
						} else {
							MonoDroidFramework.DeviceManager.SetDeviceLastForwarded (cmd.Device.ID);
						}
					}
				},
				new ChainedAsyncOperation<AdbGetProcessIdOperation> () {
					Create = () => new AdbGetProcessIdOperation (cmd.Device, cmd.PackageName),
					Completed = (op) => {
						if (!op.Success) {
							this.OnDebuggerOutput (true, "Error trying to detect already running process");
						} else if (op.ProcessId > 0) {
							this.OnDebuggerOutput (false, GettextCatalog.GetString ("Already running activity detected, restarting it in debug mode") + "\n");
							runningProcessId = op.ProcessId;
						}
					}
				},
				new ChainedAsyncOperation () {
					Skip = () => runningProcessId <= 0 ? "" : null,
					Create = () => new AdbShellOperation (cmd.Device, "kill " + runningProcessId),
					Completed = (op) => {
						if (!op.Success) {
							this.OnDebuggerOutput (true, GettextCatalog.GetString ("Failed to stop already running activity"));
						}
					}
				},
				new ChainedAsyncOperation () {
					Create = () => MonoDroidFramework.Toolbox.StartActivity (cmd.Device, cmd.Activity, DebuggerOutput, DebuggerError),
					Completed = (op) => {
						if (!op.Success)
							this.OnDebuggerOutput (true, GettextCatalog.GetString ("Failed to start activity"));
					}
				}
			);
			launchOp.Completed += delegate (IAsyncOperation op) {
				if (!op.Success) {
					EndSession ();
					return;
				}
				launchOp = null;
					
				Action<string> stdout = s => OnTargetOutput (false, s);
				Action<string> stderr = s => OnTargetOutput (true, s);

				trackProcessOp = new MonoDroidProcess (cmd.Device, cmd.Activity, cmd.PackageName, stdout, stderr);
				trackProcessOp.Completed += delegate {
					EndSession ();
				};
			
				System.Threading.Thread.Sleep (WAIT_BEFORE_CONNECT_MS);
				
				var msSinceSetProperty = (long) Math.Floor ((DateTime.Now - setPropertyTime).TotalMilliseconds);
				long msTillPropertyExpires = DEBUGGER_TIMEOUT_MS - msSinceSetProperty;
				
				if (msTillPropertyExpires < 100 || msTillPropertyExpires > DEBUGGER_TIMEOUT_MS)
					return;
				
				int retries = (int) Math.Floor ((double)  msTillPropertyExpires / WAIT_BEFORE_RETRY_MS) - 2;
				
				StartConnecting (dsi, retries, WAIT_BEFORE_RETRY_MS);
			};
			
			TargetExited += delegate {
				EndLaunch ();
			};
			
			launchOp.Start ();
		}
コード例 #60
0
 public AdbKillProcessOperation(AndroidDevice device, string packageName) :
     base(device, "am broadcast -a mono.android.intent.action.SEPPUKU " +
          "-c mono.android.intent.category.SEPPUKU." + packageName)
 {
     BeginConnect();
 }